View Javadoc
1   /*
2    * Copyright 2006 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.kuali.ole.module.cg.businessobject;
18  
19  import java.util.LinkedHashMap;
20  
21  import org.kuali.ole.sys.OLEConstants;
22  import org.kuali.ole.sys.context.SpringContext;
23  import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
24  import org.kuali.rice.kim.api.identity.Person;
25  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
26  import org.kuali.rice.krad.util.ObjectUtils;
27  
28  /**
29   * Represents a relationship between a {@link Proposal} and a {@link ProjectDirector}.
30   */
31  public class ProposalProjectDirector extends PersistableBusinessObjectBase implements Primaryable, CGProjectDirector, MutableInactivatable {
32  
33      private String principalId;
34      private Long proposalNumber;
35      private boolean proposalPrimaryProjectDirectorIndicator;
36      private String proposalProjectDirectorProjectTitle;
37      private boolean active = true;
38  
39      private Person projectDirector;
40  
41  
42      private final String userLookupRoleNamespaceCode = OLEConstants.ParameterNamespaces.OLE;
43      private final String userLookupRoleName = OLEConstants.SysKimApiConstants.CONTRACTS_AND_GRANTS_PROJECT_DIRECTOR;
44  
45      /**
46       * Default constructor.
47       */
48      public ProposalProjectDirector() {
49      }
50  
51      /**
52       * @see org.kuali.ole.module.cg.businessobject.CGProjectDirector#getPrincipalId()
53       */
54      @Override
55      public String getPrincipalId() {
56          return principalId;
57      }
58  
59      /**
60       * @see org.kuali.ole.module.cg.businessobject.CGProjectDirector#setPrincipalId(java.lang.String)
61       */
62      @Override
63      public void setPrincipalId(String principalId) {
64          this.principalId = principalId;
65      }
66  
67      /**
68       * @see org.kuali.ole.module.cg.businessobject.CGProjectDirector#getProposalNumber()
69       */
70      @Override
71      public Long getProposalNumber() {
72          return proposalNumber;
73      }
74  
75      /**
76       * @see org.kuali.ole.module.cg.businessobject.CGProjectDirector#setProposalNumber(java.lang.Long)
77       */
78      @Override
79      public void setProposalNumber(Long proposalNumber) {
80          this.proposalNumber = proposalNumber;
81      }
82  
83  
84      /**
85       * Gets the proposalPrimaryProjectDirectorIndicator attribute.
86       *
87       * @return Returns the proposalPrimaryProjectDirectorIndicator
88       */
89      public boolean isProposalPrimaryProjectDirectorIndicator() {
90          return proposalPrimaryProjectDirectorIndicator;
91      }
92  
93      /**
94       * @see Primaryable#isPrimary()
95       */
96      @Override
97      public boolean isPrimary() {
98          return isProposalPrimaryProjectDirectorIndicator();
99      }
100 
101     /**
102      * Sets the proposalPrimaryProjectDirectorIndicator attribute.
103      *
104      * @param proposalPrimaryProjectDirectorIndicator The proposalPrimaryProjectDirectorIndicator to set.
105      */
106     public void setProposalPrimaryProjectDirectorIndicator(boolean proposalPrimaryProjectDirectorIndicator) {
107         this.proposalPrimaryProjectDirectorIndicator = proposalPrimaryProjectDirectorIndicator;
108     }
109 
110 
111     /**
112      * Gets the proposalProjectDirectorProjectTitle attribute.
113      *
114      * @return Returns the proposalProjectDirectorProjectTitle
115      */
116     public String getProposalProjectDirectorProjectTitle() {
117         return proposalProjectDirectorProjectTitle;
118     }
119 
120     /**
121      * Sets the proposalProjectDirectorProjectTitle attribute.
122      *
123      * @param proposalProjectDirectorProjectTitle The proposalProjectDirectorProjectTitle to set.
124      */
125     public void setProposalProjectDirectorProjectTitle(String proposalProjectDirectorProjectTitle) {
126         this.proposalProjectDirectorProjectTitle = proposalProjectDirectorProjectTitle;
127     }
128 
129     /**
130      * Gets the active attribute.
131      *
132      * @return Returns the active.
133      */
134     @Override
135     public boolean isActive() {
136         return active;
137     }
138 
139     /**
140      * Sets the active attribute value.
141      *
142      * @param active The active to set.
143      */
144     @Override
145     public void setActive(boolean active) {
146         this.active = active;
147     }
148 
149     /**
150      * @see org.kuali.ole.module.cg.businessobject.CGProjectDirector#getProjectDirector()
151      */
152     @Override
153     public Person getProjectDirector() {
154         if (principalId != null) {
155             projectDirector = SpringContext.getBean(org.kuali.rice.kim.api.identity.PersonService.class).updatePersonIfNecessary(principalId, projectDirector);
156         }
157         return projectDirector;
158     }
159 
160     /**
161      * @see org.kuali.ole.module.cg.businessobject.CGProjectDirector#setProjectDirector(org.kuali.ole.module.cg.businessobject.ProjectDirector)
162      */
163     @Override
164     public void setProjectDirector(Person projectDirector) {
165         this.projectDirector = projectDirector;
166     }
167 
168     /**
169      * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
170      */
171     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
172         LinkedHashMap m = new LinkedHashMap();
173         m.put("principalId", this.principalId);
174         if (this.proposalNumber != null) {
175             m.put("proposalNumber", this.proposalNumber.toString());
176         }
177         return m;
178     }
179 
180     /**
181      * This can be displayed by Proposal.xml lookup results.
182      *
183      * @see Object#toString()
184      */
185     @Override
186     public String toString() {
187         // todo: get "nonexistent", "primary", and "secondary" from ApplicationResources.properties via OLEKeyConstants?
188         String name = ObjectUtils.isNull(getProjectDirector()) ? "nonexistent" : getProjectDirector().getName();
189         String title = getProposalProjectDirectorProjectTitle() == null ? "" : " " + getProposalProjectDirectorProjectTitle();
190         return name + " " + (isProposalPrimaryProjectDirectorIndicator() ? "primary" : "secondary") + title;
191     }
192 
193     /**
194      * Gets the userLookupRoleNamespaceCode attribute.
195      * @return Returns the userLookupRoleNamespaceCode.
196      */
197     public String getUserLookupRoleNamespaceCode() {
198         return userLookupRoleNamespaceCode;
199     }
200 
201     /**
202      * Gets the userLookupRoleName attribute.
203      * @return Returns the userLookupRoleName.
204      */
205     public String getUserLookupRoleName() {
206         return userLookupRoleName;
207     }
208 }
209