Class EntityXMLConverter

  • All Implemented Interfaces:
    OBNotSingleton, OBProvidable

    public class EntityXMLConverter
    extends Object
    implements OBNotSingleton
    Converts one or more business objects to a XML presentation. There are several options which control the behavior. One option is to include referenced objects (or not). For example Currency references Country, if a Currency instance is exported should then also the Country instance be exported. Another option controls if the children of a business object (e.g. the order lines of an order) are exported within the part as a subnode in the xml result. Or that children are not exported or exported in the root of the xml document.
    Author:
    mtaal
    • Constructor Detail

      • EntityXMLConverter

        public EntityXMLConverter()
    • Method Detail

      • clear

        public void clear()
        Clear internal data structures, after this call this converter can be used for a new set of objects which need to be exported to a xml representation.
      • toXML

        public String toXML​(BaseOBObject obObject)
        Converts one business object to xml and returns the resulting xml string.
        Parameters:
        obObject - the object to convert to xml
        Returns:
        the xml representation of obObject
      • toXML

        public String toXML​(Collection<BaseOBObject> bobs)
        Converts a collection of business objects to xml.
        Parameters:
        bobs - the collection to convert
        Returns:
        the resulting xml string
      • process

        public void process​(BaseOBObject bob)
        Processes one business object and outputs it to the writer (setOutput(Writer)).
        Parameters:
        bob - the business object to convert to xml (dom4j)
      • process

        public void process​(Collection<BaseOBObject> bobs)
        Processes a collection of business objects and outputs them to the writer ( setOutput(Writer)).
        Parameters:
        bobs - the business objects to convert to xml (dom4j)
      • export

        protected void export()
      • addToExportList

        protected void addToExportList​(BaseOBObject bob)
      • isOptionIncludeReferenced

        public boolean isOptionIncludeReferenced()
        Controls if referenced objects (through many-to-one associations) should also be exported (in the root of the xml).
        Returns:
        true the referenced objects are exported, false (the default) referenced objects are not exported
      • setOptionIncludeReferenced

        public void setOptionIncludeReferenced​(boolean optionIncludeReferenced)
        Controls if referenced objects (through many-to-one associations) should also be exported (in the root of the xml).
        Parameters:
        optionIncludeReferenced - set to true the referenced objects are exported, set to false (the default) referenced objects are not exported
      • setIncludedComputedColumns

        public void setIncludedComputedColumns​(boolean includedComputedColumns)
        Controls if computed columns should also be exported.
        Parameters:
        includedComputedColumns - set to true the computed columns are exported, set to false (the default) computed columns are not exported.
      • isOptionIncludeChildren

        public boolean isOptionIncludeChildren()
        Controls if children (the one-to-many associations) are exported. If true then the children can be exported embedded in the parent or in the root of the xml. This is controlled by the isOptionEmbedChildren() option.
        Returns:
        true children are exported as well, false (the default) children are not exported
      • setOptionIncludeChildren

        public void setOptionIncludeChildren​(boolean optionIncludeChildren)
        Controls if children (the one-to-many associations) are exported. If true then the children can be exported embedded in the parent or in the root of the xml. This is controlled by the isOptionEmbedChildren() option.
        Parameters:
        optionIncludeChildren - set to true children are exported as well, set to false (the default) children are not exported
      • isOptionEmbedChildren

        public boolean isOptionEmbedChildren()
        This option controls if children are exported within the parent or in the root of the xml. The default is embedded (default value is true).
        Returns:
        true (default) children are embedded in the parent, false children are exported in the root of the xml
      • setOptionEmbedChildren

        public void setOptionEmbedChildren​(boolean optionEmbedChildren)
        This option controls if children are exported within the parent or in the root of the xml. The default is embedded (default value is true).
      • isOptionExportClientOrganizationReferences

        public boolean isOptionExportClientOrganizationReferences()
        Controls if the client and organization properties are also exported. The default is false. If this is set to true then the import program should take into account that the client/organization are present in the import xml.
        Returns:
        if true then the client/organization properties are exported, if false then not
      • setOptionExportClientOrganizationReferences

        public void setOptionExportClientOrganizationReferences​(boolean optionExportClientOrganizationReferences)
        Controls if the client and organization properties are also exported. The default is false. If this is set to true then the import program should take into account that the client/organization are present in the import xml.
        Parameters:
        optionExportClientOrganizationReferences - if set to true then the client/organization properties are exported, if false then not
      • isOptionExportTransientInfo

        public boolean isOptionExportTransientInfo()
        Retrieves whether the transient information is exported or not.
        Returns:
        true if the transient information is exported, false otherwise.
      • setOptionExportTransientInfo

        public void setOptionExportTransientInfo​(boolean optionExportTransientInfo)
        Controls if transient information should also be exported.
        Parameters:
        optionExportTransientInfo - set to true (the default) the transient information is exported, set to false the transient information is not exported.
      • setIncludedProperties

        public void setIncludedProperties​(List<String> includedProperties)
        Parameters:
        includedProperties - set to the Names of the properties to be exported
      • setPropertiesToBeFetched

        public void setPropertiesToBeFetched​(Map<String,​List<String>> propertiesToBeFetched)
        Parameters:
        propertiesToBeFetched - set to the list of the non child properties to be exported for each entity
      • setChildPropertiesToBeFetched

        public void setChildPropertiesToBeFetched​(Map<String,​List<String>> childPropertiesToBeFetched)
        Parameters:
        childPropertiesToBeFetched - set to the list of the non child properties to be exported for each entity
      • getClient

        public Client getClient()
        Returns:
        The client of the references that will be exported.
      • setClient

        public void setClient​(Client client)
        Sets the client of the references that will be exported.
        Parameters:
        client - A Client object which represents the client of the references that will be exported.
      • setReadableClients

        public void setReadableClients​(String[] readableClients)
        Sets the readable clients. The child properties will be exported if they are defined for a client whose ID is included in the array provided to this method.
        Parameters:
        readableClients - An array with the IDs of the readable clients.
      • isOptionExportAuditInfo

        public boolean isOptionExportAuditInfo()
        Retrieves whether the audit information is exported or not.
        Returns:
        true if the audit information is exported, false otherwise.
      • setOptionExportAuditInfo

        public void setOptionExportAuditInfo​(boolean optionExportAuditInfo)
        Controls if the audit information should be exported or not.
        Parameters:
        optionExportAuditInfo - set to true (the default) the audit information is exported, set to false the audit information is not exported.
      • isOptionMinimizeXMLSize

        public boolean isOptionMinimizeXMLSize()
        Retrieves whether output size is minimized.
        Returns:
        true if the output size is minimized, false otherwise.
      • setOptionMinimizeXMLSize

        public void setOptionMinimizeXMLSize​(boolean optionMinimizeXMLSize)
        Controls if the output size should be minimized or not. Note that if set to true the output will probably be less readable.
        Parameters:
        optionMinimizeXMLSize - set to true the output size will be minimized, set to false (the default) the output size will not be minimized.
      • getOutput

        public Writer getOutput()
        Returns:
        The output writer to be used by the converter.
      • setOutput

        public void setOutput​(Writer output)
        Sets the output writer to be used by the converter.
        Parameters:
        output - A Writer object that will be used to generate the result.
      • getDataSet

        public DataSet getDataSet()
        Returns:
        A DataSet with the information to be exported, or null if it has not been set.
      • setDataSet

        public void setDataSet​(DataSet dataSet)
        Used to set the output result on the basis of the DataSet passed as parameter.
        Parameters:
        dataSet - A DataSet with the information to be exported.
      • getDataScroller

        public org.hibernate.ScrollableResults getDataScroller()
        Returns:
        the ScrollableResults used to iterate along the data or null if it has not been set.
      • setDataScroller

        public void setDataScroller​(org.hibernate.ScrollableResults dataScroller)
        Sets the iterator (ScrollableResults) used to handle large data sets.
        Parameters:
        dataScroller - A ScrollableResults object used to iterate along the data.
      • setDefaultValuesData

        public void setDefaultValuesData​(boolean defaultValuesData)
        Controls whether the data set is denoted for default values import.
        Parameters:
        defaultValuesData - set to true the data set will be denoted as used for default values import, set to false (the default) the data set will not be denoted as used for default values import.