Pass the identifier and schema spaces along to create better ReconCandidates

This commit is contained in:
Antonin Delpeuch 2017-07-14 12:30:39 +01:00
parent cc991cab21
commit 6501c235e8
5 changed files with 47 additions and 6 deletions

View File

@ -51,6 +51,8 @@ public class ExtendDataCommand extends EngineDependentCommand {
String baseColumnName = request.getParameter("baseColumnName"); String baseColumnName = request.getParameter("baseColumnName");
int columnInsertIndex = Integer.parseInt(request.getParameter("columnInsertIndex")); int columnInsertIndex = Integer.parseInt(request.getParameter("columnInsertIndex"));
String endpoint = request.getParameter("endpoint"); String endpoint = request.getParameter("endpoint");
String identifierSpace = request.getParameter("identifierSpace");
String schemaSpace = request.getParameter("schemaSpace");
String jsonString = request.getParameter("extension"); String jsonString = request.getParameter("extension");
JSONObject extension = ParsingUtilities.evaluateJsonStringToObject(jsonString); JSONObject extension = ParsingUtilities.evaluateJsonStringToObject(jsonString);
@ -59,6 +61,8 @@ public class ExtendDataCommand extends EngineDependentCommand {
engineConfig, engineConfig,
baseColumnName, baseColumnName,
endpoint, endpoint,
identifierSpace,
schemaSpace,
extension, extension,
columnInsertIndex columnInsertIndex
); );

View File

@ -66,6 +66,8 @@ import com.google.refine.util.Pool;
public class DataExtensionChange implements Change { public class DataExtensionChange implements Change {
final protected String _baseColumnName; final protected String _baseColumnName;
final protected String _service; final protected String _service;
final protected String _identifierSpace;
final protected String _schemaSpace;
final protected int _columnInsertIndex; final protected int _columnInsertIndex;
final protected List<String> _columnNames; final protected List<String> _columnNames;
@ -82,6 +84,8 @@ public class DataExtensionChange implements Change {
public DataExtensionChange( public DataExtensionChange(
String baseColumnName, String baseColumnName,
String service, String service,
String identifierSpace,
String schemaSpace,
int columnInsertIndex, int columnInsertIndex,
List<String> columnNames, List<String> columnNames,
List<ReconType> columnTypes, List<ReconType> columnTypes,
@ -91,6 +95,8 @@ public class DataExtensionChange implements Change {
) { ) {
_baseColumnName = baseColumnName; _baseColumnName = baseColumnName;
_service = service; _service = service;
_identifierSpace = identifierSpace;
_schemaSpace = schemaSpace;
_columnInsertIndex = columnInsertIndex; _columnInsertIndex = columnInsertIndex;
_columnNames = columnNames; _columnNames = columnNames;
@ -105,6 +111,8 @@ public class DataExtensionChange implements Change {
protected DataExtensionChange( protected DataExtensionChange(
String baseColumnName, String baseColumnName,
String service, String service,
String identifierSpace,
String schemaSpace,
int columnInsertIndex, int columnInsertIndex,
List<String> columnNames, List<String> columnNames,
@ -118,6 +126,8 @@ public class DataExtensionChange implements Change {
) { ) {
_baseColumnName = baseColumnName; _baseColumnName = baseColumnName;
_service = service; _service = service;
_identifierSpace = identifierSpace;
_schemaSpace = schemaSpace;
_columnInsertIndex = columnInsertIndex; _columnInsertIndex = columnInsertIndex;
_columnNames = columnNames; _columnNames = columnNames;
@ -211,8 +221,8 @@ public class DataExtensionChange implements Change {
Column column = new Column(cellIndex, name); Column column = new Column(cellIndex, name);
column.setReconConfig(new DataExtensionReconConfig( column.setReconConfig(new DataExtensionReconConfig(
_service, _service,
"", // TODO retrieve service by URL and fill this _identifierSpace,
"", _schemaSpace,
_columnTypes.get(i))); _columnTypes.get(i)));
column.setReconStats(ReconStats.create(project, cellIndex)); column.setReconStats(ReconStats.create(project, cellIndex));
@ -247,9 +257,9 @@ public class DataExtensionChange implements Change {
if (reconMap.containsKey(rc.id)) { if (reconMap.containsKey(rc.id)) {
recon = reconMap.get(rc.id); recon = reconMap.get(rc.id);
} else { } else {
recon = Recon.makeFreebaseRecon(_historyEntryID); recon = new Recon(_historyEntryID, _identifierSpace, _schemaSpace);
recon.addCandidate(rc); recon.addCandidate(rc);
recon.service = "mql"; recon.service = _service;
recon.match = rc; recon.match = rc;
recon.matchRank = 0; recon.matchRank = 0;
recon.judgment = Judgment.Matched; recon.judgment = Judgment.Matched;
@ -285,6 +295,8 @@ public class DataExtensionChange implements Change {
public void save(Writer writer, Properties options) throws IOException { public void save(Writer writer, Properties options) throws IOException {
writer.write("baseColumnName="); writer.write(_baseColumnName); writer.write('\n'); writer.write("baseColumnName="); writer.write(_baseColumnName); writer.write('\n');
writer.write("service="); writer.write(_service); 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("columnInsertIndex="); writer.write(Integer.toString(_columnInsertIndex)); writer.write('\n');
writer.write("columnNameCount="); writer.write(Integer.toString(_columnNames.size())); writer.write('\n'); writer.write("columnNameCount="); writer.write(Integer.toString(_columnNames.size())); writer.write('\n');
for (String name : _columnNames) { for (String name : _columnNames) {
@ -354,6 +366,8 @@ public class DataExtensionChange implements Change {
static public Change load(LineNumberReader reader, Pool pool) throws Exception { static public Change load(LineNumberReader reader, Pool pool) throws Exception {
String baseColumnName = null; String baseColumnName = null;
String service = null; String service = null;
String identifierSpace = null;
String schemaSpace = null;
int columnInsertIndex = -1; int columnInsertIndex = -1;
List<String> columnNames = null; List<String> columnNames = null;
@ -377,6 +391,10 @@ public class DataExtensionChange implements Change {
baseColumnName = value; baseColumnName = value;
} else if ("service".equals(field)) { } else if ("service".equals(field)) {
service = value; service = value;
} else if ("identifierSpace".equals(field)) {
identifierSpace = value;
} else if ("schemaSpace".equals(field)) {
schemaSpace = value;
} else if ("columnInsertIndex".equals(field)) { } else if ("columnInsertIndex".equals(field)) {
columnInsertIndex = Integer.parseInt(value); columnInsertIndex = Integer.parseInt(value);
} else if ("firstNewCellIndex".equals(field)) { } else if ("firstNewCellIndex".equals(field)) {
@ -472,6 +490,8 @@ public class DataExtensionChange implements Change {
DataExtensionChange change = new DataExtensionChange( DataExtensionChange change = new DataExtensionChange(
baseColumnName, baseColumnName,
service, service,
identifierSpace,
schemaSpace,
columnInsertIndex, columnInsertIndex,
columnNames, columnNames,
columnTypes, columnTypes,

View File

@ -70,6 +70,8 @@ import com.google.refine.process.Process;
public class ExtendDataOperation extends EngineDependentOperation { public class ExtendDataOperation extends EngineDependentOperation {
final protected String _baseColumnName; final protected String _baseColumnName;
final protected String _endpoint; final protected String _endpoint;
final protected String _identifierSpace;
final protected String _schemaSpace;
final protected JSONObject _extension; final protected JSONObject _extension;
final protected int _columnInsertIndex; final protected int _columnInsertIndex;
@ -80,6 +82,8 @@ public class ExtendDataOperation extends EngineDependentOperation {
engineConfig, engineConfig,
obj.getString("baseColumnName"), obj.getString("baseColumnName"),
obj.getString("endpoint"), obj.getString("endpoint"),
obj.getString("identifierSpace"),
obj.getString("schemaSpace"),
obj.getJSONObject("extension"), obj.getJSONObject("extension"),
obj.getInt("columnInsertIndex") obj.getInt("columnInsertIndex")
); );
@ -89,6 +93,8 @@ public class ExtendDataOperation extends EngineDependentOperation {
JSONObject engineConfig, JSONObject engineConfig,
String baseColumnName, String baseColumnName,
String endpoint, String endpoint,
String identifierSpace,
String schemaSpace,
JSONObject extension, JSONObject extension,
int columnInsertIndex int columnInsertIndex
) { ) {
@ -96,6 +102,8 @@ public class ExtendDataOperation extends EngineDependentOperation {
_baseColumnName = baseColumnName; _baseColumnName = baseColumnName;
_endpoint = endpoint; _endpoint = endpoint;
_identifierSpace = identifierSpace;
_schemaSpace = schemaSpace;
_extension = extension; _extension = extension;
_columnInsertIndex = columnInsertIndex; _columnInsertIndex = columnInsertIndex;
} }
@ -111,6 +119,8 @@ public class ExtendDataOperation extends EngineDependentOperation {
writer.key("columnInsertIndex"); writer.value(_columnInsertIndex); writer.key("columnInsertIndex"); writer.value(_columnInsertIndex);
writer.key("baseColumnName"); writer.value(_baseColumnName); writer.key("baseColumnName"); writer.value(_baseColumnName);
writer.key("endpoint"); writer.value(_endpoint); 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.key("extension"); writer.value(_extension);
writer.endObject(); writer.endObject();
} }
@ -305,6 +315,8 @@ public class ExtendDataOperation extends EngineDependentOperation {
new DataExtensionChange( new DataExtensionChange(
_baseColumnName, _baseColumnName,
_endpoint, _endpoint,
_identifierSpace,
_schemaSpace,
_columnInsertIndex, _columnInsertIndex,
columnNames, columnNames,
columnTypes, columnTypes,

View File

@ -52,7 +52,10 @@ function ExtendReconciledDataPreviewDialog(column, columnIndex, rowIndices, onDo
alert("Please add some properties first."); alert("Please add some properties first.");
} else { } else {
DialogSystem.dismissUntil(self._level - 1); 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() { this._elmts.cancelButton.click(function() {

View File

@ -153,13 +153,15 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
column, column,
columnIndex, columnIndex,
o.rowIndices, o.rowIndices,
function(extension, endpoint) { function(extension, endpoint, identifierSpace, schemaSpace) {
Refine.postProcess( Refine.postProcess(
"core", "core",
"extend-data", "extend-data",
{ {
baseColumnName: column.name, baseColumnName: column.name,
endpoint: endpoint, endpoint: endpoint,
identifierSpace: identifierSpace,
schemaSpace: schemaSpace,
columnInsertIndex: columnIndex + 1 columnInsertIndex: columnIndex + 1
}, },
{ {