001 package org.kuali.ole.patron.bo; 002 003 import org.apache.commons.collections.CollectionUtils; 004 import org.kuali.ole.patron.api.OlePatronAffiliationContract; 005 import org.kuali.ole.patron.api.OlePatronAffiliationDefinition; 006 import org.kuali.rice.kim.api.identity.employment.EntityEmployment; 007 import org.kuali.rice.kim.api.identity.phone.EntityPhone; 008 import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationBo; 009 import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationTypeBo; 010 import org.kuali.rice.kim.impl.identity.employment.EntityEmploymentBo; 011 import org.kuali.rice.kim.impl.identity.name.EntityNameBo; 012 import org.kuali.rice.kim.impl.identity.phone.EntityPhoneBo; 013 import org.kuali.rice.krad.bo.BusinessObjectBase; 014 015 import java.util.ArrayList; 016 import java.util.List; 017 018 /** 019 OlePatronAffiliation provides OlePatronAffiliation information through getter and setter. 020 */ 021 public class OlePatronAffiliation extends BusinessObjectBase implements OlePatronAffiliationContract { 022 023 private String entityAffiliationId; 024 025 private String entityId; 026 027 private String affiliationTypeCode; 028 029 private String campusCode; 030 031 private boolean defaultValue; 032 033 private boolean active; 034 035 private EntityAffiliationTypeBo affiliationType = new EntityAffiliationTypeBo(); 036 037 private List<EntityEmploymentBo> employments = new ArrayList<EntityEmploymentBo>(); 038 039 private Long versionNumber; 040 041 private String objectId; 042 043 public OlePatronAffiliation() { 044 045 } 046 047 /** 048 * Constructor sets the values to entityAffiliationBo object from OlePatronAffiliation 049 * @param entityAffiliationBo 050 */ 051 public OlePatronAffiliation(EntityAffiliationBo entityAffiliationBo) { 052 this.setEntityAffiliationId(entityAffiliationBo.getId()); 053 this.setAffiliationTypeCode(entityAffiliationBo.getAffiliationTypeCode()); 054 this.setAffiliationType(entityAffiliationBo.getAffiliationType()); 055 this.setCampusCode(entityAffiliationBo.getCampusCode()); 056 this.setDefaultValue(entityAffiliationBo.getDefaultValue()); 057 this.setActive(entityAffiliationBo.getActive()); 058 this.setVersionNumber(entityAffiliationBo.getVersionNumber()); 059 this.setObjectId(entityAffiliationBo.getObjectId()); 060 } 061 /** 062 * Gets the value of entityAffiliationId property 063 * @return entityAffiliationId 064 */ 065 public String getEntityAffiliationId() { 066 return entityAffiliationId; 067 } 068 /** 069 * Sets the value for entityAffiliationId property 070 * @param entityAffiliationId 071 */ 072 public void setEntityAffiliationId(String entityAffiliationId) { 073 this.entityAffiliationId = entityAffiliationId; 074 } 075 /** 076 * Gets the value of affiliationTypeCode property 077 * @return affiliationTypeCode 078 */ 079 public String getAffiliationTypeCode() { 080 return affiliationTypeCode; 081 } 082 /** 083 * Sets the value for affiliationTypeCode property 084 * @param affiliationTypeCode 085 */ 086 public void setAffiliationTypeCode(String affiliationTypeCode) { 087 this.affiliationTypeCode = affiliationTypeCode; 088 } 089 /** 090 * Gets the value of campusCode property 091 * @return campusCode 092 */ 093 public String getCampusCode() { 094 return campusCode; 095 } 096 /** 097 * Sets the value for campusCode property 098 * @param campusCode 099 */ 100 public void setCampusCode(String campusCode) { 101 this.campusCode = campusCode; 102 } 103 /** 104 * Gets the value of defaultValue property 105 * @return defaultValue 106 */ 107 public boolean isDefaultValue() { 108 return defaultValue; 109 } 110 /** 111 * Sets the value for defaultValue property 112 * @param defaultValue 113 */ 114 public void setDefaultValue(boolean defaultValue) { 115 this.defaultValue = defaultValue; 116 } 117 /** 118 * Gets the value of active property 119 * @return active 120 */ 121 public boolean isActive() { 122 return active; 123 } 124 /** 125 * Sets the value for active property 126 * @param active 127 */ 128 public void setActive(boolean active) { 129 this.active = active; 130 } 131 132 /** 133 * Gets the value of affiliationType property 134 * @return affiliationType 135 */ 136 public EntityAffiliationTypeBo getAffiliationType() { 137 return affiliationType; 138 } 139 /** 140 * Sets the value for affiliationType property 141 * @param affiliationType 142 */ 143 public void setAffiliationType(EntityAffiliationTypeBo affiliationType) { 144 this.affiliationType = affiliationType; 145 } 146 /** 147 * Gets the value of employments property 148 * @return employments 149 */ 150 public List<EntityEmploymentBo> getEmployments() { 151 return employments; 152 } 153 /** 154 * Sets the value for employments property 155 * @param employments 156 */ 157 public void setEmployments(List<EntityEmploymentBo> employments) { 158 this.employments = employments; 159 } 160 /** 161 * Gets the value of EntityAffiliation property 162 * @return EntityAffiliation 163 */ 164 public EntityAffiliationBo getEntityAffliationBo() { 165 EntityAffiliationBo entityAffiliationBo = new EntityAffiliationBo(); 166 entityAffiliationBo.setId(this.getEntityAffiliationId()); 167 entityAffiliationBo.setAffiliationTypeCode(this.getAffiliationTypeCode()); 168 entityAffiliationBo.setAffiliationType(this.getAffiliationType()); 169 entityAffiliationBo.setActive(this.isActive()); 170 entityAffiliationBo.setDefaultValue(this.defaultValue); 171 entityAffiliationBo.setCampusCode(this.getCampusCode()); 172 entityAffiliationBo.setObjectId(this.getObjectId()); 173 entityAffiliationBo.setVersionNumber(this.getVersionNumber()); 174 entityAffiliationBo.setEntityId(this.getEntityId()); 175 return entityAffiliationBo; 176 } 177 178 /** 179 * This method converts the PersistableBusinessObjectBase OleBorrowerType into immutable object OlePatronAffiliationDefinition 180 * @param bo(OlePatronAffiliation) 181 * @return OlePatronAffiliationDefinition 182 */ 183 static OlePatronAffiliationDefinition to(OlePatronAffiliation bo) { 184 if (bo == null) { return null; } 185 return OlePatronAffiliationDefinition.Builder.create(bo).build(); 186 } 187 188 /** 189 * This method converts the immutable object OlePatronAffiliationDefinition into PersistableBusinessObjectBase OlePatronAffiliation 190 * @param im(OlePatronAffiliationDefinition) 191 * @return bo(OlePatronAffiliation) 192 */ 193 static OlePatronAffiliation from(OlePatronAffiliationDefinition im) { 194 if (im == null) { return null; } 195 196 OlePatronAffiliation bo = new OlePatronAffiliation(); 197 bo.entityAffiliationId= im.getEntityAffiliationId(); 198 bo.affiliationTypeCode = im.getAffiliationTypeCode(); 199 if (im.getAffiliationType() != null) { 200 bo.affiliationType = EntityAffiliationTypeBo.from(im.getAffiliationType()); 201 } 202 bo.defaultValue = im.isDefaultValue(); 203 bo.active = im.isActive(); 204 bo.versionNumber = im.getVersionNumber(); 205 bo.entityId = im.getEntityId(); 206 bo.objectId = im.getObjectId(); 207 208 if (CollectionUtils.isNotEmpty(im.getEmployments())) { 209 for (EntityEmployment entityEmployment : im.getEmployments()) { 210 bo.employments.add(EntityEmploymentBo.from(entityEmployment)); 211 } 212 } 213 return bo; 214 } 215 216 @Override 217 public void refresh() { 218 //To change body of implemented methods use File | Settings | File Templates. 219 } 220 /** 221 * Gets the value of entityAffiliationId property 222 * @return entityAffiliationId 223 */ 224 @Override 225 public String getId() { 226 return this.entityAffiliationId; 227 } 228 229 /** 230 * Gets the value of versionNumber property 231 * @return versionNumber 232 */ 233 @Override 234 public Long getVersionNumber() { 235 return this.versionNumber; 236 } 237 /** 238 * Sets the value for versionNumber property 239 * @param versionNumber 240 */ 241 public void setVersionNumber(Long versionNumber) { 242 this.versionNumber = versionNumber; 243 } 244 /** 245 * Gets the value of objectId property 246 * @return objectId 247 */ 248 public String getObjectId() { 249 return objectId; 250 } 251 /** 252 * Sets the value for objectId property 253 * @param objectId 254 */ 255 public void setObjectId(String objectId) { 256 this.objectId = objectId; 257 } 258 /** 259 * Gets the value of entityId property 260 * @return entityId 261 */ 262 public String getEntityId() { 263 return entityId; 264 } 265 /** 266 * Sets the value for entityId property 267 * @param entityId 268 */ 269 public void setEntityId(String entityId) { 270 this.entityId = entityId; 271 } 272 }