.readByExecutionYearAndDegreeType(executionYear.getIdInternal(), DegreeType.MASTER_DEGREE);
.readByExecutionYearAndDegreeType(executionYear.getYear(), DegreeType.MASTER_DEGREE);
    public void run(Integer executionYearID) throws FenixServiceException {        try {            ISuportePersistente sp = PersistenceSupportFactory.getDefaultPersistenceSupport();            IExecutionYear executionYear = (IExecutionYear) sp.getIPersistentExecutionYear().readByOID(                    ExecutionYear.class, executionYearID);            IPersistentStudentCurricularPlan studentCurricularPlanDAO = sp                    .getIStudentCurricularPlanPersistente();            IPersistentGratuitySituation gratuitySituationDAO = sp.getIPersistentGratuitySituation();            IPersistentInsuranceTransaction insuranceTransactionDAO = sp                    .getIPersistentInsuranceTransaction();            IInsuranceValue insuranceValue = sp.getIPersistentInsuranceValue().readByExecutionYear(                    executionYear.getIdInternal());            IPersistentGratuityValues gratuityValuesDAO = sp.getIPersistentGratuityValues();            if (insuranceValue == null) {                throw new InsuranceNotDefinedServiceException("error.insurance.notDefinedForThisYear");            }            String shortYear = executionYear.getYear().split("/")[0].trim().substring(2);            // read master degree and specialization execution degrees            List executionDegreeList = sp.getIPersistentExecutionDegree()                    .readByExecutionYearAndDegreeType(executionYear.getIdInternal(), DegreeType.MASTER_DEGREE);            List gratuityLetterFileEntries = new ArrayList();            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");            NumberFormat numberFormat = NumberFormat.getInstance();            DecimalFormat decimalFormat = (DecimalFormat) numberFormat;            decimalFormat.applyPattern("######.##");            HashMap studentsWithInsuranceChecked = new HashMap();            for (Iterator iter = executionDegreeList.iterator(); iter.hasNext();) {                IExecutionDegree executionDegree = (IExecutionDegree) iter.next();                IDegreeCurricularPlan degreeCurricularPlan = executionDegree.getDegreeCurricularPlan();                List studentCurricularPlanList = studentCurricularPlanDAO                        .readByDegreeCurricularPlan(degreeCurricularPlan);                IGratuityValues gratuityValues = gratuityValuesDAO                        .readGratuityValuesByExecutionDegree(executionDegree);                for (Iterator iterator = studentCurricularPlanList.iterator(); iterator.hasNext();) {                    IStudentCurricularPlan studentCurricularPlan = (IStudentCurricularPlan) iterator                            .next();                    IStudent student = (studentCurricularPlan.getStudent());                    GratuityLetterFileEntry gratuityLetterFileEntryInsurancePart = null;                    if (studentsWithInsuranceChecked.containsKey(student.getIdInternal()) == false) {                        studentsWithInsuranceChecked.put(student.getIdInternal(), null);                        List insuranceTransactionList = insuranceTransactionDAO                                .readAllNonReimbursedByExecutionYearAndStudent(executionYear, student);                        if (insuranceTransactionList.size() == 0) {                            //student hasn't payed insurance                            gratuityLetterFileEntryInsurancePart = new GratuityLetterFileEntry(                                    studentCurricularPlan);                            gratuityLetterFileEntryInsurancePart.setInsuranceEndDate(simpleDateFormat                                    .format(insuranceValue.getEndDate()));                            gratuityLetterFileEntryInsurancePart.setInsuranceFullSibsReference(shortYear                                    + addCharToStringUntilMax(                                            SibsOutgoingPaymentFileConstants.ZERO_CHAR, student                                                    .getNumber().toString(),                                            SibsOutgoingPaymentFileConstants.MAX_STUDENT_NUMBER_LENGTH)                                    + SibsPaymentCodeFactory.getCode(SibsPaymentType.INSURANCE));                            gratuityLetterFileEntryInsurancePart.setInsuranceValue(decimalFormat                                    .format(insuranceValue.getAnnualValue()));                        }                    }                    GratuityLetterFileEntry gratuityLetterFileEntry = null;                    //                    if ((studentCurricularPlan.getSpecialization().equals(                    //                            Specialization.INTEGRADO_TYPE) == false)                    //                            && (gratuityValues != null)) {                    if (gratuityValues != null) {                        IGratuitySituation gratuitySituation = gratuitySituationDAO                                .readGratuitySituatuionByStudentCurricularPlanAndGratuityValues(                                        studentCurricularPlan, gratuityValues);                        if (gratuitySituation != null) {                            gratuityLetterFileEntry = createGratuityLetterFileEntry(gratuitySituation,                                    shortYear);                        }                    }                    if (gratuityLetterFileEntry == null) {                        //there wasn't gratuity part (only insurance)                        gratuityLetterFileEntry = gratuityLetterFileEntryInsurancePart;                    } else {                        if (gratuityLetterFileEntryInsurancePart != null) {                            //insurance part exists                            gratuityLetterFileEntry                                    .setInsuranceEndDate(gratuityLetterFileEntryInsurancePart                                            .getInsuranceEndDate());                            gratuityLetterFileEntry                                    .setInsuranceFullSibsReference(gratuityLetterFileEntryInsurancePart                                            .getInsuranceFullSibsReference());                            gratuityLetterFileEntry                                    .setInsuranceValue(gratuityLetterFileEntryInsurancePart                                            .getInsuranceValue());                        }                    }                    //this check is required because the insurance part can                    // also be null                    if (gratuityLetterFileEntry != null) {                        gratuityLetterFileEntries.add(gratuityLetterFileEntry);                    }                }            }            writeLetterFiles(gratuityLetterFileEntries, executionYear);        } catch (ExcepcaoPersistencia e) {            FenixServiceException newEx = new FenixServiceException("Persistence layer error");            newEx.fillInStackTrace();            throw newEx;        }    }