Search in sources :

Example 1 with ConfigurationKeyValue

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

the class ConfigurationPersistence method updateConfigurationKeyValueInteger.

/**
     * Update the value of a persistent integer configuration value;
     */
public void updateConfigurationKeyValueInteger(String key, int value) throws PersistenceException {
    ConfigurationKeyValue keyValue = getConfigurationKeyValue(key);
    if (keyValue != null && ConfigurationKeyValue.Type.INTEGER.getTypeId().equals(keyValue.getType())) {
        keyValue.setValue(Integer.toString(value));
        createOrUpdate(keyValue);
    } else {
        throw new RuntimeException("Configuration parameter not found for key: " + "'" + key + "'");
    }
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) ConfigurationKeyValue(org.mifos.config.business.ConfigurationKeyValue)

Example 2 with ConfigurationKeyValue

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

the class ConfigurationPersistence method getConfigurationKeyValueWithoutFlush.

public ConfigurationKeyValue getConfigurationKeyValueWithoutFlush(String key) {
    HashMap<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put(KEY_QUERY_PARAMETER, key);
    try {
        return (ConfigurationKeyValue) execUniqueResultNamedQueryWithoutFlush(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)

Example 3 with ConfigurationKeyValue

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

the class ConfigurationPersistence method addConfigurationKeyValueInteger.

/**
     * Create a new persistent integer configuration key value pair.
     */
public void addConfigurationKeyValueInteger(String key, int value) throws PersistenceException {
    ConfigurationKeyValue keyValue = new ConfigurationKeyValue(key, value);
    createOrUpdate(keyValue);
}
Also used : ConfigurationKeyValue(org.mifos.config.business.ConfigurationKeyValue)

Example 4 with ConfigurationKeyValue

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

the class AccountingDaoHibernate method findLastProcessingUpdatedDate.

@Override
public String findLastProcessingUpdatedDate(String namedQueryString, String globalOfficeNumber) {
    String lastProcessingDate = null;
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");
    Query query = createdNamedQuery(namedQueryString);
    query.setString("GLOBAL_OFFICE_NUMBER", globalOfficeNumber);
    List<ProcessUpdateBo> list = query.list();
    if (list.size() == 0) {
        Query q = createdNamedQuery("getConfigurationKeyValueByKey");
        q.setString("KEY", "MisProcessing");
        List<ConfigurationKeyValue> value = q.list();
        if (value.size() > 0) {
            ConfigurationKeyValue configurationKeyValue = value.get(0);
            lastProcessingDate = configurationKeyValue.getValue();
        }
    } else if (list.size() > 0 && !"".equals(list.get(0).getLastUpdateDate())) {
        ProcessUpdateBo processUpdateBo = list.get(0);
        if (processUpdateBo.getLastUpdateDate() != null) {
            lastProcessingDate = simpleDateFormat.format(processUpdateBo.getLastUpdateDate());
        }
    }
    return lastProcessingDate;
}
Also used : Query(org.hibernate.Query) ProcessUpdateBo(org.mifos.application.accounting.business.ProcessUpdateBo) ConfigurationKeyValue(org.mifos.config.business.ConfigurationKeyValue) SimpleDateFormat(java.text.SimpleDateFormat)

Example 5 with ConfigurationKeyValue

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

the class AccountingDaoHibernate method findLastProcessingDate.

@Override
public String findLastProcessingDate(String namedQueryString) {
    String lastProcessingDate = null;
    Query query = createdNamedQuery(namedQueryString);
    query.setString("KEY", "MisProcessing");
    List<ConfigurationKeyValue> list = query.list();
    if (list.size() > 0 && !"".equals(list.get(0).getValue())) {
        ConfigurationKeyValue configurationKeyValue = list.get(0);
        lastProcessingDate = configurationKeyValue.getValue();
    }
    return lastProcessingDate;
}
Also used : Query(org.hibernate.Query) ConfigurationKeyValue(org.mifos.config.business.ConfigurationKeyValue)

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