Clover Coverage Report - Kuali Student 1.2-M4-SNAPSHOT (Aggregated)
Coverage timestamp: Wed Jul 20 2011 11:14:35 EDT
../../../../../../img/srcFileCovDistChart7.png 32% of files have more coverage
91   315   54   2.22
22   223   0.59   20.5
41     1.32  
2    
 
  Metadata       Line # 26 91 0% 54 48 68.8% 0.6883117
  Metadata.WriteAccess       Line # 30 0 - 0 0 - -1.0
 
  (11)
 
1    /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10    * software distributed under the License is distributed on an "AS IS"
11    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12    * or implied. See the License for the specific language governing
13    * permissions and limitations under the License.
14    */
15   
16    package org.kuali.student.common.assembly.data;
17   
18    import java.io.Serializable;
19    import java.util.ArrayList;
20    import java.util.HashMap;
21    import java.util.LinkedHashMap;
22    import java.util.List;
23    import java.util.Map;
24    import java.util.Map.Entry;
25   
 
26    public class Metadata implements Serializable {
27   
28    private static final long serialVersionUID = 1L;
29   
 
30    public enum WriteAccess {
31    ON_CREATE, /* must also be required */
32    ALWAYS, NEVER, WHEN_NULL, REQUIRED
33    }
34   
35    private String name;
36    private String labelKey;
37    private WriteAccess writeAccess;
38   
39    private boolean canUnmask = false;
40    private boolean canView = true;
41    private boolean canEdit = true;
42    private boolean dynamic = false;
43   
44    protected String partialMaskFormatter;//Regex replace to do a partial mask
45    protected String maskFormatter;//Regex replace to do a mask
46   
47    private boolean onChangeRefreshMetadata;
48   
49    private Data.DataType dataType;
50   
51    private Data.Value defaultValue;
52   
53    private String defaultValuePath;
54   
55    //TODO: When all dictionaries have been updated, this needs to be changed to a single value object.
56    //No need for it to be a list with new dictionary structure.
57    private List<ConstraintMetadata> constraints;
58   
59    private LookupMetadata initialLookup;
60   
61    private String lookupContextPath;
62   
63    private List<LookupMetadata> additionalLookups;
64   
65    private Map<String, Metadata> childProperties;
66   
 
67  1000 toggle public Metadata() {
68   
69    }
70   
71    /**
72    *
73    * This constructs a new Metadata instance. References to non-Metadata objects are maintained, as no permissions are applied to them.
74    *
75    * @param toClone the Metadata instance to be cloned
76    */
 
77  306 toggle public Metadata(Metadata toClone) {
78  306 this.additionalLookups = toClone.additionalLookups;
79  306 this.constraints = toClone.constraints;
80  306 this.dataType = toClone.dataType;
81  306 this.defaultValue = toClone.defaultValue;
82  306 this.defaultValuePath = toClone.defaultValuePath;
83  306 this.lookupContextPath = toClone.lookupContextPath;
84    /* if(toClone.lookupMetadata != null) {
85    this.lookupMetadata = new LookupMetadata(toClone.lookupMetadata);
86    }*/
87  306 this.initialLookup = toClone.initialLookup;
88  306 this.onChangeRefreshMetadata = toClone.onChangeRefreshMetadata;
89  306 this.name = toClone.name;
90  306 this.writeAccess = toClone.writeAccess;
91  306 this.canEdit = toClone.canEdit;
92  306 this.canView = toClone.canView;
93  306 this.canUnmask = toClone.canUnmask;
94  306 if(toClone.childProperties != null) {
95  88 this.childProperties = new HashMap<String, Metadata>();
96  88 for(Map.Entry<String, Metadata> childProperty : toClone.childProperties.entrySet()) {
97  304 this.childProperties.put(childProperty.getKey(), new Metadata(childProperty.getValue()));
98    }
99   
100    }
101    }
102   
 
103  0 toggle @Override
104    public String toString() {
105  0 StringBuilder sb = new StringBuilder();
106  0 _toString(sb);
107  0 return sb.toString();
108    }
109   
 
110  0 toggle protected void _toString(StringBuilder sb) {
111  0 Data.DataType type = (null == dataType) ? Data.DataType.DATA : dataType;
112  0 sb.append("type: " + type.toString());
113  0 sb.append(", canEdit: " + canEdit);
114  0 sb.append(", canView: " + canView);
115  0 sb.append(", defaultValue: ");
116  0 sb.append(null == defaultValue ? "null" : defaultValue.toString());
117  0 sb.append(", constraints: {");
118  0 if (null != constraints) {
119  0 for (ConstraintMetadata constraint : constraints) {
120  0 sb.append(constraint.toString());
121    }
122    }
123  0 sb.append("}");
124  0 sb.append(", Properties: {");
125  0 if (null != childProperties) {
126  0 for (Entry<String, Metadata> e : childProperties.entrySet()) {
127  0 sb.append("(");
128  0 sb.append(e.getKey());
129  0 sb.append(" = ");
130  0 Metadata m = e.getValue();
131  0 if (m == null) {
132  0 sb.append("null");
133    } else {
134  0 m._toString(sb);
135    }
136  0 sb.append(");");
137    }
138    }
139  0 sb.append("}");
140    // TODO dump lookup/etc info as well
141    }
142   
 
143  276 toggle public List<ConstraintMetadata> getConstraints() {
144  276 if (constraints == null) {
145  8 constraints = new ArrayList<ConstraintMetadata>();
146    }
147  276 return constraints;
148    }
149   
 
150  707 toggle public void setConstraints(List<ConstraintMetadata> constraints) {
151  707 this.constraints = constraints;
152    }
153   
154    /**
155    * This is used to set all non-server side constraints for the metadata.
156    *
157    * @param constraints
158    */
 
159  149 toggle public void setNonServerConstraints(List<ConstraintMetadata> constraints) {
160  149 if (constraints != null){
161  148 List<ConstraintMetadata> metadataConstraints = new ArrayList<ConstraintMetadata>();
162  148 for (ConstraintMetadata constraint:constraints){
163  508 if (!"single".equals(constraint.getId()) &&
164    !"optional".equals(constraint.getId()) &&
165    !constraint.isServerSide()){
166  193 metadataConstraints.add(constraint);
167    }
168    }
169  148 this.constraints = metadataConstraints;
170    }
171    }
172   
 
173  1025 toggle public Data.DataType getDataType() {
174  1025 return dataType;
175    }
176   
 
177  1108 toggle public void setDataType(Data.DataType dataType) {
178  1108 this.dataType = dataType;
179    }
180   
 
181  30 toggle public Data.Value getDefaultValue() {
182  30 return defaultValue;
183    }
184   
 
185  852 toggle public void setDefaultValue(Data.Value defaultValue) {
186  852 this.defaultValue = defaultValue;
187    }
188   
 
189  0 toggle public String getDefaultValuePath() {
190  0 return defaultValuePath;
191    }
192   
 
193  707 toggle public void setDefaultValuePath(String defaultValuePath) {
194  707 this.defaultValuePath = defaultValuePath;
195    }
196   
 
197  54 toggle public LookupMetadata getInitialLookup() {
198  54 return initialLookup;
199    }
200   
 
201  154 toggle public void setInitialLookup(LookupMetadata initialLookup) {
202  154 this.initialLookup = initialLookup;
203    }
204   
 
205  0 toggle public String getLookupContextPath() {
206  0 return lookupContextPath;
207    }
208   
 
209  145 toggle public void setLookupContextPath(String lookupContextPath) {
210  145 this.lookupContextPath = lookupContextPath;
211    }
212   
 
213  75 toggle public List<LookupMetadata> getAdditionalLookups() {
214  75 if (additionalLookups == null) {
215  25 additionalLookups = new ArrayList<LookupMetadata>();
216    }
217  75 return additionalLookups;
218    }
219   
 
220  146 toggle public void setAdditionalLookups(List<LookupMetadata> additionalLookups) {
221  146 this.additionalLookups = additionalLookups;
222    }
223   
 
224  131 toggle public Map<String, Metadata> getProperties() {
225  131 if (childProperties == null) {
226  14 childProperties = new LinkedHashMap<String, Metadata>();
227    }
228  131 return childProperties;
229    }
230   
 
231  277 toggle public void setProperties(Map<String, Metadata> properties) {
232  277 this.childProperties = properties;
233    }
234   
 
235  0 toggle public WriteAccess getWriteAccess() {
236  0 return writeAccess;
237    }
238   
 
239  987 toggle public void setWriteAccess(WriteAccess writeAccess) {
240  987 this.writeAccess = writeAccess;
241    }
242   
243   
 
244  0 toggle public boolean isOnChangeRefreshMetadata() {
245  0 return onChangeRefreshMetadata;
246    }
247   
 
248  111 toggle public void setOnChangeRefreshMetadata(boolean onChangeRefereshMetadata) {
249  111 this.onChangeRefreshMetadata = onChangeRefereshMetadata;
250    }
251   
 
252  25 toggle public boolean isCanUnmask() {
253  25 return canUnmask;
254    }
255   
 
256  852 toggle public void setCanUnmask(boolean canUnmask) {
257  852 this.canUnmask = canUnmask;
258    }
259   
 
260  25 toggle public boolean isCanView() {
261  25 return canView;
262    }
263   
 
264  852 toggle public void setCanView(boolean canView) {
265  852 this.canView = canView;
266    }
267   
 
268  45 toggle public boolean isCanEdit() {
269  45 return canEdit;
270    }
271   
 
272  859 toggle public void setCanEdit(boolean canEdit) {
273  859 this.canEdit = canEdit;
274    }
275   
 
276  0 toggle public String getName() {
277  0 return name;
278    }
279   
 
280  145 toggle public void setName(String name) {
281  145 this.name = name;
282    }
283   
 
284  25 toggle public boolean isDynamic() {
285  25 return dynamic;
286    }
287   
 
288  707 toggle public void setDynamic(boolean dynamic) {
289  707 this.dynamic = dynamic;
290    }
291   
 
292  25 toggle public String getLabelKey() {
293  25 return labelKey;
294    }
295   
 
296  707 toggle public void setLabelKey(String labelKey) {
297  707 this.labelKey = labelKey;
298    }
299   
 
300  3 toggle public String getPartialMaskFormatter() {
301  3 return partialMaskFormatter;
302    }
303   
 
304  11 toggle public void setPartialMaskFormatter(String partialMaskFormatter) {
305  11 this.partialMaskFormatter = partialMaskFormatter;
306    }
307   
 
308  4 toggle public String getMaskFormatter() {
309  4 return maskFormatter;
310    }
311   
 
312  12 toggle public void setMaskFormatter(String maskFormatter) {
313  12 this.maskFormatter = maskFormatter;
314    }
315    }