Source Code Cross Referenced for MaintainableCollectionDefinition.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » core » datadictionary » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » org.kuali.core.datadictionary 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 The Kuali Foundation.
003:         * 
004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         * http://www.opensource.org/licenses/ecl1.php
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.kuali.core.datadictionary;
017:
018:        import java.util.Collection;
019:        import java.util.Collections;
020:        import java.util.Iterator;
021:        import java.util.LinkedHashMap;
022:        import java.util.Map;
023:
024:        import org.apache.commons.lang.StringUtils;
025:        import org.apache.commons.logging.Log;
026:        import org.apache.commons.logging.LogFactory;
027:        import org.kuali.core.datadictionary.exception.AttributeValidationException;
028:        import org.kuali.core.datadictionary.exception.ClassValidationException;
029:        import org.kuali.core.datadictionary.exception.DuplicateEntryException;
030:
031:        /**
032:         * MaintainableCollectionDefinition
033:         */
034:        public class MaintainableCollectionDefinition extends
035:                MaintainableItemDefinition implements  CollectionDefinitionI {
036:            // logger
037:            private static Log LOG = LogFactory
038:                    .getLog(MaintainableCollectionDefinition.class);
039:
040:            private String name;
041:            private Class businessObjectClass;
042:
043:            private String sourceClassName;
044:            private String sourceAttributeName;
045:            private String summaryTitle;
046:            private String attributeToHighlightOnDuplicateKey;
047:
048:            private boolean includeAddLine = true;
049:            private boolean includeMultipleLookupLine = true;
050:
051:            private Map maintainableFields;
052:            private Map maintainableCollections;
053:            private Map summaryFields;
054:            private Map duplicateIdentificationFields;
055:
056:            private Map<String, String> template;
057:
058:            public MaintainableCollectionDefinition() {
059:                LOG.debug("creating new MaintainableCollectionDefinition");
060:
061:                this .maintainableFields = new LinkedHashMap();
062:                this .maintainableCollections = new LinkedHashMap();
063:                this .summaryFields = new LinkedHashMap();
064:                this .duplicateIdentificationFields = new LinkedHashMap();
065:            }
066:
067:            /**
068:             * @return attributeName
069:             */
070:            public String getName() {
071:                return name;
072:            }
073:
074:            /**
075:             * Sets name to the given value.
076:             * 
077:             * @param name
078:             * @throws IllegalArgumentException if the given name is blank
079:             */
080:            public void setName(String name) {
081:                if (StringUtils.isBlank(name)) {
082:                    throw new IllegalArgumentException("invalid (blank) name");
083:                }
084:                if (LOG.isDebugEnabled()) {
085:                    LOG.debug("calling setName '" + name + "'");
086:                }
087:
088:                this .name = name;
089:            }
090:
091:            /**
092:             * @return businessObjectClass
093:             */
094:            public Class getBusinessObjectClass() {
095:                return this .businessObjectClass;
096:            }
097:
098:            /**
099:             * Sets businessObjectClass to the given value
100:             * 
101:             * @param businessObjectClass
102:             */
103:            public void setBusinessObjectClass(Class businessObjectClass) {
104:                if (businessObjectClass == null) {
105:                    throw new IllegalArgumentException(
106:                            "invalid (null) businessObjectClass");
107:                }
108:                if (LOG.isDebugEnabled()) {
109:                    LOG.debug("calling setBusinessObjectClass '"
110:                            + businessObjectClass.getName() + "'");
111:                }
112:
113:                this .businessObjectClass = businessObjectClass;
114:            }
115:
116:            /**
117:             * @param maintainableField
118:             * @throws IllegalArgumentException if the given maintainableField is null
119:             */
120:            public void addMaintainableField(
121:                    MaintainableFieldDefinition maintainableField) {
122:                if (maintainableField == null) {
123:                    throw new IllegalArgumentException(
124:                            "invalid (null) maintainableField");
125:                }
126:                if (LOG.isDebugEnabled()) {
127:                    LOG.debug("calling addMaintainableField for field '"
128:                            + maintainableField.getName() + "'");
129:                }
130:
131:                String fieldName = maintainableField.getName();
132:                if (this .maintainableFields.containsKey(fieldName)) {
133:                    throw new DuplicateEntryException(
134:                            "duplicate fieldName entry for field '" + fieldName
135:                                    + "'");
136:                }
137:
138:                this .maintainableFields.put(fieldName, maintainableField);
139:            }
140:
141:            /**
142:             * @return Collection of all lookupField MaintainableFieldDefinitions associated with this MaintainableCollectionDefinition, in
143:             *         the order in which they were added
144:             */
145:            public Collection<MaintainableFieldDefinition> getMaintainableFields() {
146:                return Collections
147:                        .unmodifiableCollection(this .maintainableFields
148:                                .values());
149:            }
150:
151:            public Collection getFields() {
152:                return this .getMaintainableFields();
153:            }
154:
155:            /**
156:             * Directly validate simple fields, call completeValidation on Definition fields.
157:             * 
158:             * @see org.kuali.core.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class, java.lang.Object)
159:             */
160:            public void completeValidation(Class rootBusinessObjectClass,
161:                    Class otherBusinessObjectClass,
162:                    ValidationCompletionUtils validationCompletionUtils) {
163:                if (!validationCompletionUtils.isCollectionPropertyOf(
164:                        rootBusinessObjectClass, name)) {
165:                    throw new AttributeValidationException(
166:                            "unable to find collection named '" + name
167:                                    + "' in rootBusinessObjectClass '"
168:                                    + rootBusinessObjectClass.getName() + "' ("
169:                                    + getParseLocation() + ")");
170:                }
171:
172:                if (!validationCompletionUtils
173:                        .isBusinessObjectClass(this .businessObjectClass)) {
174:                    throw new ClassValidationException("class '"
175:                            + businessObjectClass.getName()
176:                            + "' is not a subclass of BusinessObject ("
177:                            + getParseLocation() + ")");
178:                }
179:                if (dissalowDuplicateKey()) {
180:                    if (!validationCompletionUtils.isPropertyOf(
181:                            this .businessObjectClass,
182:                            attributeToHighlightOnDuplicateKey)) {
183:                        throw new AttributeValidationException(
184:                                "unable to find attribute named '" + name
185:                                        + "'in businessObjectClass '"
186:                                        + businessObjectClass.getName()
187:                                        + "' of collection '" + name
188:                                        + "' in rootBusinessObjectClass '"
189:                                        + rootBusinessObjectClass.getName()
190:                                        + "' (" + getParseLocation() + ")");
191:                    }
192:                }
193:
194:                for (Iterator i = maintainableFields.entrySet().iterator(); i
195:                        .hasNext();) {
196:                    Map.Entry e = (Map.Entry) i.next();
197:
198:                    MaintainableFieldDefinition maintainableField = (MaintainableFieldDefinition) e
199:                            .getValue();
200:                    maintainableField.completeValidation(
201:                            this .businessObjectClass, null,
202:                            validationCompletionUtils);
203:                }
204:
205:                for (Iterator i = maintainableCollections.entrySet().iterator(); i
206:                        .hasNext();) {
207:                    Map.Entry e = (Map.Entry) i.next();
208:
209:                    MaintainableCollectionDefinition maintainableCollection = (MaintainableCollectionDefinition) e
210:                            .getValue();
211:                    maintainableCollection.completeValidation(
212:                            this .businessObjectClass, null,
213:                            validationCompletionUtils);
214:                }
215:            }
216:
217:            /**
218:             * @see java.lang.Object#toString()
219:             */
220:            public String toString() {
221:                return "MaintainableCollectionDefinition for " + getName();
222:            }
223:
224:            public String getSourceAttributeName() {
225:                return sourceAttributeName;
226:            }
227:
228:            public void setSourceAttributeName(String sourceAttributeName) {
229:                this .sourceAttributeName = sourceAttributeName;
230:            }
231:
232:            public String getSourceClassName() {
233:                return sourceClassName;
234:            }
235:
236:            public void setSourceClassName(String sourceClassName) {
237:                this .sourceClassName = sourceClassName;
238:            }
239:
240:            public Map<String, String> getTemplate() {
241:                return template;
242:            }
243:
244:            public void setTemplate(Map<String, String> template) {
245:                this .template = template;
246:            }
247:
248:            public boolean getIncludeAddLine() {
249:                return includeAddLine;
250:            }
251:
252:            public void setIncludeAddLine(boolean includeAddLine) {
253:                this .includeAddLine = includeAddLine;
254:            }
255:
256:            /**
257:             * @param maintainableCollection
258:             * @throws IllegalArgumentException if the given maintainableCollection is null
259:             */
260:            public void addMaintainableCollection(
261:                    MaintainableCollectionDefinition maintainableCollection) {
262:                if (maintainableCollection == null) {
263:                    throw new IllegalArgumentException(
264:                            "invalid (null) maintainableCollection");
265:                }
266:                if (LOG.isDebugEnabled()) {
267:                    LOG.debug("calling addMaintainableCollection for field '"
268:                            + maintainableCollection.getName() + "'");
269:                }
270:
271:                String fieldName = maintainableCollection.getName();
272:                if (this .maintainableCollections.containsKey(fieldName)) {
273:                    throw new DuplicateEntryException(
274:                            "duplicate fieldName entry for field '" + fieldName
275:                                    + "'");
276:                }
277:
278:                this .maintainableCollections.put(fieldName,
279:                        maintainableCollection);
280:            }
281:
282:            /**
283:             * @return Collection of all lookupField MaintainableCollectionDefinitions associated with this
284:             *         MaintainableCollectionDefinition, in the order in which they were added
285:             */
286:            public Collection<MaintainableCollectionDefinition> getMaintainableCollections() {
287:                return Collections
288:                        .unmodifiableCollection(this .maintainableCollections
289:                                .values());
290:            }
291:
292:            public Collection getCollections() {
293:                return this .getMaintainableCollections();
294:            }
295:
296:            /**
297:             * @param maintainableCollection
298:             * @throws IllegalArgumentException if the given maintainableCollection is null
299:             */
300:            public void addSummaryField(MaintainableFieldDefinition summaryField) {
301:                if (summaryField == null) {
302:                    throw new IllegalArgumentException(
303:                            "invalid (null) summaryField");
304:                }
305:                if (LOG.isDebugEnabled()) {
306:                    LOG.debug("calling addSummaryField for field '"
307:                            + summaryField.getName() + "'");
308:                }
309:
310:                String fieldName = summaryField.getName();
311:                if (this .summaryFields.containsKey(fieldName)) {
312:                    throw new DuplicateEntryException(
313:                            "duplicate fieldName entry for field '" + fieldName
314:                                    + "'");
315:                }
316:
317:                this .summaryFields.put(fieldName, summaryField);
318:            }
319:
320:            public void addDuplicateIdentificationField(
321:                    MaintainableFieldDefinition identifierField) {
322:                if (identifierField == null) {
323:                    throw new IllegalArgumentException(
324:                            "invalid (null) identifierField");
325:                }
326:                if (LOG.isDebugEnabled()) {
327:                    LOG
328:                            .debug("calling addDuplicateIdentificationField for field '"
329:                                    + identifierField.getName() + "'");
330:                }
331:
332:                String fieldName = identifierField.getName();
333:                if (this .duplicateIdentificationFields.containsKey(fieldName)) {
334:                    throw new DuplicateEntryException(
335:                            "duplicate fieldName entry for field '" + fieldName
336:                                    + "'");
337:                }
338:
339:                this .duplicateIdentificationFields.put(fieldName,
340:                        identifierField);
341:            }
342:
343:            /**
344:             * @return Collection of all SummaryFieldDefinitions associated with this SummaryFieldDefinition, in the order in which they
345:             *         were added
346:             */
347:            public Collection<MaintainableFieldDefinition> getSummaryFields() {
348:                return Collections.unmodifiableCollection(this .summaryFields
349:                        .values());
350:            }
351:
352:            public boolean hasSummaryField(String key) {
353:                return this .summaryFields.containsKey(key);
354:            }
355:
356:            public boolean isIncludeMultipleLookupLine() {
357:                return includeMultipleLookupLine;
358:            }
359:
360:            public void setIncludeMultipleLookupLine(
361:                    boolean includeMultipleLookupLine) {
362:                this .includeMultipleLookupLine = includeMultipleLookupLine;
363:            }
364:
365:            public String getSummaryTitle() {
366:                return summaryTitle;
367:            }
368:
369:            public void setSummaryTitle(String overrideSummaryName) {
370:                this .summaryTitle = overrideSummaryName;
371:            }
372:
373:            public String getAttributeToHighlightOnDuplicateKey() {
374:                return attributeToHighlightOnDuplicateKey;
375:            }
376:
377:            public void setAttributeToHighlightOnDuplicateKey(
378:                    String attributeToHighlightOnDuplicate) {
379:                this .attributeToHighlightOnDuplicateKey = attributeToHighlightOnDuplicate;
380:            }
381:
382:            public boolean dissalowDuplicateKey() {
383:                return StringUtils
384:                        .isNotBlank(getAttributeToHighlightOnDuplicateKey());
385:            }
386:
387:            public Collection<MaintainableFieldDefinition> getDuplicateIdentificationFields() {
388:                return Collections
389:                        .unmodifiableCollection(this.duplicateIdentificationFields
390:                                .values());
391:            }
392:
393:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.