final Object[] argsToRead = { Unit.class };
    public String getUnits() throws FenixFilterException, FenixServiceException, ExcepcaoPersistencia  {        StringBuffer buffer = new StringBuffer();        Date currentDate = Calendar.getInstance().getTime();                List<Unit> allUnits = getAllUnitsWithoutParent();        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){				 return 0;				}else if(Unit1.getType() == null){					return 1;					}else if(Unit2.getType() == null){						return -1;					}else{						return Unit1.getType().compareTo(Unit2.getType());					}			}        	        });                        UnitType unitType = null;        boolean flag = false;        boolean flag1 = false;               for(Unit unit : allUnits){        	if (unit.isActive(currentDate)){	        	if (unit.getType() != null && unit.getType().name().length() > 0){     		        	unitType = unit.getType();		        	break;	        	}        	}	                }            	for (Unit unit : allUnits) {    		if (unit.isActive(currentDate) && unit.getType() != null && unit.getType().name().length() > 0){	    							    if (!unitType.equals(unit.getType())){				    	unitType = unit.getType();				    	if(unitType.equals(UnitType.DEPARTMENT)){				    		flag1 = true;		    				continue;		    			}				    	flag1=false;	    				buffer.append("<h3 class='mtop2'>").append(this.bundle.getString(unitType.getName()));		    				buffer.append("</h3>\r\n");   	    								    }else if (flag == false){				    	buffer.append("<h3 class='mtop2'>").append(this.bundle.getString(unitType.getName()));		    				buffer.append("</h3>\r\n");   	    				flag = true;				    }				    if (flag1 == false){	            	buffer.append("<ul class='padding nobullet'>\r\n");	            						if(unit.getActiveSubUnits(currentDate).size() != 0){						if(unit.getType() != null ){														if(!unit.getType().equals(UnitType.ACADEMIC_UNIT) && !unit.getType().equals(UnitType.DEPARTMENT)){									 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 {								 	if (unit.getType().equals(UnitType.ACADEMIC_UNIT)){									 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();    }