package pt.utl.ist.scripts.runOnce.executionCourse; import net.sourceforge.fenixedu.domain.ExecutionDegree; import net.sourceforge.fenixedu.domain.ExecutionYear; import net.sourceforge.fenixedu.domain.OccupationPeriod; import org.joda.time.YearMonthDay; import pt.utl.ist.scripts.commons.AtomicScript; public class FixExecutionDegreePeriods extends AtomicScript { @Override protected void run() throws Exception { final ExecutionYear currExecutionYear = ExecutionYear.readCurrentExecutionYear(); final ExecutionDegree executionDegree = currExecutionYear.getExecutionDegreeByAcronym("MEEst"); YearMonthDay endPart2 = new YearMonthDay(2011, 05, 27); YearMonthDay startPart2 = new YearMonthDay(2011, 04, 28); YearMonthDay end = new YearMonthDay(2011, 04, 20); YearMonthDay start = new YearMonthDay(2011, 02, 14); final OccupationPeriod currentPeriodLessonSecondSemester = executionDegree.getPeriodLessonsSecondSemester(); OccupationPeriod newPeriodLessonSecondSemester = OccupationPeriod.getOccupationPeriod(start, end, startPart2, endPart2); if (!newPeriodLessonSecondSemester.equals(currentPeriodLessonSecondSemester)) { executionDegree.setPeriodLessonsSecondSemester(newPeriodLessonSecondSemester); if (currentPeriodLessonSecondSemester != null) { currentPeriodLessonSecondSemester.delete(); } System.out.println(newPeriodLessonSecondSemester.asString()); System.out.println(newPeriodLessonSecondSemester.getNextPeriod().asString()); } else { System.out.println(currentPeriodLessonSecondSemester.asString()); System.out.println(currentPeriodLessonSecondSemester.getNextPeriod() != null ? currentPeriodLessonSecondSemester .getNextPeriod().asString() : "next period not available"); } } public static void main(String[] args) { logger.info("Starting the process..."); processWriteTransaction(new FixExecutionDegreePeriods()); logger.info("Process finalized"); System.exit(0); } }