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:
  • Field Details

    • logger

      protected final Logger logger
      The logger for XML imports. It is protected for extensibility.
  • Constructor Details

    • 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 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 supported
      XMLFormatException - if the document is not well-formed the input file does not contain a valid template
      FileNotFoundException - if the file does not exist or can't be opened
      IOException - 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 supported
      XMLFormatException - if the document is not well-formed the input file does not contain a valid template
      FileNotFoundException - if the file does not exist or can't be opened
      IOException - 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 supported
      XMLFormatException - if the document is not well-formed the input file does not contain a valid instance
      FileNotFoundException - if the file does not exist or can't be opened
      IOException - 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 supported
      XMLFormatException - if the document is not well-formed the input file does not contain a valid instance
      FileNotFoundException - if the file does not exist or can't be opened
      IOException - 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 parsed
      template - 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 supported
      XMLFormatException - if the document is not well-formed the input file does not contain a valid instance
      FileNotFoundException - if the file does not exist or can't be opened
      IOException - 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 supported
      XMLFormatException - if the document is not well-formed the input file does not contain a valid instance
      FileNotFoundException - if the file does not exist or can't be opened
      IOException - 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 supported
      XMLFormatException - if the document is not well-formed the input file does not contain a valid instance
      FileNotFoundException - if the file does not exist or can't be opened
      IOException - 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 supported
      XMLFormatException - if the document is not well-formed the input file does not contain a valid instance
      FileNotFoundException - if the file does not exist or can't be opened
      IOException - 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 supported
      XMLFormatException - 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 supported
      XMLFormatException - if the document is not well-formed the input stream does not contain a valid template
      IOException - 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 supported
      XMLFormatException - if the document is not well-formed the input file does not contain a valid template
      FileNotFoundException - if the file does not exist or can't be opened
      IOException - if error occurs while reading from the file
      IllegalArgumentException - 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 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
    • 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, an IOException will 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, an IOException will 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, an IOException will 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 a VersionException if 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 a VersionException if 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, an IOException will 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

      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:
      IOException
      XMLFormatException
      FileNotFoundException
      VersionException - is thrown if the version of the file is not correct
    • getInstanceLocksFromFile

      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:
      IOException
      XMLFormatException
      FileNotFoundException
      VersionException - 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:
      IOException
      XMLFormatException
      FileNotFoundException
      VersionException - 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:
      IOException
      XMLFormatException
      FileNotFoundException
      VersionException - is thrown if the version of the file is not correct
    • getProcessTypesFromFile

      Fetches the process types stored in the specified file.
      Parameters:
      file - File to load
      Returns:
      a set of the process types
      Throws:
      IOException
      XMLFormatException
      FileNotFoundException
      VersionException - 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:
      IOException
      XMLFormatException
      FileNotFoundException
      VersionException - is thrown if the version of the file is not correct
    • getTemplateInformationsFromFile

      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:
      IOException
      XMLFormatException
      FileNotFoundException
      VersionException - is thrown if the version of the file is not correct
    • error

      public void error(SAXParseException spe) throws SAXException
      Specified by:
      error in interface ErrorHandler
      Throws:
      SAXException
    • fatalError

      public void fatalError(SAXParseException spe) throws SAXException
      Specified by:
      fatalError in interface ErrorHandler
      Throws:
      SAXException
    • warning

      public void warning(SAXParseException spe) throws SAXException
      Specified by:
      warning in interface ErrorHandler
      Throws:
      SAXException