Class FlowXML

  • All Implemented Interfaces:
    java.io.Serializable

    public class FlowXML
    extends java.lang.Object
    implements java.io.Serializable
    Simplicité XML flow.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  FlowXML.ZIPFile
      ZIP file info with ZIP file and oredred list of configuration files names within the ZIP file
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CLEAR_CACHE_AFTER
      Clear cache after processing mode
      static java.lang.String CLEAR_CACHE_BEFORE
      Clear cache before processing mode
      static java.lang.String CLEAR_CACHE_BOTH
      Clear cache before and after processing mode
      static java.lang.String CLEAR_CACHE_NONE
      No clear cache mode
    • Constructor Summary

      Constructors 
      Constructor Description
      FlowXML()
      Default constructor
      FlowXML​(boolean atomic)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Atomic is not supported anymore
      FlowXML​(boolean atomic, java.lang.String clear)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Atomic is not supported anymore
      FlowXML​(byte[] zip)
      Constructor.
      FlowXML​(java.io.InputStream zis)
      Constructor.
      FlowXML​(java.io.InputStream is, java.lang.String origin)
      Constructor.
      FlowXML​(java.io.OutputStream out)
      Constructor.
      FlowXML​(java.io.OutputStream out, java.lang.String format, int flushSize, java.lang.String zipName)
      Constructor.
      FlowXML​(java.lang.String clear)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addObject​(ObjectXML obj)
      Add an XML object.
      void addObject​(ObjectDB obj, java.lang.String action)
      Add an XML object with specified action
      void addObject​(ObjectDB obj, java.lang.String action, boolean timestampFields, boolean inlineDocs)
      Add an XML object with specified action
      static java.io.File buildModuleXML​(Grant g, java.lang.String moduleName, java.io.File dir, boolean delete)
      Build single XML module XML file from exploded files
      void clear()
      Clear objects of flow
      void close()
      Close the output writer
      java.lang.String compare​(Grant g, FlowXML origin, FlowXML flow, java.lang.String title1, java.lang.String title2)
      Compare 2 flows
      Message contains​(ObjectDB object)
      Return find = 0 if not found, 1 if same functional key but difference in data, 2 if equals
      Message contains​(java.lang.String object, DataXML data)
      Return find = 0 if not found, 1 if same functional key but difference in data, 2 if equals
      static java.lang.String error​(java.lang.String message)
      Standard XML error message
      static FlowXML fromJSON​(java.lang.String json)
      Parse JSON flow string into an XML flow
      static FlowXML fromJSON​(org.json.JSONArray json)
      Parse JSON flow into an XML flow
      static FlowXML fromJSON​(org.json.JSONObject json)
      Parse JSON flow into an XML flow
      static FlowXML fromYAML​(java.lang.String yaml)
      Parse YAML flow string into an XML flow
      byte[] getBytes()
      XML flow as bytes array
      java.lang.String getClearCache()
      Get clear cache mode
      java.util.Date getEffectiveDate()
      Get effective import date
      java.lang.String getExternalDir()
      Get external directory
      ObjectXML getFirstObject()
      Get XML object at first index
      java.io.InputStream getInputStream()
      Deprecated.
      Use getXMLInputStream
      java.io.InputStream getJSONInputStream()
      Stream flow as JSON byte array input stream
      ObjectXML getLastObject()
      Get XML object at last index
      static java.io.File getModuleZIPFileFromDir​(Grant g, java.lang.String name, java.io.File dir)
      Get clean ZIP file from a checkout directory
      static java.io.InputStream getModuleZIPStreamFromDir​(Grant g, java.lang.String name, java.io.File dir)
      Get clean ZIP stream from a checkout directory
      ObjectXML getObject​(int i)
      Get XML object at specified index
      java.util.List<ObjectXML> getObjects()
      Get all XML objects of flow
      int getSize()
      Get number of XML objects in flow
      java.lang.String getTempDir()
      Get temporary directory
      java.io.InputStream getXMLInputStream()
      Stream flow as XML byte array input stream
      java.io.InputStream getYAMLInputStream()
      Stream flow as YAML byte array input stream
      void insertObject​(ObjectXML obj, int index)
      Insert an XML object at specified index
      boolean isAtomic()
      Deprecated, for removal: This API element is subject to removal in a future version. 
      void remove​(int i)
      Remove object at specified index
      void removeTempDir()
      Remove temporary directory
      static java.lang.String result​(java.lang.String message)
      Get standard XML result message
      void setEffectiveDate​(java.util.Date d)
      Set effective import date
      void setObjects​(java.util.List<ObjectXML> list)
      Set all XML objects of flow
      boolean toFile​(java.lang.String path)
      Serialize as XML file
      java.lang.StringBuilder toJSON()
      Serialize as JSON string builder
      java.lang.StringBuilder toJSON​(boolean indent)
      Serialize as JSON string builder
      org.json.JSONObject toJSONObject()
      Serialize as JSON object
      java.lang.String toString()
      Serialize as XML string
      java.lang.StringBuilder toXML()
      Serialize as XML string builder
      java.lang.StringBuilder toXML​(java.lang.String tab)
      Serialize as XML string builder
      java.lang.StringBuilder toYAML()
      Serialize as YAML string builder
      java.io.File toZIP​(java.lang.String name)
      Deprecated.
      Use toZIP with format and exploded flag
      java.io.File toZIP​(java.lang.String name, java.lang.String format)
      Deprecated.
      Use toZIP with format and exploded flag
      java.io.File toZIP​(java.lang.String name, java.lang.String format, boolean exploded)
      Serialize as ZIP archive file with documents
      FlowXML.ZIPFile toZIPFile​(java.lang.String name, java.lang.String format, boolean exploded)
      Serialize as ZIP archive file with documents
      static java.lang.String xmlFooter()
      Get XML footer
      static java.lang.String xmlHeader()
      Get XML header
      static java.lang.String xmlHeader​(boolean atomic, java.util.Date effectiveDate, java.lang.String clearCache)
      Deprecated, for removal: This API element is subject to removal in a future version. 
      static java.lang.String xmlHeader​(java.util.Date effectiveDate, java.lang.String clearCache)
      Get XML header
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • CLEAR_CACHE_NONE

        public static final java.lang.String CLEAR_CACHE_NONE
        No clear cache mode
        See Also:
        Constant Field Values
      • CLEAR_CACHE_BEFORE

        public static final java.lang.String CLEAR_CACHE_BEFORE
        Clear cache before processing mode
        See Also:
        Constant Field Values
      • CLEAR_CACHE_AFTER

        public static final java.lang.String CLEAR_CACHE_AFTER
        Clear cache after processing mode
        See Also:
        Constant Field Values
      • CLEAR_CACHE_BOTH

        public static final java.lang.String CLEAR_CACHE_BOTH
        Clear cache before and after processing mode
        See Also:
        Constant Field Values
    • Constructor Detail

      • FlowXML

        public FlowXML()
        Default constructor
      • FlowXML

        @Deprecated(forRemoval=true,
                    since="4.0")
        public FlowXML​(boolean atomic)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Atomic is not supported anymore
      • FlowXML

        @Deprecated(forRemoval=true,
                    since="4.0")
        public FlowXML​(boolean atomic,
                       java.lang.String clear)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Atomic is not supported anymore
      • FlowXML

        public FlowXML​(java.lang.String clear)
        Constructor.
        Parameters:
        clear - One of CLEAR_CACHE_* constants
      • FlowXML

        public FlowXML​(java.io.InputStream is,
                       java.lang.String origin)
                throws XMLException
        Constructor.
        Loads an input stream.
        Parameters:
        is - Input stream
        origin - Flow origin
        Throws:
        XMLException
      • FlowXML

        public FlowXML​(byte[] zip)
                throws XMLException
        Constructor.
        Loads a ZIP byte array data which contains:
        • XML files to load in alphabetic order
        • Attached documents
        Parameters:
        zip - ZIP byte array
        Throws:
        XMLException
      • FlowXML

        public FlowXML​(java.io.InputStream zis)
                throws XMLException
        Constructor.
        Load ZIP input stream which contains:
        • XML files to load in alphabetic order
        • Attached documents
        Parameters:
        zis - ZIP input stream
        Throws:
        XMLException
      • FlowXML

        public FlowXML​(java.io.OutputStream out)
        Constructor.
        Used to export XML in a stream.
        Parameters:
        out - Output stream
      • FlowXML

        public FlowXML​(java.io.OutputStream out,
                       java.lang.String format,
                       int flushSize,
                       java.lang.String zipName)
        Constructor.
        Used to export flow in a stream.
        Parameters:
        out - Output stream
        format - Integration.FORMAT_XML JSON or YAML
        flushSize - Flush buffer size
        zipName - Optional name to get a zipped result
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Close the output writer
        Throws:
        java.io.IOException
      • getObject

        public ObjectXML getObject​(int i)
        Get XML object at specified index
        Parameters:
        i - Index
        Returns:
        XML object
      • remove

        public void remove​(int i)
        Remove object at specified index
        Parameters:
        i - Index
      • getFirstObject

        public ObjectXML getFirstObject()
        Get XML object at first index
        Returns:
        XML object
      • getLastObject

        public ObjectXML getLastObject()
        Get XML object at last index
        Returns:
        XML object
      • getObjects

        public java.util.List<ObjectXML> getObjects()
        Get all XML objects of flow
        Returns:
        XML objects list
      • setObjects

        public void setObjects​(java.util.List<ObjectXML> list)
        Set all XML objects of flow
        Parameters:
        list - XML objects list
      • getSize

        public int getSize()
        Get number of XML objects in flow
        Returns:
        Number of XML objects in flow
      • clear

        public void clear()
        Clear objects of flow
      • isAtomic

        @Deprecated(forRemoval=true,
                    since="4.0")
        public boolean isAtomic()
        Deprecated, for removal: This API element is subject to removal in a future version.
      • getExternalDir

        public java.lang.String getExternalDir()
        Get external directory
        Returns:
        External directory
      • getTempDir

        public java.lang.String getTempDir()
        Get temporary directory
        Returns:
        Temporay directory
      • getClearCache

        public java.lang.String getClearCache()
        Get clear cache mode
        Returns:
        Clear cache mode
      • getEffectiveDate

        public java.util.Date getEffectiveDate()
        Get effective import date
        Returns:
        Effective import date or null
      • setEffectiveDate

        public void setEffectiveDate​(java.util.Date d)
        Set effective import date
        Parameters:
        d - Effective import date
      • addObject

        public void addObject​(ObjectXML obj)
                       throws java.io.IOException
        Add an XML object. If the FlowXML has been constructed with an output stream, the object is flushed directly to keep the heap free.
        Parameters:
        obj - XML object to add
        Throws:
        java.io.IOException
      • insertObject

        public void insertObject​(ObjectXML obj,
                                 int index)
        Insert an XML object at specified index
        Parameters:
        obj - XML object to insert
        index - Index
      • addObject

        public void addObject​(ObjectDB obj,
                              java.lang.String action)
                       throws java.io.IOException
        Add an XML object with specified action
        Parameters:
        obj - XML object
        action - Action
        Throws:
        java.io.IOException
      • addObject

        public void addObject​(ObjectDB obj,
                              java.lang.String action,
                              boolean timestampFields,
                              boolean inlineDocs)
                       throws java.io.IOException
        Add an XML object with specified action
        Parameters:
        obj - XML object
        action - Action
        timestampFields - With timestamp fields (if applicable)
        inlineDocs - With documents inlined data
        Throws:
        java.io.IOException
      • xmlHeader

        public static java.lang.String xmlHeader()
        Get XML header
        Returns:
        XML header
      • xmlHeader

        @Deprecated(forRemoval=true,
                    since="4.0")
        public static java.lang.String xmlHeader​(boolean atomic,
                                                 java.util.Date effectiveDate,
                                                 java.lang.String clearCache)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • xmlHeader

        public static java.lang.String xmlHeader​(java.util.Date effectiveDate,
                                                 java.lang.String clearCache)
        Get XML header
        Parameters:
        effectiveDate - Optional effective import date
        clearCache - Optional clear cache mode
        Returns:
        XML header
      • xmlFooter

        public static java.lang.String xmlFooter()
        Get XML footer
        Returns:
        XML footer
      • result

        public static java.lang.String result​(java.lang.String message)
        Get standard XML result message
        Parameters:
        message - Result message
        Returns:
        Standard XML fragment for result message
      • error

        public static java.lang.String error​(java.lang.String message)
        Standard XML error message
        Parameters:
        message - Error message
        Returns:
        Standard XML fragment for error message
      • getInputStream

        @Deprecated(forRemoval=false,
                    since="4.0")
        public java.io.InputStream getInputStream()
        Deprecated.
        Use getXMLInputStream
      • getXMLInputStream

        public java.io.InputStream getXMLInputStream()
        Stream flow as XML byte array input stream
        Returns:
        XML byte array input stream
      • getJSONInputStream

        public java.io.InputStream getJSONInputStream()
        Stream flow as JSON byte array input stream
        Returns:
        JSON byte array input stream
      • getYAMLInputStream

        public java.io.InputStream getYAMLInputStream()
        Stream flow as YAML byte array input stream
        Returns:
        YAML byte array input stream
      • fromJSON

        public static FlowXML fromJSON​(java.lang.String json)
        Parse JSON flow string into an XML flow
        Parameters:
        json - JSON flow string
        Returns:
        XML object
      • fromJSON

        public static FlowXML fromJSON​(org.json.JSONObject json)
        Parse JSON flow into an XML flow
        Parameters:
        json - JSON {objects:[...]}
        Returns:
        XML flow
      • fromJSON

        public static FlowXML fromJSON​(org.json.JSONArray json)
        Parse JSON flow into an XML flow
        Parameters:
        json - JSON array of single objects
        Returns:
        XML flow
      • fromYAML

        public static FlowXML fromYAML​(java.lang.String yaml)
        Parse YAML flow string into an XML flow
        Parameters:
        yaml - YAML object string
        Returns:
        XML flow
      • getBytes

        public byte[] getBytes()
        XML flow as bytes array
        Returns:
        bytes
      • toString

        public java.lang.String toString()
        Serialize as XML string
        Overrides:
        toString in class java.lang.Object
        Returns:
        XML string
      • toXML

        public java.lang.StringBuilder toXML()
        Serialize as XML string builder
        Returns:
        XML string builder
      • toXML

        public java.lang.StringBuilder toXML​(java.lang.String tab)
        Serialize as XML string builder
        Parameters:
        tab - Optional tabulation
        Returns:
        XML string builder
      • toJSON

        public java.lang.StringBuilder toJSON()
        Serialize as JSON string builder
        Returns:
        JSON string builder
      • toJSON

        public java.lang.StringBuilder toJSON​(boolean indent)
        Serialize as JSON string builder
        Parameters:
        indent - Indent?
        Returns:
        JSON string builder
      • toJSONObject

        public org.json.JSONObject toJSONObject()
        Serialize as JSON object
        Returns:
        JSON string builder
      • toYAML

        public java.lang.StringBuilder toYAML()
        Serialize as YAML string builder
        Returns:
        JSON string builder
      • toFile

        public boolean toFile​(java.lang.String path)
        Serialize as XML file
        Parameters:
        path - FIle path
        Returns:
        True if file writing is successful
      • toZIP

        @Deprecated(forRemoval=false,
                    since="4.0")
        public java.io.File toZIP​(java.lang.String name)
        Deprecated.
        Use toZIP with format and exploded flag
      • toZIP

        @Deprecated(forRemoval=false,
                    since="4.0")
        public java.io.File toZIP​(java.lang.String name,
                                  java.lang.String format)
                           throws java.io.IOException
        Deprecated.
        Use toZIP with format and exploded flag
        Throws:
        java.io.IOException
      • toZIP

        public java.io.File toZIP​(java.lang.String name,
                                  java.lang.String format,
                                  boolean exploded)
                           throws java.io.IOException
        Serialize as ZIP archive file with documents
        Parameters:
        name - ZIP archive name
        format - Format (one of Integration.FORMAT_* constants)
        exploded - Explode configuration file in per-object files
        Returns:
        ZIP file in temporary directory (caller have to delete it after usage)
        Throws:
        java.io.IOException
      • toZIPFile

        public FlowXML.ZIPFile toZIPFile​(java.lang.String name,
                                         java.lang.String format,
                                         boolean exploded)
                                  throws java.io.IOException
        Serialize as ZIP archive file with documents
        Parameters:
        name - ZIP archive name
        format - Format (one of Integration.FORMAT_* constants)
        exploded - Explode configuration file in per-object files
        Returns:
        ZIP file info with ZIP file in temporary directory (caller have to delete it after usage) and ordered list of configuration files within the ZIP file
        Throws:
        java.io.IOException
      • removeTempDir

        public void removeTempDir()
        Remove temporary directory
      • compare

        public java.lang.String compare​(Grant g,
                                        FlowXML origin,
                                        FlowXML flow,
                                        java.lang.String title1,
                                        java.lang.String title2)
        Compare 2 flows
      • contains

        public Message contains​(java.lang.String object,
                                DataXML data)
        Return find = 0 if not found, 1 if same functional key but difference in data, 2 if equals
        Parameters:
        object - Object name
        data - Data to search
        Returns:
        Message find + data
      • contains

        public Message contains​(ObjectDB object)
        Return find = 0 if not found, 1 if same functional key but difference in data, 2 if equals
        Parameters:
        object - Selected object
        Returns:
        Message find + data
      • buildModuleXML

        public static java.io.File buildModuleXML​(Grant g,
                                                  java.lang.String moduleName,
                                                  java.io.File dir,
                                                  boolean delete)
                                           throws java.io.IOException
        Build single XML module XML file from exploded files
        Parameters:
        g - Grant
        moduleName - Module name
        dir - Base directory of module
        delete - Delete exploded files?
        Returns:
        XML file or null
        Throws:
        java.io.IOException
      • getModuleZIPFileFromDir

        public static java.io.File getModuleZIPFileFromDir​(Grant g,
                                                           java.lang.String name,
                                                           java.io.File dir)
                                                    throws java.io.IOException
        Get clean ZIP file from a checkout directory
        Parameters:
        g - Grant
        dir - Checkout directory
        Returns:
        ZIP file
        Throws:
        java.io.IOException
      • getModuleZIPStreamFromDir

        public static java.io.InputStream getModuleZIPStreamFromDir​(Grant g,
                                                                    java.lang.String name,
                                                                    java.io.File dir)
                                                             throws java.io.IOException
        Get clean ZIP stream from a checkout directory
        Parameters:
        g - Grant
        dir - Checkout directory
        Returns:
        ZIP stream
        Throws:
        java.io.IOException