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