/*
 * CriarTurma.java
 *
 * Created on 25 de Outubro de 2002, 18:34
 */

package net.sourceforge.fenixedu.applicationTier.Servico.resourceAllocationManager;

/**
 * Serviço CriarTurma
 * 
 * @author tfc130
 */
import net.sourceforge.fenixedu.applicationTier.Service;
import net.sourceforge.fenixedu.applicationTier.Servico.exceptions.ExistingServiceException;
import net.sourceforge.fenixedu.dataTransferObject.InfoClass;
import net.sourceforge.fenixedu.dataTransferObject.InfoExecutionDegree;
import net.sourceforge.fenixedu.dataTransferObject.InfoExecutionPeriod;
import net.sourceforge.fenixedu.domain.ExecutionDegree;
import net.sourceforge.fenixedu.domain.ExecutionPeriod;
import net.sourceforge.fenixedu.domain.SchoolClass;
import net.sourceforge.fenixedu.domain.candidacy.degree.DayPeriodType;
import pt.iscte.ci.metadata.ISCTE;

public class CriarTurma extends Service {

    @ISCTE(comment = "Included capacity and day period type", author = "Paulo Zenida")
    public Object run(final String className, final Integer curricularYear, final Integer classCapacity,
	    final DayPeriodType dayPeriodType, final InfoExecutionDegree infoExecutionDegree,
	    final InfoExecutionPeriod infoExecutionPeriod) throws ExistingServiceException {

	final ExecutionDegree executionDegree = rootDomainObject.readExecutionDegreeByOID(infoExecutionDegree.getIdInternal());
	final ExecutionPeriod executionPeriod = rootDomainObject.readExecutionPeriodByOID(infoExecutionPeriod.getIdInternal());

	final SchoolClass schoolClass = new SchoolClass(executionDegree, executionPeriod, className, curricularYear,
		classCapacity, dayPeriodType);
	return InfoClass.newInfoFromDomain(schoolClass);
    }
}
