ISuportePersistente persistentSupport = null;
    public Object run(Integer executionDegreeId, String executionYearName, String persistentSupportecializationName,            String gratuitySituationTypeName) throws FenixServiceException {        // at least one of the arguments it's obligator        if (executionDegreeId == null && executionYearName == null) {            throw new FenixServiceException(                    "error.masterDegree.gratuity.impossible.studentsGratuityList");        }        HashMap result = null;        ISuportePersistente persistentSupport = null;        try {            IPersistentExecutionDegree executionDegreeDAO = persistentSupport.getIPersistentExecutionDegree();            IPersistentGratuitySituation gratuitySituationDAO = persistentSupport.getIPersistentGratuitySituation();            IPersistentInsuranceTransaction insuranceTransactionDAO = persistentSupport                    .getIPersistentInsuranceTransaction();            List executionDegreeList = new ArrayList();            if (executionDegreeId != null) {                ExecutionDegree executionDegree = (ExecutionDegree) persistentObject.readByOID(                        ExecutionDegree.class, executionDegreeId);                executionDegreeList.add(executionDegree);            } else {                // the execution degree wasn't supplied so                // we have to show all execution degrees from the choosen year                if (executionYearName != null) {                    IPersistentExecutionYear persistentExecutionYear = persistentSupport.getIPersistentExecutionYear();                    ExecutionYear executionYear = persistentExecutionYear.readExecutionYearByName(executionYearName);                    if (executionYear != null) {                        executionDegreeList = executionDegreeDAO.readByExecutionYearAndDegreeType(                                executionYear.getYear(), DegreeType.MASTER_DEGREE);                    }                }            }            if (executionDegreeList == null || executionDegreeList.size() == 0) {                throw new FenixServiceException(                        "error.masterDegree.gratuity.impossible.studentsGratuityList");            }            // GRATUITY SITUATION            GratuitySituationType gratuitySituationType = null;            if (!gratuitySituationTypeName.equals("all")) {                gratuitySituationType = GratuitySituationType.valueOf(gratuitySituationTypeName);            }            List infoGratuitySituationList = new ArrayList();            double totalPayedValue = 0;            double totalRemaingValue = 0;            for (Iterator iter = executionDegreeList.iterator(); iter.hasNext();) {                ExecutionDegree executionDegree = (ExecutionDegree) iter.next();                GratuityValues gratuityValues = executionDegree.getGratuityValues();                if (gratuityValues == null) {                    continue;                }                List allStudentCurricularPlans = executionDegree.getDegreeCurricularPlan().getStudentCurricularPlans();                List filteredStudentCurricularPlans = (List) CollectionUtils.select(allStudentCurricularPlans,new Predicate(){                    public boolean evaluate(Object arg0) {                        StudentCurricularPlan scp = (StudentCurricularPlan) arg0;                        return scp.getSpecialization() != null;                    }});                for (Iterator iterator = filteredStudentCurricularPlans.iterator(); iterator.hasNext();) {                    StudentCurricularPlan studentCurricularPlan = (StudentCurricularPlan) iterator                            .next();                    GratuitySituation gratuitySituation = gratuitySituationDAO                            .readByStudentCurricularPlanAndGratuityValuesAndGratuitySituationType(                                    studentCurricularPlan.getIdInternal(), gratuityValues                                            .getIdInternal(), gratuitySituationType);                    if (gratuitySituation == null) {                        // ignore them, because they will be created in the next                        // day                        // when the gratuity situation creator scheduled task                        // runs                        continue;                    }                    InfoGratuitySituation infoGratuitySituation = InfoGratuitySituationWithInfoPersonAndInfoExecutionDegree                            .newInfoFromDomain(gratuitySituation);                    fillSituationType(infoGratuitySituation);                    List insuranceTransactionList = insuranceTransactionDAO                            .readAllNonReimbursedByExecutionYearAndStudent(executionDegree                                    .getExecutionYear().getIdInternal(), studentCurricularPlan.getStudent().getIdInternal());                    /*                     * InsuranceTransaction insuranceTransaction =                     * insuranceTransactionDAO                     * .readByExecutionYearAndStudent(executionDegree                     * .getExecutionYear(), studentCurricularPlan                     * .getStudent());                     */                    if (insuranceTransactionList.size() > 0) {                        infoGratuitySituation.setInsurancePayed(SessionConstants.PAYED_INSURANCE);                    } else {                        infoGratuitySituation.setInsurancePayed(SessionConstants.NOT_PAYED_INSURANCE);                    }                    if (infoGratuitySituation.getTotalValue() != null                            && infoGratuitySituation.getRemainingValue() != null) {                        double exemption = 0;                        if (infoGratuitySituation.getExemptionPercentage() != null) {                            exemption = infoGratuitySituation.getTotalValue().doubleValue()                                    * infoGratuitySituation.getExemptionPercentage().doubleValue() / 100;                        }                        if (infoGratuitySituation.getExemptionValue() != null) {                            exemption += infoGratuitySituation.getExemptionValue().doubleValue();                        }                        Double payedValue = new Double(infoGratuitySituation.getTotalValue()                                .doubleValue()                                - infoGratuitySituation.getRemainingValue().doubleValue() - exemption);                        infoGratuitySituation.setPayedValue(payedValue);                        totalPayedValue += payedValue.doubleValue();                    }                    infoGratuitySituationList.add(infoGratuitySituation);                    totalRemaingValue += infoGratuitySituation.getRemainingValue().doubleValue();                }            }            // build the result that is a hash map with a list, total payed and            // remaining value            result = new HashMap();            result.put(new Integer(0), infoGratuitySituationList);            result.put(new Integer(1), new Double(totalPayedValue));            result.put(new Integer(2), new Double(totalRemaingValue));        } catch (Exception e) {            e.printStackTrace();            if (e.getMessage() != null && e.getMessage().length() > 0) {                throw new FenixServiceException(e.getMessage());            }            throw new FenixServiceException(                    "error.masterDegree.gratuity.impossible.studentsGratuityList");        }        return result;    }