@@ -0,0 +1,3544 @@
+/*%0A * UniTime 3.1 (University Timetabling Application)%0A * Copyright (C) 2007, UniTime.org, and individual contributors%0A * as indicated by the @authors tag.%0A * %0A * This program is free software; you can redistribute it and/or modify%0A * it under the terms of the GNU General Public License as published by%0A * the Free Software Foundation; either version 2 of the License, or%0A * (at your option) any later version.%0A * %0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU General Public License for more details.%0A * %0A * You should have received a copy of the GNU General Public License along%0A * with this program; if not, write to the Free Software Foundation, Inc.,%0A * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.%0A*/%0Apackage org.unitime.timetable.test;%0A%0Aimport java.util.Iterator;%0Aimport java.util.List;%0Aimport java.util.Properties;%0A%0Aimport org.hibernate.Session;%0Aimport org.hibernate.Transaction;%0Aimport org.unitime.commons.hibernate.util.HibernateUtil;%0Aimport org.unitime.timetable.model.Assignment;%0Aimport org.unitime.timetable.model.Event;%0Aimport org.unitime.timetable.model.EventType;%0Aimport org.unitime.timetable.model.Solution;%0Aimport org.unitime.timetable.model.dao._RootDAO;%0A%0Aimport net.sf.cpsolver.ifs.util.ToolBox;%0A%0Apublic class MakeEventsForAllCommitedAssignments %7B%0A%0A    public static void main(String args%5B%5D) %7B%0A        try %7B%0A            ToolBox.configureLogging();%0A            HibernateUtil.configureHibernate(new Properties());%0A            %0A            Session hibSession = new _RootDAO().getSession();%0A            List commitedSolutions = hibSession.createQuery(%22select distinct s from Solution s inner join s.assignments a where s.commited = true and a.event is null%22).list();%0A            %0A            for (Iterator i=commitedSolutions.iterator();i.hasNext();) %7B%0A                Solution s = (Solution)i.next();%0A                %0A                System.out.println(%22Procession solution %22+s.getOwner().getName()+%22 of %22+s.getSession().getLabel()+%22 (committed:%22+s.getCommitDate()+%22)%22);%0A                %0A                Transaction tx = null;%0A                try %7B%0A                    tx = hibSession.beginTransaction();%0A%0A                    EventType eventType = EventType.findByReference(EventType.sEventTypeClass);%0A                    for (Iterator j=hibSession.createQuery(%0A                            %22select a from Assignment a %22+%0A                            %22where a.event is null and a.solution.uniqueId = :solutionId%22)%0A                            .setLong(%22solutionId%22, s.getUniqueId())%0A                            .iterate();%0A                        j.hasNext();) %7B%0A                        Assignment a = (Assignment)j.next();%0A                        Event event = a.generateCommittedEvent(eventType, true);%0A                        if (event!=null) %7B%0A                            System.out.println(%22  %22+a.getClassName()+%22 %22+a.getPlacement().getLongName());%0A                            a.setEvent(event);%0A                            hibSession.save(event);%0A                            hibSession.update(a);%0A                        %7D%0A                    %7D%0A                    %0A                    tx.commit();%0A                %7D catch (Exception e) %7B%0A                    if (tx!=null) tx.rollback();%0A                    throw e;%0A                %7D%0A                %0A            %7D%0A        %7D catch (Exception e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%7D%0A

create class events for all assignments that are committed and that do not have class events