View Javadoc
1   package ca.uhn.fhir.jpa.entity;
2   
3   /*
4    * #%L
5    * HAPI FHIR JPA Server
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   * http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import org.apache.commons.lang3.builder.ToStringBuilder;
24  import org.apache.commons.lang3.builder.ToStringStyle;
25  import org.hibernate.validator.constraints.NotBlank;
26  
27  import javax.persistence.*;
28  import java.io.Serializable;
29  
30  @Entity
31  @Table(name = "TRM_CONCEPT_PROPERTY", uniqueConstraints = {
32  }, indexes = {
33  })
34  public class TermConceptProperty implements Serializable {
35  
36  	static final int MAX_PROPTYPE_ENUM_LENGTH = 6;
37  	private static final long serialVersionUID = 1L;
38  	@ManyToOne
39  	@JoinColumn(name = "CONCEPT_PID", referencedColumnName = "PID", foreignKey = @ForeignKey(name = "FK_CONCEPTPROP_CONCEPT"))
40  	private TermConcept myConcept;
41  	@Id()
42  	@SequenceGenerator(name = "SEQ_CONCEPT_PROP_PID", sequenceName = "SEQ_CONCEPT_PROP_PID")
43  	@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_CONCEPT_PROP_PID")
44  	@Column(name = "PID")
45  	private Long myId;
46  	@Column(name = "PROP_KEY", length = 500, nullable = false)
47  	@NotBlank
48  	private String myKey;
49  	@Column(name = "PROP_VAL", length = 500, nullable = true)
50  	private String myValue;
51  	@Column(name = "PROP_TYPE", length = MAX_PROPTYPE_ENUM_LENGTH, nullable = false)
52  	private TermConceptPropertyTypeEnum myType;
53  	/**
54  	 * Relevant only for properties of type {@link TermConceptPropertyTypeEnum#CODING}
55  	 */
56  	@Column(name = "PROP_CODESYSTEM", length = 500, nullable = true)
57  	private String myCodeSystem;
58  	/**
59  	 * Relevant only for properties of type {@link TermConceptPropertyTypeEnum#CODING}
60  	 */
61  	@Column(name = "PROP_DISPLAY", length = 500, nullable = true)
62  	private String myDisplay;
63  
64  	/**
65  	 * Relevant only for properties of type {@link TermConceptPropertyTypeEnum#CODING}
66  	 */
67  	public String getCodeSystem() {
68  		return myCodeSystem;
69  	}
70  
71  	/**
72  	 * Relevant only for properties of type {@link TermConceptPropertyTypeEnum#CODING}
73  	 */
74  	public TermConceptProperty setCodeSystem(String theCodeSystem) {
75  		myCodeSystem = theCodeSystem;
76  		return this;
77  	}
78  
79  	/**
80  	 * Relevant only for properties of type {@link TermConceptPropertyTypeEnum#CODING}
81  	 */
82  	public String getDisplay() {
83  		return myDisplay;
84  	}
85  
86  	/**
87  	 * Relevant only for properties of type {@link TermConceptPropertyTypeEnum#CODING}
88  	 */
89  	public TermConceptProperty setDisplay(String theDisplay) {
90  		myDisplay = theDisplay;
91  		return this;
92  	}
93  
94  	public String getKey() {
95  		return myKey;
96  	}
97  
98  	public void setKey(String theKey) {
99  		myKey = theKey;
100 	}
101 
102 	public TermConceptPropertyTypeEnum getType() {
103 		return myType;
104 	}
105 
106 	public TermConceptProperty setType(TermConceptPropertyTypeEnum theType) {
107 		myType = theType;
108 		return this;
109 	}
110 
111 	/**
112 	 * This will contain the value for a {@link TermConceptPropertyTypeEnum#STRING string}
113 	 * property, and the code for a {@link TermConceptPropertyTypeEnum#CODING coding} property.
114 	 */
115 	public String getValue() {
116 		return myValue;
117 	}
118 
119 	/**
120 	 * This will contain the value for a {@link TermConceptPropertyTypeEnum#STRING string}
121 	 * property, and the code for a {@link TermConceptPropertyTypeEnum#CODING coding} property.
122 	 */
123 	public void setValue(String theValue) {
124 		myValue = theValue;
125 	}
126 
127 	public void setConcept(TermConcept theConcept) {
128 		myConcept = theConcept;
129 	}
130 
131 	@Override
132 	public String toString() {
133 		return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
134 			.append("key", myKey)
135 			.append("value", myValue)
136 			.toString();
137 	}
138 
139 }