Source Code Cross Referenced for KualiGlobalMaintainableImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » core » maintenance » 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.maintenance 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006-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.maintenance;
017:
018:        import java.util.HashMap;
019:        import java.util.List;
020:        import java.util.Map;
021:
022:        import org.kuali.RicePropertyConstants;
023:        import org.kuali.core.bo.GlobalBusinessObject;
024:        import org.kuali.core.bo.GlobalBusinessObjectDetail;
025:        import org.kuali.core.bo.PersistableBusinessObject;
026:        import org.kuali.core.document.MaintenanceLock;
027:        import org.kuali.core.service.BusinessObjectService;
028:        import org.kuali.core.util.ObjectUtils;
029:        import org.kuali.rice.KNSServiceLocator;
030:
031:        public abstract class KualiGlobalMaintainableImpl extends
032:                KualiMaintainableImpl {
033:            private static final long serialVersionUID = 4814145799502207182L;
034:
035:            private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
036:                    .getLogger(KualiGlobalMaintainableImpl.class);
037:
038:            /**
039:             * @see org.kuali.core.maintenance.Maintainable#prepareForSave()
040:             */
041:            @Override
042:            public void prepareForSave() {
043:                if (businessObject != null) {
044:                    prepareGlobalsForSave();
045:                }
046:            }
047:
048:            /**
049:             * @see org.kuali.core.maintenance.Maintainable#processAfterRetrieve()
050:             */
051:            @Override
052:            public void processAfterRetrieve() {
053:                if (businessObject != null) {
054:                    processGlobalsAfterRetrieve();
055:                }
056:            }
057:
058:            /**
059:             * This method does special-case handling for Globals, doing various tasks that need to be done to make a global doc valid after
060:             * its been loaded from the db/maintenance-system.
061:             */
062:            protected void processGlobalsAfterRetrieve() {
063:
064:                // TODO: this needs refactoring ... its kind of lame that we have this set of
065:                // compound list statements, this should all be refactored. This could be moved
066:                // into a method on all GBOs, like GBO.prepareForSave(), or even better, subclass
067:                // KualiGlobalMaintainableImpl for each global, since this is all
068:                // maintainable-related stuff.
069:
070:                GlobalBusinessObject gbo = (GlobalBusinessObject) businessObject;
071:                Class gboClass = businessObject.getClass();
072:                String finDocNumber = gbo.getDocumentNumber();
073:
074:                // TODO: remove this whole pseudo-assertion code block once this gets moved into a doc-specific
075:                // maintainableImpl class.
076:
077:                // This whole mess is to fail-fast if my assumptions about the nature of the parent bo of all
078:                // global-maintenance-documents is wrong
079:                boolean assumptionIsWrong = false;
080:                List primaryKeys = KNSServiceLocator
081:                        .getPersistenceStructureService().getPrimaryKeys(
082:                                gboClass);
083:                if (primaryKeys == null) {
084:                    assumptionIsWrong = true;
085:                } else if (primaryKeys.isEmpty()) {
086:                    assumptionIsWrong = true;
087:                } else if (primaryKeys.size() != 1) {
088:                    assumptionIsWrong = true;
089:                } else if (!primaryKeys.get(0).getClass().equals(String.class)) {
090:                    assumptionIsWrong = true;
091:                } else if (!RicePropertyConstants.DOCUMENT_NUMBER
092:                        .equalsIgnoreCase((String) primaryKeys.get(0))) {
093:                    assumptionIsWrong = true;
094:                }
095:                if (assumptionIsWrong) {
096:                    throw new RuntimeException(
097:                            "An assertion about the nature of the primary keys for this GBO has "
098:                                    + "failed, and processing cannot continue.");
099:                }
100:
101:                // ASSUMPTION: This next section assumes that all GBOs have documentNumber as
102:                // their only primary key field, and that its named as follows. This will
103:                // either fail loudly or break silently if this assumption is not true. Once we
104:                // move this sort of thing into the global-doc-specific subclasses of
105:                // KualiGlobalMaintainableImpl, this will simplify tremendously.
106:                Map pkMap = new HashMap();
107:                pkMap.put(RicePropertyConstants.DOCUMENT_NUMBER, finDocNumber);
108:                PersistableBusinessObject newBo = null;
109:                newBo = (PersistableBusinessObject) KNSServiceLocator
110:                        .getBusinessObjectService().findByPrimaryKey(gboClass,
111:                                pkMap);
112:                if (newBo == null) {
113:                    throw new RuntimeException(
114:                            "The Global Business Object could not be retrieved from the DB.  "
115:                                    + "This should never happen under normal circumstances.  If this is a legitimate case "
116:                                    + "Then this exception should be removed.");
117:                }
118:
119:                // property newCollectionRecord of PersistableObjectBase is not persisted, but is always true for globals
120:                try {
121:                    ObjectUtils.setObjectPropertyDeep(newBo,
122:                            RicePropertyConstants.NEW_COLLECTION_RECORD,
123:                            boolean.class, true, 2);
124:                } catch (Exception e) {
125:                    LOG.error("unable to set newCollectionRecord property: "
126:                            + e.getMessage());
127:                    throw new RuntimeException(
128:                            "unable to set newCollectionRecord property: "
129:                                    + e.getMessage());
130:                }
131:
132:                // replace the GBO loaded from XML with the GBO loaded from the DB
133:                businessObject = newBo;
134:            }
135:
136:            /**
137:             * This method does special-case handling for Globals, filling out various fields that need to be filled, etc.
138:             */
139:            protected void prepareGlobalsForSave() {
140:                GlobalBusinessObject gbo = (GlobalBusinessObject) businessObject;
141:
142:                // set the documentNumber for all
143:                gbo.setDocumentNumber(documentNumber);
144:
145:                List<? extends GlobalBusinessObjectDetail> details = gbo
146:                        .getAllDetailObjects();
147:                for (GlobalBusinessObjectDetail detail : details) {
148:                    detail.setDocumentNumber(documentNumber);
149:                }
150:            }
151:
152:            /**
153:             * This overrides the standard version in KualiMaintainableImpl which works for non-global maintenance documents
154:             * Each global document must in turn override this with its own locking representation, since it varies from document to document (some have one detail class and others have two, and the way to combine the two detail classes is unique to document with two detail classes)
155:             * @see org.kuali.core.maintenance.Maintainable#generateMaintenanceLocks()
156:             */
157:            @Override
158:            public abstract List<MaintenanceLock> generateMaintenanceLocks();
159:
160:            /**
161:             * @see org.kuali.core.maintenance.Maintainable#saveBusinessObject()
162:             */
163:            @Override
164:            public void saveBusinessObject() {
165:                BusinessObjectService boService = KNSServiceLocator
166:                        .getBusinessObjectService();
167:                GlobalBusinessObject gbo = (GlobalBusinessObject) businessObject;
168:
169:                // delete any indicated BOs
170:                List<PersistableBusinessObject> bosToDeactivate = gbo
171:                        .generateDeactivationsToPersist();
172:                if (bosToDeactivate != null) {
173:                    if (!bosToDeactivate.isEmpty()) {
174:                        boService.save(bosToDeactivate);
175:                    }
176:                }
177:
178:                // persist any indicated BOs
179:                List<PersistableBusinessObject> bosToPersist = gbo
180:                        .generateGlobalChangesToPersist();
181:                if (bosToPersist != null) {
182:                    if (!bosToPersist.isEmpty()) {
183:                        boService.save(bosToPersist);
184:                    }
185:                }
186:
187:            }
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.