Class DataService


  • public class DataService
    extends Object
    The SnapshotService is used to store a imixs snapshot into the cluster keyspace.
    Author:
    rsoika
    • Constructor Detail

      • DataService

        public DataService()
    • Method Detail

      • saveSnapshot

        public void saveSnapshot​(org.imixs.workflow.ItemCollection snapshot)
                          throws ArchiveException
        This method saves a ItemCollection into a specific KeySpace.

        The method expects a valid session instance which must be closed by the client.

        Parameters:
        snapshot - - ItemCollection object
        session - - cassandra session
        Throws:
        ArchiveException
      • existSnapshot

        public boolean existSnapshot​(String snapshotID)
        This method test if a snapshot recored with a given ID already exists.
        Parameters:
        snapshotID -
        Returns:
        true if the snapshot exists.
      • loadSnapshot

        public org.imixs.workflow.ItemCollection loadSnapshot​(String snapshotID)
                                                       throws ArchiveException
        This method loads a snapshot form the cassandra cluster. The snapshot data includes also the accociated document data. In case you need only the snapshotdata without documents use loadSnapshot(id,false,session).
        Parameters:
        snapshotID - - snapshot id
        session - - cassandra session
        Returns:
        snapshot data including documents
        Throws:
        ArchiveException
      • loadSnapshot

        public org.imixs.workflow.ItemCollection loadSnapshot​(String snapshotID,
                                                              boolean mergeDocuments)
                                                       throws ArchiveException
        Thist method loads a snapshot form the cassandra cluster.

        Parameters:
        snapshotID - - snapshot id
        mergeDocuments - - boolean, if true the accociated document data will be loaded and merged into the snapshot data object.
        session - - cassandra session
        Returns:
        snapshot data
        Throws:
        ArchiveException
      • loadSnapshotsByUnqiueID

        public List<String> loadSnapshotsByUnqiueID​(String uniqueID,
                                                    int maxCount,
                                                    boolean descending)
        This method loads all existing snapshotIDs for a given unqiueID.

        Parameters:
        uniqueID -
        maxCount - - max search result
        descending - - sort result descending
        Returns:
        list of snapshots
      • loadSnapshotsByDate

        public List<String> loadSnapshotsByDate​(LocalDate date)
        This method loads all exsting snapshotIDs for a given date.
        Parameters:
        date -
        Returns:
        list of snapshots or an empty list if no snapshots exist for the given date
      • loadFileData

        public org.imixs.workflow.FileData loadFileData​(org.imixs.workflow.FileData fileData)
                                                 throws ArchiveException
        This helper method loades the content of a document defned by a FileData object. A document is uniquely identified by its md5 checksum which is part of the FileData custom attributes. The data of the document is stored in split 1md data blocks in the tabe 'documents_data'
        Parameters:
        itemCol -
        Throws:
        ArchiveException
      • loadFileContent

        public byte[] loadFileContent​(String md5)
                               throws ArchiveException
        This helper method loads the content of a document defned by its MD5 checksum. The data of the document is stored in chunked 1md data blocks in the table 'documents_data'
        Parameters:
        itemCol -
        Throws:
        ArchiveException
      • loadMetadata

        public org.imixs.workflow.ItemCollection loadMetadata()
                                                       throws ArchiveException
        This method loads the metadata object represended by an ItemCollection. The snapshot id for the metadata object is always "0". This id is reserverd for metadata only.

        If no metadata object yet exists, the method returns an empty ItemCollection.

        The method expects a valid session instance which must be closed by the client.

        Returns:
        metadata object
        Throws:
        ArchiveException
      • saveMetadata

        public void saveMetadata​(org.imixs.workflow.ItemCollection metadata)
                          throws ArchiveException
        This method saves the metadata represented by an ItemCollection. The snapshot id for the metadata object is always "0". This id is reserverd for metadata only.

        The method expects a valid session instance which must be closed by the client.

        Parameters:
        itemCol - - metadata
        Throws:
        ArchiveException
      • deleteSnapshot

        public void deleteSnapshot​(String snapshotID)
                            throws ArchiveException
        This method deletes a single snapshot instance.

        The method also deletes the documents and all relations

        Parameters:
        snapshotID - - id of the snapshot
        Throws:
        ArchiveException
      • getRawData

        public byte[] getRawData​(org.imixs.workflow.ItemCollection itemCol)
                          throws ArchiveException
        Converts a ItemCollection into a XMLDocument and returns the byte data.
        Parameters:
        itemCol -
        Returns:
        Throws:
        ArchiveException
      • getItemCollection

        public org.imixs.workflow.ItemCollection getItemCollection​(byte[] source)
                                                            throws ArchiveException
        Converts a byte array into a XMLDocument and returns the ItemCollection object.
        Throws:
        ArchiveException
      • isSnapshotID

        public boolean isSnapshotID​(String uid)
        This method returns true if the given id is a valid Snapshot id (UUI + timestamp

        We also need to support the old snapshto format 4832b09a1a-20c38abd-1519421083952

        Parameters:
        uid -
        Returns:
      • getUniqueID

        public String getUniqueID​(String snapshotID)
        Returns the $uniqueID from a $SnapshotID
        Parameters:
        snapshotID -
        Returns:
        $uniqueid
      • getSnapshotTime

        public long getSnapshotTime​(String snapshotID)
        Returns the snapshot time n millis of a $SnapshotID
        Parameters:
        snapshotID -
        Returns:
        long - snapshot time
      • calculateSize

        public long calculateSize​(org.imixs.workflow.xml.XMLDocument xmldoc)
        count total value size...
        Parameters:
        xmldoc -
        Returns:
      • getSyncPointISO

        public String getSyncPointISO​(long point)
        returns the date tiem from a date in iso format
        Returns: