Search in sources :

Example 6 with OfficeHierarchyDto

use of org.mifos.dto.domain.OfficeHierarchyDto in project head by mifos.

the class OfficeListTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    try {
        String officeListString = "";
        OnlyBranchOfficeHierarchyDto officeHierarchyDto = (OnlyBranchOfficeHierarchyDto) pageContext.getAttribute(OnlyBranchOfficeHierarchyDto.IDENTIFIER);
        if (officeHierarchyDto != null) {
            officeListString = getOfficeList(officeHierarchyDto);
        } else {
            // FIXME - #00006 - keithw - personnel creation use this still
            UserContext userContext = (UserContext) pageContext.getSession().getAttribute(Constants.USERCONTEXT);
            OfficePersistence officePersistence = new OfficePersistence();
            OfficeBO officeBO = officePersistence.getOffice(userContext.getBranchId());
            List<OfficeDetailsDto> levels = officePersistence.getActiveLevels();
            OfficeBO loggedInOffice = officePersistence.getOffice(userContext.getBranchId());
            List<OfficeBO> branchParents = officePersistence.getBranchParents(officeBO.getSearchId());
            List<OfficeHierarchyDto> officeHierarchy = OfficeBO.convertToBranchOnlyHierarchyWithParentsOfficeHierarchy(branchParents);
            List<OfficeBO> officesTillBranchOffice = officePersistence.getOfficesTillBranchOffice(officeBO.getSearchId());
            officeListString = getOfficeList(userContext.getPreferredLocale(), levels, loggedInOffice.getSearchId(), officeHierarchy, officesTillBranchOffice);
        }
        TagUtils.getInstance().write(pageContext, officeListString);
    } catch (Exception e) {
        /**
             * This turns into a (rather ugly) error 500. TODO: make it more reasonable.
             */
        throw new JspException(e);
    }
    return EVAL_PAGE;
}
Also used : OfficeHierarchyDto(org.mifos.dto.domain.OfficeHierarchyDto) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) JspException(javax.servlet.jsp.JspException) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) OfficeBO(org.mifos.customers.office.business.OfficeBO) UserContext(org.mifos.security.util.UserContext) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) JspException(javax.servlet.jsp.JspException)

Example 7 with OfficeHierarchyDto

use of org.mifos.dto.domain.OfficeHierarchyDto in project head by mifos.

the class OfficeDaoHibernateIntegrationTest method givenAnOfficeHierarchyExistsShouldReturnItAsOfficeHierarchyDto.

@Test
public void givenAnOfficeHierarchyExistsShouldReturnItAsOfficeHierarchyDto() {
    OfficeHierarchyDto officeHierarchy = officeDao.headOfficeHierarchy();
    assertThat(officeHierarchy.getOfficeName(), is("Mifos HO"));
    assertThat(officeHierarchy.isActive(), is(true));
    assertThat(officeHierarchy.getChildren().size(), is(2));
}
Also used : OfficeHierarchyDto(org.mifos.dto.domain.OfficeHierarchyDto) Test(org.junit.Test)

Example 8 with OfficeHierarchyDto

use of org.mifos.dto.domain.OfficeHierarchyDto in project head by mifos.

the class SystemUserController method showBranchHierarchy.

@SuppressWarnings("PMD")
public OfficeHierarchyFormBean showBranchHierarchy() {
    OnlyBranchOfficeHierarchyDto hierarchy = this.officeServiceFacade.retrieveBranchOnlyOfficeHierarchy();
    List<BranchOnlyHierarchyBean> branchOnlyHierarchyList = new ArrayList<BranchOnlyHierarchyBean>();
    for (OfficeHierarchyDto office : hierarchy.getBranchOnlyOfficeHierarchy()) {
        BranchOnlyHierarchyBean branchOnlyHierarchyBean = new BranchOnlyHierarchyBean();
        branchOnlyHierarchyBean.setId(office.getOfficeId().intValue());
        branchOnlyHierarchyBean.setName(office.getOfficeName());
        List<ListElement> branches = new ArrayList<ListElement>();
        for (OfficeHierarchyDto child : office.getChildren()) {
            branches.add(new ListElement(child.getOfficeId().intValue(), child.getOfficeName()));
        }
        branchOnlyHierarchyBean.setChildren(branches);
        branchOnlyHierarchyList.add(branchOnlyHierarchyBean);
    }
    List<OfficeDto> nonBranchOffices = this.officeServiceFacade.retrieveAllNonBranchOfficesApplicableToLoggedInUser();
    List<ListElement> nonBranches = new ArrayList<ListElement>();
    for (OfficeDto office : nonBranchOffices) {
        nonBranches.add(new ListElement(office.getId().intValue(), office.getName()));
    }
    OfficeHierarchyFormBean bean = new OfficeHierarchyFormBean();
    bean.setNonBranches(nonBranches);
    bean.setBranchOnlyOfficeHierarchy(branchOnlyHierarchyList);
    return bean;
}
Also used : OfficeHierarchyDto(org.mifos.dto.domain.OfficeHierarchyDto) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) OfficeDto(org.mifos.dto.domain.OfficeDto) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement)

Aggregations

OfficeHierarchyDto (org.mifos.dto.domain.OfficeHierarchyDto)8 OnlyBranchOfficeHierarchyDto (org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto)5 OfficeBO (org.mifos.customers.office.business.OfficeBO)4 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)3 OfficeDto (org.mifos.dto.domain.OfficeDto)3 MifosUser (org.mifos.security.MifosUser)2 UserContext (org.mifos.security.util.UserContext)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 TreeSet (java.util.TreeSet)1 JspException (javax.servlet.jsp.JspException)1 Test (org.junit.Test)1 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)1 ListElement (org.mifos.dto.screen.ListElement)1