001/** 002 * Copyright 2005-2017 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.krms.impl.repository; 017 018import org.kuali.rice.core.api.mo.common.Versioned; 019import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter; 020import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator; 021import org.kuali.rice.krms.api.repository.reference.ReferenceObjectBinding; 022import org.kuali.rice.krms.api.repository.reference.ReferenceObjectBindingContract; 023 024import javax.persistence.Column; 025import javax.persistence.Convert; 026import javax.persistence.Entity; 027import javax.persistence.GeneratedValue; 028import javax.persistence.Id; 029import javax.persistence.Table; 030import javax.persistence.Version; 031import java.io.Serializable; 032 033/** 034 * The mutable implementation of the @{link ReferenceObjectBindingContract} interface, the counterpart to the immutable implementation {@link ReferenceObjectBinding}. 035 * @author Kuali Rice Team (rice.collab@kuali.org) 036 * 037 */ 038@Entity 039@Table(name = "KRMS_REF_OBJ_KRMS_OBJ_T") 040public class ReferenceObjectBindingBo implements ReferenceObjectBindingContract, Versioned, Serializable { 041 042 private static final long serialVersionUID = 1l; 043 044 @PortableSequenceGenerator(name = "KRMS_REF_OBJ_KRMS_OBJ_S") 045 @GeneratedValue(generator = "KRMS_REF_OBJ_KRMS_OBJ_S") 046 @Id 047 @Column(name = "REF_OBJ_KRMS_OBJ_ID") 048 private String id; 049 050 @Column(name = "COLLECTION_NM") 051 private String collectionName; 052 053 @Column(name = "KRMS_DSCR_TYP") 054 private String krmsDiscriminatorType; 055 056 @Column(name = "KRMS_OBJ_ID") 057 private String krmsObjectId; 058 059 @Column(name = "NMSPC_CD") 060 private String namespace; 061 062 @Column(name = "REF_DSCR_TYP") 063 private String referenceDiscriminatorType; 064 065 @Column(name = "REF_OBJ_ID") 066 private String referenceObjectId; 067 068 @Column(name = "ACTV") 069 @Convert(converter = BooleanYNConverter.class) 070 private boolean active; 071 072 @Column(name = "VER_NBR") 073 @Version 074 private Long versionNumber; 075 076 /** 077 * Default Constructor 078 * 079 */ 080 public ReferenceObjectBindingBo() { 081 } 082 083 @Override 084 public String getCollectionName() { 085 return this.collectionName; 086 } 087 088 @Override 089 public String getKrmsDiscriminatorType() { 090 return this.krmsDiscriminatorType; 091 } 092 093 @Override 094 public String getKrmsObjectId() { 095 return this.krmsObjectId; 096 } 097 098 @Override 099 public String getNamespace() { 100 return this.namespace; 101 } 102 103 @Override 104 public String getReferenceDiscriminatorType() { 105 return this.referenceDiscriminatorType; 106 } 107 108 @Override 109 public String getReferenceObjectId() { 110 return this.referenceObjectId; 111 } 112 113 @Override 114 public String getId() { 115 return this.id; 116 } 117 118 @Override 119 public boolean isActive() { 120 return this.active; 121 } 122 123 @Override 124 public Long getVersionNumber() { 125 return this.versionNumber; 126 } 127 128 /** 129 * Sets the value of collectionName on this builder to the given value. 130 * 131 * @param collectionName the collectionName value to set. 132 * 133 */ 134 public void setCollectionName(String collectionName) { 135 this.collectionName = collectionName; 136 } 137 138 /** 139 * Sets the value of krmsDiscriminatorType on this builder to the given value. 140 * 141 * @param krmsDiscriminatorType the krmsDiscriminatorType value to set. 142 * 143 */ 144 public void setKrmsDiscriminatorType(String krmsDiscriminatorType) { 145 this.krmsDiscriminatorType = krmsDiscriminatorType; 146 } 147 148 /** 149 * Sets the value of krmsObjectId on this builder to the given value. 150 * 151 * @param krmsObjectId the krmsObjectId value to set. 152 * 153 */ 154 public void setKrmsObjectId(String krmsObjectId) { 155 this.krmsObjectId = krmsObjectId; 156 } 157 158 /** 159 * Sets the value of namespace on this builder to the given value. 160 * 161 * @param namespace the namespace value to set. 162 * 163 */ 164 public void setNamespace(String namespace) { 165 this.namespace = namespace; 166 } 167 168 /** 169 * Sets the value of referenceDiscriminatorType on this builder to the given value. 170 * 171 * @param referenceDiscriminatorType the referenceDiscriminatorType value to set. 172 * 173 */ 174 public void setReferenceDiscriminatorType(String referenceDiscriminatorType) { 175 this.referenceDiscriminatorType = referenceDiscriminatorType; 176 } 177 178 /** 179 * Sets the value of referenceObjectId on this builder to the given value. 180 * 181 * @param referenceObjectId the referenceObjectId value to set. 182 * 183 */ 184 public void setReferenceObjectId(String referenceObjectId) { 185 this.referenceObjectId = referenceObjectId; 186 } 187 188 /** 189 * Sets the value of id on this builder to the given value. 190 * 191 * @param id the id value to set. 192 * 193 */ 194 public void setId(String id) { 195 this.id = id; 196 } 197 198 /** 199 * Sets the value of active on this builder to the given value. 200 * 201 * @param active the active value to set. 202 * 203 */ 204 public void setActive(boolean active) { 205 this.active = active; 206 } 207 208 /** 209 * Sets the value of versionNumber on this builder to the given value. 210 * 211 * @param versionNumber the versionNumber value to set. 212 * 213 */ 214 public void setVersionNumber(Long versionNumber) { 215 this.versionNumber = versionNumber; 216 } 217 218 /** 219 * Converts a mutable {@link ReferenceObjectBindingBo} to its immutable counterpart, {@link ReferenceObjectBinding}. 220 * @param referenceObjectBindingBo the mutable business object. 221 * @return a {@link ReferenceObjectBinding} the immutable object. 222 * 223 */ 224 public static ReferenceObjectBinding to(ReferenceObjectBindingBo referenceObjectBindingBo) { 225 if (referenceObjectBindingBo == null) { 226 return null; 227 } 228 229 return ReferenceObjectBinding.Builder.create(referenceObjectBindingBo).build(); 230 } 231 232 /** 233 * Converts a immutable {@link ReferenceObjectBinding} to its mutable {@link ReferenceObjectBindingBo} counterpart. 234 * @param referenceObjectBinding the immutable object. 235 * @return a {@link ReferenceObjectBindingBo} the mutable ReferenceObjectBindingBo. 236 * 237 */ 238 public static org.kuali.rice.krms.impl.repository.ReferenceObjectBindingBo from(ReferenceObjectBinding referenceObjectBinding) { 239 if (referenceObjectBinding == null) { 240 return null; 241 } 242 243 ReferenceObjectBindingBo referenceObjectBindingBo = new ReferenceObjectBindingBo(); 244 referenceObjectBindingBo.setCollectionName(referenceObjectBinding.getCollectionName()); 245 referenceObjectBindingBo.setKrmsDiscriminatorType(referenceObjectBinding.getKrmsDiscriminatorType()); 246 referenceObjectBindingBo.setKrmsObjectId(referenceObjectBinding.getKrmsObjectId()); 247 referenceObjectBindingBo.setNamespace(referenceObjectBinding.getNamespace()); 248 referenceObjectBindingBo.setReferenceDiscriminatorType(referenceObjectBinding.getReferenceDiscriminatorType()); 249 referenceObjectBindingBo.setReferenceObjectId(referenceObjectBinding.getReferenceObjectId()); 250 referenceObjectBindingBo.setId(referenceObjectBinding.getId()); 251 referenceObjectBindingBo.setActive(referenceObjectBinding.isActive()); 252 referenceObjectBindingBo.setVersionNumber(referenceObjectBinding.getVersionNumber()); 253 254 return referenceObjectBindingBo; 255 } 256}