Ejemplo n.º 1
0
  private static Department getDepartment(String[] unitAcronyms)
      throws NonExistingServiceException {
    final Unit unit = getUnit(unitAcronyms, 2);
    if (!unit.isDepartmentUnit()) {
      throw new NonExistingServiceException();
    }

    return unit.getDepartment();
  }
Ejemplo n.º 2
0
  private static Degree getDegree(String[] unitAcronyms) throws NonExistingServiceException {
    Unit unit = getUnit(unitAcronyms, 3);

    if (!unit.isDegreeUnit()) {
      throw new NonExistingServiceException();
    }

    Degree degree = unit.getDegree();
    return degree;
  }
Ejemplo n.º 3
0
  public ActionForward configureGroups(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    Unit unit = getUnit(request);
    request.setAttribute("groups", unit.getPersistentGroupsSet());

    return mapping.findForward("managePersistedGroups");
  }
Ejemplo n.º 4
0
  @Override
  public Collection<Unit> getSearchResults(
      Map<String, String> argsMap, String value, int maxCount) {
    List<Unit> units = UnitUtils.readAllActiveUnitsByType(PartyTypeEnum.DEPARTMENT);
    units.addAll(UnitUtils.readAllActiveUnitsByType(PartyTypeEnum.DEGREE_UNIT));
    units.addAll(UnitUtils.readAllActiveUnitsByType(PartyTypeEnum.SCIENTIFIC_AREA));
    for (Iterator<Unit> iterator = units.iterator(); iterator.hasNext(); ) {
      Unit unit = iterator.next();
      if (unit.getUnitName().getIsExternalUnit()) {
        iterator.remove();
      }
    }

    return super.process(units, value, maxCount, argsMap);
  }
Ejemplo n.º 5
0
  private static Unit getUnit(String[] unitAcronyms, int maxIndex)
      throws NonExistingServiceException {
    Unit unit = UnitUtils.readInstitutionUnit();
    if (unit == null
        || StringUtils.isEmpty(unit.getAcronym())
        || !unit.getAcronym().equals(unitAcronyms[0])) {
      throw new NonExistingServiceException();
    }

    for (int i = 1; i <= maxIndex; i++) {
      unit = unit.getChildUnitByAcronym(unitAcronyms[i]);
      if (unit == null) {
        throw new NonExistingServiceException();
      }
    }

    return unit;
  }
Ejemplo n.º 6
0
 public String createFromName() {
   if (getCourse() != null
       && getCourse().getExecutionPeriod() != null
       && getCourse().getExecutionPeriod().getQualifiedName() != null) {
     String degreeName = getCourse().getDegreePresentationString();
     String courseName = getCourse().getNome();
     String period = getCourse().getExecutionPeriod().getQualifiedName().replace('/', '-');
     return String.format(
         "%s (%s: %s, %s)", Unit.getInstitutionAcronym(), degreeName, courseName, period);
   } else {
     return getFromName();
   }
 }
 public UnitName getInstitutionUnitName() {
   return (institution == null) ? null : institution.getUnitName();
 }
Ejemplo n.º 8
0
  @Atomic
  public static Unit run(
      Unit parentUnit,
      MultiLanguageString unitName,
      String unitNameCard,
      String unitCostCenter,
      String acronym,
      YearMonthDay begin,
      YearMonthDay end,
      PartyTypeEnum type,
      String departmentID,
      String degreeID,
      String administrativeOfficeID,
      AccountabilityType accountabilityType,
      String webAddress,
      UnitClassification classification,
      Boolean canBeResponsibleOfSpaces,
      String campusID)
      throws FenixServiceException {

    ServiceMonitoring.logService(
        CreateUnit.class,
        parentUnit,
        unitName,
        unitNameCard,
        unitCostCenter,
        acronym,
        begin,
        end,
        type,
        departmentID,
        degreeID,
        administrativeOfficeID,
        accountabilityType,
        webAddress,
        classification,
        canBeResponsibleOfSpaces,
        campusID);

    Integer costCenterCode = getCostCenterCode(unitCostCenter);
    Space campus = (Space) FenixFramework.getDomainObject(campusID);

    if (type != null) {

      switch (type) {
        case DEPARTMENT:
          Department department = FenixFramework.getDomainObject(departmentID);
          return DepartmentUnit.createNewInternalDepartmentUnit(
              unitName,
              unitNameCard,
              costCenterCode,
              acronym,
              begin,
              end,
              parentUnit,
              accountabilityType,
              webAddress,
              department,
              classification,
              canBeResponsibleOfSpaces,
              campus);

        case DEGREE_UNIT:
          Degree degree = FenixFramework.getDomainObject(degreeID);
          return DegreeUnit.createNewInternalDegreeUnit(
              unitName,
              unitNameCard,
              costCenterCode,
              acronym,
              begin,
              end,
              parentUnit,
              accountabilityType,
              webAddress,
              degree,
              classification,
              canBeResponsibleOfSpaces,
              campus);

        case PLANET:
          return PlanetUnit.createNewPlanetUnit(
              unitName,
              unitNameCard,
              costCenterCode,
              acronym,
              begin,
              end,
              parentUnit,
              webAddress,
              classification,
              canBeResponsibleOfSpaces,
              campus);

        case COUNTRY:
          return CountryUnit.createNewCountryUnit(
              unitName,
              unitNameCard,
              costCenterCode,
              acronym,
              begin,
              end,
              parentUnit,
              webAddress,
              classification,
              canBeResponsibleOfSpaces,
              campus);

        case SCHOOL:
          return SchoolUnit.createNewSchoolUnit(
              unitName,
              unitNameCard,
              costCenterCode,
              acronym,
              begin,
              end,
              parentUnit,
              webAddress,
              classification,
              canBeResponsibleOfSpaces,
              campus);

        case UNIVERSITY:
          return UniversityUnit.createNewUniversityUnit(
              unitName,
              unitNameCard,
              costCenterCode,
              acronym,
              begin,
              end,
              parentUnit,
              webAddress,
              classification,
              canBeResponsibleOfSpaces,
              campus);

        case ADMINISTRATIVE_OFFICE_UNIT:
          AdministrativeOffice office = FenixFramework.getDomainObject(administrativeOfficeID);
          Unit unit =
              Unit.createNewUnit(
                  unitName,
                  unitNameCard,
                  costCenterCode,
                  acronym,
                  begin,
                  end,
                  parentUnit,
                  accountabilityType,
                  webAddress,
                  classification,
                  office,
                  canBeResponsibleOfSpaces,
                  campus);
          unit.setType(type);
          return unit;
        case AGGREGATE_UNIT:
          return AggregateUnit.createNewAggregateUnit(
              unitName,
              unitNameCard,
              costCenterCode,
              acronym,
              begin,
              end,
              parentUnit,
              accountabilityType,
              webAddress,
              classification,
              canBeResponsibleOfSpaces,
              campus);

        case COMPETENCE_COURSE_GROUP:
          return CompetenceCourseGroupUnit.createNewInternalCompetenceCourseGroupUnit(
              unitName,
              unitNameCard,
              costCenterCode,
              acronym,
              begin,
              end,
              parentUnit,
              accountabilityType,
              webAddress,
              classification,
              canBeResponsibleOfSpaces,
              campus);

        case SCIENTIFIC_AREA:
          return ScientificAreaUnit.createNewInternalScientificArea(
              unitName,
              unitNameCard,
              costCenterCode,
              acronym,
              begin,
              end,
              parentUnit,
              accountabilityType,
              webAddress,
              classification,
              canBeResponsibleOfSpaces,
              campus);

        case SECTION:
          return SectionUnit.createNewSectionUnit(
              unitName,
              unitNameCard,
              costCenterCode,
              acronym,
              begin,
              end,
              parentUnit,
              accountabilityType,
              webAddress,
              classification,
              canBeResponsibleOfSpaces,
              campus);

        case RESEARCH_UNIT:
          return ResearchUnit.createNewResearchUnit(
              unitName,
              unitNameCard,
              costCenterCode,
              acronym,
              begin,
              end,
              parentUnit,
              accountabilityType,
              webAddress,
              classification,
              canBeResponsibleOfSpaces,
              campus);

        case MANAGEMENT_COUNCIL:
          return ManagementCouncilUnit.createManagementCouncilUnit(
              unitName,
              unitNameCard,
              costCenterCode,
              acronym,
              begin,
              end,
              parentUnit,
              accountabilityType,
              webAddress,
              classification,
              canBeResponsibleOfSpaces,
              campus);

        case SCIENTIFIC_COUNCIL:
          return ScientificCouncilUnit.createScientificCouncilUnit(
              unitName,
              unitNameCard,
              costCenterCode,
              acronym,
              begin,
              end,
              parentUnit,
              accountabilityType,
              webAddress,
              classification,
              canBeResponsibleOfSpaces,
              campus);
      }

    } else {
      return Unit.createNewUnit(
          unitName,
          unitNameCard,
          costCenterCode,
          acronym,
          begin,
          end,
          parentUnit,
          accountabilityType,
          webAddress,
          classification,
          null,
          canBeResponsibleOfSpaces,
          campus);
    }

    throw new FenixServiceException("createUnit.service.empty.unit.type");
  }