Class ProcessModelXMLExport

java.lang.Object
de.aristaflow.adept2.model.processmodel.xml.ProcessModelXMLExport

public class ProcessModelXMLExport extends Object
The XMLExport class allows to export any template or instance data to an xml file, an DOM document, a string or a byte array (containing XML code). TODO Instance: export *histories elements in the histories-namespace?
Author:
Kevin Goeser
  • Constructor Details

    • ProcessModelXMLExport

      public ProcessModelXMLExport()
  • Method Details

    • writeTemplateToFile

      public void writeTemplateToFile(Template template, File file) throws IOException, XMLFormatException
      Writes the given template to the given file.
      Parameters:
      file - The target file,
      template - The source template,
      Throws:
      IOException - Thrown if writing the XML to the file fails, e.g. if the provided file is read-only.
      XMLFormatException - Thrown if the validation of the document fails
    • writeTemplateToFile

      public void writeTemplateToFile(Template template, File file, boolean intend) throws IOException, XMLFormatException
      Writes the given template to the given file.
      Parameters:
      file - The target file,
      template - The source template,
      intend - Whether to intend child nodes and text content. Use with care! Text content may contain whitespace and linebreaks afterwards!
      Throws:
      IOException - Thrown if writing the XML to the file fails, e.g. if the provided file is read-only.
      XMLFormatException - Thrown if the validation of the document fails
    • writeTemplateAndStatusToFile

      public void writeTemplateAndStatusToFile(Template template, TemplateStatus templateStatus, File file) throws IOException, XMLFormatException
      Writes the given template including its status to the given file.
      Parameters:
      file - The target file,
      template - The source template,
      templateStatus - The status of the template.
      Throws:
      IOException - Thrown if writing the XML to the file fails, e.g. if the provided file is read-only.
      XMLFormatException - Thrown if the validation of the document fails
    • writeTemplateAndStatusToFile

      public void writeTemplateAndStatusToFile(Template template, TemplateStatus templateStatus, File file, boolean intend) throws IOException, XMLFormatException
      Writes the given template including its status to the given file.
      Parameters:
      file - The target file,
      template - The source template,
      templateStatus - The status of the template.
      intend - Whether to intend child nodes and text content. Use with care! Text content may contain whitespace and linebreaks afterwards!
      Throws:
      IOException - Thrown if writing the XML to the file fails, e.g. if the provided file is read-only.
      XMLFormatException - Thrown if the validation of the document fails
    • writeInstanceToFile

      public void writeInstanceToFile(Instance instance, File file) throws IOException, XMLFormatException
      Writes the given instance to the given file.
      Parameters:
      file - The target file,
      instance - The source instance,
      Throws:
      IOException - Thrown if writing the XML to the file fails, e.g. if the provided file is read-only.
      XMLFormatException - Thrown if the validation of the document fails
    • writeInstanceToFile

      public void writeInstanceToFile(Instance instance, File file, boolean intend) throws IOException, XMLFormatException
      Writes the given instance to the given file.
      Parameters:
      file - The target file,
      instance - The source instance,
      intend - Whether to intend child nodes and text content. Use with care! Text content may contain whitespace and linebreaks afterwards!
      Throws:
      IOException - Thrown if writing the XML to the file fails, e.g. if the provided file is read-only.
      XMLFormatException - Thrown if the validation of the document fails
    • writeInstanceAndStatusToFile

      public void writeInstanceAndStatusToFile(Instance instance, InstanceStatus instanceStatus, File file, boolean storeStructure) throws IOException, XMLFormatException
      Writes the given instance including its status to the given file.
      Parameters:
      instance - The source instance,
      instanceStatus - The status object of the instance
      file - The target file,
      storeStructure - If set to true, the structure is stored to the file, else, only an ID reference will be stored.
      Throws:
      IOException - Thrown if writing the XML to the file fails, e.g. if the provided file is read-only.
      XMLFormatException - Thrown if the validation of the document fails
    • writeInstanceAndStatusToFile

      public void writeInstanceAndStatusToFile(Instance instance, InstanceStatus instanceStatus, File file, boolean storeStructure, boolean intend) throws IOException, XMLFormatException
      Writes the given instance including its status to the given file.
      Parameters:
      instance - The source instance,
      instanceStatus - The status object of the instance
      file - The target file,
      storeStructure - If set to true, the structure is stored to the file, else, only an ID reference will be stored.
      intend - Whether to intend child nodes and text content. Use with care! Text content may contain whitespace and linebreaks afterwards!
      Throws:
      IOException - Thrown if writing the XML to the file fails, e.g. if the provided file is read-only.
      XMLFormatException - Thrown if the validation of the document fails
    • writeExecutableInstanceAndStatusToFile

      public void writeExecutableInstanceAndStatusToFile(ExecutableInstance instance, InstanceStatus instanceStatus, File file) throws IOException, XMLFormatException
      Writes the given instance including its status to the given file. The template will be written in case the designated instance is modified.
      Parameters:
      instance - The source instance,
      instanceStatus - The status object of the instance
      file - The target file,
      Throws:
      IOException - Thrown if writing the XML to the file fails, e.g. if the provided file is read-only.
      XMLFormatException - Thrown if the validation of the document fails
      See Also:
    • writeExecutableInstanceAndStatusToFile

      public void writeExecutableInstanceAndStatusToFile(ExecutableInstance instance, InstanceStatus instanceStatus, File file, boolean intend) throws IOException, XMLFormatException
      Writes the given instance including its status to the given file. The template will be written in case the designated instance is modified.
      Parameters:
      instance - The source instance,
      instanceStatus - The status object of the instance
      file - The target file,
      intend - Whether to intend child nodes and text content. Use with care! Text content may contain whitespace and linebreaks afterwards!
      Throws:
      IOException - Thrown if writing the XML to the file fails, e.g. if the provided file is read-only.
      XMLFormatException - Thrown if the validation of the document fails
      See Also:
    • writeExecutableInstanceAndStatusToFile

      public void writeExecutableInstanceAndStatusToFile(ExecutableInstance instance, InstanceStatus instanceStatus, File file, Template structure) throws IOException, XMLFormatException
      Writes the given instance including its status to the given file.
      Parameters:
      instance - The source instance,
      instanceStatus - The status object of the instance
      file - The target file,
      structure - If not null, the designated structure (template or instance delta layer) of the instance, will be stored inline.
      Throws:
      IOException - Thrown if writing the XML to the file fails, e.g. if the provided file is read-only.
      XMLFormatException - Thrown if the validation of the document fails
    • writeExecutableInstanceAndStatusToFile

      public void writeExecutableInstanceAndStatusToFile(ExecutableInstance instance, InstanceStatus instanceStatus, File file, Template structure, boolean intend) throws IOException, XMLFormatException
      Writes the given instance including its status to the given file.
      Parameters:
      instance - The source instance,
      instanceStatus - The status object of the instance
      file - The target file,
      structure - If not null, the designated structure (template or instance delta layer) of the instance, will be stored inline.
      intend - Whether to intend child nodes and text content. Use with care! Text content may contain whitespace and linebreaks afterwards!
      Throws:
      IOException - Thrown if writing the XML to the file fails, e.g. if the provided file is read-only.
      XMLFormatException - Thrown if the validation of the document fails
    • getXMLStringForTemplate

      public String getXMLStringForTemplate(Template template) throws XMLFormatException, IOException
      Returns the xml code of a given template as string.
      Parameters:
      template - The template which should be transformed.
      Returns:
      The xml code of the given process as string.
      Throws:
      XMLFormatException - Thrown if the validation of the document fails
      IOException - Thrown if an unrecoverable error occurs during the course of the transformation
    • getXMLStringForTemplate

      public String getXMLStringForTemplate(Template template, boolean intend) throws XMLFormatException, IOException
      Returns the xml code of a given template as string.
      Parameters:
      template - The template which should be transformed.
      intend - Whether to intend child nodes and text content. Use with care! Text content may contain whitespace and linebreaks afterwards!
      Returns:
      The xml code of the given process as string.
      Throws:
      XMLFormatException - Thrown if the validation of the document fails
      IOException - Thrown if an unrecoverable error occurs during the course of the transformation
    • getXMLStringForInstance

      public String getXMLStringForInstance(Instance instance) throws XMLFormatException, IOException
      Returns the xml code of a given instance as string.
      Parameters:
      instance - The instance which should be transformed.
      Returns:
      The xml code of the given process as string.
      Throws:
      XMLFormatException - Thrown if the validation of the document fails
      IOException - Thrown if an unrecoverable error occurs during the course of the transformation
    • getXMLStringForInstance

      public String getXMLStringForInstance(Instance instance, boolean intend) throws XMLFormatException, IOException
      Returns the xml code of a given instance as string.
      Parameters:
      instance - The instance which should be transformed.
      intend - Whether to intend child nodes and text content. Use with care! Text content may contain whitespace and linebreaks afterwards!
      Returns:
      The xml code of the given process as string.
      Throws:
      XMLFormatException - Thrown if the validation of the document fails
      IOException - Thrown if an unrecoverable error occurs during the course of the transformation
    • getInputStreamForTemplate

      public InputStream getInputStreamForTemplate(Template template) throws XMLFormatException, IOException
      Returns The corresponding stream for a given template
      Parameters:
      template - The source template
      Returns:
      An input stream for the given template. The caller is responsible for closing.
      Throws:
      XMLFormatException - Thrown if the validation of the document fails
      IOException - Thrown if an unrecoverable error occurs during the course of the transformation
    • getInputStreamForTemplate

      public InputStream getInputStreamForTemplate(Template template, boolean intend) throws XMLFormatException, IOException
      Returns The corresponding stream for a given template
      Parameters:
      template - The source template
      intend - Whether to intend child nodes and text content. Use with care! Text content may contain whitespace and linebreaks afterwards!
      Returns:
      An input stream for the given template. The caller is responsible for closing.
      Throws:
      XMLFormatException - Thrown if the validation of the document fails
      IOException - Thrown if an unrecoverable error occurs during the course of the transformation
    • getInputStreamForTemplateAndStatus

      public InputStream getInputStreamForTemplateAndStatus(Template template, TemplateStatus templateStatus) throws XMLFormatException, IOException
      Returns The corresponding stream for a given template and a given template status.
      Parameters:
      template - The source template
      templateStatus - The template status
      Returns:
      An input stream for the given template. The caller is responsible for closing.
      Throws:
      XMLFormatException - Thrown if the validation of the document fails
      IOException - Thrown if an unrecoverable error occurs during the course of the transformation
    • getInputStreamForTemplateAndStatus

      public InputStream getInputStreamForTemplateAndStatus(Template template, TemplateStatus templateStatus, boolean intend) throws XMLFormatException, IOException
      Returns The corresponding stream for a given template and a given template status.
      Parameters:
      template - The source template
      templateStatus - The template status
      intend - Whether to intend child nodes and text content. Use with care! Text content may contain whitespace and linebreaks afterwards!
      Returns:
      An input stream for the given template. The caller is responsible for closing.
      Throws:
      XMLFormatException - Thrown if the validation of the document fails
      IOException - Thrown if an unrecoverable error occurs during the course of the transformation
    • getDocumentForTemplateAndStatus

      public Document getDocumentForTemplateAndStatus(Template template, TemplateStatus templateStatus) throws XMLFormatException
      Returns The corresponding document for a given template and a given template status.
      Parameters:
      template - The source template
      templateStatus - The template status
      Returns:
      A document for the given template
      Throws:
      XMLFormatException - Thrown if the validation of the document fails
    • getInputStreamForInstance

      public InputStream getInputStreamForInstance(Instance instance) throws XMLFormatException, IOException
      Returns The corresponding stream for a given instance
      Parameters:
      instance - The source instance
      Returns:
      An input stream for the given instance. The caller is responsible for closing.
      Throws:
      XMLFormatException - Thrown if the validation of the document fails
      IOException - Thrown if an unrecoverable error occurs during the course of the transformation
    • getInputStreamForInstance

      public InputStream getInputStreamForInstance(Instance instance, boolean intend) throws XMLFormatException, IOException
      Returns The corresponding stream for a given instance
      Parameters:
      instance - The source instance
      intend - Whether to intend child nodes and text content. Use with care! Text content may contain whitespace and linebreaks afterwards!
      Returns:
      An input stream for the given instance. The caller is responsible for closing.
      Throws:
      XMLFormatException - Thrown if the validation of the document fails
      IOException - Thrown if an unrecoverable error occurs during the course of the transformation
    • getDocumentForExecutableInstanceAndStatus

      public Document getDocumentForExecutableInstanceAndStatus(ExecutableInstance instance, InstanceStatus instanceStatus, boolean storeStructure)
      Writes the given instance including its status to the given file.
      Parameters:
      instance - The source instance,
      instanceStatus - The status object of the instance
      storeStructure - If set to true, the structure is stored to the file, else, only an ID reference will be stored.
      Returns:
      The input stream
    • getDocumentForTemplate

      public Document getDocumentForTemplate(Template template) throws XMLFormatException
      Creates a DOM document from the template.
      Parameters:
      template - The source template
      Returns:
      A DOM document
      Throws:
      XMLFormatException - Thrown if the validation of the document fails
    • getDocumentForInstance

      public Document getDocumentForInstance(Instance instance) throws XMLFormatException
      Creates a DOM document from the instance.
      Parameters:
      instance - The source instance
      Returns:
      A DOM document
      Throws:
      XMLFormatException - Thrown if the validation of the document fails
    • getDocumentForEBP

      public Document getDocumentForEBP(ExecutableBusinessProcess ebp) throws XMLFormatException
      Parameters:
      ebp -
      Returns:
      A DOM/XML document for the given executable business process.
      Throws:
      XMLFormatException - Thrown if the validation of the document fails
    • getDocumentForParameter

      public Document getDocumentForParameter(ProcessModelParameter parameter, boolean isInputParameter)
      TODO set namespace, schema location, check schema?
      Parameters:
      parameter - The source parameter
      isInputParameter - If true, an input parameter will be created, else an output parameter.
      Returns:
      A DOM/XML document for the given parameter.
    • getDocumentForParameterSet

      public Document getDocumentForParameterSet(Collection<ProcessModelParameter> parameter, boolean isInputParameter)
      TODO set namespace, schema location, check schema?
      Parameters:
      parameter - The source Parameterset.
      isInputParameter - If true, an input parameter set will be created, else an output parameter set.
      Returns:
      A DOM/XML document for the set of parameters.
    • getDocumentDataElementList

      public Document getDocumentDataElementList(Set<DataElement> dataElements)
      Exports a set of data elements to a document.
      Parameters:
      dataElements - The data elements to be exported.
      Returns:
      A document with a list of data element XML elements.
    • getDocumentForTemplateLocks

      public Document getDocumentForTemplateLocks(Map<UUID,ProcessModelXMLHelperTools.LockDescription> locks) throws XMLFormatException
      Generates and returns a Document for the given template locks
      Parameters:
      locks -
      Returns:
      the generated document
      Throws:
      XMLFormatException
    • writeTemplateLocksToFile

      public void writeTemplateLocksToFile(Map<UUID,ProcessModelXMLHelperTools.LockDescription> locks, File file) throws IOException, XMLFormatException
      Writes the given template locks to the specified file.
      Parameters:
      locks -
      file -
      Throws:
      XMLFormatException
      IOException
    • getDocumentForInstanceLocks

      public Document getDocumentForInstanceLocks(Map<UUID,ProcessModelXMLHelperTools.LockDescription> locks) throws XMLFormatException
      Generates and returns a Document for the given instance locks
      Parameters:
      locks -
      Returns:
      the generated document
      Throws:
      XMLFormatException
    • writeInstanceLocksToFile

      public void writeInstanceLocksToFile(Map<UUID,ProcessModelXMLHelperTools.LockDescription> locks, File file) throws IOException, XMLFormatException
      Writes the given instance locks to the specified file.
      Parameters:
      locks -
      file -
      Throws:
      XMLFormatException
      IOException
    • getDocumentForEmbeddedTemplateMapping

      public Document getDocumentForEmbeddedTemplateMapping(Map<UUID,UUID> mapping) throws XMLFormatException
      Generates and returns a Document representing the given embedded template id mapping
      Parameters:
      mapping - - the embedded IDs mapping to their parent IDs
      Returns:
      the generated document
      Throws:
      XMLFormatException
    • writeEmbeddedTemplateMappingToFile

      public void writeEmbeddedTemplateMappingToFile(Map<UUID,UUID> mapping, File file) throws IOException, XMLFormatException
      Writes the given embedded template id mapping to the specified file.
      Parameters:
      mapping - - the embedded IDs mapping to their parent ones
      file -
      Throws:
      XMLFormatException
      IOException
    • getDocumentForBaseTemplateMapping

      public Document getDocumentForBaseTemplateMapping(Map<UUID,UUID> mapping) throws XMLFormatException
      Generates and returns a Document representing the given base template id mapping
      Parameters:
      mapping - - the template IDs mapping to their base template IDs
      Returns:
      the generated document
      Throws:
      XMLFormatException
    • writeBaseTemplateMappingToFile

      public void writeBaseTemplateMappingToFile(Map<UUID,UUID> mapping, File file) throws IOException, XMLFormatException
      Writes the given base template id mapping to the specified file.
      Parameters:
      mapping - - the template IDs mapping to their base template IDs
      file -
      Throws:
      XMLFormatException
      IOException
    • getDocumentForAdhocTemplateMapping

      public Document getDocumentForAdhocTemplateMapping(Map<UUID,UUID> mapping) throws XMLFormatException
      Generates and returns a Document representing the given adhoc template id mapping
      Parameters:
      mapping - - the adhoc template IDs mapping to their instance IDs
      Returns:
      the generated document
      Throws:
      XMLFormatException
    • writeAdhocTemplateMappingToFile

      public void writeAdhocTemplateMappingToFile(Map<UUID,UUID> mapping, File file) throws IOException, XMLFormatException
      Writes the given adhoc template id mapping to the specified file.
      Parameters:
      mapping - - the adhoc template IDs mapping to their instance IDs
      file -
      Throws:
      XMLFormatException
      IOException
    • getDocumentForProcessTypes

      public Document getDocumentForProcessTypes(Set<ProcessModelXMLHelperTools.SerialisableProcessType> items) throws XMLFormatException
      Generates and returns a Document representing the given ProcessTypes
      Parameters:
      items - The process types
      Returns:
      the generated document
      Throws:
      XMLFormatException
    • writeProcessTypesToFile

      public void writeProcessTypesToFile(Set<ProcessModelXMLHelperTools.SerialisableProcessType> items, File file) throws IOException, XMLFormatException
      Writes the given adhoc template id mapping to the specified file.
      Parameters:
      items - The process types to be stored
      file -
      Throws:
      XMLFormatException
      IOException
    • getDocumentForTemplateInformations

      public Document getDocumentForTemplateInformations(Map<UUID,ProcessModelXMLHelperTools.TemplateInformation> items) throws XMLFormatException
      Generates and returns a Document representing the given TemplateInformations.
      Parameters:
      items - maps from ID of template to its information
      Returns:
      the generated document
      Throws:
      XMLFormatException
    • writeTemplateInformationsToFile

      public void writeTemplateInformationsToFile(Map<UUID,ProcessModelXMLHelperTools.TemplateInformation> items, File file) throws IOException, XMLFormatException
      Writes the given template informations to the specified file.
      Parameters:
      items - maps from if of template to its template information.
      file -
      Throws:
      XMLFormatException
      IOException