Coverage Report - org.kuali.rice.kim.bo.entity.impl.KimEntityImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
KimEntityImpl
0%
0/72
0%
0/18
1.438
 
 1  
 /*
 2  
  * Copyright 2007-2008 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.bo.entity.impl;
 17  
 
 18  
 import java.util.LinkedHashMap;
 19  
 import java.util.List;
 20  
 
 21  
 import javax.persistence.CascadeType;
 22  
 import javax.persistence.Column;
 23  
 import javax.persistence.Entity;
 24  
 import javax.persistence.FetchType;
 25  
 import javax.persistence.Id;
 26  
 import javax.persistence.JoinColumn;
 27  
 import javax.persistence.OneToMany;
 28  
 import javax.persistence.OneToOne;
 29  
 import javax.persistence.Table;
 30  
 
 31  
 import org.kuali.rice.kim.bo.entity.KimEntity;
 32  
 import org.kuali.rice.kns.util.ObjectUtils;
 33  
 import org.kuali.rice.kns.util.TypedArrayList;
 34  
 
 35  
 /**
 36  
  * This is a description of what this class does - jonathan don't forget to fill
 37  
  * this in.
 38  
  * 
 39  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 40  
  * 
 41  
  */
 42  0
 @SuppressWarnings("unchecked")
 43  
 @Entity
 44  
 @Table(name = "KRIM_ENTITY_T")
 45  0
 public class KimEntityImpl extends KimInactivatableEntityDataBase implements KimEntity {
 46  
 
 47  
         private static final long serialVersionUID = 1L;
 48  
 
 49  
         @Id
 50  
         @Column(name = "ENTITY_ID")
 51  
         protected String entityId;
 52  
 
 53  0
         @OneToMany(targetEntity = KimEntityNameImpl.class, fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
 54  
         @JoinColumn(name = "ENTITY_ID", insertable = false, updatable = false)
 55  
         protected List<KimEntityNameImpl> names = new TypedArrayList(KimEntityNameImpl.class);
 56  
                 
 57  0
         @OneToMany(targetEntity = KimEntityEntityTypeImpl.class, fetch = FetchType.EAGER, cascade = { CascadeType.ALL })
 58  
         @JoinColumn(name = "ENTITY_ID", insertable = true, updatable = true)
 59  
         protected List<KimEntityEntityTypeImpl> entityTypes = new TypedArrayList(KimEntityEntityTypeImpl.class);
 60  
 
 61  0
         @OneToMany(targetEntity = KimPrincipalImpl.class, fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
 62  
         @JoinColumn(name = "ENTITY_ID", insertable = true, updatable = true)
 63  
         protected List<KimPrincipalImpl> principals = new TypedArrayList(KimPrincipalImpl.class);
 64  
 
 65  0
         @OneToMany(targetEntity=KimEntityExternalIdentifierImpl.class,fetch=FetchType.LAZY,cascade={CascadeType.ALL})
 66  
         @JoinColumn(name="ENTITY_ID", insertable=true, updatable=true)
 67  
         protected List<KimEntityExternalIdentifierImpl> externalIdentifiers = new TypedArrayList(KimEntityExternalIdentifierImpl.class);
 68  
 
 69  0
         @OneToMany(targetEntity=KimEntityAffiliationImpl.class,fetch=FetchType.LAZY,cascade={CascadeType.ALL})
 70  
         @JoinColumn(name="ENTITY_ID", insertable=true, updatable=true)
 71  
         protected List<KimEntityAffiliationImpl> affiliations = new TypedArrayList(KimEntityAffiliationImpl.class);
 72  
 
 73  0
         @OneToMany(targetEntity=KimEntityEmploymentInformationImpl.class,fetch=FetchType.LAZY, cascade={CascadeType.ALL})
 74  
         @JoinColumn(name="ENTITY_ID", insertable=true, updatable=true)
 75  
         protected List<KimEntityEmploymentInformationImpl> employmentInformation = new TypedArrayList(KimEntityEmploymentInformationImpl.class);
 76  
 
 77  
         @OneToOne(targetEntity=KimEntityPrivacyPreferencesImpl.class, fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
 78  
         @JoinColumn(name = "ENTITY_ID", insertable = true, updatable = true)
 79  
         protected KimEntityPrivacyPreferencesImpl privacyPreferences;
 80  
 
 81  
         @OneToOne(targetEntity=KimEntityBioDemographicsImpl.class, fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
 82  
         @JoinColumn(name = "ENTITY_ID", insertable = true, updatable = true)
 83  
         protected KimEntityBioDemographicsImpl bioDemographics;
 84  
         
 85  0
         @OneToMany(targetEntity = KimEntityCitizenshipImpl.class, fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
 86  
         @JoinColumn(name = "ENTITY_ID", insertable = false, updatable = false)
 87  
         protected List<KimEntityCitizenshipImpl> citizenships = new TypedArrayList(KimEntityCitizenshipImpl.class);
 88  
 
 89  0
         @OneToMany(targetEntity = KimEntityEthnicityImpl.class, fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
 90  
         @JoinColumn(name = "ENTITY_ID", insertable = false, updatable = false)
 91  
         protected List<KimEntityEthnicityImpl> ethnicities = new TypedArrayList(KimEntityEthnicityImpl.class);
 92  
 
 93  0
         @OneToMany(targetEntity = KimEntityResidencyImpl.class, fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
 94  
         @JoinColumn(name = "ENTITY_ID", insertable = false, updatable = false)
 95  
         protected List<KimEntityResidencyImpl> residencies = new TypedArrayList(KimEntityResidencyImpl.class);
 96  
 
 97  0
         @OneToMany(targetEntity = KimEntityVisaImpl.class, fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
 98  
         @JoinColumn(name = "ENTITY_ID", insertable = false, updatable = false)
 99  
         protected List<KimEntityVisaImpl> visas = new TypedArrayList(KimEntityVisaImpl.class);
 100  
 
 101  
         /**
 102  
          * @return the entityId
 103  
          */
 104  
         public String getEntityId() {
 105  0
                 return this.entityId;
 106  
         }
 107  
 
 108  
         /**
 109  
          * @param entityId
 110  
          *            the entityId to set
 111  
          */
 112  
         public void setEntityId(String entityId) {
 113  0
                 this.entityId = entityId;
 114  0
         }
 115  
 
 116  
         /**
 117  
          * @return the entityTypes
 118  
          */
 119  
         public List<KimEntityEntityTypeImpl> getEntityTypes() {
 120  0
                 return this.entityTypes;
 121  
         }
 122  
 
 123  
         /**
 124  
          * @param entityTypes
 125  
          *            the entityTypes to set
 126  
          */
 127  
         public void setEntityTypes(List<KimEntityEntityTypeImpl> entityTypes) {
 128  0
                 this.entityTypes = entityTypes;
 129  0
         }
 130  
 
 131  
         /**
 132  
          * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
 133  
          */
 134  
         protected LinkedHashMap toStringMapper() {
 135  0
                 LinkedHashMap lhm = new LinkedHashMap();
 136  0
                 lhm.put("entityId", entityId);
 137  0
                 return lhm;
 138  
         }
 139  
 
 140  
         /**
 141  
          * @return the externalIdentifiers
 142  
          */
 143  
         public List<KimEntityExternalIdentifierImpl> getExternalIdentifiers() {
 144  0
                 return this.externalIdentifiers;
 145  
         }
 146  
 
 147  
         /**
 148  
          * @param externalIdentifiers
 149  
          *            the externalIdentifiers to set
 150  
          */
 151  
         public void setExternalIdentifiers(List<KimEntityExternalIdentifierImpl> externalIdentifiers) {
 152  0
                 this.externalIdentifiers = externalIdentifiers;
 153  0
         }
 154  
 
 155  
         /**
 156  
          * @return the privacyPreferences
 157  
          */
 158  
         public KimEntityPrivacyPreferencesImpl getPrivacyPreferences() {
 159  0
             if (ObjectUtils.isNull(this.privacyPreferences)) {
 160  0
                 return null;
 161  
             }
 162  0
                 return this.privacyPreferences;
 163  
         }
 164  
 
 165  
         /**
 166  
          * @param privacyPreferences
 167  
          *            the privacyPreferences to set
 168  
          */
 169  
         public void setPrivacyPreferences(KimEntityPrivacyPreferencesImpl privacyPreferences) {
 170  0
                 this.privacyPreferences = privacyPreferences;
 171  0
         }
 172  
 
 173  
         /**
 174  
          * @return the bioDemographics
 175  
          */
 176  
         public KimEntityBioDemographicsImpl getBioDemographics() {
 177  0
             if (ObjectUtils.isNull(this.bioDemographics)) {
 178  0
             return null;
 179  
         }
 180  0
                 return this.bioDemographics;
 181  
         }
 182  
 
 183  
         /**
 184  
          * @param bioDemographics
 185  
          *            the bioDemographics to set
 186  
          */
 187  
         public void setBioDemographics(KimEntityBioDemographicsImpl bioDemographics) {
 188  0
                 this.bioDemographics = bioDemographics;
 189  0
         }
 190  
 
 191  
         /**
 192  
          * @return the affiliations
 193  
          */
 194  
         public List<KimEntityAffiliationImpl> getAffiliations() {
 195  0
                 return this.affiliations;
 196  
         }
 197  
 
 198  
         /**
 199  
          * @param affiliations
 200  
          *            the affiliations to set
 201  
          */
 202  
         public void setAffiliations(List<KimEntityAffiliationImpl> affiliations) {
 203  0
                 this.affiliations = affiliations;
 204  0
         }
 205  
 
 206  
         /**
 207  
          * @return the employmentInformation
 208  
          */
 209  
         public List<KimEntityEmploymentInformationImpl> getEmploymentInformation() {
 210  0
                 return this.employmentInformation;
 211  
         }
 212  
 
 213  
         /**
 214  
          * @param employmentInformation
 215  
          *            the employmentInformation to set
 216  
          */
 217  
         public void setEmploymentInformation(List<KimEntityEmploymentInformationImpl> employmentInformation) {
 218  0
                 this.employmentInformation = employmentInformation;
 219  0
         }
 220  
 
 221  
         /**
 222  
          * @see org.kuali.rice.kim.bo.entity.KimEntity#getPrincipals()
 223  
          */
 224  
         public List<KimPrincipalImpl> getPrincipals() {
 225  0
                 return principals;
 226  
         }
 227  
         
 228  
         
 229  
         /**
 230  
          * @see org.kuali.rice.kim.bo.entity.KimEntity#getEntityType(java.lang.String)
 231  
          */
 232  
         public KimEntityEntityTypeImpl getEntityType(String entityTypeCode) {
 233  0
                 for ( KimEntityEntityTypeImpl entType : entityTypes ) {
 234  0
                         if ( entType.getEntityTypeCode().equals( entityTypeCode ) ) {
 235  0
                                 return entType;
 236  
                         }
 237  
                 }
 238  0
                 return null;
 239  
         }
 240  
         
 241  
         /**
 242  
          * This overridden method ...
 243  
          * 
 244  
          * @see org.kuali.rice.kim.bo.entity.KimEntity#getDefaultAffiliation()
 245  
          */
 246  
         public KimEntityAffiliationImpl getDefaultAffiliation() {
 247  0
                 return (KimEntityAffiliationImpl)getDefaultItem( affiliations );
 248  
         }
 249  
         
 250  
         /**
 251  
          * This overridden method ...
 252  
          * 
 253  
          * @see org.kuali.rice.kim.bo.entity.KimEntity#getEntityExternalIdentifier(java.lang.String)
 254  
          */
 255  
         public KimEntityExternalIdentifierImpl getEntityExternalIdentifier(String externalIdentifierTypeCode) {
 256  0
                 for ( KimEntityExternalIdentifierImpl id : externalIdentifiers ) {
 257  0
                         if ( id.getExternalIdentifierTypeCode().equals(  externalIdentifierTypeCode  ) ) {
 258  0
                                 return id;
 259  
                         }
 260  
                 }
 261  0
                 return null;
 262  
         }
 263  
         
 264  
         /**
 265  
          * This overridden method ...
 266  
          * 
 267  
          * @see org.kuali.rice.kim.bo.entity.KimEntity#getPrimaryEmployment()
 268  
          */
 269  
         public KimEntityEmploymentInformationImpl getPrimaryEmployment() {
 270  0
                 for ( KimEntityEmploymentInformationImpl emp : employmentInformation ) {
 271  0
                         if ( emp.isActive() && emp.isPrimary() ) {
 272  0
                                 return emp;
 273  
                         }
 274  
                 }
 275  0
                 return null;
 276  
         }
 277  
 
 278  
         public List<KimEntityNameImpl> getNames() {
 279  0
                 return this.names;
 280  
         }
 281  
 
 282  
         public void setNames(List<KimEntityNameImpl> names) {
 283  0
                 this.names = names;
 284  0
         }        
 285  
         
 286  
         /**
 287  
          * This overridden method ...
 288  
          * 
 289  
          * @see org.kuali.rice.kim.bo.entity.KimEntity#getDefaultName()
 290  
          */
 291  
         public KimEntityNameImpl getDefaultName() {
 292  0
                 return (KimEntityNameImpl)getDefaultItem( names );
 293  
         }
 294  
 
 295  
         /**
 296  
          * @return the citizenships
 297  
          */
 298  
         public List<KimEntityCitizenshipImpl> getCitizenships() {
 299  0
                 return this.citizenships;
 300  
         }
 301  
 
 302  
         /**
 303  
          * @param citizenships the citizenships to set
 304  
          */
 305  
         public void setCitizenships(List<KimEntityCitizenshipImpl> citizenships) {
 306  0
                 this.citizenships = citizenships;
 307  0
         }
 308  
 
 309  
         /**
 310  
          * @return the ethnicities
 311  
          */
 312  
         public List<KimEntityEthnicityImpl> getEthnicities() {
 313  0
                 return this.ethnicities;
 314  
         }
 315  
 
 316  
         /**
 317  
          * @param ethnicities the ethnicities to set
 318  
          */
 319  
         public void setEthnicities(List<KimEntityEthnicityImpl> ethnicities) {
 320  0
                 this.ethnicities = ethnicities;
 321  0
         }
 322  
 
 323  
         /**
 324  
          * @return the residencies
 325  
          */
 326  
         public List<KimEntityResidencyImpl> getResidencies() {
 327  0
                 return this.residencies;
 328  
         }
 329  
 
 330  
         /**
 331  
          * @param residencies the residencies to set
 332  
          */
 333  
         public void setResidencies(List<KimEntityResidencyImpl> residencies) {
 334  0
                 this.residencies = residencies;
 335  0
         }
 336  
 
 337  
         /**
 338  
          * @return the visas
 339  
          */
 340  
         public List<KimEntityVisaImpl> getVisas() {
 341  0
                 return this.visas;
 342  
         }
 343  
 
 344  
         /**
 345  
          * @param visas the visas to set
 346  
          */
 347  
         public void setVisas(List<KimEntityVisaImpl> visas) {
 348  0
                 this.visas = visas;
 349  0
         }
 350  
 
 351  
         public void setPrincipals(List<KimPrincipalImpl> principals) {
 352  0
                 this.principals = principals;
 353  0
         }
 354  
         
 355  
         /** This possibly fixes an issue with afterLookup not following references and calling afterLookup?
 356  
         @Override
 357  
         public void afterLookup(PersistenceBroker persistenceBroker)
 358  
                         throws PersistenceBrokerException {
 359  
                 // afterLookup is not called recursively on all referenced objects, external entities can be encrypted coming out of the db, so let's resolve this by manaully walking down
 360  
                 super.afterLookup(persistenceBroker);
 361  
                 if (getExternalIdentifiers() != null) {
 362  
                         for (KimEntityExternalIdentifierImpl extId : getExternalIdentifiers()) {
 363  
                                 extId.afterLookup(persistenceBroker);
 364  
                         }
 365  
                 }
 366  
         }        
 367  
         */
 368  
         
 369  
 }