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.Entity;
025import javax.persistence.Id;
026import javax.persistence.Lob;
027import javax.persistence.Table;
028import javax.persistence.Temporal;
029import javax.persistence.TemporalType;
030import java.sql.Blob;
031import java.util.Date;
032
033@Entity
034@Table(name = "HFJ_BINARY_STORAGE_BLOB")
035public class BinaryStorageEntity {
036
037        @Id
038        @Column(name = "BLOB_ID", length = 200, nullable = false)
039        //N.B GGG: Note that the `blob id` is the same as the `externalized binary id`.
040        private String myBlobId;
041        @Column(name = "RESOURCE_ID", length = 100, nullable = false)
042        private String myResourceId;
043        @Column(name = "BLOB_SIZE", nullable = true)
044        private int mySize;
045        @Column(name = "CONTENT_TYPE", nullable = false, length = 100)
046        private String myBlobContentType;
047        @Lob
048        @Column(name = "BLOB_DATA", nullable = false, insertable = true, updatable = false)
049        private Blob myBlob;
050        @Temporal(TemporalType.TIMESTAMP)
051        @Column(name = "PUBLISHED_DATE", nullable = false)
052        private Date myPublished;
053        @Column(name = "BLOB_HASH", length = 128, nullable = true)
054        private String myHash;
055
056        public Date getPublished() {
057                return new Date(myPublished.getTime());
058        }
059
060        public void setPublished(Date thePublishedDate) {
061                myPublished = thePublishedDate;
062        }
063
064        public String getHash() {
065                return myHash;
066        }
067
068        public void setBlobId(String theBlobId) {
069                myBlobId = theBlobId;
070        }
071
072        public void setResourceId(String theResourceId) {
073                myResourceId = theResourceId;
074        }
075
076        public int getSize() {
077                return mySize;
078        }
079
080        public String getBlobContentType() {
081                return myBlobContentType;
082        }
083
084        public void setBlobContentType(String theBlobContentType) {
085                myBlobContentType = theBlobContentType;
086        }
087
088        public Blob getBlob() {
089                return myBlob;
090        }
091
092        public void setBlob(Blob theBlob) {
093                myBlob = theBlob;
094        }
095
096        public String getBlobId() {
097                return myBlobId;
098        }
099
100        public void setSize(int theSize) {
101                mySize = theSize;
102        }
103
104        public void setHash(String theHash) {
105                myHash = theHash;
106        }
107}