Search in sources :

Example 1 with UriRefExpression

use of org.apache.clerezza.rdf.core.sparql.query.UriRefExpression in project stanbol by apache.

the class IsBlankAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.IsBlankAtom tmp = (org.apache.stanbol.rules.manager.atoms.IsBlankAtom) ruleAtom;
    IObjectAtom uriResource = tmp.getUriResource();
    ClerezzaSparqlObject argumentCSO = (ClerezzaSparqlObject) adapter.adaptTo(uriResource, ConstructQuery.class);
    ;
    Object arg = argumentCSO.getClerezzaObject();
    Expression argumentExpression;
    if (arg instanceof Variable) {
        argumentExpression = (Variable) arg;
    } else if (arg instanceof IRI) {
        argumentExpression = new UriRefExpression((IRI) arg);
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    List<Expression> expressions = new ArrayList<Expression>();
    expressions.add(argumentExpression);
    return (T) new ClerezzaSparqlObject(new BuiltInCall("isBLANK", expressions));
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) Variable(org.apache.clerezza.rdf.core.sparql.query.Variable) ArrayList(java.util.ArrayList) BuiltInCall(org.apache.clerezza.rdf.core.sparql.query.BuiltInCall) UriRefExpression(org.apache.clerezza.rdf.core.sparql.query.UriRefExpression) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) ConstructQuery(org.apache.clerezza.rdf.core.sparql.query.ConstructQuery) UriRefExpression(org.apache.clerezza.rdf.core.sparql.query.UriRefExpression) Expression(org.apache.clerezza.rdf.core.sparql.query.Expression) ClerezzaSparqlObject(org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject) ClerezzaSparqlObject(org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject) RuleAtomCallExeption(org.apache.stanbol.rules.base.api.RuleAtomCallExeption)

Aggregations

ArrayList (java.util.ArrayList)1 IRI (org.apache.clerezza.commons.rdf.IRI)1 BuiltInCall (org.apache.clerezza.rdf.core.sparql.query.BuiltInCall)1 ConstructQuery (org.apache.clerezza.rdf.core.sparql.query.ConstructQuery)1 Expression (org.apache.clerezza.rdf.core.sparql.query.Expression)1 UriRefExpression (org.apache.clerezza.rdf.core.sparql.query.UriRefExpression)1 Variable (org.apache.clerezza.rdf.core.sparql.query.Variable)1 ClerezzaSparqlObject (org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject)1 RuleAtomCallExeption (org.apache.stanbol.rules.base.api.RuleAtomCallExeption)1 IObjectAtom (org.apache.stanbol.rules.manager.atoms.IObjectAtom)1