Search in sources :

Example 11 with ConfigurationException

use of org.mifos.config.exceptions.ConfigurationException in project head by mifos.

the class FinancialInitializer method loadCOA.

/**
     * Reads chart of accounts from a configuration file and inserts into the
     * database. Deleting accounts is not currently supported, but if the user
     * tries to do this (by leaving it out of the custom chart of accounts
     * config file), there is currently no error reported.
     * <p>
     * QUESION: what if custom config was missing entries from default config,
     * but then is moved _out_ of the app server classpath?
     * <p>
     * ANSWER: once ChartOfAccountsConfig.isLoaded() returns true, <em>only
     * the custom CoA config file will be considered</em>. Using the custom
     * config will be the only way to add new accounts after the initial CoA
     * data is loaded in the database.
     */
public static void loadCOA() throws FinancialException {
    Session session = StaticHibernateUtil.getSessionTL();
    final String coaLocation;
    try {
        if (!ChartOfAccountsConfig.canLoadCoa(session)) {
            logger.info("Chart of accounts data will not be modified since " + "the custom chart of accounts configuration file was " + "not found on the classpath.");
            return;
        }
        coaLocation = ChartOfAccountsConfig.getCoaUri(session);
        logger.info("going to load or modify chart of accounts " + "configuration from " + coaLocation);
    } catch (IOException e) {
        throw new FinancialException("Charts of accounts loading failed", e);
    }
    ChartOfAccountsConfig coa;
    try {
        coa = ChartOfAccountsConfig.load(coaLocation);
    } catch (ConfigurationException e) {
        throw new FinancialException(coaLocation + " loading failed", e);
    }
    LegacyAccountDao ap = ApplicationContextProvider.getBean(LegacyAccountDao.class);
    for (GLAccount glAccount : coa.getGLAccounts()) {
        Short accountId = ap.getAccountIdFromGlCode(glAccount.glCode);
        if (null == accountId) {
            logger.info("Adding new general ledger account: " + glAccount);
            ap.addGeneralLedgerAccount(glAccount.name, glAccount.glCode, glAccount.parentGlCode, glAccount.categoryType);
        } else {
            COABO account = (COABO) session.load(COABO.class, accountId);
            if (account.getCategoryType() != glAccount.categoryType) {
                throw new FinancialException("category type change not supported");
            }
            if (!accountHierarchyMatch(account, glAccount)) {
                throw new FinancialException("chart of accounts hierarchy change not supported");
            }
            if (!account.getAccountName().equals(glAccount.name)) {
                logger.info("updating general ledger account name. code=" + account.getGlCode() + ". old name=" + account.getAccountName() + ", new name=" + glAccount.name);
                ap.updateAccountName(account, glAccount.name);
            }
        }
    }
}
Also used : ChartOfAccountsConfig(org.mifos.config.ChartOfAccountsConfig) ConfigurationException(org.mifos.config.exceptions.ConfigurationException) LegacyAccountDao(org.mifos.accounts.persistence.LegacyAccountDao) COABO(org.mifos.accounts.financial.business.COABO) GLAccount(org.mifos.config.GLAccount) IOException(java.io.IOException) FinancialException(org.mifos.accounts.financial.exceptions.FinancialException) Session(org.hibernate.Session)

Example 12 with ConfigurationException

use of org.mifos.config.exceptions.ConfigurationException 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 13 with ConfigurationException

use of org.mifos.config.exceptions.ConfigurationException 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 14 with ConfigurationException

use of org.mifos.config.exceptions.ConfigurationException 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)

Example 15 with ConfigurationException

use of org.mifos.config.exceptions.ConfigurationException in project head by mifos.

the class PasswordRules method getPasswordExpirationDatePrelongationFromConfig.

private static int getPasswordExpirationDatePrelongationFromConfig() throws ConfigurationException {
    int passwordExpirationDateProlongation = 90;
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    if (configMgr.containsKey(PASSWORD_EXPIRATION_DATE_PRELONGATION)) {
        passwordExpirationDateProlongation = Integer.parseInt(configMgr.getString(PASSWORD_EXPIRATION_DATE_PRELONGATION));
    }
    if (passwordExpirationDateProlongation < 0) {
        throw new ConfigurationException("The PasswordRules.PasswordExpirationDatePrelongation defined in the " + MifosConfigurationManager.DEFAULT_CONFIG_PROPS_FILENAME + " must be a positive numer.");
    }
    return passwordExpirationDateProlongation;
}
Also used : ConfigurationException(org.mifos.config.exceptions.ConfigurationException) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Aggregations

ConfigurationException (org.mifos.config.exceptions.ConfigurationException)18 MifosConfigurationManager (org.mifos.config.business.MifosConfigurationManager)8 IOException (java.io.IOException)3 LegacyAccountDao (org.mifos.accounts.persistence.LegacyAccountDao)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 ArrayList (java.util.ArrayList)2 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)2 FinancialException (org.mifos.accounts.financial.exceptions.FinancialException)2 LegacyLoanDao (org.mifos.accounts.loan.persistance.LegacyLoanDao)2 AccountSearchResultsDto (org.mifos.accounts.util.helpers.AccountSearchResultsDto)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)2 CustomerDao (org.mifos.customers.persistence.CustomerDao)2 CustomerSearchResultDto (org.mifos.dto.domain.CustomerSearchResultDto)2 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)2 QueryResult (org.mifos.framework.hibernate.helper.QueryResult)2 InputStream (java.io.InputStream)1 Iterator (java.util.Iterator)1 Locale (java.util.Locale)1 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)1