View Javadoc
1   package ca.uhn.fhir.jpa.entity;
2   
3   /*
4    * #%L
5    * HAPI FHIR JPA Server
6    * %%
7    * Copyright (C) 2014 - 2018 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 java.io.Serializable;
24  
25  import javax.persistence.Column;
26  import javax.persistence.Entity;
27  import javax.persistence.ForeignKey;
28  import javax.persistence.GeneratedValue;
29  import javax.persistence.GenerationType;
30  import javax.persistence.Id;
31  import javax.persistence.JoinColumn;
32  import javax.persistence.ManyToOne;
33  import javax.persistence.SequenceGenerator;
34  import javax.persistence.Table;
35  import javax.persistence.UniqueConstraint;
36  
37  @Entity
38  @Table(name = "HFJ_SEARCH_RESULT", uniqueConstraints= {
39  	@UniqueConstraint(name="IDX_SEARCHRES_ORDER", columnNames= {"SEARCH_PID", "SEARCH_ORDER"})
40  })
41  public class SearchResult implements Serializable {
42  
43  	private static final long serialVersionUID = 1L;
44  
45  	@GeneratedValue(strategy = GenerationType.AUTO, generator="SEQ_SEARCH_RES")
46  	@SequenceGenerator(name="SEQ_SEARCH_RES", sequenceName="SEQ_SEARCH_RES")
47  	@Id
48  	@Column(name = "PID")
49  	private Long myId;
50  
51  	@Column(name="SEARCH_ORDER", nullable=false)
52  	private int myOrder;
53  	
54  	@ManyToOne
55  	@JoinColumn(name="RESOURCE_PID", referencedColumnName="RES_ID", foreignKey=@ForeignKey(name="FK_SEARCHRES_RES"), insertable=false, updatable=false, nullable=false)
56  	private ResourceTable myResource;
57  
58  	@Column(name="RESOURCE_PID", insertable=true, updatable=false, nullable=false)
59  	private Long myResourcePid;
60  
61  	@ManyToOne
62  	@JoinColumn(name="SEARCH_PID", referencedColumnName="PID", foreignKey=@ForeignKey(name="FK_SEARCHRES_SEARCH"))
63  	private Search mySearch;
64  
65  	@Column(name="SEARCH_PID", insertable=false, updatable=false, nullable=false)
66  	private Long mySearchPid;
67  
68  	/**
69  	 * Constructor
70  	 */
71  	public SearchResult() {
72  		// nothing
73  	}
74  
75  	/**
76  	 * Constructor
77  	 */
78  	public SearchResult(Search theSearch) {
79  		mySearch = theSearch;
80  	}
81  
82  	@Override
83  	public boolean equals(Object theObj) {
84  		if (!(theObj instanceof SearchResult)) {
85  			return false;
86  		}
87  		return myResourcePid.equals(((SearchResult)theObj).myResourcePid);
88  	}
89  
90  	public int getOrder() {
91  		return myOrder;
92  	}
93  	
94  	public Long getResourcePid() {
95  		return myResourcePid;
96  	}
97  	
98  	@Override
99  	public int hashCode() {
100 		return myResourcePid.hashCode();
101 	}
102 
103 	public void setOrder(int theOrder) {
104 		myOrder = theOrder;
105 	}
106 
107 	public SearchResult setResourcePid(Long theResourcePid) {
108 		myResourcePid = theResourcePid;
109 		return this;
110 	}
111 }