/** * @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; }
if (address.getDateCreated() == null) { sessionFactory.getCurrentSession().evict(address); } else {
pa3.setAddress1(pa1.getAddress1()); pa3.setAddress2(pa1.getAddress2()); pa3.setDateCreated(pa1.getDateCreated()); pa3.setVoided(false); assertTrue("There should be only 2 address in the person object now", p.getAddresses().size() == 2); pa3.setDateCreated(new Date(pa1.getDateCreated().getTime() + 1)); p.addAddress(pa3);
private static void copyAddressFields(PersonAddress existingAddress, PersonAddress address) { existingAddress.setPreferred(address.getPreferred()); existingAddress.setAddress1(address.getAddress1()); existingAddress.setAddress2(address.getAddress2()); existingAddress.setAddress3(address.getAddress3()); existingAddress.setAddress4(address.getAddress4()); existingAddress.setAddress5(address.getAddress5()); existingAddress.setAddress6(address.getAddress6()); existingAddress.setCityVillage(address.getCityVillage()); existingAddress.setCountry(address.getCountry()); existingAddress.setStateProvince(address.getStateProvince()); existingAddress.setCountyDistrict(address.getCountyDistrict()); existingAddress.setPostalCode(address.getPostalCode()); existingAddress.setLatitude(address.getLatitude()); existingAddress.setLongitude(address.getLongitude()); existingAddress.setDateCreated(address.getDateCreated()); }