use of org.mifos.customers.business.CustomerStatusFlagEntity in project head by mifos.
the class CustomerServiceImpl method updateClientStatus.
@Override
public final void updateClientStatus(ClientBO client, CustomerStatus oldStatus, CustomerStatus newStatus, CustomerStatusFlag customerStatusFlag, CustomerNoteEntity customerNote) throws CustomerException {
PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(client.getUserContext().getId());
handeClientChangeOfStatus(client, newStatus);
CustomerStatusFlagEntity customerStatusFlagEntity = populateCustomerStatusFlag(customerStatusFlag);
try {
hibernateTransactionHelper.startTransaction();
hibernateTransactionHelper.beginAuditLoggingFor(client);
client.clearCustomerFlagsIfApplicable(oldStatus, newStatus);
client.updateCustomerStatus(newStatus);
changeStatus(client, oldStatus, newStatus);
if (customerStatusFlagEntity != null) {
client.addCustomerFlag(customerStatusFlagEntity);
}
client.addCustomerNotes(customerNote);
this.handleChangeOfClientStatusToClosedOrCancelled(client, customerStatusFlag, customerNote, loggedInUser);
customerDao.save(client);
hibernateTransactionHelper.commitTransaction();
} catch (ApplicationException e) {
this.hibernateTransactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} catch (Exception e) {
this.hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
this.hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.customers.business.CustomerStatusFlagEntity in project head by mifos.
the class CustomerServiceImpl method updateCenterStatus.
@Override
public final void updateCenterStatus(CenterBO center, CustomerStatus newStatus, CustomerStatusFlag customerStatusFlag, CustomerNoteEntity customerNote) throws CustomerException {
if (newStatus.isCenterInActive()) {
center.validateChangeToInActive();
List<CustomerDto> clientsThatAreNotClosedOrCanceled = this.customerDao.findClientsThatAreNotCancelledOrClosed(center.getSearchId(), center.getOffice().getOfficeId());
List<CustomerDto> groupsThatAreNotClosedOrCancelled = this.customerDao.findGroupsThatAreNotCancelledOrClosed(center.getSearchId(), center.getOffice().getOfficeId());
if (clientsThatAreNotClosedOrCanceled.size() > 0 || groupsThatAreNotClosedOrCancelled.size() > 0) {
final String errorMessage = messageLookupHelper.lookupLabel(ConfigurationConstants.GROUP);
throw new CustomerException(CustomerConstants.ERROR_STATE_CHANGE_EXCEPTION, new Object[] { errorMessage });
}
} else if (newStatus.isCenterActive()) {
center.validateChangeToActive();
center.validateLoanOfficerIsActive();
}
CustomerStatusFlagEntity customerStatusFlagEntity = populateCustomerStatusFlag(customerStatusFlag);
try {
hibernateTransactionHelper.startTransaction();
hibernateTransactionHelper.beginAuditLoggingFor(center);
center.updateCustomerStatus(newStatus, customerNote, customerStatusFlagEntity);
customerDao.save(center);
hibernateTransactionHelper.commitTransaction();
} catch (Exception e) {
this.hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
this.hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.customers.business.CustomerStatusFlagEntity in project head by mifos.
the class CustomerServiceImpl method updateGroupStatus.
@Override
public final void updateGroupStatus(GroupBO group, CustomerStatus oldStatus, CustomerStatus newStatus, CustomerStatusFlag customerStatusFlag, CustomerNoteEntity customerNote) throws CustomerException {
validateChangeOfStatusForGroup(group, oldStatus, newStatus);
CustomerStatusFlagEntity customerStatusFlagEntity = populateCustomerStatusFlag(customerStatusFlag);
try {
hibernateTransactionHelper.startTransaction();
hibernateTransactionHelper.beginAuditLoggingFor(group);
if (group.isActiveForFirstTime(oldStatus.getValue(), newStatus.getValue())) {
group.setCustomerActivationDate(new DateTime().toDate());
group.updateCustomerHierarchy();
CalendarEvent applicableCalendarEvents = this.holidayDao.findCalendarEventsForThisYearAndNext(group.getOfficeId());
group.regenerateCustomerFeeSchedule(applicableCalendarEvents);
}
Set<CustomerBO> groupChildren = group.getChildren();
if (oldStatus.isGroupPending() && newStatus.isGroupCancelled() && groupChildren != null) {
for (CustomerBO child : groupChildren) {
ClientBO client = (ClientBO) child;
if (client.isPending()) {
client.setUserContext(group.getUserContext());
hibernateTransactionHelper.beginAuditLoggingFor(client);
client.updateCustomerStatus(CustomerStatus.CLIENT_PARTIAL);
customerDao.save(client);
}
}
}
group.updateCustomerStatus(newStatus, customerNote, customerStatusFlagEntity);
customerDao.save(group);
hibernateTransactionHelper.commitTransaction();
} catch (Exception e) {
this.hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
this.hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.customers.business.CustomerStatusFlagEntity in project head by mifos.
the class ApplicationConfigurationDaoHibernate method findAllCustomerStatuses.
@SuppressWarnings("unchecked")
@Override
public List<CustomerStatusEntity> findAllCustomerStatuses() {
Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("LEVEL_ID", CustomerLevel.CLIENT.getValue());
List<CustomerStatusEntity> queryResult = (List<CustomerStatusEntity>) this.genericDao.executeNamedQuery(NamedQueryConstants.GET_CUSTOMER_STATUS_LIST, queryParameters);
for (CustomerStatusEntity customerStatus : queryResult) {
for (CustomerStatusFlagEntity customerStatusFlagEntity : customerStatus.getFlagSet()) {
Hibernate.initialize(customerStatusFlagEntity);
Hibernate.initialize(customerStatusFlagEntity.getNames());
}
Hibernate.initialize(customerStatus.getLookUpValue());
}
return queryResult;
}
use of org.mifos.customers.business.CustomerStatusFlagEntity 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());
}
Aggregations