Example #1
0
  public List run(Integer guideNumber, Integer guideYear) throws FenixServiceException {
    List guides = null;

    guides = Guide.readByNumberAndYear(guideNumber, guideYear);

    if (guides == null || guides.isEmpty()) {
      throw new NonExistingServiceException();
    }

    Iterator iterator = guides.iterator();
    List result = new ArrayList();
    while (iterator.hasNext()) {
      Guide guide = (Guide) iterator.next();

      InfoGuide infoGuide =
          InfoGuideWithPersonAndExecutionDegreeAndContributor.newInfoFromDomain(guide);
      List infoReimbursementGuides = new ArrayList();
      if (guide.getReimbursementGuides() != null) {
        Iterator iter = guide.getReimbursementGuides().iterator();
        while (iter.hasNext()) {
          ReimbursementGuide reimbursementGuide = (ReimbursementGuide) iter.next();
          InfoReimbursementGuide infoReimbursementGuide =
              InfoReimbursementGuide.newInfoFromDomain(reimbursementGuide);

          infoReimbursementGuides.add(infoReimbursementGuide);
        }
      }
      infoGuide.setInfoReimbursementGuides(infoReimbursementGuides);
      result.add(infoGuide);
    }
    return result;
  }
Example #2
0
  public InfoGuide run(Integer guideNumber, Integer guideYear, Integer guideVersion)
      throws Exception {

    Guide guide = null;

    guide = Guide.readByNumberAndYearAndVersion(guideNumber, guideYear, guideVersion);

    if (guide == null) {
      throw new NonExistingServiceException();
    }
    InfoGuide infoGuide =
        InfoGuideWithPersonAndExecutionDegreeAndContributorAndExecutionYear.newInfoFromDomain(
            guide);

    List infoReimbursementGuides = new ArrayList();
    if (guide.getReimbursementGuides() != null) {
      Iterator iter = guide.getReimbursementGuides().iterator();
      while (iter.hasNext()) {
        ReimbursementGuide reimbursementGuide = (ReimbursementGuide) iter.next();
        InfoReimbursementGuide infoReimbursementGuide =
            InfoReimbursementGuide.newInfoFromDomain(reimbursementGuide);
        infoReimbursementGuides.add(infoReimbursementGuide);
      }
    }
    infoGuide.setInfoReimbursementGuides(infoReimbursementGuides);
    return infoGuide;
  }
Example #3
0
  /**
   * This function expects to receive a list ordered by number (Ascending) and version (Descending)
   *
   * @param guides
   * @return The latest version for the guides
   */
  private List getLatestVersions(List guides) {
    List result = new ArrayList();
    Integer numberAux = null;

    Collections.reverse(guides);

    Iterator iterator = guides.iterator();
    while (iterator.hasNext()) {
      Guide guide = (Guide) iterator.next();

      if ((numberAux == null) || (numberAux.intValue() != guide.getNumber().intValue())) {
        numberAux = guide.getNumber();
        InfoGuide infoGuide =
            InfoGuideWithPersonAndExecutionDegreeAndContributor.newInfoFromDomain(guide);

        List infoReimbursementGuides = new ArrayList();
        if (guide.getReimbursementGuides() != null) {
          Iterator iter = guide.getReimbursementGuides().iterator();
          while (iter.hasNext()) {
            ReimbursementGuide reimbursementGuide = (ReimbursementGuide) iter.next();
            InfoReimbursementGuide infoReimbursementGuide =
                InfoReimbursementGuide.newInfoFromDomain(reimbursementGuide);
            infoReimbursementGuides.add(infoReimbursementGuide);
          }
        }
        infoGuide.setInfoReimbursementGuides(infoReimbursementGuides);
        result.add(infoGuide);
      }
    }
    Collections.reverse(result);
    return result;
  }