-
-
Save ricardorcr/faf9ebf567448c25d83974e4238fd0e0 to your computer and use it in GitHub Desktop.
Add Affinity Cycles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pt.ist.fenixedu.integration.task; | |
import java.util.Iterator; | |
import org.fenixedu.academic.domain.DegreeCurricularPlan; | |
import org.fenixedu.academic.domain.degree.DegreeType; | |
import org.fenixedu.academic.domain.degree.degreeCurricularPlan.DegreeCurricularPlanState; | |
import org.fenixedu.academic.domain.degreeStructure.CycleCourseGroup; | |
import org.fenixedu.bennu.scheduler.custom.CustomTask; | |
import pt.ist.fenixframework.FenixFramework; | |
public class AddAffinityCycles extends CustomTask { | |
@Override | |
public void runTask() throws Exception { | |
DegreeCurricularPlan dcpLee = FenixFramework.getDomainObject("2581275345460"); // LEE 2006 | |
DegreeCurricularPlan dcpLerc = FenixFramework.getDomainObject("2581275345458"); // LERC 2006 | |
DegreeCurricularPlan dcpMeec = FenixFramework.getDomainObject("2581275345334"); // MEEC 2006 | |
DegreeCurricularPlan dcpMeicA = FenixFramework.getDomainObject("284056252055554"); // MEIC-A 2015 | |
DegreeCurricularPlan dcpMeicT = FenixFramework.getDomainObject("284056252055555"); // MEIC-T 2015 | |
//LEE 2006 -> MEIC-A 2015 MEIC-T 2015 | |
dcpLee.getFirstCycleCourseGroup().addDestinationAffinities(dcpMeicA.getSecondCycleCourseGroup()); | |
dcpLee.getFirstCycleCourseGroup().addDestinationAffinities(dcpMeicT.getSecondCycleCourseGroup()); | |
//LERC 2006 -> MEIC-A 2015 MEIC-T 2015 | |
dcpLerc.getFirstCycleCourseGroup().addDestinationAffinities(dcpMeicA.getSecondCycleCourseGroup()); | |
dcpLerc.getFirstCycleCourseGroup().addDestinationAffinities(dcpMeicT.getSecondCycleCourseGroup()); | |
//MEEC 2006 -> MEIC-A 2015 MEIC-T 2015 | |
dcpMeec.getFirstCycleCourseGroup().addDestinationAffinities(dcpMeicA.getSecondCycleCourseGroup()); | |
dcpMeec.getFirstCycleCourseGroup().addDestinationAffinities(dcpMeicT.getSecondCycleCourseGroup()); | |
printAffinities(); | |
} | |
protected void printAffinities() { | |
for (final DegreeCurricularPlan degreeCurricularPlan : DegreeCurricularPlan.readByDegreeTypesAndState( | |
DegreeType.oneOf(DegreeType::isBolonhaDegree, DegreeType::isIntegratedMasterDegree), | |
DegreeCurricularPlanState.ACTIVE)) { | |
print(degreeCurricularPlan.getFirstCycleCourseGroup()); | |
} | |
} | |
private void print(final CycleCourseGroup firstCycleCourseGroup) { | |
final StringBuilder builder = new StringBuilder(); | |
builder.append(firstCycleCourseGroup.getParentDegreeCurricularPlan().getName()).append("\t -> "); | |
final Iterator<CycleCourseGroup> iter = firstCycleCourseGroup.getDestinationAffinitiesSet().iterator(); | |
while (iter.hasNext()) { | |
builder.append(iter.next().getParentDegreeCurricularPlan().getName()); | |
if (iter.hasNext()) { | |
builder.append(", "); | |
} | |
} | |
taskLog(builder.toString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment