Class 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 the StaxXMLEntityConverter. 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 the EntityResolver.

    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 Detail

      • XMLEntityConverter

        public XMLEntityConverter()
    • Method Detail

      • process

        public List<BaseOBObject> process​(String xml)
        The main entry point. This method creates a Dom4j Document and then calls process(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 the EntityResolver.

        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 the BaseXMLEntityConverter.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