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.module.kra.budget.bo;
017:
018: import java.util.ArrayList;
019: import java.util.LinkedHashMap;
020: import java.util.List;
021:
022: import org.apache.ojb.broker.PersistenceBroker;
023: import org.apache.ojb.broker.PersistenceBrokerException;
024: import org.kuali.core.bo.PersistableBusinessObjectBase;
025: import org.kuali.core.bo.user.UniversalUser;
026: import org.kuali.core.service.KualiModuleService;
027: import org.kuali.core.service.UniversalUserService;
028: import org.kuali.core.util.KualiDecimal;
029: import org.kuali.kfs.KFSPropertyConstants;
030: import org.kuali.kfs.context.SpringContext;
031: import org.kuali.module.chart.bo.ChartUser;
032: import org.kuali.module.chart.service.ChartUserService;
033: import org.kuali.module.kra.budget.document.BudgetDocument;
034: import org.kuali.module.kra.budget.service.BudgetPersonnelService;
035:
036: /**
037: * This class...
038: */
039: public class BudgetUser extends PersistableBusinessObjectBase implements
040: Comparable {
041:
042: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
043: .getLogger(BudgetUser.class);
044: private transient BudgetPersonnelService budgetPersonnelService;
045: private transient ChartUserService chartUserService;
046:
047: private String documentNumber; // RDOC_NBR
048: private Integer budgetUserSequenceNumber; // BDGT_USR_SEQ_NBR
049: private String fiscalCampusCode; // EMP_FSCL_CMP_CD
050: private String primaryDepartmentCode; // EMP_PRM_DEPT_CD
051: private KualiDecimal baseSalary; // PRSN_BASE_SLRY
052: private Integer budgetSalaryFiscalYear;
053: private String role; //
054: private String personUniversalIdentifier;
055: private UniversalUser user;
056: private String appointmentTypeCode; // Not present in the database - only for the convenience of the user interface
057: private String appointmentTypeDescription; // Not present in the database - only for the convenience of the user interface
058: private boolean personSeniorKeyIndicator;
059: private boolean personSecretarialClericalIndicator;
060: private boolean personPostDoctoralIndicator;
061: private String personNamePrefixText;
062: private String personNameSuffixText;
063: private String personSalaryJustificationText;
064: private boolean personProjectDirectorIndicator;
065: private Integer personHourlyNumber;
066:
067: private List userAppointmentTasks = new ArrayList();
068:
069: // Only used to ease development of the UI - could/should this be somewhere else?
070: private Integer currentTaskNumber;
071: private Integer previousTaskNumber;
072: private String previousAppointmentTypeCode;
073: private String previousSecondaryAppointmentTypeCode;
074: private String secondaryAppointmentTypeCode;
075: private boolean delete;
076:
077: /**
078: * Constructs a BudgetUser.java.
079: */
080: public BudgetUser() {
081: super ();
082: budgetPersonnelService = SpringContext
083: .getBean(BudgetPersonnelService.class);
084: chartUserService = (ChartUserService) SpringContext.getBean(
085: KualiModuleService.class).getModule("chart")
086: .getModuleUserService();
087: }
088:
089: public BudgetUser(String documentNumber,
090: Integer budgetUserSequenceNumber) {
091: this ();
092: this .documentNumber = documentNumber;
093: this .budgetUserSequenceNumber = budgetUserSequenceNumber;
094: }
095:
096: public BudgetUser(BudgetUser budgetUser) {
097: this ();
098: this .documentNumber = budgetUser.getDocumentNumber();
099: this .budgetUserSequenceNumber = budgetUser
100: .getBudgetUserSequenceNumber();
101: this .fiscalCampusCode = budgetUser.getFiscalCampusCode();
102: this .primaryDepartmentCode = budgetUser
103: .getPrimaryDepartmentCode();
104: this .baseSalary = budgetUser.getBaseSalary();
105: this .role = budgetUser.getRole();
106: this .personUniversalIdentifier = budgetUser
107: .getPersonUniversalIdentifier();
108: this .personNamePrefixText = budgetUser
109: .getPersonNamePrefixText();
110: this .personNameSuffixText = budgetUser
111: .getPersonNameSuffixText();
112: this .personSalaryJustificationText = budgetUser
113: .getPersonSalaryJustificationText();
114: this .personProjectDirectorIndicator = budgetUser
115: .isPersonProjectDirectorIndicator();
116: this .personSeniorKeyIndicator = budgetUser
117: .isPersonSeniorKeyIndicator();
118: this .personSecretarialClericalIndicator = budgetUser
119: .isPersonSecretarialClericalIndicator();
120: this .personPostDoctoralIndicator = budgetUser
121: .isPersonPostDoctoralIndicator();
122: this .budgetSalaryFiscalYear = budgetUser
123: .getBudgetSalaryFiscalYear();
124:
125: this .userAppointmentTasks = new ArrayList(budgetUser
126: .getUserAppointmentTasks());
127: }
128:
129: public void initializeBudgetUser(BudgetDocument budgetDocument) {
130: this .setBudgetUserSequenceNumber(budgetDocument
131: .getPersonnelNextSequenceNumber());
132: this .setDocumentNumber(budgetDocument.getDocumentNumber());
133: this .synchronizeUserObject();
134: this .createUserAppointmentTasks(budgetDocument);
135: }
136:
137: public void createUserAppointmentTasks(BudgetDocument budgetDocument) {
138: budgetPersonnelService.createPersonnelDetail(this ,
139: budgetDocument);
140: }
141:
142: /**
143: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
144: */
145: protected LinkedHashMap toStringMapper() {
146: LinkedHashMap m = new LinkedHashMap();
147: m
148: .put(KFSPropertyConstants.DOCUMENT_NUMBER,
149: this .documentNumber);
150: m.put("userSequenceNumber", this .budgetUserSequenceNumber);
151: return m;
152: }
153:
154: /**
155: * Gets the baseSalary attribute.
156: *
157: * @return Returns the baseSalary.
158: */
159: public KualiDecimal getBaseSalary() {
160: return baseSalary;
161: }
162:
163: /**
164: * Sets the baseSalary attribute value.
165: *
166: * @param baseSalary The baseSalary to set.
167: */
168: public void setBaseSalary(KualiDecimal baseSalary) {
169: this .baseSalary = baseSalary;
170: }
171:
172: /**
173: * Gets the documentNumber attribute.
174: *
175: * @return Returns the documentNumber.
176: */
177: public String getDocumentNumber() {
178: return documentNumber;
179: }
180:
181: /**
182: * Sets the documentNumber attribute value.
183: *
184: * @param documentNumber The documentNumber to set.
185: */
186: public void setDocumentNumber(String documentNumber) {
187: this .documentNumber = documentNumber;
188: }
189:
190: /**
191: * Gets the fiscalCampusCode attribute.
192: *
193: * @return Returns the fiscalCampusCode.
194: */
195: public String getFiscalCampusCode() {
196: return fiscalCampusCode;
197: }
198:
199: /**
200: * Sets the fiscalCampusCode attribute value.
201: *
202: * @param fiscalCampusCode The fiscalCampusCode to set.
203: */
204: public void setFiscalCampusCode(String fiscalCampusCode) {
205: this .fiscalCampusCode = fiscalCampusCode;
206: }
207:
208: /**
209: * Gets the primaryDepartmentCode attribute.
210: *
211: * @return Returns the primaryDepartmentCode.
212: */
213: public String getPrimaryDepartmentCode() {
214: return primaryDepartmentCode;
215: }
216:
217: /**
218: * Sets the primaryDepartmentCode attribute value.
219: *
220: * @param primaryDepartmentCode The primaryDepartmentCode to set.
221: */
222: public void setPrimaryDepartmentCode(String primaryDepartmentCode) {
223: this .primaryDepartmentCode = primaryDepartmentCode;
224: }
225:
226: /**
227: * Gets the role attribute.
228: *
229: * @return Returns the role.
230: */
231: public String getRole() {
232: return role;
233: }
234:
235: /**
236: * Sets the role attribute value.
237: *
238: * @param role The role to set.
239: */
240: public void setRole(String role) {
241: this .role = role;
242: }
243:
244: /**
245: * Gets the personUniversalIdentifier attribute.
246: *
247: * @return Returns the personUniversalIdentifier.
248: */
249: public String getPersonUniversalIdentifier() {
250: return personUniversalIdentifier;
251: }
252:
253: /**
254: * Sets the personUniversalIdentifier attribute value.
255: *
256: * @param personUniversalIdentifier The personUniversalIdentifier to set.
257: */
258: public void setPersonUniversalIdentifier(
259: String personUniversalIdentifier) {
260: this .personUniversalIdentifier = personUniversalIdentifier;
261: }
262:
263: /**
264: * Gets the user attribute.
265: *
266: * @return Returns the user.
267: */
268: public UniversalUser getUser() {
269: user = SpringContext.getBean(UniversalUserService.class)
270: .updateUniversalUserIfNecessary(
271: personUniversalIdentifier, user);
272: return user;
273: }
274:
275: /**
276: * Sets the user attribute value.
277: *
278: * @param user The user to set.
279: * @deprecated - Should not be set, should be retrieved by SpringContext each time. See getUser() above.
280: */
281: public void setUser(UniversalUser user) {
282: this .user = user;
283: }
284:
285: /**
286: * Gets the userSequenceNumber attribute.
287: *
288: * @return Returns the userSequenceNumber.
289: */
290: public Integer getBudgetUserSequenceNumber() {
291: return budgetUserSequenceNumber;
292: }
293:
294: /**
295: * Sets the userSequenceNumber attribute value.
296: *
297: * @param userSequenceNumber The userSequenceNumber to set.
298: */
299: public void setBudgetUserSequenceNumber(Integer userSequenceNumber) {
300: this .budgetUserSequenceNumber = userSequenceNumber;
301: }
302:
303: /**
304: * Gets the personNamePrefixText attribute.
305: *
306: * @return Returns the personNamePrefixText
307: */
308: public String getPersonNamePrefixText() {
309: return personNamePrefixText;
310: }
311:
312: /**
313: * Sets the personNamePrefixText attribute.
314: *
315: * @param personNamePrefixText The personNamePrefixText to set.
316: */
317: public void setPersonNamePrefixText(String personNamePrefixText) {
318: this .personNamePrefixText = personNamePrefixText;
319: }
320:
321: /**
322: * Gets the personNameSuffixText attribute.
323: *
324: * @return Returns the personNameSuffixText
325: */
326: public String getPersonNameSuffixText() {
327: return personNameSuffixText;
328: }
329:
330: /**
331: * Sets the personNameSuffixText attribute.
332: *
333: * @param personNameSuffixText The personNameSuffixText to set.
334: */
335: public void setPersonNameSuffixText(String personNameSuffixText) {
336: this .personNameSuffixText = personNameSuffixText;
337: }
338:
339: /**
340: * Gets the personPostDoctoralIndicator attribute.
341: *
342: * @return Returns the personPostDoctoralIndicator
343: */
344: public boolean isPersonPostDoctoralIndicator() {
345: return personPostDoctoralIndicator;
346: }
347:
348: /**
349: * Sets the personPostDoctoralIndicator attribute.
350: *
351: * @param personPostDoctoralIndicator The personPostDoctoralIndicator to set.
352: */
353: public void setPersonPostDoctoralIndicator(
354: boolean personPostDoctoralIndicator) {
355: this .personPostDoctoralIndicator = personPostDoctoralIndicator;
356: }
357:
358: /**
359: * Gets the personSecretarialClericalIndicator attribute.
360: *
361: * @return Returns the personSecretarialClericalIndicator
362: */
363: public boolean isPersonSecretarialClericalIndicator() {
364: return personSecretarialClericalIndicator;
365: }
366:
367: /**
368: * Sets the personSecretarialClericalIndicator attribute.
369: *
370: * @param personSecretarialClericalIndicator The personSecretarialClericalIndicator to set.
371: */
372: public void setPersonSecretarialClericalIndicator(
373: boolean personSecretarialClericalIndicator) {
374: this .personSecretarialClericalIndicator = personSecretarialClericalIndicator;
375: }
376:
377: /**
378: * Gets the personSeniorKeyIndicator attribute.
379: *
380: * @return Returns the personSeniorKeyIndicator
381: */
382: public boolean isPersonSeniorKeyIndicator() {
383: return personSeniorKeyIndicator;
384: }
385:
386: /**
387: * Sets the personSeniorKeyIndicator attribute.
388: *
389: * @param personSeniorKeyIndicator The personSeniorKeyIndicator to set.
390: */
391: public void setPersonSeniorKeyIndicator(
392: boolean personSeniorKeyIndicator) {
393: this .personSeniorKeyIndicator = personSeniorKeyIndicator;
394: }
395:
396: /**
397: * Makes sure that copied fields between the referenced UniversalUser object and this object are properly synchronized.
398: */
399: public void synchronizeUserObject() {
400: if (this .getPersonUniversalIdentifier() != null) {
401: this .getUser();
402: if (this .getUser().getPersonBaseSalaryAmount() != null) {
403: this .baseSalary = this .user.getPersonBaseSalaryAmount();
404: } else {
405: this .baseSalary = new KualiDecimal(0);
406: }
407:
408: String chart = "";
409: String org = "";
410: if (this .user.getModuleUser(ChartUser.MODULE_ID) != null) {
411: chart = ((ChartUser) this .user
412: .getModuleUser(ChartUser.MODULE_ID))
413: .getChartOfAccountsCode();
414: org = ((ChartUser) this .user
415: .getModuleUser(ChartUser.MODULE_ID))
416: .getOrganizationCode();
417: } else {
418: chart = SpringContext.getBean(ChartUserService.class)
419: .getDefaultChartCode(this .user);
420: org = SpringContext.getBean(ChartUserService.class)
421: .getDefaultOrganizationCode(this .user);
422: }
423:
424: this .fiscalCampusCode = chart;
425: this .primaryDepartmentCode = org;
426: } else {
427: this .baseSalary = new KualiDecimal(0);
428: this .fiscalCampusCode = "";
429: this .primaryDepartmentCode = "";
430: }
431: }
432:
433: /**
434: * Gets the appointmentType attribute.
435: *
436: * @return Returns the appointmentType.
437: */
438: public String getAppointmentTypeCode() {
439: return appointmentTypeCode;
440: }
441:
442: /**
443: * Sets the appointmentType attribute value.
444: *
445: * @param appointmentType The appointmentType to set.
446: */
447: public void setAppointmentTypeCode(String appointmentTypeCode) {
448: this .appointmentTypeCode = appointmentTypeCode;
449: }
450:
451: /**
452: * Gets the appointmentTypeDescription attribute.
453: *
454: * @return Returns the appointmentTypeDescription.
455: */
456: public String getAppointmentTypeDescription() {
457: return appointmentTypeDescription;
458: }
459:
460: /**
461: * Sets the appointmentTypeDescription attribute value.
462: *
463: * @param appointmentTypeDescription The appointmentTypeDescription to set.
464: */
465: public void setAppointmentTypeDescription(
466: String appointmentTypeDescription) {
467: this .appointmentTypeDescription = appointmentTypeDescription;
468: }
469:
470: /**
471: * Log the state of this object.
472: */
473: public void logState() {
474: LOG.info("userSequenceNumber: ("
475: + this .budgetUserSequenceNumber + ")");
476: /* LOG.info(" version: (" + this.getVersion() +")"); */
477: LOG.info(" documentNumber: (" + this .documentNumber + ")");
478: LOG.info(" fiscalCampusCode: (" + this .fiscalCampusCode + ")");
479: LOG.info(" primaryDepartmentCode: ("
480: + this .primaryDepartmentCode + ")");
481: LOG.info(" baseSalary: (" + this .baseSalary + ")");
482: LOG.info(" role: (" + this .role + ")");
483: LOG.info(" personUniversalIdentifier: ("
484: + this .personUniversalIdentifier + ")");
485: LOG.info(" appointmentTypeCode: (" + this .appointmentTypeCode
486: + ")");
487: LOG.info(" appointmentTypeDescription: ("
488: + this .appointmentTypeDescription + ")");
489: LOG.info(" personSeniorKeyIndicator: ("
490: + this .personSeniorKeyIndicator + ")");
491: LOG.info(" personSecretarialClericalIndicator: ("
492: + this .personSecretarialClericalIndicator + ")");
493: LOG.info(" personPostDoctoralIndicator: ("
494: + this .personPostDoctoralIndicator + ")");
495: LOG.info(" personNamePrefixText: ("
496: + this .personNamePrefixText + ")");
497: LOG.info(" personNameSuffixText: ("
498: + this .personNameSuffixText + ")");
499: if (this .user == null) {
500: LOG.info(" user: <null>");
501: } else {
502: LOG.info(" user: ("
503: + this .user.getPersonPayrollIdentifier() + ")");
504: }
505: }
506:
507: public UserAppointmentTask getUserAppointmentTask(int index) {
508: while (getUserAppointmentTasks().size() <= index) {
509: getUserAppointmentTasks().add(new UserAppointmentTask());
510: }
511: return (UserAppointmentTask) getUserAppointmentTasks().get(
512: index);
513: }
514:
515: /**
516: * Gets the userAppointmentTasks attribute.
517: *
518: * @return Returns the userAppointmentTasks.
519: */
520: public List<UserAppointmentTask> getUserAppointmentTasks() {
521: return userAppointmentTasks;
522: }
523:
524: /**
525: * Sets the userAppointmentTasks attribute value.
526: *
527: * @param userAppointmentTasks The userAppointmentTasks to set.
528: */
529: public void setUserAppointmentTasks(List userAppointmentTasks) {
530: this .userAppointmentTasks = userAppointmentTasks;
531: }
532:
533: /**
534: * Gets the budgetPersonnelService attribute.
535: *
536: * @return Returns the budgetPersonnelService.
537: */
538: public BudgetPersonnelService getBudgetPersonnelService() {
539: return budgetPersonnelService;
540: }
541:
542: /**
543: * Sets the budgetPersonnelService attribute value.
544: *
545: * @param budgetPersonnelService The budgetPersonnelService to set.
546: */
547: public void setBudgetPersonnelService(
548: BudgetPersonnelService budgetPersonnelService) {
549: this .budgetPersonnelService = budgetPersonnelService;
550: }
551:
552: /**
553: * Gets the currentTask attribute.
554: *
555: * @return Returns the currentTask.
556: */
557: public Integer getCurrentTaskNumber() {
558: return currentTaskNumber;
559: }
560:
561: /**
562: * Sets the currentTask attribute value.
563: *
564: * @param currentTask The currentTask to set.
565: */
566: public void setCurrentTaskNumber(Integer currentTaskNumber) {
567: this .currentTaskNumber = currentTaskNumber;
568: }
569:
570: /**
571: * Gets the personSalaryJustificationText attribute.
572: *
573: * @return Returns the personSalaryJustificationText.
574: */
575: public String getPersonSalaryJustificationText() {
576: return personSalaryJustificationText;
577: }
578:
579: /**
580: * Sets the personSalaryJustificationText attribute value.
581: *
582: * @param personSalaryJustificationText The personSalaryJustificationText to set.
583: */
584: public void setPersonSalaryJustificationText(
585: String personSalaryJustificationText) {
586: this .personSalaryJustificationText = personSalaryJustificationText;
587: }
588:
589: /**
590: * Gets the personProjectDirectorIndicator attribute.
591: *
592: * @return Returns the personProjectDirectorIndicator
593: */
594: public boolean isPersonProjectDirectorIndicator() {
595: return personProjectDirectorIndicator;
596: }
597:
598: /**
599: * Sets the personProjectDirectorIndicator attribute.
600: *
601: * @param personProjectDirectorIndicator The personProjectDirectorIndicator to set.
602: */
603: public void setPersonProjectDirectorIndicator(
604: boolean personProjectDirectorIndicator) {
605: this .personProjectDirectorIndicator = personProjectDirectorIndicator;
606: }
607:
608: /**
609: * @see org.apache.ojb.broker.PersistenceBrokerAware#beforeDelete(org.apache.ojb.broker.PersistenceBroker)
610: */
611: public void beforeDelete(PersistenceBroker persistenceBroker)
612: throws PersistenceBrokerException {
613: super .beforeDelete(persistenceBroker);
614: this .refreshReferenceObject("userAppointmentTasks");
615: }
616:
617: /**
618: * @see java.lang.Comparable#compareTo(java.lang.Object)
619: */
620: public int compareTo(Object o) {
621: BudgetUser budgetUser = (BudgetUser) o;
622: return (this .isPersonProjectDirectorIndicator() ? new Integer(0)
623: : this .getBudgetUserSequenceNumber())
624: .compareTo(budgetUser
625: .isPersonProjectDirectorIndicator() ? new Integer(
626: 0)
627: : budgetUser.getBudgetUserSequenceNumber());
628: }
629:
630: public String getPreviousAppointmentTypeCode() {
631: return previousAppointmentTypeCode;
632: }
633:
634: public void setPreviousAppointmentTypeCode(
635: String previousAppointmentTypeCode) {
636: this .previousAppointmentTypeCode = previousAppointmentTypeCode;
637: }
638:
639: public Integer getPreviousTaskNumber() {
640: return previousTaskNumber;
641: }
642:
643: public void setPreviousTaskNumber(Integer previousTaskNumber) {
644: this .previousTaskNumber = previousTaskNumber;
645: }
646:
647: public Integer getPersonHourlyNumber() {
648: return personHourlyNumber;
649: }
650:
651: public void setPersonHourlyNumber(Integer personHourlyNumber) {
652: this .personHourlyNumber = personHourlyNumber;
653: }
654:
655: public Integer getBudgetSalaryFiscalYear() {
656: return budgetSalaryFiscalYear;
657: }
658:
659: public void setBudgetSalaryFiscalYear(Integer budgetSalaryFiscalYear) {
660: this .budgetSalaryFiscalYear = budgetSalaryFiscalYear;
661: }
662:
663: public String getSecondaryAppointmentTypeCode() {
664: return secondaryAppointmentTypeCode;
665: }
666:
667: public void setSecondaryAppointmentTypeCode(
668: String secondaryAppointmentTypeCode) {
669: this .secondaryAppointmentTypeCode = secondaryAppointmentTypeCode;
670: }
671:
672: public String getPreviousSecondaryAppointmentTypeCode() {
673: return previousSecondaryAppointmentTypeCode;
674: }
675:
676: public void setPreviousSecondaryAppointmentTypeCode(
677: String previousSecondaryAppointmentTypeCode) {
678: this .previousSecondaryAppointmentTypeCode = previousSecondaryAppointmentTypeCode;
679: }
680:
681: public boolean isDelete() {
682: return delete;
683: }
684:
685: public void setDelete(boolean delete) {
686: this.delete = delete;
687: }
688: }
|