Class Exporter
java.lang.Object
de.hybris.platform.impex.jalo.exp.Exporter
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionstatic final intstatic final longDuration between two logs. -
Constructor Summary
ConstructorsConstructorDescriptionExporter(ExportConfiguration config) Exporter(ImpExMedia source, EnumerationValue headerValidationMode) -
Method Summary
Modifier and TypeMethodDescriptionprotected ImpExExportWriterprotected ImpExReadercreateImpExReader(CSVReader scriptReader, DocumentIDRegistry docIDRegistry, EnumerationValue headerValidationMode) creates an (@see MyImpExReader) instanceexport()voidprotected voidfinal voidexportItems(String typecode) Called via bean shell - exports all items of given type not including subtypes.
Example:voidexportItems(String[] pklist) Called via bean shell - exports items specified by given PK list.
Example:final voidexportItems(String typecode, boolean inclSubTypes) Called via bean shell - exports all items of given type.
Example:voidexportItems(String typecode, int count) Called via bean shell - exports all items of given type not including subtypes with given range for flexible search.
Example:voidexportItems(String typecode, int count, boolean inclSubTypes) Called via bean shell - exports all items of given type.
Example:voidexportItems(String query, Map values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count) Deprecated.voidexportItems(Collection<Item> items) Called via bean shell - exports items specified by given item list.
Example:voidexportItemsFlexibleSearch(String query) Called via bean shell - exports all items resulting from given flexible search.
Performs a call ofvoidexportItemsFlexibleSearch(String query, int count) Called via bean shell - exports all items resulting from given flexible search.
Performs a call ofvoidexportItemsFlexibleSearch(String query, Map values, List resultClasses, boolean failOnUnknownFields, boolean dontNeedTotal, int start, int count) Called via bean shell - exports all items resulting from given flexible search.protected voidprotected Collection<Item>getAllItems(String code, int start, int count, boolean inclSubtypes) A flexible search likeSELECT {Item.PK} FROM {code} ORDER BYwill be executed, internallyintDeprecated.since ages - usegetImpExExportWriter()insteadlongGets the amount of exported items.booleanprotected voidLogs current state to the log4j system.protected voidvoidCalled via bean shell - sets the locale to use while import.voidsetRelaxedMode(boolean isRelaxedMode) Deprecated.since ages - use"#% impex.setValidationMode( ""import_relax"" );"or"#% impex.setValidationMode( ImpExManager.getImportRelaxedMode() );", insteadvoidsetTargetFile(String filename) Called via bean shell - sets the name of the target file within zip for resulting data of next header.voidsetTargetFile(String filename, boolean writeHeader) Called via bean shell - sets the name of the target file within zip for resulting data of next header.voidsetTargetFile(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.voidsetValidationMode(String mode) Called via bean shell - sets the validation mode to use.
-
Field Details
-
DEFAULT_ITEM_DUMP_RANGE
public static final int DEFAULT_ITEM_DUMP_RANGE- See Also:
-
LOG_INTERVAL
public static final long LOG_INTERVALDuration between two logs.- See Also:
-
-
Constructor Details
-
Exporter
- Parameters:
config-- Throws:
ImpExException
-
Exporter
- Parameters:
source-headerValidationMode-- Throws:
ImpExException
-
-
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
- Returns:
- the exported 'data'\'medias' container
- Throws:
ImpExException
-
runScriptBasedExport
-
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 - usegetImpExExportWriter()instead- Returns:
- the used ImpExExportWriter instance
-
getImpExExportWriter
- Returns:
- the used ImpExExportWriter instance
- Since:
- 3.1
-
createExportWriter
- Returns:
- ImpExExportWriter
- Throws:
ImpExException
-
hasNextHeader
public boolean hasNextHeader()- Returns:
- has next header
-
getNextHeader
- Returns:
- the next HeaderDescriptor instance
-
getCurrentHeaderCount
public int getCurrentHeaderCount()- Returns:
- header count
-
exportInternal
- Throws:
ImpExException
-
exportAllHeader
- Throws:
ImpExException
-
getResultingFiles
- Returns:
- result files
-
exportUserRights
- Throws:
ImpExException
-
getAllItems
A flexible search likeSELECT {Item.PK} FROM {code} ORDER BYwill 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
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
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
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
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
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-1regardless 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(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 thelinesToSkipparameter at the relatedinludeExternalDataMediacall of the generated import scriptoffset- sets theoffsetparameter at the relatedinludeExternalDataMediacall of the generated import script- Throws:
ImpExException- See Also:
-
setTargetFile
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() );", insteadCalled 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 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(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 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
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
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:
-
exportItems
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
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
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
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
- Specified by:
getCurrentLocationin interfaceImpExLogFilter.LocationProvider
-
exportItemsFlexibleSearch(String, Map, List, boolean, boolean, int, int)instead