From a072328637a215abfb6c47348b078d57ec284791 Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Tue, 19 Feb 2019 22:06:35 +0000 Subject: [PATCH] Accept URIs in 'Use values as ids' operation. Closes #1953. --- .../recon/ReconUseValuesAsIdentifiersOperation.java | 3 +++ .../recon/ReconUseValuesAsIdsOperationTests.java | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/main/src/com/google/refine/operations/recon/ReconUseValuesAsIdentifiersOperation.java b/main/src/com/google/refine/operations/recon/ReconUseValuesAsIdentifiersOperation.java index 6e1e6b32b..56dc50d73 100644 --- a/main/src/com/google/refine/operations/recon/ReconUseValuesAsIdentifiersOperation.java +++ b/main/src/com/google/refine/operations/recon/ReconUseValuesAsIdentifiersOperation.java @@ -116,6 +116,9 @@ public class ReconUseValuesAsIdentifiersOperation extends EngineDependentMassCel Cell cell = row.getCell(cellIndex); if (cell != null && ExpressionUtils.isNonBlankData(cell.value)) { String id = cell.value.toString(); + if(id.startsWith(identifierSpace)) { + id = id.substring(identifierSpace.length()); + } ReconCandidate match = new ReconCandidate(id, id, new String[0], 100); Recon newRecon = reconConfig.createNewRecon(historyEntryID); diff --git a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconUseValuesAsIdsOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconUseValuesAsIdsOperationTests.java index 0cebe10d6..757d734a6 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconUseValuesAsIdsOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconUseValuesAsIdsOperationTests.java @@ -50,8 +50,8 @@ public class ReconUseValuesAsIdsOperationTests extends RefineTest { + "\"columnName\":\"ids\"," + "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]}," + "\"service\":\"http://localhost:8080/api\"," - + "\"identifierSpace\":\"http://test.org/entities\"," - + "\"schemaSpace\":\"http://test.org/schema\"" + + "\"identifierSpace\":\"http://test.org/entities/\"," + + "\"schemaSpace\":\"http://test.org/schema/\"" + "}"; @BeforeSuite @@ -69,15 +69,15 @@ public class ReconUseValuesAsIdsOperationTests extends RefineTest { Project project = createCSVProject("ids,v\n" + "Q343,hello\n" + ",world\n" - + "Q31,test"); + + "http://test.org/entities/Q31,test"); ReconUseValuesAsIdentifiersOperation op = ParsingUtilities.mapper.readValue(json, ReconUseValuesAsIdentifiersOperation.class); op.createProcess(project, new Properties()).performImmediate(); assertEquals("Q343", project.rows.get(0).cells.get(0).recon.match.id); - assertEquals("http://test.org/entities", project.rows.get(0).cells.get(0).recon.identifierSpace); + assertEquals("http://test.org/entities/", project.rows.get(0).cells.get(0).recon.identifierSpace); assertNull(project.rows.get(1).cells.get(0)); assertEquals("Q31", project.rows.get(2).cells.get(0).recon.match.id); assertEquals(2, project.columnModel.columns.get(0).getReconStats().matchedTopics); - assertEquals("http://test.org/schema", ((StandardReconConfig)project.columnModel.columns.get(0).getReconConfig()).schemaSpace); + assertEquals("http://test.org/schema/", ((StandardReconConfig)project.columnModel.columns.get(0).getReconConfig()).schemaSpace); } }