Search in sources :

Example 36 with PropertyIdValue

use of org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue 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();
    }
}
Also used : PropertyIdValue(org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue) StatementGroupEdit(org.openrefine.wikidata.updates.StatementGroupEdit) SkipSchemaExpressionException(org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException) ArrayList(java.util.ArrayList) StatementEdit(org.openrefine.wikidata.updates.StatementEdit)

Aggregations

PropertyIdValue (org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue)36 Statement (org.wikidata.wdtk.datamodel.interfaces.Statement)17 QAWarning (org.openrefine.wikidata.qa.QAWarning)16 Snak (org.wikidata.wdtk.datamodel.interfaces.Snak)12 EntityIdValue (org.wikidata.wdtk.datamodel.interfaces.EntityIdValue)11 Value (org.wikidata.wdtk.datamodel.interfaces.Value)11 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 HashSet (java.util.HashSet)9 SnakGroup (org.wikidata.wdtk.datamodel.interfaces.SnakGroup)9 ValueSnak (org.wikidata.wdtk.datamodel.interfaces.ValueSnak)9 List (java.util.List)8 Set (java.util.Set)6 Claim (org.wikidata.wdtk.datamodel.interfaces.Claim)6 Reference (org.wikidata.wdtk.datamodel.interfaces.Reference)6 Collectors (java.util.stream.Collectors)5 StatementEdit (org.openrefine.wikidata.updates.StatementEdit)5 Test (org.testng.annotations.Test)5 SkipSchemaExpressionException (org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException)4 TermedStatementEntityEdit (org.openrefine.wikidata.updates.TermedStatementEntityEdit)4