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;
}
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));
}
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;
}
Aggregations