/** * @param location the location to set to * @since 1.9 */ public void setLocation(Location location) { if (location != null) { this.locationId = location.getLocationId(); } }
/** * @see org.openmrs.Attributable#serialize() */ @Override public String serialize() { if (getLocationId() != null) { return "" + getLocationId(); } else { return ""; } }
/** * @since 1.5 * @see org.openmrs.OpenmrsObject#getId() */ @Override public Integer getId() { return getLocationId(); }
/** * @see org.openmrs.api.db.LocationDAO#saveLocation(org.openmrs.Location) */ @Override public Location saveLocation(Location location) { if (location.getChildLocations() != null && location.getLocationId() != null) { // hibernate has a problem updating child collections // if the parent object was already saved so we do it // explicitly here for (Location child : location.getChildLocations()) { if (child.getLocationId() == null) { saveLocation(child); } } } sessionFactory.getCurrentSession().saveOrUpdate(location); return location; }
try { this.locationId = Context.getLocationService().getLocation(Integer.valueOf(locationId)) .getLocationId();
Location l = Context.getLocationService().getLocation(locationId); if (l != null) { return l.getLocationId(); log.debug("Couldn't find a location named '" + facility + "'"); return l == null ? null : l.getLocationId();
/** * @see LocationService#getLocationByUuid(String) */ @Test public void getLocationByUuid_shouldFindObjectGivenValidUuid() { String uuid = "f08ba64b-ea57-4a41-b33c-9dfc59b0c60a"; Location location = Context.getLocationService().getLocationByUuid(uuid); Assert.assertEquals(1, (int) location.getLocationId()); }
crit.add(Restrictions.eq("patient", searchCriteria.getPatient())); if (searchCriteria.getLocation() != null && searchCriteria.getLocation().getLocationId() != null) { crit.add(Restrictions.eq("location", searchCriteria.getLocation()));
query.setInteger("locationId", patientIdentifier.getLocation().getLocationId());
/** * You should be able to remove a tag from a location. * * @see LocationService#saveLocation(Location) */ @Test public void saveLocation_shouldRemoveLocationTagFromLocation() { LocationService ls = Context.getLocationService(); // Loading location with exactly 3 tags from the initialData.xml file Location location = ls.getLocation(1); // Removing a tag location.removeTag(location.getTags().iterator().next()); ls.saveLocation(location); Location newSavedLocation = ls.getLocation(location.getLocationId()); // Saved location should have 2 tag now assertEquals(2, newSavedLocation.getTags().size()); }
/** * You should be able to remove a child location from a location. * * @see LocationService#saveLocation(Location) */ @Test public void saveLocation_shouldRemoveChildLocationFromLocation() { LocationService ls = Context.getLocationService(); // Retrieving a location with initially 2 child locations Location location = ls.getLocation(1); // Removing a child location.removeChildLocation(location.getChildLocations().iterator().next()); ls.saveLocation(location); Location newSavedLocation = ls.getLocation(location.getLocationId()); // Saved location should have 1 child locations now assertEquals(1, newSavedLocation.getChildLocations().size()); }
/** * Make sure that purging a location removes the row from the database * * @see LocationService#purgeLocation(Location) */ @Test public void purgeLocation_shouldDeleteLocationSuccessfully() { LocationService ls = Context.getLocationService(); // fetch the encounter to delete from the db Location locationToDelete = ls.getLocation(4); ls.purgeLocation(locationToDelete); // try to refetch the location. should get a null object Location l = ls.getLocation(locationToDelete.getLocationId()); assertNull("We shouldn't find the location after deletion", l); }
/** * You should be able to add a transient tag with an existing tag name. * * @see LocationService#saveLocation(Location) */ @Test public void saveLocation_shouldOverwriteTransientTagIfTagWithSameNameExists() { LocationService ls = Context.getLocationService(); // First, create a new Location Location location = new Location(); location.setName("name"); location.setDescription("is a location"); // Add a transient tag with an existing name location.addTag(new LocationTag("General Hospital", null)); ls.saveLocation(location); Location newSavedLocation = ls.getLocation(location.getLocationId()); // Saved parent location should have exactly 1 tag assertEquals(1, newSavedLocation.getTags().size()); // Tag must be overwritten with tag with locationTagId == 1 assertNotNull("Location tag should have an ID now", newSavedLocation.getTags().iterator().next().getLocationTagId()); assertEquals(1, newSavedLocation.getTags().iterator().next().getLocationTagId().intValue()); }
Location newestLoc = ls.getLocation(location.getLocationId());
public long findLocationId(String location) throws SystemException { long locId = 1; List<Location> locationList = LocationLocalServiceUtil.getLocations(-1,-1); for(Location findLoc : locationList) { if(location == findLoc.getLocationName()) { locId = findLoc.getLocationId(); break; } } return locId; }
public long findLocationId(String location) throws SystemException { long locId = 1; // but i suggest to put -1 List<Location> locationList = LocationLocalServiceUtil.getLocations(-1,-1); for(Location findLoc : locationList) { if(location == findLoc.getLocationName()) { return findLoc.getLocationId(); } } return locId; }
Location newSavedLocation = ls.getLocation(location.getLocationId()); assertNotNull(childA.getLocationId()); assertNotNull(childB.getLocationId());
ls.saveLocation(location); Location newSavedLocation = ls.getLocation(location.getLocationId());
/** * Test to make sure that a simple save to a new location gets persisted to the database * * @see LocationService#saveLocation(Location) */ @Test public void saveLocation_shouldCreateLocationSuccessfully() { Location location = new Location(); location.setName("testing"); location.setDescription("desc"); location.setAddress1("123"); location.setAddress1("456"); location.setCityVillage("city"); location.setStateProvince("state"); location.setCountry("country"); location.setPostalCode("post"); location.setLatitude("lat"); location.setLongitude("lon"); LocationService ls = Context.getLocationService(); ls.saveLocation(location); Location newSavedLocation = ls.getLocation(location.getLocationId()); assertNotNull("The saved location should have an id now", location.getLocationId()); assertNotNull("We should get back a location", newSavedLocation); assertTrue("The created location needs to equal the pojo location", location.equals(newSavedLocation)); }
/** * @see VisitService#saveVisit(Visit) */ @Test public void saveVisit_shouldUpdateAnExistingVisitInTheDatabase() { Visit visit = visitService.getVisit(2); assertNull(visit.getLocation());//this is the field we are editing assertNull(visit.getChangedBy()); assertNull(visit.getDateChanged()); visit.setLocation(Context.getLocationService().getLocation(1)); visit = visitService.saveVisit(visit); Context.flushSession(); assertNotNull(visit.getChangedBy()); assertNotNull(visit.getDateChanged()); assertEquals(Integer.valueOf(1), visit.getLocation().getLocationId()); }