package pt.utl.ist.scripts.runOnce.phd; import net.sourceforge.fenixedu.domain.Employee; import net.sourceforge.fenixedu.domain.caseHandling.Process; import net.sourceforge.fenixedu.domain.phd.thesis.PhdThesisProcess; import net.sourceforge.fenixedu.domain.phd.thesis.PhdThesisProcessStateType; import net.sourceforge.fenixedu.domain.phd.thesis.meeting.PhdMeeting; import net.sourceforge.fenixedu.domain.phd.thesis.meeting.PhdMeetingSchedulingProcess; import net.sourceforge.fenixedu.domain.phd.thesis.meeting.PhdMeetingSchedulingProcessStateType; import pt.ist.bennu.core.domain.Bennu; import pt.utl.ist.scripts.commons.AtomicScript; public class CreateMeetingSchedulingProcess extends AtomicScript { public static void main(String[] args) { processWriteTransaction(new CreateMeetingSchedulingProcess()); } @Override protected void run() throws Exception { int countProcess = 0; int thesiscountProcess = 0; for (Process process : Bennu.getInstance().getProcessesSet()) { if ((++countProcess % 100) == 0) { System.out.println("Process nÂș " + countProcess); } if (!(process instanceof PhdThesisProcess)) { continue; } final PhdThesisProcess thesisProcess = (PhdThesisProcess) process; if (!thesisProcess.hasState(PhdThesisProcessStateType.WAITING_FOR_JURY_REPORTER_FEEDBACK)) { continue; } if (thesisProcess.hasMeetingProcess()) { continue; } System.out.println(String.format("For student %s were going to create a meeting process", thesisProcess .getIndividualProgramProcess().getStudent().getNumber())); PhdMeetingSchedulingProcess meetingProcess = new PhdMeetingSchedulingProcess(thesisProcess); meetingProcess.createState(PhdMeetingSchedulingProcessStateType.WAITING_FIRST_THESIS_MEETING_REQUEST, Employee .readByNumber(4972).getPerson(), "Created from a migration process"); if (thesisProcess.getMeetingDate() != null && thesisProcess.getMeetingPlace() != null) { PhdMeeting meeting = PhdMeeting.create(meetingProcess, thesisProcess.getMeetingDate(), thesisProcess.getMeetingPlace()); } else if (thesisProcess.getMeetingDate() != null || thesisProcess.getMeetingPlace() != null) { throw new RuntimeException("Inconsistent data in Meeting"); } } } }