Package com.nuix.superutilities.misc
Class ProfileDigester
- java.lang.Object
-
- com.nuix.superutilities.misc.ProfileDigester
-
public class ProfileDigester extends java.lang.Object
Provides functionality related to generating an MD5 digest for an item based on a concatenation of the values yielded by a MetadataProfile for a given item.
-
-
Constructor Summary
Constructors Constructor Description ProfileDigester()
ProfileDigester(nuix.MetadataProfile metadataProfile)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description nuix.ItemSet
addItemsToItemSet(nuix.Case nuixCase, java.lang.String itemSetName, java.lang.String deduplicateBy, java.util.Collection<nuix.Item> items)
Adds items to an item set using "Scripted" deduplication, providing a MD5 hash generated from the concatenation of the values yielded by the MetadataProfile associated with this instance.byte[]
generateMd5Bytes(nuix.Item item)
Generates MD5 digest byte array for a given item.java.lang.String
generateMd5String(nuix.Item item)
Generates MD5 digest hex string for a given item.java.lang.String
getDigestCustomField()
Gets the name of the custom metadata field used to record custom digest whengetRecordDigest()
returns true.boolean
getIncludeItemText()
Gets whether this instance should include the item's content text when calculating a digest.nuix.MetadataProfile
getProfile()
Gets the metadata profile used to obtain the values provided to the hash computation.boolean
getRecordDigest()
Gets whether this instance will record the digest used.boolean
getUseExistingValueWhenPresent()
Gets whether an existing value in the specified custom metadata field should be used if present.void
setDigestCustomField(java.lang.String digestCustomField)
Sets the name of the custom metadata field used to record custom digest whengetRecordDigest()
returns true.void
setIncludeItemText(boolean includeItemText)
Sets whether this instance should include the item's content text when calculating a digest.void
setProfile(nuix.MetadataProfile profile)
Sets the metadata profile used to obtain the values provided to the hash computation.void
setRecordDigest(boolean recordDigest)
Sets whether this instance will record the digest used.void
setUseExistingValueWhenPresent(boolean useExistingValueWhenPresent)
Sets whether an existing value in the specified custom metadata field should be used if present.void
whenErrorLogged(java.util.function.BiConsumer<java.lang.String,nuix.Item> callback)
Invoked when an error occurs inaddItemsToItemSet(Case, String, String, Collection)
.void
whenMessageLogged(java.util.function.Consumer<java.lang.String> callback)
Invoked when a message is logged byaddItemsToItemSet(Case, String, String, Collection)
.void
whenProgressUpdated(java.util.function.BiConsumer<java.lang.Integer,java.lang.Integer> callback)
Invoked when progress is updated inaddItemsToItemSet(Case, String, String, Collection)
.
-
-
-
Method Detail
-
whenProgressUpdated
public void whenProgressUpdated(java.util.function.BiConsumer<java.lang.Integer,java.lang.Integer> callback)
Invoked when progress is updated inaddItemsToItemSet(Case, String, String, Collection)
. Provides 2 integers, the first is current progress and the second is total progress.- Parameters:
callback
- Callback to be invoked when progress is updated.
-
whenMessageLogged
public void whenMessageLogged(java.util.function.Consumer<java.lang.String> callback)
Invoked when a message is logged byaddItemsToItemSet(Case, String, String, Collection)
.- Parameters:
callback
- Callback invoked when a message is logged. If callback is not provided, message is instead sent to Nuix log.
-
whenErrorLogged
public void whenErrorLogged(java.util.function.BiConsumer<java.lang.String,nuix.Item> callback)
Invoked when an error occurs inaddItemsToItemSet(Case, String, String, Collection)
. Provides a message String and the item being processed when the error occurred. If callback is not provided, message will instead be sent to Nuix log.- Parameters:
callback
- Callback invoked when an error occurs. If a callback is not provided, message is instead sent to Nuix log as an error.
-
addItemsToItemSet
public nuix.ItemSet addItemsToItemSet(nuix.Case nuixCase, java.lang.String itemSetName, java.lang.String deduplicateBy, java.util.Collection<nuix.Item> items)
Adds items to an item set using "Scripted" deduplication, providing a MD5 hash generated from the concatenation of the values yielded by the MetadataProfile associated with this instance. Additionally can include an items content text in the concatenated values. Effectively this allows you to create an item set where rather than deduplicating by the MD5 Nuix calculated for a given item during ingestion, the values of the given metadata profile are used to determine original/duplicate status of the provided items.- Parameters:
nuixCase
- The Nuix Case containing the items to be deduplicated and where the ItemSet will be created.itemSetName
- Name of item set. If item set already exists, existing item set will be used, if not one will be created. Important: when adding items to an existing item set, it is important that items previously added to that item set were added using this method, the same metadata profile and same setting for includeItemText, otherwise deduplication results are undefined.deduplicateBy
- Valid options are "INDIVIDUAL" and "FAMILY", these settings correspond to the behaviors noted in addItems(Collection<Item> items, Map<?,?> options).items
- The items to add to the item set.- Returns:
- The item set the items were added to.
-
generateMd5Bytes
public byte[] generateMd5Bytes(nuix.Item item) throws java.lang.Exception
Generates MD5 digest byte array for a given item. Digest is generated by digesting concatenation of values yielded by the metadata profile associated with this instance for the given item and optionally including the item's content text. Note that method is synchronized due to: - Reuse of MD5 digester - Some metadata profile fields don't seem to play nice when called concurrently- Parameters:
item
- The item to generate a custom MD5 digest for.- Returns:
- Byte array representation of the MD5 digest
- Throws:
java.lang.Exception
- Most likely if metadata profile has not yet been set for this instance.
-
generateMd5String
public java.lang.String generateMd5String(nuix.Item item) throws java.lang.Exception
Generates MD5 digest hex string for a given item. Digest is generated by digesting values concatenation of values yielded by the metadata profile associated with this instance for the given item and optionally including the item's content text. Internally this method first callsgenerateMd5Bytes(Item)
then converts the result of that method into a hexadecimal string.- Parameters:
item
- The item to generate a custom MD5 digest for.- Returns:
- Hexadecimal string representation of the MD5 digest
- Throws:
java.lang.Exception
- Most likely if metadata profile has not yet been set for this instance.
-
getIncludeItemText
public boolean getIncludeItemText()
Gets whether this instance should include the item's content text when calculating a digest.- Returns:
- Whether this instance should include the item's content text when calculating a digest.
-
setIncludeItemText
public void setIncludeItemText(boolean includeItemText)
Sets whether this instance should include the item's content text when calculating a digest.- Parameters:
includeItemText
- Whether this instance should include the item's content text when calculating a digest.
-
getProfile
public nuix.MetadataProfile getProfile()
Gets the metadata profile used to obtain the values provided to the hash computation.- Returns:
- The metadata profile used to obtain the values provided to the hash computation.
-
setProfile
public void setProfile(nuix.MetadataProfile profile)
Sets the metadata profile used to obtain the values provided to the hash computation.- Parameters:
profile
- The metadata profile used to obtain the values provided to the hash computation.
-
getRecordDigest
public boolean getRecordDigest()
Gets whether this instance will record the digest used.- Returns:
- Whether this instance will record the digest used.
-
setRecordDigest
public void setRecordDigest(boolean recordDigest)
Sets whether this instance will record the digest used.- Parameters:
recordDigest
- Whether this instance will record the digest used.
-
getDigestCustomField
public java.lang.String getDigestCustomField()
Gets the name of the custom metadata field used to record custom digest whengetRecordDigest()
returns true.- Returns:
- Name of the custom metadata field used to record custom digest.
-
setDigestCustomField
public void setDigestCustomField(java.lang.String digestCustomField)
Sets the name of the custom metadata field used to record custom digest whengetRecordDigest()
returns true.- Parameters:
digestCustomField
- Name of the custom metadata field used to record custom digest.
-
getUseExistingValueWhenPresent
public boolean getUseExistingValueWhenPresent()
Gets whether an existing value in the specified custom metadata field should be used if present. When true, if an item has the custom field specified by callingsetDigestCustomField(String)
and it has a value, that value will be used rather than calculating a value. If false the value will always be calculated fresh.- Returns:
- Whether an existing value in the specified custom metadata field should be used when present
-
setUseExistingValueWhenPresent
public void setUseExistingValueWhenPresent(boolean useExistingValueWhenPresent)
Sets whether an existing value in the specified custom metadata field should be used if present. When true, if an item has the custom field specified by callingsetDigestCustomField(String)
and it has a value, that value will be used rather than calculating a value. If false the value will always be calculated fresh.- Parameters:
useExistingValueWhenPresent
- whether an existing value in the specified custom metadata field should be used if present
-
-