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