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.krad.data.jpa.converters.BooleanYNConverter;
19  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
20  import org.kuali.rice.krms.api.repository.language.NaturalLanguageUsage;
21  import org.kuali.rice.krms.api.repository.language.NaturalLanguageUsageContract;
22  
23  import javax.persistence.Column;
24  import javax.persistence.Convert;
25  import javax.persistence.Entity;
26  import javax.persistence.GeneratedValue;
27  import javax.persistence.Id;
28  import javax.persistence.Table;
29  import javax.persistence.Version;
30  import java.io.Serializable;
31  
32  /**
33   * The mutable implementation of the @{link NaturalLanguageUsageContract} interface, the counterpart to the immutable implementation {@link NaturalLanguageUsage}.
34   * @author Kuali Rice Team (rice.collab@kuali.org)
35   * 
36   */
37  @Entity
38  @Table(name = "KRMS_NL_USAGE_T")
39  public class NaturalLanguageUsageBo implements NaturalLanguageUsageContract, Serializable {
40  
41      private static final long serialVersionUID = 1l;
42  
43      @PortableSequenceGenerator(name = "KRMS_NL_USAGE_S")
44      @GeneratedValue(generator = "KRMS_NL_USAGE_S")
45      @Id
46      @Column(name = "NL_USAGE_ID")
47      private String id;
48  
49      @Column(name = "NM")
50      private String name;
51  
52      @Column(name = "DESC_TXT")
53      private String description;
54  
55      @Column(name = "NMSPC_CD")
56      private String namespace;
57  
58      @Column(name = "ACTV")
59      @Convert(converter = BooleanYNConverter.class)
60      private boolean active;
61  
62      @Column(name = "VER_NBR")
63      @Version
64      private Long versionNumber;
65  
66      /**
67       * Default Constructor
68       * 
69       */
70      public NaturalLanguageUsageBo() {
71      }
72  
73      @Override
74      public String getName() {
75          return this.name;
76      }
77  
78      @Override
79      public String getDescription() {
80          return this.description;
81      }
82  
83      @Override
84      public String getNamespace() {
85          return this.namespace;
86      }
87  
88      @Override
89      public String getId() {
90          return this.id;
91      }
92  
93      @Override
94      public boolean isActive() {
95          return this.active;
96      }
97  
98      @Override
99      public Long getVersionNumber() {
100         return this.versionNumber;
101     }
102 
103     /**
104      * Sets the value of name on this builder to the given value.
105      * 
106      * @param name the name value to set.
107      * 
108      */
109     public void setName(String name) {
110         this.name = name;
111     }
112 
113     /**
114      * Sets the value of description on this builder to the given value.
115      * 
116      * @param description the description value to set.
117      * 
118      */
119     public void setDescription(String description) {
120         this.description = description;
121     }
122 
123     /**
124      * Sets the value of namespace on this builder to the given value.
125      * 
126      * @param namespace the namespace value to set.
127      * 
128      */
129     public void setNamespace(String namespace) {
130         this.namespace = namespace;
131     }
132 
133     /**
134      * Sets the value of id on this builder to the given value.
135      * 
136      * @param id the id value to set.
137      * 
138      */
139     public void setId(String id) {
140         this.id = id;
141     }
142 
143     /**
144      * Sets the value of active on this builder to the given value.
145      * 
146      * @param active the active value to set.
147      * 
148      */
149     public void setActive(boolean active) {
150         this.active = active;
151     }
152 
153     /**
154      * Sets the value of versionNumber on this builder to the given value.
155      * 
156      * @param versionNumber the versionNumber value to set.
157      * 
158      */
159     public void setVersionNumber(Long versionNumber) {
160         this.versionNumber = versionNumber;
161     }
162 
163     /**
164      * Converts a mutable {@link NaturalLanguageUsageBo} to its immutable counterpart, {@link NaturalLanguageUsage}.
165      * @param naturalLanguageUsageBo the mutable business object.
166      * @return a {@link NaturalLanguageUsage} the immutable object.
167      * 
168      */
169     public static NaturalLanguageUsage to(NaturalLanguageUsageBo naturalLanguageUsageBo) {
170         if (naturalLanguageUsageBo == null) {
171             return null;
172         }
173 
174         return NaturalLanguageUsage.Builder.create(naturalLanguageUsageBo).build();
175     }
176 
177     /**
178      * Converts a immutable {@link NaturalLanguageUsage} to its mutable {@link NaturalLanguageUsageBo} counterpart.
179      * @param naturalLanguageUsage the immutable object.
180      * @return a {@link NaturalLanguageUsageBo} the mutable NaturalLanguageUsageBo.
181      * 
182      */
183     public static org.kuali.rice.krms.impl.repository.NaturalLanguageUsageBo from(NaturalLanguageUsage naturalLanguageUsage) {
184         if (naturalLanguageUsage == null) {
185             return null;
186         }
187 
188         NaturalLanguageUsageBo naturalLanguageUsageBo = new NaturalLanguageUsageBo();
189         naturalLanguageUsageBo.setName(naturalLanguageUsage.getName());
190         naturalLanguageUsageBo.setDescription(naturalLanguageUsage.getDescription());
191         naturalLanguageUsageBo.setNamespace(naturalLanguageUsage.getNamespace());
192         naturalLanguageUsageBo.setId(naturalLanguageUsage.getId());
193         naturalLanguageUsageBo.setActive(naturalLanguageUsage.isActive());
194         naturalLanguageUsageBo.setVersionNumber(naturalLanguageUsage.getVersionNumber());
195 
196         return naturalLanguageUsageBo;
197     }
198 }