| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.student.kim.identity.mock; |
| 17 | |
|
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.Arrays; |
| 20 | |
import java.util.HashMap; |
| 21 | |
import java.util.List; |
| 22 | |
import java.util.Map; |
| 23 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityAddressInfo; |
| 24 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityAffiliationInfo; |
| 25 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityBioDemographicsInfo; |
| 26 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityDefaultInfo; |
| 27 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityEmailInfo; |
| 28 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityEmploymentInformationInfo; |
| 29 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityEntityTypeDefaultInfo; |
| 30 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityEntityTypeInfo; |
| 31 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityExternalIdentifierInfo; |
| 32 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityInfo; |
| 33 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityNameInfo; |
| 34 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityNamePrincipalNameInfo; |
| 35 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityPrivacyPreferencesInfo; |
| 36 | |
import org.kuali.rice.kim.bo.entity.dto.KimPrincipalInfo; |
| 37 | |
import org.kuali.rice.kim.bo.reference.dto.AddressTypeInfo; |
| 38 | |
import org.kuali.rice.kim.bo.reference.dto.AffiliationTypeInfo; |
| 39 | |
import org.kuali.rice.kim.bo.reference.dto.CitizenshipStatusInfo; |
| 40 | |
import org.kuali.rice.kim.bo.reference.dto.EmailTypeInfo; |
| 41 | |
import org.kuali.rice.kim.bo.reference.dto.EmploymentStatusInfo; |
| 42 | |
import org.kuali.rice.kim.bo.reference.dto.EmploymentTypeInfo; |
| 43 | |
import org.kuali.rice.kim.bo.reference.dto.EntityNameTypeInfo; |
| 44 | |
import org.kuali.rice.kim.bo.reference.dto.EntityTypeInfo; |
| 45 | |
import org.kuali.rice.kim.bo.reference.dto.ExternalIdentifierTypeInfo; |
| 46 | |
import org.kuali.rice.kim.bo.reference.dto.PhoneTypeInfo; |
| 47 | |
import org.kuali.rice.kim.service.IdentityService; |
| 48 | |
import org.kuali.student.enrollment.lpr.mock.CriteriaMatcherInMemory; |
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | 0 | public class IdentityServiceMockImpl implements IdentityService { |
| 54 | |
|
| 55 | 0 | private int boundedSearchMaxResults = IdentityServiceConstants.BOUNDED_SEARCH_MAX_RESULTS; |
| 56 | |
|
| 57 | |
public int getBoundedSearchMaxResults() { |
| 58 | 0 | return boundedSearchMaxResults; |
| 59 | |
} |
| 60 | |
|
| 61 | |
public void setBoundedSearchMaxResults(int boundedSearchMaxResults) { |
| 62 | 0 | this.boundedSearchMaxResults = boundedSearchMaxResults; |
| 63 | 0 | } |
| 64 | |
|
| 65 | |
@Override |
| 66 | |
public AddressTypeInfo getAddressType(String code) { |
| 67 | 0 | for (AddressTypeEnum at : AddressTypeEnum.values()) { |
| 68 | 0 | if (at.getCode().equals(code)) { |
| 69 | 0 | AddressTypeInfo info = new AddressTypeInfo(); |
| 70 | 0 | info.setActive(at.isActive()); |
| 71 | 0 | info.setAddressTypeCode(at.getCode()); |
| 72 | 0 | info.setAddressTypeName(at.getName()); |
| 73 | 0 | info.setDisplaySortCode(at.getSort()); |
| 74 | 0 | info.setCode(at.getCode()); |
| 75 | 0 | info.setName(at.getName()); |
| 76 | 0 | return info; |
| 77 | |
} |
| 78 | |
} |
| 79 | 0 | return null; |
| 80 | |
} |
| 81 | |
|
| 82 | |
@Override |
| 83 | |
public AffiliationTypeInfo getAffiliationType(String code) { |
| 84 | 0 | for (AffiliationTypeEnum aff : AffiliationTypeEnum.values()) { |
| 85 | 0 | if (aff.getCode().equals(code)) { |
| 86 | 0 | AffiliationTypeInfo info = new AffiliationTypeInfo(); |
| 87 | 0 | info.setActive(aff.isActive()); |
| 88 | 0 | info.setAffiliationTypeCode(aff.getCode()); |
| 89 | 0 | info.setAffiliationTypeName(aff.getName()); |
| 90 | 0 | info.setCode(aff.getCode()); |
| 91 | 0 | info.setName(aff.getName()); |
| 92 | 0 | info.setDisplaySortCode(aff.getSort()); |
| 93 | 0 | return info; |
| 94 | |
} |
| 95 | |
} |
| 96 | 0 | return null; |
| 97 | |
} |
| 98 | |
|
| 99 | |
@Override |
| 100 | |
public CitizenshipStatusInfo getCitizenshipStatus(String code) { |
| 101 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 102 | |
} |
| 103 | |
|
| 104 | |
private KimEntityNameInfo toKimEntityNameInfo(PersonEnum pers) { |
| 105 | 0 | KimEntityNameInfo info = new KimEntityNameInfo(); |
| 106 | 0 | info.setActive(pers.isActive()); |
| 107 | 0 | info.setDefault(true); |
| 108 | 0 | info.setEntityNameId(pers.getEntityId()); |
| 109 | 0 | info.setFirstName(pers.getFirstName()); |
| 110 | 0 | info.setFirstNameUnmasked(pers.getFirstName()); |
| 111 | 0 | info.setFormattedName(pers.getFormattedName()); |
| 112 | 0 | info.setFormattedNameUnmasked(pers.getFormattedName()); |
| 113 | 0 | info.setLastName(pers.getLastName()); |
| 114 | 0 | info.setLastNameUnmasked(pers.getLastName()); |
| 115 | 0 | info.setMiddleName(pers.getMiddleName()); |
| 116 | 0 | info.setMiddleNameUnmasked(null); |
| 117 | 0 | info.setNameTypeCode(EntityNameTypeEnum.PRIMARY.getCode()); |
| 118 | 0 | info.setSuffix(pers.getSuffix()); |
| 119 | 0 | info.setSuffixUnmasked(pers.getSuffix()); |
| 120 | 0 | info.setSuppressName(false); |
| 121 | 0 | info.setTitle(pers.getTitle()); |
| 122 | 0 | info.setTitleUnmasked(pers.getTitle()); |
| 123 | 0 | return info; |
| 124 | |
} |
| 125 | |
|
| 126 | |
private KimEntityAffiliationInfo toKimEntityAffiliationInfo(PersonEnum pers) { |
| 127 | |
|
| 128 | |
|
| 129 | 0 | KimEntityAffiliationInfo info = new KimEntityAffiliationInfo(); |
| 130 | 0 | info.setActive(true); |
| 131 | 0 | info.setAffiliationTypeCode(pers.getAffiliation()); |
| 132 | 0 | info.setCampusCode(null); |
| 133 | 0 | info.setDefault(true); |
| 134 | 0 | info.setEntityAffiliationId(pers.getEntityId()); |
| 135 | 0 | return info; |
| 136 | |
} |
| 137 | |
|
| 138 | |
private KimEntityEmailInfo toKimEntityEmailInfo(PersonEnum pers) { |
| 139 | 0 | KimEntityEmailInfo info = new KimEntityEmailInfo(); |
| 140 | 0 | info.setActive(true); |
| 141 | 0 | info.setDefault(true); |
| 142 | 0 | info.setEmailAddress(pers.getPrincipalName()); |
| 143 | 0 | info.setEmailAddressUnmasked(pers.getPrincipalName()); |
| 144 | 0 | info.setEmailTypeCode(EmailTypeEnum.WORK.getCode()); |
| 145 | 0 | info.setEntityEmailId(pers.getEntityId()); |
| 146 | 0 | info.setEntityTypeCode(EntityTypeEnum.PERSON.getCode()); |
| 147 | 0 | info.setSuppressEmail(false); |
| 148 | 0 | return info; |
| 149 | |
} |
| 150 | |
|
| 151 | |
private KimEntityAddressInfo toKimEntityAddressInfo(PersonEnum pers) { |
| 152 | 0 | KimEntityAddressInfo info = new KimEntityAddressInfo(); |
| 153 | 0 | info.setActive(true); |
| 154 | 0 | info.setAddressTypeCode(AddressTypeEnum.HOME.getCode()); |
| 155 | 0 | info.setCityName(pers.getCity()); |
| 156 | 0 | info.setCityNameUnmasked(pers.getCity()); |
| 157 | 0 | info.setCountryCode("US"); |
| 158 | 0 | info.setCountryCodeUnmasked("US"); |
| 159 | 0 | info.setDefault(true); |
| 160 | 0 | info.setEntityAddressId(pers.getEntityId()); |
| 161 | 0 | info.setEntityTypeCode(EntityTypeEnum.PERSON.getCode()); |
| 162 | 0 | info.setLine1(pers.getStreet()); |
| 163 | 0 | info.setLine1Unmasked(pers.getStreet()); |
| 164 | 0 | info.setLine2(null); |
| 165 | 0 | info.setLine2Unmasked(null); |
| 166 | 0 | info.setLine3(null); |
| 167 | 0 | info.setLine3Unmasked(null); |
| 168 | 0 | info.setPostalCode(pers.getZip()); |
| 169 | 0 | info.setPostalCodeUnmasked(pers.getZip()); |
| 170 | 0 | info.setStateCode(pers.getState()); |
| 171 | 0 | info.setStateCodeUnmasked(pers.getState()); |
| 172 | 0 | info.setSuppressAddress(false); |
| 173 | 0 | return info; |
| 174 | |
} |
| 175 | |
|
| 176 | |
private KimEntityEntityTypeDefaultInfo toKimEntityEntityTypeDefaultInfo(PersonEnum pers) { |
| 177 | 0 | KimEntityEntityTypeDefaultInfo info = new KimEntityEntityTypeDefaultInfo(); |
| 178 | 0 | info.setDefaultEmailAddress(this.toKimEntityEmailInfo(pers)); |
| 179 | 0 | info.setDefaultAddress(this.toKimEntityAddressInfo(pers)); |
| 180 | 0 | info.setEntityTypeCode(EntityTypeEnum.PERSON.getCode()); |
| 181 | 0 | return info; |
| 182 | |
} |
| 183 | |
|
| 184 | |
private KimEntityExternalIdentifierInfo toKimEntityExternalIdentifierInfo(PersonEnum pers) { |
| 185 | 0 | if (pers.getSsn() == null || pers.getSsn().isEmpty()) { |
| 186 | 0 | return null; |
| 187 | |
} |
| 188 | 0 | KimEntityExternalIdentifierInfo info = new KimEntityExternalIdentifierInfo(); |
| 189 | 0 | info.setEntityExternalIdentifierId(pers.getEntityId()); |
| 190 | 0 | info.setExternalId(pers.getSsn()); |
| 191 | 0 | info.setExternalIdentifierTypeCode(ExternalIdentifierTypeEnum.TAX.getCode()); |
| 192 | 0 | return info; |
| 193 | |
} |
| 194 | |
|
| 195 | |
private KimEntityEmploymentInformationInfo toKimEntityEmploymentInformationInfo(PersonEnum pers) { |
| 196 | |
|
| 197 | 0 | if (!(pers.getAffiliation().equals(AffiliationTypeEnum.FACULTY.getCode()) |
| 198 | |
|| pers.getAffiliation().equals(AffiliationTypeEnum.STAFF.getCode()))) { |
| 199 | 0 | return null; |
| 200 | |
} |
| 201 | 0 | KimEntityEmploymentInformationInfo info = new KimEntityEmploymentInformationInfo(); |
| 202 | 0 | info.setActive(true); |
| 203 | 0 | info.setBaseSalaryAmount(null); |
| 204 | 0 | info.setEmployeeId(pers.getSsn()); |
| 205 | 0 | info.setEmployeeStatusCode(EmployeeStatusEnum.ACTIVE.getCode()); |
| 206 | 0 | info.setEmployeeTypeCode(EmployeeTypeEnum.PROFESSIONAL.getCode()); |
| 207 | 0 | info.setEmploymentRecordId(pers.getSsn()); |
| 208 | 0 | info.setEntityAffiliationId(pers.getEntityId()); |
| 209 | 0 | info.setEntityEmploymentId(pers.getEntityId()); |
| 210 | 0 | info.setPrimary(true); |
| 211 | 0 | info.setPrimaryDepartmentCode(pers.getDept()); |
| 212 | 0 | return info; |
| 213 | |
} |
| 214 | |
|
| 215 | |
private KimPrincipalInfo toKimPrincipalInfo(PersonEnum pers) { |
| 216 | 0 | KimPrincipalInfo info = new KimPrincipalInfo(); |
| 217 | 0 | info.setActive(pers.isActive()); |
| 218 | 0 | info.setEntityId(pers.getEntityId()); |
| 219 | 0 | info.setPassword(pers.getPassword()); |
| 220 | 0 | info.setPrincipalId(pers.getPrincipalId()); |
| 221 | 0 | info.setPrincipalName(pers.getPrincipalName()); |
| 222 | 0 | return info; |
| 223 | |
} |
| 224 | |
|
| 225 | |
private KimEntityPrivacyPreferencesInfo toKimEntityPrivacyPreferencesInfo(PersonEnum pers) { |
| 226 | 0 | KimEntityPrivacyPreferencesInfo info = new KimEntityPrivacyPreferencesInfo(); |
| 227 | 0 | info.setSuppressAddress(false); |
| 228 | 0 | info.setSuppressEmail(false); |
| 229 | 0 | info.setSuppressName(false); |
| 230 | 0 | info.setSuppressPhone(false); |
| 231 | 0 | return info; |
| 232 | |
} |
| 233 | |
|
| 234 | |
|
| 235 | |
private KimEntityDefaultInfo toKimEntityDefaultInfo(PersonEnum pers) { |
| 236 | 0 | KimEntityDefaultInfo info = new KimEntityDefaultInfo(); |
| 237 | 0 | info.setActive(pers.isActive()); |
| 238 | 0 | info.setEntityTypes(Arrays.asList(this.toKimEntityEntityTypeDefaultInfo(pers))); |
| 239 | 0 | info.setDefaultAffiliation(this.toKimEntityAffiliationInfo(pers)); |
| 240 | 0 | info.setAffiliations(Arrays.asList(info.getDefaultAffiliation())); |
| 241 | 0 | info.setDefaultName(toKimEntityNameInfo(pers)); |
| 242 | 0 | info.setEntityId(pers.getEntityId()); |
| 243 | 0 | info.setExternalIdentifiers(Arrays.asList(this.toKimEntityExternalIdentifierInfo(pers))); |
| 244 | 0 | info.setPrimaryEmployment(this.toKimEntityEmploymentInformationInfo(pers)); |
| 245 | 0 | info.setPrincipals(Arrays.asList(this.toKimPrincipalInfo(pers))); |
| 246 | 0 | info.setPrivacyPreferences(this.toKimEntityPrivacyPreferencesInfo(pers)); |
| 247 | 0 | return info; |
| 248 | |
} |
| 249 | |
|
| 250 | |
@Override |
| 251 | |
public Map<String, KimEntityNameInfo> getDefaultNamesForEntityIds(List<String> entityIds) { |
| 252 | 0 | Map<String, KimEntityNameInfo> map = new HashMap<String, KimEntityNameInfo>(); |
| 253 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 254 | 0 | if (entityIds.contains(pers.getEntityId())) { |
| 255 | 0 | map.put(pers.getPrincipalId(), toKimEntityNameInfo(pers)); |
| 256 | |
} |
| 257 | |
} |
| 258 | 0 | return map; |
| 259 | |
} |
| 260 | |
|
| 261 | |
@Override |
| 262 | |
public Map<String, KimEntityNamePrincipalNameInfo> getDefaultNamesForPrincipalIds(List<String> principalIds) { |
| 263 | 0 | Map<String, KimEntityNamePrincipalNameInfo> map = new HashMap<String, KimEntityNamePrincipalNameInfo>(); |
| 264 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 265 | 0 | if (principalIds.contains(pers.getPrincipalId())) { |
| 266 | 0 | KimEntityNamePrincipalNameInfo info = new KimEntityNamePrincipalNameInfo(); |
| 267 | 0 | info.setPrincipalName(pers.getPrincipalName()); |
| 268 | 0 | info.setDefaultEntityName(toKimEntityNameInfo(pers)); |
| 269 | 0 | map.put(pers.getPrincipalId(), info); |
| 270 | |
} |
| 271 | |
} |
| 272 | 0 | return map; |
| 273 | |
} |
| 274 | |
|
| 275 | |
@Override |
| 276 | |
public EmailTypeInfo getEmailType(String code) { |
| 277 | 0 | for (EmailTypeEnum at : EmailTypeEnum.values()) { |
| 278 | 0 | if (at.getCode().equals(code)) { |
| 279 | 0 | EmailTypeInfo info = new EmailTypeInfo(); |
| 280 | 0 | info.setActive(at.isActive()); |
| 281 | 0 | info.setEmailTypeCode(at.getCode()); |
| 282 | 0 | info.setEmailTypeName(at.getName()); |
| 283 | 0 | info.setDisplaySortCode(at.getSort()); |
| 284 | 0 | info.setCode(at.getCode()); |
| 285 | 0 | info.setName(at.getName()); |
| 286 | 0 | return info; |
| 287 | |
} |
| 288 | |
} |
| 289 | 0 | return null; |
| 290 | |
} |
| 291 | |
|
| 292 | |
private EmploymentStatusInfo toEmploymentStatusInfo(EmployeeStatusEnum st) { |
| 293 | 0 | EmploymentStatusInfo info = new EmploymentStatusInfo(); |
| 294 | 0 | info.setActive(st.isActive()); |
| 295 | 0 | info.setCode(st.getCode()); |
| 296 | 0 | info.setDisplaySortCode(st.getSort()); |
| 297 | 0 | info.setEmploymentStatusCode(st.getCode()); |
| 298 | 0 | info.setEmploymentStatusName(st.getName()); |
| 299 | 0 | info.setName(st.getName()); |
| 300 | 0 | return info; |
| 301 | |
} |
| 302 | |
|
| 303 | |
@Override |
| 304 | |
public EmploymentStatusInfo getEmploymentStatus(String code) { |
| 305 | 0 | for (EmployeeStatusEnum st : EmployeeStatusEnum.values()) { |
| 306 | 0 | if (st.getCode().equals(code)) { |
| 307 | 0 | return this.toEmploymentStatusInfo(st); |
| 308 | |
} |
| 309 | |
} |
| 310 | 0 | return null; |
| 311 | |
} |
| 312 | |
|
| 313 | |
private EmploymentTypeInfo toEmploymentTypeInfo(EmployeeTypeEnum typ) { |
| 314 | 0 | EmploymentTypeInfo info = new EmploymentTypeInfo(); |
| 315 | 0 | info.setActive(typ.isActive()); |
| 316 | 0 | info.setCode(typ.getCode()); |
| 317 | 0 | info.setDisplaySortCode(typ.getSort()); |
| 318 | 0 | info.setEmploymentTypeCode(typ.getCode()); |
| 319 | 0 | info.setEmploymentTypeName(typ.getName()); |
| 320 | 0 | info.setName(typ.getName()); |
| 321 | 0 | return info; |
| 322 | |
} |
| 323 | |
|
| 324 | |
@Override |
| 325 | |
public EmploymentTypeInfo getEmploymentType(String code) { |
| 326 | 0 | for (EmployeeTypeEnum st : EmployeeTypeEnum.values()) { |
| 327 | 0 | if (st.getCode().equals(code)) { |
| 328 | 0 | return this.toEmploymentTypeInfo(st); |
| 329 | |
} |
| 330 | |
} |
| 331 | 0 | return null; |
| 332 | |
} |
| 333 | |
|
| 334 | |
@Override |
| 335 | |
public KimEntityDefaultInfo getEntityDefaultInfo(String entityId) { |
| 336 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 337 | 0 | if (pers.getEntityId().equals(entityId)) { |
| 338 | 0 | return this.toKimEntityDefaultInfo(pers); |
| 339 | |
} |
| 340 | |
} |
| 341 | 0 | return null; |
| 342 | |
} |
| 343 | |
|
| 344 | |
@Override |
| 345 | |
public KimEntityDefaultInfo getEntityDefaultInfoByPrincipalId(String principalId) { |
| 346 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 347 | 0 | if (pers.getPrincipalId().equals(principalId)) { |
| 348 | 0 | return this.toKimEntityDefaultInfo(pers); |
| 349 | |
} |
| 350 | |
} |
| 351 | 0 | return null; |
| 352 | |
} |
| 353 | |
|
| 354 | |
@Override |
| 355 | |
public KimEntityDefaultInfo getEntityDefaultInfoByPrincipalName(String principalName) { |
| 356 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 357 | 0 | if (pers.getPrincipalName().equals(principalName)) { |
| 358 | 0 | return this.toKimEntityDefaultInfo(pers); |
| 359 | |
} |
| 360 | |
} |
| 361 | 0 | return null; |
| 362 | |
} |
| 363 | |
|
| 364 | |
private KimEntityEntityTypeInfo toKimEntityEntityTypeInfo(PersonEnum pers) { |
| 365 | 0 | KimEntityEntityTypeInfo info = new KimEntityEntityTypeInfo(); |
| 366 | 0 | info.setActive(pers.isActive()); |
| 367 | 0 | info.setDefaultAddress(this.toKimEntityAddressInfo(pers)); |
| 368 | 0 | info.setAddresses(Arrays.asList(info.getDefaultAddress())); |
| 369 | 0 | info.setDefaultEmailAddress(this.toKimEntityEmailInfo(pers)); |
| 370 | 0 | info.setDefaultPhoneNumber(null); |
| 371 | 0 | info.setEmailAddresses(Arrays.asList(info.getDefaultEmailAddress())); |
| 372 | 0 | info.setEntityType(this.getEntityType(EntityTypeEnum.PERSON.getCode())); |
| 373 | 0 | info.setEntityTypeCode(EntityTypeEnum.PERSON.getCode()); |
| 374 | 0 | info.setPhoneNumbers(null); |
| 375 | 0 | return info; |
| 376 | |
} |
| 377 | |
|
| 378 | |
private KimEntityBioDemographicsInfo toKimEntityBioDemographicsInfo(PersonEnum pers) { |
| 379 | 0 | KimEntityBioDemographicsInfo info = new KimEntityBioDemographicsInfo(); |
| 380 | 0 | info.setBirthDate(null); |
| 381 | 0 | info.setBirthDateUnmasked(null); |
| 382 | 0 | info.setBirthStateCode(null); |
| 383 | 0 | info.setBirthStateCodeUnmasked(null); |
| 384 | 0 | info.setCityOfBirth(null); |
| 385 | 0 | info.setCityOfBirthUnmasked(null); |
| 386 | 0 | info.setCountryOfBirthCode(null); |
| 387 | 0 | info.setCountryOfBirthCodeUnmasked(null); |
| 388 | 0 | info.setDeceasedDate(null); |
| 389 | 0 | info.setEntityId(pers.getEntityId()); |
| 390 | 0 | info.setGenderCode(pers.getGender().substring(0, 1)); |
| 391 | 0 | info.setGenderCodeUnmasked(info.getGenderCode()); |
| 392 | 0 | info.setGenderCodeUnmaskedUnmasked(info.getGenderCode()); |
| 393 | 0 | info.setGeographicOrigin(null); |
| 394 | 0 | info.setGeographicOriginUnmasked(null); |
| 395 | 0 | info.setMaritalStatusCode(null); |
| 396 | 0 | info.setMaritalStatusCodeUnmasked(null); |
| 397 | 0 | info.setPrimaryLanguageCode(null); |
| 398 | 0 | info.setPrimaryLanguageCodeUnmasked(null); |
| 399 | 0 | info.setSecondaryLanguageCode(null); |
| 400 | 0 | info.setSecondaryLanguageCodeUnmasked(null); |
| 401 | 0 | info.setSuppressPersonal(false); |
| 402 | 0 | return info; |
| 403 | |
} |
| 404 | |
|
| 405 | |
private KimEntityInfo toKimEntityInfo(PersonEnum pers) { |
| 406 | 0 | KimEntityInfo info = new KimEntityInfo(); |
| 407 | 0 | info.setActive(pers.isActive()); |
| 408 | 0 | info.setAffiliations(Arrays.asList(this.toKimEntityAffiliationInfo(pers))); |
| 409 | 0 | info.setBioDemographics(this.toKimEntityBioDemographicsInfo(pers)); |
| 410 | 0 | info.setCitizenships(null); |
| 411 | 0 | info.setEmploymentInformation(Arrays.asList(toKimEntityEmploymentInformationInfo(pers))); |
| 412 | 0 | info.setEntityId(pers.getEntityId()); |
| 413 | 0 | info.setEntityTypes(Arrays.asList(this.toKimEntityEntityTypeInfo(pers))); |
| 414 | 0 | info.setEthnicities(null); |
| 415 | 0 | info.setExternalIdentifiers(Arrays.asList(this.toKimEntityExternalIdentifierInfo(pers))); |
| 416 | 0 | info.setNames(Arrays.asList(this.toKimEntityNameInfo(pers))); |
| 417 | 0 | info.setPrincipals(Arrays.asList(this.toKimPrincipalInfo(pers))); |
| 418 | 0 | info.setPrivacyPreferences(this.toKimEntityPrivacyPreferencesInfo(pers)); |
| 419 | 0 | info.setResidencies(null); |
| 420 | 0 | info.setVisas(null); |
| 421 | 0 | return info; |
| 422 | |
} |
| 423 | |
|
| 424 | |
@Override |
| 425 | |
public KimEntityInfo getEntityInfo(String entityId) { |
| 426 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 427 | 0 | if (pers.getEntityId().equals(entityId)) { |
| 428 | 0 | return this.toKimEntityInfo(pers); |
| 429 | |
} |
| 430 | |
} |
| 431 | 0 | return null; |
| 432 | |
} |
| 433 | |
|
| 434 | |
@Override |
| 435 | |
public KimEntityInfo getEntityInfoByPrincipalId(String principalId) { |
| 436 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 437 | 0 | if (pers.getPrincipalId().equals(principalId)) { |
| 438 | 0 | return this.toKimEntityInfo(pers); |
| 439 | |
} |
| 440 | |
} |
| 441 | 0 | return null; |
| 442 | |
} |
| 443 | |
|
| 444 | |
@Override |
| 445 | |
public KimEntityInfo getEntityInfoByPrincipalName(String principalName) { |
| 446 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 447 | 0 | if (pers.getPrincipalName().equals(principalName)) { |
| 448 | 0 | return this.toKimEntityInfo(pers); |
| 449 | |
} |
| 450 | |
} |
| 451 | 0 | return null; |
| 452 | |
} |
| 453 | |
|
| 454 | |
@Override |
| 455 | |
public EntityNameTypeInfo getEntityNameType(String code) { |
| 456 | 0 | for (EntityNameTypeEnum at : EntityNameTypeEnum.values()) { |
| 457 | 0 | if (at.getCode().equals(code)) { |
| 458 | 0 | EntityNameTypeInfo info = new EntityNameTypeInfo(); |
| 459 | 0 | info.setActive(at.isActive()); |
| 460 | 0 | info.setEntityNameTypeCode(at.getCode()); |
| 461 | 0 | info.setEntityNameTypeName(at.getName()); |
| 462 | 0 | info.setDisplaySortCode(at.getSort()); |
| 463 | 0 | info.setCode(at.getCode()); |
| 464 | 0 | info.setName(at.getName()); |
| 465 | 0 | return info; |
| 466 | |
} |
| 467 | |
} |
| 468 | 0 | return null; |
| 469 | |
} |
| 470 | |
|
| 471 | |
@Override |
| 472 | |
public KimEntityPrivacyPreferencesInfo getEntityPrivacyPreferences(String entityId) { |
| 473 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 474 | 0 | if (pers.getEntityId().equals(entityId)) { |
| 475 | 0 | return this.toKimEntityPrivacyPreferencesInfo(pers); |
| 476 | |
} |
| 477 | |
} |
| 478 | 0 | return null; |
| 479 | |
} |
| 480 | |
|
| 481 | |
@Override |
| 482 | |
public EntityTypeInfo getEntityType(String code) { |
| 483 | 0 | for (EntityTypeEnum typ : EntityTypeEnum.values()) { |
| 484 | 0 | if (typ.getCode().equals(code)) { |
| 485 | 0 | EntityTypeInfo info = new EntityTypeInfo(); |
| 486 | 0 | info.setActive(typ.isActive()); |
| 487 | 0 | info.setCode(typ.getCode()); |
| 488 | 0 | info.setDisplaySortCode(typ.getSort()); |
| 489 | 0 | info.setEntityTypeCode(typ.getCode()); |
| 490 | 0 | info.setEntityTypeName(typ.getName()); |
| 491 | 0 | info.setName(typ.getName()); |
| 492 | 0 | return info; |
| 493 | |
} |
| 494 | |
} |
| 495 | 0 | return null; |
| 496 | |
} |
| 497 | |
|
| 498 | |
@Override |
| 499 | |
public ExternalIdentifierTypeInfo getExternalIdentifierType(String code) { |
| 500 | 0 | for (ExternalIdentifierTypeEnum typ : ExternalIdentifierTypeEnum.values()) { |
| 501 | 0 | if (typ.getCode().equals(code)) { |
| 502 | 0 | ExternalIdentifierTypeInfo info = new ExternalIdentifierTypeInfo(); |
| 503 | 0 | info.setActive(typ.isActive()); |
| 504 | 0 | info.setCode(typ.getCode()); |
| 505 | 0 | info.setDisplaySortCode(typ.getSort()); |
| 506 | 0 | info.setExternalIdentifierTypeCode(typ.getCode()); |
| 507 | 0 | info.setExternalIdentifierTypeName(typ.getName()); |
| 508 | 0 | info.setName(typ.getName()); |
| 509 | 0 | return info; |
| 510 | |
} |
| 511 | |
} |
| 512 | 0 | return null; |
| 513 | |
} |
| 514 | |
|
| 515 | |
@Override |
| 516 | |
public PhoneTypeInfo getPhoneType(String code) { |
| 517 | 0 | for (PhoneTypeEnum typ : PhoneTypeEnum.values()) { |
| 518 | 0 | if (typ.getCode().equals(code)) { |
| 519 | 0 | PhoneTypeInfo info = new PhoneTypeInfo(); |
| 520 | 0 | info.setActive(typ.isActive()); |
| 521 | 0 | info.setCode(typ.getCode()); |
| 522 | 0 | info.setDisplaySortCode(typ.getSort()); |
| 523 | 0 | info.setPhoneTypeCode(typ.getCode()); |
| 524 | 0 | info.setPhoneTypeName(typ.getName()); |
| 525 | 0 | info.setName(typ.getName()); |
| 526 | 0 | return info; |
| 527 | |
} |
| 528 | |
} |
| 529 | 0 | return null; |
| 530 | |
} |
| 531 | |
|
| 532 | |
@Override |
| 533 | |
public KimPrincipalInfo getPrincipal(String principalId) { |
| 534 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 535 | 0 | if (pers.getPrincipalId().equals(principalId)) { |
| 536 | 0 | return this.toKimPrincipalInfo(pers); |
| 537 | |
} |
| 538 | |
} |
| 539 | 0 | return null; |
| 540 | |
} |
| 541 | |
|
| 542 | |
@Override |
| 543 | |
public KimPrincipalInfo getPrincipalByPrincipalName(String principalName) { |
| 544 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 545 | 0 | if (pers.getPrincipalName().equals(principalName)) { |
| 546 | 0 | return this.toKimPrincipalInfo(pers); |
| 547 | |
} |
| 548 | |
} |
| 549 | 0 | return null; |
| 550 | |
} |
| 551 | |
|
| 552 | |
@Override |
| 553 | |
public KimPrincipalInfo getPrincipalByPrincipalNameAndPassword(String principalName, |
| 554 | |
String password) { |
| 555 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 556 | 0 | if (pers.getPrincipalName().equals(principalName)) { |
| 557 | 0 | if (pers.getPassword().equals(password)) { |
| 558 | 0 | return this.toKimPrincipalInfo(pers); |
| 559 | |
} |
| 560 | |
} |
| 561 | |
} |
| 562 | 0 | return null; |
| 563 | |
} |
| 564 | |
|
| 565 | |
private void validate(Map<String, String> searchCriteria) |
| 566 | |
throws IllegalArgumentException { |
| 567 | 0 | DataProviderForKimEntityInfoImpl provider = new DataProviderForKimEntityInfoImpl(); |
| 568 | 0 | for (String key : searchCriteria.keySet()) { |
| 569 | 0 | if (!provider.supportsField(key)) { |
| 570 | 0 | throw new IllegalArgumentException("Search criteria " + key + " is not supported"); |
| 571 | |
} |
| 572 | |
} |
| 573 | |
|
| 574 | 0 | } |
| 575 | |
|
| 576 | |
@Override |
| 577 | |
public List<KimEntityDefaultInfo> lookupEntityDefaultInfo(Map<String, String> searchCriteria, |
| 578 | |
boolean unbounded) { |
| 579 | 0 | this.validate(searchCriteria); |
| 580 | 0 | List<KimEntityDefaultInfo> selected = new ArrayList<KimEntityDefaultInfo>(); |
| 581 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 582 | 0 | KimEntityInfo info = this.toKimEntityInfo(pers); |
| 583 | 0 | if (matchesAll(searchCriteria, info)) { |
| 584 | 0 | selected.add(this.toKimEntityDefaultInfo(pers)); |
| 585 | 0 | if (!unbounded) { |
| 586 | 0 | if (selected.size() >= this.boundedSearchMaxResults) { |
| 587 | 0 | return selected; |
| 588 | |
} |
| 589 | |
} |
| 590 | |
} |
| 591 | |
} |
| 592 | 0 | return selected; |
| 593 | |
} |
| 594 | |
|
| 595 | |
private boolean matchesAll(Map<String, String> searchCriteria, KimEntityInfo info) { |
| 596 | |
|
| 597 | 0 | for (String key : searchCriteria.keySet()) { |
| 598 | 0 | if (!matches(key, searchCriteria.get(key), info)) { |
| 599 | 0 | return false; |
| 600 | |
} |
| 601 | |
} |
| 602 | 0 | return true; |
| 603 | |
} |
| 604 | |
|
| 605 | |
private boolean matches(String key, String value, KimEntityInfo info) { |
| 606 | 0 | DataProviderForKimEntityInfoImpl provider = new DataProviderForKimEntityInfoImpl(); |
| 607 | 0 | List<Object> dataValues = provider.getValues(info, key); |
| 608 | 0 | return matches(key, value, dataValues); |
| 609 | |
} |
| 610 | |
|
| 611 | |
private boolean matches(String key, String value, List<Object> dataValues) { |
| 612 | |
|
| 613 | 0 | for (Object dataValue : dataValues) { |
| 614 | 0 | if (matches(key, value, dataValue)) { |
| 615 | 0 | return true; |
| 616 | |
} |
| 617 | |
} |
| 618 | 0 | return false; |
| 619 | |
} |
| 620 | |
|
| 621 | |
private boolean matches(String key, String value, Object dataValue) { |
| 622 | 0 | if (value == dataValue) { |
| 623 | 0 | return true; |
| 624 | |
} |
| 625 | 0 | if (value == null && dataValue == null) { |
| 626 | 0 | return true; |
| 627 | |
} |
| 628 | 0 | if (value == null) { |
| 629 | 0 | return false; |
| 630 | |
} |
| 631 | 0 | if (dataValue == null) { |
| 632 | 0 | return false; |
| 633 | |
} |
| 634 | 0 | if (value.equals(dataValue)) { |
| 635 | 0 | return true; |
| 636 | |
} |
| 637 | 0 | if (value.equalsIgnoreCase((String) dataValue)) { |
| 638 | 0 | return true; |
| 639 | |
} |
| 640 | |
|
| 641 | 0 | if (value.contains("*")) { |
| 642 | 0 | value = value.replace('*', '%'); |
| 643 | |
} |
| 644 | 0 | if (value.contains("%") || value.contains("_")) { |
| 645 | 0 | return CriteriaMatcherInMemory.matchesLike(((String) dataValue).toLowerCase(), value.toLowerCase()); |
| 646 | |
} |
| 647 | 0 | return false; |
| 648 | |
} |
| 649 | |
|
| 650 | |
@Override |
| 651 | |
public List<KimEntityInfo> lookupEntityInfo(Map<String, String> searchCriteria, |
| 652 | |
boolean unbounded) { |
| 653 | 0 | this.validate(searchCriteria); |
| 654 | 0 | List<KimEntityInfo> selected = new ArrayList<KimEntityInfo>(); |
| 655 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 656 | 0 | KimEntityInfo info = this.toKimEntityInfo(pers); |
| 657 | 0 | if (matchesAll(searchCriteria, info)) { |
| 658 | 0 | selected.add(this.toKimEntityInfo(pers)); |
| 659 | 0 | if (!unbounded) { |
| 660 | 0 | if (selected.size() >= this.boundedSearchMaxResults) { |
| 661 | 0 | return selected; |
| 662 | |
} |
| 663 | |
} |
| 664 | |
} |
| 665 | |
} |
| 666 | 0 | return selected; |
| 667 | |
} |
| 668 | |
|
| 669 | |
@Override |
| 670 | |
public int getMatchingEntityCount(Map<String, String> searchCriteria) { |
| 671 | 0 | this.validate(searchCriteria); |
| 672 | 0 | List<KimEntityInfo> selected = new ArrayList<KimEntityInfo>(); |
| 673 | 0 | for (PersonEnum pers : PersonEnum.values()) { |
| 674 | 0 | KimEntityInfo info = this.toKimEntityInfo(pers); |
| 675 | 0 | if (matchesAll(searchCriteria, info)) { |
| 676 | 0 | selected.add(this.toKimEntityInfo(pers)); |
| 677 | |
} |
| 678 | |
} |
| 679 | 0 | return selected.size(); |
| 680 | |
} |
| 681 | |
} |
| 682 | |
|