001/** 002 * Copyright 2005-2015 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.data.jpa.testbo; 017 018import java.io.Serializable; 019import java.util.Date; 020import java.util.List; 021 022import javax.persistence.CascadeType; 023import javax.persistence.Column; 024import javax.persistence.Convert; 025import javax.persistence.Entity; 026import javax.persistence.FetchType; 027import javax.persistence.Id; 028import javax.persistence.JoinColumn; 029import javax.persistence.JoinColumns; 030import javax.persistence.JoinTable; 031import javax.persistence.ManyToMany; 032import javax.persistence.ManyToOne; 033import javax.persistence.OneToMany; 034import javax.persistence.OneToOne; 035import javax.persistence.OrderBy; 036import javax.persistence.PrimaryKeyJoinColumn; 037import javax.persistence.Table; 038import javax.persistence.Temporal; 039import javax.persistence.TemporalType; 040import javax.persistence.Transient; 041import javax.validation.constraints.DecimalMin; 042import javax.validation.constraints.Digits; 043import javax.validation.constraints.NotNull; 044 045import org.eclipse.persistence.annotations.JoinFetch; 046import org.eclipse.persistence.annotations.JoinFetchType; 047import org.kuali.rice.core.api.util.type.KualiDecimal; 048import org.kuali.rice.krad.data.jpa.converters.EncryptionConverter; 049import org.kuali.rice.krad.data.provider.annotation.AttributeRelationship; 050import org.kuali.rice.krad.data.provider.annotation.CollectionRelationship; 051import org.kuali.rice.krad.data.provider.annotation.ForceUppercase; 052import org.kuali.rice.krad.data.provider.annotation.InheritProperties; 053import org.kuali.rice.krad.data.provider.annotation.InheritProperty; 054import org.kuali.rice.krad.data.provider.annotation.Label; 055import org.kuali.rice.krad.data.provider.annotation.NonPersistentProperty; 056import org.kuali.rice.krad.data.provider.annotation.ReadOnly; 057 058@Entity 059@Table(name = "KRTST_TEST_TABLE_T") 060@Label("Label From Annotation") 061public class TestDataObject implements Serializable { 062 private static final long serialVersionUID = 1L; 063 064 @Id 065 @Column(name = "PK_PROP") 066 @ForceUppercase 067 String primaryKeyProperty; 068 069 @Column(name = "STR_PROP", length = 40) 070 @Label("Attribute Label From Annotation") 071 @NotNull 072 String stringProperty; 073 074 @Column(name = "LONG_STR_PROP", length = 200) 075 String longStringProperty; 076 077 @Temporal(TemporalType.DATE) 078 @Column(name = "DATE_PROP") 079 Date dateProperty; 080 @Column(name = "CURR_PROP") 081 @Digits( 082 integer = 10, 083 fraction = 2) 084 @DecimalMin( 085 value = "0.00", 086 message = "The currency amount may not be less than zero.") 087 KualiDecimal currencyProperty; 088 @Column(name = "NON_STANDARD") 089 // @Convert( 090 // converter = NonStandardDataTypeConverter.class) 091 NonStandardDataType nonStandardDataType; 092 093 // DON'T MOVE THIS - WE ARE TESTING ORDERING OF PROPERTIES 094 @ManyToOne( 095 fetch = FetchType.LAZY, 096 cascade = CascadeType.REFRESH) 097 @JoinColumn( 098 name = "STR_PROP", 099 insertable = false, 100 updatable = false) 101 @InheritProperty( 102 name = "someOtherStringProperty") 103 ReferencedDataObject referencedObject; 104 105 @Column(name="BOOL_PROP") 106 // @Convert("YN_BooleanConverter") 107 Boolean booleanProperty; 108 109 @Transient 110 String nonPersistedProperty; 111 112 @Convert( 113 converter = EncryptionConverter.class) 114 @Column( 115 name = "ENCR_PROP") 116 String encryptedProperty; 117 118 @Column( 119 name = "RO_PROP") 120 @ReadOnly 121 String readOnlyProperty; 122 123 @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) 124 @OrderBy("collectionKeyProperty ASC") 125 @JoinColumn( 126 name = "PK_PROP", 127 referencedColumnName = "STR_PROP") 128 List<CollectionDataObject> collectionProperty; 129 130 @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH) 131 @OrderBy("collectionKeyProperty ASC") 132 @JoinColumn( 133 name = "PK_PROP", 134 referencedColumnName = "STR_PROP") 135 List<CollectionDataObjectTwo> collectionPropertyTwo; 136 137 @OneToMany(cascade = CascadeType.ALL, mappedBy = "testDataObject") 138 List<CollectionDataObjectThree> collectionPropertyThree; 139 140 @CollectionRelationship( 141 attributeRelationships = @AttributeRelationship( 142 parentAttributeName = "dateProperty", 143 childAttributeName = "collectionDateProperty")) 144 List<SomeOtherCollection> someOtherCollection; 145 146 @ManyToMany 147 @JoinTable( 148 name = "KRDATA_TEST_INDIR_LINK_T", 149 joinColumns = @JoinColumn( 150 name = "PK_PROP", 151 referencedColumnName = "COLL_PK_PROP"), 152 inverseJoinColumns = @JoinColumn( 153 name = "COLL_PK_PROP", 154 referencedColumnName = "PK_PROP")) 155 List<IndirectlyLinkedCollectionDataObject> indirectCollection; 156 157 @ManyToOne( 158 fetch = FetchType.EAGER, 159 cascade = CascadeType.REFRESH) 160 @JoinColumns({ @JoinColumn( 161 name = "STR_PROP", 162 referencedColumnName = "STR_PROP", 163 insertable = false, 164 updatable = false), @JoinColumn( 165 name = "DATE_PROP", 166 referencedColumnName = "DATE_PROP", 167 insertable = false, 168 updatable = false) }) 169 @InheritProperties({ @InheritProperty( 170 name = "someOtherStringProperty", 171 label = @Label("Overridden Inherited Property Label")) }) 172 AnotherReferencedDataObject anotherReferencedObject; 173 174 @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) 175 @JoinFetch(JoinFetchType.OUTER) 176 @PrimaryKeyJoinColumn 177 YetAnotherReferencedDataObject yetAnotherReferencedObject; 178 179 @Transient 180 Object extension; 181 182 @NonPersistentProperty 183 @Label("Test Data Object") 184 public String getKeyAndString() { 185 return primaryKeyProperty + "-" + stringProperty; 186 } 187 188 public List<CollectionDataObject> getCollectionProperty() { 189 return collectionProperty; 190 } 191 192 public void setCollectionProperty(List<CollectionDataObject> collectionProperty) { 193 this.collectionProperty = collectionProperty; 194 } 195 196 public String getStringProperty() { 197 return stringProperty; 198 } 199 200 public void setStringProperty(String stringProperty) { 201 this.stringProperty = stringProperty; 202 } 203 204 public String getPrimaryKeyProperty() { 205 return primaryKeyProperty; 206 } 207 208 public void setPrimaryKeyProperty(String primaryKeyProperty) { 209 this.primaryKeyProperty = primaryKeyProperty; 210 } 211 212 public Date getDateProperty() { 213 return dateProperty; 214 } 215 216 public void setDateProperty(Date dateProperty) { 217 this.dateProperty = dateProperty; 218 } 219 220 public KualiDecimal getCurrencyProperty() { 221 return currencyProperty; 222 } 223 224 public void setCurrencyProperty(KualiDecimal currencyProperty) { 225 this.currencyProperty = currencyProperty; 226 } 227 228 public List<CollectionDataObjectTwo> getCollectionPropertyTwo() { 229 return collectionPropertyTwo; 230 } 231 232 public void setCollectionPropertyTwo(List<CollectionDataObjectTwo> collectionPropertyTwo) { 233 this.collectionPropertyTwo = collectionPropertyTwo; 234 } 235 236 public ReferencedDataObject getReferencedObject() { 237 return referencedObject; 238 } 239 240 public void setReferencedObject(ReferencedDataObject referencedObject) { 241 this.referencedObject = referencedObject; 242 } 243 244 public NonStandardDataType getNonStandardDataType() { 245 return nonStandardDataType; 246 } 247 248 public void setNonStandardDataType(NonStandardDataType nonStandardDataType) { 249 this.nonStandardDataType = nonStandardDataType; 250 } 251 252 public List<IndirectlyLinkedCollectionDataObject> getIndirectCollection() { 253 return indirectCollection; 254 } 255 256 public void setIndirectCollection(List<IndirectlyLinkedCollectionDataObject> indirectCollection) { 257 this.indirectCollection = indirectCollection; 258 } 259 260 public String getNonPersistedProperty() { 261 return nonPersistedProperty; 262 } 263 264 public void setNonPersistedProperty(String nonPersistedProperty) { 265 this.nonPersistedProperty = nonPersistedProperty; 266 } 267 268 public AnotherReferencedDataObject getAnotherReferencedObject() { 269 return anotherReferencedObject; 270 } 271 272 public void setAnotherReferencedObject(AnotherReferencedDataObject anotherReferencedObject) { 273 this.anotherReferencedObject = anotherReferencedObject; 274 } 275 276 public YetAnotherReferencedDataObject getYetAnotherReferencedObject() { 277 return yetAnotherReferencedObject; 278 } 279 280 public void setYetAnotherReferencedObject(YetAnotherReferencedDataObject yetAnotherReferencedObject) { 281 this.yetAnotherReferencedObject = yetAnotherReferencedObject; 282 } 283 284 public String getLongStringProperty() { 285 return longStringProperty; 286 } 287 288 public void setLongStringProperty(String longStringProperty) { 289 this.longStringProperty = longStringProperty; 290 } 291 292 public boolean isBooleanProperty() { 293 return booleanProperty; 294 } 295 296 public void setBooleanProperty(boolean booleanProperty) { 297 this.booleanProperty = booleanProperty; 298 } 299 300 public String getEncryptedProperty() { 301 return encryptedProperty; 302 } 303 304 public void setEncryptedProperty(String encryptedProperty) { 305 this.encryptedProperty = encryptedProperty; 306 } 307 308 public String getReadOnlyProperty() { 309 return readOnlyProperty; 310 } 311 312 public void setReadOnlyProperty(String readOnlyProperty) { 313 this.readOnlyProperty = readOnlyProperty; 314 } 315 316 public List<SomeOtherCollection> getSomeOtherCollection() { 317 return someOtherCollection; 318 } 319 320 public void setSomeOtherCollection(List<SomeOtherCollection> someOtherCollection) { 321 this.someOtherCollection = someOtherCollection; 322 } 323 324 public List<CollectionDataObjectThree> getCollectionPropertyThree() { 325 return collectionPropertyThree; 326 } 327 328 public void setCollectionPropertyThree(List<CollectionDataObjectThree> collectionPropertyThree) { 329 this.collectionPropertyThree = collectionPropertyThree; 330 } 331 332 public Object getExtension() { 333 return extension; 334 } 335 336 public void setExtension(Object extension) { 337 this.extension = extension; 338 } 339 340}