use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class AdministrationServiceImpl method updateGlobalProperty.
/**
* @see org.openmrs.api.AdministrationService#updateGlobalProperty(java.lang.String,
* java.lang.String)
*/
@Override
public void updateGlobalProperty(String propertyName, String propertyValue) throws IllegalStateException {
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject(propertyName);
if (gp == null) {
throw new IllegalStateException("Global property with the given propertyName does not exist" + propertyName);
}
gp.setPropertyValue(propertyValue);
dao.saveGlobalProperty(gp);
}
use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class LocationUtilityTest method getDefaultLocation_shouldReturnTheUpdatedDefaultLocationWhenTheValueOfTheGlobalPropertyIsChanged.
/**
* @see LocationUtility#getDefaultLocation()
*/
@Test
public void getDefaultLocation_shouldReturnTheUpdatedDefaultLocationWhenTheValueOfTheGlobalPropertyIsChanged() {
// sanity check
Assert.assertEquals("Unknown Location", LocationUtility.getDefaultLocation().getName());
GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCATION_NAME, "Xanadu", "Testing");
Context.getAdministrationService().saveGlobalProperty(gp);
Assert.assertEquals("Xanadu", LocationUtility.getDefaultLocation().getName());
}
use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class EncounterServiceTest method saveEncounter_shouldAssignEncounterToVisitIfTheAssignToExistingHandlerIsRegistered.
/**
* @see EncounterService#saveEncounter(Encounter)
*/
@Test
public void saveEncounter_shouldAssignEncounterToVisitIfTheAssignToExistingHandlerIsRegistered() {
Encounter encounter = buildEncounter();
// We should have no visit
assertNull(encounter.getVisit());
GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject(OpenmrsConstants.GP_VISIT_ASSIGNMENT_HANDLER);
gp.setPropertyValue("org.openmrs.api.handler.ExistingVisitAssignmentHandler");
Context.getAdministrationService().saveGlobalProperty(gp);
Context.getEncounterService().saveEncounter(encounter);
// We should have a visit.
assertNotNull(encounter.getVisit());
assertNotNull(encounter.getVisit().getVisitId());
}
use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class EncounterServiceTest method getActiveEncounterVisitHandler_shouldReturnBeanHaveBeenRegisteredWithGivenName.
@Test
public void getActiveEncounterVisitHandler_shouldReturnBeanHaveBeenRegisteredWithGivenName() {
String correctBeanName = OpenmrsConstants.REGISTERED_COMPONENT_NAME_PREFIX + "existingOrNewVisitAssignmentHandler";
GlobalProperty visitHandlerProperty = new GlobalProperty(OpenmrsConstants.GP_VISIT_ASSIGNMENT_HANDLER, correctBeanName);
Context.getAdministrationService().saveGlobalProperty(visitHandlerProperty);
EncounterVisitHandler activeEncounterVisitHandler = Context.getEncounterService().getActiveEncounterVisitHandler();
Assert.assertNotNull(activeEncounterVisitHandler);
}
use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class EncounterServiceTest method unretireEncounterType_shouldThrowErrorWhenTryingToUnretireEncounterTypeWhenEncounterTypesAreLocked.
/**
* @see EncounterService#unretireEncounterType(EncounterType)
*/
@Test(expected = EncounterTypeLockedException.class)
public void unretireEncounterType_shouldThrowErrorWhenTryingToUnretireEncounterTypeWhenEncounterTypesAreLocked() {
EncounterService encounterService = Context.getEncounterService();
EncounterType encounterType = Context.getEncounterService().getEncounterType(2);
GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_ENCOUNTER_TYPES_LOCKED);
gp.setPropertyValue("true");
Context.getAdministrationService().saveGlobalProperty(gp);
encounterService.unretireEncounterType(encounterType);
}
Aggregations