public static void setPathToAddress(Address address, String orcid) { if(address != null) { address.setPath(ADDRESS.replace("{orcid}", orcid) + '/' + address.getPutCode()); } }
public static void validateAddress(Address address, Source activeSource, boolean createFlag, boolean isApiRequest, Visibility originalVisibility) { if(createFlag) { if(address.getPutCode() != null) { throw InvalidPutCodeException.forSource(activeSource); } } else { if(address.getPutCode() == null) { Map<String, String> params = new HashMap<String, String>(); throw new PutCodeRequiredException(params); } } if(address.getCountry() == null || address.getCountry().getValue() == null) { String message = "Country cannot be null"; LOGGER.error(message); throw new OrcidValidationException(message); } //Check that we are not changing the visibility validateAndFixVisibility(address, createFlag, isApiRequest, originalVisibility); }
private boolean isDuplicated(AddressEntity existing, Address address, Source activeSource) { if (!existing.getId().equals(address.getPutCode())) { //If they have the same source String existingSourceId = existing.getElementSourceId(); if (!PojoUtil.isEmpty(existingSourceId) && SourceEntityUtils.isTheSameForDuplicateChecking(activeSource,existing)) { //TODO: Not sure this works! String vs Iso3166Country enum if(existing.getIso2Country().equals(address.getCountry().getValue())) { return true; } } } return false; }
for (AddressEntity existing : existingAddresses) { if(!existing.getId().equals(address.getPutCode())) { if (isDuplicated(existing, address, activeSource)) { Map<String, String> params = new HashMap<String, String>();
if(addresses.getAddress() != null) { for(Address updatedOrNew : addresses.getAddress()) { if(existingAddress.getId().equals(updatedOrNew.getPutCode())) { deleteMe = false; break; if(updatedOrNew.getPutCode() != null) { if(existingAddress.getId().equals(updatedOrNew.getPutCode())) { existingAddress.setLastModified(new Date()); existingAddress.setVisibility(updatedOrNew.getVisibility().name());
if (address.getPutCode() != null) { form.setPutCode(String.valueOf(address.getPutCode()));