public static DegreeUnit createNewInternalDegreeUnit( MultiLanguageString unitName, String unitNameCard, Integer costCenterCode, String acronym, YearMonthDay beginDate, YearMonthDay endDate, Unit parentUnit, AccountabilityType accountabilityType, String webAddress, Degree degree, UnitClassification classification, Boolean canBeResponsibleOfSpaces, Space campus) { DegreeUnit degreeUnit = new DegreeUnit(); degreeUnit.init( unitName, unitNameCard, costCenterCode, acronym, beginDate, endDate, webAddress, classification, null, canBeResponsibleOfSpaces, campus); degreeUnit.setDegree(degree); degreeUnit.addParentUnit(parentUnit, accountabilityType); checkIfAlreadyExistsOneDegreeWithSameAcronym(degreeUnit); return degreeUnit; }
private static void checkIfAlreadyExistsOneDegreeWithSameAcronym(DegreeUnit degreeUnit) { for (Unit unit : UnitUtils.readInstitutionUnit().getAllSubUnits()) { if (!unit.equals(degreeUnit) && unit.isDegreeUnit() && degreeUnit.getAcronym().equalsIgnoreCase(unit.getAcronym())) { throw new DomainException("error.unit.already.exists.unit.with.same.name.or.acronym"); } } }