001/* 002 * #%L 003 * HAPI FHIR JPA Server 004 * %% 005 * Copyright (C) 2014 - 2024 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 jakarta.persistence.Column; 023import jakarta.persistence.Entity; 024import jakarta.persistence.ForeignKey; 025import jakarta.persistence.GeneratedValue; 026import jakarta.persistence.GenerationType; 027import jakarta.persistence.Id; 028import jakarta.persistence.Index; 029import jakarta.persistence.JoinColumn; 030import jakarta.persistence.ManyToOne; 031import jakarta.persistence.SequenceGenerator; 032import jakarta.persistence.Table; 033 034import java.io.Serializable; 035 036// @formatter:off 037@Entity 038@Table( 039 name = "HFJ_SEARCH_INCLUDE", 040 indexes = {@Index(name = "FK_SEARCHINC_SEARCH", columnList = "SEARCH_PID")}) 041// @formatter:on 042public class SearchInclude implements Serializable { 043 044 private static final long serialVersionUID = 1L; 045 046 @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_SEARCH_INC") 047 @SequenceGenerator(name = "SEQ_SEARCH_INC", sequenceName = "SEQ_SEARCH_INC") 048 @Id 049 @Column(name = "PID") 050 private Long myId; 051 052 @Column(name = "REVINCLUDE", insertable = true, updatable = false, nullable = false) 053 private boolean myReverse; 054 055 public boolean isReverse() { 056 return myReverse; 057 } 058 059 @Column(name = "SEARCH_INCLUDE", length = 200, insertable = true, updatable = false, nullable = false) 060 private String myInclude; 061 062 @ManyToOne 063 @JoinColumn( 064 name = "SEARCH_PID", 065 referencedColumnName = "PID", 066 foreignKey = @ForeignKey(name = "FK_SEARCHINC_SEARCH"), 067 insertable = true, 068 updatable = false, 069 nullable = false) 070 private Search mySearch; 071 072 @Column(name = "SEARCH_PID", insertable = false, updatable = false, nullable = false) 073 private Long mySearchPid; 074 075 @Column(name = "INC_RECURSE", insertable = true, updatable = false, nullable = false) 076 private boolean myRecurse; 077 078 /** 079 * Constructor 080 */ 081 public SearchInclude() { 082 // nothing 083 } 084 085 /** 086 * Constructor 087 */ 088 public SearchInclude(Search theSearch, String theInclude, boolean theReverse, boolean theRecurse) { 089 mySearch = theSearch; 090 myInclude = theInclude; 091 myReverse = theReverse; 092 myRecurse = theRecurse; 093 } 094 095 @Override 096 public boolean equals(Object theObj) { 097 if (!(theObj instanceof SearchInclude)) { 098 return false; 099 } 100 if (myId == null) { 101 return false; 102 } 103 return myId.equals(((SearchInclude) theObj).myId); 104 } 105 106 public String getInclude() { 107 return myInclude; 108 } 109 110 @Override 111 public int hashCode() { 112 return myId == null ? 0 : myId.hashCode(); 113 } 114 115 public boolean isRecurse() { 116 return myRecurse; 117 } 118}