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:
017: package org.kuali.core.bo.user;
018:
019: import java.util.HashMap;
020: import java.util.LinkedHashMap;
021: import java.util.List;
022: import java.util.Map;
023: import java.util.Set;
024:
025: import org.apache.commons.lang.StringUtils;
026: import org.kuali.core.KualiModule;
027: import org.kuali.core.bo.Campus;
028: import org.kuali.core.bo.EmployeeStatus;
029: import org.kuali.core.bo.EmployeeType;
030: import org.kuali.core.bo.PersistableBusinessObjectBase;
031: import org.kuali.core.service.KualiModuleService;
032: import org.kuali.core.service.UniversalUserService;
033: import org.kuali.core.util.KualiDecimal;
034: import org.kuali.rice.KNSServiceLocator;
035:
036: /**
037: *
038: */
039: public class UniversalUser extends PersistableBusinessObjectBase {
040: protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
041: .getLogger(UniversalUser.class);
042:
043: private transient static UniversalUserService universalUserService;
044: private transient static KualiModuleService kualiModuleService;
045:
046: private String personUniversalIdentifier;
047: private String personUserIdentifier;
048: private String personPayrollIdentifier;
049: private String personTaxIdentifier;
050: private String personTaxIdentifierTypeCode;
051: private String personFirstName;
052: private String personLastName;
053: private String personMiddleName;
054: private String personName;
055: private String personEmailAddress;
056: private String campusCode;
057: private String primaryDepartmentCode;
058: private String personCampusAddress;
059: private String personLocalPhoneNumber;
060: private String employeeStatusCode;
061: private String employeeTypeCode;
062: private KualiDecimal personBaseSalaryAmount;
063: private String financialSystemsEncryptedPasswordText;
064:
065: private boolean student;
066: private boolean staff;
067: private boolean faculty;
068: private boolean affiliate;
069:
070: private Campus campus;
071: private EmployeeStatus employeeStatus;
072: private EmployeeType employeeType;
073:
074: private Map<String, KualiModuleUser> moduleUsers;
075: private boolean activeForAnyModule = false;
076: private List<KualiGroup> groups;
077:
078: // TODO this shouldn't really be here
079: // need to push a list of changed module codes into workflow - doing this in the UniversalUserPreRules
080: // - ideally this would go on the doc, since it relates to the old and new maintainable, but no option for extending document implementation in the maint framework
081: // - so, we could put it on the maintainable, but properties of the maintainable don't get put in the main doc xml in populateXmDocumentContentsFromMaintainables
082: // - so, we could derive and set after populateMaintainablesFromXmlDocumentContents, but i don't see a hook - have processAfterRetrieve called then on the new maintainable, but we need the od maintainable to derive
083: // - so, i could modify the framework - e.g. implement handleRouteLevelChange on maintenance document and call a method on the maintainable, where i pass the prior row - seems like a big change for this need
084: private Set<String> changedModuleCodes;
085:
086: /**
087: * Default no-arg constructor.
088: */
089: public UniversalUser() {
090: }
091:
092: /**
093: * Gets the personUniversalIdentifier attribute.
094: *
095: * @return - Returns the personUniversalIdentifier
096: *
097: */
098: public String getPersonUniversalIdentifier() {
099: return personUniversalIdentifier;
100: }
101:
102: /**
103: * Sets the personUniversalIdentifier attribute.
104: *
105: * @param personUniversalIdentifier The personUniversalIdentifier to set.
106: *
107: */
108: public void setPersonUniversalIdentifier(
109: String personUniversalIdentifier) {
110: this .personUniversalIdentifier = personUniversalIdentifier;
111: }
112:
113: /**
114: * Gets the personUserIdentifier attribute.
115: *
116: * @return - Returns the personUserIdentifier
117: *
118: */
119: public String getPersonUserIdentifier() {
120: return personUserIdentifier;
121: }
122:
123: /**
124: * Sets the personUserIdentifier attribute.
125: *
126: * @param personUserIdentifier The personUserIdentifier to set.
127: *
128: */
129: public void setPersonUserIdentifier(String personUserIdentifier) {
130: this .personUserIdentifier = personUserIdentifier;
131: }
132:
133: /**
134: * Gets the employeeStatusCode attribute.
135: *
136: * @return - Returns the employeeStatusCode
137: *
138: */
139: public String getEmployeeStatusCode() {
140: return employeeStatusCode;
141: }
142:
143: /**
144: * Sets the employeeStatusCode attribute.
145: *
146: * @param employeeStatusCode The employeeStatusCode to set.
147: *
148: */
149: public void setEmployeeStatusCode(String employeeStatusCode) {
150: this .employeeStatusCode = employeeStatusCode;
151: }
152:
153: /**
154: * Gets the personPayrollIdentifier attribute.
155: *
156: * @return - Returns the personPayrollIdentifier
157: *
158: */
159: public String getPersonPayrollIdentifier() {
160: return personPayrollIdentifier;
161: }
162:
163: /**
164: * Sets the personPayrollIdentifier attribute.
165: *
166: * @param personPayrollIdentifier The personPayrollIdentifier to set.
167: *
168: */
169: public void setPersonPayrollIdentifier(String emplid) {
170: this .personPayrollIdentifier = emplid;
171: }
172:
173: /**
174: * Gets the primaryDepartmentCode attribute.
175: *
176: * @return - Returns the primaryDepartmentCode
177: *
178: */
179: public String getPrimaryDepartmentCode() {
180: return primaryDepartmentCode;
181: }
182:
183: /**
184: * Sets the primaryDepartmentCode attribute.
185: *
186: * @param primaryDepartmentCode The primaryDepartmentCode to set.
187: *
188: */
189: public void setPrimaryDepartmentCode(String deptid) {
190: this .primaryDepartmentCode = deptid;
191: }
192:
193: /**
194: * Gets the personEmailAddress attribute.
195: *
196: * @return - Returns the personEmailAddress
197: *
198: */
199: public String getPersonEmailAddress() {
200: return personEmailAddress;
201: }
202:
203: /**
204: * Sets the personEmailAddress attribute.
205: *
206: * @param personEmailAddress The personEmailAddress to set.
207: *
208: */
209: public void setPersonEmailAddress(String personEmailAddress) {
210: this .personEmailAddress = personEmailAddress;
211: }
212:
213: /**
214: * Gets the personFirstName attribute.
215: *
216: * @return - Returns the personFirstName
217: *
218: */
219: public String getPersonFirstName() {
220: return personFirstName;
221: }
222:
223: /**
224: * Sets the personFirstName attribute.
225: *
226: * @param personFirstName The personFirstName to set.
227: *
228: */
229: public void setPersonFirstName(String personFirstName) {
230: this .personFirstName = personFirstName;
231: }
232:
233: /**
234: * Gets the personLastName attribute.
235: *
236: * @return - Returns the personLastName
237: *
238: */
239: public String getPersonLastName() {
240: return personLastName;
241: }
242:
243: /**
244: * Sets the personLastName attribute.
245: *
246: * @param personLastName The personLastName to set.
247: *
248: */
249: public void setPersonLastName(String personLastName) {
250: this .personLastName = personLastName;
251: }
252:
253: /**
254: * Gets the personCampusAddress attribute.
255: *
256: * @return - Returns the personCampusAddress
257: *
258: */
259: public String getPersonCampusAddress() {
260: return personCampusAddress;
261: }
262:
263: /**
264: * Sets the personCampusAddress attribute.
265: *
266: * @param personCampusAddress The personCampusAddress to set.
267: *
268: */
269: public void setPersonCampusAddress(String personCampusAddress) {
270: this .personCampusAddress = personCampusAddress;
271: }
272:
273: /**
274: * Gets the personLocalPhoneNumber attribute.
275: *
276: * @return - Returns the personLocalPhoneNumber
277: *
278: */
279: public String getPersonLocalPhoneNumber() {
280: return personLocalPhoneNumber;
281: }
282:
283: /**
284: * Sets the personLocalPhoneNumber attribute.
285: *
286: * @param personLocalPhoneNumber The personLocalPhoneNumber to set.
287: *
288: */
289: public void setPersonLocalPhoneNumber(String personLocalPhoneNumber) {
290: this .personLocalPhoneNumber = personLocalPhoneNumber;
291: }
292:
293: /**
294: * Gets the personBaseSalaryAmount attribute.
295: *
296: * @return - Returns the personBaseSalaryAmount
297: *
298: */
299: public KualiDecimal getPersonBaseSalaryAmount() {
300: return personBaseSalaryAmount;
301: }
302:
303: /**
304: * Sets the personBaseSalaryAmount attribute.
305: *
306: * @param personBaseSalaryAmount The personBaseSalaryAmount to set.
307: *
308: */
309: public void setPersonBaseSalaryAmount(
310: KualiDecimal personBaseSalaryAmount) {
311: this .personBaseSalaryAmount = personBaseSalaryAmount;
312: }
313:
314: /**
315: * @return Returns the personTaxIdentifier.
316: */
317: public String getPersonTaxIdentifier() {
318: return personTaxIdentifier;
319: }
320:
321: /**
322: * @param personTaxIdentifier The personTaxIdentifier to set.
323: */
324: public void setPersonTaxIdentifier(String personSocialSecurityNbrId) {
325: this .personTaxIdentifier = personSocialSecurityNbrId;
326: }
327:
328: /**
329: * @return Returns the campusCode.
330: */
331: public String getCampusCode() {
332: return campusCode;
333: }
334:
335: /**
336: * @param campusCode The campusCode to set.
337: */
338: public void setCampusCode(String campusCode) {
339: this .campusCode = campusCode;
340: }
341:
342: /**
343: * @return Returns the campus.
344: */
345: public Campus getCampus() {
346: return campus;
347: }
348:
349: /**
350: * @param campus The campus to set.
351: * @deprecated
352: */
353: public void setCampus(Campus campus) {
354: this .campus = campus;
355: }
356:
357: /**
358: * Gets the personName attribute.
359: * @return Returns the personName.
360: */
361: public String getPersonName() {
362: return personName;
363: }
364:
365: /**
366: * Sets the personName attribute value.
367: * @param personName The personName to set.
368: */
369: public void setPersonName(String personName) {
370: this .personName = personName;
371: }
372:
373: /**
374: * Gets the financialSystemsEncryptedPasswordText attribute.
375: * @return Returns the financialSystemsEncryptedPasswordText.
376: */
377: public String getFinancialSystemsEncryptedPasswordText() {
378: return financialSystemsEncryptedPasswordText;
379: }
380:
381: /**
382: * Sets the financialSystemsEncryptedPasswordText attribute value.
383: * @param financialSystemsEncryptedPasswordText The financialSystemsEncryptedPasswordText to set.
384: */
385: public void setFinancialSystemsEncryptedPasswordText(
386: String financialSystemsEncryptedPasswordText) {
387: this .financialSystemsEncryptedPasswordText = financialSystemsEncryptedPasswordText;
388: }
389:
390: private void initModuleUsers() {
391: if (universalUserService == null) {
392: universalUserService = KNSServiceLocator
393: .getUniversalUserService();
394: }
395: moduleUsers = universalUserService.getModuleUsers(this );
396: }
397:
398: public KualiModuleUser getModuleUser(String moduleId) {
399: if (moduleUsers == null) {
400: initModuleUsers();
401: }
402: refreshModuleUsersToUniversalUserReferences();
403: KualiModuleUser kualiModuleUser = moduleUsers.get(moduleId);
404: return kualiModuleUser;
405: }
406:
407: public Map<String, KualiModuleUser> getModuleUsers() {
408: if (moduleUsers == null) {
409: initModuleUsers();
410: }
411: refreshModuleUsersToUniversalUserReferences();
412: return moduleUsers;
413: }
414:
415: /**
416: * sometimes there are problems w/ the serialization when coming back from struts when retrieving the actionform from struts.
417: *
418: * the module user is not linked to "this" universal user, so this code fixes that
419: */
420: protected void refreshModuleUsersToUniversalUserReferences() {
421: for (KualiModuleUser kualiModuleUser : moduleUsers.values()) {
422: if (kualiModuleUser instanceof KualiModuleUserBase) {
423: ((KualiModuleUserBase) kualiModuleUser)
424: .setUniversalUser(this );
425: }
426: }
427: }
428:
429: public boolean isActiveForModule(String moduleId) {
430: KualiModuleUser user = getModuleUser(moduleId);
431: if (user == null)
432: return false;
433: return user.isActive();
434: }
435:
436: public boolean isActiveForAnyModule() {
437: if (activeForAnyModule == false) {
438: for (KualiModuleUser user : getModuleUsers().values()) {
439: if (user != null && user.isActive()) {
440: activeForAnyModule = true;
441: }
442: }
443: }
444: return activeForAnyModule;
445: }
446:
447: /**
448: * Returns a comma-delimited string of the KualiModule codes for which this person is an active user.
449: *
450: * @return
451: */
452: public String getActiveModuleCodeString() {
453: if (kualiModuleService == null) {
454: kualiModuleService = KNSServiceLocator
455: .getKualiModuleService();
456: }
457: StringBuffer sb = new StringBuffer(40);
458: for (KualiModule module : kualiModuleService
459: .getInstalledModules()) {
460: if (isActiveForModule(module.getModuleId())) {
461: if (sb.length() > 0) {
462: sb.append(", ");
463: }
464: sb.append(module.getModuleCode());
465: }
466: }
467: return sb.toString();
468: }
469:
470: private Map<String, Map<String, String>> moduleProperties;
471:
472: public Map<String, Map<String, String>> getModuleProperties() {
473: if (moduleProperties == null) {
474: loadModuleProperties();
475: }
476: return moduleProperties;
477: }
478:
479: public Map<String, String> getModuleProperties(String moduleId) {
480: if (moduleProperties == null) {
481: loadModuleProperties();
482: }
483: if (moduleProperties.get(moduleId) == null) {
484: moduleProperties.put(moduleId,
485: new HashMap<String, String>());
486: }
487: return moduleProperties.get(moduleId);
488: }
489:
490: private void loadModuleProperties() {
491: if (universalUserService == null) {
492: universalUserService = KNSServiceLocator
493: .getUniversalUserService();
494: }
495: moduleProperties = universalUserService
496: .loadModuleUserProperties(this );
497: }
498:
499: /**
500: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
501: */
502: protected LinkedHashMap toStringMapper() {
503: LinkedHashMap m = new LinkedHashMap();
504: m.put("personUniversalIdentifier",
505: this .personUniversalIdentifier);
506: return m;
507: }
508:
509: /**
510: * @return Returns the groups.
511: */
512: public List<KualiGroup> getGroups() {
513: if (groups == null) {
514: refreshUserGroups();
515: }
516: return groups;
517: }
518:
519: /**
520: * @param groups The groups to set.
521: */
522: public void setGroups(List<KualiGroup> groups) {
523: this .groups = groups;
524: }
525:
526: public void refreshUserGroups() {
527: if (universalUserService == null) {
528: universalUserService = KNSServiceLocator
529: .getUniversalUserService();
530: }
531: if (!StringUtils.isBlank(personUserIdentifier)) {
532: setGroups(universalUserService.getUsersGroups(this ));
533: }
534: }
535:
536: /**
537: * boolean to indicate if the user is a member of a kuali group
538: *
539: * @param kualiGroup
540: * @return true if the user is a member of the group passed in
541: */
542: public boolean isMember(String groupName) {
543: if (universalUserService == null) {
544: universalUserService = KNSServiceLocator
545: .getUniversalUserService();
546: }
547: return universalUserService.isMember(this , groupName);
548: }
549:
550: public boolean isMember(KualiGroup kualiGroup) {
551: if (universalUserService == null) {
552: universalUserService = KNSServiceLocator
553: .getUniversalUserService();
554: }
555: return universalUserService.isMember(this , kualiGroup);
556: }
557:
558: /**
559: * check if the user is a supervisor user (belongs to all groups)
560: *
561: * @return
562: */
563: public boolean isSupervisorUser() {
564: if (universalUserService == null) {
565: universalUserService = KNSServiceLocator
566: .getUniversalUserService();
567: }
568: return universalUserService.isSupervisorUser(this );
569: }
570:
571: /**
572: * check if the user is an exception user (has the Exception role, belongs to the Exception workgroup, whatever)
573: *
574: * @return
575: */
576: public boolean isWorkflowExceptionUser() {
577: if (universalUserService == null) {
578: universalUserService = KNSServiceLocator
579: .getUniversalUserService();
580: }
581: return universalUserService.isWorkflowExceptionUser(this );
582: }
583:
584: public String getPersonMiddleName() {
585: return personMiddleName;
586: }
587:
588: public void setPersonMiddleName(String personMiddleName) {
589: this .personMiddleName = personMiddleName;
590: }
591:
592: public String getEmployeeTypeCode() {
593: return employeeTypeCode;
594: }
595:
596: public void setEmployeeTypeCode(String personTypeCode) {
597: this .employeeTypeCode = personTypeCode;
598: }
599:
600: public String getPersonTaxIdentifierTypeCode() {
601: return personTaxIdentifierTypeCode;
602: }
603:
604: public void setPersonTaxIdentifierTypeCode(
605: String personTaxIdentifierTypeCode) {
606: this .personTaxIdentifierTypeCode = personTaxIdentifierTypeCode;
607: }
608:
609: public boolean isAffiliate() {
610: return affiliate;
611: }
612:
613: public void setAffiliate(boolean affiliate) {
614: this .affiliate = affiliate;
615: }
616:
617: public boolean isFaculty() {
618: return faculty;
619: }
620:
621: public void setFaculty(boolean faculty) {
622: this .faculty = faculty;
623: }
624:
625: public boolean isStaff() {
626: return staff;
627: }
628:
629: public void setStaff(boolean staff) {
630: this .staff = staff;
631: }
632:
633: public boolean isStudent() {
634: return student;
635: }
636:
637: public void setStudent(boolean student) {
638: this .student = student;
639: }
640:
641: /**
642: *
643: * This method returns the Employee Status record currently associated with this Universal User
644: * @return EmployeeStatus the current status of this user
645: */
646: public EmployeeStatus getEmployeeStatus() {
647: return employeeStatus;
648: }
649:
650: /**
651: *
652: * This method sets the current employee status of this universal user
653: * @param employeeStatus the current status this universal user should be associated with
654: * @deprecated
655: */
656: public void setEmployeeStatus(EmployeeStatus employeeStatus) {
657: this .employeeStatus = employeeStatus;
658: }
659:
660: /**
661: *
662: * This method returns the employee type that currently describes this universal user
663: * @return EmployeeType the type of employee this universal user currently is
664: */
665: public EmployeeType getEmployeeType() {
666: return employeeType;
667: }
668:
669: /**
670: *
671: * This method sets the employee type of this universal user
672: * @param employeeType the employee type to set this universal user to
673: * @deprecated
674: */
675: public void setEmployeeType(EmployeeType employeeType) {
676: this .employeeType = employeeType;
677: }
678:
679: /* added for XStream de-serialization purposes */
680: @Deprecated
681: private transient String emplid;
682: @Deprecated
683: private transient String deptid;
684:
685: /**
686: * Gets the changedModuleCodes attribute.
687: * @return Returns the changedModuleCodes.
688: */
689: public Set<String> getChangedModuleCodes() {
690: return changedModuleCodes;
691: }
692:
693: /**
694: * Sets the changedModuleCodes attribute value.
695: * @param changedModuleCodes The changedModuleCodes to set.
696: */
697: public void setChangedModuleCodes(Set<String> changedModuleCodes) {
698: this.changedModuleCodes = changedModuleCodes;
699: }
700: }
|