// Path: src/java/se/idega/idegaweb/commune/school/data/SchoolTime.java
// public interface SchoolTime extends IDOEntity {
// 	public void setUser (User user) throws RemoteException;
//     public void setSchool (School school) throws RemoteException;
//     public void setHours (int hours) throws RemoteException;
//     public void setSeason (SchoolSeason season) throws RemoteException;
//     public void setRegistrationTime (Date date) throws RemoteException;
// }


import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.ejb.FinderException;
import javax.ejb.SessionContext;
import javax.transaction.UserTransaction;
import se.idega.idegaweb.commune.business.CommuneUserBusiness;
import se.idega.idegaweb.commune.school.business.SchoolCommuneBusiness;
import se.idega.idegaweb.commune.school.data.SchoolTime;
import se.idega.idegaweb.commune.school.data.SchoolTimeHome;
import se.idega.util.PIDChecker;
import com.idega.block.importer.data.ImportFile;
import com.idega.block.school.business.SchoolBusiness;
import com.idega.block.school.data.School;
import com.idega.block.school.data.SchoolHome;
import com.idega.block.school.data.SchoolSeason;
import com.idega.block.school.data.SchoolSeasonHome;
import com.idega.business.IBOServiceBean;
import com.idega.data.IDOLookup;
import com.idega.user.data.Group;
import com.idega.user.data.User;
import com.idega.user.data.UserHome;
    @Override
	public void setRootGroup (final Group rootGroup) {
        this.rootGroup = rootGroup;
    }

    /**
     * Reads records in a format specified in {@link se.idega.idegaweb.commune.school.importer.NackaStudentTimeImportFileHandler}.
     * Relies on the fact that {@link #setImportFile} has been invoked correctly
     * prior to invocation of this method.
     */
    @Override
	public boolean handleRecords () {
        log ("Importing records: " + getClass ().getName ());
        boolean readSuccess = true;
        failedRecords.clear ();
        final SessionContext sessionContext = getSessionContext();
        final UserTransaction transaction = sessionContext.getUserTransaction();
        final Set unknownSchools = new HashSet ();
        try {
            transaction.begin();
            // get all home and business objects needed in traversal below
            final CommuneUserBusiness communeUserBusiness
                    = (CommuneUserBusiness) getServiceInstance
                    (CommuneUserBusiness.class);
            final UserHome userHome = communeUserBusiness.getUserHome ();
            final SchoolBusiness schoolBusiness = (SchoolBusiness)
                    getServiceInstance (SchoolBusiness.class);
            final SchoolHome schoolHome = schoolBusiness.getSchoolHome ();
            final PIDChecker pidChecker = PIDChecker.getInstance ();
            final SchoolTimeHome schoolTimeHome
// Path: src/java/se/idega/idegaweb/commune/school/data/SchoolTime.java
// public interface SchoolTime extends IDOEntity {
// 	public void setUser (User user) throws RemoteException;
//     public void setSchool (School school) throws RemoteException;
//     public void setHours (int hours) throws RemoteException;
//     public void setSeason (SchoolSeason season) throws RemoteException;
//     public void setRegistrationTime (Date date) throws RemoteException;
// }


// Path: src/java/se/idega/idegaweb/commune/school/importer/NackaStudentTimeImportFileHandlerBean.java
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.ejb.FinderException;
import javax.ejb.SessionContext;
import javax.transaction.UserTransaction;
import se.idega.idegaweb.commune.business.CommuneUserBusiness;
import se.idega.idegaweb.commune.school.business.SchoolCommuneBusiness;
import se.idega.idegaweb.commune.school.data.SchoolTime;
import se.idega.idegaweb.commune.school.data.SchoolTimeHome;
import se.idega.util.PIDChecker;
import com.idega.block.importer.data.ImportFile;
import com.idega.block.school.business.SchoolBusiness;
import com.idega.block.school.data.School;
import com.idega.block.school.data.SchoolHome;
import com.idega.block.school.data.SchoolSeason;
import com.idega.block.school.data.SchoolSeasonHome;
import com.idega.business.IBOServiceBean;
import com.idega.data.IDOLookup;
import com.idega.user.data.Group;
import com.idega.user.data.User;
import com.idega.user.data.UserHome;

    @Override
	public void setRootGroup (final Group rootGroup) {
        this.rootGroup = rootGroup;
    }

    /**
     * Reads records in a format specified in {@link se.idega.idegaweb.commune.school.importer.NackaStudentTimeImportFileHandler}.
     * Relies on the fact that {@link #setImportFile} has been invoked correctly
     * prior to invocation of this method.
     */
    @Override
	public boolean handleRecords () {
        log ("Importing records: " + getClass ().getName ());
        boolean readSuccess = true;
        failedRecords.clear ();
        final SessionContext sessionContext = getSessionContext();
        final UserTransaction transaction = sessionContext.getUserTransaction();
        final Set unknownSchools = new HashSet ();
        try {
            transaction.begin();
            // get all home and business objects needed in traversal below
            final CommuneUserBusiness communeUserBusiness
                    = (CommuneUserBusiness) getServiceInstance
                    (CommuneUserBusiness.class);
            final UserHome userHome = communeUserBusiness.getUserHome ();
            final SchoolBusiness schoolBusiness = (SchoolBusiness)
                    getServiceInstance (SchoolBusiness.class);
            final SchoolHome schoolHome = schoolBusiness.getSchoolHome ();
            final PIDChecker pidChecker = PIDChecker.getInstance ();
            final SchoolTimeHome schoolTimeHome
                    = (SchoolTimeHome) IDOLookup.getHome (SchoolTime.class);