public LocationMock(Location loc) { setAddress1(loc.getAddress1()); setAddress2(loc.getAddress2()); setChangedBy(loc.getChangedBy()); setChildLocations(loc.getChildLocations(true)); setCityVillage(loc.getCityVillage()); setCountry(loc.getCountry()); setCountyDistrict(loc.getCountyDistrict()); setCreator(loc.getCreator()); setDateChanged(loc.getDateChanged()); setDateCreated(loc.getDateCreated()); setDateRetired(loc.getDateRetired()); setDescription(loc.getDescription()); setId(loc.getId()); setLatitude(loc.getLatitude()); setLongitude(loc.getLongitude()); setName(loc.getName()); setNeighborhoodCell(loc.getNeighborhoodCell()); setParentLocation(loc.getParentLocation()); setPostalCode(loc.getPostalCode()); setRegion(loc.getRegion()); setRetired(loc.getRetired()); setRetiredBy(loc.getRetiredBy()); setRetireReason(loc.getRetireReason()); setStateProvince(loc.getStateProvince()); setSubregion(loc.getSubregion()); setTags(loc.getTags()); setTownshipDivision(loc.getTownshipDivision()); setUuid(loc.getUuid()); }
/** * Looks at location, and if necessary its ancestors in the location hierarchy, until it finds one * tagged with "Visit Location" * * @param location * @return location, or an ancestor * @throws IllegalArgumentException if neither location nor its ancestors support visits */ @Override public Location getLocationThatSupportsVisits(Location location) { if (location == null) { throw new IllegalArgumentException("Location does not support visits"); } else if (location.hasTag(EmrApiConstants.LOCATION_TAG_SUPPORTS_VISITS)) { return location; } else { return getLocationThatSupportsVisits(location.getParentLocation()); } }
/** * @param a * @param b * @return true if a.equals(b) or a is an ancestor of b. */ private boolean isSameOrAncestor(Location a, Location b) { if (a == null || b == null) { return a == null && b == null; } return a.equals(b) || isSameOrAncestor(a, b.getParentLocation()); }