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.module.cg.bo;
018:
019: import java.util.LinkedHashMap;
020:
021: import org.kuali.core.bo.Inactivateable;
022: import org.kuali.core.bo.PersistableBusinessObjectBase;
023: import org.kuali.core.bo.user.UniversalUser;
024: import org.kuali.core.exceptions.UserNotFoundException;
025: import org.kuali.core.service.UniversalUserService;
026: import org.kuali.kfs.context.SpringContext;
027:
028: /**
029: *
030: */
031: public class ProjectDirector extends PersistableBusinessObjectBase
032: implements Inactivateable {
033:
034: private static final long serialVersionUID = -8864103362445919041L;
035: private String personUniversalIdentifier;
036: private String personUserIdentifier; // secondary key from user input, not persisted but takes priority over primary key.
037: private UniversalUser universalUser;
038: private boolean active;
039:
040: /**
041: * Default no-arg constructor.
042: */
043: public ProjectDirector() {
044: }
045:
046: /**
047: * @return the {@link UniversalUser} to which the project director refers.
048: */
049: public UniversalUser getUniversalUser() {
050: // If personUserIdentifier is not set, then fall back to personUniversalIdentifier.
051: if (personUserIdentifier == null) {
052: universalUser = SpringContext.getBean(
053: UniversalUserService.class)
054: .updateUniversalUserIfNecessary(
055: personUniversalIdentifier, universalUser);
056: }
057: return universalUser;
058: }
059:
060: /**
061: * Sets the personUniversal attribute.
062: *
063: * @param personUniversal The personUniversal to set.
064: * @deprecated
065: */
066: public void setUniversalUser(UniversalUser user) {
067: this .universalUser = user;
068: }
069:
070: /**
071: * Gets the personUniversalIdentifier attribute.
072: *
073: * @return Returns the personUniversalIdentifier.
074: */
075: public String getPersonUniversalIdentifier() {
076: return personUniversalIdentifier;
077: }
078:
079: /**
080: * Sets the personUniversalIdentifier attribute value.
081: *
082: * @param personUniversalIdentifier The personUniversalIdentifier to set.
083: */
084: public void setPersonUniversalIdentifier(
085: String personUniversalIdentifier) {
086: this .personUniversalIdentifier = personUniversalIdentifier;
087: }
088:
089: /**
090: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
091: */
092: protected LinkedHashMap toStringMapper() {
093: LinkedHashMap m = new LinkedHashMap();
094: m.put("universalUser.getUniversalIdentifier", this
095: .getPersonUniversalIdentifier());
096: return m;
097: }
098:
099: /**
100: * @return the person name
101: */
102: public String getPersonName() {
103: UniversalUser u = getUniversalUser();
104: return u == null ? "" : u.getPersonName();
105: }
106:
107: /**
108: * @param personName the person name.
109: */
110: public void setPersonName(String personName) {
111: if (universalUser == null) {
112: universalUser = new UniversalUser();
113: }
114: universalUser.setPersonName(personName);
115: }
116:
117: /**
118: * @return the persons first name
119: */
120: public String getPersonFirstName() {
121: UniversalUser u = getUniversalUser();
122: return u == null ? "" : u.getPersonFirstName();
123: }
124:
125: /**
126: * @param personFirstName the persons first name
127: */
128: public void setPersonFirstName(String personFirstName) {
129: if (universalUser == null) {
130: universalUser = new UniversalUser();
131: }
132: universalUser.setPersonFirstName(personFirstName);
133: }
134:
135: /**
136: * @return the persons last name
137: */
138: public String getPersonLastName() {
139: UniversalUser u = getUniversalUser();
140: return u == null ? "" : u.getPersonLastName();
141: }
142:
143: /**
144: * @param personLastName the persons last name
145: */
146: public void setPersonLastName(String personLastName) {
147: if (universalUser == null) {
148: universalUser = new UniversalUser();
149: }
150: universalUser.setPersonName(personLastName);
151: }
152:
153: /**
154: * @return the userID for the person.
155: */
156: public String getPersonUserIdentifier() {
157: if (personUserIdentifier != null) {
158: return personUserIdentifier;
159: }
160: UniversalUser u = getUniversalUser();
161: return u == null ? "" : u.getPersonUserIdentifier();
162: }
163:
164: /**
165: * @param personUserIdentifier the userID for the person.
166: */
167: public void setPersonUserIdentifier(String personUserIdentifier) {
168: this .personUserIdentifier = personUserIdentifier;
169: if (universalUser == null
170: || !personUserIdentifier.equals(universalUser
171: .getPersonUserIdentifier())) {
172: try {
173: universalUser = SpringContext.getBean(
174: UniversalUserService.class)
175: .getUniversalUserByAuthenticationUserId(
176: personUserIdentifier);
177: } catch (UserNotFoundException ex) {
178: universalUser = null;
179: }
180: }
181: }
182:
183: /**
184: * @return the primary DepartmentCodee
185: */
186: public String getPrimaryDepartmentCode() {
187: UniversalUser u = getUniversalUser();
188: return u == null ? "" : u.getPrimaryDepartmentCode();
189: }
190:
191: /**
192: * @param personName the primary DepartmentCode.
193: */
194: public void setPrimaryDepartmentCode(String primaryDepartmentCode) {
195: if (universalUser == null) {
196: universalUser = new UniversalUser();
197: }
198: universalUser.setPrimaryDepartmentCode(primaryDepartmentCode);
199: }
200:
201: /**
202: * @see org.kuali.core.bo.Inactivateable#isActive()
203: */
204: public boolean isActive() {
205: return active;
206: }
207:
208: /**
209: * @see org.kuali.core.bo.Inactivateable#setActive(boolean)
210: */
211: public void setActive(boolean active) {
212: this.active = active;
213: }
214:
215: }
|