View Javadoc
1   /**
2    * Copyright 2005-2015 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  package org.kuali.rice.kim.web.struts.form;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.core.web.format.DateDisplayTimestampObjectFormatter;
20  import org.kuali.rice.kim.bo.ui.PersonDocumentAddress;
21  import org.kuali.rice.kim.bo.ui.PersonDocumentAffiliation;
22  import org.kuali.rice.kim.bo.ui.PersonDocumentCitizenship;
23  import org.kuali.rice.kim.bo.ui.PersonDocumentEmail;
24  import org.kuali.rice.kim.bo.ui.PersonDocumentEmploymentInfo;
25  import org.kuali.rice.kim.bo.ui.PersonDocumentGroup;
26  import org.kuali.rice.kim.bo.ui.PersonDocumentName;
27  import org.kuali.rice.kim.bo.ui.PersonDocumentPhone;
28  import org.kuali.rice.kim.bo.ui.PersonDocumentRole;
29  import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMember;
30  import org.kuali.rice.kim.document.IdentityManagementPersonDocument;
31  import org.kuali.rice.krad.util.GlobalVariables;
32  
33  /**
34   * This is a description of what this class does - shyu don't forget to fill this in. 
35   * 
36   * @author Kuali Rice Team (rice.collab@kuali.org)
37   *
38   */
39  public class IdentityManagementPersonDocumentForm extends IdentityManagementDocumentFormBase {
40  
41  	{
42  		requiredNonEditableProperties.add("methodToCall");
43  	}
44  
45      protected static final long serialVersionUID = -4787045391777666988L;
46      protected String principalId;
47      protected PersonDocumentAffiliation newAffln;
48      protected PersonDocumentEmploymentInfo newEmpInfo;
49      protected PersonDocumentCitizenship newCitizenship;
50      protected PersonDocumentName newName;
51      protected PersonDocumentAddress newAddress;
52      protected PersonDocumentPhone newPhone;
53      protected PersonDocumentEmail newEmail;
54      protected PersonDocumentGroup newGroup;
55      protected PersonDocumentRole newRole;
56      protected RoleDocumentDelegationMember newDelegationMember = new RoleDocumentDelegationMember();
57      protected String newDelegationMemberRoleId = null;
58      protected boolean delegationMemberLookup = false;
59      protected boolean canModifyEntity = false;
60      protected boolean canOverrideEntityPrivacyPreferences = false;
61      protected boolean userSameAsPersonEdited = false;
62      
63  	/**
64  	 * @return the canModifyEntity
65  	 */
66  	public boolean isCanModifyEntity() {
67  		return this.canModifyEntity;
68  	}
69  
70  	/**
71  	 * @param canModifyEntity the canModifyEntity to set
72  	 */
73  	public void setCanModifyEntity(boolean canModifyEntity) {
74  		this.canModifyEntity = canModifyEntity;
75  	}
76  
77  	public IdentityManagementPersonDocumentForm() {
78          super();
79          //this.registerEditableProperty("methodToCall.approve.x");
80          this.setNewAffln(new PersonDocumentAffiliation());
81          this.setNewAddress(new PersonDocumentAddress());
82          this.setNewEmpInfo(new PersonDocumentEmploymentInfo());
83          this.setNewName(new PersonDocumentName());
84          this.setNewPhone(new PersonDocumentPhone());
85          this.setNewEmail(new PersonDocumentEmail());
86          this.setNewGroup(new PersonDocumentGroup());
87          this.setNewRole(new PersonDocumentRole());
88          this.setNewDelegationMember(new RoleDocumentDelegationMember());
89          setFormatterType("document.groups.activeFromDate", DateDisplayTimestampObjectFormatter.class);
90          setFormatterType("document.groups.activeToDate", DateDisplayTimestampObjectFormatter.class);
91      }
92  
93  	@Override
94  	public String getDefaultDocumentTypeName(){
95  		return "IdentityManagementPersonDocument";
96  	}
97  	
98  	public IdentityManagementPersonDocument getPersonDocument() {
99          return (IdentityManagementPersonDocument) this.getDocument();
100     }
101 
102 	public PersonDocumentAffiliation getNewAffln() {
103 		return this.newAffln;
104 	}
105 
106 	public void setNewAffln(PersonDocumentAffiliation newAffln) {
107 		this.newAffln = newAffln;
108 	}
109 
110 	public PersonDocumentEmploymentInfo getNewEmpInfo() {
111 		return this.newEmpInfo;
112 	}
113 
114 	public void setNewEmpInfo(PersonDocumentEmploymentInfo newEmpInfo) {
115 		this.newEmpInfo = newEmpInfo;
116 	}
117 
118 	public PersonDocumentCitizenship getNewCitizenship() {
119 		return this.newCitizenship;
120 	}
121 
122 	public void setNewCitizenship(PersonDocumentCitizenship newCitizenship) {
123 		this.newCitizenship = newCitizenship;
124 	}
125 
126 	public PersonDocumentName getNewName() {
127 		return this.newName;
128 	}
129 
130 	public void setNewName(PersonDocumentName newName) {
131 		this.newName = newName;
132 	}
133 
134 	public PersonDocumentAddress getNewAddress() {
135 		return this.newAddress;
136 	}
137 
138 	public void setNewAddress(PersonDocumentAddress newAddress) {
139 		this.newAddress = newAddress;
140 	}
141 
142 	public PersonDocumentPhone getNewPhone() {
143 		return this.newPhone;
144 	}
145 
146 	public void setNewPhone(PersonDocumentPhone newPhone) {
147 		this.newPhone = newPhone;
148 	}
149 
150 	public PersonDocumentEmail getNewEmail() {
151 		return this.newEmail;
152 	}
153 
154 	public void setNewEmail(PersonDocumentEmail newEmail) {
155 		this.newEmail = newEmail;
156 	}
157 
158 	public PersonDocumentGroup getNewGroup() {
159 		return this.newGroup;
160 	}
161 
162 	public void setNewGroup(PersonDocumentGroup newGroup) {
163 		this.newGroup = newGroup;
164 	}
165 
166 	public PersonDocumentRole getNewRole() {
167 		return this.newRole;
168 	}
169 
170 	public void setNewRole(PersonDocumentRole newRole) {
171 		this.newRole = newRole;
172 	}
173 
174 	public String getPrincipalId() {
175 		return this.principalId;
176 	}
177 
178 	public void setPrincipalId(String principalId) {
179 		this.principalId = principalId;
180 	}
181 
182 	/**
183 	 * @return the newDelegationMember
184 	 */
185 	public RoleDocumentDelegationMember getNewDelegationMember() {
186 		return this.newDelegationMember;
187 	}
188 
189 	/**
190 	 * @param newDelegationMember the newDelegationMember to set
191 	 */
192 	public void setNewDelegationMember(
193 			RoleDocumentDelegationMember newDelegationMember) {
194 		this.newDelegationMember = newDelegationMember;
195 	}
196 
197 	/**
198 	 * @return the delegationMemberLookup
199 	 */
200 	public boolean isDelegationMemberLookup() {
201 		return this.delegationMemberLookup;
202 	}
203 
204 	/**
205 	 * @param delegationMemberLookup the delegationMemberLookup to set
206 	 */
207 	public void setDelegationMemberLookup(boolean delegationMemberLookup) {
208 		this.delegationMemberLookup = delegationMemberLookup;
209 	}
210 
211 	/**
212 	 * @return the newDelegationMemberRoleId
213 	 */
214 	public String getNewDelegationMemberRoleId() {
215 		return this.newDelegationMemberRoleId;
216 	}
217 
218 	/**
219 	 * @param newDelegationMemberRoleId the newDelegationMemberRoleId to set
220 	 */
221 	public void setNewDelegationMemberRoleId(String newDelegationMemberRoleId) {
222 		this.newDelegationMemberRoleId = newDelegationMemberRoleId;
223 		if(StringUtils.isNotEmpty(newDelegationMemberRoleId)){
224 			newDelegationMember.getRoleBo().setId(newDelegationMemberRoleId);
225 		}
226 	}
227 
228 	/**
229 	 * @return the canOverrideEntityPrivacyPreferences
230 	 */
231 	public boolean isCanOverrideEntityPrivacyPreferences() {
232 		return this.canOverrideEntityPrivacyPreferences || isUserSameAsPersonEdited();
233 	}
234 
235 	/**
236 	 * @param canOverrideEntityPrivacyPreferences the canOverrideEntityPrivacyPreferences to set
237 	 */
238 	public void setCanOverrideEntityPrivacyPreferences(
239 			boolean canOverrideEntityPrivacyPreferences) {
240 		this.canOverrideEntityPrivacyPreferences = canOverrideEntityPrivacyPreferences;
241 	}
242 
243 	/**
244 	 * @return the userSameAsPersonEdited
245 	 */
246 	public boolean isUserSameAsPersonEdited() {
247 		if(StringUtils.isNotEmpty(getPrincipalId())){
248 			userSameAsPersonEdited = StringUtils.equals(GlobalVariables.getUserSession().getPrincipalId(), getPrincipalId());
249 		}
250 		return this.userSameAsPersonEdited;
251 	}
252 
253 	/**
254 	 * @param userSameAsPersonEdited the userSameAsPersonEdited to set
255 	 */
256 	public void setUserSameAsPersonEdited(boolean userSameAsPersonEdited) {
257 		this.userSameAsPersonEdited = userSameAsPersonEdited;
258 	}
259 
260 }