IPersistentReimbursementTransaction reimbursementTransactionDAO = sp .getIPersistentReimbursementTransaction();
for (Iterator iter = reimbursementTransactionList.iterator(); iter.hasNext();) { IReimbursementTransaction reimbursementTransaction = (IReimbursementTransaction) iter.next(); infoTransactionList.add(InfoTransaction.newInfoFromDomain(reimbursementTransaction)); }
    public List run(Integer gratuitySituationID) throws FenixServiceException {        List infoTransactionList = new ArrayList();        try {            List paymentTransactionList = new ArrayList();            List reimbursementTransactionList = new ArrayList();            ISuportePersistente sp = PersistenceSupportFactory.getDefaultPersistenceSupport();            IGratuitySituation gratuitySituation = (IGratuitySituation) sp                    .getIPersistentGratuitySituation().readByOID(GratuitySituation.class,                            gratuitySituationID);            List insuranceTransactionList = sp.getIPersistentInsuranceTransaction()                    .readAllByExecutionYearAndStudent(                            gratuitySituation.getGratuityValues().getExecutionDegree()                                    .getExecutionYear(),                            gratuitySituation.getStudentCurricularPlan().getStudent());            // read insurance transactions            for (Iterator iter = insuranceTransactionList.iterator(); iter.hasNext();) {                IInsuranceTransaction insuranceTransaction = (IInsuranceTransaction) iter.next();                paymentTransactionList.add(insuranceTransaction);            }            List gratuityTransactionList = sp.getIPersistentGratuityTransaction()                    .readAllByGratuitySituation(gratuitySituation);            // read gratuity transactions            for (Iterator iter = gratuityTransactionList.iterator(); iter.hasNext();) {                IGratuityTransaction gratuityTransaction = (IGratuityTransaction) iter.next();                paymentTransactionList.add(gratuityTransaction);            }            IPersistentReimbursementTransaction reimbursementTransactionDAO = sp                    .getIPersistentReimbursementTransaction();            // read reimbursement transactions            for (Iterator iter = paymentTransactionList.iterator(); iter.hasNext();) {                IPaymentTransaction paymentTransaction = (IPaymentTransaction) iter.next();                IGuideEntry guideEntry = paymentTransaction.getGuideEntry();                if ((guideEntry != null)                        && ((guideEntry.getDocumentType().equals(DocumentType.INSURANCE) || (guideEntry                                .getDocumentType().equals(DocumentType.GRATUITY))))) {                    List reimbursementGuideEntryList = guideEntry.getReimbursementGuideEntries();                    for (Iterator iterator = reimbursementGuideEntryList.iterator(); iterator.hasNext();) {                        IReimbursementGuideEntry reimbursementGuideEntry = (IReimbursementGuideEntry) iterator                                .next();                        // we have to read again because of OJB bug                        IReimbursementGuideEntry newReimbursementGuideEntry = (IReimbursementGuideEntry) sp                                .getIPersistentReimbursementGuideEntry().readByOID(                                        ReimbursementGuideEntry.class,                                        reimbursementGuideEntry.getIdInternal());                        IReimbursementGuide reimbursementGuide = (IReimbursementGuide) sp                                .getIPersistentReimbursementGuide().readByOID(                                        ReimbursementGuide.class,                                        ((ReimbursementGuideEntry) reimbursementGuideEntry)                                                .getKeyReimbursementGuide());                        if (reimbursementGuide.getActiveReimbursementGuideSituation()                                .getReimbursementGuideState().equals(ReimbursementGuideState.PAYED) == false) {                            //reimbursement is not payed, so there is no                            // transaction                            continue;                        }                        IReimbursementTransaction reimbursementTransaction = reimbursementTransactionDAO                                .readByReimbursementGuideEntry(newReimbursementGuideEntry);                        if (reimbursementTransaction == null) {                            throw new NonExistingServiceException(                                    "Database is inconsistent because this reimbursement guide entry is supposed to have a reimbursement transaction");                        }                        reimbursementTransactionList.add(reimbursementTransaction);                    }                }            }            for (Iterator iter = insuranceTransactionList.iterator(); iter.hasNext();) {                IInsuranceTransaction insuranceTransaction = (IInsuranceTransaction) iter.next();                infoTransactionList.add(InfoTransaction.newInfoFromDomain(insuranceTransaction));            }            for (Iterator iter = gratuityTransactionList.iterator(); iter.hasNext();) {                IGratuityTransaction gratuityTransaction = (IGratuityTransaction) iter.next();                infoTransactionList.add(InfoTransaction.newInfoFromDomain(gratuityTransaction));            }            for (Iterator iter = reimbursementTransactionList.iterator(); iter.hasNext();) {                IReimbursementTransaction reimbursementTransaction = (IReimbursementTransaction) iter                        .next();                infoTransactionList.add(InfoTransaction.newInfoFromDomain(reimbursementTransaction));            }            BeanComparator transactionDateComparator = new BeanComparator("transactionDate");            ComparatorChain chainComparator = new ComparatorChain();            chainComparator.addComparator(transactionDateComparator, true);            Collections.sort(infoTransactionList, chainComparator);            return infoTransactionList;        } catch (ExcepcaoPersistencia ex) {            FenixServiceException newEx = new FenixServiceException("Persistence layer error");            newEx.fillInStackTrace();            throw newEx;        }    }