@Test public void getGlobalPropertiesByPrefix_shouldReturnAllRelevantGlobalPropertiesInTheDatabase() { executeDataSet("org/openmrs/api/include/AdministrationServiceTest-globalproperties.xml"); List<GlobalProperty> properties = adminService.getGlobalPropertiesByPrefix("fake.module."); for (GlobalProperty property : properties) { assertTrue(property.getProperty().startsWith("fake.module.")); assertTrue(property.getPropertyValue().startsWith("correct-value")); } }
/** * @return */ @ModelAttribute("globalPropertiesModel") public GlobalPropertiesModel getModel() { List<GlobalProperty> editableProps = new ArrayList<GlobalProperty>(); Set<String> props = new LinkedHashSet<String>(); props.add(RestConstants.URI_PREFIX_GLOBAL_PROPERTY_NAME); props.add(RestConstants.ALLOWED_IPS_GLOBAL_PROPERTY_NAME); props.add(RestConstants.MAX_RESULTS_DEFAULT_GLOBAL_PROPERTY_NAME); props.add(RestConstants.MAX_RESULTS_ABSOLUTE_GLOBAL_PROPERTY_NAME); //remove the properties we dont want to edit for (GlobalProperty gp : Context.getAdministrationService().getGlobalPropertiesByPrefix(RestConstants.MODULE_ID)) { if (props.contains(gp.getProperty())) editableProps.add(gp); } return new GlobalPropertiesModel(editableProps); }
/** * GlobalProperty searches support the following additional query parameters: * * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(RequestContext) */ @Override protected PageableResult doSearch(RequestContext context) { AdministrationService service = Context.getAdministrationService(); List<GlobalProperty> searchResults; searchResults = service.getGlobalPropertiesByPrefix(context.getParameter("q")); PageableResult result = new NeedsPaging<GlobalProperty>(searchResults, context); return result; }