Class ImpExManager

All Implemented Interfaces:
ItemLifecycleListener, Serializable

public class ImpExManager extends GeneratedImpExManager
This is the extension manager of the ImpEx extension. Here you can create default import or export cronjobs as well as performing an import or export using pre-defined methods.
See Also:
  • Constructor Details

    • ImpExManager

      public ImpExManager()
  • Method Details

    • getInstance

      public static ImpExManager getInstance()
      Gets the singleton instance of this manager.
      Returns:
      instance of this manager
    • createDefaultExportCronJob

      public ImpExExportCronJob createDefaultExportCronJob(ExportConfiguration config)
      Creates an export cronjob with given export configuration.
      Parameters:
      config - export configuration
      Returns:
      ImpExExportCronJob created instance
    • createDefaultExportCronJob

      public ImpExExportCronJob createDefaultExportCronJob()
      Creates an export cronjob with default values including the DEST_MEDIA media and ItemPKsMedia media (all Items of the System).
      Returns:
      ImpExExportCronJob created instance
    • createDefaultExportCronJob

      public ImpExExportCronJob createDefaultExportCronJob(HeaderLibrary headerlibrary, Collection<Item> items) throws ImpExException
      Creates an export cronjob with default values including the DEST_MEDIA media and ItemPKsMedia media with the given list (null for all Items of the System).
      Parameters:
      items - list of items to export (PK-Strings and/or Items) or null for all.
      Returns:
      ImpExExportCronJob created instance
      Throws:
      ImpExException
    • createDefaultExportCronJob

      public ImpExExportCronJob createDefaultExportCronJob(ImpExExportJob impexExportJob, HeaderLibrary headerlibrary, Collection<Item> items) throws ImpExException
      Creates an export cronjob with default values including the DEST_MEDIA media and ItemPKsMedia media with the given list (null for all Items of the System).
      Parameters:
      impexExportJob - job instance set to cronjob
      items - list of items to export (PK-Strings and/or Items) or null for all.
      Returns:
      ImpExExportCronJob created instance
      Throws:
      ImpExException
    • getOrCreateImpExExportJob

      public ImpExExportJob getOrCreateImpExExportJob()
      Gets (or creates) the central ImpExExportJob instance.
      Returns:
      the export job instance
    • createDefaultImpExImportCronJob

      public ImpExImportCronJob createDefaultImpExImportCronJob()
      Creates a cronjob instance. As job instance the default job will be used.
      Flag singleexecutable is set to true and changrecordingenabled is set to false.
      Flag errorMode is set to FAIL.
      Returns:
      created cronjob instance
    • createDefaultImpExImportCronJob

      public ImpExImportCronJob createDefaultImpExImportCronJob(ImpExImportJob impexImportJob)
      Creates a cronjob instance. As job instance the given one is used or if null is given the default job will be used.
      Flag singleexecutable is set to true and changrecordingenabled is set to false.
      Flag errorMode is set to FAIL.
      Parameters:
      impexImportJob - job instance the cronjob will be initialized with or null if default job will be used
      Returns:
      created cronjob instance
    • getOrCreateImpExImportJob

      public ImpExImportJob getOrCreateImpExImportJob()
      Gets the central import job instance or creates it if not existent already.
      Returns:
      import job instance
    • createImpExExportMedia

      public ImpExExportMedia createImpExExportMedia(String code)
      Creates an ImpExExportMedia with given code.
      Parameters:
      code - code to use for media
      Returns:
      created media
    • createImpExMedia

      public ImpExMedia createImpExMedia(String code)
      Creates an ImpExMedia with given code. (null not allowed here)
      Parameters:
      code - code to use for media
      Returns:
      created media
    • createImpExMediaForCodeAndExtractionId

      public ImpExMedia createImpExMediaForCodeAndExtractionId(String code, String extractionId)
    • createImpExMedia

      public ImpExMedia createImpExMedia(String code, EnumerationValue encoding)
      Creates an ImpExMedia with given code and default encoding.
      Parameters:
      code - code to use for media
      encoding - encoding set to encoding attribute of media
      Returns:
      created media
    • createImpExMedia

      public ImpExMedia createImpExMedia(String code, String encoding, InputStream content) throws UnsupportedEncodingException
      Creates an ImpExMedia with given code, default encoding and content as well as CSV as mime type.
      Parameters:
      code - code to use for media
      encoding - encoding set to encoding attribute of media
      content - content to be set to the media
      Returns:
      created media
      Throws:
      UnsupportedEncodingException
    • createImpExMedia

      public ImpExMedia createImpExMedia(String code, String encoding, String content) throws UnsupportedEncodingException
      Creates an ImpExMedia with given code, default encoding and content as well as CSV as mime type.
      Parameters:
      code - code to use for media
      encoding - encoding set to encoding attribute of media
      content - content to be set to the media
      Returns:
      created media
      Throws:
      UnsupportedEncodingException
    • createImpExMedia

      public ImpExMedia createImpExMedia(String code, String encoding) throws UnsupportedEncodingException
      Creates an ImpExMedia with given code and default encoding as well as CSV as mime type.
      Parameters:
      code - code to use for media
      encoding - encoding set to encoding attribute of media
      Returns:
      created media
      Throws:
      UnsupportedEncodingException - given encoding can not be resolved to a valid encoding instance
    • createItem

      public Item createItem(String type, String attributes, String values) throws ImpExException
      Creates any item using ImpEx specific syntax. It is a simplification of an import with exactly one value line. It will be always performed an import with INSERT mode. For usage you have to give the type of the desired type, all attributes in ImpEx style you want to use (like in a header description) as well as the values for specified attributes.
      The field separator to use is always CSVConstants.HYBRIS_FIELD_SEPARATOR.
      The quote character to use is always CSVConstants.HYBRIS_QUOTE_CHARACTER.
      Sample usage:
       Language lang = (Language) ImpExUtils.createItem("Language", "isocode; active", "testLang; false");
       

      The example call will result in an import with following script:

        INSERT Language ; isocode  ; active
                        ; testLang ; false
       
      Parameters:
      type - the code of the type of the desired item
      attributes - separated text with specification of all attributes used in values in same order (for accepted separator see CSVConstants.DEFAULT_FIELD_SEPARATOR
      values - separated text with values for all attributes as specified in attributes in same order (for accepted separator see CSVConstants.DEFAULT_FIELD_SEPARATOR
      Returns:
      created item
      Throws:
      ImpExException - error while import of item
    • exportData

      public ImpExExportCronJob exportData(ImpExExportCronJob cronJob, boolean synchronous)
      Exports data using given ImpExExportCronJob instance.
      The used cronjob instance will be returned for further information gathering, so check result of cronjob in error case.
      Parameters:
      cronJob - cronjob used for import
      synchronous - start cronjob synchronous or asynchronous?
      Returns:
      cronjob instance used for export
    • exportData

      public Export exportData(ExportConfiguration config, boolean synchronous)
      Exports data using a new ImpExExportCronJob instance.
      The used cronjob instance will be created using given configuration. As result the resulting Export instance is returned if successful.
      Parameters:
      config - export configuration to use
      synchronous - start cronjob synchronous or asynchronous?
      Returns:
      export instance resulting by used cronjob or null if export has failed
    • exportData

      public Export exportData(ExportConfiguration config, HeaderLibrary library, Collection<Item> items, boolean synchronous) throws ImpExException
      Exports data using a new ImpExExportCronJob instance.
      The used cronjob instance will be created using given configuration and export script created out of given library and items (see ExportUtils.createExportScript(HeaderLibrary, Collection). As result the resulting Export instance is returned if successful.
      Parameters:
      config - export configuration to use
      library - header library used for creating of the export script
      items - list of items used for creating of the export script
      synchronous - start cronjob synchronous or asynchronous?
      Returns:
      export instance resulting by used cronjob or null if export has failed
      Throws:
      ImpExException - Error while creating export script of given library and items
    • exportDataLight

      public Export exportDataLight(ExportConfiguration config, HeaderLibrary library, Collection<Item> items) throws ImpExException
      Exports data without using a cronjob.
      ATTENTION: No logs are available except of these fired to the log4j system.
      Parameters:
      config - export configuration to use
      library - header library used for creating of the export script
      items - list of items used for creating of the export script
      Returns:
      export instance resulting by used cronjob or null if export has failed
      Throws:
      ImpExException - Error while creating export script of given library and items
    • exportDataLight

      public Export exportDataLight(ExportConfiguration config) throws ImpExException
      Exports data without using a cronjob.
      ATTENTION: No logs are available except of these fired to the log4j system.
      Parameters:
      config - export configuration to use
      Returns:
      export instance resulting by used cronjob or null if export has failed
      Throws:
      ImpExException - if no export script is set at config
    • importData

      public ImpExImportCronJob importData(ImpExImportCronJob cronJob, boolean synchronous, boolean removeOnSuccess)
      Imports data using given ImpExImportCronJob instance.
      If you want to use ImpEx syntax in external files, you have to enable external syntax parsing via bean shell statements in source data.
      The used cronjob instance will be returned for further information gathering ( except in removal case), so check result of cronjob in error case.
      Parameters:
      cronJob - cronjob used for import
      synchronous - start cronjob synchronous or asynchronous?
      removeOnSuccess - removes the used cronjob instance on success
      Returns:
      cronjob instance used for import or null if removed on success
    • importData

      public ImpExImportCronJob importData(ImpExMedia media, Collection<ImpExMedia> externalData, boolean codeexecution, boolean synchronous, boolean removeOnSuccess)
      Imports data using a new ImpExImportCronJob instance.
      If you want to use ImpEx syntax in external files, you have to enable external syntax parsing via bean shell statements in source data.
      The used cronjob instance will be returned for further information gathering ( except in removal case), so check result of cronjob in error case.
      Parameters:
      media - input media
      externalData - medias containing external data
      codeexecution - enable code execution while import
      synchronous - start cronjob synchronous or asynchronous?
      removeOnSuccess - removes the used cronjob instance on success
      Returns:
      cronjob instance used for import or null if removed on success
    • importData

      public ImpExImportCronJob importData(ImpExMedia media, ImpExMedia zipMedia, Collection<ImpExMedia> externalData, boolean codeexecution, boolean synchronous, boolean removeOnSuccess)
      Imports data using a new ImpExImportCronJob instance.
      If you want to use ImpEx syntax in external files, you have to enable external syntax parsing via bean shell statements in source data.
      The used cronjob instance will be returned for further information gathering ( except in removal case), so check result of cronjob in error case.
      Parameters:
      media - input media
      zipMedia - input zip media
      externalData - medias containing external data
      codeexecution - enable code execution while import
      synchronous - start cronjob synchronous or asynchronous?
      removeOnSuccess - removes the used cronjob instance on success
      Returns:
      cronjob instance used for import or null if removed on success
    • importData

      public ImpExImportCronJob importData(InputStream input, String encoding, char fieldSeparator, char quoteCharacter, boolean codeexecution)
      Imports data using a new ImpExImportCronJob instance.
      Parameters:
      input - input stream to source data
      encoding - encoding used by source data
      fieldSeparator - separator used for separating CSV-fields within given stream
      quoteCharacter - separator used for separating CSV-fields within given stream
      codeexecution - enable code execution while import
      Returns:
      cronjob instance used for import or null if removed on success
    • importData

      public ImpExImportCronJob importData(InputStream input, String encoding, boolean codeexecution)
      Imports data using a new ImpExImportCronJob instance.
      The used cronjob will be executed synchronous and removed on success.
      If you want to use ImpEx syntax in external files, you have to enable external syntax parsing via bean shell statements in source data.
      The used cronjob instance will be returned for further information gathering ( except in removal case), so check result of cronjob in error case.
      For further options please use importData(ImpExMedia, Collection, boolean, boolean, boolean) or importData(ImpExImportCronJob, boolean, boolean) directly.
      Parameters:
      input - input stream to source data
      encoding - encoding used by source data
      codeexecution - enable code execution while import
      Returns:
      cronjob instance used for import or null if removed on success
    • importData

      public ImpExImportCronJob importData(InputStream dataIs, InputStream mediaIs, String encoding, char fieldSeparator, char quoteCharacter, boolean codeexecution)
      Imports data using a new ImpExImportCronJob instance.
      Parameters:
      dataIs - input stream to source data
      mediaIs - input stream to source media
      encoding - encoding used by source data
      fieldSeparator - separator used for separating CSV-fields within given stream
      quoteCharacter - separator used for separating CSV-fields within given stream
      codeexecution - enable code execution while import
      Returns:
      cronjob instance used for import or null if removed on success
    • importDataLight

      public Importer importDataLight(InputStream input, String encoding, boolean codeexecution) throws ImpExException
      Imports data without using a cronjob.
      Amount of maximal performed passes will be set to infinit (-1).
      For getting further informations about passed import process, the used Importer instance is returned.
      ATTENTION: No logs are available except of these fired to the log4j system.
      Parameters:
      input - input stream to source data
      encoding - encoding used by source data
      codeexecution - enable code execution while import
      Returns:
      for import used Importer instance
      Throws:
      ImpExException - unsupported encoding
    • importDataLight

      public Importer importDataLight(CSVReader reader, boolean codeexecution) throws ImpExException
      Imports data without using a cronjob.
      Amount of maximal performed passes will be set to infinit (-1).
      For getting further informations about passed import process, the used Importer instance is returned.
      ATTENTION: No logs are available except of those fired to the log4j system.
      Parameters:
      reader - reader providing source data
      codeexecution - enable code execution while import
      Returns:
      for import used Importer instance
      Throws:
      ImpExException - error while import
    • importDataLight

      public Importer importDataLight(CSVReader reader, boolean codeexecution, int passes) throws ImpExException
      Imports data without using a cronjob.
      For getting further informations about passed import process, the used Importer instance is returned.
      ATTENTION: No logs are available except of these fired to the log4j system.
      Parameters:
      reader - providing source data
      codeexecution - enable code execution while import
      passes - maximal amount of import passes for resolving lines
      Returns:
      for import used Importer instance
      Throws:
      ImpExException - unsupported encoding
    • isSystemType

      public Boolean isSystemType(SessionContext ctx, ComposedType item)
      This overridden version adds support for inheritance of the "system type" flag, i.e. sub types of a "system type" will also be system types unless they're explicitly set not to.
      Overrides:
      isSystemType in class GeneratedImpExManager
      Returns:
      the systemType
    • createEssentialData

      public void createEssentialData(Map params, JspContext jspc) throws ConsistencyCheckException
      Overrides:
      createEssentialData in class Extension
      Throws:
      ConsistencyCheckException
    • getImpExMediaFolder

      public MediaFolder getImpExMediaFolder()
      Gets the impex specific MediaFolder used for storing data of ImpExMedia.
      Returns:
      folder for impex specific medias
      Since:
      3.1-u4
    • getImportStrictMode

      public static EnumerationValue getImportStrictMode()
      Gathers the enumeration value for the strict import validation mode.
      Returns:
      enumeration value for strict import
    • getImportRelaxedMode

      public static EnumerationValue getImportRelaxedMode()
      Gathers the enumeration value for the relaxed import validation mode.
      Returns:
      enumeration value for relaxed import
    • getExportOnlyMode

      public static EnumerationValue getExportOnlyMode()
      Gathers the enumeration value for the export only validation mode.
      Returns:
      enumeration value for export only mode
    • getExportReimportRelaxedMode

      public static EnumerationValue getExportReimportRelaxedMode()
      Gathers the enumeration value for the relaxed export validation mode.
      Returns:
      enumeration value for relaxed export
    • getExportReimportStrictMode

      public static EnumerationValue getExportReimportStrictMode()
      Gathers the enumeration value for the strict export validation mode.
      Returns:
      enumeration value for strict export
    • getValidationMode

      public static EnumerationValue getValidationMode(String code)
      Gathers the enumeration value for given validation mode.
      Returns:
      enumeration value for given validation mode