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