Package org.openbravo.dal.xml
Class StaxXMLEntityConverter
- java.lang.Object
-
- org.openbravo.dal.xml.BaseXMLEntityConverter
-
- org.openbravo.dal.xml.StaxXMLEntityConverter
-
- All Implemented Interfaces:
OBNotSingleton
,OBProvidable
public class StaxXMLEntityConverter extends BaseXMLEntityConverter implements OBNotSingleton
Converts a XML string to an objectgraph with objects using a Stax approach. It can handle very large XML Documents (> 500mb). It can not handle OneToMany properties, for this theXMLEntityConverter
should be used. The StaxXMLEntityConverter is mainly used for client import and export which has larger datasets. During the XML parse phase this converter will match XML tags with new or existing (in the database) business objects. The matching logic is implemented in theEntityResolver
.The XMLEntityConverter keeps track of which objects are new, which exist but do not need to be updated or which objects exist but need to be updated.
This converter does not update the database directly. However, it changes the properties of existing objects. This means that a commit after calling the process method on the converter can result in database updates by Hibernate.
- Author:
- mtaal
- See Also:
Entity
-
-
Constructor Summary
Constructors Constructor Description StaxXMLEntityConverter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StaxXMLEntityConverter
newInstance()
List<BaseOBObject>
process(Reader reader)
The main entry point.List<BaseOBObject>
process(XMLStreamReader xmlReader)
The main entry point.-
Methods inherited from class org.openbravo.dal.xml.BaseXMLEntityConverter
addToInsertOrUpdateLists, checkClientOrganizationSet, checkDanglingObjects, clear, error, getClient, getEntityResolver, getErrorMessages, getImportProcessor, getLogMessages, getOrganization, getToInsert, getToUpdate, getWarningMessages, hasErrorOccured, isOptionClientImport, isOptionImportAuditInfo, log, repairReferences, replaceByUniqueObject, replaceValue, resolve, resolve, setClient, setEntityResolver, setImportProcessor, setOptionClientImport, setOptionImportAuditInfo, setOrganization, warn, warnDifferentClientOrg
-
-
-
-
Method Detail
-
newInstance
public static StaxXMLEntityConverter newInstance()
-
process
public List<BaseOBObject> process(Reader reader)
The main entry point. This method creates a XMLStreamReader and then calls process(XMLStreamReader).- Parameters:
reader
- the xml- Returns:
- the list of BaseOBObject present in the root of the xml. This list contains the to-be-updated, to-be-inserted as well as the unchanged business objects
-
process
public List<BaseOBObject> process(XMLStreamReader xmlReader)
The main entry point. This method walks through the elements in the root and parses them. The children of a business object (in the xml) are also parsed. Referenced objects are resolved through theEntityResolver
.After a call to this method the to-be-inserted objects can be retrieved through the
BaseXMLEntityConverter.getToInsert()
method and the to-be-updated objects through theBaseXMLEntityConverter.getToUpdate()
method.- Parameters:
xmlReader
- the xml to parse- Returns:
- the list of BaseOBObject present in the root of the xml. This list contains the to-be-updated, to-be-inserted as well as the unchanged business objects
-
-