Search in sources :

Example 1 with ProcessUpdateBo

use of org.mifos.application.accounting.business.ProcessUpdateBo 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 2 with ProcessUpdateBo

use of org.mifos.application.accounting.business.ProcessUpdateBo in project head by mifos.

the class AccountingDaoHibernate method updateLastProcessUpdatedDate.

@Override
public void updateLastProcessUpdatedDate(Date lastProcessDate, String globalOfficeNumber) {
    Query q = createdNamedQuery("getLastProcessUpdateDate");
    q.setString("GLOBAL_OFFICE_NUMBER", globalOfficeNumber);
    List<ProcessUpdateBo> list = q.list();
    if (list.size() > 0) {
        ProcessUpdateBo processUpdateBo = list.get(0);
        processUpdateBo.setLastUpdateDate(lastProcessDate);
        try {
            createOrUpdate(processUpdateBo);
        } catch (PersistenceException e) {
            throw new MifosRuntimeException(e);
        }
    } else {
        try {
            ProcessUpdateBo processUpdateBo = new ProcessUpdateBo();
            processUpdateBo.setGlobalOfficeNumber(globalOfficeNumber);
            processUpdateBo.setLastUpdateDate(lastProcessDate);
            save(processUpdateBo);
        } catch (PersistenceException e) {
            throw new MifosRuntimeException(e);
        }
    }
}
Also used : Query(org.hibernate.Query) ProcessUpdateBo(org.mifos.application.accounting.business.ProcessUpdateBo) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

Query (org.hibernate.Query)2 ProcessUpdateBo (org.mifos.application.accounting.business.ProcessUpdateBo)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ConfigurationKeyValue (org.mifos.config.business.ConfigurationKeyValue)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1