/** * @should recognise short name * @should recognise long name */ Boolean isShortName(String name) { Integer minChars = Context.getAdministrationService().getGlobalPropertyValue( OpenmrsConstants.GLOBAL_PROPERTY_MIN_SEARCH_CHARACTERS, OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_MIN_SEARCH_CHARACTERS); if (name != null && name.length() < minChars) { return Boolean.TRUE; } else { return Boolean.FALSE; } }
String dateTimeFormat = Context.getAdministrationService().getGlobalPropertyValue( OpenmrsConstants.GP_SEARCH_DATE_DISPLAY_FORMAT, null); if (StringUtils.isEmpty(dateTimeFormat)) { String timeFormat = Context.getAdministrationService().getGlobalPropertyValue( OpenmrsConstants.GP_SEARCH_DATE_DISPLAY_FORMAT, null); if (StringUtils.isEmpty(timeFormat)) { String formatValue = Context.getAdministrationService().getGlobalPropertyValue( OpenmrsConstants.GP_SEARCH_DATE_DISPLAY_FORMAT, ""); if (StringUtils.isEmpty(formatValue)) {
@Test(expected = IllegalArgumentException.class) public void getGlobalPropertyValue_shouldFailIfDefaultValueIsNull() { adminService.getGlobalPropertyValue("valid.double", null); }
String value = Context.getAdministrationService().getGlobalPropertyValue( OpenmrsConstants.GP_ENCOUNTER_TYPE_TO_VISIT_TYPE_MAPPING, "");
@Test public void getGlobalPropertyValue_shouldReturnDefaultValueForMissingProperty() { // put the global property into the database executeDataSet("org/openmrs/api/include/AdministrationServiceTest-globalproperties.xml"); Object value = adminService.getGlobalPropertyValue("does.not.exist", 1234); assertEquals(1234, value); }
@Test public void getGlobalPropertyValue_shouldReturnValueInTheSpecifiedIntegerType() { // put the global property into the database executeDataSet("org/openmrs/api/include/AdministrationServiceTest-globalproperties.xml"); Object value = adminService.getGlobalPropertyValue("valid.integer", 4); assertTrue(value instanceof Integer); assertEquals(1234, value); }
@Test public void getGlobalPropertyValue_shouldReturnValueInTheSpecifiedDoubleType() { // put the global property into the database executeDataSet("org/openmrs/api/include/AdministrationServiceTest-globalproperties.xml"); Object retValue = adminService.getGlobalPropertyValue("valid.double", 4.34); assertTrue(retValue instanceof Double); assertEquals(1234.54, retValue); }
private void validateForRequireDrug(Errors errors, DrugOrder order) { //Reject if global property is set to specify a formulation for drug order boolean requireDrug = Context.getAdministrationService().getGlobalPropertyValue( OpenmrsConstants.GLOBAL_PROPERTY_DRUG_ORDER_REQUIRE_DRUG, false); OrderService orderService = Context.getOrderService(); if(requireDrug){ if(order.getConcept() != null && OpenmrsUtil.nullSafeEquals(orderService.getNonCodedDrugConcept(), order.getConcept())){ if(order.getDrug() == null && !order.isNonCodedDrug()){ errors.rejectValue("drugNonCoded", "DrugOrder.error.drugNonCodedIsRequired"); } else if(order.getDrug() != null){ errors.rejectValue("concept", "DrugOrder.error.onlyOneOfDrugOrNonCodedShouldBeSet"); } }else{ if(order.getDrug() == null && !order.isNonCodedDrug()){ errors.rejectValue("drug", "DrugOrder.error.drugIsRequired"); } else if(order.getDrug() != null && order.isNonCodedDrug()){ errors.rejectValue("concept", "DrugOrder.error.onlyOneOfDrugOrNonCodedShouldBeSet"); } } } }