unit.getIdInternal()).append("'));return false;").append("\"> ");
unit.getIdInternal()).append("'));return false;").append("\"/> ");
    public String getUnits() throws FenixFilterException, FenixServiceException, ExcepcaoPersistencia {        StringBuilder buffer = new StringBuilder();        YearMonthDay currentDate = new YearMonthDay();        List<Unit> allUnits = getAllInstitutionSubUnits();        Collections.sort(allUnits, new Comparator() {            public int compare(Object arg0, Object arg1) {                Unit Unit1 = (Unit) arg0;                Unit Unit2 = (Unit) arg1;                //if (Unit1.getType() == null && Unit2.getType() == null) {                if (Unit1.getType() == Unit2.getType()) {                    return 0;                } else if (Unit1.getType() == null) {                    return 1;                } else if (Unit2.getType() == null) {                    return -1;                } else {                    return Unit1.getType().compareTo(Unit2.getType());                }            }        });        PartyTypeEnum partyType = null;        boolean flag = false;        boolean flag1 = false;           for (Unit unit : allUnits) {            if (unit.isActive(currentDate)) {                if (unit.getType() != null /*&& unit.getType().name().length() > 0*/) {                    partyType = unit.getType();                    break;                }            }        }        for (Unit unit : allUnits) {            if (unit.isActive(currentDate)) {                if (unit.getType() != null /*&& unit.getType().name().length() > 0*/) {                    if (!partyType.equals(unit.getType())) {                        partyType = unit.getType();                        buffer.append("<h3 class='mtop2'>").append(                                this.bundle.getString(partyType.getName()));                        buffer.append("</h3>\r\n");                    } else if (flag == false) {                        buffer.append("<h3 class='mtop2'>").append(                                this.bundle.getString(partyType.getName()));                        buffer.append("</h3>\r\n");                        flag = true;                    }                } else if (unit.getType() == null) {	                    if (flag1 == false) {	                        buffer.append("<div class='mtop2' style='color: #aaa;'>- - - - - - - -");	                        buffer.append("</div>\r\n");	                        flag1 = true;	                    } else {	                        buffer.append("<div class='mtop2'>");	                        buffer.append("</div>\r\n");	                    }                       }                buffer.append("<ul class='padding nobullet'>\r\n");                                if (unit.getActiveSubUnits(new YearMonthDay(), AccountabilityTypeEnum.ORGANIZATIONAL_STRUCTURE).size() != 0) {                    if (unit.getType() != null) {                        if (!unit.getType().equals(PartyTypeEnum.ACADEMIC_UNIT)) {                            buffer.append("\t<li><img ").append("src='").append(getContextPath())                                    .append("/images/toggle_plus10.gif' id=\"").append(                                            unit.getIdInternal()).append("\" ").append(                                            "indexed='true' onClick=\"").append(                                            "check(document.getElementById('").append("aa").append(                                            unit.getIdInternal()).append("'),document.getElementById('")                                    .append(unit.getIdInternal()).append("'));return false;").append(                                            "\"> ");                            buffer.append("<a href=\"").append(getContextPath()).append(                                    "/person/organizationalStructure/chooseUnit.faces?unitID=").append(                                    unit.getIdInternal()).append("&amp;subUnit=").append(                                    unit.getIdInternal()).append("#").append(unit.getIdInternal())                                    .append("\">").append(unit.getName()).append("</a></li>\r\n");                        } else {                            getDepartment(buffer, unit);                            continue;                        }                    } else {                        buffer.append("\t<li><img ").append("src='").append(getContextPath()).append(                                "/images/toggle_plus10.gif' id=\"").append(unit.getIdInternal()).append(                                "\" ").append("indexed='true' onClick=\"").append(                                "check(document.getElementById('").append("aa").append(                                unit.getIdInternal()).append("'),document.getElementById('").append(                                unit.getIdInternal()).append("'));return false;").append("\"> ");                        buffer.append("<a href=\"").append(getContextPath()).append(                                "/person/organizationalStructure/chooseUnit.faces?unitID=").append(                                unit.getIdInternal()).append("&amp;subUnit=").append(                                unit.getIdInternal()).append("#").append(unit.getIdInternal()).append(                                "\">").append(unit.getName()).append("</a></li>\r\n");                    }                } else {                    buffer.append("\t<li><a href=\"").append(getContextPath()).append(                            "/person/organizationalStructure/chooseUnit.faces?unitID=").append(                            unit.getIdInternal()).append("&amp;subUnit=").append(unit.getIdInternal())                            .append("#").append(unit.getIdInternal()).append("\">").append(                                    unit.getName()).append("</a></li>\r\n");                }                getUnitTree(buffer, unit);                buffer.append("</ul>\r\n");            }        }        return buffer.toString();    }