/** * @see org.openmrs.api.LocationService#saveAddressTemplate(String) */ @Override public void saveAddressTemplate(String xml) throws APIException { Context.getAdministrationService().setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_ADDRESS_TEMPLATE, xml); }
/** * @see org.openmrs.api.AdministrationService#purgeGlobalProperties(java.util.List) */ @Override public void purgeGlobalProperties(List<GlobalProperty> globalProperties) throws APIException { for (GlobalProperty globalProperty : globalProperties) { Context.getAdministrationService().purgeGlobalProperty(globalProperty); } }
@Override public String getDefaultLayoutFormat() { String ret = Context.getAdministrationService().getGlobalProperty("layout.name.format"); return (ret != null && ret.length() > 0) ? ret : defaultLayoutFormat; } }
@Override public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(getAdministrationService().getGlobalProperty("mail.user"), getAdministrationService().getGlobalProperty("mail.password")); } };
MatchMode getAttributeMatchMode() { AdministrationService adminService = Context.getAdministrationService(); String matchModeProperty = adminService.getGlobalProperty( OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATTRIBUTE_SEARCH_MATCH_MODE, ""); return (matchModeProperty.equals(OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATTRIBUTE_SEARCH_MATCH_ANYWHERE)) ? MatchMode.ANYWHERE : MatchMode.EXACT; }
/** * Returns the location of the OpenMRS log file. * * @return the path to the OpenMRS log file * @since 1.9.2 */ public static String getOpenmrsLogLocation() { String logPathGP = Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GP_LOG_LOCATION, ""); File logPath = OpenmrsUtil.getDirectoryInApplicationDataDirectory(logPathGP); File logFile = new File(logPath, "openmrs.log"); return logFile.getPath(); }
/** * @see org.openmrs.api.db.ContextDAO#setupSearchIndex() */ @Override public void setupSearchIndex() { String gp = Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GP_SEARCH_INDEX_VERSION, ""); if (!OpenmrsConstants.SEARCH_INDEX_VERSION.toString().equals(gp)) { updateSearchIndex(); } }
@Override public void checkIfFormsAreLocked() { String locked = Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_FORMS_LOCKED, "false"); if (Boolean.valueOf(locked)) { throw new FormsLockedException(); } }
@Override public void checkIfPersonAttributeTypesAreLocked() { String locked = Context.getAdministrationService() .getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATRIBUTE_TYPES_LOCKED, "false"); if (Boolean.valueOf(locked)) { throw new PersonAttributeTypeLockedException(); } } }
@Override public Concept getNonCodedDrugConcept() { String conceptUuid = Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GP_DRUG_ORDER_DRUG_OTHER); if (StringUtils.hasText(conceptUuid)) { return Context.getConceptService().getConceptByUuid(conceptUuid); } return null; }
/** * @see AdministrationService#getSearchLocales() */ @Override @Transactional(readOnly = true) public List<Locale> getSearchLocales(){ //call it via interface, so cache interceptor is invoked return Context.getAdministrationService().getSearchLocales(Context.getLocale(), Context.getAuthenticatedUser()); }
@Before public void setUp() { SessionFactory sessionFactory = (SessionFactory) applicationContext.getBean("sessionFactory"); Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Patient.class); patientSearchCriteria = new PatientSearchCriteria(sessionFactory, criteria); globalPropertiesTestHelper = new GlobalPropertiesTestHelper(Context.getAdministrationService()); }
/** * Creates a new Global Property to lock person attribute types by setting its value * @param propertyValue value for person attribute types locked GP */ public void createPersonAttributeTypeLockedGPAndSetValue(String propertyValue) { GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATRIBUTE_TYPES_LOCKED); gp.setPropertyValue(propertyValue); Context.getAdministrationService().saveGlobalProperty(gp); }
/** * Creates a new Global Property to lock patient identifier types by setting its value * * @param propertyValue value for patient identifier types locked GP */ public void createPatientIdentifierTypeLockedGPAndSetValue(String propertyValue) { GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_IDENTIFIER_TYPES_LOCKED); gp.setPropertyValue(propertyValue); Context.getAdministrationService().saveGlobalProperty(gp); }
/** * @see LocaleUtility#getDefaultLocale() */ @Test public void getDefaultLocale_shouldNotReturnNullIfGlobalPropertyDoesNotExist() { // sanity check Assert.assertNull(Context.getAdministrationService().getGlobalProperty( OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCALE)); // check for nonnullness Assert.assertNotNull(LocaleUtility.getDefaultLocale()); }
@Test(expected = APIException.class) public void getActiveEncounterVisitHandler_shouldThrowIfBeanWithGivenTypeAndNameNotFound() { String incorrectBeanName = OpenmrsConstants.REGISTERED_COMPONENT_NAME_PREFIX + "invalidName"; GlobalProperty visitHandlerProperty = new GlobalProperty(OpenmrsConstants.GP_VISIT_ASSIGNMENT_HANDLER, incorrectBeanName); Context.getAdministrationService().saveGlobalProperty(visitHandlerProperty); Context.getEncounterService().getActiveEncounterVisitHandler(); }
@Before public void setup() { allergies = new Allergies(); executeDataSet(ALLERGY_OTHER_NONCODED_TEST_DATASET); Allergen.setOtherNonCodedConceptUuid(Context.getAdministrationService().getGlobalProperty( OpenmrsConstants.GP_ALLERGEN_OTHER_NON_CODED_UUID)); }
/** * @see LocaleUtility#getDefaultLocale() */ @Test public void getDefaultLocale_shouldNotFailWithEmptyGlobalPropertyValue() { Context.getAdministrationService().saveGlobalProperty( new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCALE, "")); // check for nonnullness Assert.assertNotNull(LocaleUtility.getDefaultLocale()); }
@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); }
@Before public void runBeforeEachTest() { executeDataSet(CREATE_PATIENT_PROGRAMS_XML); executeDataSet(PROGRAM_ATTRIBUTES_XML); if (pws == null) { pws = Context.getProgramWorkflowService(); adminService = Context.getAdministrationService(); encounterService = Context.getEncounterService(); cs = Context.getConceptService(); } }