View Javadoc
1   /**
2    * Copyright 2005-2015 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krms.impl.repository;
17  
18  import org.kuali.rice.core.api.mo.common.Versioned;
19  import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
20  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
21  import org.kuali.rice.krms.api.repository.reference.ReferenceObjectBinding;
22  import org.kuali.rice.krms.api.repository.reference.ReferenceObjectBindingContract;
23  
24  import javax.persistence.Column;
25  import javax.persistence.Convert;
26  import javax.persistence.Entity;
27  import javax.persistence.GeneratedValue;
28  import javax.persistence.Id;
29  import javax.persistence.Table;
30  import javax.persistence.Version;
31  import java.io.Serializable;
32  
33  /**
34   * The mutable implementation of the @{link ReferenceObjectBindingContract} interface, the counterpart to the immutable implementation {@link ReferenceObjectBinding}.
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   * 
37   */
38  @Entity
39  @Table(name = "KRMS_REF_OBJ_KRMS_OBJ_T")
40  public class ReferenceObjectBindingBo implements ReferenceObjectBindingContract, Versioned, Serializable {
41  
42      private static final long serialVersionUID = 1l;
43  
44      @PortableSequenceGenerator(name = "KRMS_REF_OBJ_KRMS_OBJ_S")
45      @GeneratedValue(generator = "KRMS_REF_OBJ_KRMS_OBJ_S")
46      @Id
47      @Column(name = "REF_OBJ_KRMS_OBJ_ID")
48      private String id;
49  
50      @Column(name = "COLLECTION_NM")
51      private String collectionName;
52  
53      @Column(name = "KRMS_DSCR_TYP")
54      private String krmsDiscriminatorType;
55  
56      @Column(name = "KRMS_OBJ_ID")
57      private String krmsObjectId;
58  
59      @Column(name = "NMSPC_CD")
60      private String namespace;
61  
62      @Column(name = "REF_DSCR_TYP")
63      private String referenceDiscriminatorType;
64  
65      @Column(name = "REF_OBJ_ID")
66      private String referenceObjectId;
67  
68      @Column(name = "ACTV")
69      @Convert(converter = BooleanYNConverter.class)
70      private boolean active;
71  
72      @Column(name = "VER_NBR")
73      @Version
74      private Long versionNumber;
75  
76      /**
77       * Default Constructor
78       * 
79       */
80      public ReferenceObjectBindingBo() {
81      }
82  
83      @Override
84      public String getCollectionName() {
85          return this.collectionName;
86      }
87  
88      @Override
89      public String getKrmsDiscriminatorType() {
90          return this.krmsDiscriminatorType;
91      }
92  
93      @Override
94      public String getKrmsObjectId() {
95          return this.krmsObjectId;
96      }
97  
98      @Override
99      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 }