Class ProcessModelXMLImport
- java.lang.Object
-
- de.aristaflow.adept2.model.processmodel.xml.ProcessModelXMLImport
-
- All Implemented Interfaces:
ErrorHandler
public class ProcessModelXMLImport extends Object implements 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:
ProcessModelFactory
-
-
Constructor Summary
Constructors Constructor Description ProcessModelXMLImport(ProcessModelFactory factory)Constructor, requiring the factory to use.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiderror(SAXParseException spe)voidfatalError(SAXParseException spe)static Map<UUID,UUID>getAdhocTemplateMappingFromFile(File file)Fetches the adhoc template ID mappings stored in the specified file.static Map<UUID,UUID>getBaseTemplateMappingFromFile(File file)Fetches the base template ID mappings stored in the specified file.ExecutableBusinessProcessgetEBPForDocument(Document document)Retrieves the corresponding ExecutableBusinessProcessstatic Map<UUID,UUID>getEmbeddedTemplateMappingFromFile(File file)Fetches the embedded template ID mappings stored in the specified file.ExecutableInstancegetExecutableInstanceFromDocument(ExecutionFactory executionFactory, Document document, Template template)Creates an instance using the given DOM document.ExecutableInstancegetExecutableInstanceFromFile(ExecutionFactory executionFactory, File file)Reads a process instance from the given file and determines the file type.ExecutableInstancegetExecutableInstanceFromFile(ExecutionFactory executionFactory, File file, Template template)Reads a process instance from the given file and determines the file type.ExecutableInstancegetExecutableInstanceFromStream(ExecutionFactory executionFactory, InputStream stream, Template template)Reads a process instance from the designated input stream.InstancegetInstanceFromDocument(Document document, Template template)Creates an instance using the given DOM document.InstancegetInstanceFromFile(File file)Reads a process instance from the given file and determines the file type.InstancegetInstanceFromFile(File file, Template template)Reads a process instance from the given file and determines the file type.InstancegetInstanceFromStream(InputStream inputStream)Reads a process instance from an input stream.static Map<UUID,ProcessModelXMLHelperTools.LockDescription>getInstanceLocksFromFile(File file)Fetches the current locks stored in the specified file.InstanceStatusgetInstanceStatusFromInstanceDocument(Document document)Reads a process instance status from the given.InstanceStatusgetInstanceStatusFromInstanceFile(File file)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.ProcessModelParametergetParameterForDocument(Document document)Retrieves the Corresponding parameterSet<ProcessModelParameter>getParameterSetForDocument(Document document)Retrieves the corresponding set of Parameterstatic Set<ProcessModelXMLHelperTools.SerialisableProcessType>getProcessTypesFromFile(File file)Fetches the process types stored in the specified file.TemplategetTemplateFromDocument(Document document)Creates a template using the given DOM document.TemplategetTemplateFromFile(File file)Reads a process template from the given file and determines the file type.TemplategetTemplateFromStream(InputStream inputStream)Reads a process template from an input stream.UUIDgetTemplateIDFromInstanceDocument(Document document)Returns the template ID stored in the given documentUUIDgetTemplateIDFromInstanceFile(File file)Reads a process instance from the given file and determines the file type.static Map<UUID,ProcessModelXMLHelperTools.TemplateInformation>getTemplateInformationsFromFile(File file)Fetches the template informations stored in the specified file.static Map<UUID,ProcessModelXMLHelperTools.LockDescription>getTemplateLocksFromFile(File file)Fetches the current locks stored in the specified file.TemplateStatusgetTemplateStatusFromDocument(Document document)Returns a template status object from the given template document.TemplateStatusgetTemplateStatusFromStream(InputStream inputStream)Reads the template status from the given template file.TemplateStatusgetTemplateStatusFromTemplateFile(File file)Reads the template status from the given template file.booleaninstanceStatusDatePresent(Document doc)Gets 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 Detail
-
logger
protected final Logger logger
The logger for XML imports. It is protected for extensibility.
-
-
Constructor Detail
-
ProcessModelXMLImport
public ProcessModelXMLImport(ProcessModelFactory factory)
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 Detail
-
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
public boolean instanceStatusDatePresent(Document doc)
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
public TemplateStatus getTemplateStatusFromDocument(Document document)
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
public Template getTemplateFromDocument(Document document) throws IOException
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
public Instance getInstanceFromDocument(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.- 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
public UUID getTemplateIDFromInstanceDocument(Document document)
Returns the template ID stored in the given document- Parameters:
document-- Returns:
- The parsed UUID of the template.
-
getIsModifiedFromInstanceDocument
public boolean getIsModifiedFromInstanceDocument(Document document)
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
public static void validateTemplateFormatVersion(Document template) throws VersionException
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
public static void validateInstanceFormatVersion(Document instance) throws VersionException
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
public ExecutableBusinessProcess getEBPForDocument(Document document) throws IOException
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
public ProcessModelParameter getParameterForDocument(Document document)
Retrieves the Corresponding parameter- Parameters:
document- The document, for which the parameter are needed- Returns:
- The parameter in the given document
-
getParameterSetForDocument
public Set<ProcessModelParameter> getParameterSetForDocument(Document document)
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
public void error(SAXParseException spe) throws SAXException
- Specified by:
errorin interfaceErrorHandler- Throws:
SAXException
-
fatalError
public void fatalError(SAXParseException spe) throws SAXException
- Specified by:
fatalErrorin interfaceErrorHandler- Throws:
SAXException
-
warning
public void warning(SAXParseException spe) throws SAXException
- Specified by:
warningin interfaceErrorHandler- Throws:
SAXException
-
-