/** * @since 1.5 * @see org.openmrs.OpenmrsObject#getId() */ @Override public Integer getId() { return getPersonAddressId(); }
/** * @see java.lang.Comparable#compareTo(java.lang.Object) * Note: this comparator imposes orderings that are inconsistent with equals. */ @Override @SuppressWarnings("squid:S1210") public int compareTo(PersonAddress other) { int retValue = 0; if (other != null) { retValue = getVoided().compareTo(other.getVoided()); if (retValue == 0) { retValue = other.getPreferred().compareTo(getPreferred()); } if (retValue == 0 && getDateCreated() != null) { retValue = OpenmrsUtil.compareWithNullAsLatest(getDateCreated(), other.getDateCreated()); } if (retValue == 0) { retValue = OpenmrsUtil.compareWithNullAsGreatest(getPersonAddressId(), other.getPersonAddressId()); } // if we've gotten this far, just check all address values. If they are // equal, leave the objects at 0. If not, arbitrarily pick retValue=1 // and return that (they are not equal). if (retValue == 0 && !equalsContent(other)) { retValue = 1; } } return retValue; }
/** * @see PersonService#getPersonAddressByUuid(String) */ @Test public void getPersonAddressByUuid_shouldFindObjectGivenValidUuid() throws Exception { String uuid = "3350d0b5-821c-4e5e-ad1d-a9bce331e118"; PersonAddress personAddress = Context.getPersonService().getPersonAddressByUuid(uuid); Assert.assertEquals(2, (int) personAddress.getPersonAddressId()); }
preferred.addAddress(tmpAddress); mergedData.addCreatedAddress(tmpAddress.getUuid()); log.debug("Merging address " + newAddress.getPersonAddressId() + " to " + preferred.getPatientId());
/** * Sets the preferred address for a person. If no address exists new address is set as * preferred. * * @param instance * @param address * @throws ResourceDoesNotSupportOperationException */ @PropertySetter("preferredAddress") public static void setPreferredAddress(Person instance, PersonAddress address) throws ResourceDoesNotSupportOperationException { if (address.getPersonAddressId() == null) { throw new ResourceDoesNotSupportOperationException("Only an existing address can be marked as preferred!"); } //un mark the current preferred address as preferred if any for (PersonAddress existing : instance.getAddresses()) { if (existing.isPreferred() && !OpenmrsUtil.nullSafeEquals(existing, address)) existing.setPreferred(false); } address.setPreferred(true); }