View Javadoc
1   /**
2    * Copyright 2005-2014 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.active.MutableInactivatable;
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.type.KrmsAttributeDefinition;
22  import org.kuali.rice.krms.api.repository.type.KrmsAttributeDefinitionContract;
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  @Entity
34  @Table(name = "KRMS_ATTR_DEFN_T")
35  public class KrmsAttributeDefinitionBo implements KrmsAttributeDefinitionContract, MutableInactivatable, Serializable {
36  
37      private static final long serialVersionUID = 1l;
38  
39      @PortableSequenceGenerator(name = "KRMS_ATTR_DEFN_S")
40      @GeneratedValue(generator = "KRMS_ATTR_DEFN_S")
41      @Id
42      @Column(name = "ATTR_DEFN_ID")
43      private String id;
44  
45      @Column(name = "NM")
46      private String name;
47  
48      @Column(name = "NMSPC_CD")
49      private String namespace;
50  
51      @Column(name = "LBL")
52      private String label;
53  
54      @Column(name = "DESC_TXT")
55      private String description;
56  
57      @Column(name = "ACTV")
58      @Convert(converter = BooleanYNConverter.class)
59      private boolean active = true;
60  
61      @Column(name = "CMPNT_NM")
62      private String componentName;
63  
64      @Version
65      @Column(name="VER_NBR", length=8)
66      protected Long versionNumber;
67  
68      /**
69       * Converts a mutable bo to it's immutable counterpart
70       *
71       * @param bo the mutable business object
72       * @return the immutable object
73       */
74      public static KrmsAttributeDefinition to(KrmsAttributeDefinitionBo bo) {
75          if (bo == null) {
76              return null;
77          }
78  
79          return KrmsAttributeDefinition.Builder.create(bo).build();
80      }
81  
82      /**
83       * Converts a immutable object to it's mutable bo counterpart
84       *
85       * @param im immutable object
86       * @return the mutable bo
87       */
88      public static KrmsAttributeDefinitionBo from(KrmsAttributeDefinition im) {
89          if (im == null) {
90              return null;
91          }
92  
93          KrmsAttributeDefinitionBo bo = new KrmsAttributeDefinitionBo();
94          bo.id = im.getId();
95          bo.name = im.getName();
96          bo.namespace = im.getNamespace();
97          bo.label = im.getLabel();
98          bo.description = im.getDescription();
99          bo.active = im.isActive();
100         bo.componentName = im.getComponentName();
101         bo.setVersionNumber(im.getVersionNumber());
102 
103         return bo;
104     }
105 
106     public String getId() {
107         return id;
108     }
109 
110     public void setId(String id) {
111         this.id = id;
112     }
113 
114     public String getName() {
115         return name;
116     }
117 
118     public void setName(String name) {
119         this.name = name;
120     }
121 
122     public String getNamespace() {
123         return namespace;
124     }
125 
126     public void setNamespace(String namespace) {
127         this.namespace = namespace;
128     }
129 
130     public String getLabel() {
131         return label;
132     }
133 
134     public void setLabel(String label) {
135         this.label = label;
136     }
137 
138     public String getDescription() {
139         return description;
140     }
141 
142     public void setDescription(String description) {
143         this.description = description;
144     }
145 
146     public boolean getActive() {
147         return active;
148     }
149 
150     public boolean isActive() {
151         return active;
152     }
153 
154     public void setActive(boolean active) {
155         this.active = active;
156     }
157 
158     public String getComponentName() {
159         return componentName;
160     }
161 
162     public void setComponentName(String componentName) {
163         this.componentName = componentName;
164     }
165 
166     public Long getVersionNumber() {
167         return versionNumber;
168     }
169 
170     public void setVersionNumber(Long versionNumber) {
171         this.versionNumber = versionNumber;
172     }
173 }