Class DataImportService

  • All Implemented Interfaces:
    OBProvidable, OBSingleton

    public class DataImportService
    extends Object
    implements OBSingleton
    Imports business objects from XML. The business objects can be imported in a specific Client and Organization or as a complete Client import.
    Author:
    Martin Taal
    • Constructor Detail

      • DataImportService

        public DataImportService()
    • Method Detail

      • importDataFromXML

        public ImportResult importDataFromXML​(Client client,
                                              Organization organization,
                                              String xml)
        Imports the business objects using the client/organization. If there are no error messages and no Exception occurred then the import method will persist the imported business objects. However, the import method does not do a commit. It is the callers responsibility to call commit (if the ImportResult does not contain error messages).
        Parameters:
        client - the client in which the business objects are created/updated
        organization - the organization in which the business objects are created/updated
        xml - the xml containing the data
        Returns:
        the ImportResult object contains error, log and warning messages and lists with the inserted and updated business objects
      • importDataFromXML

        public ImportResult importDataFromXML​(Client client,
                                              Organization organization,
                                              String xml,
                                              Module module,
                                              boolean filterOrganizations)
        Imports the business objects using the client/organization. If there are no error messages and no Exception occurred then the import method will persist the imported business objects. However, the import method does not do a commit. It is the callers responsibility to call commit (if the ImportResult does not contain error messages).
        Parameters:
        client - the client in which the import takes place
        organization - the organization in which the business objects are created
        xml - the xml containing the data
        module - the module is used to update the AD_REF_DATA_LOADED table during the import action
        Returns:
        the result of the import (error, log and warning messages, to-be-inserted and to-be-updated business objects
      • importClientData

        public ImportResult importClientData​(EntityXMLProcessor importProcessor,
                                             boolean importAuditInfo,
                                             Reader reader)
        Imports a complete client. This import method behaves slightly differently than the other import methods because it does not use the client/organization of the current user but uses the client and organization of the data in the import file itself. In addition no unique-constraint checking is done.
        Parameters:
        importProcessor - the import processor which is called for each object after the import
        importAuditInfo - if true then the auditInfo (updated, updatedBy etc.) is also imported.
        reader - the xml stream
        Returns:
        ImportResult which contains the updated/inserted objects and log and error messages
        See Also:
        importDataFromXML(Client, Organization, String)
      • saveUpdateConvertedObjects

        public void saveUpdateConvertedObjects​(XMLEntityConverter xec,
                                               ImportResult ir,
                                               boolean isClientImport,
                                               Module module)
        Performs the actual update/insert of objects in the correct order in the database. Also sets the ReferenceDataStore if required.
        Parameters:
        xec - the converter containing the to-be-inserted and to-be-updated objects
        ir - the ImportResult, warning and error messages are added to this object, also its ImportResult.getUpdatedObjects() and ImportResult.getInsertedObjects() is set
        isClientImport - is true if the import is for a client, in that case the ReferenceDataStore data is not set
        module - is set if the import is for a module, null is allowed