Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ___________________________________________________________________________________________
- In UserContext
- ___________________________________________________________________________________________
- private void setUserLocation() {
- if (this.user != null) {
- String locationId = this.user.getUserProperty(OpenmrsConstants.USER_PROPERTY_DEFAULT_LOCATION);
- if (StringUtils.isNotBlank(locationId)) {
- //only go ahead if it has actually changed OR if wasn't set before
- if (this.locationId == null || !this.locationId.getName().equalsIgnoreCase(locationId)) {
- try {
- this.locationId = Context.getLocationService().getLocationId(Integer.valueOf(locationId));
- }
- catch (NumberFormatException e) {
- //Drop the stored value since we have no match for the set id
- if (this.locationId != null)
- this.locationId = null;
- log.warn("The value of the default Location property of the user with id:" + this.user.getUserId()
- + " should be an integer", e);
- }
- }
- } else {
- if (this.locationId != null)
- this.locationId = null;
- }
- }
- }
- ______________________________________________________________________________
- In Location Service
- _______________________________________________________________________________
- /**
- * Returns locationId from Location object
- *
- * @param locationId
- * @return LocationId
- * @since 1.5
- */
- @Authorized(PrivilegeConstants.GET_LOCATIONS)
- public Integer getLocationId(Integer locationId);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement