Class CSVImportService


  • @Named
    public class CSVImportService
    extends Object
    The CSVImportService reacts on DocumentImportEvent and importes a CSV file form a FTP data source.

    The implementation is based on org.apache.commons.net.ftp

    The CSV import can be customized by various options

    Author:
    rsoika
    • Constructor Detail

      • CSVImportService

        public CSVImportService()
    • Method Detail

      • onEvent

        public void onEvent​(@Observes
                            DocumentImportEvent event)
        This method reacts on a CDI ImportEvent and imports the data of a CSV file form a ftp server.
      • importData

        public String importData​(InputStream imputStream,
                                 String encoding,
                                 String type,
                                 String keyField,
                                 DocumentImportEvent event)
                          throws org.imixs.workflow.exceptions.PluginException
        This method imports all entities from a csv file. The file must have one header line.

        The method runs in a new transaction so processing exceptions can be caught.

        All existing entries not listed in the current file will be removed.

        Each imported document will have a unique key in the item 'name' to be used to verify if the entry already exists.

        The method returns a log . If an error occurs a plugin exception is thrown

        Returns:
        ErrorMessage or empty String
        Throws:
        org.imixs.workflow.exceptions.PluginException
      • findEntityByName

        public org.imixs.workflow.ItemCollection findEntityByName​(String key,
                                                                  String type)
        This method finds a entity by the attribute 'Name'

        Parameters:
        key - - name of the object (name)
        type - - type of the object
        Returns:
        entity or null if no entity with the given name exits