Class Exporter
- java.lang.Object
-
- de.hybris.platform.impex.jalo.exp.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 Summary
Fields Modifier and Type Field Description static int
DEFAULT_ITEM_DUMP_RANGE
static long
LOG_INTERVAL
Duration between two logs.
-
Constructor Summary
Constructors Constructor Description Exporter(ExportConfiguration config)
Exporter(ImpExMedia source, EnumerationValue headerValidationMode)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected ImpExExportWriter
createExportWriter()
protected ImpExReader
createImpExReader(CSVReader scriptReader, DocumentIDRegistry docIDRegistry, EnumerationValue headerValidationMode)
creates an (@see MyImpExReader) instanceExport
export()
void
exportAllHeader()
protected void
exportInternal()
void
exportItems(java.lang.String typecode)
Called via bean shell - exports all items of given type not including subtypes.
Example:void
exportItems(java.lang.String[] pklist)
Called via bean shell - exports items specified by given PK list.
Example:void
exportItems(java.lang.String typecode, boolean inclSubTypes)
Called via bean shell - exports all items of given type.
Example:void
exportItems(java.lang.String typecode, int count)
Called via bean shell - exports all items of given type not including subtypes with given range for flexible search.
Example:void
exportItems(java.lang.String typecode, int count, boolean inclSubTypes)
Called via bean shell - exports all items of given type.
Example:void
exportItems(java.lang.String query, java.util.Map values, java.util.List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count)
Deprecated.since ages - useexportItemsFlexibleSearch(String, Map, List, boolean, boolean, int, int)
insteadvoid
exportItems(java.util.Collection<Item> items)
Called via bean shell - exports items specified by given item list.
Example:void
exportItemsFlexibleSearch(java.lang.String query)
Called via bean shell - exports all items resulting from given flexible search.
Performs a call ofvoid
exportItemsFlexibleSearch(java.lang.String query, int count)
Called via bean shell - exports all items resulting from given flexible search.
Performs a call ofvoid
exportItemsFlexibleSearch(java.lang.String query, java.util.Map values, java.util.List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count)
Called via bean shell - exports all items resulting from given flexible search.protected void
exportUserRights()
protected java.util.Collection<Item>
getAllItems(java.lang.String code, int start, int count, boolean inclSubtypes)
A flexible search likeSELECT {Item.PK} FROM {code} ORDER BY
will be executed, internallyint
getCurrentHeaderCount()
java.lang.String
getCurrentLocation()
ImpExExportWriter
getExExportWriter()
Deprecated.since ages - usegetImpExExportWriter()
insteadlong
getExportedItemsCount()
Gets the amount of exported items.ImpExExportWriter
getImpExExportWriter()
HeaderDescriptor
getNextHeader()
java.util.Collection<java.lang.String>
getResultingFiles()
boolean
hasNextHeader()
protected void
logProcess()
Logs current state to the log4j system.protected void
runScriptBasedExport()
void
setLocale(java.util.Locale l)
Called via bean shell - sets the locale to use while import.void
setRelaxedMode(boolean isRelaxedMode)
Deprecated.since ages - use"#% impex.setValidationMode( ""import_relax"" );"
or"#% impex.setValidationMode( ImpExManager.getImportRelaxedMode() );"
, insteadvoid
setTargetFile(java.lang.String filename)
Called via bean shell - sets the name of the target file within zip for resulting data of next header.void
setTargetFile(java.lang.String filename, boolean writeHeader)
Called via bean shell - sets the name of the target file within zip for resulting data of next header.void
setTargetFile(java.lang.String filename, boolean writeHeader, int linesToSkip, int offset)
Called via bean shell - sets the name of the target file within zip for resulting data of next header.void
setValidationMode(java.lang.String mode)
Called via bean shell - sets the validation mode to use.
-
-
-
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
-
-
Constructor Detail
-
Exporter
public Exporter(ExportConfiguration config) throws ImpExException
- Parameters:
config
-- Throws:
ImpExException
-
Exporter
public Exporter(ImpExMedia source, EnumerationValue headerValidationMode) throws ImpExException
- Parameters:
source
-headerValidationMode
-- Throws:
ImpExException
-
-
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
-
export
public Export export() throws ImpExException
- Returns:
- the exported 'data'\'medias' container
- Throws:
ImpExException
-
runScriptBasedExport
protected void runScriptBasedExport() throws java.io.FileNotFoundException, JaloBusinessException
- Throws:
java.io.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 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 java.util.Collection<java.lang.String> getResultingFiles()
- Returns:
- result files
-
exportUserRights
protected void exportUserRights() throws ImpExException
- Throws:
ImpExException
-
getAllItems
protected java.util.Collection<Item> getAllItems(java.lang.String code, int start, int count, boolean inclSubtypes)
A flexible search likeSELECT {Item.PK} FROM {code} ORDER BY
will be executed, internally- Parameters:
code
- typecodestart
- the start number of the search range (@seeFlexibleSearch.search(String, List, List, boolean, boolean, boolean, int, int, String)
)count
- the number of elements in this search range (@seeFlexibleSearch.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(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 exportedinclSubTypes
- 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 exportedcount
- 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 exportedcount
- range used for flexible searchinclSubTypes
- 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 filewriteHeader
- 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 filewriteHeader
- write header as comment to the target filelinesToSkip
- sets thelinesToSkip
parameter at the relatedinludeExternalDataMedia
call of the generated import scriptoffset
- sets theoffset
parameter at the relatedinludeExternalDataMedia
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() );"
, insteadCalled 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
Deprecated.since ages - useexportItemsFlexibleSearch(String, Map, List, boolean, boolean, int, int)
insteadCalled via bean shell - exports all items resulting from given flexible search. The parameters of this method redirecting toFlexibleSearch.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 toFlexibleSearch.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 ofexportItemsFlexibleSearch(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 ofexportItemsFlexibleSearch(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 itemscount
- 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
-
getCurrentLocation
public java.lang.String getCurrentLocation()
- Specified by:
getCurrentLocation
in interfaceImpExLogFilter.LocationProvider
-
-