Class AnnotationHistoryRepository

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class AnnotationHistoryRepository
    extends java.lang.Object
    implements java.io.Closeable
    Class for recording annotation in a source case and replaying on a destination case. GUID is used to record items in source case and match items in destination case.
    • Constructor Detail

      • AnnotationHistoryRepository

        public AnnotationHistoryRepository​(java.io.File databaseFile)
                                    throws java.sql.SQLException
        Creates a new instance against the given and database file. If the database file does not already exist it will be created and initialized.
        Parameters:
        databaseFile - The database file to record annotations to or playback annotations from
        Throws:
        java.sql.SQLException - If the SQL bits throw an error
      • AnnotationHistoryRepository

        public AnnotationHistoryRepository​(java.lang.String databaseFile)
                                    throws java.sql.SQLException
        Creates a new instance against the given and database file. If the database file does not already exist it will be created and initialized.
        Parameters:
        databaseFile - The database file to record annotations to or playback annotations from
        Throws:
        java.sql.SQLException - If the SQL bits throw an error
    • Method Detail

      • getIntegerInfo

        public java.lang.Long getIntegerInfo​(java.lang.String name)
                                      throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • setIntegerInfo

        public void setIntegerInfo​(java.lang.String name,
                                   java.lang.Long value)
                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getTextInfo

        public java.lang.String getTextInfo​(java.lang.String name)
                                     throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • setTextInfo

        public void setTextInfo​(java.lang.String name,
                                java.lang.String value)
                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • setSyncPointToNow

        public void setSyncPointToNow()
                               throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • setSyncPointFromDestinationCaseLastEvent

        public void setSyncPointFromDestinationCaseLastEvent​(nuix.Case nuixCase)
                                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setSyncPoint

        public void setSyncPoint​(org.joda.time.DateTime dateTime)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • executeUpdate

        public int executeUpdate​(java.lang.String sql,
                                 java.util.List<java.lang.Object> data)
                          throws java.sql.SQLException
        Executes an update query against the SQLite database file
        Parameters:
        sql - The SQL to execute
        data - Optional list of associated data, can be null
        Returns:
        Count of affected records
        Throws:
        java.sql.SQLException - If the SQL bits throw an error
      • executeUpdate

        public int executeUpdate​(java.lang.String sql,
                                 java.lang.Object... data)
                          throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • executeUpdate

        public int executeUpdate​(java.lang.String sql)
                          throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • executeInsert

        public void executeInsert​(java.lang.String sql,
                                  java.util.List<java.lang.Object> data)
                           throws java.sql.SQLException
        Executes an insert query against the SQLite database file
        Parameters:
        sql - The SQL to execute
        data - Optional list of associated data, can be null
        Throws:
        java.sql.SQLException - If the SQL bits throw an error
      • executeInsert

        public void executeInsert​(java.lang.String sql,
                                  java.lang.Object... data)
                           throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • executeLongScalar

        public java.lang.Long executeLongScalar​(java.lang.String sql,
                                                java.lang.Object... data)
                                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • executeLongScalar

        public java.lang.Long executeLongScalar​(java.lang.String sql,
                                                java.util.List<java.lang.Object> data)
                                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • executeLongScalar

        public java.lang.Long executeLongScalar​(java.lang.String sql)
                                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • executeStringScalar

        public java.lang.String executeStringScalar​(java.lang.String sql,
                                                    java.lang.Object... data)
                                             throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • executeStringScalar

        public java.lang.String executeStringScalar​(java.lang.String sql,
                                                    java.util.List<java.lang.Object> data)
                                             throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • executeStringScalar

        public java.lang.String executeStringScalar​(java.lang.String sql)
                                             throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • executeScalar

        public <T> T executeScalar​(java.lang.String sql,
                                   java.lang.Object... data)
                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • executeQuery

        public void executeQuery​(java.lang.String sql,
                                 java.util.List<java.lang.Object> data,
                                 java.util.function.Consumer<java.sql.ResultSet> resultConsumer)
                          throws java.sql.SQLException
        Executes a query which is expected to return row data, providing the result set to the provided callback.
        Parameters:
        sql - The SQL query to execute
        data - Optional list of associated data, can be null
        resultConsumer - Callback which will be provided the result set. This is where you provide code to make use of the results.
        Throws:
        java.sql.SQLException - If the SQL bits throw an error
      • getTotalEventCount

        public long getTotalEventCount()
                                throws java.sql.SQLException
        Returns the total number of event entries in the database file
        Returns:
        Total event row count
        Throws:
        java.sql.SQLException - If the SQL bits throw an error
      • calculateLastDbEventStart

        public org.joda.time.DateTime calculateLastDbEventStart()
                                                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • syncHistory

        public void syncHistory​(nuix.Case nuixCase,
                                AnnotationSyncSettings settings)
                         throws java.io.IOException,
                                java.sql.SQLException
        Records annotation event data to the database file. If there are 0 events currently recorded and snap shot on first sync is enabled (see setSnapshotFirstSync(boolean), true is the default) then this will attempt to make a compacted representation of the state of the annotations in the case. Otherwise this method will iterate every single history event in the case and record it in the database. If the database already contains event entries, instead this method will determine the latest event started date and then query the Nuix case history for all further events started after that point, effectively obtaining and recording all new event history entries not yet recorded in this database.
        Parameters:
        nuixCase - The case to record history events from
        settings - The settings which determine how the sync is performed
        Throws:
        java.io.IOException - If there is an error: creating snapshot, getting case history or converting items into bitamp byte array for DB
        java.sql.SQLException - If the SQL bits throw an error
      • eachRecordedTagEvent

        public void eachRecordedTagEvent​(long startedAfter,
                                         java.util.function.Consumer<TagEvent> callback)
                                  throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • eachRecordedTagEvent

        public void eachRecordedTagEvent​(org.joda.time.DateTime startedAfter,
                                         java.util.function.Consumer<TagEvent> callback)
                                  throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • eachRecordedExclusionEvent

        public void eachRecordedExclusionEvent​(long startedAfter,
                                               java.util.function.Consumer<ExclusionEvent> callback)
                                        throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • eachRecordedExclusionEvent

        public void eachRecordedExclusionEvent​(org.joda.time.DateTime startedAfter,
                                               java.util.function.Consumer<ExclusionEvent> callback)
                                        throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • eachRecordedCustomMetadataEvent

        public void eachRecordedCustomMetadataEvent​(long startedAfter,
                                                    java.util.function.Consumer<CustomMetadataEvent> callback)
                                             throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • eachRecordedCustomMetadataEvent

        public void eachRecordedCustomMetadataEvent​(org.joda.time.DateTime startedAfter,
                                                    java.util.function.Consumer<CustomMetadataEvent> callback)
                                             throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • eachRecordedItemSetEvent

        public void eachRecordedItemSetEvent​(long startedAfter,
                                             java.util.function.Consumer<ItemSetEvent> callback)
                                      throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • eachRecordedItemSetEvent

        public void eachRecordedItemSetEvent​(org.joda.time.DateTime startedAfter,
                                             java.util.function.Consumer<ItemSetEvent> callback)
                                      throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • eachRecordedCustodianEvent

        public void eachRecordedCustodianEvent​(long startedAfter,
                                               java.util.function.Consumer<CustodianEvent> callback)
                                        throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • eachRecordedCustodianEvent

        public void eachRecordedCustodianEvent​(org.joda.time.DateTime startedAfter,
                                               java.util.function.Consumer<CustodianEvent> callback)
                                        throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • eachRecordedProductionSetEvent

        public void eachRecordedProductionSetEvent​(long startedAfter,
                                                   java.util.function.Consumer<ProductionSetEvent> callback)
                                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • eachRecordedProductionSetEvent

        public void eachRecordedProductionSetEvent​(org.joda.time.DateTime startedAfter,
                                                   java.util.function.Consumer<ProductionSetEvent> callback)
                                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getSnapshotFirstSync

        public boolean getSnapshotFirstSync()
        Gets whether a more succinct snapshot should be created in a new database.
        Returns:
        True means the code will attempt to make a snapshot while false means the code will just record all annotation history events.
      • setSnapshotFirstSync

        public void setSnapshotFirstSync​(boolean snapshotFirstSync)
        Sets whether a more succinct snapshot should be created in a new database.
        Parameters:
        snapshotFirstSync - True means the code will attempt to make a snapshot while false means the code will just record all annotation history events.
      • getGuidRefInsertBatchSize

        public int getGuidRefInsertBatchSize()
      • setGuidRefInsertBatchSize

        public void setGuidRefInsertBatchSize​(int guidRefInsertBatchSize)
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException