pl.edu.agh.cast.importer.base.converter
Class AbstractImportConverter<T extends IDataSet<?>>

java.lang.Object
  extended by pl.edu.agh.cast.importer.base.converter.AbstractImportConverter<T>
Type Parameters:
T -
All Implemented Interfaces:
IImportConverter
Direct Known Subclasses:
GeneralImportConverter

public abstract class AbstractImportConverter<T extends IDataSet<?>>
extends Object
implements IImportConverter

Abstract import converter class, which defines some basic utility methods for all converters.

Author:
AGH CAST Team

Field Summary
protected static SimpleDateFormat DATA_SET_DATE_FORMAT
          The data set date format.
protected static String EMPTY_STRING
          The empty string.
protected  ErrorsLog errorsLog
          The errors log.
protected  String importedFilePath
          The imported file path.
protected  List<List<IImportLogger>> importLoggers
          The list of import loggers for each tabular data.
protected  int rowsConverted
          The number of converted rows.
 
Constructor Summary
AbstractImportConverter()
          The default constructor.
 
Method Summary
 List<IDataSet<IDomainElement>> convert(List<TabularData> tabDatas, org.eclipse.core.runtime.IProgressMonitor monitor)
          Converts tabular data into data sets.
protected abstract  void convertRow(DataRow dataRow, int rowIndex, T dataSet, List<IImportLogger> loggers)
          Converts a specified data row and adds the relation, included within the row, to the specified data set.
protected  T convertTabularData(TabularData tabularData, int tabularDataIndex, org.eclipse.core.runtime.IProgressMonitor monitor, String subTaskString)
           
protected  int countMonitorTotalWork(List<TabularData> tabularDatas)
           
protected  void createAndAddColumn(List<TabularDataColumn> columns, IConversionRule rule, Class<?> type, String caption)
           
protected  String createDataSetName()
          Return the name of new data set.
 ErrorsLog getErrorsLog()
          Retrieves the conversion errors log.
protected abstract  List<TabularDataColumn> getPreviewColumns()
           
protected abstract  T initializeNewDataSetConversion()
           
protected  boolean isRuleComplete(IConversionRule rule)
           
protected  void logRowError(DataRow row, ErrorType errorType, List<IImportLogger> loggers)
           
protected  void logRowError(DataRow row, int rowIndex, ErrorType errorType, List<IImportLogger> loggers)
           
protected  void logTokenError(DataRow row, ConversionRuleException e, ErrorType errorType, List<IImportLogger> loggers)
           
protected  void logTokenError(DataRow row, ConversionRuleException e, List<IImportLogger> loggers)
           
protected  void notifyLoggers(List<IImportLogger> loggers, AbstractErrorLogData error)
           
 List<TabularData> preview(List<TabularData> tabularDatas)
          Creates preview of specified tabular data.
protected abstract  DataRow previewRow(DataRow row, TabularData data)
           
 void setImportLoggerData(List<List<IImportLogger>> loggers, String filePath)
          Sets the import process logger data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface pl.edu.agh.cast.importer.base.converter.IImportConverter
isComplete
 

Field Detail

DATA_SET_DATE_FORMAT

protected static final SimpleDateFormat DATA_SET_DATE_FORMAT
The data set date format.


EMPTY_STRING

protected static final String EMPTY_STRING
The empty string.

See Also:
Constant Field Values

importLoggers

protected List<List<IImportLogger>> importLoggers
The list of import loggers for each tabular data.


importedFilePath

protected String importedFilePath
The imported file path.


errorsLog

protected ErrorsLog errorsLog
The errors log.


rowsConverted

protected int rowsConverted
The number of converted rows.

Constructor Detail

AbstractImportConverter

public AbstractImportConverter()
The default constructor.

Method Detail

convert

public List<IDataSet<IDomainElement>> convert(List<TabularData> tabDatas,
                                              org.eclipse.core.runtime.IProgressMonitor monitor)
Description copied from interface: IImportConverter
Converts tabular data into data sets.

Specified by:
convert in interface IImportConverter
Parameters:
tabDatas - the tabular data to convert
monitor - the progress monitor for the conversion operation
Returns:
the converted data

convertTabularData

protected T convertTabularData(TabularData tabularData,
                               int tabularDataIndex,
                               org.eclipse.core.runtime.IProgressMonitor monitor,
                               String subTaskString)

convertRow

protected abstract void convertRow(DataRow dataRow,
                                   int rowIndex,
                                   T dataSet,
                                   List<IImportLogger> loggers)
                            throws ConversionRuleException
Converts a specified data row and adds the relation, included within the row, to the specified data set. The method modifies dataSet parameter.

Parameters:
dataRow - the data row to be converted
rowIndex - the index of the data row
dataSet - the data set into which the converted data will be added
loggers - list of registered import loggers for this conversion
Throws:
ConversionRuleException

initializeNewDataSetConversion

protected abstract T initializeNewDataSetConversion()

preview

public List<TabularData> preview(List<TabularData> tabularDatas)
Description copied from interface: IImportConverter
Creates preview of specified tabular data.

Specified by:
preview in interface IImportConverter
Parameters:
tabularDatas - the tabular data to preview
Returns:
the preview in form of tabular data

previewRow

protected abstract DataRow previewRow(DataRow row,
                                      TabularData data)

getPreviewColumns

protected abstract List<TabularDataColumn> getPreviewColumns()

createDataSetName

protected String createDataSetName()
Return the name of new data set. At this moment the name of the data set is the same as the file from which it was created and from actual time, but it should be determined by user.

Returns:
The name of the new data set

isRuleComplete

protected boolean isRuleComplete(IConversionRule rule)

notifyLoggers

protected void notifyLoggers(List<IImportLogger> loggers,
                             AbstractErrorLogData error)

createAndAddColumn

protected void createAndAddColumn(List<TabularDataColumn> columns,
                                  IConversionRule rule,
                                  Class<?> type,
                                  String caption)

logRowError

protected void logRowError(DataRow row,
                           int rowIndex,
                           ErrorType errorType,
                           List<IImportLogger> loggers)

logRowError

protected void logRowError(DataRow row,
                           ErrorType errorType,
                           List<IImportLogger> loggers)

logTokenError

protected void logTokenError(DataRow row,
                             ConversionRuleException e,
                             ErrorType errorType,
                             List<IImportLogger> loggers)

logTokenError

protected void logTokenError(DataRow row,
                             ConversionRuleException e,
                             List<IImportLogger> loggers)

countMonitorTotalWork

protected int countMonitorTotalWork(List<TabularData> tabularDatas)

setImportLoggerData

public void setImportLoggerData(List<List<IImportLogger>> loggers,
                                String filePath)
Sets the import process logger data.

Specified by:
setImportLoggerData in interface IImportConverter
Parameters:
loggers - the list of import logger lists for tabular datas
filePath - the path to the imported file
See Also:
IImportConverter.setImportLoggerData(java.util.List, java.lang.String)

getErrorsLog

public ErrorsLog getErrorsLog()
Retrieves the conversion errors log.

Specified by:
getErrorsLog in interface IImportConverter
Returns:
errors log
See Also:
IImportConverter.getErrorsLog()


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.