Fix ItemIdValue generation from project to pass on terms

This commit is contained in:
Antonin Delpeuch 2018-01-10 15:23:32 +00:00
parent d4cb64cdfd
commit 5891f8c270

View File

@ -2,6 +2,7 @@ package org.openrefine.wikidata.schema;
import org.openrefine.wikidata.schema.entityvalues.NewEntityIdValue; import org.openrefine.wikidata.schema.entityvalues.NewEntityIdValue;
import org.openrefine.wikidata.schema.entityvalues.TermedItemIdValue;
import org.wikidata.wdtk.datamodel.helpers.Datamodel; import org.wikidata.wdtk.datamodel.helpers.Datamodel;
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue; import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
@ -30,12 +31,19 @@ public class WbItemVariable extends WbItemExpr {
Recon recon = cell.recon; Recon recon = cell.recon;
if (recon.judgment == Recon.Judgment.Matched && cell.recon.match != null) { if (recon.judgment == Recon.Judgment.Matched && cell.recon.match != null) {
ReconCandidate match = cell.recon.match; ReconCandidate match = cell.recon.match;
return Datamodel.makeItemIdValue(match.id, ctxt.getBaseIRI()); String label = match.name;
return new TermedItemIdValue(
match.id,
ctxt.getBaseIRI(),
label);
} else if (recon.judgment == Recon.Judgment.New) { } else if (recon.judgment == Recon.Judgment.New) {
int rowId = ctxt.getRowId(); int rowId = ctxt.getRowId();
int columnId = ctxt.getCellIndexByName(getColumnName()); int columnId = ctxt.getCellIndexByName(getColumnName());
String siteIRI = ctxt.getBaseIRI(); String siteIRI = ctxt.getBaseIRI();
String label = ctxt.getCellByName(getColumnName()).value.toString(); String label = cell.value.toString();
if (label.isEmpty()) {
}
return new NewEntityIdValue( return new NewEntityIdValue(
rowId, columnId, siteIRI, label); rowId, columnId, siteIRI, label);
} }