Merge pull request #1962 from OpenRefine/issue1953

Accept URIs in 'Use values as ids' operation.
This commit is contained in:
Antonin Delpeuch 2019-02-23 19:07:29 +00:00 committed by GitHub
commit 6aba9403c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -116,6 +116,9 @@ public class ReconUseValuesAsIdentifiersOperation extends EngineDependentMassCel
Cell cell = row.getCell(cellIndex); Cell cell = row.getCell(cellIndex);
if (cell != null && ExpressionUtils.isNonBlankData(cell.value)) { if (cell != null && ExpressionUtils.isNonBlankData(cell.value)) {
String id = cell.value.toString(); String id = cell.value.toString();
if(id.startsWith(identifierSpace)) {
id = id.substring(identifierSpace.length());
}
ReconCandidate match = new ReconCandidate(id, id, new String[0], 100); ReconCandidate match = new ReconCandidate(id, id, new String[0], 100);
Recon newRecon = reconConfig.createNewRecon(historyEntryID); Recon newRecon = reconConfig.createNewRecon(historyEntryID);

View File

@ -50,8 +50,8 @@ public class ReconUseValuesAsIdsOperationTests extends RefineTest {
+ "\"columnName\":\"ids\"," + "\"columnName\":\"ids\","
+ "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]}," + "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]},"
+ "\"service\":\"http://localhost:8080/api\"," + "\"service\":\"http://localhost:8080/api\","
+ "\"identifierSpace\":\"http://test.org/entities\"," + "\"identifierSpace\":\"http://test.org/entities/\","
+ "\"schemaSpace\":\"http://test.org/schema\"" + "\"schemaSpace\":\"http://test.org/schema/\""
+ "}"; + "}";
@BeforeSuite @BeforeSuite
@ -69,15 +69,15 @@ public class ReconUseValuesAsIdsOperationTests extends RefineTest {
Project project = createCSVProject("ids,v\n" Project project = createCSVProject("ids,v\n"
+ "Q343,hello\n" + "Q343,hello\n"
+ ",world\n" + ",world\n"
+ "Q31,test"); + "http://test.org/entities/Q31,test");
ReconUseValuesAsIdentifiersOperation op = ParsingUtilities.mapper.readValue(json, ReconUseValuesAsIdentifiersOperation.class); ReconUseValuesAsIdentifiersOperation op = ParsingUtilities.mapper.readValue(json, ReconUseValuesAsIdentifiersOperation.class);
op.createProcess(project, new Properties()).performImmediate(); op.createProcess(project, new Properties()).performImmediate();
assertEquals("Q343", project.rows.get(0).cells.get(0).recon.match.id); 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)); assertNull(project.rows.get(1).cells.get(0));
assertEquals("Q31", project.rows.get(2).cells.get(0).recon.match.id); assertEquals("Q31", project.rows.get(2).cells.get(0).recon.match.id);
assertEquals(2, project.columnModel.columns.get(0).getReconStats().matchedTopics); 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);
} }
} }