Search in sources :

Example 6 with ConfigurationKeyValue

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

the class AccountingDaoHibernate method updateLastProcessDate.

public void updateLastProcessDate(Date lastProcessDate) {
    Query q = createdNamedQuery("getConfigurationKeyValueByKey");
    q.setString("KEY", "MisProcessing");
    List<ConfigurationKeyValue> list = q.list();
    if (list.size() > 0) {
        ConfigurationKeyValue configurationKeyValue = list.get(0);
        configurationKeyValue.setValue(DateUtils.format(lastProcessDate));
        try {
            createOrUpdate(configurationKeyValue);
        } catch (PersistenceException e) {
            throw new MifosRuntimeException(e);
        }
    }
}
Also used : Query(org.hibernate.Query) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ConfigurationKeyValue(org.mifos.config.business.ConfigurationKeyValue) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 7 with ConfigurationKeyValue

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

the class MonthClosingServiceFacadeWebTier method getMonthClosingDate.

@Override
public Date getMonthClosingDate() {
    ConfigurationKeyValue configurationKeyValue = configurationPersistence.getConfigurationKeyValue(MONTH_CLOSING_DAY_CONFIG_KEY);
    Date monthClosingDay = null;
    if (configurationKeyValue != null) {
        monthClosingDay = DateUtils.getDateAsRetrievedFromDb(configurationKeyValue.getValue());
    }
    return monthClosingDay;
}
Also used : ConfigurationKeyValue(org.mifos.config.business.ConfigurationKeyValue) Date(java.util.Date)

Example 8 with ConfigurationKeyValue

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

the class ClientCustActionFormTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    form = new ClientCustActionForm();
    errors = new ActionErrors();
    ConfigurationKeyValue groupCanApplyLoansKey = new ConfigurationKeyValue(ClientRules.GroupCanApplyLoansKey, 1);
    ConfigurationKeyValue clientCanExistOutsideGroupKey = new ConfigurationKeyValue(ClientRules.ClientCanExistOutsideGroupKey, 1);
    ConfigurationPersistence configPersistence = mock(ConfigurationPersistence.class);
    when(configPersistence.getConfigurationKeyValue(ClientRules.GroupCanApplyLoansKey)).thenReturn(groupCanApplyLoansKey);
    when(configPersistence.getConfigurationKeyValue(ClientRules.ClientCanExistOutsideGroupKey)).thenReturn(clientCanExistOutsideGroupKey);
    ClientRules.setConfigPersistence(configPersistence);
    minimumAgeForNewClientBeforeTestRun = ClientRules.getMinimumAgeForNewClient();
    maximumAgeForNewClientBeforeTestRun = ClientRules.getMaximumAgeForNewClient();
    ageCheckSettingBeforeTestRun = ClientRules.isAgeCheckEnabled();
}
Also used : ConfigurationPersistence(org.mifos.config.persistence.ConfigurationPersistence) ConfigurationKeyValue(org.mifos.config.business.ConfigurationKeyValue) ActionErrors(org.apache.struts.action.ActionErrors)

Example 9 with ConfigurationKeyValue

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

the class ConfigurationPersistence method createOrUpdateConfigurationKeyValueString.

public void createOrUpdateConfigurationKeyValueString(String key, String value) throws PersistenceException {
    ConfigurationKeyValue keyValue = getConfigurationKeyValue(key);
    if (keyValue == null) {
        keyValue = new ConfigurationKeyValue(key, value);
    } else if (ConfigurationKeyValue.Type.TEXT.getTypeId().equals(keyValue.getType())) {
        keyValue.setValue(value);
    } else {
        throw new RuntimeException("Invalid configuration type for key: " + "'" + key + "'");
    }
    createOrUpdate(keyValue);
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) ConfigurationKeyValue(org.mifos.config.business.ConfigurationKeyValue)

Example 10 with ConfigurationKeyValue

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

the class ConfigurationPersistence method getConfigurationKeyValue.

public ConfigurationKeyValue getConfigurationKeyValue(String key) {
    HashMap<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put(KEY_QUERY_PARAMETER, key);
    try {
        return (ConfigurationKeyValue) execUniqueResultNamedQuery(NamedQueryConstants.GET_CONFIGURATION_KEYVALUE_BY_KEY, queryParameters);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : HashMap(java.util.HashMap) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ConfigurationKeyValue(org.mifos.config.business.ConfigurationKeyValue) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

ConfigurationKeyValue (org.mifos.config.business.ConfigurationKeyValue)12 MifosRuntimeException (org.mifos.core.MifosRuntimeException)5 Query (org.hibernate.Query)3 ConfigurationPersistence (org.mifos.config.persistence.ConfigurationPersistence)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 MifosConfigurationManager (org.mifos.config.business.MifosConfigurationManager)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 ActionErrors (org.apache.struts.action.ActionErrors)1 ProcessUpdateBo (org.mifos.application.accounting.business.ProcessUpdateBo)1