diff --git a/extensions/database/src/com/google/refine/extension/database/DatabaseImportController.java b/extensions/database/src/com/google/refine/extension/database/DatabaseImportController.java
index dc900ba82..2e964a364 100644
--- a/extensions/database/src/com/google/refine/extension/database/DatabaseImportController.java
+++ b/extensions/database/src/com/google/refine/extension/database/DatabaseImportController.java
@@ -285,6 +285,7 @@ public class DatabaseImportController implements ImportingController {
job,
new DBQueryResultPreviewReader(job, databaseService, querySource, columns, dbQueryInfo, 100),
querySource,
+ "", // archivefilename
limit,
options,
exceptions
@@ -414,6 +415,7 @@ public class DatabaseImportController implements ImportingController {
job,
new DBQueryResultImportReader(job, databaseService, querySource, columns, dbQueryInfo, getCreateBatchSize()),
querySource,
+ "", //archivefilename,
limit,
options,
exceptions
diff --git a/extensions/gdata/src/com/google/refine/extension/gdata/GDataImporter.java b/extensions/gdata/src/com/google/refine/extension/gdata/GDataImporter.java
index 9792379bb..000264c83 100644
--- a/extensions/gdata/src/com/google/refine/extension/gdata/GDataImporter.java
+++ b/extensions/gdata/src/com/google/refine/extension/gdata/GDataImporter.java
@@ -142,6 +142,7 @@ public class GDataImporter {
job,
new WorksheetBatchRowReader(job, fileSource, service, spreadsheetId, worksheetEntry),
fileSource,
+ "", //archivefilename
limit,
options,
exceptions
diff --git a/extensions/pc-axis/module/scripts/pc-axis-parser-ui.html b/extensions/pc-axis/module/scripts/pc-axis-parser-ui.html
index 472bcc76f..1d1dd0394 100644
--- a/extensions/pc-axis/module/scripts/pc-axis-parser-ui.html
+++ b/extensions/pc-axis/module/scripts/pc-axis-parser-ui.html
@@ -24,7 +24,9 @@
|
|
- |
+ |
+ |
+ |
\ No newline at end of file
diff --git a/extensions/pc-axis/module/scripts/pc-axis-parser-ui.js b/extensions/pc-axis/module/scripts/pc-axis-parser-ui.js
index f95de983c..69f16aba8 100644
--- a/extensions/pc-axis/module/scripts/pc-axis-parser-ui.js
+++ b/extensions/pc-axis/module/scripts/pc-axis-parser-ui.js
@@ -89,6 +89,7 @@ Refine.PCAxisParserUI.prototype.getOptions = function() {
options.skipDataLines = -1;
}
options.includeFileSources = this._optionContainerElmts.includeFileSourcesCheckbox[0].checked;
+ options.includeArchiveFileName = this._optionContainerElmts.includeArchiveFileCheckbox[0].checked;
return options;
};
@@ -120,6 +121,9 @@ Refine.PCAxisParserUI.prototype._initialize = function() {
if (this._config.includeFileSources) {
this._optionContainerElmts.includeFileSourcesCheckbox.prop("checked", true);
}
+ if (this._config.includeArchiveFileName) {
+ this._optionContainerElmts.includeArchiveFileCheckbox.prop("checked", true);
+ }
var onChange = function() {
self._scheduleUpdatePreview();
diff --git a/extensions/pc-axis/src/com/google/refine/pcaxis/PCAxisImporter.java b/extensions/pc-axis/src/com/google/refine/pcaxis/PCAxisImporter.java
index 1b6203b44..7fb1cdf46 100644
--- a/extensions/pc-axis/src/com/google/refine/pcaxis/PCAxisImporter.java
+++ b/extensions/pc-axis/src/com/google/refine/pcaxis/PCAxisImporter.java
@@ -71,6 +71,7 @@ public class PCAxisImporter extends TabularImportingParserBase {
ProjectMetadata metadata,
ImportingJob job,
String fileSource,
+ String archiveFileName,
Reader reader,
int limit,
ObjectNode options,
@@ -88,8 +89,8 @@ public class PCAxisImporter extends TabularImportingParserBase {
TabularImportingParserBase.readTable(
project, metadata, job, dataReader,
- fileSource, limit, options, exceptions);
+ fileSource, archiveFileName, limit, options, exceptions);
- super.parseOneFile(project, metadata, job, fileSource, reader, limit, options, exceptions);
+ super.parseOneFile(project, metadata, job, fileSource, archiveFileName, reader, limit, options, exceptions);
}
}
diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/WikidataRefineTest.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/WikidataRefineTest.java
index 2e61b413d..60321c767 100644
--- a/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/WikidataRefineTest.java
+++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/WikidataRefineTest.java
@@ -46,7 +46,7 @@ public class WikidataRefineTest extends PowerMockTestCase {
SeparatorBasedImporter importer = new SeparatorBasedImporter();
List exceptions = new ArrayList();
- importer.parseOneFile(project, metadata, job, "filesource", new StringReader(input), -1, options, exceptions);
+ importer.parseOneFile(project, metadata, job, "filesource", "archivefile", new StringReader(input), -1, options, exceptions);
project.update();
ProjectManager.singleton.registerProject(project, metadata);
diff --git a/main/src/com/google/refine/importers/ExcelImporter.java b/main/src/com/google/refine/importers/ExcelImporter.java
index 1c2b6225d..aae21528b 100644
--- a/main/src/com/google/refine/importers/ExcelImporter.java
+++ b/main/src/com/google/refine/importers/ExcelImporter.java
@@ -129,6 +129,7 @@ public class ExcelImporter extends TabularImportingParserBase {
ProjectMetadata metadata,
ImportingJob job,
String fileSource,
+ String archiveFileName,
InputStream inputStream,
int limit,
ObjectNode options,
@@ -221,14 +222,14 @@ public class ExcelImporter extends TabularImportingParserBase {
metadata,
job,
dataReader,
- fileSource + "#" + sheet.getSheetName(),
+ fileSource + "#" + sheet.getSheetName(), archiveFileName,
limit,
options,
exceptions
);
}
- super.parseOneFile(project, metadata, job, fileSource, inputStream, limit, options, exceptions);
+ super.parseOneFile(project, metadata, job, fileSource, archiveFileName, inputStream, limit, options, exceptions);
}
static protected Cell extractCell(org.apache.poi.ss.usermodel.Cell cell) {
diff --git a/main/src/com/google/refine/importers/FixedWidthImporter.java b/main/src/com/google/refine/importers/FixedWidthImporter.java
index f389dbffa..63c978d07 100644
--- a/main/src/com/google/refine/importers/FixedWidthImporter.java
+++ b/main/src/com/google/refine/importers/FixedWidthImporter.java
@@ -83,6 +83,7 @@ public class FixedWidthImporter extends TabularImportingParserBase {
ProjectMetadata metadata,
ImportingJob job,
String fileSource,
+ String archiveFileName,
Reader reader,
int limit,
ObjectNode options,
@@ -132,9 +133,9 @@ public class FixedWidthImporter extends TabularImportingParserBase {
}
};
- TabularImportingParserBase.readTable(project, metadata, job, dataReader, fileSource, limit, options, exceptions);
+ TabularImportingParserBase.readTable(project, metadata, job, dataReader, fileSource, archiveFileName, limit, options, exceptions);
- super.parseOneFile(project, metadata, job, fileSource, reader, limit, options, exceptions);
+ super.parseOneFile(project, metadata, job, fileSource, archiveFileName, reader, limit, options, exceptions);
}
/**
diff --git a/main/src/com/google/refine/importers/ImportingParserBase.java b/main/src/com/google/refine/importers/ImportingParserBase.java
index 0ca2d066d..931103f0f 100644
--- a/main/src/com/google/refine/importers/ImportingParserBase.java
+++ b/main/src/com/google/refine/importers/ImportingParserBase.java
@@ -71,7 +71,8 @@ abstract public class ImportingParserBase implements ImportingParser {
List fileRecords, String format) {
ObjectNode options = ParsingUtilities.mapper.createObjectNode();
JSONUtilities.safePut(options, "includeFileSources", fileRecords.size() > 1);
-
+ JSONUtilities.safePut(options, "includeArchiveFileName", ImportingUtilities.hasArchiveFileField(fileRecords));
+
return options;
}
@@ -109,13 +110,14 @@ abstract public class ImportingParserBase implements ImportingParser {
) throws IOException {
final File file = ImportingUtilities.getFile(job, fileRecord);
final String fileSource = ImportingUtilities.getFileSource(fileRecord);
+ final String archiveFileName = ImportingUtilities.getArchiveFileName(fileRecord);
progress.startFile(fileSource);
try {
InputStream inputStream = ImporterUtilities.openAndTrackFile(fileSource, file, progress);
try {
if (useInputStream) {
- parseOneFile(project, metadata, job, fileSource, inputStream, limit, options, exceptions);
+ parseOneFile(project, metadata, job, fileSource, archiveFileName, inputStream, limit, options, exceptions);
} else {
String commonEncoding = JSONUtilities.getString(options, "encoding", null);
if (commonEncoding != null && commonEncoding.isEmpty()) {
@@ -125,7 +127,7 @@ abstract public class ImportingParserBase implements ImportingParser {
Reader reader = ImportingUtilities.getReaderFromStream(
inputStream, fileRecord, commonEncoding);
- parseOneFile(project, metadata, job, fileSource, reader, limit, options, exceptions);
+ parseOneFile(project, metadata, job, fileSource, archiveFileName, reader, limit, options, exceptions);
}
} finally {
inputStream.close();
@@ -140,16 +142,18 @@ abstract public class ImportingParserBase implements ImportingParser {
ProjectMetadata metadata,
ImportingJob job,
String fileSource,
+ String archiveFileName,
Reader reader,
int limit,
ObjectNode options,
List exceptions
) {
- pushImportingOptions(metadata, fileSource, options);
+ pushImportingOptions(metadata, "fileSource", fileSource, options);
+ pushImportingOptions(metadata, "archiveFileName", archiveFileName, options);
}
- private void pushImportingOptions(ProjectMetadata metadata, String fileSource, ObjectNode options) {
- options.put("fileSource", fileSource);
+ private void pushImportingOptions(ProjectMetadata metadata, String key, String value, ObjectNode options) {
+ options.put(key, value);
// set the import options to metadata:
metadata.appendImportOptionMetadata(options);
}
@@ -159,21 +163,42 @@ abstract public class ImportingParserBase implements ImportingParser {
ProjectMetadata metadata,
ImportingJob job,
String fileSource,
+ String archiveFileName,
InputStream inputStream,
int limit,
ObjectNode options,
List exceptions
) {
- pushImportingOptions(metadata, fileSource, options);
+ pushImportingOptions(metadata, "fileSource", fileSource, options);
+ pushImportingOptions(metadata, "archiveFileName", archiveFileName, options);
}
- protected static int addFilenameColumn(Project project) {
+ protected static int addFilenameColumn(Project project, boolean archiveColumnAdded) {
String fileNameColumnName = "File";
+ int columnId = archiveColumnAdded? 1 : 0;
if (project.columnModel.getColumnByName(fileNameColumnName) == null) {
try {
project.columnModel.addColumn(
- 0, new Column(project.columnModel.allocateNewCellIndex(), fileNameColumnName), false);
+ columnId, new Column(project.columnModel.allocateNewCellIndex(), fileNameColumnName), false);
+
+ return columnId;
+ } catch (ModelException e) {
+ // Shouldn't happen: We already checked for duplicate name.
+ logger.error("ModelException adding Filename column",e);
+ }
+ return -1;
+ } else {
+ return columnId;
+ }
+ }
+
+ protected static int addArchiveColumn(Project project) {
+ String ArchiveColumnName = "Archive";
+ if (project.columnModel.getColumnByName(ArchiveColumnName) == null) {
+ try {
+ project.columnModel.addColumn(
+ 0, new Column(project.columnModel.allocateNewCellIndex(), ArchiveColumnName), false);
return 0;
} catch (ModelException e) {
diff --git a/main/src/com/google/refine/importers/JsonImporter.java b/main/src/com/google/refine/importers/JsonImporter.java
index 62b7f6ab9..44a28cd67 100644
--- a/main/src/com/google/refine/importers/JsonImporter.java
+++ b/main/src/com/google/refine/importers/JsonImporter.java
@@ -201,13 +201,13 @@ public class JsonImporter extends TreeImportingParserBase {
@Override
public void parseOneFile(Project project, ProjectMetadata metadata,
- ImportingJob job, String fileSource, InputStream is,
+ ImportingJob job, String fileSource, String archiveFileName, InputStream is,
ImportColumnGroup rootColumnGroup, int limit, ObjectNode options, List exceptions) {
- parseOneFile(project, metadata, job, fileSource,
+ parseOneFile(project, metadata, job, fileSource, archiveFileName,
new JSONTreeReader(is), rootColumnGroup, limit, options, exceptions);
- super.parseOneFile(project, metadata, job, fileSource, is, rootColumnGroup, limit, options, exceptions);
+ super.parseOneFile(project, metadata, job, fileSource, archiveFileName, is, rootColumnGroup, limit, options, exceptions);
}
static public class JSONTreeReader implements TreeReader {
diff --git a/main/src/com/google/refine/importers/LineBasedImporter.java b/main/src/com/google/refine/importers/LineBasedImporter.java
index 0fa5ade42..7dfb903fd 100644
--- a/main/src/com/google/refine/importers/LineBasedImporter.java
+++ b/main/src/com/google/refine/importers/LineBasedImporter.java
@@ -66,6 +66,7 @@ public class LineBasedImporter extends TabularImportingParserBase {
ProjectMetadata metadata,
ImportingJob job,
String fileSource,
+ String archiveFileName,
Reader reader,
int limit,
ObjectNode options,
@@ -129,8 +130,8 @@ public class LineBasedImporter extends TabularImportingParserBase {
}
};
- TabularImportingParserBase.readTable(project, metadata, job, dataReader, fileSource, limit, options, exceptions);
+ TabularImportingParserBase.readTable(project, metadata, job, dataReader, fileSource, archiveFileName, limit, options, exceptions);
- super.parseOneFile(project, metadata, job, fileSource, reader, limit, options, exceptions);
+ super.parseOneFile(project, metadata, job, fileSource, archiveFileName, reader, limit, options, exceptions);
}
}
diff --git a/main/src/com/google/refine/importers/OdsImporter.java b/main/src/com/google/refine/importers/OdsImporter.java
index 7f127b216..e4441cf70 100644
--- a/main/src/com/google/refine/importers/OdsImporter.java
+++ b/main/src/com/google/refine/importers/OdsImporter.java
@@ -126,6 +126,7 @@ public class OdsImporter extends TabularImportingParserBase {
ProjectMetadata metadata,
ImportingJob job,
String fileSource,
+ String archiveFileName,
InputStream inputStream,
int limit,
ObjectNode options,
@@ -188,13 +189,14 @@ public class OdsImporter extends TabularImportingParserBase {
job,
dataReader,
fileSource + "#" + table.getTableName(),
+ archiveFileName,
limit,
options,
exceptions
);
}
- super.parseOneFile(project, metadata, job, fileSource, inputStream, limit, options, exceptions);
+ super.parseOneFile(project, metadata, job, fileSource, archiveFileName, inputStream, limit, options, exceptions);
}
static protected Serializable extractCell(OdfTableCell cell) {
diff --git a/main/src/com/google/refine/importers/RdfTripleImporter.java b/main/src/com/google/refine/importers/RdfTripleImporter.java
index 4eb36b472..822a75d99 100644
--- a/main/src/com/google/refine/importers/RdfTripleImporter.java
+++ b/main/src/com/google/refine/importers/RdfTripleImporter.java
@@ -76,7 +76,7 @@ public class RdfTripleImporter extends ImportingParserBase {
this.mode = mode;
}
- public void parseOneFile(Project project, ProjectMetadata metadata, ImportingJob job, String fileSource,
+ public void parseOneFile(Project project, ProjectMetadata metadata, ImportingJob job, String fileSource, String archiveFileName,
InputStream input, int limit, ObjectNode options, List exceptions) {
// create an empty model
Model model = ModelFactory.createDefaultModel();
@@ -162,6 +162,6 @@ public class RdfTripleImporter extends ImportingParserBase {
exceptions.add(e);
}
- super.parseOneFile(project, metadata, job, fileSource, input, limit, options, exceptions);
+ super.parseOneFile(project, metadata, job, fileSource, archiveFileName, input, limit, options, exceptions);
}
}
diff --git a/main/src/com/google/refine/importers/SeparatorBasedImporter.java b/main/src/com/google/refine/importers/SeparatorBasedImporter.java
index 51234c4f3..c7bf46ef4 100644
--- a/main/src/com/google/refine/importers/SeparatorBasedImporter.java
+++ b/main/src/com/google/refine/importers/SeparatorBasedImporter.java
@@ -87,6 +87,7 @@ public class SeparatorBasedImporter extends TabularImportingParserBase {
ProjectMetadata metadata,
ImportingJob job,
String fileSource,
+ String archiveFileName,
Reader reader,
int limit,
ObjectNode options,
@@ -157,8 +158,8 @@ public class SeparatorBasedImporter extends TabularImportingParserBase {
}
};
- TabularImportingParserBase.readTable(project, metadata, job, dataReader, fileSource, limit, options, exceptions);
- super.parseOneFile(project, metadata, job, fileSource, lnReader, limit, options, exceptions);
+ TabularImportingParserBase.readTable(project, metadata, job, dataReader, fileSource, archiveFileName, limit, options, exceptions);
+ super.parseOneFile(project, metadata, job, fileSource, archiveFileName, lnReader, limit, options, exceptions);
}
static protected ArrayList