Source Code Cross Referenced for SegmentedLookupResultsServiceImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » labor » 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.module.labor.service.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 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:
017:        package org.kuali.module.labor.service.impl;
018:
019:        import java.sql.Timestamp;
020:        import java.util.ArrayList;
021:        import java.util.Collection;
022:        import java.util.HashMap;
023:        import java.util.List;
024:        import java.util.Map;
025:        import java.util.Set;
026:
027:        import org.apache.commons.codec.binary.Base64;
028:        import org.apache.commons.logging.Log;
029:        import org.apache.commons.logging.LogFactory;
030:        import org.kuali.core.bo.LookupResults;
031:        import org.kuali.core.bo.PersistableBusinessObject;
032:        import org.kuali.core.bo.SelectedObjectIds;
033:        import org.kuali.core.exceptions.AuthorizationException;
034:        import org.kuali.core.lookup.LookupResultsServiceImpl;
035:        import org.kuali.core.lookup.LookupUtils;
036:        import org.kuali.core.service.DateTimeService;
037:        import org.kuali.core.util.ObjectUtils;
038:        import org.kuali.core.web.ui.ResultRow;
039:        import org.kuali.kfs.KFSPropertyConstants;
040:        import org.kuali.module.labor.service.SegmentedLookupResultsService;
041:        import org.springframework.transaction.annotation.Transactional;
042:
043:        /**
044:         * Used for segemented lookup results
045:         */
046:        @Transactional
047:        public class SegmentedLookupResultsServiceImpl extends
048:                LookupResultsServiceImpl implements 
049:                SegmentedLookupResultsService {
050:
051:            private static final Log LOG = LogFactory
052:                    .getLog(SegmentedLookupResultsServiceImpl.class);
053:
054:            private DateTimeService dateTimeService;
055:
056:            /**
057:             * Retrieve the Date Time Service
058:             * 
059:             * @return Date Time Service
060:             */
061:            public DateTimeService getDateTimeService() {
062:                return dateTimeService;
063:            }
064:
065:            /**
066:             * Assign the Date Time Service
067:             * 
068:             * @param dateTimeService
069:             */
070:            public void setDateTimeService(DateTimeService dateTimeService) {
071:                this .dateTimeService = dateTimeService;
072:            }
073:
074:            /**
075:             * @see org.kuali.core.lookup.LookupResultsService#persistResultsTable(java.lang.String, java.util.List, java.lang.String)
076:             */
077:            public void persistResultsTable(String lookupResultsSequenceNumber,
078:                    List<ResultRow> resultTable, String universalUserId)
079:                    throws Exception {
080:                String resultTableString = new String(Base64
081:                        .encodeBase64(ObjectUtils.toByteArray(resultTable)));
082:
083:                Timestamp now = getDateTimeService().getCurrentTimestamp();
084:
085:                LookupResults lookupResults = retrieveLookupResults(lookupResultsSequenceNumber);
086:                if (lookupResults == null) {
087:                    lookupResults = new LookupResults();
088:                    lookupResults
089:                            .setLookupResultsSequenceNumber(lookupResultsSequenceNumber);
090:                }
091:                lookupResults
092:                        .setLookupResultsSequenceNumber(lookupResultsSequenceNumber);
093:                lookupResults.setLookupUniversalUserId(universalUserId);
094:                lookupResults.setSerializedLookupResults(resultTableString);
095:                lookupResults.setLookupDate(now);
096:                getBusinessObjectService().save(lookupResults);
097:                LOG.debug("Wrote resultTable " + resultTable);
098:            }
099:
100:            /**
101:             * @see org.kuali.core.lookup.LookupResultsService#persistSelectedObjectIds(java.lang.String, java.util.Set, java.lang.String)
102:             */
103:            public void persistSelectedObjectIds(
104:                    String lookupResultsSequenceNumber,
105:                    Set<String> selectedObjectIds, String universalUserId)
106:                    throws Exception {
107:                SelectedObjectIds selectedObjectIdsBO = retrieveSelectedObjectIds(lookupResultsSequenceNumber);
108:                if (selectedObjectIdsBO == null) {
109:                    selectedObjectIdsBO = new SelectedObjectIds();
110:                    selectedObjectIdsBO
111:                            .setLookupResultsSequenceNumber(lookupResultsSequenceNumber);
112:                }
113:                selectedObjectIdsBO
114:                        .setLookupResultsSequenceNumber(lookupResultsSequenceNumber);
115:                selectedObjectIdsBO.setLookupUniversalUserId(universalUserId);
116:                selectedObjectIdsBO.setSelectedObjectIds(LookupUtils
117:                        .convertSetOfObjectIdsToString(selectedObjectIds));
118:                selectedObjectIdsBO.setLookupDate(getDateTimeService()
119:                        .getCurrentTimestamp());
120:                getBusinessObjectService().save(selectedObjectIdsBO);
121:            }
122:
123:            /**
124:             * @see org.kuali.core.lookup.LookupResultsService#retrieveResultsTable(java.lang.String, java.lang.String)
125:             */
126:            public List<ResultRow> retrieveResultsTable(
127:                    String lookupResultsSequenceNumber, String universalUserId)
128:                    throws Exception {
129:                LookupResults lookupResults = retrieveLookupResults(lookupResultsSequenceNumber);
130:                if (!isAuthorizedToAccessLookupResults(lookupResults,
131:                        universalUserId)) {
132:                    throw new AuthorizationException(universalUserId,
133:                            "retrieve lookup results",
134:                            "lookup sequence number "
135:                                    + lookupResultsSequenceNumber);
136:                }
137:                List<ResultRow> resultTable = (List<ResultRow>) ObjectUtils
138:                        .fromByteArray(Base64.decodeBase64(lookupResults
139:                                .getSerializedLookupResults().getBytes()));
140:                return resultTable;
141:            }
142:
143:            /**
144:             * Returns a list of BOs that were selected. This implementation makes an attempt to retrieve all BOs with the given object IDs,
145:             * unless they have been deleted or the object ID changed. Since data may have changed since the search, the returned BOs may
146:             * not match the criteria used to search.
147:             * 
148:             * @see org.kuali.core.lookup.LookupResultsService#retrieveSelectedResultBOs(java.lang.String, java.lang.Class,
149:             *      java.lang.String)
150:             */
151:            public Collection<PersistableBusinessObject> retrieveSelectedResultBOs(
152:                    String lookupResultsSequenceNumber, Class boClass,
153:                    String universalUserId) throws Exception {
154:                Set<String> setOfSelectedObjIds = retrieveSetOfSelectedObjectIds(
155:                        lookupResultsSequenceNumber, universalUserId);
156:                return retrieveSelectedResultBOs(lookupResultsSequenceNumber,
157:                        setOfSelectedObjIds, boClass, universalUserId);
158:            }
159:
160:            /**
161:             * @param lookupResultsSequenceNumber
162:             * @param universalUserId
163:             * @return Set<String>
164:             */
165:            public Set<String> retrieveSetOfSelectedObjectIds(
166:                    String lookupResultsSequenceNumber, String universalUserId)
167:                    throws Exception {
168:                SelectedObjectIds selectedObjectIds = retrieveSelectedObjectIds(lookupResultsSequenceNumber);
169:                if (!isAuthorizedToAccessSelectedObjectIds(selectedObjectIds,
170:                        universalUserId)) {
171:                    throw new AuthorizationException(universalUserId,
172:                            "retrieve lookup results",
173:                            "lookup sequence number "
174:                                    + lookupResultsSequenceNumber);
175:                }
176:                Set<String> retval = LookupUtils
177:                        .convertStringOfObjectIdsToSet(selectedObjectIds
178:                                .getSelectedObjectIds());
179:                return retval;
180:            }
181:
182:            /**
183:             * @param lookupResultsSequenceNumber
184:             * @param setOfSelectedObjIds
185:             * @param boClass
186:             * @param universalUserId
187:             * @return Collection<PersistableBusinessObject>
188:             */
189:            public Collection<PersistableBusinessObject> retrieveSelectedResultBOs(
190:                    String lookupResultsSequenceNumber,
191:                    Set<String> setOfSelectedObjIds, Class boClass,
192:                    String universalUserId) throws Exception {
193:                LOG.debug("Retrieving results for class " + boClass
194:                        + " with objectIds " + setOfSelectedObjIds);
195:                if (setOfSelectedObjIds.isEmpty()) {
196:                    // OJB throws exception if querying on empty set
197:                    return new ArrayList<PersistableBusinessObject>();
198:                }
199:                Map<String, Collection<String>> queryCriteria = new HashMap<String, Collection<String>>();
200:                queryCriteria.put(KFSPropertyConstants.OBJECT_ID,
201:                        setOfSelectedObjIds);
202:                return getBusinessObjectService().findMatching(boClass,
203:                        queryCriteria);
204:            }
205:
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.