Source Code Cross Referenced for UniversalUserServiceImpl.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 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.service.impl;
017:
018:        import java.io.File;
019:        import java.io.InputStream;
020:        import java.lang.reflect.InvocationTargetException;
021:        import java.sql.Timestamp;
022:        import java.util.Collection;
023:        import java.util.HashMap;
024:        import java.util.Iterator;
025:        import java.util.List;
026:        import java.util.Map;
027:
028:        import org.apache.commons.beanutils.PropertyUtils;
029:        import org.apache.commons.lang.StringUtils;
030:        import org.apache.log4j.Logger;
031:        import org.kuali.RiceConstants;
032:        import org.kuali.core.KualiModule;
033:        import org.kuali.core.bo.BusinessObjectRelationship;
034:        import org.kuali.core.bo.PersistableBusinessObject;
035:        import org.kuali.core.bo.user.AuthenticationUserId;
036:        import org.kuali.core.bo.user.KualiGroup;
037:        import org.kuali.core.bo.user.KualiModuleUser;
038:        import org.kuali.core.bo.user.KualiModuleUserProperty;
039:        import org.kuali.core.bo.user.UniversalUser;
040:        import org.kuali.core.bo.user.UserId;
041:        import org.kuali.core.bo.user.UuId;
042:        import org.kuali.core.dao.LookupDao;
043:        import org.kuali.core.dao.UniversalUserDao;
044:        import org.kuali.core.datadictionary.control.ControlDefinition;
045:        import org.kuali.core.exceptions.UserNotFoundException;
046:        import org.kuali.core.service.BusinessObjectMetaDataService;
047:        import org.kuali.core.service.DataDictionaryService;
048:        import org.kuali.core.service.DateTimeService;
049:        import org.kuali.core.service.KualiGroupService;
050:        import org.kuali.core.service.KualiModuleService;
051:        import org.kuali.core.service.KualiModuleUserPropertyService;
052:        import org.kuali.core.service.MaintenanceDocumentDictionaryService;
053:        import org.kuali.core.service.UniversalUserService;
054:        import org.kuali.rice.KNSServiceLocator;
055:        import org.springframework.transaction.annotation.Transactional;
056:
057:        import edu.iu.uis.eden.clientapp.vo.EmplIdVO;
058:        import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
059:        import edu.iu.uis.eden.clientapp.vo.UserIdVO;
060:        import edu.iu.uis.eden.clientapp.vo.UuIdVO;
061:        import edu.iu.uis.eden.clientapp.vo.WorkflowIdVO;
062:        import edu.iu.uis.eden.exception.EdenUserNotFoundException;
063:        import edu.iu.uis.eden.user.BaseUserService;
064:        import edu.iu.uis.eden.user.BaseWorkflowUser;
065:        import edu.iu.uis.eden.user.UserCapabilities;
066:        import edu.iu.uis.eden.user.WorkflowUser;
067:        import edu.iu.uis.eden.user.WorkflowUserId;
068:
069:        /**
070:         * This class is the service implementation for the KualiUser structure. This is the default implementation, that is delivered with
071:         * Kuali. This implementation retrieves the user based on a relational data structure that we have defined withing the KUL schema.
072:         */
073:        @Transactional
074:        public class UniversalUserServiceImpl extends BaseUserService implements 
075:                UniversalUserService {
076:            private static final Logger LOG = Logger
077:                    .getLogger(UniversalUserServiceImpl.class);
078:            private static final String IS_UNIVERSAL_USER_PROPERTY_METHOD_ERROR = "UniversalUserServiceImpl encountered an exception while attempting to determine whether a property name references UniversalUser - propertyName: ";
079:            private static final String RESOLVE_USER_IDENTIFIERS_TO_UNIVERSAL_IDENTIFIERS_METHOD_ERROR = "UniversalUserServiceImpl encountered an exception while attempting to result user identifier to universal identifier - propertyName: ";
080:
081:            private UniversalUserDao universalUserDao;
082:            private KualiModuleUserPropertyService moduleUserPropertyService;
083:            private KualiGroupService kualiGroupService;
084:            private BusinessObjectMetaDataService businessObjectMetaDataService;
085:            private DataDictionaryService dataDictionaryService;
086:            private MaintenanceDocumentDictionaryService maintenanceDocumentDictionaryService;
087:            private LookupDao lookupDao;
088:            private KualiModuleService kualiModuleService;
089:            //    private KualiConfigurationService kualiConfigurationService;
090:            private DateTimeService dateTimeService;
091:
092:            private String super visorWorkgroup;
093:            private String workflowExceptionWorkgroup;
094:            private UserCapabilities workflowUserCapabilities;
095:
096:            /**
097:             * Overriding inherited method which returns true for all to allow configuration
098:             * 
099:             * @see edu.iu.uis.eden.user.BaseUserService#getCapabilities()
100:             */
101:            public UserCapabilities getCapabilities() {
102:                if (workflowUserCapabilities == null) {
103:                    workflowUserCapabilities = super .capabilities;
104:                }
105:                return workflowUserCapabilities;
106:            }
107:
108:            public void setWorkflowUserCapabilities(
109:                    UserCapabilities workflowUserCapabilities) {
110:                this .workflowUserCapabilities = workflowUserCapabilities;
111:            }
112:
113:            /**
114:             * @see org.kuali.core.service.UniversalUserService#getUniversalUser(org.kuali.core.bo.user.UserId)
115:             */
116:            public UniversalUser getUniversalUser(UserId userId)
117:                    throws UserNotFoundException {
118:                UniversalUser user = universalUserDao.getUser(userId);
119:                if (user == null) {
120:                    throw new UserNotFoundException(
121:                            "unable to find universaluser for userId '"
122:                                    + userId + "'");
123:                }
124:                return user;
125:            }
126:
127:            public UniversalUser getUniversalUserByAuthenticationUserId(
128:                    String authenticationUserId) throws UserNotFoundException {
129:                return getUniversalUser(new AuthenticationUserId(
130:                        authenticationUserId));
131:            }
132:
133:            public UniversalUser getUniversalUser(
134:                    String personUniversalIdentifier)
135:                    throws UserNotFoundException {
136:                return getUniversalUser(new UuId(personUniversalIdentifier));
137:            }
138:
139:            public UniversalUser updateUniversalUserIfNecessary(
140:                    String sourcePersonUniversalIdentifier,
141:                    UniversalUser currentSourceUniversalUser) {
142:                if (currentSourceUniversalUser == null
143:                        || (sourcePersonUniversalIdentifier != null && !sourcePersonUniversalIdentifier
144:                                .equals(currentSourceUniversalUser
145:                                        .getPersonUniversalIdentifier()))
146:                        || currentSourceUniversalUser.getVersionNumber() == null) {
147:                    try {
148:                        return getUniversalUser(new UuId(
149:                                sourcePersonUniversalIdentifier));
150:                    } catch (UserNotFoundException unfe) {
151:                        if (currentSourceUniversalUser == null) {
152:                            return new UniversalUser();
153:                        }
154:                    }
155:                }
156:                return currentSourceUniversalUser;
157:            }
158:
159:            /**
160:             * @see org.kuali.core.service.UniversalUserService#findUniversalUsers(java.util.Map)
161:             */
162:            public Collection findUniversalUsers(Map formFields) {
163:                String moduleCode = (String) formFields
164:                        .get("activeModuleCodeString");
165:                if (StringUtils.isNotBlank(moduleCode)) {
166:                    KualiModule module = kualiModuleService
167:                            .getModuleByCode(moduleCode);
168:                    if (module != null) {
169:                        return lookupDao
170:                                .findCollectionBySearchHelper(
171:                                        UniversalUser.class,
172:                                        formFields,
173:                                        false,
174:                                        KNSServiceLocator
175:                                                .getLookupService()
176:                                                .allPrimaryKeyValuesPresentAndNotWildcard(
177:                                                        UniversalUser.class,
178:                                                        formFields), module
179:                                                .getModuleUserService()
180:                                                .getUserActiveCriteria());
181:                    }
182:                }
183:                return lookupDao.findCollectionBySearchHelper(
184:                        UniversalUser.class, formFields, false,
185:                        KNSServiceLocator.getLookupService()
186:                                .allPrimaryKeyValuesPresentAndNotWildcard(
187:                                        UniversalUser.class, formFields));
188:            }
189:
190:            // TODO WARNING: this does not support nested joins, because i don't have a test case
191:            public Collection findWithUniversalUserJoin(
192:                    Class businessObjectClass, Map fieldValues,
193:                    boolean unbounded) {
194:                return lookupDao
195:                        .findCollectionBySearchHelperWithUniversalUserJoin(
196:                                businessObjectClass,
197:                                getNonUniversalUserSearchCriteria(
198:                                        businessObjectClass, fieldValues),
199:                                getUniversalUserSearchCriteria(
200:                                        businessObjectClass, fieldValues),
201:                                unbounded,
202:                                KNSServiceLocator
203:                                        .getLookupService()
204:                                        .allPrimaryKeyValuesPresentAndNotWildcard(
205:                                                businessObjectClass,
206:                                                fieldValues));
207:            }
208:
209:            public boolean hasUniversalUserProperty(Class businessObjectClass,
210:                    Map fieldValues) {
211:                boolean hasUniversalUserProperty = false;
212:                Iterator propertyNameItr = fieldValues.keySet().iterator();
213:                while (propertyNameItr.hasNext() && !hasUniversalUserProperty) {
214:                    hasUniversalUserProperty = isUniversalUserProperty(
215:                            businessObjectClass, (String) propertyNameItr
216:                                    .next());
217:                }
218:                return hasUniversalUserProperty;
219:            }
220:
221:            /**
222:             * @see org.kuali.core.service.UniversalUserService#resolveUserIdentifiersToUniversalIdentifiers(PersistableBusinessObject, java.util.Map)
223:             */
224:            public Map resolveUserIdentifiersToUniversalIdentifiers(
225:                    PersistableBusinessObject businessObject, Map fieldValues) {
226:                Map processedFieldValues = getNonUniversalUserSearchCriteria(
227:                        businessObject.getClass(), fieldValues);
228:                Iterator propertyNameItr = fieldValues.keySet().iterator();
229:                while (propertyNameItr.hasNext()) {
230:                    String propertyName = (String) propertyNameItr.next();
231:                    if (isUniversalUserProperty(businessObject.getClass(),
232:                            propertyName)
233:                            && !StringUtils.isBlank((String) fieldValues
234:                                    .get(propertyName))) {
235:                        String universalUserPropertyName = propertyName
236:                                .substring(propertyName.lastIndexOf(".") + 1);
237:                        if ("personUserIdentifier"
238:                                .equals(universalUserPropertyName)) {
239:                            Map searchCriteria = new HashMap();
240:                            searchCriteria.put("personUserIdentifier",
241:                                    fieldValues.get(propertyName).toString()
242:                                            .toUpperCase());
243:                            // since personUserIdentifier is not the PK of UnivUser, then we are not using the PK of the UU BO to search (hence, the second false parameter)
244:                            Collection universalUsers = lookupDao
245:                                    .findCollectionBySearchHelper(
246:                                            UniversalUser.class,
247:                                            searchCriteria, false, false);
248:                            String universalUserReferenceObjectPropertyName = StringUtils
249:                                    .substringBeforeLast(propertyName, ".");
250:                            Class targetBusinessObjectClass = null;
251:                            try {
252:                                StringBuffer resolvedPersonUniversalIdentifierPropertyName = new StringBuffer();
253:                                if (universalUserReferenceObjectPropertyName
254:                                        .indexOf(".") > 0) {
255:                                    String targetBusinessObjectPropertyName = StringUtils
256:                                            .substringBeforeLast(
257:                                                    universalUserReferenceObjectPropertyName,
258:                                                    ".");
259:                                    Object targetProperty = PropertyUtils
260:                                            .getProperty(businessObject,
261:                                                    targetBusinessObjectPropertyName);
262:                                    if (targetProperty != null) {
263:                                        targetBusinessObjectClass = targetProperty
264:                                                .getClass();
265:                                        resolvedPersonUniversalIdentifierPropertyName
266:                                                .append(
267:                                                        targetBusinessObjectPropertyName)
268:                                                .append(".");
269:                                    } else {
270:                                        LOG
271:                                                .info("Could not find target property for "
272:                                                        + propertyName
273:                                                        + " in class of "
274:                                                        + businessObject
275:                                                                .getClass()
276:                                                                .getName());
277:                                    }
278:                                } else {
279:                                    targetBusinessObjectClass = businessObject
280:                                            .getClass();
281:                                }
282:                                if (targetBusinessObjectClass != null) {
283:                                    String propName = universalUserReferenceObjectPropertyName
284:                                            .substring(universalUserReferenceObjectPropertyName
285:                                                    .lastIndexOf(".") + 1);
286:                                    String institutionalIdSourcePrimitivePropertyName = (String) dataDictionaryService
287:                                            .getRelationshipAttributeMap(
288:                                                    targetBusinessObjectClass
289:                                                            .getName(),
290:                                                    propName)
291:                                            .get("personUniversalIdentifier");
292:                                    resolvedPersonUniversalIdentifierPropertyName
293:                                            .append(institutionalIdSourcePrimitivePropertyName);
294:                                    if (universalUsers != null
295:                                            && universalUsers.size() == 1) {
296:                                        processedFieldValues
297:                                                .put(
298:                                                        resolvedPersonUniversalIdentifierPropertyName
299:                                                                .toString(),
300:                                                        ((UniversalUser) ((List) universalUsers)
301:                                                                .get(0))
302:                                                                .getPersonUniversalIdentifier());
303:                                    } else {
304:                                        processedFieldValues.put(
305:                                                resolvedPersonUniversalIdentifierPropertyName
306:                                                        .toString(), null);
307:                                    }
308:                                } else {
309:                                    processedFieldValues.put(
310:                                            resolvedPersonUniversalIdentifierPropertyName
311:                                                    .toString(), null);
312:                                }
313:                            } catch (IllegalAccessException e) {
314:                                throw new RuntimeException(
315:                                        RESOLVE_USER_IDENTIFIERS_TO_UNIVERSAL_IDENTIFIERS_METHOD_ERROR
316:                                                + propertyName, e);
317:                            } catch (InvocationTargetException e) {
318:                                throw new RuntimeException(
319:                                        RESOLVE_USER_IDENTIFIERS_TO_UNIVERSAL_IDENTIFIERS_METHOD_ERROR
320:                                                + propertyName, e);
321:                            } catch (NoSuchMethodException e) {
322:                                throw new RuntimeException(
323:                                        RESOLVE_USER_IDENTIFIERS_TO_UNIVERSAL_IDENTIFIERS_METHOD_ERROR
324:                                                + propertyName, e);
325:                            } catch (NumberFormatException e) {
326:                                throw new RuntimeException(
327:                                        RESOLVE_USER_IDENTIFIERS_TO_UNIVERSAL_IDENTIFIERS_METHOD_ERROR
328:                                                + propertyName, e);
329:                            }
330:                        }
331:                    } else if (propertyName.endsWith("personUserIdentifier")) {
332:                        // if we're adding to a collection and we've got the personUserIdentifier; let's populate universalUser
333:                        Object personUserIdentifier = fieldValues
334:                                .get(propertyName);
335:                        if (personUserIdentifier != null) {
336:                            String containerPropertyName = propertyName;
337:                            if (containerPropertyName
338:                                    .startsWith(RiceConstants.MAINTENANCE_ADD_PREFIX)) {
339:                                containerPropertyName = propertyName
340:                                        .substring(RiceConstants.MAINTENANCE_ADD_PREFIX
341:                                                .length());
342:                            }
343:                            // get the class of the object that is referenced by the property name
344:                            if (containerPropertyName.indexOf(".") > 0) {
345:                                String collectionName = containerPropertyName
346:                                        .substring(0, containerPropertyName
347:                                                .indexOf("."));
348:                                // what is the class held by that collection?
349:                                Class collectionBusinessObjectClass = maintenanceDocumentDictionaryService
350:                                        .getCollectionBusinessObjectClass(
351:                                                maintenanceDocumentDictionaryService
352:                                                        .getDocumentTypeName(businessObject
353:                                                                .getClass()),
354:                                                collectionName);
355:                                if (collectionBusinessObjectClass != null) {
356:                                    // we are adding to a collection; get the relationships for that object; is there one for personUniversalIdentifier?
357:                                    try {
358:                                        List<BusinessObjectRelationship> relationships = businessObjectMetaDataService
359:                                                .getBusinessObjectRelationships((PersistableBusinessObject) collectionBusinessObjectClass
360:                                                        .newInstance());
361:                                        for (BusinessObjectRelationship rel : relationships) {
362:                                            for (Map.Entry<String, String> entry : rel
363:                                                    .getParentToChildReferences()
364:                                                    .entrySet()) {
365:                                                if (entry
366:                                                        .getValue()
367:                                                        .equals(
368:                                                                "personUniversalIdentifier")) {
369:                                                    // there is a relationship for personUserIdentifier; use that to find the universal user
370:                                                    String fieldPrefix = propertyName
371:                                                            .substring(
372:                                                                    0,
373:                                                                    propertyName
374:                                                                            .substring(
375:                                                                                    0,
376:                                                                                    propertyName
377:                                                                                            .lastIndexOf(".personUserIdentifier"))
378:                                                                            .lastIndexOf(
379:                                                                                    "."));
380:                                                    String relatedUniversalUserPropertyName = fieldPrefix
381:                                                            + "."
382:                                                            + entry.getKey();
383:                                                    Object currRelatedUniversalUser = processedFieldValues
384:                                                            .get(relatedUniversalUserPropertyName);
385:                                                    if (currRelatedUniversalUser == null
386:                                                            || (currRelatedUniversalUser instanceof  String && ((String) currRelatedUniversalUser)
387:                                                                    .length() == 0)) {
388:                                                        try {
389:                                                            UniversalUser universalUser = this 
390:                                                                    .getUniversalUserByAuthenticationUserId(personUserIdentifier
391:                                                                            .toString()
392:                                                                            .toUpperCase());
393:                                                            processedFieldValues
394:                                                                    .put(
395:                                                                            relatedUniversalUserPropertyName,
396:                                                                            universalUser
397:                                                                                    .getPersonUniversalIdentifier());
398:                                                        } catch (UserNotFoundException unfe) {
399:                                                            LOG
400:                                                                    .info("User "
401:                                                                            + personUserIdentifier
402:                                                                                    .toString()
403:                                                                            + " was not found.");
404:                                                        }
405:                                                    }
406:                                                }
407:                                            }
408:                                        }
409:                                    } catch (InstantiationException e) {
410:                                        throw new RuntimeException(
411:                                                RESOLVE_USER_IDENTIFIERS_TO_UNIVERSAL_IDENTIFIERS_METHOD_ERROR
412:                                                        + propertyName, e);
413:                                    } catch (IllegalAccessException e) {
414:                                        throw new RuntimeException(
415:                                                RESOLVE_USER_IDENTIFIERS_TO_UNIVERSAL_IDENTIFIERS_METHOD_ERROR
416:                                                        + propertyName, e);
417:                                    }
418:                                }
419:                            }
420:                        }
421:                    }
422:                }
423:                return processedFieldValues;
424:            }
425:
426:            private Map getUniversalUserSearchCriteria(
427:                    Class businessObjectClass, Map fieldValues) {
428:                Map allUniversalUserSearchCriteria = new HashMap();
429:                Iterator propertyNameItr = fieldValues.keySet().iterator();
430:                while (propertyNameItr.hasNext()) {
431:                    String propertyName = (String) propertyNameItr.next();
432:                    if (isUniversalUserProperty(businessObjectClass,
433:                            propertyName)
434:                            && !StringUtils.isBlank((String) fieldValues
435:                                    .get(propertyName))) {
436:                        ControlDefinition controlDefinition = dataDictionaryService
437:                                .getAttributeControlDefinition(
438:                                        businessObjectClass, propertyName);
439:                        if ((controlDefinition != null)
440:                                && !controlDefinition.isHidden()) {
441:                            String universalUserReferenceObjectPropertyName = propertyName
442:                                    .substring(0, propertyName.lastIndexOf("."));
443:                            String universalUserSearchFieldName = propertyName
444:                                    .substring(propertyName.lastIndexOf(".") + 1);
445:                            String institutionalIdSourcePrimitivePropertyName = (String) dataDictionaryService
446:                                    .getRelationshipAttributeMap(
447:                                            businessObjectClass.getName(),
448:                                            universalUserReferenceObjectPropertyName)
449:                                    .get("personUniversalIdentifier");
450:                            if (allUniversalUserSearchCriteria
451:                                    .containsKey(institutionalIdSourcePrimitivePropertyName)) {
452:                                ((Map) allUniversalUserSearchCriteria
453:                                        .get(institutionalIdSourcePrimitivePropertyName))
454:                                        .put(universalUserSearchFieldName,
455:                                                fieldValues.get(propertyName));
456:                            } else {
457:                                Map universalUserReferenceObjectSearchCriteria = new HashMap();
458:                                universalUserReferenceObjectSearchCriteria.put(
459:                                        universalUserSearchFieldName,
460:                                        fieldValues.get(propertyName));
461:                                allUniversalUserSearchCriteria
462:                                        .put(
463:                                                institutionalIdSourcePrimitivePropertyName,
464:                                                universalUserReferenceObjectSearchCriteria);
465:                            }
466:                        }
467:                    }
468:                }
469:                return allUniversalUserSearchCriteria;
470:            }
471:
472:            private Map getNonUniversalUserSearchCriteria(
473:                    Class businessObjectClass, Map fieldValues) {
474:                Map nonUniversalUserSearchCriteria = new HashMap();
475:                Iterator propertyNameItr = fieldValues.keySet().iterator();
476:                while (propertyNameItr.hasNext()) {
477:                    String propertyName = (String) propertyNameItr.next();
478:                    if (!isUniversalUserProperty(businessObjectClass,
479:                            propertyName)) {
480:                        nonUniversalUserSearchCriteria.put(propertyName,
481:                                fieldValues.get(propertyName));
482:                    }
483:                }
484:                return nonUniversalUserSearchCriteria;
485:            }
486:
487:            private boolean isUniversalUserProperty(Class businessObjectClass,
488:                    String propertyName) {
489:                try {
490:                    return (propertyName.indexOf(".") > 0)
491:                            && !(StringUtils.contains(propertyName, "add."))
492:                            && UniversalUser.class.equals(PropertyUtils
493:                                    .getPropertyType(businessObjectClass
494:                                            .newInstance(), propertyName
495:                                            .substring(0, propertyName
496:                                                    .lastIndexOf("."))));
497:                } catch (IllegalAccessException e) {
498:                    throw new RuntimeException(
499:                            IS_UNIVERSAL_USER_PROPERTY_METHOD_ERROR
500:                                    + propertyName, e);
501:                } catch (InvocationTargetException e) {
502:                    throw new RuntimeException(
503:                            IS_UNIVERSAL_USER_PROPERTY_METHOD_ERROR
504:                                    + propertyName, e);
505:                } catch (NoSuchMethodException e) {
506:                    throw new RuntimeException(
507:                            IS_UNIVERSAL_USER_PROPERTY_METHOD_ERROR
508:                                    + propertyName, e);
509:                } catch (InstantiationException e) {
510:                    throw new RuntimeException(
511:                            IS_UNIVERSAL_USER_PROPERTY_METHOD_ERROR
512:                                    + propertyName, e);
513:                }
514:            }
515:
516:            public void setUniversalUserDao(UniversalUserDao userDao) {
517:                this .universalUserDao = userDao;
518:            }
519:
520:            /**
521:             * setter for spring injected group service
522:             * 
523:             * @param kualiGroupService The kualiGroupService to set.
524:             */
525:            public void setKualiGroupService(KualiGroupService kualiGroupService) {
526:                this .kualiGroupService = kualiGroupService;
527:            }
528:
529:            public void setDataDictionaryService(
530:                    DataDictionaryService dataDictionaryService) {
531:                this .dataDictionaryService = dataDictionaryService;
532:            }
533:
534:            public void setLookupDao(LookupDao lookupDao) {
535:                this .lookupDao = lookupDao;
536:            }
537:
538:            // workflow user service methods
539:            public void save(WorkflowUser user) {
540:                BaseWorkflowUser simpleUser = (BaseWorkflowUser) user;
541:                Timestamp currentTimestamp = dateTimeService
542:                        .getCurrentTimestamp();
543:                if (user.getWorkflowId() == null
544:                        || simpleUser.getCreateDate() == null) {
545:                    simpleUser.setCreateDate(currentTimestamp);
546:                } else {
547:                    removeFromCache(user.getWorkflowUserId());
548:                }
549:                simpleUser.setLastUpdateDate(currentTimestamp);
550:                universalUserDao.save(simpleUser);
551:            }
552:
553:            public WorkflowUser getWorkflowUser(UserIdVO userId)
554:                    throws EdenUserNotFoundException {
555:                return universalUserDao
556:                        .getWorkflowUser(getWorkflowUserId(userId));
557:            }
558:
559:            public WorkflowUser getWorkflowUser(
560:                    edu.iu.uis.eden.user.UserId userId)
561:                    throws EdenUserNotFoundException {
562:                WorkflowUser user = getFromCache(userId);
563:                if (user == null) {
564:                    user = (WorkflowUser) universalUserDao
565:                            .getWorkflowUser(userId);
566:                    if (user == null) {
567:                        throw new EdenUserNotFoundException(
568:                                "User is invalid. userId " + userId.toString());
569:                    } else {
570:                        addToCache(user);
571:                    }
572:                }
573:                return user;
574:            }
575:
576:            public List search(WorkflowUser user, boolean useWildcards) {
577:                return universalUserDao.search(user, useWildcards);
578:            }
579:
580:            private edu.iu.uis.eden.user.UserId getWorkflowUserId(
581:                    UserIdVO userId) throws EdenUserNotFoundException {
582:                edu.iu.uis.eden.user.UserId userIdInterface = null;
583:                if (userId instanceof  EmplIdVO) {
584:                    userIdInterface = new edu.iu.uis.eden.user.EmplId(
585:                            ((EmplIdVO) userId).getEmplId());
586:                } else if (userId instanceof  NetworkIdVO) {
587:                    userIdInterface = new edu.iu.uis.eden.user.AuthenticationUserId(
588:                            ((NetworkIdVO) userId).getNetworkId());
589:                } else if (userId instanceof  UuIdVO) {
590:                    userIdInterface = new edu.iu.uis.eden.user.UuId(
591:                            ((UuIdVO) userId).getUuId());
592:                } else if (userId instanceof  WorkflowIdVO) {
593:                    userIdInterface = new WorkflowUserId(
594:                            ((WorkflowIdVO) userId).getWorkflowId());
595:                } else {
596:                    throw new EdenUserNotFoundException(
597:                            "Attempting to fetch user with unknown id type");
598:                }
599:                return userIdInterface;
600:            }
601:
602:            public WorkflowUser getBlankUser() {
603:                return new org.kuali.core.workflow.bo.WorkflowUser();
604:            }
605:
606:            public void loadXmlFile(File xmlFile) {
607:                LOG.warn("KualiUserService cannot import XML");
608:            }
609:
610:            public void loadXml(InputStream arg0, WorkflowUser arg1) {
611:                LOG.warn("KualiUserService cannot import XML");
612:            }
613:
614:            public Map<String, KualiModuleUser> getModuleUsers(
615:                    UniversalUser user) {
616:                return kualiModuleService.getModuleUsers(user);
617:            }
618:
619:            /**
620:             * boolean to indicate if the user is a member of a kuali group
621:             * 
622:             * @param groupName
623:             * @return true if the user is a member of the group passed in
624:             */
625:            public boolean isMember(UniversalUser user, String groupName) {
626:                if (groupName != null && !StringUtils.isEmpty(groupName)) {
627:                    groupName = groupName.toUpperCase().trim();
628:                    if (isSupervisorUser(user)) { // TODO why was there a check for inquiry role?
629:                        return true;
630:                    }
631:                    for (KualiGroup group : user.getGroups()) {
632:                        if (groupName.toUpperCase().equals(
633:                                group.getGroupName().toUpperCase().trim())) {
634:                            return true;
635:                        }
636:                    }
637:                }
638:                return false;
639:            }
640:
641:            public boolean isMember(UniversalUser user, KualiGroup kualiGroup) {
642:                return isMember(user, kualiGroup.getGroupName());
643:            }
644:
645:            public List<KualiGroup> getUsersGroups(UniversalUser user) {
646:                return kualiGroupService.getUsersGroups(user);
647:            }
648:
649:            /**
650:             * check if the user is a supervisor user (belongs to all groups)
651:             * 
652:             * @return
653:             */
654:            public boolean isSupervisorUser(UniversalUser user) {
655:                for (KualiGroup group : user.getGroups()) {
656:                    if (getSupervisorWorkgroup().equals(
657:                            group.getGroupName().toUpperCase().trim())) {
658:                        return true;
659:                    }
660:                }
661:                return false;
662:            }
663:
664:            private String getSupervisorWorkgroup() {
665:                if (super visorWorkgroup == null) {
666:                    super visorWorkgroup = KNSServiceLocator
667:                            .getKualiConfigurationService()
668:                            .getParameterValue(
669:                                    RiceConstants.KNS_NAMESPACE,
670:                                    RiceConstants.DetailTypes.DOCUMENT_DETAIL_TYPE,
671:                                    RiceConstants.CoreApcParms.SUPERVISOR_WORKGROUP);
672:                }
673:                return super visorWorkgroup;
674:            }
675:
676:            private String getWorkflowExceptionWorkgroup() {
677:                if (workflowExceptionWorkgroup == null) {
678:                    workflowExceptionWorkgroup = KNSServiceLocator
679:                            .getKualiConfigurationService()
680:                            .getParameterValue(
681:                                    RiceConstants.KNS_NAMESPACE,
682:                                    RiceConstants.DetailTypes.DOCUMENT_DETAIL_TYPE,
683:                                    RiceConstants.CoreApcParms.WORKFLOW_EXCEPTION_WORKGROUP);
684:                }
685:                return workflowExceptionWorkgroup;
686:            }
687:
688:            /**
689:             * check if the user is an exception user (has the Exception role, belongs to the Exception workgroup, whatever)
690:             * 
691:             * @return
692:             */
693:            public boolean isWorkflowExceptionUser(UniversalUser user) {
694:                return isMember(user, getWorkflowExceptionWorkgroup());
695:            }
696:
697:            public KualiModuleService getKualiModuleService() {
698:                return kualiModuleService;
699:            }
700:
701:            public void setKualiModuleService(
702:                    KualiModuleService kualiModuleService) {
703:                this .kualiModuleService = kualiModuleService;
704:            }
705:
706:            //    public KualiConfigurationService getKualiConfigurationService() {
707:            //        return kualiConfigurationService;
708:            //    }
709:            //
710:            //    public void setKualiConfigurationService(KualiConfigurationService kualiConfigurationService) {
711:            //        this.kualiConfigurationService = kualiConfigurationService;
712:            //    }
713:
714:            public void setDateTimeService(DateTimeService dateTimeService) {
715:                this .dateTimeService = dateTimeService;
716:            }
717:
718:            public Map<String, Map<String, String>> loadModuleUserProperties(
719:                    UniversalUser user) {
720:                // load the property objects from the DAO
721:                Collection<KualiModuleUserProperty> props = moduleUserPropertyService
722:                        .getPropertiesForUser(user);
723:
724:                Map<String, Map<String, String>> moduleProps = new HashMap<String, Map<String, String>>();
725:                // iterate over the DB objects and build the map
726:                for (KualiModuleUserProperty prop : props) {
727:                    if (moduleProps.get(prop.getModuleId()) == null) {
728:                        moduleProps.put(prop.getModuleId(),
729:                                new HashMap<String, String>());
730:                    }
731:                    moduleProps.get(prop.getModuleId()).put(prop.getName(),
732:                            prop.getValue());
733:                }
734:                return moduleProps;
735:            }
736:
737:            public KualiModuleUserPropertyService getModuleUserPropertyService() {
738:                return moduleUserPropertyService;
739:            }
740:
741:            public void setModuleUserPropertyService(
742:                    KualiModuleUserPropertyService moduleUserPropertyService) {
743:                this .moduleUserPropertyService = moduleUserPropertyService;
744:            }
745:
746:            public MaintenanceDocumentDictionaryService getMaintenanceDocumentDictionaryService() {
747:                return this .maintenanceDocumentDictionaryService;
748:            }
749:
750:            public void setMaintenanceDocumentDictionaryService(
751:                    MaintenanceDocumentDictionaryService mdds) {
752:                this .maintenanceDocumentDictionaryService = mdds;
753:            }
754:
755:            public BusinessObjectMetaDataService getBusinessObjectMetaDataService() {
756:                return this .businessObjectMetaDataService;
757:            }
758:
759:            public void setBusinessObjectMetaDataService(
760:                    BusinessObjectMetaDataService boms) {
761:                this.businessObjectMetaDataService = boms;
762:            }
763:
764:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.