View Javadoc
1   /*
2    * Copyright 2008 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.ole.sys.businessobject;
17  
18  import java.util.LinkedHashMap;
19  
20  import org.kuali.ole.sys.dataaccess.FieldMetaData;
21  import org.kuali.rice.kns.datadictionary.BusinessObjectEntry;
22  import org.kuali.rice.krad.bo.TransientBusinessObjectBase;
23  import org.kuali.rice.krad.datadictionary.AttributeDefinition;
24  
25  public class DataMappingFieldDefinition extends TransientBusinessObjectBase {
26      private String namespaceCode;
27      private String componentClass;
28      private String propertyName;
29      private String tableName;
30      private String fieldName;
31      private FunctionalFieldDescription functionalFieldDescription;
32  
33      private BusinessObjectEntry businessObjectEntry;
34      private AttributeDefinition attributeDefinition;
35      private FieldMetaData fieldMetaData;
36      private String propertyType;
37      private String referenceComponentLabel;
38  
39      public DataMappingFieldDefinition() {
40      }
41  
42      public DataMappingFieldDefinition(FunctionalFieldDescription functionalFieldDescription, BusinessObjectEntry businessObjectEntry, AttributeDefinition attributeDefinition, FieldMetaData fieldMetaData, String propertyType, String referenceComponentLabel) {
43          setNamespaceCode(functionalFieldDescription.getNamespaceCode());
44          setComponentClass(functionalFieldDescription.getComponentClass());
45          setPropertyName(functionalFieldDescription.getPropertyName());
46          setTableName(fieldMetaData.getTableName());
47          setFieldName(fieldMetaData.getColumnName());
48          setFunctionalFieldDescription(functionalFieldDescription);
49          this.businessObjectEntry = businessObjectEntry;
50          this.attributeDefinition = attributeDefinition;
51          this.fieldMetaData = fieldMetaData;
52          this.propertyType = propertyType;
53          this.referenceComponentLabel = referenceComponentLabel;
54      }
55  
56      public String getDatabaseDataType() {
57          return fieldMetaData.getDataType();
58      }
59  
60      public String getApplicationDataType() {
61          return propertyType;
62      }
63  
64      public int getDatabaseDefinedLength() {
65          return fieldMetaData.getLength();
66      }
67  
68      public int getApplicationDefinedLength() {
69          return attributeDefinition.getMaxLength();
70      }
71  
72      public int getDecimalPlaces() {
73          return fieldMetaData.getDecimalPlaces();
74      }
75  
76      public String getReferenceComponent() {
77          return referenceComponentLabel;
78      }
79  
80      public boolean isRequired() {
81          return attributeDefinition.isRequired();
82      }
83  
84      public String getValidationPattern() {
85          return new StringBuffer(attributeDefinition.getValidationPattern().getClass().getSimpleName()).append(" (").append(attributeDefinition.getValidationPattern().getRegexPattern().toString()).append(")").toString();
86      }
87      
88      public boolean isEncrypted() {
89          return fieldMetaData.isEncrypted();
90      }
91      
92      public String getMaskPattern() {
93          // TODO: see how to handle the multiple mask formatters that may appear on an AttributeSecurity object
94          /*if (attributeDefinition.getDisplayMask().getMaskFormatter() instanceof MaskFormatterLiteral) {
95              return ((MaskFormatterLiteral)attributeDefinition.getDisplayMask().getMaskFormatter()).getLiteral();
96          }
97          else if (attributeDefinition.getDisplayMask().getMaskFormatter() instanceof MaskFormatterSubString) {
98              return new StringBuffer(((MaskFormatterSubString)attributeDefinition.getDisplayMask().getMaskFormatter()).getMaskLength()).append(" ").append(((MaskFormatterSubString)attributeDefinition.getDisplayMask().getMaskFormatter()).getMaskCharacter()).append(" characters").toString();
99          }
100         else {*/
101             return "Unknown MaskFormatter";
102         //} 
103     }
104 
105     public String getNamespaceCode() {
106         return namespaceCode;
107     }
108 
109     public void setNamespaceCode(String namespaceCode) {
110         this.namespaceCode = namespaceCode;
111     }
112 
113     public String getComponentClass() {
114         return componentClass;
115     }
116 
117     public void setComponentClass(String componentClass) {
118         this.componentClass = componentClass;
119     }
120 
121     public String getPropertyName() {
122         return propertyName;
123     }
124 
125     public void setPropertyName(String propertyName) {
126         this.propertyName = propertyName;
127     }
128 
129     public String getTableName() {
130         return tableName;
131     }
132 
133     public void setTableName(String tableName) {
134         this.tableName = tableName;
135     }
136 
137     public String getFieldName() {
138         return fieldName;
139     }
140 
141     public void setFieldName(String fieldName) {
142         this.fieldName = fieldName;
143     }
144 
145     public FunctionalFieldDescription getFunctionalFieldDescription() {
146         return functionalFieldDescription;
147     }
148 
149     public void setFunctionalFieldDescription(FunctionalFieldDescription functionalFieldDescription) {
150         this.functionalFieldDescription = functionalFieldDescription;
151     }
152 
153     
154     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
155         return new LinkedHashMap();
156     }
157 }