Class Exporter

  • All Implemented Interfaces:
    ImpExLogFilter.LocationProvider

    public class Exporter
    extends java.lang.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 Detail

      • DEFAULT_ITEM_DUMP_RANGE

        public static final int DEFAULT_ITEM_DUMP_RANGE
        See Also:
        Constant Field Values
      • LOG_INTERVAL

        public static final long LOG_INTERVAL
        Duration between two logs.
        See Also:
        Constant Field Values
    • Method Detail

      • 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
      • createImpExReader

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

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

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

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

        public int getCurrentHeaderCount()
        Returns:
        header count
      • getResultingFiles

        public java.util.Collection<java.lang.String> getResultingFiles()
        Returns:
        result files
      • exportItems

        public final void exportItems​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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:
        ImpExReader.includeExternalDataMedia(String, String, int, int)
      • setTargetFile

        public void setTargetFile​(java.lang.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
        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
        public void exportItems​(java.lang.String query,
                                java.util.Map values,
                                java.util.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​(java.lang.String query,
                                              java.util.Map values,
                                              java.util.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​(java.lang.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(String, Map, List, boolean, boolean, int, int)
      • exportItemsFlexibleSearch

        public void exportItemsFlexibleSearch​(java.lang.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:
        exportItemsFlexibleSearch(String, Map, List, boolean, boolean, int, int)
      • exportItems

        public void exportItems​(java.lang.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​(java.util.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​(java.lang.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​(java.util.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