Search in sources :

Example 1 with OfficeHierarchyDto

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

the class CustomerServiceFacadeWebTier method retrieveBranchOnlyOfficeHierarchy.

@Override
public OnlyBranchOfficeHierarchyDto retrieveBranchOnlyOfficeHierarchy() {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    OfficeDto office = officeDao.findOfficeDtoById(userContext.getBranchId());
    List<OfficeBO> branchParents = officeDao.findBranchsOnlyWithParentsMatching(office.getSearchId());
    List<OfficeDetailsDto> levels = officeDao.findActiveOfficeLevels();
    List<OfficeHierarchyDto> branchOnlyOfficeHierarchy = OfficeBO.convertToBranchOnlyHierarchyWithParentsOfficeHierarchy(branchParents);
    return new OnlyBranchOfficeHierarchyDto(userContext.getPreferredLocale(), levels, office.getSearchId(), branchOnlyOfficeHierarchy);
}
Also used : OfficeHierarchyDto(org.mifos.dto.domain.OfficeHierarchyDto) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) OfficeDto(org.mifos.dto.domain.OfficeDto) OfficeBO(org.mifos.customers.office.business.OfficeBO) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto)

Example 2 with OfficeHierarchyDto

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

the class OfficeListTag method getBranchOffices.

void getBranchOffices(XmlBuilder html, List<OfficeHierarchyDto> officeList, Locale preferredUserLocale, String loggedInOfficeSearchId, String branchName) {
    html.singleTag("br");
    html.startTag("span", "class", "fontnormalBold");
    html.text(branchName);
    html.endTag("span");
    html.singleTag("br");
    if (officeList == null) {
        html.startTag("span", "class", "fontnormal");
        html.text(MessageLookup.getLocalizedMessage("Office.labelNo"));
        html.text(" ");
        html.text(branchName.toLowerCase());
        html.text(" ");
        html.text(MessageLookup.getLocalizedMessage("Office.labelPresent"));
        html.endTag("span");
    } else {
        for (int i = 0; i < officeList.size(); i++) {
            OfficeHierarchyDto officeParent = officeList.get(i);
            Set<OfficeHierarchyDto> branchList = new TreeSet<OfficeHierarchyDto>();
            for (OfficeHierarchyDto dataScopeBranch : officeParent.getChildren()) {
                if (dataScopeBranch.getSearchId().startsWith(loggedInOfficeSearchId) && dataScopeBranch.isActive()) {
                    branchList.add(dataScopeBranch);
                }
            }
            if (branchList.size() > 0) {
                if (i > 0) {
                    html.singleTag("br");
                }
                html.startTag("span", "class", "fontnormal");
                html.text(officeParent.getOfficeName());
                html.endTag("span");
                html.startTag("table", "width", "90%", "border", "0", "cellspacing", "0", "cellpadding", "0");
                for (OfficeHierarchyDto office : branchList) {
                    html.startTag("tr", "class", "fontnormal");
                    bullet(html);
                    html.startTag("td", "width", "99%");
                    html.append(getLink(office.getOfficeId(), office.getOfficeName()));
                    html.endTag("td");
                    html.endTag("tr");
                }
                html.endTag("table");
            }
        }
    }
}
Also used : OfficeHierarchyDto(org.mifos.dto.domain.OfficeHierarchyDto) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) TreeSet(java.util.TreeSet)

Example 3 with OfficeHierarchyDto

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

the class OfficeBO method convertToBranchOnlyHierarchyWithParentsOfficeHierarchy.

public static List<OfficeHierarchyDto> convertToBranchOnlyHierarchyWithParentsOfficeHierarchy(List<OfficeBO> branchParents) {
    List<OfficeHierarchyDto> hierarchy = new ArrayList<OfficeHierarchyDto>();
    for (OfficeBO officeBO : branchParents) {
        List<OfficeHierarchyDto> children = new ArrayList<OfficeHierarchyDto>();
        Set<OfficeBO> branchOnlyChildren = officeBO.getBranchOnlyChildren();
        if (branchOnlyChildren != null && !branchOnlyChildren.isEmpty()) {
            children = convertToBranchOnlyHierarchyWithParentsOfficeHierarchy(new ArrayList<OfficeBO>(branchOnlyChildren));
        }
        OfficeHierarchyDto officeHierarchy = new OfficeHierarchyDto(officeBO.getOfficeId(), officeBO.getOfficeName(), officeBO.getSearchId(), officeBO.isActive(), children);
        hierarchy.add(officeHierarchy);
    }
    return hierarchy;
}
Also used : OfficeHierarchyDto(org.mifos.dto.domain.OfficeHierarchyDto)

Example 4 with OfficeHierarchyDto

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

the class OfficeDaoHibernate method officeHierarchy.

private OfficeHierarchyDto officeHierarchy(OfficeBO office) {
    List<OfficeHierarchyDto> childOfficeList = new LinkedList<OfficeHierarchyDto>();
    Set<OfficeBO> children = office.getChildren();
    for (OfficeBO child : children) {
        childOfficeList.add(officeHierarchy(child));
    }
    Collections.sort(childOfficeList);
    OfficeHierarchyDto hierarchy = new OfficeHierarchyDto(office.getOfficeId(), office.getOfficeName().trim(), office.getSearchId(), office.isActive(), childOfficeList);
    return hierarchy;
}
Also used : OfficeHierarchyDto(org.mifos.dto.domain.OfficeHierarchyDto) OfficeBO(org.mifos.customers.office.business.OfficeBO) LinkedList(java.util.LinkedList)

Example 5 with OfficeHierarchyDto

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

the class OfficeServiceFacadeWebTier method retrieveBranchOnlyOfficeHierarchy.

@Override
public OnlyBranchOfficeHierarchyDto retrieveBranchOnlyOfficeHierarchy() {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    OfficeDto office = officeDao.findOfficeDtoById(user.getBranchId());
    List<OfficeBO> branchParents = officeDao.findBranchsOnlyWithParentsMatching(office.getSearchId());
    List<OfficeDetailsDto> levels = officeDao.findActiveOfficeLevels();
    List<OfficeHierarchyDto> branchOnlyOfficeHierarchy = OfficeBO.convertToBranchOnlyHierarchyWithParentsOfficeHierarchy(branchParents);
    return new OnlyBranchOfficeHierarchyDto(Locale.getDefault(), levels, office.getSearchId(), branchOnlyOfficeHierarchy);
}
Also used : OfficeHierarchyDto(org.mifos.dto.domain.OfficeHierarchyDto) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) OfficeDto(org.mifos.dto.domain.OfficeDto) OfficeBO(org.mifos.customers.office.business.OfficeBO) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) MifosUser(org.mifos.security.MifosUser) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto)

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