use of org.openrefine.wikidata.schema.entityvalues.ReconMediaInfoIdValue in project OpenRefine by OpenRefine.
the class WbEntityVariableTest method testReconciledMediaInfoCell.
@Test
public void testReconciledMediaInfoCell() {
Recon recon = Recon.makeWikidataRecon(3782378L);
recon.judgment = Recon.Judgment.Matched;
recon.match = new ReconCandidate("M123", "some item", null, 100.0);
Cell cell = new Cell("some value", recon);
evaluatesTo(new ReconMediaInfoIdValue(recon, "some value"), cell);
}
use of org.openrefine.wikidata.schema.entityvalues.ReconMediaInfoIdValue in project OpenRefine by OpenRefine.
the class WbEntityVariable method fromCell.
@Override
public EntityIdValue fromCell(Cell cell, ExpressionContext ctxt) throws SkipSchemaExpressionException {
if (cell.recon != null && (Judgment.Matched.equals(cell.recon.judgment) || Judgment.New.equals(cell.recon.judgment))) {
if (Judgment.New.equals(cell.recon.judgment)) {
return new ReconItemIdValue(cell.recon, cell.value.toString());
}
EntityIdValue entityIdValue = EntityIdValueImpl.fromId(cell.recon.match.id, cell.recon.identifierSpace);
EntityIdValue reconEntityIdValue = null;
String entityType = null;
if (entityIdValue instanceof ItemIdValue) {
reconEntityIdValue = new ReconItemIdValue(cell.recon, cell.value.toString());
entityType = "item";
} else if (entityIdValue instanceof MediaInfoIdValue) {
reconEntityIdValue = new ReconMediaInfoIdValue(cell.recon, cell.value.toString());
entityType = "mediainfo";
} else if (entityIdValue instanceof PropertyIdValue) {
reconEntityIdValue = new ReconPropertyIdValue(cell.recon, cell.value.toString());
entityType = "property";
}
if (reconEntityIdValue == null) {
throw new SkipSchemaExpressionException();
}
if (cell.recon.identifierSpace == null || !cell.recon.identifierSpace.equals(ctxt.getBaseIRIForEntityType(entityType))) {
QAWarning warning = new QAWarning("invalid-identifier-space", null, QAWarning.Severity.INFO, 1);
warning.setProperty("example_cell", cell.value.toString());
warning.setProperty("expected_site_iri", ctxt.getBaseIRIForEntityType(entityType));
ctxt.addWarning(warning);
throw new SkipSchemaExpressionException();
}
return reconEntityIdValue;
}
throw new SkipSchemaExpressionException();
}
Aggregations