Class DataService
- java.lang.Object
-
- org.imixs.archive.service.cassandra.DataService
-
public class DataService extends Object
The SnapshotService is used to store a imixs snapshot into the cluster keyspace.- Author:
- rsoika
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description DataService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcalculateSize(org.imixs.workflow.xml.XMLDocument xmldoc)count total value size...voiddeleteSnapshot(String snapshotID)This method deletes a single snapshot instance.booleanexistSnapshot(String snapshotID)This method test if a snapshot recored with a given ID already exists.org.imixs.workflow.ItemCollectiongetItemCollection(byte[] source)Converts a byte array into a XMLDocument and returns the ItemCollection object.byte[]getRawData(org.imixs.workflow.ItemCollection itemCol)Converts a ItemCollection into a XMLDocument and returns the byte data.longgetSnapshotTime(String snapshotID)Returns the snapshot time n millis of a $SnapshotIDStringgetSyncPointISO(long point)returns the date tiem from a date in iso formatStringgetUniqueID(String snapshotID)Returns the $uniqueID from a $SnapshotIDbooleanisSnapshotID(String uid)This method returns true if the given id is a valid Snapshot id (UUI + timestampbyte[]loadFileContent(String md5)This helper method loads the content of a document defned by its MD5 checksum.org.imixs.workflow.FileDataloadFileData(org.imixs.workflow.FileData fileData)This helper method loades the content of a document defned by a FileData object.org.imixs.workflow.ItemCollectionloadMetadata()This method loads the metadata object represended by an ItemCollection.org.imixs.workflow.ItemCollectionloadSnapshot(String snapshotID)This method loads a snapshot form the cassandra cluster.org.imixs.workflow.ItemCollectionloadSnapshot(String snapshotID, boolean mergeDocuments)Thist method loads a snapshot form the cassandra cluster.List<String>loadSnapshotsByDate(LocalDate date)This method loads all exsting snapshotIDs for a given date.List<String>loadSnapshotsByUnqiueID(String uniqueID, int maxCount, boolean descending)This method loads all existing snapshotIDs for a given unqiueID.voidsaveMetadata(org.imixs.workflow.ItemCollection metadata)This method saves the metadata represented by an ItemCollection.voidsaveSnapshot(org.imixs.workflow.ItemCollection snapshot)This method saves a ItemCollection into a specific KeySpace.
-
-
-
Field Detail
-
ITEM_MD5_CHECKSUM
public static final String ITEM_MD5_CHECKSUM
- See Also:
- Constant Field Values
-
ITEM_SNAPSHOT_HISTORY
public static final String ITEM_SNAPSHOT_HISTORY
- See Also:
- Constant Field Values
-
COLUMN_SNAPSHOT
public static final String COLUMN_SNAPSHOT
- See Also:
- Constant Field Values
-
COLUMN_MODIFIED
public static final String COLUMN_MODIFIED
- See Also:
- Constant Field Values
-
COLUMN_UNIQUEID
public static final String COLUMN_UNIQUEID
- See Also:
- Constant Field Values
-
COLUMN_DATA
public static final String COLUMN_DATA
- See Also:
- Constant Field Values
-
COLUMN_MD5
public static final String COLUMN_MD5
- See Also:
- Constant Field Values
-
STATEMENT_UPSET_SNAPSHOTS
public static final String STATEMENT_UPSET_SNAPSHOTS
- See Also:
- Constant Field Values
-
STATEMENT_UPSET_SNAPSHOTS_BY_UNIQUEID
public static final String STATEMENT_UPSET_SNAPSHOTS_BY_UNIQUEID
- See Also:
- Constant Field Values
-
STATEMENT_UPSET_SNAPSHOTS_BY_MODIFIED
public static final String STATEMENT_UPSET_SNAPSHOTS_BY_MODIFIED
- See Also:
- Constant Field Values
-
STATEMENT_UPSET_DOCUMENTS
public static final String STATEMENT_UPSET_DOCUMENTS
- See Also:
- Constant Field Values
-
STATEMENT_UPSET_DOCUMENTS_DATA
public static final String STATEMENT_UPSET_DOCUMENTS_DATA
- See Also:
- Constant Field Values
-
STATEMENT_UPSET_SNAPSHOTS_BY_DOCUMENT
public static final String STATEMENT_UPSET_SNAPSHOTS_BY_DOCUMENT
- See Also:
- Constant Field Values
-
STATEMENT_SELECT_SNAPSHOT
public static final String STATEMENT_SELECT_SNAPSHOT
- See Also:
- Constant Field Values
-
STATEMENT_SELECT_METADATA
public static final String STATEMENT_SELECT_METADATA
- See Also:
- Constant Field Values
-
STATEMENT_SELECT_SNAPSHOT_ID
public static final String STATEMENT_SELECT_SNAPSHOT_ID
- See Also:
- Constant Field Values
-
STATEMENT_SELECT_MD5
public static final String STATEMENT_SELECT_MD5
- See Also:
- Constant Field Values
-
STATEMENT_SELECT_DOCUMENTS
public static final String STATEMENT_SELECT_DOCUMENTS
- See Also:
- Constant Field Values
-
STATEMENT_SELECT_DOCUMENTS_DATA
public static final String STATEMENT_SELECT_DOCUMENTS_DATA
- See Also:
- Constant Field Values
-
STATEMENT_SELECT_SNAPSHOTS_BY_DOCUMENT
public static final String STATEMENT_SELECT_SNAPSHOTS_BY_DOCUMENT
- See Also:
- Constant Field Values
-
STATEMENT_SELECT_SNAPSHOTS_BY_UNIQUEID
public static final String STATEMENT_SELECT_SNAPSHOTS_BY_UNIQUEID
- See Also:
- Constant Field Values
-
STATEMENT_SELECT_SNAPSHOTS_BY_MODIFIED
public static final String STATEMENT_SELECT_SNAPSHOTS_BY_MODIFIED
- See Also:
- Constant Field Values
-
STATEMENT_DELETE_SNAPSHOTS
public static final String STATEMENT_DELETE_SNAPSHOTS
- See Also:
- Constant Field Values
-
STATEMENT_DELETE_SNAPSHOTS_BY_MODIFIED
public static final String STATEMENT_DELETE_SNAPSHOTS_BY_MODIFIED
- See Also:
- Constant Field Values
-
STATEMENT_DELETE_SNAPSHOTS_BY_UNIQUEID
public static final String STATEMENT_DELETE_SNAPSHOTS_BY_UNIQUEID
- See Also:
- Constant Field Values
-
STATEMENT_DELETE_SNAPSHOTS_BY_DOCUMENT
public static final String STATEMENT_DELETE_SNAPSHOTS_BY_DOCUMENT
- See Also:
- Constant Field Values
-
STATEMENT_DELETE_DOCUMENTS_DATA
public static final String STATEMENT_DELETE_DOCUMENTS_DATA
- See Also:
- Constant Field Values
-
STATEMENT_DELETE_DOCUMENTS
public static final String STATEMENT_DELETE_DOCUMENTS
- See Also:
- Constant Field Values
-
events
@Inject protected javax.enterprise.event.Event<ArchiveEvent> events
-
-
Method Detail
-
saveSnapshot
public void saveSnapshot(org.imixs.workflow.ItemCollection snapshot) throws ArchiveExceptionThis 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 objectsession- - 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 idsession- - 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 idmergeDocuments- - 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 resultdescending- - 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 ArchiveExceptionThis 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 ArchiveExceptionThis 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 ArchiveExceptionThis 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 ArchiveExceptionConverts 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 ArchiveExceptionConverts 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 + timestampWe 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:
-
-