public abstract class GenericCSVImportStep extends GeneratedGenericCSVImportStep
GenericCSVImportStep offers a framework of methods to support the parsing of CSV files.
Extend this Step to implement a CSV import for a specific CSV format.
If the default tokenisation is sufficent (tokenise(String)) for your file format, then you only have to
implement processObjects(Map, CronJob).
GenericItem.GenericItemImplLocalizableItem.LocalizableItemImplExtensibleItem.ExtensibleItemImplItem.AttributeFilter, Item.AttributeMode, Item.CachedGetter, Item.CachedSetter, Item.ItemAttributeMap, Item.ItemConstraint, Item.ItemImpl, Item.JaloCachedComputationExceptionDEFAULT_INITIAL_ATTRIBUTESBATCHJOB, CODE, CRONJOBPENDINGSTEPSRELATION_MARKMODIFIED, CRONJOBPENDINGSTEPSRELATION_SRC_ORDERED, CRONJOBPENDINGSTEPSRELATION_TGT_ORDERED, CRONJOBPROCESSEDSTEPSRELATION_MARKMODIFIED, CRONJOBPROCESSEDSTEPSRELATION_SRC_ORDERED, CRONJOBPROCESSEDSTEPSRELATION_TGT_ORDERED, ERRORMODE, PENDINGCRONJOBS, PROCESSEDCRONJOBS, SEQUENCENUMBER, SYNCHRONOUSLANGUAGE_FALLBACK_ENABLED_CREATION_TIME_INTERNAL, _MODIFIED_TIME_INTERNAL, accessorLog, CREATION_TIME, DISABLE_ATTRIBUTE_CHECK, DISABLE_ITEMCHECK_BEFORE_REMOVABLE, EVEN, FEATURE_ACCESSMAP_QUALIFIER, INITIAL_CREATION_FLAG, isJaloOnly, MODIFIED_TIME, NEGATIVE, NOT_FOUND, OWNER, PK, POSITIVE, SAVE_FROM_SERVICE_LAYER, staticTransientObjects, TYPEimpl, tenant| Constructor and Description |
|---|
GenericCSVImportStep() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkAbort(CronJob cronJob) |
protected CSVReader |
createCSVReader(java.io.InputStream inputStream,
java.lang.String encoding)
As default creates a new
CSVReader instance with the given stream and encoding. |
protected void |
finalizeStep(CronJob cronJob)
Method for finalizing the step.
|
protected java.lang.String |
getCharSet()
define the character set for the performStep() method.
|
protected char[] |
getCommentOutCharacters()
Returns a char array with of all comment tokens.
|
protected char[] |
getTokenCharacters()
Returns a character array witch is used as value seperator token.
|
boolean |
isAbortable()
Returns
true, if this Step is abortable. |
protected java.io.InputStream |
openMedia(JobMedia media,
CronJob cronJob)
Opens an
InputStream to the JobMedia of the specified CronJob. |
protected void |
performStep(CronJob cronJob)
Opens the batch media provided by the given job detail and iterates over all lines.
|
protected boolean |
processLine(java.lang.String line,
CronJob cronJob)
Deprecated.
since ages - no longer needed - just override
processObjects(Map, CronJob) to handle a tokenized line or
createCSVReader(InputStream, String) to define own tokenizing logic. |
protected abstract boolean |
processObjects(java.util.Map map,
CronJob cronJob)
Processes one parsed csv line.
|
protected boolean |
skipFirstLine()
Returns
true, if the first line of the file should be skipped. |
protected java.util.Map |
tokenise(java.lang.String line)
Deprecated.
since ages - to override line tokenizing use
createCSVReader(InputStream, String)! |
getDefaultAttributeModescanPerform, prepareMediaaddChange, canUndo, createItem, debug, error, fatal, getChanges, getChanges, getChanges, getChanges, getFailErrorMode, getIgnoreErrorMode, getMostRecentChange, getNonInitialAttributes, getPauseErrorMode, hasChanges, info, isDebugEnabled, isErrorEnabled, isInfoEnabled, isWarnEnabled, log, setNonInitialAttributes, toString, undoStep, warngetBatchJob, getBatchJob, getCode, getCode, getErrorMode, getErrorMode, getSequenceNumber, getSequenceNumber, getSequenceNumberAsPrimitive, getSequenceNumberAsPrimitive, isMarkModifiedDisabled, isSynchronous, isSynchronous, isSynchronousAsPrimitive, isSynchronousAsPrimitive, setBatchJob, setBatchJob, setCode, setCode, setErrorMode, setErrorMode, setSequenceNumber, setSequenceNumber, setSequenceNumber, setSequenceNumber, setSynchronous, setSynchronous, setSynchronous, setSynchronousgetInitialPropertiesgetAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllValuesSessionContext, getLocalizedProperty, getLocalizedProperty, getLocalizedPropertyInternal, getLocalizedPropertyNames, getLocalizedPropertyNames, hasLanguage, isEmptyValue, isFallbackEnabled, removeLocalizedProperty, removeLocalizedProperty, setAllLocalizedProperties, setAllLocalizedProperties, setLocalizedProperty, setLocalizedPropertycreateNonClassAccessor, getAllProperties, getAllProperties, getImplementation, getProperty, getProperty, getPropertyNames, getPropertyNames, removeProperty, removeProperty, setAllProperties, setAllProperties, setProperty, setPropertyaddLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addNegativePermission, addPermission, addPositivePermission, assureExtensionsLoaded, changeTypeAfterCreation, checkConstraint, checkItemPermission, checkMandatoryAttribute, checkMandatoryAttribute, checkPermission, checkPermission, checkRemovable, clearPermission, compareTo, ctx, doAfterRemove, doBeforeRemove, equals, getAccessorFor, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributesInternal, getAllLinkedItems, getAndCheckCacheBoundItem, getAttribute, getAttribute, getCacheBoundItem, getComposedType, getComposedTypePK, getCreationTime, getCurrentlyRemovingCount, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItemsCount, getLinkedItemsCount, getLinkedItemsCount, getModificationTime, getNegativePermissions, getOwner, getPermissionMap, getPermissions, getPersistenceVersion, getPK, getPositivePermissions, getRestrictedPrincipals, getSession, getSyncObject, getTenant, getTransientObject, getTransientObjectMap, hashCode, hasRegisteredClassAccessorFor, internal_registerClassAccessorFor, internal_registerNonClassAccessorFor, invalidateLocalCaches, isAlive, isCacheBound, isCurrentlyRemoving, isCurrentlyRemoving, isEmptyRelationValue, isInCreate, isInstanceOf, isItemCheckBeforeRemoveableDisabled, isRelationLocalizationFallbackEnabled, newInstance, notifyExtensionsAfterItemCreation, notifyExtensionsBeforeItemCreation, notifyItemRemoval, notifyManagerAboutItemRemoval, readResolve, registerAccessFor, registerAccessFor, registerJaloInvalidationListeners, remove, remove, removeItemCollection, removeItemCollection, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinks, removePartOfItems, removePartOfItems, setAllAttributes, setAllAttributes, setAllAttributesInternal, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAttribute, setAttribute, setAttributeFromString, setAttributeFromString, setCacheBound, setComposedType, setCreationTime, setImplementation, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setModificationTime, setOwner, setPermissionsByMap, setTransientObject, setUseTA, useTA, writeReplacesetTenantprotected abstract boolean processObjects(java.util.Map map,
CronJob cronJob)
throws JaloBusinessException
map - the data of the line as a Map Integer -> String - the key contains the
column index staring with 0cronJob - true if processing has succeeded - the job will continue regardless of this
resultJaloBusinessException - may be thrown to indicate a process error - the job will abort after this lineprotected void finalizeStep(CronJob cronJob) throws JaloBusinessException
cronJob - JaloBusinessExceptionprotected boolean skipFirstLine()
true, if the first line of the file should be skipped. This default implementation returns
false. Overwrite this method in your subclass, to change this default implementation.true, if the first line of the file should be skipped@Deprecated
protected final boolean processLine(java.lang.String line,
CronJob cronJob)
throws JaloBusinessException,
AbortCronJobException
processObjects(Map, CronJob) to handle a tokenized line or
createCSVReader(InputStream, String) to define own tokenizing logic.protected char[] getTokenCharacters()
As default CronJobConstants.CHARS.VERTICAL_LINE ( '|' ) is used.
Override this method to specify a different separator token.
protected char[] getCommentOutCharacters()
As default this method returns CronJobConstants.CHARS.POUND +
CronJobConstants.CHARS.PERCENT ( '#%' ). Override to specify a
different token.
protected CSVReader createCSVReader(java.io.InputStream inputStream, java.lang.String encoding) throws java.io.UnsupportedEncodingException
CSVReader instance with the given stream and encoding. Override when own parsing
and tokenizing logic is needed.inputStream - the csv data input streamencoding - the text encoding of the csv data streamjava.io.UnsupportedEncodingException - if the given encoding is not supportedprotected void performStep(CronJob cronJob) throws AbortCronJobException, JaloInvalidParameterException
MediaProcessorStep.prepareMedia(CronJob) at the beginning, openMedia(JobMedia, CronJob) to
open the input stream and processLine(String, CronJob) for each line which is read. Finally
finalizeStep(CronJob) is called after all lines are read.performStep in class StepcronJob - the CronJob which this step if performed for - must be a MediaProcessCronJob instanceAbortCronJobException - if a abort request has been detectedJaloInvalidParameterException - in case the job detail is no instance of MediaProcessCronJobStep.canPerform(CronJob)protected java.lang.String getCharSet()
protected java.io.InputStream openMedia(JobMedia media, CronJob cronJob) throws JaloBusinessException, java.io.IOException
InputStream to the JobMedia of the specified CronJob.
This default implementation used Media.getDataFromStream() to open the
stream to the media. Subclasses may override this e.g. to support zip file medias or similar.
media - the JobMedia which will be openedcronJob - the CronJob which this Step is executed forDataInputStream to the specified JobMediaJaloBusinessExceptionjava.io.IOException@Deprecated protected final java.util.Map tokenise(java.lang.String line)
createCSVReader(InputStream, String)!public boolean isAbortable()
Steptrue, if this Step is abortable.
The default implementation returns always false. To mark your Step subclass as
abortable, override this method and return true.isAbortable in class Steptrue, if this Step is abortableStep.isAbortable()protected void checkAbort(CronJob cronJob) throws AbortCronJobException
AbortCronJobExceptionCopyright © 2018 SAP SE. All Rights Reserved.