Skip to content

Commit

Permalink
cleanup and rebuild javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
JuicyDragon committed Oct 12, 2022
1 parent 3982b8a commit 59d5331
Show file tree
Hide file tree
Showing 269 changed files with 63,726 additions and 30,927 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ public void storeAllTags(Case nuixCase) throws IOException, SQLException {
* @param nuixCase The case in which items will be tagged.
* @param matchingMethod Determines how a record in the DB file is associated to an item in the case to apply tags to it.
* @throws SQLException Thrown if there are errors while interacting with the SQLite DB file.
* @throws Thrown by Nuix if there is something
*/
public void applyTagsFromDatabaseToCase(Case nuixCase, AnnotationMatchingMethod matchingMethod) throws SQLException {
// Will reuse this multiple times to provide values to be bound to prepared SQL statements later
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import nuix.MarkupSet;

/***
* Provides settings regarding bulk redaction performed by {@link BulkRedactor#findAndMarkup(Case, BulkRedactorSettings, Collection)}.
* Provides settings regarding bulk redaction performed by {@link BulkRedactor#findAndMarkup(Case, BulkRedactorSettings, Collection, int)}.
* @author Jason Wells
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public String render(Item item, Map<String,Object> data){
return (String) container.callMethod("", "render", new Object[]{item,toSend});
}

public void renderToFile(Item item, File outputFile, Map<String,Object> data) throws Exception{
public void renderToFile(Item item, File outputFile, Map<String,Object> data) throws Exception {
FileOutputStream fos = null;
BufferedWriter bw = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -267,4 +268,36 @@ public boolean itemsAreSiblings(Item a, Item b){

return true;
}

/***
* Gets items and sibling items within a certain ordinal distance.
* @param items The items to obtain the neighboring siblings of
* @param itemsBefore How many siblings before each item to include
* @param itemsAfter How many siblings after each item to include
* @return A new list of items which includes both input items and neighboring siblings, sorted by position
*/
public List<Item> getItemsAndNeighboringSiblings(List<Item> items, int itemsBefore, int itemsAfter){
if(itemsBefore < 0) { itemsBefore = 0; }
if(itemsAfter < 0) { itemsAfter = 0; }

if(items.size() < 1) { return Collections.emptyList(); }
else {
Set<Item> tempSet = new HashSet<Item>();
for(Item item : items) {
Item parent = item.getParent();
List<Item> siblings = parent.getChildren();
int itemIndex = siblings.indexOf(item);
int first = itemIndex - itemsBefore;
int last = itemIndex + itemsAfter;
if(first < 0) { first = 0; }
if(last > items.size() - 1) { last = items.size() - 1; }
for (int i = first; i <= last; i++) {
tempSet.add(items.get(i));
}
}
List<Item> result = new ArrayList<Item>();
result.addAll(tempSet);
return SuperUtilities.getItemUtility().sortItemsByPosition(result);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public void setDigestCustomField(String digestCustomField) {

/***
* 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 callin {@link #setDigestCustomField(String)) and it has a value, that value will
* if an item has the custom field specified by calling {@link #setDigestCustomField(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.
* @return Whether an existing value in the specified custom metadata field should be used when present
*/
Expand All @@ -339,9 +339,9 @@ public boolean getUseExistingValueWhenPresent() {

/***
* 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 calling {@link #setDigestCustomField(String)) and it has a value, that value will
* if an item has the custom field specified by calling {@link #setDigestCustomField(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.
* @param useExistingValueWhenPresent
* @param useExistingValueWhenPresent whether an existing value in the specified custom metadata field should be used if present
*/
public void setUseExistingValueWhenPresent(boolean useExistingValueWhenPresent) {
this.useExistingValueWhenPresent = useExistingValueWhenPresent;
Expand Down
46 changes: 44 additions & 2 deletions Java/src/main/java/com/nuix/superutilities/misc/ZipHelper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.nuix.superutilities.misc;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand All @@ -8,10 +10,45 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
import org.apache.commons.compress.archivers.sevenz.SevenZMethod;
import org.apache.commons.compress.archivers.sevenz.SevenZOutputFile;
import org.apache.commons.io.IOUtils;
import org.apache.jena.ext.com.google.common.primitives.Ints;

public class ZipHelper {

public static void compressDirectoryToSevenZipFile(String directory, String sevenZipFile) throws IOException {
SevenZOutputFile sevenZipOutput = new SevenZOutputFile(new File(sevenZipFile));
sevenZipOutput.setContentCompression(SevenZMethod.DEFLATE);
compressDirectoryToSevenZipFile(directory, directory, sevenZipOutput);
sevenZipOutput.finish();
sevenZipOutput.close();
}

private static void compressDirectoryToSevenZipFile(String rootDir, String sourceDir, SevenZOutputFile sevenZipOutput) throws IOException {
for (File file : new File(sourceDir).listFiles()) {
if (file.isDirectory()) {
compressDirectoryToSevenZipFile(rootDir, sourceDir + File.separator + file.getName(), sevenZipOutput);
} else {
String dir = sourceDir.replace(rootDir, "");
SevenZArchiveEntry entry = null;
if (!dir.trim().isEmpty()) {
entry = sevenZipOutput.createArchiveEntry(file,dir + File.separator + file.getName());
} else {
entry = sevenZipOutput.createArchiveEntry(file,file.getName());
}
sevenZipOutput.putArchiveEntry(entry);
FileInputStream in = new FileInputStream(sourceDir + File.separator + file.getName());
BufferedInputStream bufferedIn = new BufferedInputStream(in);
sevenZipOutput.write(bufferedIn);
bufferedIn.close();
in.close();
sevenZipOutput.closeArchiveEntry();
}
}
}

/***
* Compresses the contents of the given directory (files and sub-directories) in to a Zip file.
* @param directory The directory to archive into the Zip file.
Expand All @@ -23,8 +60,12 @@ public class ZipHelper {
@SuppressWarnings("deprecation")
public static void compressDirectoryToZipFile(String directory, String zipFile, int compressionLevel) throws IOException, FileNotFoundException {
ZipOutputStream zipStream = null;
FileOutputStream fileOutStream = null;
BufferedOutputStream bufferedOutStream = null;
try{
zipStream = new ZipOutputStream(new FileOutputStream(zipFile));
fileOutStream = new FileOutputStream(zipFile);
bufferedOutStream = new BufferedOutputStream(fileOutStream);
zipStream = new ZipOutputStream(bufferedOutStream);
zipStream.setLevel(Ints.constrainToRange(compressionLevel, 0, 9));
compressDirectoryToZipfile(directory,directory,zipStream);
} finally {
Expand Down Expand Up @@ -57,7 +98,8 @@ private static void compressDirectoryToZipfile(String rootDir, String sourceDir,

out.putNextEntry(entry);
FileInputStream in = new FileInputStream(sourceDir + File.separator + file.getName());
IOUtils.copy(in, out);
BufferedInputStream bufferedIn = new BufferedInputStream(in);
IOUtils.copy(bufferedIn, out);
IOUtils.closeQuietly(in);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public PatternInfo(String title, String expression){
/***
* Compiles the regular expression String provided into a Java Pattern object
* @param caseSensitive Whether it should be case sensitive
* @param multiline Whether the multi-line matching flag should be set
* @param dotAll Whether the dot matches all flag should be set
*/
public void compile(boolean caseSensitive, boolean multiline, boolean dotAll){
if(pattern == null){
Expand Down Expand Up @@ -53,8 +55,8 @@ public String getExpression() {
}

/***
* Gets the compiled Pattern object. Note this will return null until {@link #compile(boolean)} is called.
* @return The compiled Pattern object or null if {@link #compile(boolean)} has not yet been called.
* Gets the compiled Pattern object. Note this will return null until {@link #compile(boolean, boolean, boolean)} is called.
* @return The compiled Pattern object or null if {@link #compile(boolean, boolean, boolean)} has not yet been called.
*/
public Pattern getPattern() {
return pattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.stream.Collectors;

import org.apache.log4j.Logger;
import org.joda.time.DateTime;

import com.aspose.cells.BackgroundType;
import com.aspose.cells.Color;
Expand All @@ -32,6 +33,40 @@ public class IntersectionReport {

private static Logger logger = Logger.getLogger(IntersectionReport.class);

/***
* Analyzes batch loads in the given case, determining which have a loaded datetime that falls
* within the specified range, returning the GUIDs of the batch loads which qualify.
* @param nuixCase The case to analyze
* @param min The minimum date time, can be null
* @param max The maximum date time, can be null
* @return Returns a list of zero or more GUIDs for the batch loads loaded within the given date range
*/
public static List<String> findBatchLoadsInDateRange(Case nuixCase, DateTime min, DateTime max) {
List<String> inRangeBatchLoadGuids = new ArrayList<String>();
List<BatchLoadDetails> allBatchLoads = nuixCase.getBatchLoads();

// Filter all batch loads by whether their loaded date falls within
// the range specifies by the min/max values
for(BatchLoadDetails bld : allBatchLoads) {
boolean satisfiesMin = true;
boolean satisfiesMax = true;

if(min != null) {
satisfiesMin = bld.getLoaded().isAfter(min);
}

if(max != null) {
satisfiesMax = bld.getLoaded().isBefore(max);
}

if(satisfiesMin && satisfiesMax) {
inRangeBatchLoadGuids.add(bld.getBatchId());
}
}

return inRangeBatchLoadGuids;
}

private SimpleXlsx xlsx = null;

private Style rowCategoryLabelStyle = null;
Expand Down Expand Up @@ -163,27 +198,8 @@ public void generate(Case nuixCase, String sheetName, IntersectionReportSheetCon
// in the case and filter to those within our date range. Using that filtered set we then get their batch
// load GUIDs and use that to attach additional scope query for those batch loads.
if(sheetConfig.hasBatchLoadDateCriteria()) {
List<String> inRangeBatchLoadGuids = new ArrayList<String>();
List<BatchLoadDetails> allBatchLoads = nuixCase.getBatchLoads();

// Filter all batch loads by whether their loaded date falls within
// the range specifies by the min/max values
for(BatchLoadDetails bld : allBatchLoads) {
boolean satisfiesMin = true;
boolean satisfiesMax = true;

if(sheetConfig.getBatchLoadMinDate() != null) {
satisfiesMin = bld.getLoaded().isAfter(sheetConfig.getBatchLoadMinDate());
}

if(sheetConfig.getBatchLoadMaxDate() != null) {
satisfiesMax = bld.getLoaded().isBefore(sheetConfig.getBatchLoadMaxDate());
}

if(satisfiesMin && satisfiesMax) {
inRangeBatchLoadGuids.add(bld.getBatchId());
}
}
List<String> inRangeBatchLoadGuids = findBatchLoadsInDateRange(nuixCase,
sheetConfig.getBatchLoadMinDate(),sheetConfig.getBatchLoadMaxDate());

String batchLoadGuidQuery = "";
if(inRangeBatchLoadGuids.size() > 0) {
Expand Down
Loading

0 comments on commit 59d5331

Please sign in to comment.