/** * @see org.openmrs.customdatatype.SingleCustomValue#getValueReference() * * @since 1.9 */ @Override public String getValueReference() { return getPropertyValue(); }
@Override public boolean isDatabaseStringComparisonCaseSensitive() { GlobalProperty gp = (GlobalProperty) sessionFactory.getCurrentSession().get(GlobalProperty.class, OpenmrsConstants.GP_CASE_SENSITIVE_DATABASE_STRING_COMPARISON); if (gp != null) { return Boolean.valueOf(gp.getPropertyValue()); } else { return true; } } }
/** * @see org.openmrs.api.db.AdministrationDAO#getGlobalProperty(java.lang.String) */ @Override public String getGlobalProperty(String propertyName) throws DAOException { GlobalProperty gp = getGlobalPropertyObject(propertyName); // if no gp exists, return a null value if (gp == null) { return null; } return gp.getPropertyValue(); }
/** * @see org.openmrs.api.GlobalPropertyListener#globalPropertyChanged(org.openmrs.GlobalProperty) */ @Override public void globalPropertyChanged(GlobalProperty newValue) { allowedLocales = new LinkedHashSet<>(); for (String allowedLocaleString : newValue.getPropertyValue().split(",")) { Locale allowedLocale = LocaleUtility.fromSpecification(allowedLocaleString.trim()); if (allowedLocale != null) { allowedLocales.add(allowedLocale); } } }
/** * @see java.lang.Object#toString() */ @Override public String toString() { return "property: " + getProperty() + " value: " + getPropertyValue(); }
@Override public void globalPropertyChanged(GlobalProperty newValue) { PersonName.setFormat(newValue.getPropertyValue()); }
/** * @see org.openmrs.api.GlobalPropertyListener#globalPropertyChanged(org.openmrs.GlobalProperty) */ @Override public void globalPropertyChanged(GlobalProperty newValue) { if (!OpenmrsConstants.GLOBAL_PROPERTY_ADDRESS_TEMPLATE.equals(newValue.getProperty())) { return; } try { setAddressTemplate(newValue.getPropertyValue()); } catch (Exception ex) { log.error("Error in new xml global property value", ex); setAddressTemplate(new ArrayList<>()); } }
/** * Returns all modules that are marked as mandatory. Currently this means there is a * <moduleid>.mandatory=true global property. * * @return list of modules ids for mandatory modules * @should return mandatory module ids */ public static List<String> getMandatoryModules() { List<String> mandatoryModuleIds = new ArrayList<>(); try { List<GlobalProperty> props = Context.getAdministrationService().getGlobalPropertiesBySuffix(".mandatory"); for (GlobalProperty prop : props) { if ("true".equalsIgnoreCase(prop.getPropertyValue())) { mandatoryModuleIds.add(prop.getProperty().replace(".mandatory", "")); } } } catch (Exception e) { log.warn("Unable to get the mandatory module list", e); } return mandatoryModuleIds; }
String gpTextValue = globalProperty.getPropertyValue(); if (StringUtils.isBlank(gpTextValue)) { throw new APIException("GlobalProperty.invalid.value",
/** * @see org.openmrs.api.db.AdministrationDAO#saveGlobalProperty(org.openmrs.GlobalProperty) */ @Override public GlobalProperty saveGlobalProperty(GlobalProperty gp) throws DAOException { GlobalProperty gpObject = getGlobalPropertyObject(gp.getProperty()); if (gpObject != null) { gpObject.setPropertyValue(gp.getPropertyValue()); gpObject.setDescription(gp.getDescription()); sessionFactory.getCurrentSession().update(gpObject); return gpObject; } else { sessionFactory.getCurrentSession().save(gp); return gp; } }
if (gp.getPropertyValue() != null) { List<Locale> localeList = new ArrayList<>(); for (String localeString : gp.getPropertyValue().split(",")) { localeList.add(LocaleUtility.fromSpecification(localeString.trim())); && gp.getPropertyValue() != null) { if (!localeList.contains(LocaleUtility.fromSpecification(gp.getPropertyValue().trim()))) { String value = gp.getPropertyValue(); gp.setPropertyValue(LocaleUtility.getDefaultLocale().toString()); throw new APIException((Context.getMessageSourceService().getMessage(
if (gp != null && StringUtils.hasLength(gp.getPropertyValue())) { String currentDbVersion = gp.getPropertyValue(); if (log.isDebugEnabled()) { log.debug("version:column " + version + ":" + currentDbVersion); gp = new GlobalProperty(key, version, description); as.saveGlobalProperty(gp); } else if (!gp.getPropertyValue().equals(version)) { log.info("Updating global property " + key + " to version: " + version); gp.setDescription(description);
@Test public void parse_shouldParseGlobalPropertyContainingElementsNotIncludedInGlobalProperty() throws IOException { GlobalProperty gp1 = new GlobalProperty("report.deleteReportsAgeInHours", "72", "delete reports after"); Document config = buildOnValidConfigXml() .withGlobalProperty(gp1.getProperty(), gp1.getPropertyValue(), gp1.getDescription(), null, null) .build(); config.getElementsByTagName("globalProperty").item(0).appendChild(config.createElement("ignoreMe")); Module module = parser.parse(writeConfigXmlToFile(config)); assertThat(module.getGlobalProperties().size(), is(1)); assertThat(module.getGlobalProperties().get(0).getProperty(), is(gp1.getProperty())); assertThat(module.getGlobalProperties().get(0).getPropertyValue(), is(gp1.getPropertyValue())); assertThat(module.getGlobalProperties().get(0).getDescription(), is(gp1.getDescription())); }
String propVal = prop.getPropertyValue(); if (propVal != null && propVal.contains(oldTypeName)) { prop.setPropertyValue(propVal.replaceFirst(oldTypeName, newTypeName));
@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")); } }
@Test public void parse_shouldParseGlobalProperty() throws IOException { GlobalProperty gp1 = new GlobalProperty("report.deleteReportsAgeInHours", "72", "delete reports after hours"); GlobalProperty gp2 = new GlobalProperty("report.validateInput", "2", "to validate input", RegexValidatedTextDatatype.class, "^\\d+$"); Document config = buildOnValidConfigXml() .withGlobalProperty(gp1.getProperty(), gp1.getPropertyValue(), gp1.getDescription(), null, null) .withGlobalProperty(gp2.getProperty(), gp2.getPropertyValue(), gp2.getDescription(), gp2.getDatatypeClassname(), gp2.getDatatypeConfig()) .build(); Module module = parser.parse(writeConfigXmlToFile(config)); assertThat(module.getGlobalProperties().size(), is(2)); assertThat(module.getGlobalProperties().get(0).getProperty(), is(gp1.getProperty())); assertThat(module.getGlobalProperties().get(0).getPropertyValue(), is(gp1.getPropertyValue())); assertThat(module.getGlobalProperties().get(0).getDescription(), is(gp1.getDescription())); assertThat(module.getGlobalProperties().get(0).getDatatypeClassname(), is(gp1.getDatatypeClassname())); assertThat(module.getGlobalProperties().get(0).getDatatypeConfig(), is(gp1.getDatatypeConfig())); assertThat(module.getGlobalProperties().get(1).getProperty(), is(gp2.getProperty())); assertThat(module.getGlobalProperties().get(1).getPropertyValue(), is(gp2.getPropertyValue())); assertThat(module.getGlobalProperties().get(1).getDescription(), is(gp2.getDescription())); assertThat(module.getGlobalProperties().get(1).getDatatypeClassname(), is(gp2.getDatatypeClassname())); assertThat(module.getGlobalProperties().get(1).getDatatypeConfig(), is(gp2.getDatatypeConfig())); }
@Test public void saveGlobalProperty_shouldOverwriteGlobalPropertyIfExists() { executeDataSet(ADMIN_INITIAL_DATA_XML); GlobalProperty gp = adminService.getGlobalPropertyObject("a_valid_gp_key"); assertEquals("correct-value", gp.getPropertyValue()); gp.setPropertyValue("new-even-more-correct-value"); adminService.saveGlobalProperty(gp); assertEquals("new-even-more-correct-value", adminService.getGlobalProperty("a_valid_gp_key")); }
@RequestMapping(value = "module/manage", method = RequestMethod.POST) public String processSubmit(@RequestParam(value = "errors", required = false) String ignoredExceprions, BindingResult result, SessionStatus status) { boolean successSave = false; GlobalProperty glProp = Context.getAdministrationService().getGlobalPropertyObject( ErrorLoggingConstants.ERRROR_LOGGING_GP_IGNORED_EXCEPTION); if (glProp != null) { glProp.setPropertyValue(ignoredExceprions); GlobalProperty saved = Context.getAdministrationService().saveGlobalProperty(glProp); System.out.println(saved.getPropertyValue()); if (saved != null && saved.getPropertyValue().equals(ignoredExceprions)) { successSave = true; } } status.setComplete(); return "module/manage"; }
/** * Gets the value of the global property delegate * * @param instance the delegate instance to get the value off * @return value object */ @PropertyGetter("value") public static Object getValue(GlobalProperty globalProperty) { if (StringUtils.isNotEmpty(globalProperty.getDatatypeClassname()) && StringUtils.isNotEmpty(globalProperty.getDatatypeConfig())) { return globalProperty.getValue(); } else { return globalProperty.getPropertyValue(); } }
/** * @see ConceptService#saveConcept(Concept) */ @Test public void saveConcept_shouldSetAPreferredNameForEachLocaleIfNoneIsMarked() { //add some other locales to locale.allowed.list for testing purposes GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject( OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST); gp.setPropertyValue(gp.getPropertyValue().concat(",fr,ja,en_GB")); Context.getAdministrationService().saveGlobalProperty(gp); Concept concept = new Concept(); concept.addName(new ConceptName("name1", Locale.ENGLISH)); concept.addName(new ConceptName("name2", Locale.ENGLISH)); concept.addName(new ConceptName("name3", Locale.FRENCH)); concept.addName(new ConceptName("name4", Locale.FRENCH)); concept.addName(new ConceptName("name5", Locale.JAPANESE)); concept.addName(new ConceptName("name6", Locale.JAPANESE)); concept.addDescription(new ConceptDescription("some description",null)); concept.setDatatype(new ConceptDatatype(1)); concept.setConceptClass(new ConceptClass(1)); concept = Context.getConceptService().saveConcept(concept); Assert.assertNotNull(concept.getPreferredName(Locale.ENGLISH)); Assert.assertNotNull(concept.getPreferredName(Locale.FRENCH)); Assert.assertNotNull(concept.getPreferredName(Locale.JAPANESE)); }