Search in sources :

Example 1 with CustomerDao

use of org.mifos.customers.persistence.CustomerDao in project head by mifos.

the class CenterPersistence method createCenter.

/**
     * @deprecated use {@link CustomerDao#save(org.mifos.customers.business.CustomerBO)} with {@link CustomerBO} static
     *             factory methods.
     */
@Deprecated
public CenterBO createCenter(UserContext userContext, CenterTemplate template) throws Exception {
    OfficeBO centerOffice = officePersistence.getOffice(template.getOfficeId());
    PersonnelBO loanOfficer = legacyPersonnelDao.getPersonnel(template.getLoanOfficerId());
    MeetingBO meeting = template.getMeeting();
    CenterBO center = CenterBO.createNew(userContext, template.getDisplayName(), new DateTime(template.getMfiJoiningDate()), meeting, loanOfficer, centerOffice, template.getAddress(), template.getExternalId(), new DateMidnight().toDateTime());
    CustomerDao customerDao = ApplicationContextProvider.getBean(CustomerDao.class);
    try {
        StaticHibernateUtil.startTransaction();
        customerDao.save(center);
        center.generateGlobalCustomerNumber();
        customerDao.save(center);
        StaticHibernateUtil.commitTransaction();
    } catch (Exception e) {
        StaticHibernateUtil.rollbackTransaction();
    } finally {
        StaticHibernateUtil.closeSession();
    }
    return center;
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) DateMidnight(org.joda.time.DateMidnight) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBO(org.mifos.customers.center.business.CenterBO) CustomerDao(org.mifos.customers.persistence.CustomerDao) DateTime(org.joda.time.DateTime) CustomerException(org.mifos.customers.exceptions.CustomerException) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 2 with CustomerDao

use of org.mifos.customers.persistence.CustomerDao in project head by mifos.

the class ProcessFlowRules method initFromDB.

public static void initFromDB() {
    MifosConfigurationManager cm = MifosConfigurationManager.getInstance();
    CustomerDao customerDao = ApplicationContextProvider.getBean(CustomerDao.class);
    LegacyAccountDao ap = ApplicationContextProvider.getBean(LegacyAccountDao.class);
    CustomerStatusEntity cse = customerDao.findClientPendingStatus();
    cm.setProperty(CLIENT_PENDING_APPROVAL, isClientPendingApprovalStateEnabledOnDatabaseConfiguration(cse));
    cse = customerDao.findGroupPendingStatus();
    cm.setProperty(GROUP_PENDING_APPROVAL, isGroupPendingApprovalStateEnabledOnDatabaseConfiguration(cse));
    AccountStateEntity ase = ap.loadPersistentObject(AccountStateEntity.class, AccountState.LOAN_PENDING_APPROVAL.getValue());
    cm.setProperty(LOAN_PENDING_APPROVAL, isLoanPendingApprovalStateEnabledOnDatabaseConfig(ase));
    ase = ap.loadPersistentObject(AccountStateEntity.class, AccountState.SAVINGS_PENDING_APPROVAL.getValue());
    cm.setProperty(SAVINGS_PENDING_APPROVAL, isSavingPendingApprovalStateEnabledOnDatabaseConfig(ase));
}
Also used : LegacyAccountDao(org.mifos.accounts.persistence.LegacyAccountDao) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) CustomerDao(org.mifos.customers.persistence.CustomerDao) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Example 3 with CustomerDao

use of org.mifos.customers.persistence.CustomerDao in project head by mifos.

the class ProcessFlowRules method initGroupPendingApprovalState.

private static void initGroupPendingApprovalState() throws ConfigurationException {
    CustomerDao customerDao = ApplicationContextProvider.getBean(CustomerDao.class);
    CustomerStatusEntity cse = customerDao.findGroupPendingStatus();
    boolean fromDb = isGroupPendingApprovalStateEnabledOnDatabaseConfiguration(cse);
    boolean fromCfg = isGroupPendingApprovalStateEnabled();
    if (databaseAndCustomConfigurationAreNotTheSame(fromDb, fromCfg)) {
        int count = customerDao.countOfGroups();
        if (count > 0) {
            final String errMsg = getBadOverrideMsg(GROUP_PENDING_APPROVAL, "Records for groups in the 'pending approval' state" + " may already exist.");
            throw new ConfigurationException(errMsg);
        }
        makeDatabaseConfigurationMatchPropertiesFileConfiguration(customerDao, cse, fromCfg);
    }
}
Also used : ConfigurationException(org.mifos.config.exceptions.ConfigurationException) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CustomerDao(org.mifos.customers.persistence.CustomerDao)

Example 4 with CustomerDao

use of org.mifos.customers.persistence.CustomerDao in project head by mifos.

the class ProcessFlowRules method initClientPendingApprovalState.

private static void initClientPendingApprovalState() throws ConfigurationException {
    CustomerDao customerDao = ApplicationContextProvider.getBean(CustomerDao.class);
    CustomerStatusEntity cse = customerDao.findClientPendingStatus();
    boolean fromDb = isClientPendingApprovalStateEnabledOnDatabaseConfiguration(cse);
    boolean fromCfg = isClientPendingApprovalStateEnabled();
    if (databaseAndCustomConfigurationAreNotTheSame(fromDb, fromCfg)) {
        int count = customerDao.countOfClients();
        if (count > 0) {
            final String errMsg = getBadOverrideMsg(CLIENT_PENDING_APPROVAL, "Records for clients in the 'pending approval' state" + " may already exist.");
            throw new ConfigurationException(errMsg);
        }
        makeDatabaseConfigurationMatchPropertiesFileConfiguration(customerDao, cse, fromCfg);
    }
}
Also used : ConfigurationException(org.mifos.config.exceptions.ConfigurationException) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CustomerDao(org.mifos.customers.persistence.CustomerDao)

Aggregations

CustomerDao (org.mifos.customers.persistence.CustomerDao)4 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)3 ConfigurationException (org.mifos.config.exceptions.ConfigurationException)2 DateMidnight (org.joda.time.DateMidnight)1 DateTime (org.joda.time.DateTime)1 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)1 LegacyAccountDao (org.mifos.accounts.persistence.LegacyAccountDao)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 MifosConfigurationManager (org.mifos.config.business.MifosConfigurationManager)1 CenterBO (org.mifos.customers.center.business.CenterBO)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1 OfficeBO (org.mifos.customers.office.business.OfficeBO)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1