@Override public int compareTo(Address o) { if(o == null || o.getCountry() == null) { return 1; } if(getCountry() == null) { return -1; } return this.getCountry().compareTo(o.getCountry()); } }
public static void setPathToAddress(Address address, String orcid) { if(address != null) { address.setPath(ADDRESS.replace("{orcid}", orcid) + '/' + address.getPutCode()); } }
/** * Create an instance of {@link Address } * */ public Address createAddress() { return new Address(); }
private boolean isDuplicated(AddressEntity existing, Address address, SourceEntity source) { if (!existing.getId().equals(address.getPutCode())) { //If they have the same source String existingSourceId = existing.getElementSourceId(); if (!PojoUtil.isEmpty(existingSourceId) && existingSourceId.equals(SourceEntityUtils.getSourceId(source))) { if(existing.getIso2Country().equals(address.getCountry().getValue())) { return true; } } } return false; }
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()); existingAddress.setIso2Country(updatedOrNew.getCountry().getValue().name()); existingAddress.setDisplayIndex(updatedOrNew.getDisplayIndex()); addressDao.merge(existingAddress); newAddress.setVisibility(updatedOrNew.getVisibility().name()); newAddress.setDisplayIndex(updatedOrNew.getDisplayIndex()); addressDao.persist(newAddress);
@Generated(value = "com.sun.tools.xjc.Driver", date = "2018-04-24T11:17:38-05:00", comments = "JAXB RI v2.2.11") public String toString() { final ToStringStrategy strategy = JAXBToStringStrategy.INSTANCE; final StringBuilder buffer = new StringBuilder(); append(null, buffer, strategy); return buffer.toString(); }
public static void calculateLastModified(Addresses addresses) { if (addresses != null && addresses.getAddress() != null && !addresses.getAddress().isEmpty()) { LastModifiedDate latest = null; for (Address address : addresses.getAddress()) { if (address.getLastModifiedDate() != null && address.getLastModifiedDate().after(latest)) { latest = address.getLastModifiedDate(); } } addresses.setLastModifiedDate(latest); } }
@Generated(value = "com.sun.tools.xjc.Driver", date = "2018-04-24T11:17:38-05:00", comments = "JAXB RI v2.2.11") public StringBuilder append(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) { strategy.appendStart(locator, this, buffer); appendFields(locator, buffer, strategy); strategy.appendEnd(locator, this, buffer); return buffer; }
@Override public Address getPrimaryAddress(String orcid) { List<AddressEntity> addresses = addressDao.getAddresses(orcid, getLastModified(orcid)); Address address = null; if(addresses != null) { //Look for the address with the largest display index for(AddressEntity entity : addresses) { if(address == null || address.getDisplayIndex() < entity.getDisplayIndex()) { address = adapter.toAddress(entity); } } } return address; }
public static void validateAddress(Address address, SourceEntity sourceEntity, boolean createFlag, boolean isApiRequest, Visibility originalVisibility) { if(createFlag) { if(address.getPutCode() != null) { Map<String, String> params = new HashMap<String, String>(); if (sourceEntity != null) { params.put("clientName", SourceEntityUtils.getSourceName(sourceEntity)); } throw new InvalidPutCodeException(params); } } 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); }
for (AddressEntity existing : existingAddresses) { if(!existing.getId().equals(address.getPutCode())) { if (isDuplicated(existing, address, sourceEntity)) { Map<String, String> params = new HashMap<String, String>(); params.put("type", "address"); params.put("value", address.getCountry().getValue().value()); throw new OrcidDuplicatedElementException(params);
Address addr = (addresses != null && addresses.getAddress().size()>0)?addresses.getAddress().get(0):null; if (addr != null) { if (addr.getCountry() != null) { String countryCode = addr.getCountry().getValue().name();
Map<String, String> params = new HashMap<String, String>(); params.put("type", "address"); params.put("value", address.getCountry().getValue().value()); throw new OrcidDuplicatedElementException(params);
if (a.getCountry() != null && a.getCountry().getValue() !=null) doc.address.add(new SchemaOrgAddress(a.getCountry().getValue().toString()));