From 6501c235e8c134d5fac20b506dbcc968e8879397 Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Fri, 14 Jul 2017 12:30:39 +0100 Subject: [PATCH] Pass the identifier and schema spaces along to create better ReconCandidates --- .../commands/recon/ExtendDataCommand.java | 4 +++ .../model/changes/DataExtensionChange.java | 28 ++++++++++++++++--- .../operations/recon/ExtendDataOperation.java | 12 ++++++++ .../dialogs/extend-data-preview-dialog.js | 5 +++- .../views/data-table/menu-edit-column.js | 4 ++- 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/main/src/com/google/refine/commands/recon/ExtendDataCommand.java b/main/src/com/google/refine/commands/recon/ExtendDataCommand.java index 52cd66476..bdf0748b8 100644 --- a/main/src/com/google/refine/commands/recon/ExtendDataCommand.java +++ b/main/src/com/google/refine/commands/recon/ExtendDataCommand.java @@ -51,6 +51,8 @@ public class ExtendDataCommand extends EngineDependentCommand { String baseColumnName = request.getParameter("baseColumnName"); int columnInsertIndex = Integer.parseInt(request.getParameter("columnInsertIndex")); String endpoint = request.getParameter("endpoint"); + String identifierSpace = request.getParameter("identifierSpace"); + String schemaSpace = request.getParameter("schemaSpace"); String jsonString = request.getParameter("extension"); JSONObject extension = ParsingUtilities.evaluateJsonStringToObject(jsonString); @@ -59,6 +61,8 @@ public class ExtendDataCommand extends EngineDependentCommand { engineConfig, baseColumnName, endpoint, + identifierSpace, + schemaSpace, extension, columnInsertIndex ); diff --git a/main/src/com/google/refine/model/changes/DataExtensionChange.java b/main/src/com/google/refine/model/changes/DataExtensionChange.java index 4deebf612..b5a478939 100644 --- a/main/src/com/google/refine/model/changes/DataExtensionChange.java +++ b/main/src/com/google/refine/model/changes/DataExtensionChange.java @@ -66,6 +66,8 @@ import com.google.refine.util.Pool; public class DataExtensionChange implements Change { final protected String _baseColumnName; final protected String _service; + final protected String _identifierSpace; + final protected String _schemaSpace; final protected int _columnInsertIndex; final protected List _columnNames; @@ -82,6 +84,8 @@ public class DataExtensionChange implements Change { public DataExtensionChange( String baseColumnName, String service, + String identifierSpace, + String schemaSpace, int columnInsertIndex, List columnNames, List columnTypes, @@ -91,6 +95,8 @@ public class DataExtensionChange implements Change { ) { _baseColumnName = baseColumnName; _service = service; + _identifierSpace = identifierSpace; + _schemaSpace = schemaSpace; _columnInsertIndex = columnInsertIndex; _columnNames = columnNames; @@ -105,6 +111,8 @@ public class DataExtensionChange implements Change { protected DataExtensionChange( String baseColumnName, String service, + String identifierSpace, + String schemaSpace, int columnInsertIndex, List columnNames, @@ -118,6 +126,8 @@ public class DataExtensionChange implements Change { ) { _baseColumnName = baseColumnName; _service = service; + _identifierSpace = identifierSpace; + _schemaSpace = schemaSpace; _columnInsertIndex = columnInsertIndex; _columnNames = columnNames; @@ -211,8 +221,8 @@ public class DataExtensionChange implements Change { Column column = new Column(cellIndex, name); column.setReconConfig(new DataExtensionReconConfig( _service, - "", // TODO retrieve service by URL and fill this - "", + _identifierSpace, + _schemaSpace, _columnTypes.get(i))); column.setReconStats(ReconStats.create(project, cellIndex)); @@ -247,9 +257,9 @@ public class DataExtensionChange implements Change { if (reconMap.containsKey(rc.id)) { recon = reconMap.get(rc.id); } else { - recon = Recon.makeFreebaseRecon(_historyEntryID); + recon = new Recon(_historyEntryID, _identifierSpace, _schemaSpace); recon.addCandidate(rc); - recon.service = "mql"; + recon.service = _service; recon.match = rc; recon.matchRank = 0; recon.judgment = Judgment.Matched; @@ -285,6 +295,8 @@ public class DataExtensionChange implements Change { public void save(Writer writer, Properties options) throws IOException { writer.write("baseColumnName="); writer.write(_baseColumnName); writer.write('\n'); writer.write("service="); writer.write(_service); writer.write('\n'); + writer.write("identifierSpace="); writer.write(_identifierSpace); writer.write('\n'); + writer.write("schemaSpace="); writer.write(_schemaSpace); writer.write('\n'); writer.write("columnInsertIndex="); writer.write(Integer.toString(_columnInsertIndex)); writer.write('\n'); writer.write("columnNameCount="); writer.write(Integer.toString(_columnNames.size())); writer.write('\n'); for (String name : _columnNames) { @@ -354,6 +366,8 @@ public class DataExtensionChange implements Change { static public Change load(LineNumberReader reader, Pool pool) throws Exception { String baseColumnName = null; String service = null; + String identifierSpace = null; + String schemaSpace = null; int columnInsertIndex = -1; List columnNames = null; @@ -377,6 +391,10 @@ public class DataExtensionChange implements Change { baseColumnName = value; } else if ("service".equals(field)) { service = value; + } else if ("identifierSpace".equals(field)) { + identifierSpace = value; + } else if ("schemaSpace".equals(field)) { + schemaSpace = value; } else if ("columnInsertIndex".equals(field)) { columnInsertIndex = Integer.parseInt(value); } else if ("firstNewCellIndex".equals(field)) { @@ -472,6 +490,8 @@ public class DataExtensionChange implements Change { DataExtensionChange change = new DataExtensionChange( baseColumnName, service, + identifierSpace, + schemaSpace, columnInsertIndex, columnNames, columnTypes, diff --git a/main/src/com/google/refine/operations/recon/ExtendDataOperation.java b/main/src/com/google/refine/operations/recon/ExtendDataOperation.java index 132e4da45..eea06a711 100644 --- a/main/src/com/google/refine/operations/recon/ExtendDataOperation.java +++ b/main/src/com/google/refine/operations/recon/ExtendDataOperation.java @@ -70,6 +70,8 @@ import com.google.refine.process.Process; public class ExtendDataOperation extends EngineDependentOperation { final protected String _baseColumnName; final protected String _endpoint; + final protected String _identifierSpace; + final protected String _schemaSpace; final protected JSONObject _extension; final protected int _columnInsertIndex; @@ -80,6 +82,8 @@ public class ExtendDataOperation extends EngineDependentOperation { engineConfig, obj.getString("baseColumnName"), obj.getString("endpoint"), + obj.getString("identifierSpace"), + obj.getString("schemaSpace"), obj.getJSONObject("extension"), obj.getInt("columnInsertIndex") ); @@ -89,6 +93,8 @@ public class ExtendDataOperation extends EngineDependentOperation { JSONObject engineConfig, String baseColumnName, String endpoint, + String identifierSpace, + String schemaSpace, JSONObject extension, int columnInsertIndex ) { @@ -96,6 +102,8 @@ public class ExtendDataOperation extends EngineDependentOperation { _baseColumnName = baseColumnName; _endpoint = endpoint; + _identifierSpace = identifierSpace; + _schemaSpace = schemaSpace; _extension = extension; _columnInsertIndex = columnInsertIndex; } @@ -111,6 +119,8 @@ public class ExtendDataOperation extends EngineDependentOperation { writer.key("columnInsertIndex"); writer.value(_columnInsertIndex); writer.key("baseColumnName"); writer.value(_baseColumnName); writer.key("endpoint"); writer.value(_endpoint); + writer.key("identifierSpace"); writer.value(_identifierSpace); + writer.key("schemaSpace"); writer.value(_schemaSpace); writer.key("extension"); writer.value(_extension); writer.endObject(); } @@ -305,6 +315,8 @@ public class ExtendDataOperation extends EngineDependentOperation { new DataExtensionChange( _baseColumnName, _endpoint, + _identifierSpace, + _schemaSpace, _columnInsertIndex, columnNames, columnTypes, diff --git a/main/webapp/modules/core/scripts/dialogs/extend-data-preview-dialog.js b/main/webapp/modules/core/scripts/dialogs/extend-data-preview-dialog.js index 622cf194c..e98d0b890 100644 --- a/main/webapp/modules/core/scripts/dialogs/extend-data-preview-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/extend-data-preview-dialog.js @@ -52,7 +52,10 @@ function ExtendReconciledDataPreviewDialog(column, columnIndex, rowIndices, onDo alert("Please add some properties first."); } else { DialogSystem.dismissUntil(self._level - 1); - self._onDone(self._extension, self._service); + self._onDone(self._extension, + self._service, + self._serviceMetadata.identifierSpace, + self._serviceMetadata.schemaSpace); } }); this._elmts.cancelButton.click(function() { diff --git a/main/webapp/modules/core/scripts/views/data-table/menu-edit-column.js b/main/webapp/modules/core/scripts/views/data-table/menu-edit-column.js index 7ecf95074..0a327bc51 100644 --- a/main/webapp/modules/core/scripts/views/data-table/menu-edit-column.js +++ b/main/webapp/modules/core/scripts/views/data-table/menu-edit-column.js @@ -153,13 +153,15 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) { column, columnIndex, o.rowIndices, - function(extension, endpoint) { + function(extension, endpoint, identifierSpace, schemaSpace) { Refine.postProcess( "core", "extend-data", { baseColumnName: column.name, endpoint: endpoint, + identifierSpace: identifierSpace, + schemaSpace: schemaSpace, columnInsertIndex: columnIndex + 1 }, {