// Path: src/java/com/idega/block/importer/data/ImportFile.java
// public interface ImportFile{
// 
//   public Collection getRecords();
//   public Object getNextRecord(); 
//   public ArrayList getValuesFromRecordString(String recordString);
//   public String getValueAtIndexFromRecordString(int index, String recordString);
//   public void setFile(File file);
//   public String getEmptyValueString();
//   public void close();
// /**
//  * Method setEmptyValueString. This will be the value returned if a column you want is empty in the import file.
//  * @param emptyValueString
//  */
//   public void setEmptyValueString(String emptyValueString);
//   public File getFile();
//   public String getEncoding();
//   //public Object getRecordAtIndex(int index);
//  // public boolean parse();
// }
// 
// Path: src/java/com/idega/block/importer/data/ImportFileClass.java
// public interface ImportFileClass extends com.idega.data.IDOEntity
// {
//  public java.lang.String getClassName();
//  public java.lang.String getDescription();
//  public java.lang.String getName();
//  public void setClassName(java.lang.String p0);
//  public void setDescription(java.lang.String p0);
//  public void setName(java.lang.String p0);
// }
// 
// Path: src/java/com/idega/block/importer/data/ImportFileClassHome.java
// public interface ImportFileClassHome extends com.idega.data.IDOHome
// {
//  public ImportFileClass create() throws javax.ejb.CreateException;
//  public ImportFileClass findByPrimaryKey(Object pk) throws javax.ejb.FinderException;
//  public java.util.Collection findAllImportFileClasses()throws javax.ejb.FinderException;
//  public ImportFileClass findByClassName(java.lang.String p0)throws javax.ejb.FinderException;
// 
// }
// 
// Path: src/java/com/idega/block/importer/data/ImportHandler.java
// public interface ImportHandler extends com.idega.data.IDOEntity
// {
//  public java.lang.String getAutoImpFileType();
//  public java.lang.String getAutoImpFolder();
//  public java.lang.String getClassName();
//  public java.lang.String getDescription();
//  public java.lang.String getName();
//  public void setAutoImpFileType(java.lang.String p0);
//  public void setAutoImpFolder(java.lang.String p0);
//  public void setClassName(java.lang.String p0);
//  public void setDescription(java.lang.String p0);
//  public void setName(java.lang.String p0);
// }
// 
// Path: src/java/com/idega/block/importer/data/ImportHandlerHome.java
// public interface ImportHandlerHome extends com.idega.data.IDOHome
// {
//  public ImportHandler create() throws javax.ejb.CreateException;
//  public ImportHandler findByPrimaryKey(Object pk) throws javax.ejb.FinderException;
//  public java.util.Collection findAllAutomaticUpdates()throws javax.ejb.FinderException;
//  public java.util.Collection findAllImportHandlers()throws javax.ejb.FinderException;
//  public ImportHandler findByClassName(java.lang.String p0)throws javax.ejb.FinderException;
// 
// }


import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.rmi.RemoteException;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.stereotype.Service;
import com.idega.block.importer.data.ImportFile;
import com.idega.block.importer.data.ImportFileClass;
import com.idega.block.importer.data.ImportFileClassHome;
import com.idega.block.importer.data.ImportHandler;
import com.idega.block.importer.data.ImportHandlerHome;
import com.idega.business.IBOService;
import com.idega.business.IBOServiceBean;
import com.idega.business.IBOSession;
import com.idega.core.file.data.ICFile;
import com.idega.core.file.data.ICFileHome;
import com.idega.data.IDOLookup;
import com.idega.idegaweb.IWUserContext;
import com.idega.presentation.IWContext;
import com.idega.presentation.ui.DropdownMenu;
import com.idega.repository.data.RefactorClassRegistry;
import com.idega.user.business.GroupBusiness;
import com.idega.util.IWTimestamp;
import com.idega.util.expression.ELUtil;
import com.idega.util.text.TextSoap;
		catch (Exception ex) {
			ex.printStackTrace();
			return false;
		}
	}

	/**
	 * @see com.idega.block.importer.business.ImportBusiness#importRecords(String,
	 *      String, String)
	 */
	public boolean importRecords(String handlerClass, String fileClass, String filePath, IWUserContext iwuc, List failedRecords) throws RemoteException {
		return importRecords(handlerClass, fileClass, filePath, iwuc, failedRecords, null);
	}
	
	/**
	 * @see com.idega.block.importer.business.ImportBusiness#importRecords(String,
	 *      String, String)
	 */
	public boolean importRecords(String handlerClass, String fileClass, String filePath, IWUserContext iwuc, List failedRecords, List successRecords) throws RemoteException {
		try {
			boolean status = false;
			ImportFileHandler handler = this.getImportFileHandler(handlerClass, iwuc);
			ImportFile file = this.getImportFile(fileClass);

			file.setFile(new File(filePath));

			handler.setImportFile(file);

			status = handler.handleRecords();
			failedRecords.addAll(handler.getFailedRecords());
// Path: src/java/com/idega/block/importer/data/ImportFile.java
// public interface ImportFile{
// 
//   public Collection getRecords();
//   public Object getNextRecord(); 
//   public ArrayList getValuesFromRecordString(String recordString);
//   public String getValueAtIndexFromRecordString(int index, String recordString);
//   public void setFile(File file);
//   public String getEmptyValueString();
//   public void close();
// /**
//  * Method setEmptyValueString. This will be the value returned if a column you want is empty in the import file.
//  * @param emptyValueString
//  */
//   public void setEmptyValueString(String emptyValueString);
//   public File getFile();
//   public String getEncoding();
//   //public Object getRecordAtIndex(int index);
//  // public boolean parse();
// }
// 
// Path: src/java/com/idega/block/importer/data/ImportFileClass.java
// public interface ImportFileClass extends com.idega.data.IDOEntity
// {
//  public java.lang.String getClassName();
//  public java.lang.String getDescription();
//  public java.lang.String getName();
//  public void setClassName(java.lang.String p0);
//  public void setDescription(java.lang.String p0);
//  public void setName(java.lang.String p0);
// }
// 
// Path: src/java/com/idega/block/importer/data/ImportFileClassHome.java
// public interface ImportFileClassHome extends com.idega.data.IDOHome
// {
//  public ImportFileClass create() throws javax.ejb.CreateException;
//  public ImportFileClass findByPrimaryKey(Object pk) throws javax.ejb.FinderException;
//  public java.util.Collection findAllImportFileClasses()throws javax.ejb.FinderException;
//  public ImportFileClass findByClassName(java.lang.String p0)throws javax.ejb.FinderException;
// 
// }
// 
// Path: src/java/com/idega/block/importer/data/ImportHandler.java
// public interface ImportHandler extends com.idega.data.IDOEntity
// {
//  public java.lang.String getAutoImpFileType();
//  public java.lang.String getAutoImpFolder();
//  public java.lang.String getClassName();
//  public java.lang.String getDescription();
//  public java.lang.String getName();
//  public void setAutoImpFileType(java.lang.String p0);
//  public void setAutoImpFolder(java.lang.String p0);
//  public void setClassName(java.lang.String p0);
//  public void setDescription(java.lang.String p0);
//  public void setName(java.lang.String p0);
// }
// 
// Path: src/java/com/idega/block/importer/data/ImportHandlerHome.java
// public interface ImportHandlerHome extends com.idega.data.IDOHome
// {
//  public ImportHandler create() throws javax.ejb.CreateException;
//  public ImportHandler findByPrimaryKey(Object pk) throws javax.ejb.FinderException;
//  public java.util.Collection findAllAutomaticUpdates()throws javax.ejb.FinderException;
//  public java.util.Collection findAllImportHandlers()throws javax.ejb.FinderException;
//  public ImportHandler findByClassName(java.lang.String p0)throws javax.ejb.FinderException;
// 
// }


// Path: src/java/com/idega/block/importer/business/ImportBusinessBean.java
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.rmi.RemoteException;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.stereotype.Service;
import com.idega.block.importer.data.ImportFile;
import com.idega.block.importer.data.ImportFileClass;
import com.idega.block.importer.data.ImportFileClassHome;
import com.idega.block.importer.data.ImportHandler;
import com.idega.block.importer.data.ImportHandlerHome;
import com.idega.business.IBOService;
import com.idega.business.IBOServiceBean;
import com.idega.business.IBOSession;
import com.idega.core.file.data.ICFile;
import com.idega.core.file.data.ICFileHome;
import com.idega.data.IDOLookup;
import com.idega.idegaweb.IWUserContext;
import com.idega.presentation.IWContext;
import com.idega.presentation.ui.DropdownMenu;
import com.idega.repository.data.RefactorClassRegistry;
import com.idega.user.business.GroupBusiness;
import com.idega.util.IWTimestamp;
import com.idega.util.expression.ELUtil;
import com.idega.util.text.TextSoap;

		catch (Exception ex) {
			ex.printStackTrace();
			return false;
		}
	}

	/**
	 * @see com.idega.block.importer.business.ImportBusiness#importRecords(String,
	 *      String, String)
	 */
	public boolean importRecords(String handlerClass, String fileClass, String filePath, IWUserContext iwuc, List failedRecords) throws RemoteException {
		return importRecords(handlerClass, fileClass, filePath, iwuc, failedRecords, null);
	}
	
	/**
	 * @see com.idega.block.importer.business.ImportBusiness#importRecords(String,
	 *      String, String)
	 */
	public boolean importRecords(String handlerClass, String fileClass, String filePath, IWUserContext iwuc, List failedRecords, List successRecords) throws RemoteException {
		try {
			boolean status = false;
			ImportFileHandler handler = this.getImportFileHandler(handlerClass, iwuc);
			ImportFile file = this.getImportFile(fileClass);

			file.setFile(new File(filePath));

			handler.setImportFile(file);

			status = handler.handleRecords();
			failedRecords.addAll(handler.getFailedRecords());
			List success = handler.getSuccessRecords();