コード例 #1
0
ファイル: ChooseGuide.java プロジェクト: joantune/fenix
  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;
  }
コード例 #2
0
ファイル: ChooseGuide.java プロジェクト: joantune/fenix
  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;
  }
コード例 #3
0
ファイル: ChooseGuide.java プロジェクト: joantune/fenix
  /**
   * 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;
  }
コード例 #4
0
 @Override
 public void copyFromDomain(Guide guide) {
   super.copyFromDomain(guide);
   if (guide != null) {
     setInfoPerson(InfoPerson.newInfoFromDomain(guide.getPerson()));
   }
 }
コード例 #5
0
 /*
  * (non-Javadoc)
  *
  * @see
  * net.sourceforge.fenixedu.dataTransferObject.InfoGuide#copyFromDomain(
  * Dominio.Guide)
  */
 @Override
 public void copyFromDomain(Guide guide) {
   super.copyFromDomain(guide);
   if (guide != null) {
     setInfoGuideEntries(copyIGuideEntry2InfoGuide(guide.getGuideEntries()));
   }
 }
コード例 #6
0
ファイル: ChooseGuide.java プロジェクト: joantune/fenix
  public List run(Integer guideYear) throws Exception {

    List guides = Guide.readByYear(guideYear);
    if (guides.isEmpty()) {
      throw new NonExistingServiceException();
    }

    BeanComparator numberComparator = new BeanComparator("number");
    BeanComparator versionComparator = new BeanComparator("version");
    ComparatorChain chainComparator = new ComparatorChain();
    chainComparator.addComparator(numberComparator);
    chainComparator.addComparator(versionComparator);
    Collections.sort(guides, chainComparator);

    // CollectionUtils.filter(guides,)
    List result = getLatestVersions(guides);

    return result;
  }
コード例 #7
0
ファイル: CreateGuide.java プロジェクト: joantune/fenix
  @Checked("RolePredicates.MASTER_DEGREE_ADMINISTRATIVE_OFFICE_PREDICATE")
  @Service
  public static InfoGuide run(
      InfoGuide infoGuide,
      String othersRemarks,
      Double othersPrice,
      String remarks,
      GuideState situationOfGuide,
      String paymentType)
      throws FenixServiceException {

    GuideSituation guideSituation = null;

    // Check the Guide Situation
    if (situationOfGuide.equals(GuideState.ANNULLED)) {
      throw new InvalidSituationServiceException();
    }

    InfoGuideEntry infoGuideEntry = new InfoGuideEntry();
    if ((othersPrice != null) && (othersPrice.floatValue() > 0)) {
      infoGuideEntry.setDescription(othersRemarks);
      infoGuideEntry.setPrice(othersPrice);
      infoGuideEntry.setInfoGuide(infoGuide);
      infoGuideEntry.setDocumentType(DocumentType.OTHERS);
      infoGuideEntry.setGraduationType(GraduationType.MASTER_DEGREE);
      infoGuideEntry.setQuantity(Integer.valueOf(1));
      List entries = infoGuide.getInfoGuideEntries();
      entries.add(infoGuideEntry);
      infoGuide.setInfoGuideEntries(entries);
    }

    // Calculate the Guide Total Price
    infoGuide.setTotal(CalculateGuideTotal.calculate(infoGuide));

    // Get the Guide Number
    Integer guideNumber = Guide.generateGuideNumber();
    infoGuide.setNumber(guideNumber);

    // Create the new Guide Situation
    InfoGuideSituation infoGuideSituation = new InfoGuideSituation();
    infoGuideSituation.setState(new State(State.ACTIVE));
    infoGuideSituation.setRemarks(remarks);
    infoGuideSituation.setInfoGuide(infoGuide);

    Calendar calendar = Calendar.getInstance();
    infoGuideSituation.setDate(calendar.getTime());
    infoGuideSituation.setSituation(situationOfGuide);

    Person person =
        (Person) rootDomainObject.readPartyByOID(infoGuide.getInfoPerson().getIdInternal());
    ExecutionDegree executionDegree =
        rootDomainObject.readExecutionDegreeByOID(
            infoGuide.getInfoExecutionDegree().getIdInternal());
    final Party contributor =
        infoGuide.getInfoContributor() != null
            ? rootDomainObject.readPartyByOID(infoGuide.getInfoContributor().getIdInternal())
            : person;

    Guide guide = new Guide();
    guide.setExecutionDegree(executionDegree);
    guide.setContributorParty(contributor);
    guide.setPerson(person);
    guide.setCreationDate(infoGuide.getCreationDate());
    guide.setGuideRequester(infoGuide.getGuideRequester());
    guide.setNumber(infoGuide.getNumber());
    guide.setPaymentDate(infoGuide.getPaymentDate());
    guide.setPaymentType(infoGuide.getPaymentType());
    guide.setRemarks(infoGuide.getRemarks());
    guide.setTotal(infoGuide.getTotal());
    guide.setVersion(infoGuide.getVersion());
    guide.setYear(infoGuide.getYear());

    if (situationOfGuide.equals(GuideState.PAYED)) {
      guide.setPaymentType(PaymentType.valueOf(paymentType));
      guide.setPaymentDate(calendar.getTime());
    }

    // Write the new Entries of the Guide
    for (InfoGuideEntry infoGuideEntryIter : infoGuide.getInfoGuideEntries()) {
      GuideEntry guideEntry = new GuideEntry();

      guideEntry.setDescription(infoGuideEntryIter.getDescription());
      guideEntry.setDocumentType(infoGuideEntryIter.getDocumentType());
      guideEntry.setGraduationType(infoGuideEntryIter.getGraduationType());
      guideEntry.setPrice(infoGuideEntryIter.getPrice());
      guideEntry.setQuantity(infoGuideEntryIter.getQuantity());

      guide.addGuideEntries(guideEntry);
    }

    // Write the New Guide Situation
    guideSituation =
        new GuideSituation(
            situationOfGuide, remarks, calendar.getTime(), guide, new State(State.ACTIVE));

    InfoGuide result = InfoGuideWithPersonAndExecutionDegreeAndContributor.newInfoFromDomain(guide);
    result.setInfoGuideEntries(infoGuide.getInfoGuideEntries());
    result.setInfoGuideSituation(infoGuideSituation);
    result.setInfoGuideSituations(new ArrayList(1));
    result.getInfoGuideSituations().add(infoGuideSituation);

    return result;
  }