View Javadoc

1   /*
2    * Copyright 2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 1.0 (the
5    * "License"); you may not use this file except in compliance with the
6    * License.  You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl1.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  
17  package org.kuali.student.r2.common.datadictionary.dto;
18  
19  import java.io.Serializable;
20  import javax.xml.bind.annotation.XmlAccessType;
21  import javax.xml.bind.annotation.XmlAccessorType;
22  import javax.xml.bind.annotation.XmlElement;
23  import org.kuali.rice.core.api.uif.DataType;
24  import org.kuali.student.r2.common.datadictionary.infc.AttributeDefinitionInfc;
25  import org.kuali.student.r2.common.datadictionary.infc.ValidCharactersConstraintInfc;
26  
27  @XmlAccessorType(XmlAccessType.FIELD)
28  public class AttributeDefinitionInfo 
29      implements AttributeDefinitionInfc, Serializable {
30  
31      private static final long serialVersionUID = 1L;
32  
33      @XmlElement
34      private String name;
35  
36      @XmlElement
37      private String childEntryName;
38  
39      @XmlElement
40      private DataType dataType;
41  
42      @XmlElement
43      private Boolean isRequired;
44  
45      @XmlElement
46      private Integer minOccurs;
47  
48      @XmlElement
49      private Integer maxOccurs;
50  
51      @XmlElement
52      private Integer minLength;
53  
54      @XmlElement
55      private Integer maxLength;
56  
57      @XmlElement
58      private Boolean isForceUppercase;
59  
60      @XmlElement
61      private String shortLabel;
62  
63      @XmlElement
64      private String summary;
65  
66      @XmlElement
67      private String label;
68  
69      @XmlElement
70      private String description;
71  
72      @XmlElement
73      private String exclusiveMin;
74  
75      @XmlElement
76      private String inclusiveMax;
77  
78      @XmlElement
79      private String displayLabelAttribute;
80  
81      @XmlElement
82      private Boolean isUnique;
83  
84      @XmlElement
85      private String customValidatorClass;
86  
87      @XmlElement
88      private String formatterClass;
89  
90      @XmlElement
91      private ValidCharactersConstraintInfo validCharactersConstraint;
92  
93      
94      /** 
95       * Constructs a new AttributeDefinitionInfo.
96       */
97      public AttributeDefinitionInfo() {
98      }
99  
100     /** 
101      * Constructs a new AttributeDefinitionInfo from an
102      * AttributeDefinition.
103      *
104      * @param attrDef the AttributeDefinition to copy
105      */
106     public AttributeDefinitionInfo(AttributeDefinitionInfc attrDef) {
107         
108         if (attrDef != null) {
109             this.name = attrDef.getName();
110             this.childEntryName = attrDef.getChildEntryName();
111             this.dataType = attrDef.getDataType();
112             this.isRequired = attrDef.getIsRequired();
113             this.minOccurs = attrDef.getMinOccurs();
114             this.maxOccurs = attrDef.getMaxOccurs();
115             this.minLength = attrDef.getMinLength();
116             this.maxLength = attrDef.getMaxLength();
117             this.isForceUppercase = attrDef.getIsForceUppercase();
118             this.shortLabel = attrDef.getShortLabel();
119             this.summary = attrDef.getSummary();
120             this.label = attrDef.getLabel();
121             this.description = attrDef.getDescription();
122             this.exclusiveMin = attrDef.getExclusiveMin();
123             this.inclusiveMax = attrDef.getInclusiveMax();
124             this.displayLabelAttribute = attrDef.getDisplayLabelAttribute();
125             this.isUnique = attrDef.getIsUnique();
126             this.customValidatorClass = attrDef.getCustomValidatorClass();
127             this.formatterClass = attrDef.getFormatterClass();
128             if (attrDef.getValidCharactersConstraint() != null) {
129                 this.validCharactersConstraint = new ValidCharactersConstraintInfo.Builder(attrDef.getValidCharactersConstraint()).build();
130             }
131         }
132     }
133 
134     @Override
135     public String getName() {
136         return this.name;
137     }
138 
139     @Override
140     public String getChildEntryName() {
141         return this.childEntryName;
142     }
143 
144     @Override
145     public DataType getDataType() {
146         return this.dataType;
147     }
148 
149     @Override
150     public Boolean getIsRequired() {
151         return this.isRequired;
152     }
153 
154     @Override
155     public Integer getMinOccurs() {
156         return this.minOccurs;
157     }
158 
159     @Override
160     public Integer getMaxOccurs() {
161         return this.maxOccurs;
162     }
163 
164     @Override
165     public Integer getMinLength() {
166         return this.minLength;
167     }
168 
169     @Override
170     public Integer getMaxLength() {
171         return this.maxLength;
172     }
173 
174     @Override
175     public Boolean getIsForceUppercase() {
176         return this.isForceUppercase;
177     }
178 
179     @Override
180     public String getShortLabel() {
181         return this.shortLabel;
182     }
183 
184     @Override
185     public String getSummary() {
186         return this.summary;
187     }
188 
189     @Override
190     public String getLabel() {
191         return this.label;
192     }
193 
194     @Override
195     public String getDescription() {
196         return this.description;
197     }
198 
199     @Override
200     public String getExclusiveMin() {
201         return this.exclusiveMin;
202     }
203 
204     @Override
205     public String getInclusiveMax() {
206         return this.inclusiveMax;
207     }
208 
209     @Override
210     public String getDisplayLabelAttribute() {
211         return this.displayLabelAttribute;
212     }
213 
214     @Override
215     public Boolean getIsUnique() {
216         return this.isUnique;
217     }
218 
219     @Override
220     public String getCustomValidatorClass() {
221         return this.customValidatorClass;
222     }
223 
224     @Override
225     public String getFormatterClass() {
226         return this.formatterClass;
227     }
228 
229     @Override
230     public ValidCharactersConstraintInfo getValidCharactersConstraint() {
231         return this.validCharactersConstraint;
232     }
233 
234 
235     public static class Builder implements AttributeDefinitionInfc {
236 
237         private String name;
238         private String childEntryName;
239         private DataType dataType;
240         private Boolean required;
241         private Integer minOccurs;
242         private Integer maxOccurs;
243         private Integer minLength;
244         private Integer maxLength;
245         private Boolean forceUppercase;
246         private String shortLabel;
247         private String summary;
248         private String label;
249         private String description;
250         private String exclusiveMin;
251         private String inclusiveMax;
252         private String displayLabelAttribute;
253         private Boolean unique;
254         private String customValidatorClass;
255         private String formatterClass;
256         private ValidCharactersConstraintInfc validCharactersConstraint;
257 
258         public Builder() {
259         }
260 
261         public Builder(AttributeDefinitionInfc attrDef) {
262             this.name = attrDef.getName();
263             this.childEntryName = attrDef.getChildEntryName();
264             this.dataType = attrDef.getDataType();
265             this.required = attrDef.getIsRequired();
266             this.minOccurs = attrDef.getMinOccurs();
267             this.maxOccurs = attrDef.getMaxOccurs();
268             this.minLength = attrDef.getMinLength();
269             this.maxLength = attrDef.getMaxLength();
270             this.forceUppercase = attrDef.getIsForceUppercase();
271             this.shortLabel = attrDef.getShortLabel();
272             this.summary = attrDef.getSummary();
273             this.label = attrDef.getLabel();
274             this.description = attrDef.getDescription();
275             this.exclusiveMin = attrDef.getExclusiveMin();
276             this.inclusiveMax = attrDef.getInclusiveMax();
277             this.displayLabelAttribute = attrDef.getDisplayLabelAttribute();
278             this.unique = attrDef.getIsUnique();
279             this.customValidatorClass = attrDef.getCustomValidatorClass();
280             this.formatterClass = attrDef.getFormatterClass();
281             this.validCharactersConstraint = attrDef.getValidCharactersConstraint();
282         }
283 
284         public AttributeDefinitionInfo build() {
285             return new AttributeDefinitionInfo(this);
286         }
287 
288         @Override
289         public String getChildEntryName() {
290             return this.childEntryName;
291         }
292 
293         @Override
294         public String getCustomValidatorClass() {
295             return this.customValidatorClass;
296         }
297 
298         @Override
299         public DataType getDataType() {
300             return this.dataType;
301         }
302 
303         @Override
304         public String getDescription() {
305             return this.description;
306         }
307 
308         @Override
309         public String getDisplayLabelAttribute() {
310             return this.displayLabelAttribute;
311         }
312 
313         @Override
314         public String getExclusiveMin() {
315             return this.exclusiveMin;
316         }
317 
318         @Override
319         public Boolean getIsForceUppercase() {
320             return this.forceUppercase;
321         }
322 
323         @Override
324         public String getFormatterClass() {
325             return this.formatterClass;
326         }
327 
328         @Override
329         public String getInclusiveMax() {
330             return this.inclusiveMax;
331         }
332 
333         @Override
334         public String getLabel() {
335             return this.label;
336         }
337 
338         @Override
339         public Integer getMaxLength() {
340             return this.maxLength;
341         }
342 
343         @Override
344         public Integer getMaxOccurs() {
345             return this.maxOccurs;
346         }
347 
348         @Override
349         public Integer getMinLength() {
350             return this.minLength;
351         }
352 
353         @Override
354         public Integer getMinOccurs() {
355             return this.minOccurs;
356         }
357 
358         @Override
359         public String getName() {
360             return this.name;
361         }
362 
363         @Override
364         public String getShortLabel() {
365             return this.shortLabel;
366         }
367 
368         @Override
369         public String getSummary() {
370             return this.summary;
371         }
372 
373         @Override
374         public Boolean getIsUnique() {
375             return this.unique;
376         }
377 
378         @Override
379         public ValidCharactersConstraintInfc getValidCharactersConstraint() {
380             return this.validCharactersConstraint;
381         }
382 
383         @Override
384         public Boolean getIsRequired() {
385             return this.required;
386         }
387 
388         public Builder setChildEntryName(String childEntryName) {
389             this.childEntryName = childEntryName;
390             return this;
391         }
392 
393         public Builder setCustomValidatorClass(String customValidatorClass) {
394             this.customValidatorClass = customValidatorClass;
395             return this;
396         }
397 
398         public Builder setDataType(DataType dataType) {
399             this.dataType = dataType;
400             return this;
401         }
402 
403         public Builder setDescription(String description) {
404             this.description = description;
405             return this;
406         }
407 
408         public Builder setDisplayLabelAttribute(String displayLabelAttribute) {
409             this.displayLabelAttribute = displayLabelAttribute;
410             return this;
411         }
412 
413         public Builder setExclusiveMin(String exclusiveMin) {
414             this.exclusiveMin = exclusiveMin;
415             return this;
416         }
417 
418         public Builder setForceUppercase(Boolean forceUppercase) {
419             this.forceUppercase = forceUppercase;
420             return this;
421         }
422 
423         public Builder setFormatterClass(String formatterClass) {
424             this.formatterClass = formatterClass;
425             return this;
426         }
427 
428         public Builder setInclusiveMax(String inclusiveMax) {
429             this.inclusiveMax = inclusiveMax;
430             return this;
431         }
432 
433         public Builder setLabel(String label) {
434             this.label = label;
435             return this;
436         }
437 
438         public Builder setMaxLength(Integer maxLength) {
439             this.maxLength = maxLength;
440             return this;
441         }
442 
443         public Builder setMaxOccurs(Integer maxOccurs) {
444             this.maxOccurs = maxOccurs;
445             return this;
446         }
447 
448         public Builder setMinLength(Integer minLength) {
449             this.minLength = minLength;
450             return this;
451         }
452 
453         public Builder setMinOccurs(Integer minOccurs) {
454             this.minOccurs = minOccurs;
455             return this;
456         }
457 
458         public Builder setName(String name) {
459             this.name = name;
460             return this;
461         }
462 
463         public Builder setRequired(Boolean required) {
464             this.required = required;
465             return this;
466         }
467 
468         public Builder setShortLabel(String shortLabel) {
469             this.shortLabel = shortLabel;
470             return this;
471         }
472 
473         public Builder setSummary(String summary) {
474             this.summary = summary;
475             return this;
476         }
477 
478         public Builder setUnique(Boolean unique) {
479             this.unique = unique;
480             return this;
481         }
482 
483         public Builder setValidCharactersConstraint(ValidCharactersConstraintInfc validCharactersConstraint) {
484             this.validCharactersConstraint = validCharactersConstraint;
485             return this;
486         }
487     }
488 }