Advertisement
Guest User

Untitled

a guest
Jan 21st, 2013
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. ___________________________________________________________________________________________
  2. In UserContext
  3. ___________________________________________________________________________________________
  4.  
  5. private void setUserLocation() {
  6. if (this.user != null) {
  7. String locationId = this.user.getUserProperty(OpenmrsConstants.USER_PROPERTY_DEFAULT_LOCATION);
  8. if (StringUtils.isNotBlank(locationId)) {
  9. //only go ahead if it has actually changed OR if wasn't set before
  10. if (this.locationId == null || !this.locationId.getName().equalsIgnoreCase(locationId)) {
  11. try {
  12. this.locationId = Context.getLocationService().getLocationId(Integer.valueOf(locationId));
  13. }
  14. catch (NumberFormatException e) {
  15. //Drop the stored value since we have no match for the set id
  16. if (this.locationId != null)
  17. this.locationId = null;
  18. log.warn("The value of the default Location property of the user with id:" + this.user.getUserId()
  19. + " should be an integer", e);
  20. }
  21. }
  22. } else {
  23. if (this.locationId != null)
  24. this.locationId = null;
  25. }
  26. }
  27. }
  28.  
  29.  
  30.  
  31. ______________________________________________________________________________
  32. In Location Service
  33. _______________________________________________________________________________
  34.  
  35. /**
  36. * Returns locationId from Location object
  37. *
  38. * @param locationId
  39. * @return LocationId
  40. * @since 1.5
  41. */
  42. @Authorized(PrivilegeConstants.GET_LOCATIONS)
  43. public Integer getLocationId(Integer locationId);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement