use of org.openrefine.wikidata.updates.StatementEdit in project OpenRefine by OpenRefine.
the class QuickStatementsExporter method translateItem.
protected void translateItem(TermedStatementEntityEdit item, Writer writer) throws IOException {
String qid = item.getEntityId().getId();
if (item.isNew()) {
writer.write("CREATE\n");
qid = "LAST";
item = item.normalizeLabelsAndAliases();
}
translateNameDescr(qid, item.getLabels(), "L", item.getEntityId(), writer);
translateNameDescr(qid, item.getLabelsIfNew(), "L", item.getEntityId(), writer);
translateNameDescr(qid, item.getDescriptions(), "D", item.getEntityId(), writer);
translateNameDescr(qid, item.getDescriptionsIfNew(), "D", item.getEntityId(), writer);
translateNameDescr(qid, item.getAliases(), "A", item.getEntityId(), writer);
for (StatementEdit s : item.getStatementEdits()) {
translateStatement(qid, s.getStatement(), s.getPropertyId().getId(), s.getMode() == StatementEditingMode.ADD_OR_MERGE, writer);
}
}
use of org.openrefine.wikidata.updates.StatementEdit in project OpenRefine by OpenRefine.
the class WbStatementGroupExpr method evaluate.
public StatementGroupEdit evaluate(ExpressionContext ctxt, EntityIdValue subject) throws SkipSchemaExpressionException {
PropertyIdValue propertyId = propertyExpr.evaluate(ctxt);
List<StatementEdit> statements = new ArrayList<>(statementExprs.size());
for (WbStatementExpr expr : statementExprs) {
try {
statements.add(expr.evaluate(ctxt, subject, propertyId));
} catch (SkipSchemaExpressionException e) {
continue;
}
}
if (!statements.isEmpty()) {
return new StatementGroupEdit(statements);
} else {
throw new SkipSchemaExpressionException();
}
}
Aggregations