Package org.openbravo.service.db
Class DataImportService
- java.lang.Object
-
- org.openbravo.service.db.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 Summary
Constructors Constructor Description DataImportService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DataImportService
getInstance()
ImportResult
importClientData(EntityXMLProcessor importProcessor, boolean importAuditInfo, Reader reader)
Imports a complete client.ImportResult
importDataFromXML(Client client, Organization organization, String xml)
Imports the business objects using the client/organization.ImportResult
importDataFromXML(Client client, Organization organization, String xml, Module module)
ImportResult
importDataFromXML(Client client, Organization organization, String xml, Module module, boolean filterOrganizations)
Imports the business objects using the client/organization.void
saveUpdateConvertedObjects(XMLEntityConverter xec, ImportResult ir, boolean isClientImport, Module module)
Performs the actual update/insert of objects in the correct order in the database.static void
setInstance(DataImportService instance)
-
-
-
Method Detail
-
getInstance
public static DataImportService getInstance()
-
setInstance
public static void setInstance(DataImportService instance)
-
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/updatedorganization
- the organization in which the business objects are created/updatedxml
- 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 placeorganization
- the organization in which the business objects are createdxml
- the xml containing the datamodule
- 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
-
importDataFromXML
public ImportResult importDataFromXML(Client client, Organization organization, String xml, Module module)
-
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 importimportAuditInfo
- 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 theReferenceDataStore
if required.- Parameters:
xec
- the converter containing the to-be-inserted and to-be-updated objectsir
- the ImportResult, warning and error messages are added to this object, also itsImportResult.getUpdatedObjects()
andImportResult.getInsertedObjects()
is setisClientImport
- is true if the import is for a client, in that case theReferenceDataStore
data is not setmodule
- is set if the import is for a module, null is allowed
-
-