001/** 002 * Copyright 2005-2016 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 */ 016package org.kuali.rice.kim.web.struts.form; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.rice.core.web.format.DateDisplayTimestampObjectFormatter; 020import org.kuali.rice.kim.bo.ui.PersonDocumentAddress; 021import org.kuali.rice.kim.bo.ui.PersonDocumentAffiliation; 022import org.kuali.rice.kim.bo.ui.PersonDocumentCitizenship; 023import org.kuali.rice.kim.bo.ui.PersonDocumentEmail; 024import org.kuali.rice.kim.bo.ui.PersonDocumentEmploymentInfo; 025import org.kuali.rice.kim.bo.ui.PersonDocumentGroup; 026import org.kuali.rice.kim.bo.ui.PersonDocumentName; 027import org.kuali.rice.kim.bo.ui.PersonDocumentPhone; 028import org.kuali.rice.kim.bo.ui.PersonDocumentRole; 029import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMember; 030import org.kuali.rice.kim.document.IdentityManagementPersonDocument; 031import org.kuali.rice.krad.util.GlobalVariables; 032 033/** 034 * This is a description of what this class does - shyu don't forget to fill this in. 035 * 036 * @author Kuali Rice Team (rice.collab@kuali.org) 037 * 038 */ 039public class IdentityManagementPersonDocumentForm extends IdentityManagementDocumentFormBase { 040 041 { 042 requiredNonEditableProperties.add("methodToCall"); 043 } 044 045 protected static final long serialVersionUID = -4787045391777666988L; 046 protected String principalId; 047 protected PersonDocumentAffiliation newAffln; 048 protected PersonDocumentEmploymentInfo newEmpInfo; 049 protected PersonDocumentCitizenship newCitizenship; 050 protected PersonDocumentName newName; 051 protected PersonDocumentAddress newAddress; 052 protected PersonDocumentPhone newPhone; 053 protected PersonDocumentEmail newEmail; 054 protected PersonDocumentGroup newGroup; 055 protected PersonDocumentRole newRole; 056 protected RoleDocumentDelegationMember newDelegationMember = new RoleDocumentDelegationMember(); 057 protected String newDelegationMemberRoleId = null; 058 protected boolean delegationMemberLookup = false; 059 protected boolean canModifyEntity = false; 060 protected boolean canOverrideEntityPrivacyPreferences = false; 061 protected boolean userSameAsPersonEdited = false; 062 063 /** 064 * @return the canModifyEntity 065 */ 066 public boolean isCanModifyEntity() { 067 return this.canModifyEntity; 068 } 069 070 /** 071 * @param canModifyEntity the canModifyEntity to set 072 */ 073 public void setCanModifyEntity(boolean canModifyEntity) { 074 this.canModifyEntity = canModifyEntity; 075 } 076 077 public IdentityManagementPersonDocumentForm() { 078 super(); 079 //this.registerEditableProperty("methodToCall.approve.x"); 080 this.setNewAffln(new PersonDocumentAffiliation()); 081 this.setNewAddress(new PersonDocumentAddress()); 082 this.setNewEmpInfo(new PersonDocumentEmploymentInfo()); 083 this.setNewName(new PersonDocumentName()); 084 this.setNewPhone(new PersonDocumentPhone()); 085 this.setNewEmail(new PersonDocumentEmail()); 086 this.setNewGroup(new PersonDocumentGroup()); 087 this.setNewRole(new PersonDocumentRole()); 088 this.setNewDelegationMember(new RoleDocumentDelegationMember()); 089 setFormatterType("document.groups.activeFromDate", DateDisplayTimestampObjectFormatter.class); 090 setFormatterType("document.groups.activeToDate", DateDisplayTimestampObjectFormatter.class); 091 } 092 093 @Override 094 public String getDefaultDocumentTypeName(){ 095 return "IdentityManagementPersonDocument"; 096 } 097 098 public IdentityManagementPersonDocument getPersonDocument() { 099 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}