Class DatevImportService


  • @DeclareRoles({"org.imixs.ACCESSLEVEL.NOACCESS","org.imixs.ACCESSLEVEL.READERACCESS","org.imixs.ACCESSLEVEL.AUTHORACCESS","org.imixs.ACCESSLEVEL.EDITORACCESS","org.imixs.ACCESSLEVEL.MANAGERACCESS"})
    @RolesAllowed({"org.imixs.ACCESSLEVEL.NOACCESS","org.imixs.ACCESSLEVEL.READERACCESS","org.imixs.ACCESSLEVEL.AUTHORACCESS","org.imixs.ACCESSLEVEL.EDITORACCESS","org.imixs.ACCESSLEVEL.MANAGERACCESS"})
    public class DatevImportService
    extends Object
    This Service provides methods to import data from a DATEV file.

    The import file must contain 2 header rows. The 1st row contains the object type, the 2nd row contains the filed names.

    Example 1st line:

     "DTVF";700;20;"Kontenbeschriftungen";2;20180917165240335;;"RE";"Farida.Weikard";"";217386;21010;20180101;6;;;"";"";;0;;"";;"";;141987;"04";;;"";""
     
    Example 2nd line:
     Konto;Kontobeschriftung;SprachId
     

    The service provides methods to search for DATEV objects by key or search phrase. A search result can be optional restricted to a specific DATEV client. NOTE: the item _datev_client_id must be part of the property lucence.indexFieldListNoAnalyze to use this feature.

    Author:
    rsoika
    See Also:
    to import datev data and assign the data to a workflow model.
    • Constructor Detail

      • DatevImportService

        public DatevImportService()
    • Method Detail

      • findEntityByName

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

        The param clientID is optional and restricts the result to a specific DATEV client. NOTE: the item _datev_client_id must be part of the property lucence.indexFieldListNoAnalyze.

        Parameters:
        key - - name of the object (txtname)
        type - - DATEV type of the object
        clientID - - optional restriction to a specific client id (_datev_client_id)
        Returns:
        DATEV entity or null if no entity with the given name exits
      • searchEntity

        public List<org.imixs.workflow.ItemCollection> searchEntity​(String phrase,
                                                                    String type,
                                                                    String clientID)
        This method returns a list of ItemCollections matching the search phrase and type. The type depends on the datev import file

        The param clientID is optional and restricts the result to a specific DATEV client. NOTE: the item _datev_client_id must be part of the property lucence.indexFieldListNoAnalyze.

        Parameters:
        phrase - - search phrase
        type - - DATEV type of the object
        clientID - - optional restriction to a specific client id (_datev_client_id)
        Returns:
        - list of matching profiles
      • importData

        public String importData​(InputStream imputStream,
                                 String encoding)
                          throws org.imixs.workflow.exceptions.PluginException
        This method imports all entities from a csv file. The file must have two header lines. 1st Line=object type, 2nd line = fieldnames.

        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 the item '_datev_client_id' and '_datev_consultant_id'. These item are mapped to the "Mandant id" and "Berater id" from Datev. These categories allow the import of data from different clients and consults. It is important that the fields '_datev_client_id' and '_datev_consultant_id' are added to the lucene index so that a search for data of a specific client is possible.

        lucence.indexFieldListNoAnalyze=....,_datev_client_id,_datev_consultant_id

        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
      • normalizeValueList

        public String[] normalizeValueList​(String[] data)
        This method removes the " from a value list
        Parameters:
        data -
        Returns:
      • parseFieldList

        public List<String> parseFieldList​(String data)
        This method parses a DATEV field description (first line of the csv file)
        Returns:
        list of fieldnames
      • saveEntry

        public void saveEntry​(org.imixs.workflow.ItemCollection aWorkitem,
                              String type,
                              String clientID,
                              String consultenID)
                       throws org.imixs.workflow.exceptions.AccessDeniedException,
                              org.imixs.workflow.exceptions.ProcessingErrorException,
                              org.imixs.workflow.exceptions.PluginException,
                              org.imixs.workflow.exceptions.ModelException
        This method process a single workIten in a new transaction. The method adds the type 'kreditor' to the entity.
        Parameters:
        aWorkitem -
        Throws:
        org.imixs.workflow.exceptions.PluginException
        org.imixs.workflow.exceptions.ProcessingErrorException
        org.imixs.workflow.exceptions.AccessDeniedException
        org.imixs.workflow.exceptions.ModelException
      • readEntity

        public org.imixs.workflow.ItemCollection readEntity​(String data,
                                                            List<String> fieldnames)
        This method creates a ItemCollection from a csv file data line The method also creates a txtworkflowabstract to support fulltext search
        Parameters:
        data -
        fieldnames -
        Returns: