use of org.openmrs.api.AdministrationService in project openmrs-module-pihcore by PIH.
the class PihCoreActivator method setGlobalProperty.
protected void setGlobalProperty(String propertyName, String propertyValue) {
AdministrationService administrationService = Context.getAdministrationService();
GlobalProperty gp = administrationService.getGlobalPropertyObject(propertyName);
if (gp == null) {
gp = new GlobalProperty(propertyName);
}
gp.setPropertyValue(propertyValue);
administrationService.saveGlobalProperty(gp);
}
use of org.openmrs.api.AdministrationService in project openmrs-core by openmrs.
the class ConceptServiceImpl method getConceptClassesOfOrderTypes.
private List<ConceptClass> getConceptClassesOfOrderTypes() {
List<ConceptClass> mappedClasses = new ArrayList<>();
AdministrationService administrationService = Context.getAdministrationService();
List<List<Object>> result = administrationService.executeSQL("SELECT DISTINCT concept_class_id FROM order_type_class_map", true);
for (List<Object> temp : result) {
for (Object value : temp) {
if (value != null) {
mappedClasses.add(this.getConceptClass((Integer) value));
}
}
}
return mappedClasses;
}
use of org.openmrs.api.AdministrationService in project openmrs-core by openmrs.
the class PersonServiceImpl method getGlobalProperties.
private List<String> getGlobalProperties(String... properties) {
List<String> result = new ArrayList<>();
AdministrationService as = Context.getAdministrationService();
for (String p : properties) {
String id = as.getGlobalProperty(p, "");
if (StringUtils.isNotBlank(id)) {
result.add(id.trim());
}
}
return result;
}
use of org.openmrs.api.AdministrationService in project openmrs-core by openmrs.
the class UserValidatorTest method validate_shouldFailValidationIfEmailAsUsernameDisabledAndEmailProvided.
/**
* @see UserValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfEmailAsUsernameDisabledAndEmailProvided() {
User user = new User();
user.setUsername("test@example.com");
AdministrationService as = Context.getAdministrationService();
as.saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_USER_REQUIRE_EMAIL_AS_USERNAME, "false"));
Errors errors = new BindException(user, "user");
validator.validate(user, errors);
Assert.assertTrue(errors.hasFieldErrors("username"));
}
use of org.openmrs.api.AdministrationService in project openmrs-core by openmrs.
the class UserValidatorTest method validate_shouldFailValidationIfEmailAsUsernameEnabledAndEmailInvalid.
/**
* @see UserValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfEmailAsUsernameEnabledAndEmailInvalid() {
User user = new User();
user.setUsername("test@example.com");
AdministrationService as = Context.getAdministrationService();
as.saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_USER_REQUIRE_EMAIL_AS_USERNAME, "true"));
Errors errors = new BindException(user, "user");
validator.validate(user, errors);
Assert.assertFalse(errors.hasFieldErrors("username"));
}
Aggregations