Guest User

Untitled

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