Advertisement
Guest User

Untitled

a guest
Jan 21st, 2013
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. private void setUserLocation() {
  2. if (this.user != null) {
  3. String locationId = this.user.getUserProperty(OpenmrsConstants.USER_PROPERTY_DEFAULT_LOCATION);
  4. if (StringUtils.isNotBlank(locationId)) {
  5. //only go ahead if it has actually changed OR if wasn't set before
  6. if (this.locationId == null || !this.locationId.getName().equalsIgnoreCase(locationId)) {
  7. try {
  8. this.locationId = Context.getLocationService().getLocation(locationId);
  9. }
  10. catch (NumberFormatException e) {
  11. //Drop the stored value since we have no match for the set id
  12. if (this.locationId != null)
  13. this.locationId = null;
  14. log.warn("The value of the default Location property of the user with id:" + this.user.getUserId()
  15. + " should be an integer", e);
  16. }
  17. }
  18. } else {
  19. if (this.locationId != null)
  20. this.locationId = null;
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement