Class Exporter

java.lang.Object
de.hybris.platform.impex.jalo.exp.Exporter
All Implemented Interfaces:
ImpExLogFilter.LocationProvider

public class Exporter extends Object implements ImpExLogFilter.LocationProvider
Base class for processing an impex based export.

> Sample usage:

 ExportConfiguration    config  = new ExportConfiguration( impexscript, ImpExManager.getExportOnlyMode() );
 <br>
 config.setDataExportTarget( datatarget );
 <br>
 config.setMediasExportTarget( mediastarget );
 <br>
 exporter = new Exporter( config );
 <br>
 Export export  = exporter.export();
 <br>
 
  • Field Details

    • DEFAULT_ITEM_DUMP_RANGE

      public static final int DEFAULT_ITEM_DUMP_RANGE
      See Also:
    • LOG_INTERVAL

      public static final long LOG_INTERVAL
      Duration between two logs.
      See Also:
  • Constructor Details

  • Method Details

    • logProcess

      protected void logProcess()
      Logs current state to the log4j system. Will log only if log level and log interval fits.
    • getExportedItemsCount

      public long getExportedItemsCount()
      Gets the amount of exported items.
      Returns:
      amount of exported items
    • export

      public Export export() throws ImpExException
      Returns:
      the exported 'data'\'medias' container
      Throws:
      ImpExException
    • runScriptBasedExport

      protected void runScriptBasedExport() throws FileNotFoundException, JaloBusinessException
      Throws:
      FileNotFoundException
      JaloBusinessException
    • createImpExReader

      protected ImpExReader createImpExReader(CSVReader scriptReader, DocumentIDRegistry docIDRegistry, EnumerationValue headerValidationMode)
      creates an (@see MyImpExReader) instance
      Parameters:
      scriptReader -
      docIDRegistry -
      headerValidationMode -
      Returns:
      the used ImpExReader instance
    • getExExportWriter

      @Deprecated(since="ages", forRemoval=false) public ImpExExportWriter getExExportWriter()
      Deprecated.
      since ages - usegetImpExExportWriter() instead
      Returns:
      the used ImpExExportWriter instance
    • getImpExExportWriter

      public ImpExExportWriter getImpExExportWriter()
      Returns:
      the used ImpExExportWriter instance
      Since:
      3.1
    • createExportWriter

      protected ImpExExportWriter createExportWriter() throws ImpExException
      Returns:
      ImpExExportWriter
      Throws:
      ImpExException
    • hasNextHeader

      public boolean hasNextHeader()
      Returns:
      has next header
    • getNextHeader

      public HeaderDescriptor getNextHeader()
      Returns:
      the next HeaderDescriptor instance
    • getCurrentHeaderCount

      public int getCurrentHeaderCount()
      Returns:
      header count
    • exportInternal

      protected void exportInternal() throws ImpExException
      Throws:
      ImpExException
    • exportAllHeader

      public void exportAllHeader() throws ImpExException
      Throws:
      ImpExException
    • getResultingFiles

      public Collection<String> getResultingFiles()
      Returns:
      result files
    • exportUserRights

      protected void exportUserRights() throws ImpExException
      Throws:
      ImpExException
    • getAllItems

      protected Collection<Item> getAllItems(String code, int start, int count, boolean inclSubtypes)
      A flexible search like SELECT {Item.PK} FROM {code} ORDER BY will be executed, internally
      Parameters:
      code - typecode
      start - the start number of the search range (@see FlexibleSearch.search(String, List, List, boolean, boolean, boolean, int, int, String))
      count - the number of elements in this search range (@see FlexibleSearch.search(String, List, List, boolean, boolean, boolean, int, int, String))
      inclSubtypes - including subtypes "SELECT {Item.PK} FROM {code} ORDER BY ..." or "SELECT {Item.PK} FROM {code!} ORDER BY ..."
      Returns:
      search result
    • exportItems

      public final void exportItems(String typecode) throws ImpExException
      Called via bean shell - exports all items of given type not including subtypes.
      Example:
       "#% impex.exportItems( ""CategoryProductRelation"" );"
       
      Parameters:
      typecode - type whose items will be exported
      Throws:
      ImpExException
    • exportItems

      public final void exportItems(String typecode, boolean inclSubTypes) throws ImpExException
      Called via bean shell - exports all items of given type.
      Example:
       "#% impex.exportItems( ""CategoryProductRelation"", false );"
       
      Parameters:
      typecode - type whose items will be exported
      inclSubTypes - should subtypes of given type be considered too?
      Throws:
      ImpExException
    • exportItems

      public void exportItems(String typecode, int count) throws ImpExException
      Called via bean shell - exports all items of given type not including subtypes with given range for flexible search.
      Example:
       "#% impex.exportItems( ""CategoryProductRelation"", Exporter.DEFAULT_ITEM_DUMP_RANGE );"
       
      Parameters:
      typecode - type whose items will be exported
      count - range used for flexible search
      Throws:
      ImpExException
    • exportItems

      public void exportItems(String typecode, int count, boolean inclSubTypes) throws ImpExException
      Called via bean shell - exports all items of given type.
      Example:
       "#% impex.exportItems( ""CategoryProductRelation"", Exporter.DEFAULT_ITEM_DUMP_RANGE, false );"
       
      Parameters:
      typecode - type whose items will be exported
      count - range used for flexible search
      inclSubTypes - should subtypes of given type be considered too?
      Throws:
      ImpExException
    • setTargetFile

      public void setTargetFile(String filename, boolean writeHeader) throws ImpExException
      Called via bean shell - sets the name of the target file within zip for resulting data of next header. Does only fire for the next header. The column offset used is -1 regardless of what the column offset has been set to.
      Example:
       "#% impex.setTargetFile( ""CategoryProductRelation.csv"" , true );"
       
      Parameters:
      filename - name for target file
      writeHeader - write header as comment to the target file
      Throws:
      ImpExException
    • setTargetFile

      public void setTargetFile(String filename, boolean writeHeader, int linesToSkip, int offset) throws ImpExException
      Called via bean shell - sets the name of the target file within zip for resulting data of next header. Does only fire for the next header.
      Example:
       "#% impex.setTargetFile( ""CategoryProductRelation.csv"" , true, 1, -1 );"
       
      Parameters:
      filename - name for target file
      writeHeader - write header as comment to the target file
      linesToSkip - sets the linesToSkip parameter at the related inludeExternalDataMedia call of the generated import script
      offset - sets the offset parameter at the related inludeExternalDataMedia call of the generated import script
      Throws:
      ImpExException
      See Also:
    • setTargetFile

      public void setTargetFile(String filename) throws ImpExException
      Called via bean shell - sets the name of the target file within zip for resulting data of next header. Does only fire for the next header.
      Example:
       "#% impex.setTargetFile( ""CategoryProductRelation.csv"" );"
       
      Parameters:
      filename - name for target file
      Throws:
      ImpExException
    • setRelaxedMode

      @Deprecated(since="ages", forRemoval=false) public void setRelaxedMode(boolean isRelaxedMode) throws ImpExException
      Deprecated.
      since ages - use "#% impex.setValidationMode( ""import_relax"" );" or "#% impex.setValidationMode( ImpExManager.getImportRelaxedMode() );" , instead
      Called via bean shell.
      Throws:
      ImpExException
    • exportItems

      @Deprecated(since="ages", forRemoval=false) public void exportItems(String query, Map values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count) throws ImpExException
      Called via bean shell - exports all items resulting from given flexible search. The parameters of this method redirecting to FlexibleSearch.search(String, Map, List, boolean, boolean, int, int)
      Example:
       #-----------------------------------------------------------
       INSERT Product; PK; code[unique=true]; name[lang=de]
       #-----------------------------------------------------------
       "#% impex.exportItems( ""select {pk}from {Product}"", Collections.EMPTY_MAP, Collections.singletonList( Item.class ), true, true, -1, -1 );"
       
      Throws:
      ImpExException
    • exportItemsFlexibleSearch

      public void exportItemsFlexibleSearch(String query, Map values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count) throws ImpExException
      Called via bean shell - exports all items resulting from given flexible search. The parameters of this method redirecting to FlexibleSearch.search(String, Map, List, boolean, boolean, int, int)
      Example:
       #-----------------------------------------------------------
       INSERT Product; PK; code[unique=true]; name[lang=de]
       #-----------------------------------------------------------
       "#% impex.exportItemsFlexibleSearch( ""select {pk}from {Product}"", Collections.EMPTY_MAP, Collections.singletonList( Item.class ), true, true, -1, -1 );"
       
      Throws:
      ImpExException
      Since:
      3.1-RC
    • exportItemsFlexibleSearch

      public void exportItemsFlexibleSearch(String query) throws ImpExException
      Called via bean shell - exports all items resulting from given flexible search.
      Performs a call of
       exportItemsFlexibleSearch(query, Collections.EMPTY_MAP, Collections.singletonList(Item.class), true, true, -1, -1);
       
      Example:
       #-----------------------------------------------------------
       INSERT Product; PK; code[unique=true]; name[lang=de]
       #-----------------------------------------------------------
       "#% impex.exportItemsFlexibleSearch( ""select {pk}from {Product}"" );"
       
      Parameters:
      query - used flexible search query used for gathering items
      Throws:
      ImpExException
      Since:
      3.1-RC
      See Also:
    • exportItemsFlexibleSearch

      public void exportItemsFlexibleSearch(String query, int count) throws ImpExException
      Called via bean shell - exports all items resulting from given flexible search.
      Performs a call of
       exportItemsFlexibleSearch(query, Collections.EMPTY_MAP, Collections.singletonList(Item.class), true, true, -1, -1);
       
      Example:
       #-----------------------------------------------------------
       INSERT Product; PK; code[unique=true]; name[lang=de]
       #-----------------------------------------------------------
       "#% impex.exportItemsFlexibleSearch( ""select {pk}from {Product}"", 1000);"
       
      Parameters:
      query - used flexible search query used for gathering items
      count - range parameter used for flexible search call
      Throws:
      ImpExException
      Since:
      3.1-u6
      See Also:
    • exportItems

      public void exportItems(String[] pklist) throws ImpExException
      Called via bean shell - exports items specified by given PK list.
      Example:
       #-----------------------------------------------------------
       INSERT Employee; PK; uid[unique=true];
       #-----------------------------------------------------------
       "#% impex.exportItems( new String[]{ ""1132326173852672"" } );"
       
      Parameters:
      pklist - list of PK's whose items will be exported
      Throws:
      ImpExException
    • exportItems

      public void exportItems(Collection<Item> items) throws ImpExException
      Called via bean shell - exports items specified by given item list.
      Example:
       #-----------------------------------------------------------
       INSERT Employee; PK; uid[unique=true];
       #-----------------------------------------------------------
       "#% impex.exportItems( ProductManager.getInstance.getAllProducts() );"
       
      Parameters:
      items - collection of items which will be exported
      Throws:
      ImpExException
    • setValidationMode

      public void setValidationMode(String mode) throws ImpExException
      Called via bean shell - sets the validation mode to use.
      Example:
       "#% impex.setValidationMode( ""export_only"" );"
       "#% impex.setValidationMode(ImpExManager.getExportOnlyMode() );"
       
      Parameters:
      mode - new validation mode
      Throws:
      ImpExException
    • setLocale

      public void setLocale(Locale l) throws ImpExException
      Called via bean shell - sets the locale to use while import.
      Example:
       "#% impex.setLocale( Locale.GERMANY );"
       "#% impex.setLocale( new Locale(""de"",""de"" );"
       
      Parameters:
      l - new locale to use
      Throws:
      ImpExException
    • getCurrentLocation

      public String getCurrentLocation()
      Specified by:
      getCurrentLocation in interface ImpExLogFilter.LocationProvider