package net.sourceforge.fenixedu.applicationTier.Servico.resourceAllocationManager; import pt.ist.fenixWebFramework.services.Service; import pt.ist.fenixWebFramework.security.accessControl.Checked; import java.util.List; import net.sourceforge.fenixedu.applicationTier.FenixService; import net.sourceforge.fenixedu.applicationTier.Servico.exceptions.FenixServiceException; import net.sourceforge.fenixedu.applicationTier.Servico.exceptions.InvalidArgumentsServiceException; import net.sourceforge.fenixedu.dataTransferObject.InfoClass; import net.sourceforge.fenixedu.domain.SchoolClass; import net.sourceforge.fenixedu.domain.Shift; public class AddShiftsToSchoolClass extends FenixService { @Checked("RolePredicates.RESOURCE_ALLOCATION_MANAGER_PREDICATE") @Service public static void run(InfoClass infoClass, List shiftOIDs) throws FenixServiceException { final SchoolClass schoolClass = rootDomainObject.readSchoolClassByOID(infoClass.getIdInternal()); if (schoolClass == null) { throw new InvalidArgumentsServiceException(); } for (final String shiftOID : shiftOIDs) { final Shift shift = rootDomainObject.readShiftByOID(Integer.valueOf(shiftOID)); if (shift == null) { throw new InvalidArgumentsServiceException(); } schoolClass.associateShift(shift); } } }