001/*- 002 * #%L 003 * HAPI FHIR JPA Model 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.model.entity; 021 022import ca.uhn.fhir.context.FhirVersionEnum; 023import jakarta.persistence.Column; 024import jakarta.persistence.Entity; 025import jakarta.persistence.EnumType; 026import jakarta.persistence.Enumerated; 027import jakarta.persistence.ForeignKey; 028import jakarta.persistence.GeneratedValue; 029import jakarta.persistence.GenerationType; 030import jakarta.persistence.Id; 031import jakarta.persistence.Index; 032import jakarta.persistence.JoinColumn; 033import jakarta.persistence.ManyToOne; 034import jakarta.persistence.SequenceGenerator; 035import jakarta.persistence.Table; 036import jakarta.persistence.Temporal; 037import jakarta.persistence.TemporalType; 038import jakarta.persistence.Version; 039import org.apache.commons.lang3.builder.ToStringBuilder; 040import org.apache.commons.lang3.builder.ToStringStyle; 041 042import java.util.Date; 043 044@Entity() 045@Table( 046 name = "NPM_PACKAGE_VER_RES", 047 indexes = { 048 @Index(name = "IDX_PACKVERRES_URL", columnList = "CANONICAL_URL"), 049 @Index(name = "FK_NPM_PACKVERRES_PACKVER", columnList = "PACKVER_PID"), 050 @Index(name = "FK_NPM_PKVR_RESID", columnList = "BINARY_RES_ID") 051 }) 052public class NpmPackageVersionResourceEntity { 053 054 @Id 055 @SequenceGenerator(name = "SEQ_NPM_PACKVERRES", sequenceName = "SEQ_NPM_PACKVERRES") 056 @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_NPM_PACKVERRES") 057 @Column(name = "PID") 058 private Long myId; 059 060 @ManyToOne 061 @JoinColumn( 062 name = "PACKVER_PID", 063 referencedColumnName = "PID", 064 foreignKey = @ForeignKey(name = "FK_NPM_PACKVERRES_PACKVER"), 065 nullable = false) 066 private NpmPackageVersionEntity myPackageVersion; 067 068 @ManyToOne 069 @JoinColumn( 070 name = "BINARY_RES_ID", 071 referencedColumnName = "RES_ID", 072 nullable = false, 073 foreignKey = @ForeignKey(name = "FK_NPM_PKVR_RESID")) 074 private ResourceTable myResourceBinary; 075 076 @Column(name = "FILE_DIR", length = 200) 077 private String myDirectory; 078 079 @Column(name = "FILE_NAME", length = 200) 080 private String myFilename; 081 082 @Column(name = "RES_TYPE", length = ResourceTable.RESTYPE_LEN, nullable = false) 083 private String myResourceType; 084 085 @Column(name = "CANONICAL_URL", length = 200) 086 private String myCanonicalUrl; 087 088 @Column(name = "CANONICAL_VERSION", length = 200) 089 private String myCanonicalVersion; 090 091 @Enumerated(EnumType.STRING) 092 @Column(name = "FHIR_VERSION", length = NpmPackageVersionEntity.FHIR_VERSION_LENGTH, nullable = false) 093 private FhirVersionEnum myFhirVersion; 094 095 @Column(name = "FHIR_VERSION_ID", length = NpmPackageVersionEntity.FHIR_VERSION_ID_LENGTH, nullable = false) 096 private String myFhirVersionId; 097 098 @Column(name = "RES_SIZE_BYTES", nullable = false) 099 private long myResSizeBytes; 100 101 @Temporal(TemporalType.TIMESTAMP) 102 @Version 103 @Column(name = "UPDATED_TIME", nullable = false) 104 private Date myVersion; 105 106 public long getResSizeBytes() { 107 return myResSizeBytes; 108 } 109 110 public void setResSizeBytes(long theResSizeBytes) { 111 myResSizeBytes = theResSizeBytes; 112 } 113 114 public String getCanonicalVersion() { 115 return myCanonicalVersion; 116 } 117 118 public void setCanonicalVersion(String theCanonicalVersion) { 119 myCanonicalVersion = theCanonicalVersion; 120 } 121 122 public ResourceTable getResourceBinary() { 123 return myResourceBinary; 124 } 125 126 public void setResourceBinary(ResourceTable theResourceBinary) { 127 myResourceBinary = theResourceBinary; 128 } 129 130 public String getFhirVersionId() { 131 return myFhirVersionId; 132 } 133 134 public void setFhirVersionId(String theFhirVersionId) { 135 myFhirVersionId = theFhirVersionId; 136 } 137 138 public FhirVersionEnum getFhirVersion() { 139 return myFhirVersion; 140 } 141 142 public void setFhirVersion(FhirVersionEnum theFhirVersion) { 143 myFhirVersion = theFhirVersion; 144 } 145 146 public void setPackageVersion(NpmPackageVersionEntity thePackageVersion) { 147 myPackageVersion = thePackageVersion; 148 } 149 150 public String getDirectory() { 151 return myDirectory; 152 } 153 154 public void setDirectory(String theDirectory) { 155 myDirectory = theDirectory; 156 } 157 158 public String getFilename() { 159 return myFilename; 160 } 161 162 public void setFilename(String theFilename) { 163 myFilename = theFilename; 164 } 165 166 public String getResourceType() { 167 return myResourceType; 168 } 169 170 public void setResourceType(String theResourceType) { 171 myResourceType = theResourceType; 172 } 173 174 public String getCanonicalUrl() { 175 return myCanonicalUrl; 176 } 177 178 public void setCanonicalUrl(String theCanonicalUrl) { 179 myCanonicalUrl = theCanonicalUrl; 180 } 181 182 @Override 183 public String toString() { 184 185 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) 186 .append("myId", myId) 187 .append("myCanonicalUrl", myCanonicalUrl) 188 .append("myCanonicalVersion", myCanonicalVersion) 189 .append("myResourceType", myResourceType) 190 .append("myDirectory", myDirectory) 191 .append("myFilename", myFilename) 192 .append("myPackageVersion", myPackageVersion) 193 .append("myResSizeBytes", myResSizeBytes) 194 .append("myVersion", myVersion) 195 .toString(); 196 } 197}