use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.
the class AccountStateMachines method retrieveNextPossibleCustomerStateForGroup.
private List<CustomerStatusEntity> retrieveNextPossibleCustomerStateForGroup(StateEntity customerStateEntityObj) throws ApplicationException {
logger.debug("In AccountStateMachines::retrieveNextPossibleCustomerStateForGroup()");
List<CustomerStatusEntity> stateEntityList = new ArrayList<CustomerStatusEntity>();
try {
List<StateEntity> stateList = statesMapForGroup.get(customerStateEntityObj);
if (null != stateList) {
for (StateEntity customerStateEntity : stateList) {
for (CustomerStatusEntity customerStatusEntry : customerStatusListForGroup) {
if (customerStatusEntry.sameId(customerStateEntity)) {
stateEntityList.add(customerStatusEntry);
break;
}
}
}
}
return stateEntityList;
} catch (Exception e) {
throw new StatesInitializationException(SavingsConstants.STATEINITIALIZATION_EXCEPTION, e);
}
}
use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.
the class EditCustomerStatusAction method loadStatus.
@TransactionDemarcate(joinToken = true)
public ActionForward loadStatus(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In EditCustomerStatusAction:load()");
EditCustomerStatusActionForm editCustomerStatusActionForm = (EditCustomerStatusActionForm) form;
editCustomerStatusActionForm.clear();
UserContext userContext = getUserContext(request);
Integer customerId = editCustomerStatusActionForm.getCustomerIdValue();
CustomerBO customer = this.customerDao.findCustomerById(customerId);
customer.setUserContext(userContext);
SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, customer, request);
List<CustomerStatusEntity> statusList = new ArrayList<CustomerStatusEntity>();
switch(customer.getLevel()) {
case CENTER:
this.centerServiceFacade.initializeCenterStates(customer.getGlobalCustNum());
statusList = AccountStateMachines.getInstance().getCenterStatusList(customer.getCustomerStatus());
editCustomerStatusActionForm.setInput("center");
break;
case GROUP:
this.centerServiceFacade.initializeGroupStates(customer.getGlobalCustNum());
statusList = AccountStateMachines.getInstance().getGroupStatusList(customer.getCustomerStatus());
editCustomerStatusActionForm.setInput("group");
break;
case CLIENT:
this.centerServiceFacade.initializeClientStates(customer.getGlobalCustNum());
statusList = AccountStateMachines.getInstance().getClientStatusList(customer.getCustomerStatus());
editCustomerStatusActionForm.setInput("client");
break;
default:
break;
}
;
for (CustomerStatusEntity customerStatusEntity : statusList) {
for (CustomerStatusFlagEntity flag : customerStatusEntity.getFlagSet()) {
String statusMessageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(flag.getLookUpValue().getPropertiesKey());
flag.setStatusFlagMessageText(statusMessageText);
}
}
editCustomerStatusActionForm.setLevelId(customer.getCustomerLevel().getId().toString());
editCustomerStatusActionForm.setCurrentStatusId(customer.getCustomerStatus().getId().toString());
editCustomerStatusActionForm.setGlobalAccountNum(customer.getGlobalCustNum());
editCustomerStatusActionForm.setCustomerName(customer.getDisplayName());
SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_LIST, statusList, request);
return mapping.findForward(ActionForwards.loadStatus_success.toString());
}
use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.
the class CheckListBOIntegrationTest method testCreateCheckListExceptionForCustomer.
@Test
public void testCreateCheckListExceptionForCustomer() throws Exception {
CustomerLevelEntity customerLevelEntity = new CustomerLevelEntity(CustomerLevel.CENTER);
CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(CustomerStatus.CENTER_ACTIVE);
try {
customerCheckList = new CustomerCheckListBO(customerLevelEntity, customerStatusEntity, null, CheckListConstants.STATUS_ACTIVE, getCheckListDetails(), (short) 1, (short) 1);
Assert.fail();
} catch (CheckListException ce) {
Assert.assertTrue(true);
}
}
use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.
the class CheckListBOIntegrationTest method testUpdateCustomerCheckListInvalidState.
@Test
public void testUpdateCustomerCheckListInvalidState() throws Exception {
CustomerCheckListBO customerCheckList1 = TestObjectFactory.createCustomerChecklist(CustomerLevel.CENTER.getValue(), CustomerStatus.CENTER_INACTIVE.getValue(), CheckListConstants.STATUS_ACTIVE);
customerCheckList = TestObjectFactory.createCustomerChecklist(CustomerLevel.CENTER.getValue(), CustomerStatus.CENTER_ACTIVE.getValue(), CheckListConstants.STATUS_ACTIVE);
CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(CustomerStatus.fromInt(CustomerStatus.CENTER_INACTIVE.getValue()));
StaticHibernateUtil.flushSession();
customerCheckList = (CustomerCheckListBO) TestObjectFactory.getObject(CustomerCheckListBO.class, customerCheckList.getChecklistId());
try {
customerCheckList.update(customerCheckList.getCustomerLevel(), customerStatusEntity, "Customer CheckList", CheckListConstants.STATUS_INACTIVE, getCheckListDetails(), (short) 1, (short) 1);
Assert.fail();
} catch (CheckListException ce) {
Assert.assertTrue(true);
} finally {
TestObjectFactory.deleteChecklist(customerCheckList1);
StaticHibernateUtil.flushSession();
}
}
use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.
the class ProcessFlowRulesIntegrationTest method testValidOverrideAgainstDb.
@Test
public void testValidOverrideAgainstDb() throws Exception {
CustomerPersistence cp = new CustomerPersistence();
CustomerStatusEntity cse = (CustomerStatusEntity) cp.loadPersistentObject(CustomerStatusEntity.class, CustomerStatus.CLIENT_PENDING.getValue());
Assert.assertTrue(cse.getIsOptional());
cse.setIsOptional(false);
StaticHibernateUtil.flushSession();
Assert.assertFalse(cse.getIsOptional());
Assert.assertTrue(ProcessFlowRules.isClientPendingApprovalStateEnabled());
ProcessFlowRules.init();
Assert.assertTrue(cse.getIsOptional());
}
Aggregations