001/*
002 * Copyright 2006 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.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/ecl2.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
017package org.kuali.ole.module.cg.businessobject;
018
019import java.util.LinkedHashMap;
020
021import org.kuali.ole.sys.OLEConstants;
022import org.kuali.ole.sys.context.SpringContext;
023import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
024import org.kuali.rice.kim.api.identity.Person;
025import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
026
027/**
028 * This class represents an association between an award and a project director. It's like a reference to the project director from
029 * the award. This way an award can maintain a collection of these references instead of owning project directors directly.
030 */
031public class AwardProjectDirector extends PersistableBusinessObjectBase implements Primaryable, CGProjectDirector, MutableInactivatable {
032
033    private String principalId;
034    private Long proposalNumber;
035    private boolean awardPrimaryProjectDirectorIndicator;
036    private String awardProjectDirectorProjectTitle;
037    private boolean active = true;
038
039    private Person projectDirector;
040
041    private final String userLookupRoleNamespaceCode = OLEConstants.ParameterNamespaces.OLE;
042    private final String userLookupRoleName = OLEConstants.SysKimApiConstants.CONTRACTS_AND_GRANTS_PROJECT_DIRECTOR;
043
044    /**
045     * Default no-args constructor.
046     */
047    public AwardProjectDirector() {
048    }
049
050    /**
051     * @see org.kuali.ole.module.cg.businessobject.CGProjectDirector#getPrincipalId()
052     */
053    @Override
054    public String getPrincipalId() {
055        return principalId;
056    }
057
058    /**
059     * @see org.kuali.ole.module.cg.businessobject.CGProjectDirector#setPrincipalId(java.lang.String)
060     */
061    @Override
062    public void setPrincipalId(String principalId) {
063        this.principalId = principalId;
064    }
065
066
067    /**
068     * @see org.kuali.ole.module.cg.businessobject.CGProjectDirector#getProposalNumber()
069     */
070    @Override
071    public Long getProposalNumber() {
072        return proposalNumber;
073    }
074
075    /**
076     * @see org.kuali.ole.module.cg.businessobject.CGProjectDirector#setProposalNumber(java.lang.Long)
077     */
078    @Override
079    public void setProposalNumber(Long proposalNumber) {
080        this.proposalNumber = proposalNumber;
081    }
082
083
084    /**
085     * Gets the awardPrimaryProjectDirectorIndicator attribute.
086     *
087     * @return Returns the awardPrimaryProjectDirectorIndicator
088     */
089    public boolean isAwardPrimaryProjectDirectorIndicator() {
090        return awardPrimaryProjectDirectorIndicator;
091    }
092
093
094    /**
095     * Sets the awardPrimaryProjectDirectorIndicator attribute.
096     *
097     * @param awardPrimaryProjectDirectorIndicator The awardPrimaryProjectDirectorIndicator to set.
098     */
099    public void setAwardPrimaryProjectDirectorIndicator(boolean awardPrimaryProjectDirectorIndicator) {
100        this.awardPrimaryProjectDirectorIndicator = awardPrimaryProjectDirectorIndicator;
101    }
102
103
104    /**
105     * Gets the awardProjectDirectorProjectTitle attribute.
106     *
107     * @return Returns the awardProjectDirectorProjectTitle
108     */
109    public String getAwardProjectDirectorProjectTitle() {
110        return awardProjectDirectorProjectTitle;
111    }
112
113    /**
114     * Sets the awardProjectDirectorProjectTitle attribute.
115     *
116     * @param awardProjectDirectorProjectTitle The awardProjectDirectorProjectTitle to set.
117     */
118    public void setAwardProjectDirectorProjectTitle(String awardProjectDirectorProjectTitle) {
119        this.awardProjectDirectorProjectTitle = awardProjectDirectorProjectTitle;
120    }
121
122    /**
123     * @see org.kuali.ole.module.cg.businessobject.CGProjectDirector#getProjectDirector()
124     */
125    @Override
126    public Person getProjectDirector() {
127        projectDirector = SpringContext.getBean(org.kuali.rice.kim.api.identity.PersonService.class).updatePersonIfNecessary(principalId, projectDirector);
128        return projectDirector;
129    }
130
131    /**
132     * @see org.kuali.ole.module.cg.businessobject.CGProjectDirector#setProjectDirector(org.kuali.ole.module.cg.businessobject.ProjectDirector)
133     */
134    @Override
135    public void setProjectDirector(Person projectDirector) {
136        this.projectDirector = projectDirector;
137    }
138
139    /**
140     * @see Primaryable#isPrimary()
141     */
142    @Override
143    public boolean isPrimary() {
144        return isAwardPrimaryProjectDirectorIndicator();
145    }
146
147    /**
148     * @see org.kuali.rice.core.api.mo.common.active.MutableInactivatable#isActive()
149     */
150    @Override
151    public boolean isActive() {
152        return active;
153    }
154
155    /**
156     * @see org.kuali.rice.core.api.mo.common.active.MutableInactivatable#setActive(boolean)
157     */
158    @Override
159    public void setActive(boolean active) {
160        this.active = active;
161    }
162
163    public String getUserLookupRoleNamespaceCode() {
164        return userLookupRoleNamespaceCode;
165    }
166
167    public void setUserLookupRoleNamespaceCode(String userLookupRoleNamespaceCode) {
168    }
169
170    public String getUserLookupRoleName() {
171        return userLookupRoleName;
172    }
173
174    public void setUserLookupRoleName(String userLookupRoleName) {
175    }
176
177    /**
178     * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
179     */
180    @SuppressWarnings("unchecked")
181
182    protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
183        LinkedHashMap m = new LinkedHashMap();
184        m.put("principalId", this.principalId);
185        if (this.proposalNumber != null) {
186            m.put("proposalNumber", this.proposalNumber.toString());
187        }
188        return m;
189    }
190
191}
192