001package ca.uhn.fhir.jpa.model.entity;
002
003/*
004 * #%L
005 * HAPI FHIR JPA Model
006 * %%
007 * Copyright (C) 2014 - 2022 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import javax.persistence.Column;
024import javax.persistence.Embeddable;
025import javax.persistence.Entity;
026import javax.persistence.ForeignKey;
027import javax.persistence.GeneratedValue;
028import javax.persistence.GenerationType;
029import javax.persistence.Id;
030import javax.persistence.Index;
031import javax.persistence.JoinColumn;
032import javax.persistence.ManyToOne;
033import javax.persistence.SequenceGenerator;
034import javax.persistence.Table;
035import javax.persistence.UniqueConstraint;
036import java.io.Serializable;
037
038@Embeddable
039@Entity
040@Table(name = "HFJ_HISTORY_TAG", uniqueConstraints = {
041        @UniqueConstraint(name = "IDX_RESHISTTAG_TAGID", columnNames = {"RES_VER_PID", "TAG_ID"}),
042}, indexes =  {
043        @Index(name = "IDX_RESHISTTAG_RESID", columnList="RES_ID")
044})
045public class ResourceHistoryTag extends BaseTag implements Serializable {
046
047        private static final long serialVersionUID = 1L;
048
049        @SequenceGenerator(name = "SEQ_HISTORYTAG_ID", sequenceName = "SEQ_HISTORYTAG_ID")
050        @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_HISTORYTAG_ID")
051        @Id
052        @Column(name = "PID")
053        private Long myId;
054
055        @ManyToOne()
056        @JoinColumn(name = "RES_VER_PID", referencedColumnName = "PID", nullable = false, foreignKey = @ForeignKey(name = "FK_HISTORYTAG_HISTORY"))
057        private ResourceHistoryTable myResourceHistory;
058
059        @Column(name = "RES_VER_PID", insertable = false, updatable = false, nullable = false)
060        private Long myResourceHistoryPid;
061
062        @Column(name = "RES_TYPE", length = ResourceTable.RESTYPE_LEN, nullable = false)
063        private String myResourceType;
064
065        @Column(name = "RES_ID", nullable = false)
066        private Long myResourceId;
067
068        public ResourceHistoryTag() {
069        }
070
071
072        public ResourceHistoryTag(ResourceHistoryTable theResourceHistoryTable, TagDefinition theTag, PartitionablePartitionId theRequestPartitionId) {
073                setTag(theTag);
074                setResource(theResourceHistoryTable);
075                setResourceId(theResourceHistoryTable.getResourceId());
076                setResourceType(theResourceHistoryTable.getResourceType());
077                setPartitionId(theRequestPartitionId);
078        }
079
080        public String getResourceType() {
081                return myResourceType;
082        }
083
084        public void setResourceType(String theResourceType) {
085                myResourceType = theResourceType;
086        }
087
088        public Long getResourceId() {
089                return myResourceId;
090        }
091
092        public void setResourceId(Long theResourceId) {
093                myResourceId = theResourceId;
094        }
095
096        public ResourceHistoryTable getResourceHistory() {
097                return myResourceHistory;
098        }
099
100        public void setResource(ResourceHistoryTable theResourceHistory) {
101                myResourceHistory = theResourceHistory;
102        }
103
104        public Long getId() {
105                return myId;
106        }
107}