diff --git a/droid-export-interfaces/src/main/java/uk/gov/nationalarchives/droid/export/interfaces/ExportDetails.java b/droid-export-interfaces/src/main/java/uk/gov/nationalarchives/droid/export/interfaces/ExportDetails.java index fa5da4328..094b8b6d5 100644 --- a/droid-export-interfaces/src/main/java/uk/gov/nationalarchives/droid/export/interfaces/ExportDetails.java +++ b/droid-export-interfaces/src/main/java/uk/gov/nationalarchives/droid/export/interfaces/ExportDetails.java @@ -49,6 +49,16 @@ public final class ExportDetails { private final boolean quoteAllFields; private final String columnsToWrite; private final String exportTemplatePath; + + /** + * Private constructor. The consumer can get the ExportDetails instance using the ExportDetailsBuilder. + * @param exportOptions whether it is a "per row" export or "per format" export + * @param outputEncoding encoding to be used + * @param bomFlag whether to use BOM + * @param quoteAllFields whether the export fields should be enclosed in double quotes + * @param columnsToWrite List of columns to write + * @param exportTemplatePath absolute path to an export template, if one is being used. + */ private ExportDetails(ExportOptions exportOptions, String outputEncoding, boolean bomFlag, boolean quoteAllFields, String columnsToWrite, String exportTemplatePath) { this.exportOptions = exportOptions; this.outputEncoding = outputEncoding; @@ -102,6 +112,9 @@ public String getExportTemplatePath() { return exportTemplatePath; } + /** + * Builder class to build the ExportDetails as a fluent API. + */ public static class ExportDetailsBuilder { private ExportOptions exportOptions = ExportOptions.ONE_ROW_PER_FILE; private String outputEncoding; diff --git a/droid-export/src/main/java/uk/gov/nationalarchives/droid/export/template/ExportTemplateImpl.java b/droid-export/src/main/java/uk/gov/nationalarchives/droid/export/template/ExportTemplateImpl.java index d10128c7a..ff9cac07e 100644 --- a/droid-export/src/main/java/uk/gov/nationalarchives/droid/export/template/ExportTemplateImpl.java +++ b/droid-export/src/main/java/uk/gov/nationalarchives/droid/export/template/ExportTemplateImpl.java @@ -37,25 +37,15 @@ import java.util.HashMap; import java.util.Map; +/** + * Implementation of ExportTemplate. + */ public class ExportTemplateImpl implements ExportTemplate { private final Map columnOrderMap = new HashMap<>(); - //CHECKSTYLE:OFF - No need to worry about magic numbers here for now, until UI is all wired up - public ExportTemplateImpl() { - columnOrderMap.put(0, new ProfileResourceNodeColumnDef("ID", "Identifier")); - columnOrderMap.put(1, new ProfileResourceNodeColumnDef("FILE_PATH", "Path")); - columnOrderMap.put(2, new ProfileResourceNodeColumnDef("SIZE", "Size")); - columnOrderMap.put(3, new ProfileResourceNodeColumnDef("HASH", "HASH")); - columnOrderMap.put(4, new ProfileResourceNodeColumnDef("PUID", "Puid")); - columnOrderMap.put(5, new ConstantStringColumnDef("Welsh", "Language")); - columnOrderMap.put(6, new DataModifierColumnDef(new ProfileResourceNodeColumnDef("MIME_TYPE", "Mime Type"), ExportTemplateColumnDef.DataModification.UCASE)); - } - public ExportTemplateImpl(final Map columnOrder) { this.columnOrderMap.putAll(columnOrder); } - //CHECKSTYLE:ON - public Map getColumnOrderMap() { return columnOrderMap; } diff --git a/droid-swing-ui/src/main/java/uk/gov/nationalarchives/droid/gui/export/ExportAction.java b/droid-swing-ui/src/main/java/uk/gov/nationalarchives/droid/gui/export/ExportAction.java index 3344fdf74..c4093e8ab 100644 --- a/droid-swing-ui/src/main/java/uk/gov/nationalarchives/droid/gui/export/ExportAction.java +++ b/droid-swing-ui/src/main/java/uk/gov/nationalarchives/droid/gui/export/ExportAction.java @@ -229,15 +229,13 @@ public void setExportTemplatePath(String exportTemplatePath) { */ private ExportDetails getExportDetails() { ExportDetails.ExportDetailsBuilder builder = new ExportDetails.ExportDetailsBuilder(); - ExportDetails details = builder.withExportOptions(options) - .withOutpuEncoding(outputEncoding) //default + return builder.withExportOptions(options) + .withOutpuEncoding(outputEncoding) .withBomFlag(bom) .withQuotingAllFields(quoteAllFields) .withColumnsToWrite(columnsToWrite) .withExportTemplatePath(exportTemplatePath) .build(); - - return details; } }