View Javadoc
1   package ca.uhn.fhir.jpa.entity;
2   
3   /*
4    * #%L
5    * HAPI FHIR JPA Server
6    * %%
7    * Copyright (C) 2014 - 2019 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   *
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   *
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import ca.uhn.fhir.rest.api.Constants;
24  import com.google.common.annotations.VisibleForTesting;
25  import org.apache.commons.lang3.builder.ToStringBuilder;
26  import org.apache.commons.lang3.builder.ToStringStyle;
27  
28  import javax.persistence.*;
29  import java.io.Serializable;
30  import java.util.Date;
31  
32  @Entity
33  @Table(name = "HFJ_RES_REINDEX_JOB")
34  public class ResourceReindexJobEntity implements Serializable {
35  	@Id
36  	@SequenceGenerator(name = "SEQ_RES_REINDEX_JOB", sequenceName = "SEQ_RES_REINDEX_JOB")
37  	@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_RES_REINDEX_JOB")
38  	@Column(name = "PID")
39  	private Long myId;
40  	@Column(name = "RES_TYPE", nullable = true, length = Constants.MAX_RESOURCE_NAME_LENGTH)
41  	private String myResourceType;
42  	/**
43  	 * Inclusive
44  	 */
45  	@Column(name = "UPDATE_THRESHOLD_HIGH", nullable = false)
46  	@Temporal(TemporalType.TIMESTAMP)
47  	private Date myThresholdHigh;
48  	@Column(name = "JOB_DELETED", nullable = false)
49  	private boolean myDeleted;
50  	/**
51  	 * Inclusive
52  	 */
53  	@Column(name = "UPDATE_THRESHOLD_LOW", nullable = true)
54  	@Temporal(TemporalType.TIMESTAMP)
55  	private Date myThresholdLow;
56  	@Column(name = "SUSPENDED_UNTIL", nullable = true)
57  	@Temporal(TemporalType.TIMESTAMP)
58  	private Date mySuspendedUntil;
59  	@Column(name = "REINDEX_COUNT", nullable = true)
60  	private Integer myReindexCount;
61  
62  	public Integer getReindexCount() {
63  		return myReindexCount;
64  	}
65  
66  	public void setReindexCount(Integer theReindexCount) {
67  		myReindexCount = theReindexCount;
68  	}
69  
70  	public Date getSuspendedUntil() {
71  		return mySuspendedUntil;
72  	}
73  
74  	public void setSuspendedUntil(Date theSuspendedUntil) {
75  		mySuspendedUntil = theSuspendedUntil;
76  	}
77  
78  	/**
79  	 * Inclusive
80  	 */
81  	public Date getThresholdLow() {
82  		Date retVal = myThresholdLow;
83  		if (retVal != null) {
84  			retVal = new Date(retVal.getTime());
85  		}
86  		return retVal;
87  	}
88  
89  	/**
90  	 * Inclusive
91  	 */
92  	public void setThresholdLow(Date theThresholdLow) {
93  		myThresholdLow = theThresholdLow;
94  	}
95  
96  	public String getResourceType() {
97  		return myResourceType;
98  	}
99  
100 	public void setResourceType(String theResourceType) {
101 		myResourceType = theResourceType;
102 	}
103 
104 	/**
105 	 * Inclusive
106 	 */
107 	public Date getThresholdHigh() {
108 		Date retVal = myThresholdHigh;
109 		if (retVal != null) {
110 			retVal = new Date(retVal.getTime());
111 		}
112 		return retVal;
113 	}
114 
115 	/**
116 	 * Inclusive
117 	 */
118 	public void setThresholdHigh(Date theThresholdHigh) {
119 		myThresholdHigh = theThresholdHigh;
120 	}
121 
122 	public Long getId() {
123 		return myId;
124 	}
125 
126 	@VisibleForTesting
127 	public void setIdForUnitTest(long theId) {
128 		myId = theId;
129 	}
130 
131 	public void setDeleted(boolean theDeleted) {
132 		myDeleted = theDeleted;
133 	}
134 
135 	@Override
136 	public String toString() {
137 		ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
138 			.append("id", myId)
139 			.append("resourceType", myResourceType)
140 			.append("thresholdLow", myThresholdLow)
141 			.append("thresholdHigh", myThresholdHigh);
142 		if (myDeleted) {
143 			b.append("deleted", myDeleted);
144 		}
145 		if (mySuspendedUntil != null) {
146 			b.append("suspendedUntil", mySuspendedUntil);
147 		}
148 		return b.toString();
149 	}
150 }