Source Code Cross Referenced for BusinessObjectDictionaryServiceImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » core » service » impl » 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.service.impl 
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.service.impl;
017:
018:        import java.beans.IndexedPropertyDescriptor;
019:        import java.beans.PropertyDescriptor;
020:        import java.lang.reflect.InvocationTargetException;
021:        import java.util.ArrayList;
022:        import java.util.Collection;
023:        import java.util.Iterator;
024:        import java.util.List;
025:
026:        import org.apache.commons.beanutils.PropertyUtils;
027:        import org.apache.commons.lang.StringUtils;
028:        import org.apache.log4j.Logger;
029:        import org.kuali.core.bo.BusinessObject;
030:        import org.kuali.core.bo.PersistableBusinessObject;
031:        import org.kuali.core.datadictionary.BusinessObjectEntry;
032:        import org.kuali.core.datadictionary.FieldDefinition;
033:        import org.kuali.core.datadictionary.FieldPairDefinition;
034:        import org.kuali.core.datadictionary.InquiryDefinition;
035:        import org.kuali.core.datadictionary.InquirySectionDefinition;
036:        import org.kuali.core.datadictionary.LookupDefinition;
037:        import org.kuali.core.datadictionary.MaintenanceDocumentEntry;
038:        import org.kuali.core.exceptions.IntrospectionException;
039:        import org.kuali.core.service.BusinessObjectDictionaryService;
040:        import org.kuali.core.service.DataDictionaryService;
041:        import org.kuali.core.service.PersistenceStructureService;
042:        import org.kuali.core.util.ObjectUtils;
043:
044:        /**
045:         * This class is the service implementation for the BusinessObjectDictionary. This is the default, Kuali delivered implementation
046:         * which leverages the DataDictionaryService.
047:         */
048:        public class BusinessObjectDictionaryServiceImpl implements 
049:                BusinessObjectDictionaryService {
050:            private static Logger LOG = Logger
051:                    .getLogger(BusinessObjectDictionaryServiceImpl.class);
052:
053:            private DataDictionaryService dataDictionaryService;
054:            private PersistenceStructureService persistenceStructureService;
055:
056:            /**
057:             * Uses the DataDictionaryService.
058:             * 
059:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getBusinessObjectEntries()
060:             */
061:            public List getBusinessObjectClassnames() {
062:                return getDataDictionaryService().getDataDictionary()
063:                        .getBusinessObjectClassNames();
064:            }
065:
066:            /**
067:             * @see org.kuali.core.service.BusinessObjectDictionaryService#isLookupable(java.lang.Class)
068:             */
069:            public Boolean isLookupable(Class businessObjectClass) {
070:                Boolean isLookupable = null;
071:
072:                BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass);
073:                if (entry != null) {
074:                    isLookupable = Boolean.valueOf(entry.hasLookupDefinition());
075:                }
076:
077:                return isLookupable;
078:            }
079:
080:            /**
081:             * @see org.kuali.core.service.BusinessObjectDictionaryService#isInquirable(java.lang.Class)
082:             */
083:            public Boolean isInquirable(Class businessObjectClass) {
084:                Boolean isInquirable = null;
085:
086:                BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass);
087:                if (entry != null) {
088:                    isInquirable = Boolean
089:                            .valueOf(entry.hasInquiryDefinition());
090:                }
091:
092:                return isInquirable;
093:            }
094:
095:            /**
096:             * @see org.kuali.core.service.BusinessObjectDictionaryService#isMaintainable(java.lang.Class)
097:             */
098:            public Boolean isMaintainable(Class businessObjectClass) {
099:                Boolean isMaintainable = null;
100:
101:                BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass);
102:                if (entry != null) {
103:                    isMaintainable = Boolean
104:                            .valueOf(getMaintenanceDocumentEntry(businessObjectClass) != null);
105:                }
106:
107:                return isMaintainable;
108:            }
109:
110:            /**
111:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getLookupFieldNames(java.lang.Class)
112:             */
113:            public List getLookupFieldNames(Class businessObjectClass) {
114:                List results = null;
115:
116:                LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass);
117:                if (lookupDefinition != null) {
118:                    results = lookupDefinition.getLookupFieldNames();
119:                }
120:
121:                return results;
122:            }
123:
124:            /**
125:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getLookupTitle(java.lang.Class)
126:             */
127:            public String getLookupTitle(Class businessObjectClass) {
128:                String lookupTitle = "";
129:
130:                LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass);
131:                if (lookupDefinition != null) {
132:                    lookupTitle = lookupDefinition.getTitle();
133:                }
134:
135:                return lookupTitle;
136:            }
137:
138:            /**
139:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getLookupMenuBar(java.lang.Class)
140:             */
141:            public String getLookupMenuBar(Class businessObjectClass) {
142:                String menubar = "";
143:
144:                LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass);
145:                if (lookupDefinition != null) {
146:                    if (lookupDefinition.hasMenubar()) {
147:                        menubar = lookupDefinition.getMenubar();
148:                    }
149:                }
150:
151:                return menubar;
152:            }
153:
154:            /**
155:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getLookupInstructions(java.lang.Class)
156:             */
157:            public String getLookupInstructions(Class businessObjectClass) {
158:                String instructions = "";
159:
160:                LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass);
161:                if (lookupDefinition != null) {
162:                    if (lookupDefinition.hasInstructions()) {
163:                        instructions = lookupDefinition.getInstructions();
164:                    }
165:                }
166:
167:                return instructions;
168:            }
169:
170:            /**
171:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getExtraButtonSource(java.lang.Class)
172:             */
173:            public String getExtraButtonSource(Class businessObjectClass) {
174:                String buttonSource = "";
175:
176:                LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass);
177:                if (lookupDefinition != null) {
178:                    if (lookupDefinition.hasExtraButtonSource()) {
179:                        buttonSource = lookupDefinition.getExtraButtonSource();
180:                    }
181:                }
182:
183:                return buttonSource;
184:            }
185:
186:            /**
187:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getExtraButtonParams(java.lang.Class)
188:             */
189:            public String getExtraButtonParams(Class businessObjectClass) {
190:                String buttonParams = "";
191:
192:                LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass);
193:                if (lookupDefinition != null) {
194:                    if (lookupDefinition.hasExtraButtonParams()) {
195:                        buttonParams = lookupDefinition.getExtraButtonParams();
196:                    }
197:                }
198:
199:                return buttonParams;
200:            }
201:
202:            /**
203:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getLookupDefaultSortFieldName(java.lang.Class)
204:             */
205:            public List getLookupDefaultSortFieldNames(Class businessObjectClass) {
206:                List defaultSort = null;
207:
208:                LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass);
209:                if (lookupDefinition != null) {
210:                    if (lookupDefinition.hasDefaultSort()) {
211:                        defaultSort = lookupDefinition.getDefaultSort()
212:                                .getAttributeNames();
213:                    }
214:                }
215:                if (defaultSort == null) {
216:                    defaultSort = new ArrayList();
217:                }
218:
219:                return defaultSort;
220:            }
221:
222:            /**
223:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getLookupResultFieldNames(java.lang.Class)
224:             */
225:            public List<String> getLookupResultFieldNames(
226:                    Class businessObjectClass) {
227:                List<String> results = null;
228:
229:                LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass);
230:                if (lookupDefinition != null) {
231:                    results = lookupDefinition.getResultFieldNames();
232:                }
233:
234:                return results;
235:            }
236:
237:            /**
238:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getLookupResultFieldMaxLength(java.lang.Class, java.lang.String)
239:             */
240:            public Integer getLookupResultFieldMaxLength(
241:                    Class businessObjectClass, String resultFieldName) {
242:                LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass);
243:                FieldDefinition field = lookupDefinition
244:                        .getResultField(resultFieldName);
245:                return field.getMaxLength();
246:            }
247:
248:            /**
249:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getLookupAttributeRequired(java.lang.Class, java.lang.String)
250:             */
251:            public Boolean getLookupAttributeRequired(
252:                    Class businessObjectClass, String attributeName) {
253:                Boolean isRequired = null;
254:
255:                FieldDefinition definition = getLookupFieldDefinition(
256:                        businessObjectClass, attributeName);
257:                if (definition != null) {
258:                    isRequired = Boolean.valueOf(definition.isRequired());
259:                }
260:
261:                return isRequired;
262:            }
263:
264:            /**
265:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getInquiryFieldNames(java.lang.Class, java.lang.String)
266:             */
267:            public List getInquiryFieldNames(Class businessObjectClass,
268:                    String sectionTitle) {
269:                List results = null;
270:
271:                InquirySectionDefinition inquirySection = getInquiryDefinition(
272:                        businessObjectClass).getInquirySection(sectionTitle);
273:                if (inquirySection != null) {
274:                    results = inquirySection.getInquiryFieldNames();
275:                }
276:
277:                return results;
278:            }
279:
280:            /**
281:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getInquirySections(java.lang.Class)
282:             */
283:            public List getInquirySections(Class businessObjectClass) {
284:                List results = null;
285:
286:                results = getInquiryDefinition(businessObjectClass)
287:                        .getInquirySections();
288:
289:                return results;
290:            }
291:
292:            /**
293:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getInquiryTitle(java.lang.Class)
294:             */
295:            public String getInquiryTitle(Class businessObjectClass) {
296:                String title = "";
297:
298:                InquiryDefinition inquiryDefinition = getInquiryDefinition(businessObjectClass);
299:                if (inquiryDefinition != null) {
300:                    title = inquiryDefinition.getTitle();
301:                }
302:
303:                return title;
304:            }
305:
306:            /**
307:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getInquirableClass(java.lang.Class)
308:             */
309:            public Class getInquirableClass(Class businessObjectClass) {
310:                Class clazz = null;
311:
312:                InquiryDefinition inquiryDefinition = getInquiryDefinition(businessObjectClass);
313:                if (inquiryDefinition != null) {
314:                    clazz = inquiryDefinition.getInquirableClass();
315:                }
316:
317:                return clazz;
318:            }
319:
320:            /**
321:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getMaintainableTitle(java.lang.Class)
322:             */
323:            public String getMaintainableLabel(Class businessObjectClass) {
324:                String label = "";
325:
326:                MaintenanceDocumentEntry entry = getMaintenanceDocumentEntry(businessObjectClass);
327:                if (entry != null) {
328:                    label = entry.getLabel();
329:                }
330:
331:                return label;
332:            }
333:
334:            /**
335:             * 
336:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getLookupableID(java.lang.Class)
337:             */
338:            public String getLookupableID(Class businessObjectClass) {
339:                String lookupableID = null;
340:
341:                LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass);
342:                if (lookupDefinition != null) {
343:                    lookupableID = lookupDefinition.getLookupableID();
344:                }
345:
346:                return lookupableID;
347:            }
348:
349:            /**
350:             * Recurses down the updatable references and collections of a BO, uppercasing those attributes which are marked as needing to be
351:             * uppercased in the data dictionary.  Updatability of a reference or collection is defined by the PersistenceStructureService
352:             * 
353:             * @param bo the BO to uppercase
354:             * 
355:             * @see PersistenceStructureService#isCollectionUpdatable(Class, String)
356:             * @see PersistenceStructureService#isReferenceUpdatable(Class, String)
357:             * @see DataDictionaryService#getAttributeForceUppercase(Class, String)
358:             */
359:            public void performForceUppercase(BusinessObject bo) {
360:                PropertyDescriptor descriptors[] = PropertyUtils
361:                        .getPropertyDescriptors(bo);
362:                for (int i = 0; i < descriptors.length; ++i) {
363:                    try {
364:                        if (descriptors[i] instanceof  IndexedPropertyDescriptor) {
365:                            // Skip this case because PropertyUtils.getProperty(bo, descriptors[i].getName()) will throw a
366:                            // NoSuchMethodException on those. These
367:                            // fields are usually convenience methods in the BO and in the below code we anyway wouldn't know which index
368:                            // .toUpperCase().
369:                        } else {
370:                            Object nestedObject = ObjectUtils.getPropertyValue(
371:                                    bo, descriptors[i].getName());
372:                            if (nestedObject instanceof  BusinessObject) {
373:                                if (persistenceStructureService
374:                                        .isPersistable(nestedObject.getClass())) {
375:                                    try {
376:                                        if (persistenceStructureService
377:                                                .hasReference(bo.getClass(),
378:                                                        descriptors[i]
379:                                                                .getName())) {
380:                                            if (persistenceStructureService
381:                                                    .isReferenceUpdatable(bo
382:                                                            .getClass(),
383:                                                            descriptors[i]
384:                                                                    .getName())) {
385:                                                if (persistenceStructureService
386:                                                        .getForeignKeyFieldsPopulationState(
387:                                                                (PersistableBusinessObject) bo,
388:                                                                descriptors[i]
389:                                                                        .getName())
390:                                                        .isAllFieldsPopulated()) {
391:                                                    // check FKs to prevent probs caused by referential integrity problems
392:                                                    performForceUppercase((BusinessObject) nestedObject);
393:                                                }
394:                                            }
395:                                        }
396:                                    } catch (org.kuali.core.exceptions.ReferenceAttributeNotAnOjbReferenceException ranaore) {
397:                                        LOG
398:                                                .debug("Propery "
399:                                                        + descriptors[i]
400:                                                                .getName()
401:                                                        + " is not a foreign key reference.");
402:                                    }
403:                                }
404:                            } else if (nestedObject instanceof  String) {
405:                                if (dataDictionaryService
406:                                        .isAttributeDefined(bo.getClass(),
407:                                                descriptors[i].getName())
408:                                        .booleanValue()
409:                                        && dataDictionaryService
410:                                                .getAttributeForceUppercase(
411:                                                        bo.getClass(),
412:                                                        descriptors[i]
413:                                                                .getName())
414:                                                .booleanValue()) {
415:                                    String curValue = (String) nestedObject;
416:                                    PropertyUtils.setProperty(bo,
417:                                            descriptors[i].getName(), curValue
418:                                                    .toUpperCase());
419:                                }
420:                            } else {
421:                                if (nestedObject instanceof  Collection) {
422:                                    if (persistenceStructureService
423:                                            .hasCollection(bo.getClass(),
424:                                                    descriptors[i].getName())) {
425:                                        if (persistenceStructureService
426:                                                .isCollectionUpdatable(bo
427:                                                        .getClass(),
428:                                                        descriptors[i]
429:                                                                .getName())) {
430:                                            Iterator iter = ((Collection) nestedObject)
431:                                                    .iterator();
432:                                            while (iter.hasNext()) {
433:                                                Object collElem = iter.next();
434:                                                if (collElem instanceof  BusinessObject) {
435:                                                    if (persistenceStructureService
436:                                                            .isPersistable(collElem
437:                                                                    .getClass())) {
438:                                                        performForceUppercase((BusinessObject) collElem);
439:                                                    }
440:                                                }
441:                                            }
442:                                        }
443:                                    }
444:                                }
445:                            }
446:                        }
447:                    } catch (IllegalAccessException e) {
448:                        throw new IntrospectionException(
449:                                "unable to performForceUppercase", e);
450:                    } catch (InvocationTargetException e) {
451:                        throw new IntrospectionException(
452:                                "unable to performForceUppercase", e);
453:                    } catch (NoSuchMethodException e) {
454:                        // if the getter/setter does not exist, just skip over
455:                        //throw new IntrospectionException("unable to performForceUppercase", e);
456:                    }
457:                }
458:            }
459:
460:            /**
461:             * Sets the instance of the data dictionary service.
462:             * 
463:             * @param dataDictionaryService
464:             */
465:            public void setDataDictionaryService(
466:                    DataDictionaryService dataDictionaryService) {
467:                this .dataDictionaryService = dataDictionaryService;
468:            }
469:
470:            /**
471:             * This method retrieves the instance of the data dictionary service.
472:             * 
473:             * @return An instance of the DataDictionaryService.
474:             */
475:            public DataDictionaryService getDataDictionaryService() {
476:                return this .dataDictionaryService;
477:            }
478:
479:            /**
480:             * @param businessObjectClass
481:             * @return BusinessObjectEntry for the given businessObjectClass, or null if there is none
482:             * @throws IllegalArgumentException if the given Class is null or is not a BusinessObject class
483:             */
484:            private BusinessObjectEntry getBusinessObjectEntry(
485:                    Class businessObjectClass) {
486:                validateBusinessObjectClass(businessObjectClass);
487:
488:                BusinessObjectEntry entry = getDataDictionaryService()
489:                        .getDataDictionary().getBusinessObjectEntry(
490:                                businessObjectClass.getName());
491:                return entry;
492:            }
493:
494:            /**
495:             * @param businessObjectClass
496:             * @return MaintenanceDocumentEntry for the given businessObjectClass, or null if there is none
497:             * @throws IllegalArgumentException if the given Class is null or is not a BusinessObject class
498:             */
499:            private MaintenanceDocumentEntry getMaintenanceDocumentEntry(
500:                    Class businessObjectClass) {
501:                validateBusinessObjectClass(businessObjectClass);
502:
503:                MaintenanceDocumentEntry entry = getDataDictionaryService()
504:                        .getDataDictionary()
505:                        .getMaintenanceDocumentEntryForBusinessObjectClass(
506:                                businessObjectClass);
507:                return entry;
508:            }
509:
510:            /**
511:             * @param businessObjectClass
512:             * @return LookupDefinition for the given businessObjectClass, or null if there is none
513:             * @throws IllegalArgumentException if the given Class is null or is not a BusinessObject class
514:             */
515:            private LookupDefinition getLookupDefinition(
516:                    Class businessObjectClass) {
517:                LookupDefinition lookupDefinition = null;
518:
519:                BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass);
520:                if (entry != null) {
521:                    if (entry.hasLookupDefinition()) {
522:                        lookupDefinition = entry.getLookupDefinition();
523:                    }
524:                }
525:
526:                return lookupDefinition;
527:            }
528:
529:            /**
530:             * @param businessObjectClass
531:             * @param attributeName
532:             * @return FieldDefinition for the given businessObjectClass and lookup field name, or null if there is none
533:             * @throws IllegalArgumentException if the given Class is null or is not a BusinessObject class
534:             */
535:            private FieldDefinition getLookupFieldDefinition(
536:                    Class businessObjectClass, String lookupFieldName) {
537:                if (StringUtils.isBlank(lookupFieldName)) {
538:                    throw new IllegalArgumentException(
539:                            "invalid (blank) lookupFieldName");
540:                }
541:
542:                FieldDefinition fieldDefinition = null;
543:
544:                LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass);
545:                if (lookupDefinition != null) {
546:                    fieldDefinition = lookupDefinition
547:                            .getLookupField(lookupFieldName);
548:                }
549:
550:                return fieldDefinition;
551:            }
552:
553:            /**
554:             * @param businessObjectClass
555:             * @param attributeName
556:             * @return FieldDefinition for the given businessObjectClass and lookup result field name, or null if there is none
557:             * @throws IllegalArgumentException if the given Class is null or is not a BusinessObject class
558:             */
559:            private FieldDefinition getLookupResultFieldDefinition(
560:                    Class businessObjectClass, String lookupFieldName) {
561:                if (StringUtils.isBlank(lookupFieldName)) {
562:                    throw new IllegalArgumentException(
563:                            "invalid (blank) lookupFieldName");
564:                }
565:
566:                FieldDefinition fieldDefinition = null;
567:
568:                LookupDefinition lookupDefinition = getLookupDefinition(businessObjectClass);
569:                if (lookupDefinition != null) {
570:                    fieldDefinition = lookupDefinition
571:                            .getResultField(lookupFieldName);
572:                }
573:
574:                return fieldDefinition;
575:            }
576:
577:            /**
578:             * @param businessObjectClass
579:             * @return InquiryDefinition for the given businessObjectClass, or null if there is none
580:             * @throws IllegalArgumentException if the given Class is null or is not a BusinessObject class
581:             */
582:            private InquiryDefinition getInquiryDefinition(
583:                    Class businessObjectClass) {
584:                InquiryDefinition inquiryDefinition = null;
585:
586:                BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass);
587:                if (entry != null) {
588:                    if (entry.hasInquiryDefinition()) {
589:                        inquiryDefinition = entry.getInquiryDefinition();
590:                    }
591:                }
592:
593:                return inquiryDefinition;
594:            }
595:
596:            /**
597:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getTitleAttribute(java.lang.Class)
598:             */
599:            public String getTitleAttribute(Class businessObjectClass) {
600:                String titleAttribute = null;
601:
602:                BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass);
603:                if (entry != null) {
604:                    titleAttribute = entry.getTitleAttribute();
605:                }
606:
607:                return titleAttribute;
608:            }
609:
610:            /**
611:             * @param businessObjectClass
612:             * @param attributeName
613:             * @return FieldDefinition for the given businessObjectClass and field name, or null if there is none
614:             * @throws IllegalArgumentException if the given Class is null or is not a BusinessObject class
615:             */
616:            private FieldDefinition getInquiryFieldDefinition(
617:                    Class businessObjectClass, String fieldName) {
618:                if (StringUtils.isBlank(fieldName)) {
619:                    throw new IllegalArgumentException(
620:                            "invalid (blank) fieldName");
621:                }
622:
623:                FieldDefinition fieldDefinition = null;
624:
625:                InquiryDefinition inquiryDefinition = getInquiryDefinition(businessObjectClass);
626:                if (inquiryDefinition != null) {
627:                    fieldDefinition = inquiryDefinition
628:                            .getFieldDefinition(fieldName);
629:                }
630:
631:                return fieldDefinition;
632:            }
633:
634:            /**
635:             * @param businessObjectClass
636:             * @throws IllegalArgumentException if the given Class is null or is not a BusinessObject class
637:             */
638:            private void validateBusinessObjectClass(Class businessObjectClass) {
639:                if (businessObjectClass == null) {
640:                    throw new IllegalArgumentException(
641:                            "invalid (null) businessObjectClass");
642:                }
643:                if (!BusinessObject.class.isAssignableFrom(businessObjectClass)) {
644:                    throw new IllegalArgumentException("class '"
645:                            + businessObjectClass.getName()
646:                            + "' is not a descendent of BusinessObject");
647:                }
648:            }
649:
650:            /**
651:             * @param fieldPairs
652:             * @param toFirst
653:             * @return
654:             */
655:            private String buildFieldPairString(List fieldPairs, boolean toFirst) {
656:                StringBuffer assembly = new StringBuffer();
657:
658:                for (Iterator i = fieldPairs.iterator(); i.hasNext();) {
659:                    FieldPairDefinition fieldPair = (FieldPairDefinition) i
660:                            .next();
661:                    String field1 = toFirst ? fieldPair.getFieldTo()
662:                            : fieldPair.getFieldFrom();
663:                    String field2 = toFirst ? fieldPair.getFieldFrom()
664:                            : fieldPair.getFieldTo();
665:                    // TODO BJM -- due to a bug? I switched the order of these below...
666:                    assembly.append(field2 + ":" + field1);
667:                    if (i.hasNext()) {
668:                        assembly.append(",");
669:                    }
670:                }
671:
672:                return assembly.toString();
673:            }
674:
675:            /**
676:             * @see org.kuali.core.service.BusinessObjectDictionaryService#forceLookupResultFieldInquiry(java.lang.Class, java.lang.String)
677:             */
678:            public Boolean forceLookupResultFieldInquiry(
679:                    Class businessObjectClass, String attributeName) {
680:                Boolean forceLookup = null;
681:                if (getLookupResultFieldDefinition(businessObjectClass,
682:                        attributeName) != null) {
683:                    forceLookup = Boolean
684:                            .valueOf(getLookupResultFieldDefinition(
685:                                    businessObjectClass, attributeName)
686:                                    .isForceInquiry());
687:                }
688:
689:                return forceLookup;
690:            }
691:
692:            /**
693:             * @see org.kuali.core.service.BusinessObjectDictionaryService#noLookupResultFieldInquiry(java.lang.Class, java.lang.String)
694:             */
695:            public Boolean noLookupResultFieldInquiry(
696:                    Class businessObjectClass, String attributeName) {
697:                Boolean noLookup = null;
698:                if (getLookupResultFieldDefinition(businessObjectClass,
699:                        attributeName) != null) {
700:                    noLookup = Boolean.valueOf(getLookupResultFieldDefinition(
701:                            businessObjectClass, attributeName).isNoInquiry());
702:                }
703:
704:                return noLookup;
705:            }
706:
707:            /**
708:             * @see org.kuali.core.service.BusinessObjectDictionaryService#forceLookupFieldLookup(java.lang.Class, java.lang.String)
709:             */
710:            public Boolean forceLookupFieldLookup(Class businessObjectClass,
711:                    String attributeName) {
712:                Boolean forceLookup = null;
713:                if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) {
714:                    forceLookup = Boolean
715:                            .valueOf(getLookupFieldDefinition(
716:                                    businessObjectClass, attributeName)
717:                                    .isForceLookup());
718:                }
719:
720:                return forceLookup;
721:            }
722:
723:            /**
724:             * @see org.kuali.core.service.BusinessObjectDictionaryService#noLookupFieldLookup(java.lang.Class, java.lang.String)
725:             */
726:            public Boolean noLookupFieldLookup(Class businessObjectClass,
727:                    String attributeName) {
728:                Boolean noLookup = null;
729:                if (getLookupFieldDefinition(businessObjectClass, attributeName) != null) {
730:                    noLookup = Boolean.valueOf(getLookupFieldDefinition(
731:                            businessObjectClass, attributeName).isNoLookup());
732:                }
733:
734:                return noLookup;
735:            }
736:
737:            /**
738:             * @see org.kuali.core.service.BusinessObjectDictionaryService#forceInquiryFieldInquiry(java.lang.Class, java.lang.String)
739:             */
740:            public Boolean forceInquiryFieldInquiry(Class businessObjectClass,
741:                    String attributeName) {
742:                Boolean forceInquiry = null;
743:                if (getInquiryFieldDefinition(businessObjectClass,
744:                        attributeName) != null) {
745:                    forceInquiry = Boolean.valueOf(getInquiryFieldDefinition(
746:                            businessObjectClass, attributeName)
747:                            .isForceInquiry());
748:                }
749:
750:                return forceInquiry;
751:            }
752:
753:            /**
754:             * @see org.kuali.core.service.BusinessObjectDictionaryService#noInquiryFieldInquiry(java.lang.Class, java.lang.String)
755:             */
756:            public Boolean noInquiryFieldInquiry(Class businessObjectClass,
757:                    String attributeName) {
758:                Boolean noInquiry = null;
759:                if (getInquiryFieldDefinition(businessObjectClass,
760:                        attributeName) != null) {
761:                    noInquiry = Boolean.valueOf(getInquiryFieldDefinition(
762:                            businessObjectClass, attributeName).isNoInquiry());
763:                }
764:
765:                return noInquiry;
766:            }
767:
768:            /**
769:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getLookupFieldDefaultValue(java.lang.Class, java.lang.String)
770:             */
771:            public String getLookupFieldDefaultValue(Class businessObjectClass,
772:                    String attributeName) {
773:                return getLookupFieldDefinition(businessObjectClass,
774:                        attributeName).getDefaultValue();
775:            }
776:
777:            /**
778:             * @see org.kuali.core.service.BusinessObjectDictionaryService#getLookupFieldDefaultValueFinderClass(java.lang.Class,
779:             *      java.lang.String)
780:             */
781:            public Class getLookupFieldDefaultValueFinderClass(
782:                    Class businessObjectClass, String attributeName) {
783:                return getLookupFieldDefinition(businessObjectClass,
784:                        attributeName).getDefaultValueFinderClass();
785:            }
786:
787:            public void setPersistenceStructureService(
788:                    PersistenceStructureService persistenceStructureService) {
789:                this .persistenceStructureService = persistenceStructureService;
790:            }
791:
792:            public Boolean areNotesSupported(Class businessObjectClass) {
793:                Boolean hasNotesSupport = null;
794:
795:                BusinessObjectEntry entry = getBusinessObjectEntry(businessObjectClass);
796:                if (entry != null) {
797:                    hasNotesSupport = Boolean.valueOf(entry.isBoNotesEnabled());
798:                }
799:
800:                return hasNotesSupport;
801:            }
802:
803:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.