Class DefaultImpExTransformationService
- java.lang.Object
-
- de.hybris.platform.importcockpit.services.impex.impl.DefaultImpExTransformationService
-
- All Implemented Interfaces:
ImpExTransformationService
public class DefaultImpExTransformationService extends java.lang.Object implements ImpExTransformationService
-
-
Constructor Summary
Constructors Constructor Description DefaultImpExTransformationService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DataGeneratorOperationgetDataGeneratorOperation()protected FileGeneratorOperationgetFileGeneratorOperation()protected ImportCockpitMediaServicegetImportCockpitMediaService()protected booleanhasValidSource(MappingModel mappingModel, CSVReader csvReader)Checks if the mapping model for transformation and the CSVReader used to read source in the mapping model is valid.protected booleanisValidCsvReadLine(CSVReader csvReader, int linesToSkip)Checks if the currentCSVReaderline is validvoidsetDataGeneratorOperation(DataGeneratorOperation dataGenOperation)voidsetFileGeneratorOperation(FileGeneratorOperation fileGenOperation)voidsetImportCockpitMediaService(ImportCockpitMediaService importCockpitMediaService)java.util.Map<java.lang.String,java.io.File>transformData(ImportCockpitCronJobModel cronJobModel, MappingModel mappingModel)Transforms all the source data (CSV format) stored in a givenImportCockpitCronJobModelinto seperate CSV Data files based on theMappingModeldefined.protected voidwriteRocordToCsvFile(CSVWriter csvWriter, java.util.Map<java.lang.Integer,java.lang.String> record, boolean clear)Writes a record to a CSV file using a CSVWriter.
-
-
-
Method Detail
-
getImportCockpitMediaService
protected ImportCockpitMediaService getImportCockpitMediaService()
-
setImportCockpitMediaService
public void setImportCockpitMediaService(ImportCockpitMediaService importCockpitMediaService)
-
getDataGeneratorOperation
protected DataGeneratorOperation getDataGeneratorOperation()
-
setDataGeneratorOperation
public void setDataGeneratorOperation(DataGeneratorOperation dataGenOperation)
-
getFileGeneratorOperation
protected FileGeneratorOperation getFileGeneratorOperation()
-
setFileGeneratorOperation
public void setFileGeneratorOperation(FileGeneratorOperation fileGenOperation)
-
transformData
public java.util.Map<java.lang.String,java.io.File> transformData(ImportCockpitCronJobModel cronJobModel, MappingModel mappingModel)
Description copied from interface:ImpExTransformationServiceTransforms all the source data (CSV format) stored in a givenImportCockpitCronJobModelinto seperate CSV Data files based on theMappingModeldefined. The CSV files generated consist of the Main CSV file e.g.Productand all "Sub Data" e.g.europe1Prices,...,.... "Sub Data" here is the data that will be imported on the fly when the user has specified the CREATE impexImportMode for at least one composed mapped line (MappingLineModel).- Specified by:
transformDatain interfaceImpExTransformationService- Parameters:
cronJobModel- - aImportCockpitCronJobModelobject that ismappingModel- - theMappingModelobject which is linked to the source data.- Returns:
- an
unmodifiableMapof all the files generated during the transformation process.
-
hasValidSource
protected boolean hasValidSource(MappingModel mappingModel, CSVReader csvReader)
Checks if the mapping model for transformation and the CSVReader used to read source in the mapping model is valid.- Parameters:
mappingModel- - aMappingModelobject.csvReader- - aCSVReaderobject.- Returns:
- true if the mapping model has a valid source CSV file and the CSVReader used to read this source is valid.
-
isValidCsvReadLine
protected boolean isValidCsvReadLine(CSVReader csvReader, int linesToSkip)
Checks if the currentCSVReaderline is valid- Parameters:
csvReader- - aCSVReaderobject.linesToSkip- - number of lines to skip when reading from the csv file.- Returns:
- true if the line is valid
-
writeRocordToCsvFile
protected void writeRocordToCsvFile(CSVWriter csvWriter, java.util.Map<java.lang.Integer,java.lang.String> record, boolean clear) throws java.io.IOException
Writes a record to a CSV file using a CSVWriter. The record is validated before writing.- Parameters:
csvWriter- - aCSVWriterobject used to write CSV data.record- - aMapcontaining data to be written to the csv file. SeeCSVReader.parseLine(String)for the structure of theMap.clear- - aboolean, if true will clear the recordMapof all data when the write completes. Suitable when this is called in a loop.- Throws:
java.io.IOException- - error while writing.
-
-