Class AnnotationRepository

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

    public class AnnotationRepository
    extends SQLiteBacked
    This class leverages a SQLite database file to export and import annotations between Nuix cases.
    • Constructor Summary

      Constructors 
      Constructor Description
      AnnotationRepository​(java.io.File databaseFile)
      Creates a new instance associated to the specified SQLite DB file.
      AnnotationRepository​(java.lang.String databaseFile)
      Creates a new instance associated to the specified SQLite DB file.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void abort()
      Signals that you wish to abort.
      void applyMarkupsFromDatabaseToCase​(nuix.Case nuixCase, boolean addToExistingMarkupSet, AnnotationMatchingMethod matchingMethod)
      Applies markups present in the SQLite DB file associated to this instance to the provided Nuix case.
      void applyTagsFromDatabaseToCase​(nuix.Case nuixCase, AnnotationMatchingMethod matchingMethod)
      Applies tags to items in the provided case based on tag records in the DB file associated to this instance.
      boolean getAlwaysCreateTagOnImport()
      Gets whether a tag should always be created even when the source case had no items associated to that tag.
      long getItemId​(nuix.Item item)
      Gets the sequentially assigned ID value from the Item table for a given item based on its GUID.
      long getItemMarkupCount()
      Gets the number of markups present in the ItemMarkup table.
      long getMarkupSetId​(nuix.MarkupSet markupSet)
      Gets the sequentially assigned ID value from the MarkupSet table for a given markup.
      long getTagId​(java.lang.String tagName)
      Gets the sequentially assigned ID value from the Tag table for a given tag name.
      java.util.List<java.lang.String> getTagsForGuid​(java.lang.String guid)
      Queries the DB for the names of tags associated with the provided GUID.
      java.util.List<java.lang.String> getTagsForMd5​(java.lang.String md5)
      Queries the DB for the names of tags associated with the provided MD5.
      void setAlwaysCreateTagOnImport​(boolean alwaysCreateTagOnImport)
      Sets whether a tag should always be created even when the source case had no items associated to that tag.
      void storeAllMarkupSets​(nuix.Case nuixCase)
      Stores all markup sets found in the provided case to the SQLite DB file.
      void storeAllTags​(nuix.Case nuixCase)
      Stores all tags present in the provided case as records in the DB file.
      void storeMarkupSet​(nuix.Case nuixCase, nuix.MarkupSet markupSet)
      Stores a particular markup set present in the provided Nuix case.
      void storeTag​(nuix.Case nuixCase, java.lang.String tagName)
      Stores a specific tag present in the provided case as records in the DB file.
      void whenMessageLogged​(java.util.function.Consumer<java.lang.String> callback)
      Allows you to provide a callback which will be invoked when this instance emits a log message.
      void whenProgressUpdated​(java.util.function.BiConsumer<java.lang.Integer,​java.lang.Integer> callback)
      Allows you to provide a callback which will be invoked when this instance emits a progress update.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AnnotationRepository

        public AnnotationRepository​(java.lang.String databaseFile)
                             throws java.sql.SQLException
        Creates a new instance associated to the specified SQLite DB file. File will be created if it does not already exist.
        Parameters:
        databaseFile - The SQLite database file to use.
        Throws:
        java.sql.SQLException - Thrown if there are errors while interacting with the SQLite DB file.
      • AnnotationRepository

        public AnnotationRepository​(java.io.File databaseFile)
                             throws java.sql.SQLException
        Creates a new instance associated to the specified SQLite DB file. File will be created if it does not already exist.
        Parameters:
        databaseFile - The SQLite database file to use.
        Throws:
        java.sql.SQLException - Thrown if there are errors while interacting with the SQLite DB file.
    • Method Detail

      • whenMessageLogged

        public void whenMessageLogged​(java.util.function.Consumer<java.lang.String> callback)
        Allows you to provide a callback which will be invoked when this instance emits a log message.
        Parameters:
        callback - The callback to receive logged messages
      • whenProgressUpdated

        public void whenProgressUpdated​(java.util.function.BiConsumer<java.lang.Integer,​java.lang.Integer> callback)
        Allows you to provide a callback which will be invoked when this instance emits a progress update.
        Parameters:
        callback - The callback to invoke when progress is updated
      • storeAllMarkupSets

        public void storeAllMarkupSets​(nuix.Case nuixCase)
                                throws java.io.IOException,
                                       java.sql.SQLException
        Stores all markup sets found in the provided case to the SQLite DB file.
        Parameters:
        nuixCase - The Nuix case to record markup sets from.
        Throws:
        java.io.IOException - Thrown most likely if there was an issue searching or retrieving printed pages of and item.
        java.sql.SQLException - Thrown if anything goes wrong interacting with the SQLite database file.
      • getItemId

        public long getItemId​(nuix.Item item)
                       throws java.sql.SQLException
        Gets the sequentially assigned ID value from the Item table for a given item based on its GUID. Will attempt to get this from a cache first.
        Parameters:
        item - The item to retrieve the DB ID number for.
        Returns:
        The DB ID number for the given item, based on finding a record in the Item table with a matching GUID.
        Throws:
        java.sql.SQLException - Thrown if there are errors while interacting with the SQLite DB file.
      • getMarkupSetId

        public long getMarkupSetId​(nuix.MarkupSet markupSet)
                            throws java.sql.SQLException
        Gets the sequentially assigned ID value from the MarkupSet table for a given markup. Will attempt to get this from a cache first.
        Parameters:
        markupSet - The markup set to find the DB ID for.
        Returns:
        The DB ID number for the given markup set, based on finding a record in the MarkupSet table with a matching name.
        Throws:
        java.sql.SQLException - Thrown if there are errors while interacting with the SQLite DB file.
      • getTagId

        public long getTagId​(java.lang.String tagName)
                      throws java.sql.SQLException
        Gets the sequentially assigned ID value from the Tag table for a given tag name. Will attempt to get this from a cache first.
        Parameters:
        tagName - Name of the tag you wish to get the ID of.
        Returns:
        The DB ID number for the given Tag, based on finding a record in the Tag table with a matching name.
        Throws:
        java.sql.SQLException - Thrown if there are errors while interacting with the SQLite DB file.
      • storeTag

        public void storeTag​(nuix.Case nuixCase,
                             java.lang.String tagName)
                      throws java.io.IOException,
                             java.sql.SQLException
        Stores a specific tag present in the provided case as records in the DB file.
        Parameters:
        nuixCase - The Nuix case that the specified tag is present in.
        tagName - The name of the tag in the specified case to store in the DB file.
        Throws:
        java.io.IOException - Thrown if a search error occurs.
        java.sql.SQLException - Thrown if there are errors while interacting with the SQLite DB file.
      • storeAllTags

        public void storeAllTags​(nuix.Case nuixCase)
                          throws java.io.IOException,
                                 java.sql.SQLException
        Stores all tags present in the provided case as records in the DB file.
        Parameters:
        nuixCase - The Nuix case to record tags from.
        Throws:
        java.io.IOException - Thrown if a search error occurs.
        java.sql.SQLException - Thrown if there are errors while interacting with the SQLite DB file.
      • applyTagsFromDatabaseToCase

        public void applyTagsFromDatabaseToCase​(nuix.Case nuixCase,
                                                AnnotationMatchingMethod matchingMethod)
                                         throws java.sql.SQLException
        Applies tags to items in the provided case based on tag records in the DB file associated to this instance.
        Parameters:
        nuixCase - The case in which items will be tagged.
        matchingMethod - Determines how a record in the DB file is associated to an item in the case to apply tags to it.
        Throws:
        java.sql.SQLException - Thrown if there are errors while interacting with the SQLite DB file.
      • storeMarkupSet

        public void storeMarkupSet​(nuix.Case nuixCase,
                                   nuix.MarkupSet markupSet)
                            throws java.io.IOException,
                                   java.sql.SQLException
        Stores a particular markup set present in the provided Nuix case.
        Parameters:
        nuixCase - The Nuix case containing the provided markup set.
        markupSet - The specific markup set to store.
        Throws:
        java.io.IOException - Thrown most likely if there was an issue searching or retrieving printed pages of and item.
        java.sql.SQLException - Thrown if anything goes wrong interacting with the SQLite database file.
      • applyMarkupsFromDatabaseToCase

        public void applyMarkupsFromDatabaseToCase​(nuix.Case nuixCase,
                                                   boolean addToExistingMarkupSet,
                                                   AnnotationMatchingMethod matchingMethod)
                                            throws java.sql.SQLException
        Applies markups present in the SQLite DB file associated to this instance to the provided Nuix case.
        Parameters:
        nuixCase - The Nuix case to apply the DB file markups to.
        addToExistingMarkupSet - Whether to append marukps to existing markup sets of the the same name or create a new markup set with a suffixed name.
        matchingMethod - Specifies whether to match records in the DB file to item in the case by using GUID or MD5.
        Throws:
        java.sql.SQLException - Thrown if there are errors while interacting with the SQLite DB file.
      • getTagsForMd5

        public java.util.List<java.lang.String> getTagsForMd5​(java.lang.String md5)
                                                       throws java.sql.SQLException
        Queries the DB for the names of tags associated with the provided MD5.
        Parameters:
        md5 - The MD5 to find the associated tags of.
        Returns:
        A list of 0 or more Tag names associated with the specified MD5.
        Throws:
        java.sql.SQLException - Thrown if there are errors while interacting with the SQLite DB file.
      • getTagsForGuid

        public java.util.List<java.lang.String> getTagsForGuid​(java.lang.String guid)
                                                        throws java.sql.SQLException
        Queries the DB for the names of tags associated with the provided GUID.
        Parameters:
        guid - The GUID to find the associated tags of.
        Returns:
        A list of 0 or more Tag names associated with the specified GUID.
        Throws:
        java.sql.SQLException - Thrown if there are errors while interacting with the SQLite DB file.
      • getItemMarkupCount

        public long getItemMarkupCount()
                                throws java.sql.SQLException
        Gets the number of markups present in the ItemMarkup table.
        Returns:
        The number of markup records present in the ItemMarkup table of the DB file.
        Throws:
        java.sql.SQLException - Thrown if there are errors while interacting with the SQLite DB file.
      • abort

        public void abort()
        Signals that you wish to abort. Export and import logic test for the abort signal in various loops and will cut short their iteration when the abort signal has been set.
      • getAlwaysCreateTagOnImport

        public boolean getAlwaysCreateTagOnImport()
        Gets whether a tag should always be created even when the source case had no items associated to that tag.
        Returns:
        True if tag should be created during import, even if no items are associated.
      • setAlwaysCreateTagOnImport

        public void setAlwaysCreateTagOnImport​(boolean alwaysCreateTagOnImport)
        Sets whether a tag should always be created even when the source case had no items associated to that tag.
        Parameters:
        alwaysCreateTagOnImport - True if tag should be created during import, even if no items are associated.