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.routingform.bo;
017:
018: import java.util.LinkedHashMap;
019:
020: import org.kuali.core.bo.PersistableBusinessObjectBase;
021: import org.kuali.core.bo.user.UniversalUser;
022: import org.kuali.core.service.UniversalUserService;
023: import org.kuali.core.util.KualiInteger;
024: import org.kuali.kfs.bo.Country;
025: import org.kuali.kfs.bo.PostalZipCode;
026: import org.kuali.kfs.bo.State;
027: import org.kuali.kfs.context.SpringContext;
028: import org.kuali.kfs.service.ParameterService;
029: import org.kuali.module.chart.bo.Chart;
030: import org.kuali.module.chart.bo.Org;
031: import org.kuali.module.chart.service.ChartUserService;
032: import org.kuali.module.kra.KraConstants;
033: import org.kuali.module.kra.budget.bo.BudgetUser;
034: import org.kuali.module.kra.routingform.document.RoutingFormDocument;
035:
036: public class RoutingFormPersonnel extends PersistableBusinessObjectBase {
037:
038: private String documentNumber;
039: private Integer routingFormPersonSequenceNumber;
040: private String personUniversalIdentifier;
041: private String chartOfAccountsCode;
042: private String organizationCode;
043: private KualiInteger personCreditPercent;
044: private KualiInteger personFinancialAidPercent;
045: private String personRoleCode;
046: private String personPrefixText;
047: private String personSuffixText;
048: private String personPositionTitle;
049: private String personDivisionText;
050: private String personLine1Address;
051: private String personLine2Address;
052: private String personCityName;
053: private String personCountyName;
054: private String personStateCode;
055: private String personCountryCode;
056: private String personZipCode;
057: private String personPhoneNumber;
058: private String personFaxNumber;
059: private String personEmailAddress;
060: private String personRoleText;
061: private boolean personToBeNamedIndicator;
062:
063: private Org organization;
064: private Chart chartOfAccounts;
065: private State personState;
066: private PostalZipCode personZip;
067: private Country personCountry;
068: private PersonRole personRole;
069: // private RoutingFormDocument routingFormDocument;
070: private UniversalUser user;
071:
072: /**
073: * Default constructor.
074: */
075: public RoutingFormPersonnel() {
076:
077: }
078:
079: /**
080: * Default constructor.
081: */
082: public RoutingFormPersonnel(BudgetUser budgetUser,
083: String documentNumber, String personRoleCode) {
084: this .documentNumber = documentNumber;
085: this .personRoleCode = personRoleCode;
086: this .personUniversalIdentifier = budgetUser
087: .getPersonUniversalIdentifier();
088:
089: this .chartOfAccountsCode = budgetUser.getFiscalCampusCode();
090: this .organizationCode = budgetUser.getPrimaryDepartmentCode();
091: this .personPrefixText = budgetUser.getPersonNamePrefixText();
092: this .personSuffixText = budgetUser.getPersonNameSuffixText();
093: ;
094: this .personRoleText = budgetUser.getRole();
095: this .personToBeNamedIndicator = budgetUser
096: .getPersonUniversalIdentifier() == null;
097: }
098:
099: /**
100: * Sets several fields in RoutingFormPersonnel person based upon the contained UniversalUserService's ChartUserService:
101: * <ul>
102: * <li>chart</li>
103: * <li>org</li>
104: * <li>email address</li>
105: * <li>campus address</li>
106: * <li>phone number</li>
107: * </ul>
108: */
109: public void populateWithUserServiceFields() {
110: // retrieve services and refresh UniversalUser objects (it's empty after returning from a kul:lookup)
111: UniversalUserService universalUserService = SpringContext
112: .getBean(UniversalUserService.class);
113: ChartUserService chartUserService = SpringContext
114: .getBean(ChartUserService.class);
115: UniversalUser user = universalUserService
116: .updateUniversalUserIfNecessary(this
117: .getPersonUniversalIdentifier(), this .getUser());
118:
119: // set chart / org for new person
120: this .setChartOfAccountsCode(chartUserService
121: .getDefaultChartCode(user));
122: this .setOrganizationCode(chartUserService
123: .getDefaultOrganizationCode(user));
124:
125: // set email address, campus address, and phone
126: this .setPersonEmailAddress(user.getPersonEmailAddress());
127: this .setPersonLine1Address(user.getPersonCampusAddress());
128: this .setPersonPhoneNumber(user.getPersonLocalPhoneNumber());
129: }
130:
131: /**
132: * Gets the documentNumber attribute.
133: *
134: * @return Returns the documentNumber
135: */
136: public String getDocumentNumber() {
137: return documentNumber;
138: }
139:
140: /**
141: * Sets the documentNumber attribute.
142: *
143: * @param documentNumber The documentNumber to set.
144: */
145: public void setDocumentNumber(String documentNumber) {
146: this .documentNumber = documentNumber;
147: }
148:
149: /**
150: * Gets the routingFormPersonSequenceNumber attribute.
151: *
152: * @return Returns the routingFormPersonSequenceNumber.
153: */
154: public Integer getRoutingFormPersonSequenceNumber() {
155: return routingFormPersonSequenceNumber;
156: }
157:
158: /**
159: * Sets the routingFormPersonSequenceNumber attribute value.
160: *
161: * @param routingFormPersonSequenceNumber The routingFormPersonSequenceNumber to set.
162: */
163: public void setRoutingFormPersonSequenceNumber(
164: Integer routingFormPersonSequenceNumber) {
165: this .routingFormPersonSequenceNumber = routingFormPersonSequenceNumber;
166: }
167:
168: /**
169: * Gets the personUniversalIdentifier attribute.
170: *
171: * @return Returns the personUniversalIdentifier
172: */
173: public String getPersonUniversalIdentifier() {
174: return personUniversalIdentifier;
175: }
176:
177: /**
178: * Sets the personUniversalIdentifier attribute.
179: *
180: * @param personUniversalIdentifier The personUniversalIdentifier to set.
181: */
182: public void setPersonUniversalIdentifier(
183: String personUniversalIdentifier) {
184: this .personUniversalIdentifier = personUniversalIdentifier;
185: }
186:
187: /**
188: * Gets the chartOfAccountsCode attribute.
189: *
190: * @return Returns the chartOfAccountsCode
191: */
192: public String getChartOfAccountsCode() {
193: return chartOfAccountsCode;
194: }
195:
196: /**
197: * Sets the chartOfAccountsCode attribute.
198: *
199: * @param chartOfAccountsCode The chartOfAccountsCode to set.
200: */
201: public void setChartOfAccountsCode(String chartOfAccountsCode) {
202: this .chartOfAccountsCode = chartOfAccountsCode;
203: }
204:
205: /**
206: * Gets the organizationCode attribute.
207: *
208: * @return Returns the organizationCode
209: */
210: public String getOrganizationCode() {
211: return organizationCode;
212: }
213:
214: /**
215: * Sets the organizationCode attribute.
216: *
217: * @param organizationCode The organizationCode to set.
218: */
219: public void setOrganizationCode(String organizationCode) {
220: this .organizationCode = organizationCode;
221: }
222:
223: /**
224: * Gets the personCreditPercent attribute.
225: *
226: * @return Returns the personCreditPercent
227: */
228: public KualiInteger getPersonCreditPercent() {
229: return personCreditPercent;
230: }
231:
232: /**
233: * Sets the personCreditPercent attribute.
234: *
235: * @param personCreditPercent The personCreditPercent to set.
236: */
237: public void setPersonCreditPercent(KualiInteger personCreditPercent) {
238: this .personCreditPercent = personCreditPercent;
239: }
240:
241: /**
242: * Gets the personFinancialAidPercent attribute.
243: *
244: * @return Returns the personFinancialAidPercent
245: */
246: public KualiInteger getPersonFinancialAidPercent() {
247: return personFinancialAidPercent;
248: }
249:
250: /**
251: * Sets the personFinancialAidPercent attribute.
252: *
253: * @param personFinancialAidPercent The personFinancialAidPercent to set.
254: */
255: public void setPersonFinancialAidPercent(
256: KualiInteger personFinancialAidPercent) {
257: this .personFinancialAidPercent = personFinancialAidPercent;
258: }
259:
260: /**
261: * Gets the personRoleCode attribute.
262: *
263: * @return Returns the personRoleCode
264: */
265: public String getPersonRoleCode() {
266: return personRoleCode;
267: }
268:
269: /**
270: * Sets the personRoleCode attribute.
271: *
272: * @param personRoleCode The personRoleCode to set.
273: */
274: public void setPersonRoleCode(String personRoleCode) {
275: this .personRoleCode = personRoleCode;
276: }
277:
278: /**
279: * Gets the personPrefixText attribute.
280: *
281: * @return Returns the personPrefixText
282: */
283: public String getPersonPrefixText() {
284: return personPrefixText;
285: }
286:
287: /**
288: * Sets the personPrefixText attribute.
289: *
290: * @param personPrefixText The personPrefixText to set.
291: */
292: public void setPersonPrefixText(String personPrefixText) {
293: this .personPrefixText = personPrefixText;
294: }
295:
296: /**
297: * Gets the personSuffixText attribute.
298: *
299: * @return Returns the personSuffixText
300: */
301: public String getPersonSuffixText() {
302: return personSuffixText;
303: }
304:
305: /**
306: * Sets the personSuffixText attribute.
307: *
308: * @param personSuffixText The personSuffixText to set.
309: */
310: public void setPersonSuffixText(String personSuffixText) {
311: this .personSuffixText = personSuffixText;
312: }
313:
314: /**
315: * Gets the personPositionTitle attribute.
316: *
317: * @return Returns the personPositionTitle
318: */
319: public String getPersonPositionTitle() {
320: return personPositionTitle;
321: }
322:
323: /**
324: * Sets the personPositionTitle attribute.
325: *
326: * @param personPositionTitle The personPositionTitle to set.
327: */
328: public void setPersonPositionTitle(String personPositionTitle) {
329: this .personPositionTitle = personPositionTitle;
330: }
331:
332: /**
333: * Gets the personDivisionText attribute.
334: *
335: * @return Returns the personDivisionText
336: */
337: public String getPersonDivisionText() {
338: return personDivisionText;
339: }
340:
341: /**
342: * Sets the personDivisionText attribute.
343: *
344: * @param personDivisionText The personDivisionText to set.
345: */
346: public void setPersonDivisionText(String personDivisionText) {
347: this .personDivisionText = personDivisionText;
348: }
349:
350: /**
351: * Gets the personLine1Address attribute.
352: *
353: * @return Returns the personLine1Address
354: */
355: public String getPersonLine1Address() {
356: return personLine1Address;
357: }
358:
359: /**
360: * Sets the personLine1Address attribute.
361: *
362: * @param personLine1Address The personLine1Address to set.
363: */
364: public void setPersonLine1Address(String personLine1Address) {
365: this .personLine1Address = personLine1Address;
366: }
367:
368: /**
369: * Gets the personLine2Address attribute.
370: *
371: * @return Returns the personLine2Address
372: */
373: public String getPersonLine2Address() {
374: return personLine2Address;
375: }
376:
377: /**
378: * Sets the personLine2Address attribute.
379: *
380: * @param personLine2Address The personLine2Address to set.
381: */
382: public void setPersonLine2Address(String personLine2Address) {
383: this .personLine2Address = personLine2Address;
384: }
385:
386: /**
387: * Gets the personCityName attribute.
388: *
389: * @return Returns the personCityName
390: */
391: public String getPersonCityName() {
392: return personCityName;
393: }
394:
395: /**
396: * Sets the personCityName attribute.
397: *
398: * @param personCityName The personCityName to set.
399: */
400: public void setPersonCityName(String personCityName) {
401: this .personCityName = personCityName;
402: }
403:
404: /**
405: * Gets the personCountyName attribute.
406: *
407: * @return Returns the personCountyName
408: */
409: public String getPersonCountyName() {
410: return personCountyName;
411: }
412:
413: /**
414: * Sets the personCountyName attribute.
415: *
416: * @param personCountyName The personCountyName to set.
417: */
418: public void setPersonCountyName(String personCountyName) {
419: this .personCountyName = personCountyName;
420: }
421:
422: /**
423: * Gets the personStateCode attribute.
424: *
425: * @return Returns the personStateCode
426: */
427: public String getPersonStateCode() {
428: return personStateCode;
429: }
430:
431: /**
432: * Sets the personStateCode attribute.
433: *
434: * @param personStateCode The personStateCode to set.
435: */
436: public void setPersonStateCode(String personStateCode) {
437: this .personStateCode = personStateCode;
438: }
439:
440: /**
441: * Gets the personCountryCode attribute.
442: *
443: * @return Returns the personCountryCode
444: */
445: public String getPersonCountryCode() {
446: return personCountryCode;
447: }
448:
449: /**
450: * Sets the personCountryCode attribute.
451: *
452: * @param personCountryCode The personCountryCode to set.
453: */
454: public void setPersonCountryCode(String personCountryCode) {
455: this .personCountryCode = personCountryCode;
456: }
457:
458: /**
459: * Gets the personZipCode attribute.
460: *
461: * @return Returns the personZipCode
462: */
463: public String getPersonZipCode() {
464: return personZipCode;
465: }
466:
467: /**
468: * Sets the personZipCode attribute.
469: *
470: * @param personZipCode The personZipCode to set.
471: */
472: public void setPersonZipCode(String personZipCode) {
473: this .personZipCode = personZipCode;
474: }
475:
476: /**
477: * Gets the personPhoneNumber attribute.
478: *
479: * @return Returns the personPhoneNumber
480: */
481: public String getPersonPhoneNumber() {
482: return personPhoneNumber;
483: }
484:
485: /**
486: * Sets the personPhoneNumber attribute.
487: *
488: * @param personPhoneNumber The personPhoneNumber to set.
489: */
490: public void setPersonPhoneNumber(String personPhoneNumber) {
491: this .personPhoneNumber = personPhoneNumber;
492: }
493:
494: /**
495: * Gets the personFaxNumber attribute.
496: *
497: * @return Returns the personFaxNumber
498: */
499: public String getPersonFaxNumber() {
500: return personFaxNumber;
501: }
502:
503: /**
504: * Sets the personFaxNumber attribute.
505: *
506: * @param personFaxNumber The personFaxNumber to set.
507: */
508: public void setPersonFaxNumber(String personFaxNumber) {
509: this .personFaxNumber = personFaxNumber;
510: }
511:
512: /**
513: * Gets the personEmailAddress attribute.
514: *
515: * @return Returns the personEmailAddress
516: */
517: public String getPersonEmailAddress() {
518: return personEmailAddress;
519: }
520:
521: /**
522: * Sets the personEmailAddress attribute.
523: *
524: * @param personEmailAddress The personEmailAddress to set.
525: */
526: public void setPersonEmailAddress(String personEmailAddress) {
527: this .personEmailAddress = personEmailAddress;
528: }
529:
530: /**
531: * Gets the organization attribute.
532: *
533: * @return Returns the organization
534: */
535: public Org getOrganization() {
536: return organization;
537: }
538:
539: /**
540: * Sets the organization attribute.
541: *
542: * @param organization The organization to set.
543: * @deprecated
544: */
545: public void setOrganization(Org organization) {
546: this .organization = organization;
547: }
548:
549: /**
550: * Gets the chartOfAccounts attribute.
551: *
552: * @return Returns the chartOfAccounts
553: */
554: public Chart getChartOfAccounts() {
555: return chartOfAccounts;
556: }
557:
558: /**
559: * Sets the chartOfAccounts attribute.
560: *
561: * @param chartOfAccounts The chartOfAccounts to set.
562: * @deprecated
563: */
564: public void setChartOfAccounts(Chart chartOfAccounts) {
565: this .chartOfAccounts = chartOfAccounts;
566: }
567:
568: /**
569: * Gets the personCountry attribute.
570: *
571: * @return Returns the personCountry.
572: */
573: public Country getPersonCountry() {
574: return personCountry;
575: }
576:
577: /**
578: * Sets the personCountry attribute value.
579: *
580: * @param personCountry The personCountry to set.
581: * @deprecated
582: */
583: public void setPersonCountry(Country personCountry) {
584: this .personCountry = personCountry;
585: }
586:
587: /**
588: * Gets the personState attribute.
589: *
590: * @return Returns the personState.
591: */
592: public State getPersonState() {
593: return personState;
594: }
595:
596: /**
597: * Sets the personState attribute value.
598: *
599: * @param personState The personState to set.
600: * @deprecated
601: */
602: public void setPersonState(State personState) {
603: this .personState = personState;
604: }
605:
606: /**
607: * Gets the personZip attribute.
608: *
609: * @return Returns the personZip.
610: */
611: public PostalZipCode getPersonZip() {
612: return personZip;
613: }
614:
615: /**
616: * Sets the personZip attribute value.
617: *
618: * @param personZip The personZip to set.
619: * @deprecated
620: */
621: public void setPersonZip(PostalZipCode personZip) {
622: this .personZip = personZip;
623: }
624:
625: /**
626: * Gets the personRole attribute.
627: *
628: * @return Returns the personRole.
629: */
630: public PersonRole getPersonRole() {
631: return personRole;
632: }
633:
634: /**
635: * Sets the personRole attribute value.
636: *
637: * @param personRole The personRole to set.
638: * @deprecated
639: */
640: public void setPersonRole(PersonRole personRole) {
641: this .personRole = personRole;
642: }
643:
644: //
645: // /**
646: // * Gets the routingFormDocument attribute.
647: // * @return Returns the routingFormDocument.
648: // */
649: // public RoutingFormDocument getRoutingFormDocument() {
650: // return routingFormDocument;
651: // }
652: //
653: // /**
654: // * Sets the routingFormDocument attribute value.
655: // * @param routingFormDocument The routingFormDocument to set.
656: // * @deprecated
657: // */
658: // public void setRoutingFormDocument(RoutingFormDocument routingFormDocument) {
659: // this.routingFormDocument = routingFormDocument;
660: // }
661: //
662: /**
663: * Gets the user attribute.
664: *
665: * @return Returns the user.
666: */
667: public UniversalUser getUser() {
668: user = SpringContext.getBean(UniversalUserService.class)
669: .updateUniversalUserIfNecessary(
670: personUniversalIdentifier, user);
671: return user;
672: }
673:
674: /**
675: * Sets the user attribute value.
676: *
677: * @param user The user to set.
678: * @deprecated Should not be set. User should be retrieved by SpringContext each time. See getUser() above.
679: */
680: public void setUser(UniversalUser user) {
681: this .user = user;
682: }
683:
684: /**
685: * Gets the personRoleText attribute.
686: *
687: * @return Returns the personRoleText.
688: */
689: public String getPersonRoleText() {
690: return personRoleText;
691: }
692:
693: /**
694: * Sets the personRoleText attribute value.
695: *
696: * @param personRoleText The personRoleText to set.
697: */
698: public void setPersonRoleText(String personRoleText) {
699: this .personRoleText = personRoleText;
700: }
701:
702: /**
703: * Gets the personToBeNamedIndicator attribute.
704: *
705: * @return Returns the personToBeNamedIndicator.
706: */
707: public boolean isPersonToBeNamedIndicator() {
708: return personToBeNamedIndicator;
709: }
710:
711: /**
712: * Sets the personToBeNamedIndicator attribute value.
713: *
714: * @param personToBeNamedIndicator The personToBeNamedIndicator to set.
715: */
716: public void setPersonToBeNamedIndicator(
717: boolean personToBeNamedIndicator) {
718: this .personToBeNamedIndicator = personToBeNamedIndicator;
719: }
720:
721: /**
722: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
723: */
724: protected LinkedHashMap toStringMapper() {
725: LinkedHashMap m = new LinkedHashMap();
726: if (this .personUniversalIdentifier != null) {
727: m.put("personUniversalIdentifier",
728: this .personUniversalIdentifier.toString());
729: }
730: m.put("documentNumber", this .documentNumber);
731: return m;
732: }
733:
734: public boolean isProjectDirector() {
735: final String PERSON_ROLE_CODE_PD = SpringContext.getBean(
736: ParameterService.class).getParameterValue(
737: RoutingFormDocument.class,
738: KraConstants.PERSON_ROLE_CODE_PROJECT_DIRECTOR);
739:
740: return PERSON_ROLE_CODE_PD.equals(this .getPersonRoleCode());
741: }
742:
743: public boolean isContactPerson() {
744: final String PERSON_ROLE_CODE_CP = SpringContext.getBean(
745: ParameterService.class).getParameterValue(
746: RoutingFormDocument.class,
747: KraConstants.PERSON_ROLE_CODE_CONTACT_PERSON);
748:
749: return PERSON_ROLE_CODE_CP.equals(this.getPersonRoleCode());
750: }
751: }
|