コード例 #1
0
  public static PlanetUnit createNewPlanetUnit(
      MultiLanguageString planetName,
      String planetNameCard,
      Integer costCenterCode,
      String planetAcronym,
      YearMonthDay beginDate,
      YearMonthDay endDate,
      Unit parentUnit,
      String webAddress,
      UnitClassification classification,
      Boolean canBeResponsibleOfSpaces,
      Space campus) {

    PlanetUnit planetUnit = new PlanetUnit();
    planetUnit.init(
        planetName,
        planetNameCard,
        costCenterCode,
        planetAcronym,
        beginDate,
        endDate,
        webAddress,
        classification,
        null,
        canBeResponsibleOfSpaces,
        campus);

    checkIfAlreadyExistsOnePlanetWithSameAcronymAndName(planetUnit);

    return planetUnit;
  }
コード例 #2
0
 private static void checkIfAlreadyExistsOnePlanetWithSameAcronymAndName(PlanetUnit planetUnit) {
   for (Unit unit : UnitUtils.readAllUnitsWithoutParents()) {
     if (!unit.equals(planetUnit)
         && unit.isPlanetUnit()
         && (planetUnit.getAcronym().equalsIgnoreCase(unit.getAcronym())
             || planetUnit.getName().equalsIgnoreCase(unit.getName()))) {
       throw new DomainException("error.unit.already.exists.unit.with.same.name.or.acronym");
     }
   }
 }