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