
001/* 002 * #%L 003 * HAPI FHIR JPA Server 004 * %% 005 * Copyright (C) 2014 - 2023 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.jpa.entity; 021 022import java.io.Serializable; 023import javax.persistence.Column; 024import javax.persistence.Entity; 025import javax.persistence.ForeignKey; 026import javax.persistence.GeneratedValue; 027import javax.persistence.GenerationType; 028import javax.persistence.Id; 029import javax.persistence.Index; 030import javax.persistence.JoinColumn; 031import javax.persistence.ManyToOne; 032import javax.persistence.SequenceGenerator; 033import javax.persistence.Table; 034 035// @formatter:off 036@Entity 037@Table( 038 name = "HFJ_SEARCH_INCLUDE", 039 indexes = {@Index(name = "FK_SEARCHINC_SEARCH", columnList = "SEARCH_PID")}) 040// @formatter:on 041public class SearchInclude implements Serializable { 042 043 private static final long serialVersionUID = 1L; 044 045 @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_SEARCH_INC") 046 @SequenceGenerator(name = "SEQ_SEARCH_INC", sequenceName = "SEQ_SEARCH_INC") 047 @Id 048 @Column(name = "PID") 049 private Long myId; 050 051 @Column(name = "REVINCLUDE", insertable = true, updatable = false, nullable = false) 052 private boolean myReverse; 053 054 public boolean isReverse() { 055 return myReverse; 056 } 057 058 @Column(name = "SEARCH_INCLUDE", length = 200, insertable = true, updatable = false, nullable = false) 059 private String myInclude; 060 061 @ManyToOne 062 @JoinColumn( 063 name = "SEARCH_PID", 064 referencedColumnName = "PID", 065 foreignKey = @ForeignKey(name = "FK_SEARCHINC_SEARCH"), 066 insertable = true, 067 updatable = false, 068 nullable = false) 069 private Search mySearch; 070 071 @Column(name = "SEARCH_PID", insertable = false, updatable = false, nullable = false) 072 private Long mySearchPid; 073 074 @Column(name = "INC_RECURSE", insertable = true, updatable = false, nullable = false) 075 private boolean myRecurse; 076 077 /** 078 * Constructor 079 */ 080 public SearchInclude() { 081 // nothing 082 } 083 084 /** 085 * Constructor 086 */ 087 public SearchInclude(Search theSearch, String theInclude, boolean theReverse, boolean theRecurse) { 088 mySearch = theSearch; 089 myInclude = theInclude; 090 myReverse = theReverse; 091 myRecurse = theRecurse; 092 } 093 094 @Override 095 public boolean equals(Object theObj) { 096 if (!(theObj instanceof SearchInclude)) { 097 return false; 098 } 099 if (myId == null) { 100 return false; 101 } 102 return myId.equals(((SearchInclude) theObj).myId); 103 } 104 105 public String getInclude() { 106 return myInclude; 107 } 108 109 @Override 110 public int hashCode() { 111 return myId == null ? 0 : myId.hashCode(); 112 } 113 114 public boolean isRecurse() { 115 return myRecurse; 116 } 117}