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();
}
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;
}
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);
}
}
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;
}
Aggregations