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 Summary
Constructors Constructor Description ProcessModelXMLExport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DocumentgetDocumentDataElementList(Set<DataElement> dataElements)Exports a set of data elements to a document.DocumentgetDocumentForAdhocTemplateMapping(Map<UUID,UUID> mapping)Generates and returns aDocumentrepresenting the given adhoc template id mappingDocumentgetDocumentForBaseTemplateMapping(Map<UUID,UUID> mapping)Generates and returns aDocumentrepresenting the given base template id mappingDocumentgetDocumentForEBP(ExecutableBusinessProcess ebp)DocumentgetDocumentForEmbeddedTemplateMapping(Map<UUID,UUID> mapping)Generates and returns aDocumentrepresenting the given embedded template id mappingDocumentgetDocumentForExecutableInstanceAndStatus(ExecutableInstance instance, InstanceStatus instanceStatus, boolean storeStructure)Writes the given instance including its status to the given file.DocumentgetDocumentForInstance(Instance instance)Creates a DOM document from the instance.DocumentgetDocumentForInstanceLocks(Map<UUID,ProcessModelXMLHelperTools.LockDescription> locks)Generates and returns aDocumentfor the given instance locksDocumentgetDocumentForParameter(ProcessModelParameter parameter, boolean isInputParameter)TODO set namespace, schema location, check schema?DocumentgetDocumentForParameterSet(Collection<ProcessModelParameter> parameter, boolean isInputParameter)TODO set namespace, schema location, check schema?DocumentgetDocumentForProcessTypes(Set<ProcessModelXMLHelperTools.SerialisableProcessType> items)Generates and returns aDocumentrepresenting the given ProcessTypesDocumentgetDocumentForTemplate(Template template)Creates a DOM document from the template.DocumentgetDocumentForTemplateAndStatus(Template template, TemplateStatus templateStatus)Returns The corresponding document for a given template and a given template status.DocumentgetDocumentForTemplateInformations(Map<UUID,ProcessModelXMLHelperTools.TemplateInformation> items)Generates and returns aDocumentrepresenting the given TemplateInformations.DocumentgetDocumentForTemplateLocks(Map<UUID,ProcessModelXMLHelperTools.LockDescription> locks)Generates and returns aDocumentfor the given template locksInputStreamgetInputStreamForInstance(Instance instance)Returns The corresponding stream for a given instanceInputStreamgetInputStreamForInstance(Instance instance, boolean intend)Returns The corresponding stream for a given instanceInputStreamgetInputStreamForTemplate(Template template)Returns The corresponding stream for a given templateInputStreamgetInputStreamForTemplate(Template template, boolean intend)Returns The corresponding stream for a given templateInputStreamgetInputStreamForTemplateAndStatus(Template template, TemplateStatus templateStatus)Returns The corresponding stream for a given template and a given template status.InputStreamgetInputStreamForTemplateAndStatus(Template template, TemplateStatus templateStatus, boolean intend)Returns The corresponding stream for a given template and a given template status.StringgetXMLStringForInstance(Instance instance)Returns the xml code of a given instance as string.StringgetXMLStringForInstance(Instance instance, boolean intend)Returns the xml code of a given instance as string.StringgetXMLStringForTemplate(Template template)Returns the xml code of a given template as string.StringgetXMLStringForTemplate(Template template, boolean intend)Returns the xml code of a given template as string.voidwriteAdhocTemplateMappingToFile(Map<UUID,UUID> mapping, File file)Writes the given adhoc template id mapping to the specified file.voidwriteBaseTemplateMappingToFile(Map<UUID,UUID> mapping, File file)Writes the given base template id mapping to the specified file.voidwriteEmbeddedTemplateMappingToFile(Map<UUID,UUID> mapping, File file)Writes the given embedded template id mapping to the specified file.voidwriteExecutableInstanceAndStatusToFile(ExecutableInstance instance, InstanceStatus instanceStatus, File file)Writes the given instance including its status to the given file.voidwriteExecutableInstanceAndStatusToFile(ExecutableInstance instance, InstanceStatus instanceStatus, File file, boolean intend)Writes the given instance including its status to the given file.voidwriteExecutableInstanceAndStatusToFile(ExecutableInstance instance, InstanceStatus instanceStatus, File file, Template structure)Writes the given instance including its status to the given file.voidwriteExecutableInstanceAndStatusToFile(ExecutableInstance instance, InstanceStatus instanceStatus, File file, Template structure, boolean intend)Writes the given instance including its status to the given file.voidwriteInstanceAndStatusToFile(Instance instance, InstanceStatus instanceStatus, File file, boolean storeStructure)Writes the given instance including its status to the given file.voidwriteInstanceAndStatusToFile(Instance instance, InstanceStatus instanceStatus, File file, boolean storeStructure, boolean intend)Writes the given instance including its status to the given file.voidwriteInstanceLocksToFile(Map<UUID,ProcessModelXMLHelperTools.LockDescription> locks, File file)Writes the given instance locks to the specified file.voidwriteInstanceToFile(Instance instance, File file)Writes the given instance to the given file.voidwriteInstanceToFile(Instance instance, File file, boolean intend)Writes the given instance to the given file.voidwriteProcessTypesToFile(Set<ProcessModelXMLHelperTools.SerialisableProcessType> items, File file)Writes the given adhoc template id mapping to the specified file.voidwriteTemplateAndStatusToFile(Template template, TemplateStatus templateStatus, File file)Writes the given template including its status to the given file.voidwriteTemplateAndStatusToFile(Template template, TemplateStatus templateStatus, File file, boolean intend)Writes the given template including its status to the given file.voidwriteTemplateInformationsToFile(Map<UUID,ProcessModelXMLHelperTools.TemplateInformation> items, File file)Writes the given template informations to the specified file.voidwriteTemplateLocksToFile(Map<UUID,ProcessModelXMLHelperTools.LockDescription> locks, File file)Writes the given template locks to the specified file.voidwriteTemplateToFile(Template template, File file)Writes the given template to the given file.voidwriteTemplateToFile(Template template, File file, boolean intend)Writes the given template to the given file.
-
-
-
Method Detail
-
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 instancefile- 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 instancefile- 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 instancefile- 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(ExecutableInstance, InstanceStatus, File, Template)
-
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 instancefile- 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(ExecutableInstance, InstanceStatus, File, Template)
-
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 instancefile- 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 instancefile- 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 failsIOException- 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 failsIOException- 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 failsIOException- 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 failsIOException- 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 failsIOException- 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 templateintend- 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 failsIOException- 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 templatetemplateStatus- 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 failsIOException- 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 templatetemplateStatus- The template statusintend- 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 failsIOException- 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 templatetemplateStatus- 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 failsIOException- 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 instanceintend- 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 failsIOException- 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 instancestoreStructure- 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 parameterisInputParameter- 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 aDocumentfor 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:
XMLFormatExceptionIOException
-
getDocumentForInstanceLocks
public Document getDocumentForInstanceLocks(Map<UUID,ProcessModelXMLHelperTools.LockDescription> locks) throws XMLFormatException
Generates and returns aDocumentfor 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:
XMLFormatExceptionIOException
-
getDocumentForEmbeddedTemplateMapping
public Document getDocumentForEmbeddedTemplateMapping(Map<UUID,UUID> mapping) throws XMLFormatException
Generates and returns aDocumentrepresenting 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 onesfile-- Throws:
XMLFormatExceptionIOException
-
getDocumentForBaseTemplateMapping
public Document getDocumentForBaseTemplateMapping(Map<UUID,UUID> mapping) throws XMLFormatException
Generates and returns aDocumentrepresenting 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 IDsfile-- Throws:
XMLFormatExceptionIOException
-
getDocumentForAdhocTemplateMapping
public Document getDocumentForAdhocTemplateMapping(Map<UUID,UUID> mapping) throws XMLFormatException
Generates and returns aDocumentrepresenting 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 IDsfile-- Throws:
XMLFormatExceptionIOException
-
getDocumentForProcessTypes
public Document getDocumentForProcessTypes(Set<ProcessModelXMLHelperTools.SerialisableProcessType> items) throws XMLFormatException
Generates and returns aDocumentrepresenting 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 storedfile-- Throws:
XMLFormatExceptionIOException
-
getDocumentForTemplateInformations
public Document getDocumentForTemplateInformations(Map<UUID,ProcessModelXMLHelperTools.TemplateInformation> items) throws XMLFormatException
Generates and returns aDocumentrepresenting 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:
XMLFormatExceptionIOException
-
-