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