Search in sources :

Example 46 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class StandardTestingService method setAccountingRules.

@Override
public void setAccountingRules(String accountingRulesParamName, String accountingRulesParamValue) throws MifosException {
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    if (accountingRulesParamValue == null || accountingRulesParamValue.equals("")) {
        configMgr.clearProperty(accountingRulesParamName);
        return;
    }
    configMgr.setProperty(accountingRulesParamName, accountingRulesParamValue);
}
Also used : MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Example 47 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class StandardTestingService method setLocale.

@Override
public void setLocale(String languageCode, String countryCode) throws MifosException {
    try {
        LocaleSetting configLocale = new LocaleSetting();
        configLocale.setLanguageCode(languageCode);
        configLocale.setCountryCode(countryCode);
        Localization localization = Localization.getInstance();
        localization.setConfigLocale(configLocale);
        if (SecurityContextHolder.getContext() != null) {
            if (SecurityContextHolder.getContext().getAuthentication() != null) {
                if (SecurityContextHolder.getContext().getAuthentication().getPrincipal() != null) {
                    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
                    user.setPreferredLocaleId(Localization.getInstance().getLocaleId(Localization.getInstance().getConfiguredLocale()));
                }
            }
        }
        StaticHibernateUtil.startTransaction();
        PersonnelBO p = (PersonnelBO) StaticHibernateUtil.getSessionTL().get(PersonnelBO.class, (short) 1);
        p.setPreferredLocale(Localization.getInstance().getConfiguredLocaleId());
        StaticHibernateUtil.getSessionTL().update(p);
        StaticHibernateUtil.commitTransaction();
        MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
        configMgr.setProperty("Localization.LanguageCode", languageCode);
        configMgr.setProperty("Localization.CountryCode", countryCode);
    } catch (MifosRuntimeException e) {
        throw new MifosException("The locale " + languageCode + "_" + countryCode + " is not supported by Mifos.");
    }
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MifosException(org.mifos.core.MifosException) LocaleSetting(org.mifos.config.LocaleSetting) MifosUser(org.mifos.security.MifosUser) Localization(org.mifos.config.Localization) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 48 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class ClientFamilyInfoConfig method getMaximumNumberOfFamilyMembers.

public static int getMaximumNumberOfFamilyMembers() throws ConfigurationException {
    //default value is 15
    int familyMembers = 15;
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    if (configMgr.containsKey(MaximumNumberOfFamilyMembers)) {
        familyMembers = configMgr.getInt(MaximumNumberOfFamilyMembers);
    } else {
        throw new ConfigurationException("The Maximum Number of Family Members are not defined in " + MifosConfigurationManager.DEFAULT_CONFIG_PROPS_FILENAME);
    }
    return familyMembers;
}
Also used : ConfigurationException(org.mifos.config.exceptions.ConfigurationException) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Example 49 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class ClientFamilyInfoConfig method getAreFamilyDetailsRequired.

public static Boolean getAreFamilyDetailsRequired() throws ConfigurationException {
    //default value is false
    Boolean required = false;
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    if (configMgr.containsKey(AreFamilyDetailsRequired)) {
        required = configMgr.getBoolean(AreFamilyDetailsRequired);
    } else {
        throw new ConfigurationException("The property are family details required is not set in " + MifosConfigurationManager.DEFAULT_CONFIG_PROPS_FILENAME);
    }
    return required;
}
Also used : ConfigurationException(org.mifos.config.exceptions.ConfigurationException) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Example 50 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class ClientRules method getMaximumAge.

/*
     * Gets the minimum age specified in the application configuration file,
     * Also Checks if its in the range of 0 to 150
     */
public static int getMaximumAge() throws ConfigurationException {
    int maximumAge = 0;
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    if (configMgr.containsKey(ClientRules.MaximumAgeForNewClients)) {
        maximumAge = Integer.parseInt(configMgr.getString(ClientRules.MaximumAgeForNewClients));
    } else {
        throw new ConfigurationException("The Maximum Age for a client is not defined in " + MifosConfigurationManager.DEFAULT_CONFIG_PROPS_FILENAME);
    }
    if (maximumAge > 150 || maximumAge < 0) {
        throw new ConfigurationException("The Maximum Age defined in the " + MifosConfigurationManager.DEFAULT_CONFIG_PROPS_FILENAME + "is not within the acceptable range (0 to 150)");
    }
    return maximumAge;
}
Also used : ConfigurationException(org.mifos.config.exceptions.ConfigurationException) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Aggregations

MifosConfigurationManager (org.mifos.config.business.MifosConfigurationManager)66 Test (org.junit.Test)18 ConfigurationException (org.mifos.config.exceptions.ConfigurationException)8 Properties (java.util.Properties)5 MifosRuntimeException (org.mifos.core.MifosRuntimeException)5 PersistenceException (org.mifos.framework.exceptions.PersistenceException)5 ApplicationException (org.mifos.framework.exceptions.ApplicationException)4 RoundingMode (java.math.RoundingMode)3 ConfigurationPersistence (org.mifos.config.persistence.ConfigurationPersistence)3 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)3 SystemException (org.mifos.framework.exceptions.SystemException)3 BigDecimal (java.math.BigDecimal)2 Ignore (org.junit.Ignore)2 AccountBO (org.mifos.accounts.business.AccountBO)2 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)2 ConfigurationKeyValue (org.mifos.config.business.ConfigurationKeyValue)2 CurrencyMismatchException (org.mifos.core.CurrencyMismatchException)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1