use of org.openrefine.wikidata.updates.StatementGroupEdit in project OpenRefine by OpenRefine.
the class WbEntityDocumentExpr method evaluate.
@Override
public TermedStatementEntityEdit evaluate(ExpressionContext ctxt) throws SkipSchemaExpressionException {
EntityIdValue subjectId = getSubject().evaluate(ctxt);
TermedStatementEntityEditBuilder update = new TermedStatementEntityEditBuilder(subjectId);
for (WbStatementGroupExpr expr : getStatementGroups()) {
try {
StatementGroupEdit statementGroupUpdate = expr.evaluate(ctxt, subjectId);
// TODO also store statement groups in TermedStatementEntityUpdate?
for (StatementEdit s : statementGroupUpdate.getStatementEdits()) {
update.addStatement(s);
}
} catch (SkipSchemaExpressionException e) {
continue;
}
}
for (WbNameDescExpr expr : getNameDescs()) {
expr.contributeTo(update, ctxt);
}
return update.build();
}
use of org.openrefine.wikidata.updates.StatementGroupEdit 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