Package org.openbravo.dal.xml
Class XMLEntityConverter
- java.lang.Object
-
- org.openbravo.dal.xml.BaseXMLEntityConverter
-
- org.openbravo.dal.xml.XMLEntityConverter
-
- All Implemented Interfaces:
OBNotSingleton
,OBProvidable
public class XMLEntityConverter extends BaseXMLEntityConverter
Converts a XML string to an objectgraph with objects using Dom4j. This XMLEntityConverter can be used for smaller xml strings (less than 100mb). This XMLEntityConverter can handle OneToMany relations, this in contrast to theStaxXMLEntityConverter
. 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 XMLEntityConverter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static XMLEntityConverter
newInstance()
List<BaseOBObject>
process(String xml)
The main entry point.List<BaseOBObject>
process(org.dom4j.Document doc)
List<BaseOBObject>
process(org.dom4j.Document doc, boolean filterOrganizations)
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 XMLEntityConverter newInstance()
-
process
public List<BaseOBObject> process(String xml)
The main entry point. This method creates a Dom4j Document and then callsprocess(Document)
.- Parameters:
xml
- the xml string- 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(org.dom4j.Document doc, boolean filterOrganizations)
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:
doc
- the dom4j Document to process- 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(org.dom4j.Document doc)
-
-