Search in sources :

Example 1 with GroupPersistence

use of org.mifos.customers.group.persistence.GroupPersistence in project head by mifos.

the class ClientCustActionStrutsTest method createGroupWithoutFee.

private void createGroupWithoutFee() throws Exception {
    meeting = new MeetingBO(WeekDay.MONDAY, TestObjectFactory.EVERY_WEEK, new Date(), MeetingType.CUSTOMER_MEETING, "Delhi");
    group = new GroupBO(userContext, "groupName", CustomerStatus.GROUP_PENDING, "1234", false, null, null, null, null, legacyPersonnelDao.getPersonnel(Short.valueOf("3")), new OfficePersistence().getOffice(Short.valueOf("3")), meeting, legacyPersonnelDao.getPersonnel(Short.valueOf("3")));
    new GroupPersistence().saveGroup(group);
    StaticHibernateUtil.flushAndClearSession();
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBO(org.mifos.customers.group.business.GroupBO) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Date(java.util.Date) GroupPersistence(org.mifos.customers.group.persistence.GroupPersistence)

Example 2 with GroupPersistence

use of org.mifos.customers.group.persistence.GroupPersistence in project head by mifos.

the class TestObjectFactory method createGroupUnderCenter.

public static GroupBO createGroupUnderCenter(final String customerName, final CustomerStatus customerStatus, final String externalId, final boolean trained, final Date trainedDate, final Address address, final List<CustomFieldDto> customFields, final List<FeeDto> fees, final Short formedById, final CustomerBO parentCustomer) {
    GroupBO group;
    try {
        group = new GroupBO(TestUtils.makeUserWithLocales(), customerName, customerStatus, externalId, trained, trainedDate, address, customFields, fees, getPersonnel(formedById), parentCustomer);
        new GroupPersistence().saveGroup(group);
        StaticHibernateUtil.flushSession();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return group;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) GroupBO(org.mifos.customers.group.business.GroupBO) GroupPersistence(org.mifos.customers.group.persistence.GroupPersistence) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) OfficeException(org.mifos.customers.office.exceptions.OfficeException)

Example 3 with GroupPersistence

use of org.mifos.customers.group.persistence.GroupPersistence in project head by mifos.

the class PortfolioAtRiskHelper method execute.

@Override
public void execute(long timeInMillis) throws BatchJobException {
    long time1 = new DateTimeService().getCurrentDateTime().getMillis();
    List<BasicGroupInfo> groupInfos = null;
    List<String> errorList = new ArrayList<String>();
    try {
        groupInfos = new CustomerPersistence().getAllBasicGroupInfo();
    } catch (Exception e) {
        throw new BatchJobException(e);
    }
    if (groupInfos != null && !groupInfos.isEmpty()) {
        int groupCount = groupInfos.size();
        getLogger().info("PortfolioAtRisk: got " + groupCount + " groups to process.");
        long startTime = new DateTimeService().getCurrentDateTime().getMillis();
        int i = 1;
        Integer groupId = null;
        GroupPersistence groupPersistence = new GroupPersistence();
        try {
            for (BasicGroupInfo groupInfo : groupInfos) {
                groupId = groupInfo.getGroupId();
                String searchStr = groupInfo.getSearchId() + ".%";
                double portfolioAtRisk = PortfolioAtRiskCalculation.generatePortfolioAtRiskForTask(groupId, groupInfo.getBranchId(), searchStr);
                // updated_by and updated_date
                if (portfolioAtRisk > -1) {
                    groupPersistence.updateGroupInfoAndGroupPerformanceHistoryForPortfolioAtRisk(portfolioAtRisk, groupId);
                }
                if (i % 500 == 0) {
                    long time = new DateTimeService().getCurrentDateTime().getMillis();
                    getLogger().info("500 groups updated in " + (time - startTime) + " milliseconds. There are " + (groupCount - i) + " more groups to be updated.");
                    startTime = time;
                }
                i++;
            }
        } catch (Exception e) {
            getLogger().error("PortfolioAtRiskHelper execute failed with exception " + e.getClass().getName() + ": " + e.getMessage() + " at group " + groupId.toString(), e);
            StaticHibernateUtil.rollbackTransaction();
            errorList.add(groupId.toString());
        } finally {
            StaticHibernateUtil.closeSession();
        }
    }
    long time2 = new DateTimeService().getCurrentDateTime().getMillis();
    getLogger().info("PortfolioAtRiskTask ran in " + (time2 - time1) + " milliseconds");
    if (errorList.size() > 0) {
        throw new BatchJobException(SchedulerConstants.FAILURE, errorList);
    }
}
Also used : BasicGroupInfo(org.mifos.customers.group.BasicGroupInfo) ArrayList(java.util.ArrayList) BatchJobException(org.mifos.framework.components.batchjobs.exceptions.BatchJobException) BatchJobException(org.mifos.framework.components.batchjobs.exceptions.BatchJobException) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) DateTimeService(org.mifos.framework.util.DateTimeService) GroupPersistence(org.mifos.customers.group.persistence.GroupPersistence)

Example 4 with GroupPersistence

use of org.mifos.customers.group.persistence.GroupPersistence in project head by mifos.

the class TestObjectFactory method createGroupUnderBranch.

public static GroupBO createGroupUnderBranch(final String customerName, final CustomerStatus customerStatus, final String externalId, final boolean trained, final Date trainedDate, final Address address, final List<CustomFieldDto> customFields, final List<FeeDto> fees, final Short formedById, final Short officeId, final MeetingBO meeting, final Short loanOfficerId) {
    GroupBO group;
    PersonnelBO loanOfficer = null;
    try {
        if (loanOfficerId != null) {
            loanOfficer = getPersonnel(loanOfficerId);
        }
        group = new GroupBO(TestUtils.makeUserWithLocales(), customerName, customerStatus, externalId, trained, trainedDate, address, customFields, fees, getPersonnel(formedById), new OfficePersistence().getOffice(officeId), meeting, loanOfficer);
        new GroupPersistence().saveGroup(group);
        StaticHibernateUtil.flushSession();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return group;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) GroupBO(org.mifos.customers.group.business.GroupBO) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) GroupPersistence(org.mifos.customers.group.persistence.GroupPersistence) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) OfficeException(org.mifos.customers.office.exceptions.OfficeException)

Aggregations

GroupPersistence (org.mifos.customers.group.persistence.GroupPersistence)4 GroupBO (org.mifos.customers.group.business.GroupBO)3 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)2 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 CustomerException (org.mifos.customers.exceptions.CustomerException)2 OfficeException (org.mifos.customers.office.exceptions.OfficeException)2 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)2 ApplicationException (org.mifos.framework.exceptions.ApplicationException)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 SystemException (org.mifos.framework.exceptions.SystemException)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 BasicGroupInfo (org.mifos.customers.group.BasicGroupInfo)1 CustomerPersistence (org.mifos.customers.persistence.CustomerPersistence)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1 BatchJobException (org.mifos.framework.components.batchjobs.exceptions.BatchJobException)1 DateTimeService (org.mifos.framework.util.DateTimeService)1