if (total == 0) { infoExecutionCourse.setOccupancy(new Double(-1)); } else { infoExecutionCourse.setOccupancy(NumberUtils.formatNumber( new Double((new Double(executionCourse.getAttendsCount()) .floatValue() * 100 / total)), 1)); } return infoExecutionCourse;
if (!capacities.isEmpty()) { total = ((Integer) Collections.min(capacities)).intValue();
                private InfoExecutionCourse getOccupancyLevels(Object arg0) throws ExcepcaoPersistencia {                    InfoExecutionCourse infoExecutionCourse;                    // Get the associated Shifs                    ISuportePersistente spTemp = PersistenceSupportFactory.getDefaultPersistenceSupport();                    IExecutionCourse executionCourse = (IExecutionCourse) arg0;                    // FIXME: Find a better way to get the total                    // capacity for                    // each type of Shift                    Integer theoreticalCapacity = new Integer(0);                    Integer theoPraticalCapacity = new Integer(0);                    Integer praticalCapacity = new Integer(0);                    Integer labCapacity = new Integer(0);                    Integer doubtsCapacity = new Integer(0);                    Integer reserveCapacity = new Integer(0);                    List shifts = spTemp.getITurnoPersistente().readByExecutionCourse(executionCourse.getIdInternal());                    Iterator iterator = shifts.iterator();                    while (iterator.hasNext()) {                        IShift shift = (IShift) iterator.next();                        if (shift.getTipo().equals(ShiftType.TEORICA)) {                            theoreticalCapacity = new Integer(theoreticalCapacity.intValue()                                    + shift.getLotacao().intValue());                        } else if (shift.getTipo().equals(ShiftType.TEORICO_PRATICA)) {                            theoPraticalCapacity = new Integer(theoPraticalCapacity.intValue()                                    + shift.getLotacao().intValue());                        } else if (shift.getTipo().equals(ShiftType.DUVIDAS)) {                            doubtsCapacity = new Integer(doubtsCapacity.intValue()                                    + shift.getLotacao().intValue());                        } else if (shift.getTipo().equals(ShiftType.LABORATORIAL)) {                            labCapacity = new Integer(labCapacity.intValue()                                    + shift.getLotacao().intValue());                        } else if (shift.getTipo().equals(ShiftType.PRATICA)) {                            praticalCapacity = new Integer(praticalCapacity.intValue()                                    + shift.getLotacao().intValue());                        } else if (shift.getTipo().equals(ShiftType.RESERVA)) {                            reserveCapacity = new Integer(reserveCapacity.intValue()                                    + shift.getLotacao().intValue());                        }                    }                    infoExecutionCourse = InfoExecutionCourse.newInfoFromDomain(executionCourse);                    List capacities = new ArrayList();                    if (theoreticalCapacity.intValue() != 0) {                        capacities.add(theoreticalCapacity);                    }                    if (theoPraticalCapacity.intValue() != 0) {                        capacities.add(theoPraticalCapacity);                    }                    if (doubtsCapacity.intValue() != 0) {                        capacities.add(doubtsCapacity);                    }                    if (labCapacity.intValue() != 0) {                        capacities.add(labCapacity);                    }                    if (praticalCapacity.intValue() != 0) {                        capacities.add(praticalCapacity);                    }                    if (reserveCapacity.intValue() != 0) {                        capacities.add(reserveCapacity);                    }                    int total = 0;                    if (!capacities.isEmpty()) {                        total = ((Integer) Collections.min(capacities)).intValue();                    }                    if (total == 0) {                        infoExecutionCourse.setOccupancy(new Double(-1));                    } else {                        infoExecutionCourse.setOccupancy(NumberUtils.formatNumber(                                new Double((new Double(executionCourse.getAttendsCount())                                        .floatValue() * 100 / total)), 1));                    }                    return infoExecutionCourse;                }