Ejemplo n.º 1
0
 public final Integer createCandidacyNumber() {
   if (Bennu.getInstance().getCandidaciesSet().size() == 0) {
     return Integer.valueOf(1);
   }
   Candidacy candidacy =
       Collections.max(Bennu.getInstance().getCandidaciesSet(), new BeanComparator("number"));
   return candidacy.getNumber() + 1;
 }
Ejemplo n.º 2
0
 public InquiryGlobalComment(ExecutionCourse executionCourse, ExecutionDegree executionDegree) {
   super();
   setRootDomainObject(Bennu.getInstance());
   setExecutionCourse(executionCourse);
   setExecutionDegree(executionDegree);
   setCommentOnTeacher(false);
 }
 public static pt.ist.fenixframework.dml.runtime.DirectRelation<
         org.fenixedu.bennu.core.domain.Bennu,
         org.fenixedu.academic.domain.phd.candidacy.PhdCandidacyRefereeLetter>
     getRelationPhdCandidacyRefereeLetterRootDomainObject() {
   return org.fenixedu.bennu.core.domain.Bennu
       .getRelationPhdCandidacyRefereeLetterRootDomainObject();
 }
Ejemplo n.º 4
0
 public InquiryGlobalComment(Person teacher, ExecutionSemester executionSemester) {
   super();
   setRootDomainObject(Bennu.getInstance());
   setTeacher(teacher);
   setExecutionSemester(executionSemester);
   setCommentOnTeacher(true);
 }
Ejemplo n.º 5
0
 public Country(
     Planet parent,
     String iso3166alpha2Code,
     String iso3166alpha3Code,
     Integer iso3166numericCode,
     LocalizedString name,
     LocalizedString nationality,
     Class<AddressPrinter> iAddressPrinter) {
   super();
   setBennu(Bennu.getInstance());
   setUnit(
       Unit.create(
           parent.getUnit(),
           name,
           iso3166alpha3Code,
           getPartyType("País", COUNTRY_PARTYTYPE_NAME),
           getOrCreateAccountabilityType(),
           new LocalDate(),
           null,
           null));
   setIso3166alpha2Code(iso3166alpha2Code);
   setIAddressPrinter(iAddressPrinter);
   setIso3166alpha3Code(iso3166alpha3Code);
   setIso3166numericCode(iso3166numericCode);
   setNationality(nationality);
 }
Ejemplo n.º 6
0
  public static List<ExecutionDegree> getAllByExecutionCourseAndTeacher(
      ExecutionCourse executionCourse, Person person) {
    List<ExecutionDegree> result = new ArrayList<ExecutionDegree>();

    for (ExecutionDegree executionDegree : Bennu.getInstance().getExecutionDegreesSet()) {
      boolean matchExecutionCourse = false;
      for (CurricularCourse curricularCourse :
          executionDegree.getDegreeCurricularPlan().getCurricularCoursesSet()) {
        if (curricularCourse.getAssociatedExecutionCoursesSet().contains(executionCourse)) {
          matchExecutionCourse = true;
          break;
        }
      }

      if (!matchExecutionCourse) {
        continue;
      }

      // if teacher is not a coordinator of the executionDegree
      if (executionDegree.getCoordinatorByTeacher(person) == null) {
        continue;
      }

      result.add(executionDegree);
    }

    return result;
  }
Ejemplo n.º 7
0
 public static Set<AcademicServiceRequest> getAcademicServiceRequests(
     Party party, Integer year, AcademicServiceRequestSituationType situation, Interval interval) {
   Set<AcademicServiceRequest> serviceRequests = new HashSet<AcademicServiceRequest>();
   Set<AcademicProgram> programs =
       getProgramsForOperation(party, AcademicOperationType.SERVICE_REQUESTS);
   Collection<AcademicServiceRequest> possible = null;
   if (year != null) {
     possible = AcademicServiceRequestYear.getAcademicServiceRequests(year);
   } else {
     possible = Bennu.getInstance().getAcademicServiceRequestsSet();
   }
   for (AcademicServiceRequest request : possible) {
     if (!programs.contains(request.getAcademicProgram())) {
       continue;
     }
     if (situation != null
         && !request.getAcademicServiceRequestSituationType().equals(situation)) {
       continue;
     }
     if (interval != null && !interval.contains(request.getActiveSituationDate())) {
       continue;
     }
     serviceRequests.add(request);
   }
   return serviceRequests;
 }
Ejemplo n.º 8
0
  private static Map<PhdProgramFocusArea, Set<PhdProgramPublicCandidacyHashCode>> getApplicants(
      final List<PhdProgramPublicCandidacyHashCode> unfocusAreaCandidates) {
    final Map<PhdProgramFocusArea, Set<PhdProgramPublicCandidacyHashCode>> candidates =
        new TreeMap<PhdProgramFocusArea, Set<PhdProgramPublicCandidacyHashCode>>(
            PhdProgramFocusArea.COMPARATOR_BY_NAME);

    for (final PublicCandidacyHashCode hashCode : Bennu.getInstance().getCandidacyHashCodesSet()) {
      if (hashCode.isFromPhdProgram() && hashCode.hasCandidacyProcess()) {

        final PhdProgramPublicCandidacyHashCode phdHashCode =
            (PhdProgramPublicCandidacyHashCode) hashCode;

        if (phdHashCode.getIndividualProgramProcess().getExecutionYear()
            != ExecutionYear.readCurrentExecutionYear()) {
          continue;
        }

        if (!PhdIndividualProgramCollaborationType.EPFL.equals(
            phdHashCode.getIndividualProgramProcess().getCollaborationType())) {
          continue;
        }

        if (!PhdIndividualProgramProcessState.CANDIDACY.equals(
            phdHashCode.getIndividualProgramProcess().getActiveState())) {
          continue;
        }

        //                if (phdHashCode.getPhdProgramCandidacyProcess().isValidatedByCandidate())
        // {
        addCandidate(unfocusAreaCandidates, candidates, phdHashCode);
        //                }
      }
    }
    return candidates;
  }
Ejemplo n.º 9
0
 private void checkForEqualFocusArea(final MultiLanguageString name) {
   for (final PhdProgramFocusArea focusArea : Bennu.getInstance().getPhdProgramFocusAreasSet()) {
     if (focusArea != this && focusArea.getName().equalInAnyLanguage(name)) {
       throw new DomainException("error.PhdProgramFocusArea.found.area.with.same.name");
     }
   }
 }
Ejemplo n.º 10
0
  public static List<ExecutionDegree> getAllByDegreeAndCurricularStage(
      Degree degree, CurricularStage stage) {
    List<ExecutionDegree> result = new ArrayList<ExecutionDegree>();

    if (degree == null) {
      return result;
    }

    if (stage == null) {
      return result;
    }

    for (ExecutionDegree executionDegree : Bennu.getInstance().getExecutionDegreesSet()) {
      if (!degree.equals(executionDegree.getDegreeCurricularPlan().getDegree())) {
        continue;
      }

      if (!stage.equals(executionDegree.getDegreeCurricularPlan().getCurricularStage())) {
        continue;
      }

      result.add(executionDegree);
    }

    return result;
  }
 private List<SelectItem> readAllowedDepartmentUnits() {
   final List<SelectItem> result = new ArrayList<SelectItem>();
   for (final Department department : Bennu.getInstance().getDepartmentsSet()) {
     if (department.getCompetenceCourseMembersGroup() != null
         && department.getCompetenceCourseMembersGroup().isMember(getUserView())) {
       DepartmentUnit departmentUnit = department.getDepartmentUnit();
       result.add(new SelectItem(departmentUnit.getExternalId(), departmentUnit.getName()));
     }
   }
   Collections.sort(result, new BeanComparator("label"));
   if (result.size() == 1) {
     Department personDepartment = getPersonDepartment();
     if (personDepartment != null
         && !result
             .get(0)
             .getValue()
             .equals(personDepartment.getDepartmentUnit().getExternalId())) {
       result.add(
           0,
           new SelectItem(
               personDepartment.getDepartmentUnit().getExternalId(), personDepartment.getName()));
     }
   }
   return result;
 }
Ejemplo n.º 12
0
 public static Candidacy readByCandidacyNumber(Integer candidacyNumber) {
   for (Candidacy candidacy : Bennu.getInstance().getCandidaciesSet()) {
     if (candidacy.getNumber().equals(candidacyNumber)) {
       return candidacy;
     }
   }
   return null;
 }
Ejemplo n.º 13
0
 public TutorshipSummaryPeriod(
     ExecutionSemester executionSemester, LocalDate beginDate, LocalDate endDate) {
   super();
   setRootDomainObject(Bennu.getInstance());
   setExecutionSemester(executionSemester);
   setBeginDate(beginDate);
   setEndDate(endDate);
 }
 protected ExternalEnrolment() {
   super();
   setRootDomainObject(Bennu.getInstance());
   setCreationDateDateTime(new DateTime());
   if (AccessControl.getPerson() != null) {
     setCreatedBy(AccessControl.getPerson().getUsername());
   }
 }
Ejemplo n.º 15
0
 public static Country findByAcronym(String acronym) {
   for (Country country : Bennu.getInstance().getCountriesSet()) {
     if (country.getAcronym().equalsIgnoreCase(acronym)) {
       return country;
     }
   }
   return null;
 }
Ejemplo n.º 16
0
 public static Country findByIso3166alpha3Code(String code) {
   for (Country country : Bennu.getInstance().getCountriesSet()) {
     if (country.getIso3166alpha3Code().equalsIgnoreCase(code)) {
       return country;
     }
   }
   return null;
 }
Ejemplo n.º 17
0
 @Test
 @Atomic(mode = TxMode.READ)
 public void membership() {
   assertEquals(
       Group.logged().getMembers().collect(Collectors.toSet()), Bennu.getInstance().getUserSet());
   assertTrue(Group.logged().isMember(user1));
   assertFalse(Group.logged().isMember(null));
 }
Ejemplo n.º 18
0
 private void checkIfCanCreate(final DateTime start, final DateTime end) {
   for (final CandidacyPeriod period : Bennu.getInstance().getCandidacyPeriodsSet()) {
     if (!period.equals(this) && period.isEpflCandidacyPeriod() && period.intercept(start, end)) {
       throw new DomainException(
           "error.EPFLInstitutionPhdCandidacyPeriod.already.contains.candidacyPeriod.in.given.dates");
     }
   }
 }
Ejemplo n.º 19
0
 public static Set<Candidacy> readCandidaciesBetween(final Integer from, final Integer to) {
   final Set<Candidacy> result = new HashSet<Candidacy>();
   for (final Candidacy candidacy : Bennu.getInstance().getCandidaciesSet()) {
     if (candidacy.getNumber() >= from && candidacy.getNumber() <= to) {
       result.add(candidacy);
     }
   }
   return result;
 }
Ejemplo n.º 20
0
  public static EPFLPhdCandidacyPeriod readEPFLPhdCandidacyPeriodForDateTime(final DateTime date) {
    for (final CandidacyPeriod period : Bennu.getInstance().getCandidacyPeriodsSet()) {
      if (period.isEpflCandidacyPeriod() && period.contains(date)) {
        return (EPFLPhdCandidacyPeriod) period;
      }
    }

    return null;
  }
 public static StudentTeacherInquiryTemplate getCurrentTemplate() {
   final Collection<InquiryTemplate> inquiryTemplates =
       Bennu.getInstance().getInquiryTemplatesSet();
   for (final InquiryTemplate inquiryTemplate : inquiryTemplates) {
     if (inquiryTemplate instanceof StudentTeacherInquiryTemplate && inquiryTemplate.isOpen()) {
       return (StudentTeacherInquiryTemplate) inquiryTemplate;
     }
   }
   return null;
 }
 public static CurricularCourseInquiryTemplate getCurrentTemplate() {
   final Collection<InquiryTemplate> inquiryTemplates =
       Bennu.getInstance().getInquiryTemplatesSet();
   for (final InquiryTemplate inquiryTemplate : inquiryTemplates) {
     if (inquiryTemplate instanceof CurricularCourseInquiryTemplate && inquiryTemplate.isOpen()) {
       return (CurricularCourseInquiryTemplate) inquiryTemplate;
     }
   }
   return null;
 }
  public static void init() {
    for (final DegreeCurricularPlan degreeCurricularPlan :
        Bennu.getInstance().getDegreeCurricularPlansSet()) {

      deleteMaximumNumberOfCreditsForEnrolmentPeriod(degreeCurricularPlan);
      createEnrolmentPeriodRestrictions(degreeCurricularPlan);
    }

    EnrolmentPeriodRestrictionsExecutorLogic.configure();
  }
Ejemplo n.º 24
0
 public static Country findByName(String name) {
   for (Country country : Bennu.getInstance().getCountriesSet()) {
     for (Locale locale : country.getName().getLocales()) {
       if (country.getName().getContent(locale).equalsIgnoreCase(name)) {
         return country;
       }
     }
   }
   return null;
 }
Ejemplo n.º 25
0
  public static List<ExecutionDegree> getAllByDegree(final Degree degree) {
    List<ExecutionDegree> result = new ArrayList<ExecutionDegree>();

    for (ExecutionDegree executionDegree : Bennu.getInstance().getExecutionDegreesSet()) {
      if (executionDegree.getDegree() == degree) {
        result.add(executionDegree);
      }
    }

    return result;
  }
 private List<SelectItem> readDepartmentUnits() {
   final List<SelectItem> result = new ArrayList<SelectItem>();
   for (final Object departmentObject : Bennu.getInstance().getDepartmentsSet()) {
     DepartmentUnit departmentUnit = ((Department) departmentObject).getDepartmentUnit();
     result.add(new SelectItem(departmentUnit.getExternalId(), departmentUnit.getName()));
   }
   Collections.sort(result, new BeanComparator("label"));
   result.add(
       0,
       new SelectItem(this.NO_SELECTION_STRING, BundleUtil.getString(Bundle.BOLONHA, "choose")));
   return result;
 }
 public static CurricularCourseInquiryTemplate getTemplateByExecutionPeriod(
     ExecutionSemester executionSemester) {
   final Collection<InquiryTemplate> inquiryTemplates =
       Bennu.getInstance().getInquiryTemplatesSet();
   for (final InquiryTemplate inquiryTemplate : inquiryTemplates) {
     if (inquiryTemplate instanceof CurricularCourseInquiryTemplate
         && executionSemester == inquiryTemplate.getExecutionPeriod()) {
       return (CurricularCourseInquiryTemplate) inquiryTemplate;
     }
   }
   return null;
 }
Ejemplo n.º 28
0
  public static RequestMapping createOrRetrieveRequestMapping(String path, String... parameters) {

    for (RequestMapping requestMapping : Bennu.getInstance().getRequestMappingsSet()) {
      if (requestMapping.getPath().equals(path)) {
        if (Arrays.equals(requestMapping.getParameters().split("&"), parameters)) {
          return requestMapping;
        }
      }
    }

    return new RequestMapping(path, parameters);
  }
Ejemplo n.º 29
0
  public static PhdProgramFocusArea readPhdProgramFocusAreaByName(final String name) {
    return (PhdProgramFocusArea)
        CollectionUtils.find(
            Bennu.getInstance().getPhdProgramFocusAreasSet(),
            new Predicate() {

              @Override
              public boolean evaluate(Object arg0) {
                return name.equals(((PhdProgramFocusArea) arg0).getName().getContent());
              }
            });
  }
Ejemplo n.º 30
0
  @GET
  @Produces(JSON_UTF8)
  @Path("suppliers")
  public String suppliers(
      @QueryParam("userID") String userID, @QueryParam("access_token") String access_token) {
    checkToken(access_token);
    Set<Supplier> suppliers = Bennu.getInstance().getSuppliersSet();
    JsonArray toReturn = new JsonArray();
    for (Supplier supplier : suppliers) {
      if (supplier != null) {
        JsonObject obj = new JsonObject();

        obj.addProperty("supplierID", supplier.getExternalId());
        obj.addProperty("fiscalID", supplier.getFiscalIdentificationCode());
        obj.addProperty("name", supplier.getName());
        obj.addProperty("shortName", supplier.getAbbreviatedName());
        obj.addProperty("limit", supplier.getSupplierLimit().toFormatString());
        JsonArray contacts = new JsonArray();
        for (SupplierContact contact : supplier.getSupplierContactSet()) {
          JsonObject contactObj = new JsonObject();
          if (contact.getAddress() != null) {
            JsonObject addressObj = new JsonObject();
            addressObj.addProperty("line1", contact.getAddress().getLine1());
            addressObj.addProperty("line2", contact.getAddress().getLine2());
            addressObj.addProperty("country", contact.getAddress().getCountry());
            contactObj.add("address", addressObj);
          }
          contactObj.addProperty("phone", contact.getPhone());
          contactObj.addProperty("fax", contact.getFax());
          contactObj.addProperty("email", contact.getEmail());
          contacts.add(contactObj);
        }
        obj.add("contacts", contacts);
        obj.addProperty("totalAllocated", supplier.getTotalAllocated().toFormatString());
        JsonArray byCpv = new JsonArray();
        for (CPVReference cpv : supplier.getAllocationsByCPVReference().keySet()) {
          if (cpv != null) {
            JsonObject cpvObj = new JsonObject();
            cpvObj.addProperty("cpvCode", cpv.getCode());
            cpvObj.addProperty("cpvDescription", cpv.getDescription());
            cpvObj.addProperty("totalAllocated", supplier.getTotalAllocated(cpv).toFormatString());
            byCpv.add(cpvObj);
            ;
          }
        }
        obj.add("allocationsByCPV", byCpv);
        toReturn.add(obj);
      }
    }

    return gson.toJson(toReturn);
  }