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:
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.util.ObjectUtils;
024:
025: /**
026: * Represents a relationship between a {@link Proposal} and a {@link ProjectDirector}.
027: */
028: public class ProposalProjectDirector extends
029: PersistableBusinessObjectBase implements Primaryable,
030: CGProjectDirector, Inactivateable {
031:
032: private String personUniversalIdentifier;
033: private Long proposalNumber;
034: private boolean proposalPrimaryProjectDirectorIndicator;
035: private String proposalProjectDirectorProjectTitle;
036: private boolean active = true;
037:
038: private ProjectDirector projectDirector;
039:
040: /**
041: * Default constructor.
042: */
043: public ProposalProjectDirector() {
044: // Struts needs this instance to populate the secondary key, personUserIdentifier.
045: projectDirector = new ProjectDirector();
046: }
047:
048: /**
049: * @see org.kuali.module.cg.bo.CGProjectDirector#getPersonUniversalIdentifier()
050: */
051: public String getPersonUniversalIdentifier() {
052: return personUniversalIdentifier;
053: }
054:
055: /**
056: * @see org.kuali.module.cg.bo.CGProjectDirector#setPersonUniversalIdentifier(java.lang.String)
057: */
058: public void setPersonUniversalIdentifier(
059: String personUniversalIdentifier) {
060: this .personUniversalIdentifier = personUniversalIdentifier;
061: if (projectDirector != null) {
062: projectDirector
063: .setPersonUniversalIdentifier(personUniversalIdentifier);
064: }
065: }
066:
067: /**
068: * @see org.kuali.module.cg.bo.CGProjectDirector#getProposalNumber()
069: */
070: public Long getProposalNumber() {
071: return proposalNumber;
072: }
073:
074: /**
075: * @see org.kuali.module.cg.bo.CGProjectDirector#setProposalNumber(java.lang.Long)
076: */
077: public void setProposalNumber(Long proposalNumber) {
078: this .proposalNumber = proposalNumber;
079: }
080:
081: /**
082: * Gets the proposalPrimaryProjectDirectorIndicator attribute.
083: *
084: * @return Returns the proposalPrimaryProjectDirectorIndicator
085: */
086: public boolean isProposalPrimaryProjectDirectorIndicator() {
087: return proposalPrimaryProjectDirectorIndicator;
088: }
089:
090: /**
091: * @see Primaryable#isPrimary()
092: */
093: public boolean isPrimary() {
094: return isProposalPrimaryProjectDirectorIndicator();
095: }
096:
097: /**
098: * Sets the proposalPrimaryProjectDirectorIndicator attribute.
099: *
100: * @param proposalPrimaryProjectDirectorIndicator The proposalPrimaryProjectDirectorIndicator to set.
101: */
102: public void setProposalPrimaryProjectDirectorIndicator(
103: boolean proposalPrimaryProjectDirectorIndicator) {
104: this .proposalPrimaryProjectDirectorIndicator = proposalPrimaryProjectDirectorIndicator;
105: }
106:
107: /**
108: * Gets the proposalProjectDirectorProjectTitle attribute.
109: *
110: * @return Returns the proposalProjectDirectorProjectTitle
111: */
112: public String getProposalProjectDirectorProjectTitle() {
113: return proposalProjectDirectorProjectTitle;
114: }
115:
116: /**
117: * Sets the proposalProjectDirectorProjectTitle attribute.
118: *
119: * @param proposalProjectDirectorProjectTitle The proposalProjectDirectorProjectTitle to set.
120: */
121: public void setProposalProjectDirectorProjectTitle(
122: String proposalProjectDirectorProjectTitle) {
123: this .proposalProjectDirectorProjectTitle = proposalProjectDirectorProjectTitle;
124: }
125:
126: /**
127: * Gets the active attribute.
128: *
129: * @return Returns the active.
130: */
131: public boolean isActive() {
132: return active;
133: }
134:
135: /**
136: * Sets the active attribute value.
137: *
138: * @param active The active to set.
139: */
140: public void setActive(boolean active) {
141: this .active = active;
142: }
143:
144: /**
145: * @see org.kuali.module.cg.bo.CGProjectDirector#getProjectDirector()
146: */
147: public ProjectDirector getProjectDirector() {
148: return projectDirector;
149: }
150:
151: /**
152: * @see org.kuali.module.cg.bo.CGProjectDirector#setProjectDirector(org.kuali.module.cg.bo.ProjectDirector)
153: */
154: public void setProjectDirector(ProjectDirector projectDirector) {
155: this .projectDirector = projectDirector;
156: }
157:
158: /**
159: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
160: */
161: protected LinkedHashMap toStringMapper() {
162: LinkedHashMap m = new LinkedHashMap();
163: m.put("personUniversalIdentifier",
164: this .personUniversalIdentifier);
165: if (this .proposalNumber != null) {
166: m.put("proposalNumber", this .proposalNumber.toString());
167: }
168: return m;
169: }
170:
171: /**
172: * This can be displayed by Proposal.xml lookup results.
173: *
174: * @see Object#toString()
175: */
176: @Override
177: public String toString() {
178: // todo: get "nonexistent", "primary", and "secondary" from ApplicationResources.properties via KFSKeyConstants?
179: String name = ObjectUtils.isNull(getProjectDirector()) ? "nonexistent"
180: : getProjectDirector().getPersonName();
181: String title = getProposalProjectDirectorProjectTitle() == null ? ""
182: : " " + getProposalProjectDirectorProjectTitle();
183: return name
184: + " "
185: + (isProposalPrimaryProjectDirectorIndicator() ? "primary"
186: : "secondary") + title;
187: }
188: }
|