Class DefaultImpExTransformationService

    • Constructor Detail

      • DefaultImpExTransformationService

        public DefaultImpExTransformationService()
    • Method Detail

      • setImportCockpitMediaService

        public void setImportCockpitMediaService​(ImportCockpitMediaService importCockpitMediaService)
      • setDataGeneratorOperation

        public void setDataGeneratorOperation​(DataGeneratorOperation dataGenOperation)
      • 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: ImpExTransformationService
        Transforms all the source data (CSV format) stored in a given ImportCockpitCronJobModel into seperate CSV Data files based on the MappingModel defined. The CSV files generated consist of the Main CSV file e.g. Product and 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:
        transformData in interface ImpExTransformationService
        Parameters:
        cronJobModel - - a ImportCockpitCronJobModel object that is
        mappingModel - - the MappingModel object which is linked to the source data.
        Returns:
        an unmodifiableMap of 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 - - a MappingModel object.
        csvReader - - a CSVReader object.
        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 current CSVReader line is valid
        Parameters:
        csvReader - - a CSVReader object.
        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 - - a CSVWriter object used to write CSV data.
        record - - a Map containing data to be written to the csv file. See CSVReader.parseLine(String) for the structure of the Map.
        clear - - a boolean, if true will clear the record Map of all data when the write completes. Suitable when this is called in a loop.
        Throws:
        java.io.IOException - - error while writing.