use of org.mifos.customers.group.struts.actionforms.GroupCustActionForm in project head by mifos.
the class GroupCustAction method update.
@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
GroupBO group = (GroupBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
GroupCustActionForm actionForm = (GroupCustActionForm) form;
boolean trained = false;
if (actionForm.getTrainedValue() != null && actionForm.getTrainedValue().equals(Short.valueOf("1"))) {
trained = true;
}
AddressDto address = null;
if (actionForm.getAddress() != null) {
address = Address.toDto(actionForm.getAddress());
}
GroupUpdate groupUpdate = new GroupUpdate(group.getCustomerId(), group.getGlobalCustNum(), group.getVersionNo(), actionForm.getDisplayName(), actionForm.getLoanOfficerIdValue(), actionForm.getExternalId(), trained, actionForm.getTrainedDate(), address, actionForm.getCustomFields(), actionForm.getCustomerPositions());
try {
this.groupServiceFacade.updateGroup(groupUpdate);
} catch (BusinessRuleException e) {
throw new ApplicationException(e.getMessageKey(), e);
}
return mapping.findForward(ActionForwards.update_success.toString());
}
use of org.mifos.customers.group.struts.actionforms.GroupCustActionForm in project head by mifos.
the class GroupCustAction method loadSearch.
@TransactionDemarcate(conditionToken = true)
public ActionForward loadSearch(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
GroupCustActionForm actionForm = (GroupCustActionForm) form;
actionForm.setSearchString(null);
cleanUpSearch(request);
boolean groupHierarchyRequired = this.customerServiceFacade.isGroupHierarchyRequired();
if (groupHierarchyRequired) {
SessionUtils.setAttribute(CustomerConstants.GROUP_HIERARCHY_REQUIRED, CustomerConstants.NO, request);
} else {
SessionUtils.setAttribute(CustomerConstants.GROUP_HIERARCHY_REQUIRED, CustomerConstants.YES, request);
}
if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
return mapping.findForward(ActionForwards.loadTransferSearch_success.toString());
}
SessionUtils.setAttribute(CustomerConstants.URL_MAP, null, request.getSession(false));
return mapping.findForward(ActionForwards.loadSearch_success.toString());
}
use of org.mifos.customers.group.struts.actionforms.GroupCustActionForm in project head by mifos.
the class GroupCustAction method load.
@TransactionDemarcate(saveToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
GroupCustActionForm actionForm = (GroupCustActionForm) form;
actionForm.cleanForm();
SessionUtils.removeAttribute(CustomerConstants.CUSTOMER_MEETING, request.getSession());
GroupCreation groupCreation = null;
boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
if (isCenterHierarchyExists) {
String centerSystemId = actionForm.getCenterSystemId();
CenterBO center = this.customerDao.findCenterBySystemId(centerSystemId);
groupCreation = new GroupCreation(actionForm.getOfficeIdValue(), centerSystemId);
// inherit these settings from center/parent if center hierarchy is configured
actionForm.setParentCustomer(center);
actionForm.setOfficeId(center.getOfficeId().toString());
actionForm.setFormedByPersonnel(center.getLoanOfficerId().toString());
} else {
groupCreation = new GroupCreation(actionForm.getOfficeIdValue(), "");
}
GroupFormCreationDto groupFormCreationDto = this.groupServiceFacade.retrieveGroupFormCreationData(groupCreation);
actionForm.setCustomFields(new ArrayList<CustomFieldDto>());
actionForm.setDefaultFees(groupFormCreationDto.getDefaultFees());
SessionUtils.setCollectionAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, groupFormCreationDto.getAdditionalFees(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, groupFormCreationDto.getPersonnelList(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<CustomFieldDto>(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.FORMEDBY_LOAN_OFFICER_LIST, groupFormCreationDto.getFormedByPersonnel(), request);
SessionUtils.setAttribute(GroupConstants.CENTER_HIERARCHY_EXIST, groupFormCreationDto.isCenterHierarchyExists(), request);
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.customers.group.struts.actionforms.GroupCustActionForm in project head by mifos.
the class GroupActionStrutsTest method testPreviewManageSuccessForNameChange_AfterTrainedSet.
/**
* This test asserts that when a group name for a trained group is edited, there are no errors and the trained date
* is present in the action form.
*/
@Test
public void testPreviewManageSuccessForNameChange_AfterTrainedSet() throws Exception {
Calendar cal = new GregorianCalendar();
cal.set(Calendar.DAY_OF_MONTH, 2);
cal.set(Calendar.MONTH, 5);
cal.set(Calendar.YEAR, 2008);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
createTrainedGroupAndSetInSession(cal.getTime());
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "manage");
addRequestParameter("officeId", "3");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
List<CustomFieldDto> customFieldDefs = getCustomFieldsFromSession();
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "previewManage");
addRequestParameter("officeId", "3");
// editing group name
addRequestParameter("displayName", "group123");
int i = 0;
for (CustomFieldDto customFieldDef : customFieldDefs) {
addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
addRequestParameter("customField[" + i + "].fieldValue", "Req");
i++;
}
addRequestParameter("trained", "1");
addRequestParameter("trainedDate", "2/6/2008");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
GroupCustActionForm actionForm = (GroupCustActionForm) getActionForm();
Assert.assertEquals("2/6/2008", actionForm.getTrainedDate());
Assert.assertEquals(0, getErrorSize());
}
use of org.mifos.customers.group.struts.actionforms.GroupCustActionForm in project head by mifos.
the class GroupActionStrutsTest method testFailureCreate_DuplicateName.
@Test
public void testFailureCreate_DuplicateName() throws Exception {
createGroupWithCenter();
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "load");
addRequestParameter("centerSystemId", center.getGlobalCustNum());
actionPerform();
List<CustomFieldDto> customFieldDefs = getCustomFieldsFromSession();
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "preview");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("displayName", "group");
addRequestParameter("status", CustomerStatus.GROUP_PENDING.getValue().toString());
addRequestParameter("formedByPersonnel", center.getPersonnel().getPersonnelId().toString());
int i = 0;
for (CustomFieldDto customFieldDef : customFieldDefs) {
addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
addRequestParameter("customField[" + i + "].fieldValue", "11");
i++;
}
actionPerform();
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "create");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyActionErrors(new String[] { CustomerConstants.ERRORS_DUPLICATE_CUSTOMER });
verifyForward(ActionForwards.create_failure.toString());
group = TestObjectFactory.getGroup(group.getCustomerId());
center = TestObjectFactory.getCenter(center.getCustomerId());
GroupCustActionForm actionForm = (GroupCustActionForm) request.getSession().getAttribute("groupCustActionForm");
actionForm.setParentCustomer(null);
}
Aggregations