use of org.mifos.customers.group.struts.actionforms.GroupCustActionForm in project head by mifos.
the class GroupCustAction method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
GroupCustActionForm actionForm = (GroupCustActionForm) form;
MeetingBO meeting = (MeetingBO) SessionUtils.getAttribute(CustomerConstants.CUSTOMER_MEETING, request);
UserContext userContext = getUserContext(request);
String groupName = actionForm.getDisplayName();
String externalId = actionForm.getExternalId();
boolean trained = actionForm.isCustomerTrained();
DateTime trainedOn = new DateTime(actionForm.getTrainedDateValue(userContext.getPreferredLocale()));
AddressDto addressDto = null;
if (actionForm.getAddress() != null) {
addressDto = Address.toDto(actionForm.getAddress());
}
Short customerStatusId = actionForm.getStatusValue().getValue();
String centerSystemId = "";
boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
if (isCenterHierarchyExists) {
centerSystemId = actionForm.getParentCustomer().getGlobalCustNum();
}
Short officeId = actionForm.getOfficeIdValue();
MeetingDto meetingDto = null;
if (meeting != null) {
meetingDto = meeting.toDto();
}
DateTime mfiJoiningDate = new DateTime().toDateMidnight().toDateTime();
DateTime activationDate = new DateTime().toDateMidnight().toDateTime();
try {
GroupCreationDetail groupCreationDetail = new GroupCreationDetail(groupName, externalId, addressDto, actionForm.getFormedByPersonnelValue(), actionForm.getFeesToApply(), customerStatusId, trained, trainedOn, centerSystemId, officeId, mfiJoiningDate, activationDate);
CustomerDetailsDto centerDetails = this.groupServiceFacade.createNewGroup(groupCreationDetail, meetingDto);
createGroupQuestionnaire.saveResponses(request, actionForm, centerDetails.getId());
actionForm.setCustomerId(centerDetails.getId().toString());
actionForm.setGlobalCustNum(centerDetails.getGlobalCustNum());
} catch (BusinessRuleException e) {
throw new ApplicationException(e.getMessageKey(), e);
}
SessionUtils.setAttribute(GroupConstants.IS_GROUP_LOAN_ALLOWED, ClientRules.getGroupCanApplyLoans(), request);
return mapping.findForward(ActionForwards.create_success.toString());
}
use of org.mifos.customers.group.struts.actionforms.GroupCustActionForm in project head by mifos.
the class GroupActionStrutsTest method testSuccessfulCreate_UnderCenter.
@Test
public void testSuccessfulCreate_UnderCenter() throws Exception {
createParentCustomer();
StaticHibernateUtil.flushAndClearSession();
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", "groupUnderCenter");
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();
verifyNoActionErrors();
verifyForward(ActionForwards.create_success.toString());
GroupCustActionForm actionForm = (GroupCustActionForm) request.getSession().getAttribute("groupCustActionForm");
group = TestObjectFactory.getGroup(actionForm.getCustomerIdAsInt());
center = TestObjectFactory.getCenter(center.getCustomerId());
actionForm.setParentCustomer(null);
}
use of org.mifos.customers.group.struts.actionforms.GroupCustActionForm in project head by mifos.
the class GroupActionStrutsTest method testSuccessfulCreate_UnderBranch.
@Test
public void testSuccessfulCreate_UnderBranch() throws Exception {
createParentCustomer();
StaticHibernateUtil.flushAndClearSession();
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "load");
addRequestParameter("branchId", officeId.toString());
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", "groupUnderBranch");
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();
SessionUtils.setAttribute(GroupConstants.CENTER_HIERARCHY_EXIST, Boolean.FALSE, request);
setRequestPathInfo("/groupCustAction.do");
addRequestParameter("method", "create");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyNoActionErrors();
verifyForward(ActionForwards.create_success.toString());
GroupCustActionForm actionForm = (GroupCustActionForm) request.getSession().getAttribute("groupCustActionForm");
group = TestObjectFactory.getGroup(actionForm.getCustomerIdAsInt());
center = TestObjectFactory.getCenter(center.getCustomerId());
actionForm.setParentCustomer(null);
}
Aggregations