Class ProcessModelXMLImport
java.lang.Object
de.aristaflow.adept2.model.processmodel.xml.ProcessModelXMLImport
- All Implemented Interfaces:
ErrorHandler
Import templates and instances from XML. The XML constructs a process using
the ProcessModelFactory.
TODO Validate the Document in getTemplateFromDocument using the Validator.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionProcessModelXMLImport(ProcessModelFactory factory) Constructor, requiring the factory to use. -
Method Summary
Modifier and TypeMethodDescriptionvoiderror(SAXParseException spe) voidFetches the adhoc template ID mappings stored in the specified file.Fetches the base template ID mappings stored in the specified file.getEBPForDocument(Document document) Retrieves the corresponding ExecutableBusinessProcessFetches the embedded template ID mappings stored in the specified file.getExecutableInstanceFromDocument(ExecutionFactory executionFactory, Document document, Template template) Creates an instance using the given DOM document.getExecutableInstanceFromFile(ExecutionFactory executionFactory, File file) Reads a process instance from the given file and determines the file type.getExecutableInstanceFromFile(ExecutionFactory executionFactory, File file, Template template) Reads a process instance from the given file and determines the file type.getExecutableInstanceFromStream(ExecutionFactory executionFactory, InputStream stream, Template template) Reads a process instance from the designated input stream.getInstanceFromDocument(Document document, Template template) Creates an instance using the given DOM document.getInstanceFromFile(File file) Reads a process instance from the given file and determines the file type.getInstanceFromFile(File file, Template template) Reads a process instance from the given file and determines the file type.getInstanceFromStream(InputStream inputStream) Reads a process instance from an input stream.getInstanceLocksFromFile(File file) Fetches the current locks stored in the specified file.Reads a process instance status from the given.Reads a process instance status from the given.booleangetIsModifiedFromInstanceDocument(Document document) Returns the state of the isModified attribute in the given document of an instance.getParameterForDocument(Document document) Retrieves the Corresponding parametergetParameterSetForDocument(Document document) Retrieves the corresponding set of ParametergetProcessTypesFromFile(File file) Fetches the process types stored in the specified file.getTemplateFromDocument(Document document) Creates a template using the given DOM document.getTemplateFromFile(File file) Reads a process template from the given file and determines the file type.getTemplateFromStream(InputStream inputStream) Reads a process template from an input stream.getTemplateIDFromInstanceDocument(Document document) Returns the template ID stored in the given documentReads a process instance from the given file and determines the file type.Fetches the template informations stored in the specified file.getTemplateLocksFromFile(File file) Fetches the current locks stored in the specified file.getTemplateStatusFromDocument(Document document) Returns a template status object from the given template document.getTemplateStatusFromStream(InputStream inputStream) Reads the template status from the given template file.Reads the template status from the given template file.booleanGets whether the designated document contains an instance status with a migration (and execution) status date.static voidvalidateInstanceFormatVersion(Document instance) Validates the format version of the given instance document.static voidvalidateTemplateFormatVersion(Document template) Validates the format version of the given template document.voidwarning(SAXParseException spe)
-
Field Details
-
logger
The logger for XML imports. It is protected for extensibility.
-
-
Constructor Details
-
ProcessModelXMLImport
Constructor, requiring the factory to use.- Parameters:
factory- the factory, that shall be used by the importer to create the objects of the processModel
-
-
Method Details
-
getTemplateFromFile
public Template getTemplateFromFile(File file) throws VersionException, XMLFormatException, IOException Reads a process template from the given file and determines the file type. This will parse the file two times: First to recognise the file type, then to actually parse and validate the file.- Parameters:
file- The file which will be parsed- Returns:
- A Template
- Throws:
VersionException- if the format version of the template file is not or no longer supportedXMLFormatException- if the document is not well-formed the input file does not contain a valid templateFileNotFoundException- if the file does not exist or can't be openedIOException- if error occurs while reading from the file
-
getTemplateStatusFromTemplateFile
public TemplateStatus getTemplateStatusFromTemplateFile(File file) throws VersionException, XMLFormatException, IOException Reads the template status from the given template file. Note: the file must contain a template including a template status element.- Parameters:
file- The file which will be parsed- Returns:
- A TemplateStatus
- Throws:
VersionException- if the format version of the template file is not or no longer supportedXMLFormatException- if the document is not well-formed the input file does not contain a valid templateFileNotFoundException- if the file does not exist or can't be openedIOException- if error occurs while reading from the file
-
getInstanceFromFile
public Instance getInstanceFromFile(File file) throws VersionException, XMLFormatException, IOException Reads a process instance from the given file and determines the file type. This will parse the file two times: First to recognise the file type, then to actually parse and validate the file.- Parameters:
file- The file which will be parsed- Returns:
- An Instance
- Throws:
VersionException- if the format version of the instance file is not or no longer supportedXMLFormatException- if the document is not well-formed the input file does not contain a valid instanceFileNotFoundException- if the file does not exist or can't be openedIOException- if error occurs while reading from the file
-
getExecutableInstanceFromFile
public ExecutableInstance getExecutableInstanceFromFile(ExecutionFactory executionFactory, File file) throws VersionException, XMLFormatException, IOException Reads a process instance from the given file and determines the file type. This will parse the file two times: First to recognise the file type, then to actually parse and validate the file.- Parameters:
executionFactory- The execution factory needed for the creation of the executable instance.file- The file which will be parsed- Returns:
- An ExecutableInstance
- Throws:
VersionException- if the format version of the instance file is not or no longer supportedXMLFormatException- if the document is not well-formed the input file does not contain a valid instanceFileNotFoundException- if the file does not exist or can't be openedIOException- if error occurs while reading from the file
-
getInstanceFromFile
public Instance getInstanceFromFile(File file, Template template) throws VersionException, XMLFormatException, IOException Reads a process instance from the given file and determines the file type. This will parse the file two times: First to recognise the file type, then to actually parse and validate the file.- Parameters:
file- The file which will be parsedtemplate- The template object to use in the instance object.- Returns:
- An Instance
- Throws:
VersionException- if the format version of the instance file is not or no longer supportedXMLFormatException- if the document is not well-formed the input file does not contain a valid instanceFileNotFoundException- if the file does not exist or can't be openedIOException- if error occurs while reading from the file
-
getExecutableInstanceFromStream
public ExecutableInstance getExecutableInstanceFromStream(ExecutionFactory executionFactory, InputStream stream, Template template) throws VersionException, XMLFormatException, IOException Reads a process instance from the designated input stream.- Parameters:
executionFactory- The execution factory needed for the creation of the executable instance.stream- The stream from which to read the XML.template- The template object to use in the instance object.- Returns:
- An ExecutableInstance
- Throws:
VersionException- if the format version of the instance is not or no longer supported.XMLFormatException- if the document is not well-formed the input stream does not contain a valid instance.IOException- if error occurs while reading from the stream.
-
getExecutableInstanceFromFile
public ExecutableInstance getExecutableInstanceFromFile(ExecutionFactory executionFactory, File file, Template template) throws VersionException, XMLFormatException, IOException Reads a process instance from the given file and determines the file type. This will parse the file two times: First to recognise the file type, then to actually parse and validate the file.- Parameters:
executionFactory- The execution factory needed for the creation of the executable instance.file- The file which will be parsed.template- The template object to use in the instance object.- Returns:
- An ExecutableInstance
- Throws:
VersionException- if the format version of the instance file is not or no longer supportedXMLFormatException- if the document is not well-formed the input file does not contain a valid instanceFileNotFoundException- if the file does not exist or can't be openedIOException- if error occurs while reading from the file
-
getTemplateIDFromInstanceFile
public UUID getTemplateIDFromInstanceFile(File file) throws VersionException, XMLFormatException, IOException Reads a process instance from the given file and determines the file type. This will parse the file two times: First to recognise the file type, then to actually parse and validate the file.- Parameters:
file- The file which will be parsed- Returns:
- An Instance
- Throws:
VersionException- if the format version of the instance file is not or no longer supportedXMLFormatException- if the document is not well-formed the input file does not contain a valid instanceFileNotFoundException- if the file does not exist or can't be openedIOException- if error occurs while reading from the file
-
getInstanceStatusFromInstanceFile
public InstanceStatus getInstanceStatusFromInstanceFile(File file) throws VersionException, XMLFormatException, IOException Reads a process instance status from the given.- Parameters:
file- The file which will be parsed- Returns:
- An Instance
- Throws:
VersionException- if the format version of the instance file is not or no longer supportedXMLFormatException- if the document is not well-formed the input file does not contain a valid instanceFileNotFoundException- if the file does not exist or can't be openedIOException- if error occurs while reading from the file
-
getInstanceStatusFromInstanceDocument
public InstanceStatus getInstanceStatusFromInstanceDocument(Document document) throws VersionException, XMLFormatException Reads a process instance status from the given.- Parameters:
document- The (instance) document containing the instanceStatus- Returns:
- An Instance
- Throws:
VersionException- if the format version of the instance file is not or no longer supportedXMLFormatException- if the document is not well-formed the input file does not contain a valid instance
-
instanceStatusDatePresent
Gets whether the designated document contains an instance status with a migration (and execution) status date.- Parameters:
doc- The document which to check for whether it contains an instance status with migration (and execution) status date.- Returns:
- Whether the designated document contains an instance migration (and execution) status date.
-
getTemplateFromStream
public Template getTemplateFromStream(InputStream inputStream) throws VersionException, XMLFormatException, IOException Reads a process template from an input stream.- Parameters:
inputStream-- Returns:
- the template
- Throws:
VersionException- if the format version of the template stream is not or no longer supportedXMLFormatException- if the document is not well-formed the input stream does not contain a valid templateIOException- if error occurs while reading from the stream
-
getTemplateStatusFromStream
public TemplateStatus getTemplateStatusFromStream(InputStream inputStream) throws VersionException, XMLFormatException, IOException Reads the template status from the given template file. Note: the file must contain a template including a template status element.- Parameters:
inputStream- The input stream that will be parsed- Returns:
- A TemplateStatus
- Throws:
VersionException- if the format version of the template file is not or no longer supportedXMLFormatException- if the document is not well-formed the input file does not contain a valid templateFileNotFoundException- if the file does not exist or can't be openedIOException- if error occurs while reading from the fileIllegalArgumentException- If the XML in the stream does not contain a template status.
-
getTemplateStatusFromDocument
Returns a template status object from the given template document.- Parameters:
document- An XML document.- Returns:
- A template status element.
-
getInstanceFromStream
public Instance getInstanceFromStream(InputStream inputStream) throws VersionException, XMLFormatException, IOException Reads a process instance from an input stream.- Parameters:
inputStream-- Returns:
- the process
- Throws:
VersionException- if the format version of the instance stream is not or no longer supportedXMLFormatException- if the document is not well-formed the input stream does not contain a valid instanceIOException- if error occurs while reading from the stream
-
getTemplateFromDocument
Creates a template using the given DOM document. This method does not verify that the passed document is really a template.- Parameters:
document-- Returns:
- The parsed Template.
- Throws:
IOException- If there are problems decoding an EBP component signature from Base64, anIOExceptionwill be thrown.
-
getInstanceFromDocument
Creates an instance using the given DOM document.- Parameters:
document-template- The template to be used as structure, or null if the structure is stored inline.- Returns:
- The parsed Instance.
- Throws:
IOException- If there are problems decoding an EBP component signature from Base64, anIOExceptionwill be thrown.
-
getExecutableInstanceFromDocument
public ExecutableInstance getExecutableInstanceFromDocument(ExecutionFactory executionFactory, Document document, Template template) throws IOException Creates an instance using the given DOM document.- Parameters:
document-template- The template to be used as structure, or null if the structure is stored inline.executionFactory- The execution factory needed for the creation of the executable instance.- Returns:
- The parsed ExecutableInstance.
- Throws:
IOException- If there are problems decoding an EBP component signature from Base64, anIOExceptionwill be thrown.
-
getTemplateIDFromInstanceDocument
Returns the template ID stored in the given document- Parameters:
document-- Returns:
- The parsed UUID of the template.
-
getIsModifiedFromInstanceDocument
Returns the state of the isModified attribute in the given document of an instance.- Parameters:
document-- Returns:
- True if the instance has already been modified.
-
validateTemplateFormatVersion
Validates the format version of the given template document. Throws aVersionExceptionif the format version is not or no longer supported.- Parameters:
template- the template document to be tested- Throws:
VersionException- if the format version is not supported
-
validateInstanceFormatVersion
Validates the format version of the given instance document. Throws aVersionExceptionif the format version is not or no longer supported.- Parameters:
instance- the instance document to be tested- Throws:
VersionException- if the format version is not supported
-
getEBPForDocument
Retrieves the corresponding ExecutableBusinessProcess- Parameters:
document- The document, for which the EBP is needed- Returns:
- The EBP in the given document
- Throws:
IOException- If there are problems decoding the component signature from Base64, anIOExceptionwill be thrown.
-
getParameterForDocument
Retrieves the Corresponding parameter- Parameters:
document- The document, for which the parameter are needed- Returns:
- The parameter in the given document
-
getParameterSetForDocument
Retrieves the corresponding set of Parameter- Parameters:
document-- Returns:
- The parameter in the given document
-
getTemplateLocksFromFile
public static Map<UUID,ProcessModelXMLHelperTools.LockDescription> getTemplateLocksFromFile(File file) throws FileNotFoundException, XMLFormatException, IOException, VersionException Fetches the current locks stored in the specified file.- Parameters:
file- File to load- Returns:
- a map from UUID of template to LockDescription object with locking agent and lockCount
- Throws:
IOExceptionXMLFormatExceptionFileNotFoundExceptionVersionException- is thrown if the version of the file is not correct
-
getInstanceLocksFromFile
public static Map<UUID,ProcessModelXMLHelperTools.LockDescription> getInstanceLocksFromFile(File file) throws FileNotFoundException, XMLFormatException, IOException, VersionException Fetches the current locks stored in the specified file.- Parameters:
file- File to load- Returns:
- a map from UUID of instance to LockDescription object with locking agent and lockCount
- Throws:
IOExceptionXMLFormatExceptionFileNotFoundExceptionVersionException- is thrown if the version of the file is not correct
-
getEmbeddedTemplateMappingFromFile
public static Map<UUID,UUID> getEmbeddedTemplateMappingFromFile(File file) throws FileNotFoundException, XMLFormatException, IOException, VersionException Fetches the embedded template ID mappings stored in the specified file.- Parameters:
file- File to load- Returns:
- a map from ID of the embedded to the parents ID
- Throws:
IOExceptionXMLFormatExceptionFileNotFoundExceptionVersionException- is thrown if the version of the file is not correct
-
getBaseTemplateMappingFromFile
public static Map<UUID,UUID> getBaseTemplateMappingFromFile(File file) throws FileNotFoundException, XMLFormatException, IOException, VersionException Fetches the base template ID mappings stored in the specified file.- Parameters:
file- File to load- Returns:
- a map from template ID to the base template ID
- Throws:
IOExceptionXMLFormatExceptionFileNotFoundExceptionVersionException- is thrown if the version of the file is not correct
-
getProcessTypesFromFile
public static Set<ProcessModelXMLHelperTools.SerialisableProcessType> getProcessTypesFromFile(File file) throws FileNotFoundException, XMLFormatException, IOException, VersionException Fetches the process types stored in the specified file.- Parameters:
file- File to load- Returns:
- a set of the process types
- Throws:
IOExceptionXMLFormatExceptionFileNotFoundExceptionVersionException- is thrown if the version of the file is not correct
-
getAdhocTemplateMappingFromFile
public static Map<UUID,UUID> getAdhocTemplateMappingFromFile(File file) throws FileNotFoundException, XMLFormatException, IOException, VersionException Fetches the adhoc template ID mappings stored in the specified file.- Parameters:
file- File to load- Returns:
- a map from adhoc template ID to the instance ID
- Throws:
IOExceptionXMLFormatExceptionFileNotFoundExceptionVersionException- is thrown if the version of the file is not correct
-
getTemplateInformationsFromFile
public static Map<UUID,ProcessModelXMLHelperTools.TemplateInformation> getTemplateInformationsFromFile(File file) throws FileNotFoundException, XMLFormatException, IOException, VersionException Fetches the template informations stored in the specified file.- Parameters:
file- File to load- Returns:
- a map from template id to its template information
- Throws:
IOExceptionXMLFormatExceptionFileNotFoundExceptionVersionException- is thrown if the version of the file is not correct
-
error
- Specified by:
errorin interfaceErrorHandler- Throws:
SAXException
-
fatalError
- Specified by:
fatalErrorin interfaceErrorHandler- Throws:
SAXException
-
warning
- Specified by:
warningin interfaceErrorHandler- Throws:
SAXException
-