Exemplo n.º 1
0
 public static pt.ist.fenixframework.dml.runtime.DirectRelation<
         org.fenixedu.academic.domain.organizationalStructure.DepartmentUnit,
         org.fenixedu.academic.domain.Department>
     getRelationDepartmentUnit() {
   return org.fenixedu.academic.domain.organizationalStructure.DepartmentUnit
       .getRelationDepartmentUnit();
 }
Exemplo n.º 2
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");
  }