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);
}
}
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations