
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 ca.uhn.fhir.interceptor.model.RequestPartitionId; 023 024import javax.persistence.Column; 025import javax.persistence.Entity; 026import javax.persistence.Id; 027import javax.persistence.Table; 028import javax.persistence.UniqueConstraint; 029 030@Entity 031@Table( 032 name = "HFJ_PARTITION", 033 uniqueConstraints = { 034 @UniqueConstraint( 035 name = "IDX_PART_NAME", 036 columnNames = {"PART_NAME"}) 037 }) 038public class PartitionEntity { 039 040 public static final int MAX_NAME_LENGTH = 200; 041 public static final int MAX_DESC_LENGTH = 200; 042 043 /** 044 * Note that unlike most PID columns in HAPI FHIR JPA, this one is an Integer, and isn't 045 * auto assigned. 046 */ 047 @Id 048 @Column(name = "PART_ID", nullable = false) 049 private Integer myId; 050 051 @Column(name = "PART_NAME", length = MAX_NAME_LENGTH, nullable = false) 052 private String myName; 053 054 @Column(name = "PART_DESC", length = MAX_DESC_LENGTH, nullable = true) 055 private String myDescription; 056 057 public Integer getId() { 058 return myId; 059 } 060 061 public PartitionEntity setId(Integer theId) { 062 myId = theId; 063 return this; 064 } 065 066 public String getName() { 067 return myName; 068 } 069 070 public PartitionEntity setName(String theName) { 071 myName = theName; 072 return this; 073 } 074 075 public String getDescription() { 076 return myDescription; 077 } 078 079 public void setDescription(String theDescription) { 080 myDescription = theDescription; 081 } 082 083 public RequestPartitionId toRequestPartitionId() { 084 return RequestPartitionId.fromPartitionIdAndName(getId(), getName()); 085 } 086}