| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kim.bo.entity.impl; |
| 17 | |
|
| 18 | |
import java.sql.Timestamp; |
| 19 | |
import java.util.ArrayList; |
| 20 | |
import java.util.LinkedHashMap; |
| 21 | |
|
| 22 | |
import javax.persistence.Column; |
| 23 | |
import javax.persistence.Entity; |
| 24 | |
import javax.persistence.Id; |
| 25 | |
import javax.persistence.PrePersist; |
| 26 | |
import javax.persistence.PreUpdate; |
| 27 | |
import javax.persistence.Table; |
| 28 | |
import javax.persistence.Transient; |
| 29 | |
|
| 30 | |
import org.apache.ojb.broker.PersistenceBroker; |
| 31 | |
import org.apache.ojb.broker.PersistenceBrokerException; |
| 32 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityAddressInfo; |
| 33 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityAffiliationInfo; |
| 34 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityDefaultInfo; |
| 35 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityEmailInfo; |
| 36 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityEmploymentInformationInfo; |
| 37 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityEntityTypeDefaultInfo; |
| 38 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityExternalIdentifierInfo; |
| 39 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityNameInfo; |
| 40 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityPhoneInfo; |
| 41 | |
import org.kuali.rice.kim.bo.entity.dto.KimPrincipalInfo; |
| 42 | |
import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; |
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
@Entity |
| 51 | |
@Table(name="KRIM_ENTITY_CACHE_T") |
| 52 | |
public class KimEntityDefaultInfoCacheImpl extends PersistableBusinessObjectBase { |
| 53 | |
|
| 54 | |
private static final long serialVersionUID = 1L; |
| 55 | |
|
| 56 | |
@Transient |
| 57 | |
protected Long versionNumber; |
| 58 | |
|
| 59 | |
|
| 60 | |
@Id |
| 61 | |
@Column(name="PRNCPL_ID") |
| 62 | |
protected String principalId; |
| 63 | |
@Column(name="PRNCPL_NM") |
| 64 | |
protected String principalName; |
| 65 | |
@Column(name="ENTITY_ID") |
| 66 | |
protected String entityId; |
| 67 | |
@Column(name="ENTITY_TYP_CD") |
| 68 | |
protected String entityTypeCode; |
| 69 | |
|
| 70 | |
|
| 71 | 0 | @Column(name="FIRST_NM") |
| 72 | |
protected String firstName = ""; |
| 73 | 0 | @Column(name="MIDDLE_NM") |
| 74 | |
protected String middleName = ""; |
| 75 | 0 | @Column(name="LAST_NM") |
| 76 | |
protected String lastName = ""; |
| 77 | 0 | @Column(name="PRSN_NM") |
| 78 | |
protected String name = ""; |
| 79 | |
|
| 80 | 0 | @Column(name="CAMPUS_CD") |
| 81 | |
protected String campusCode = ""; |
| 82 | |
|
| 83 | |
|
| 84 | 0 | @Column(name="PRMRY_DEPT_CD") |
| 85 | |
protected String primaryDepartmentCode = ""; |
| 86 | 0 | @Column(name="EMP_ID") |
| 87 | |
protected String employeeId = ""; |
| 88 | |
|
| 89 | |
@Column(name="LAST_UPDT_TS") |
| 90 | |
protected Timestamp lastUpdateTimestamp; |
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | 0 | public KimEntityDefaultInfoCacheImpl() { |
| 96 | 0 | } |
| 97 | |
|
| 98 | 0 | public KimEntityDefaultInfoCacheImpl( KimEntityDefaultInfo entity ) { |
| 99 | 0 | if ( entity != null ) { |
| 100 | 0 | entityId = entity.getEntityId(); |
| 101 | 0 | if ( entity.getPrincipals() != null && !entity.getPrincipals().isEmpty() ) { |
| 102 | 0 | principalId = entity.getPrincipals().get(0).getPrincipalId(); |
| 103 | 0 | principalName = entity.getPrincipals().get(0).getPrincipalName(); |
| 104 | |
} |
| 105 | 0 | if ( entity.getEntityTypes() != null && !entity.getEntityTypes().isEmpty() ) { |
| 106 | 0 | entityTypeCode = entity.getEntityTypes().get(0).getEntityTypeCode(); |
| 107 | |
} |
| 108 | 0 | if ( entity.getDefaultName() != null ) { |
| 109 | 0 | firstName = entity.getDefaultName().getFirstNameUnmasked(); |
| 110 | 0 | middleName = entity.getDefaultName().getMiddleNameUnmasked(); |
| 111 | 0 | lastName = entity.getDefaultName().getLastNameUnmasked(); |
| 112 | 0 | name = entity.getDefaultName().getFormattedNameUnmasked(); |
| 113 | |
} |
| 114 | 0 | if ( entity.getDefaultAffiliation() != null ) { |
| 115 | 0 | campusCode = entity.getDefaultAffiliation().getCampusCode(); |
| 116 | |
} |
| 117 | 0 | if ( entity.getPrimaryEmployment() != null ) { |
| 118 | 0 | primaryDepartmentCode = entity.getPrimaryEmployment().getPrimaryDepartmentCode(); |
| 119 | 0 | employeeId = entity.getPrimaryEmployment().getEmployeeId(); |
| 120 | |
} |
| 121 | |
} |
| 122 | 0 | } |
| 123 | |
|
| 124 | |
@SuppressWarnings("unchecked") |
| 125 | |
public KimEntityDefaultInfo convertCacheToEntityDefaultInfo() { |
| 126 | 0 | KimEntityDefaultInfo info = new KimEntityDefaultInfo(); |
| 127 | |
|
| 128 | |
|
| 129 | 0 | info.setEntityId( this.getEntityId() ); |
| 130 | 0 | info.setActive( this.isActive() ); |
| 131 | |
|
| 132 | |
|
| 133 | 0 | KimPrincipalInfo principalInfo = new KimPrincipalInfo(); |
| 134 | 0 | principalInfo.setEntityId(this.getEntityId() ); |
| 135 | 0 | principalInfo.setPrincipalId(this.getPrincipalId()); |
| 136 | 0 | principalInfo.setPrincipalName(this.getPrincipalName()); |
| 137 | 0 | principalInfo.setActive(this.isActive()); |
| 138 | 0 | info.setPrincipals( new ArrayList<KimPrincipalInfo>( 1 ) ); |
| 139 | 0 | ((ArrayList<KimPrincipalInfo>)info.getPrincipals()).add(principalInfo); |
| 140 | |
|
| 141 | |
|
| 142 | 0 | KimEntityNameInfo nameInfo = new KimEntityNameInfo(); |
| 143 | 0 | nameInfo.setFirstName( this.getFirstName() ); |
| 144 | 0 | nameInfo.setLastName( this.getLastName() ); |
| 145 | 0 | nameInfo.setMiddleName( this.getMiddleName() ); |
| 146 | 0 | info.setDefaultName(nameInfo); |
| 147 | |
|
| 148 | |
|
| 149 | 0 | ArrayList<KimEntityEntityTypeDefaultInfo> entityTypesInfo = new ArrayList<KimEntityEntityTypeDefaultInfo>( 1 ); |
| 150 | 0 | info.setEntityTypes( entityTypesInfo ); |
| 151 | 0 | KimEntityEntityTypeDefaultInfo entityTypeInfo = new KimEntityEntityTypeDefaultInfo(); |
| 152 | 0 | entityTypeInfo.setEntityTypeCode( this.getEntityTypeCode() ); |
| 153 | 0 | entityTypeInfo.setDefaultAddress( new KimEntityAddressInfo() ); |
| 154 | 0 | entityTypeInfo.setDefaultEmailAddress( new KimEntityEmailInfo() ); |
| 155 | |
|
| 156 | 0 | entityTypeInfo.setDefaultPhoneNumber( new KimEntityPhoneInfo() ); |
| 157 | 0 | entityTypesInfo.add(entityTypeInfo); |
| 158 | 0 | info.setEntityTypes(entityTypesInfo); |
| 159 | |
|
| 160 | |
|
| 161 | 0 | ArrayList<KimEntityAffiliationInfo> affInfo = new ArrayList<KimEntityAffiliationInfo>( 1 ); |
| 162 | 0 | info.setAffiliations( affInfo ); |
| 163 | 0 | KimEntityAffiliationInfo aff = new KimEntityAffiliationInfo(); |
| 164 | 0 | aff.setCampusCode(this.getCampusCode()); |
| 165 | 0 | aff.setDefault(true); |
| 166 | 0 | info.setDefaultAffiliation(aff); |
| 167 | 0 | info.setAffiliations(affInfo); |
| 168 | |
|
| 169 | |
|
| 170 | 0 | KimEntityEmploymentInformationInfo empInfo = new KimEntityEmploymentInformationInfo(); |
| 171 | 0 | empInfo.setEmployeeId( this.getEmployeeId() ); |
| 172 | 0 | empInfo.setPrimary(true); |
| 173 | 0 | empInfo.setPrimaryDepartmentCode(this.getPrimaryDepartmentCode()); |
| 174 | 0 | info.setPrimaryEmployment( empInfo ); |
| 175 | |
|
| 176 | |
|
| 177 | 0 | info.setExternalIdentifiers( new ArrayList<KimEntityExternalIdentifierInfo>(0) ); |
| 178 | 0 | return info; |
| 179 | |
|
| 180 | |
} |
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | |
|
| 185 | |
|
| 186 | |
@SuppressWarnings("unchecked") |
| 187 | |
@Override |
| 188 | |
protected LinkedHashMap toStringMapper() { |
| 189 | 0 | LinkedHashMap<String,Object> m = new LinkedHashMap<String,Object>( 2 ); |
| 190 | 0 | m.put( "principalId", principalId ); |
| 191 | 0 | m.put( "principalName", principalName ); |
| 192 | 0 | return m; |
| 193 | |
} |
| 194 | |
|
| 195 | |
|
| 196 | |
public String getPrincipalId() { |
| 197 | 0 | return this.principalId; |
| 198 | |
} |
| 199 | |
|
| 200 | |
|
| 201 | |
public void setPrincipalId(String principalId) { |
| 202 | 0 | this.principalId = principalId; |
| 203 | 0 | } |
| 204 | |
|
| 205 | |
|
| 206 | |
public String getPrincipalName() { |
| 207 | 0 | return this.principalName; |
| 208 | |
} |
| 209 | |
|
| 210 | |
|
| 211 | |
public void setPrincipalName(String principalName) { |
| 212 | 0 | this.principalName = principalName; |
| 213 | 0 | } |
| 214 | |
|
| 215 | |
|
| 216 | |
public String getEntityId() { |
| 217 | 0 | return this.entityId; |
| 218 | |
} |
| 219 | |
|
| 220 | |
|
| 221 | |
public void setEntityId(String entityId) { |
| 222 | 0 | this.entityId = entityId; |
| 223 | 0 | } |
| 224 | |
|
| 225 | |
|
| 226 | |
public String getEntityTypeCode() { |
| 227 | 0 | return this.entityTypeCode; |
| 228 | |
} |
| 229 | |
|
| 230 | |
|
| 231 | |
public void setEntityTypeCode(String entityTypeCode) { |
| 232 | 0 | this.entityTypeCode = entityTypeCode; |
| 233 | 0 | } |
| 234 | |
|
| 235 | |
|
| 236 | |
public String getFirstName() { |
| 237 | 0 | return this.firstName; |
| 238 | |
} |
| 239 | |
|
| 240 | |
|
| 241 | |
public void setFirstName(String firstName) { |
| 242 | 0 | this.firstName = firstName; |
| 243 | 0 | } |
| 244 | |
|
| 245 | |
|
| 246 | |
public String getMiddleName() { |
| 247 | 0 | return this.middleName; |
| 248 | |
} |
| 249 | |
|
| 250 | |
|
| 251 | |
public void setMiddleName(String middleName) { |
| 252 | 0 | this.middleName = middleName; |
| 253 | 0 | } |
| 254 | |
|
| 255 | |
|
| 256 | |
public String getLastName() { |
| 257 | 0 | return this.lastName; |
| 258 | |
} |
| 259 | |
|
| 260 | |
|
| 261 | |
public void setLastName(String lastName) { |
| 262 | 0 | this.lastName = lastName; |
| 263 | 0 | } |
| 264 | |
|
| 265 | |
|
| 266 | |
public String getName() { |
| 267 | 0 | return this.name; |
| 268 | |
} |
| 269 | |
|
| 270 | |
|
| 271 | |
public void setName(String name) { |
| 272 | 0 | this.name = name; |
| 273 | 0 | } |
| 274 | |
|
| 275 | |
|
| 276 | |
public String getCampusCode() { |
| 277 | 0 | return this.campusCode; |
| 278 | |
} |
| 279 | |
|
| 280 | |
|
| 281 | |
public void setCampusCode(String campusCode) { |
| 282 | 0 | this.campusCode = campusCode; |
| 283 | 0 | } |
| 284 | |
|
| 285 | |
|
| 286 | |
public String getPrimaryDepartmentCode() { |
| 287 | 0 | return this.primaryDepartmentCode; |
| 288 | |
} |
| 289 | |
|
| 290 | |
|
| 291 | |
public void setPrimaryDepartmentCode(String primaryDepartmentCode) { |
| 292 | 0 | this.primaryDepartmentCode = primaryDepartmentCode; |
| 293 | 0 | } |
| 294 | |
|
| 295 | |
|
| 296 | |
public String getEmployeeId() { |
| 297 | 0 | return this.employeeId; |
| 298 | |
} |
| 299 | |
|
| 300 | |
|
| 301 | |
public void setEmployeeId(String employeeId) { |
| 302 | 0 | this.employeeId = employeeId; |
| 303 | 0 | } |
| 304 | |
|
| 305 | |
|
| 306 | |
public boolean isActive() { |
| 307 | 0 | return false; |
| 308 | |
} |
| 309 | |
|
| 310 | |
public Timestamp getLastUpdateTimestamp() { |
| 311 | 0 | return this.lastUpdateTimestamp; |
| 312 | |
} |
| 313 | |
|
| 314 | |
|
| 315 | |
|
| 316 | |
public void beforeInsert(PersistenceBroker persistenceBroker) throws PersistenceBrokerException { |
| 317 | 0 | super.beforeInsert( persistenceBroker ); |
| 318 | 0 | lastUpdateTimestamp = new Timestamp(System.currentTimeMillis()); |
| 319 | 0 | } |
| 320 | |
|
| 321 | |
public void beforeUpdate(PersistenceBroker persistenceBroker) throws PersistenceBrokerException { |
| 322 | 0 | super.beforeUpdate( persistenceBroker ); |
| 323 | 0 | lastUpdateTimestamp = new Timestamp(System.currentTimeMillis()); |
| 324 | 0 | } |
| 325 | |
|
| 326 | |
@PrePersist |
| 327 | |
public void beforeInsert() { |
| 328 | 0 | super.beforeInsert(); |
| 329 | 0 | lastUpdateTimestamp = new Timestamp(System.currentTimeMillis()); |
| 330 | 0 | } |
| 331 | |
|
| 332 | |
@PreUpdate |
| 333 | |
public void beforeUpdate() { |
| 334 | 0 | super.beforeUpdate(); |
| 335 | 0 | lastUpdateTimestamp = new Timestamp(System.currentTimeMillis()); |
| 336 | 0 | } |
| 337 | |
|
| 338 | |
} |