Search in sources :

Example 56 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class GroupCustAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In GroupCustAction get method ");
    // John W - UserContext object passed because some status' need to be looked up for internationalisation based
    // on UserContext info
    String groupSystemId = ((GroupCustActionForm) form).getGlobalCustNum();
    GroupInformationDto groupInformationDto;
    try {
        groupInformationDto = this.groupServiceFacade.getGroupInformationDto(groupSystemId);
    } catch (MifosRuntimeException e) {
        if (e.getCause() instanceof ApplicationException) {
            throw (ApplicationException) e.getCause();
        }
        throw e;
    }
    SessionUtils.removeThenSetAttribute("groupInformationDto", groupInformationDto, request);
    // John W - - not sure whether to leave these rules as is or do something else like bake the logic into the main
    // dto and out of the jsp
    SessionUtils.setAttribute(GroupConstants.IS_GROUP_LOAN_ALLOWED, ClientRules.getGroupCanApplyLoans(), request);
    SessionUtils.setAttribute(GroupConstants.CENTER_HIERARCHY_EXIST, ClientRules.getCenterHierarchyExists(), request);
    // John W - 'BusinessKey' attribute linked to GroupBo is still used by other actions (e.g. meeting related)
    // further on and also breadcrumb.
    GroupBO groupBO = (GroupBO) this.customerDao.findCustomerById(groupInformationDto.getGroupDisplay().getCustomerId());
    SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, groupBO, request);
    setCurrentPageUrl(request, groupBO);
    setQuestionGroupInstances(request, groupBO);
    logger.debug("Exiting GroupCustAction get method ");
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) GroupBO(org.mifos.customers.group.business.GroupBO) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) GroupInformationDto(org.mifos.dto.screen.GroupInformationDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 57 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class GroupTransferAction method transferToCenter.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward transferToCenter(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    GroupTransferActionForm actionForm = (GroupTransferActionForm) form;
    GroupBO groupInSession = (GroupBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    CustomerDetailDto groupDetail = this.groupServiceFacade.transferGroupToCenter(groupInSession.getGlobalCustNum(), actionForm.getCenterSystemId(), groupInSession.getVersionNo());
    GroupBO group = this.customerDao.findGroupBySystemId(groupDetail.getGlobalCustNum());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, group, request);
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : GroupTransferActionForm(org.mifos.customers.group.struts.actionforms.GroupTransferActionForm) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) GroupBO(org.mifos.customers.group.business.GroupBO) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 58 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class GroupTransferAction method transferToBranch.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward transferToBranch(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    GroupTransferActionForm actionForm = (GroupTransferActionForm) form;
    GroupBO groupInSession = (GroupBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    CustomerDetailDto groupDetail = this.groupServiceFacade.transferGroupToBranch(groupInSession.getGlobalCustNum(), actionForm.getOfficeIdValue(), groupInSession.getVersionNo());
    GroupBO group = this.customerDao.findGroupBySystemId(groupDetail.getGlobalCustNum());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, group, request);
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : GroupTransferActionForm(org.mifos.customers.group.struts.actionforms.GroupTransferActionForm) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) GroupBO(org.mifos.customers.group.business.GroupBO) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 59 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class GroupServiceFacadeWebTierIntegrationTest method shouldTransferGroupFromOfficeToOffice.

@Test
public void shouldTransferGroupFromOfficeToOffice() {
    // setup
    boolean centerHierarchyExistsOriginal = ClientRules.getCenterHierarchyExists();
    ClientRules.setCenterHierarchyExists(false);
    OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    createOfficeHierarchyUnderHeadOffice(headOffice);
    Short officeId1 = branch1.getOfficeId();
    CustomerDetailsDto group1Details = createGroup("group1", officeId1);
    Short officeId2 = branch2.getOfficeId();
    CustomerDetailsDto group2Details = createGroup("group2", officeId2);
    CustomerDetailsDto newlyCreatedCustomerDetails = createClient(group1Details.getId().toString());
    GroupBO group1 = customerDao.findGroupBySystemId(group1Details.getGlobalCustNum());
    groupServiceFacade.transferGroupToBranch(group1Details.getGlobalCustNum(), officeId2, group1.getVersionNo());
    ClientRules.setCenterHierarchyExists(centerHierarchyExistsOriginal);
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) Test(org.junit.Test)

Example 60 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class GroupServiceFacadeWebTierIntegrationTest method shouldCreateGroupWithActivationDateInPast.

@Test
public void shouldCreateGroupWithActivationDateInPast() {
    // setup
    boolean centerHierarchyExistsOriginal = ClientRules.getCenterHierarchyExists();
    MeetingBO meeting = new MeetingBuilder().withStartDate(new DateTime().minusWeeks(2)).build();
    MeetingDto meetingDto = meeting.toDto();
    String displayName = "testGroup";
    String externalId = null;
    AddressDto addressDto = null;
    PersonnelBO user = IntegrationTestObjectMother.findPersonnelById(Short.valueOf("1"));
    Short loanOfficerId = user.getPersonnelId();
    List<ApplicableAccountFeeDto> feesToApply = new ArrayList<ApplicableAccountFeeDto>();
    Short customerStatus = CustomerStatus.GROUP_ACTIVE.getValue();
    boolean trained = false;
    DateTime trainedOn = null;
    String parentSystemId = null;
    OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    // setup
    createOfficeHierarchyUnderHeadOffice(headOffice);
    Short officeId = branch1.getOfficeId();
    DateTime mfiJoiningDate = new DateTime().minusWeeks(2);
    DateTime activationDate = new DateTime().minusWeeks(1);
    GroupCreationDetail groupCenterDetail = new GroupCreationDetail(displayName, externalId, addressDto, loanOfficerId, feesToApply, customerStatus, trained, trainedOn, parentSystemId, officeId, mfiJoiningDate, activationDate);
    // exercise test
    ClientRules.setCenterHierarchyExists(false);
    CustomerDetailsDto newlyCreatedGroupDetails = groupServiceFacade.createNewGroup(groupCenterDetail, meetingDto);
    // verification
    ClientRules.setCenterHierarchyExists(centerHierarchyExistsOriginal);
    GroupBO group = customerDao.findGroupBySystemId(newlyCreatedGroupDetails.getGlobalCustNum());
    Assert.assertThat(new LocalDate(group.getCustomerActivationDate()), is(activationDate.toLocalDate()));
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) GroupCreationDetail(org.mifos.dto.domain.GroupCreationDetail) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) MeetingDto(org.mifos.dto.domain.MeetingDto) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBO(org.mifos.customers.group.business.GroupBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) Test(org.junit.Test)

Aggregations

GroupBO (org.mifos.customers.group.business.GroupBO)84 Test (org.junit.Test)56 CenterBO (org.mifos.customers.center.business.CenterBO)45 GroupBuilder (org.mifos.domain.builders.GroupBuilder)42 CenterBuilder (org.mifos.domain.builders.CenterBuilder)36 CustomerException (org.mifos.customers.exceptions.CustomerException)23 ClientBO (org.mifos.customers.client.business.ClientBO)22 ArrayList (java.util.ArrayList)16 OfficeBO (org.mifos.customers.office.business.OfficeBO)16 MeetingBO (org.mifos.application.meeting.business.MeetingBO)15 ClientBuilder (org.mifos.domain.builders.ClientBuilder)15 DateTime (org.joda.time.DateTime)14 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)12 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)11 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)11 UserContext (org.mifos.security.util.UserContext)11 LocalDate (org.joda.time.LocalDate)10 MifosRuntimeException (org.mifos.core.MifosRuntimeException)10 ApplicationException (org.mifos.framework.exceptions.ApplicationException)10 Date (java.util.Date)9