Search in sources :

Example 26 with IObjectAtom

use of org.apache.stanbol.rules.manager.atoms.IObjectAtom in project stanbol by apache.

the class StrAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.StrAtom tmp = (org.apache.stanbol.rules.manager.atoms.StrAtom) ruleAtom;
    IObjectAtom uriResource = tmp.getUriResource();
    ClerezzaSparqlObject clerezzaSparqlObject = (ClerezzaSparqlObject) adapter.adaptTo(uriResource, ConstructQuery.class);
    List<Expression> expressions = new ArrayList<Expression>();
    expressions.add((Expression) clerezzaSparqlObject.getClerezzaObject());
    return (T) new ClerezzaSparqlObject(new BuiltInCall("STR", expressions));
}
Also used : ArrayList(java.util.ArrayList) BuiltInCall(org.apache.clerezza.rdf.core.sparql.query.BuiltInCall) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) ConstructQuery(org.apache.clerezza.rdf.core.sparql.query.ConstructQuery) Expression(org.apache.clerezza.rdf.core.sparql.query.Expression) ClerezzaSparqlObject(org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject)

Example 27 with IObjectAtom

use of org.apache.stanbol.rules.manager.atoms.IObjectAtom in project stanbol by apache.

the class NewIRIAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.NewIRIAtom tmp = (org.apache.stanbol.rules.manager.atoms.NewIRIAtom) ruleAtom;
    StringFunctionAtom bindingAtom = tmp.getBinding();
    IObjectAtom variableAtom = tmp.getNewNodeVariable();
    ClerezzaSparqlObject binding = (ClerezzaSparqlObject) adapter.adaptTo(bindingAtom, ConstructQuery.class);
    ClerezzaSparqlObject variable = (ClerezzaSparqlObject) adapter.adaptTo(variableAtom, ConstructQuery.class);
    List<Expression> iriArgumentExpressions = new ArrayList<Expression>();
    iriArgumentExpressions.add((Expression) binding.getClerezzaObject());
    BuiltInCall iriBuiltInCall = new BuiltInCall("IRI", iriArgumentExpressions);
    List<Expression> bindArgumentExpressions = new ArrayList<Expression>();
    bindArgumentExpressions.add(iriBuiltInCall);
    bindArgumentExpressions.add((Expression) variable.getClerezzaObject());
    BuiltInCall bindBuiltInCall = new BuiltInCall("BIND", bindArgumentExpressions);
    return (T) new ClerezzaSparqlObject(bindBuiltInCall);
}
Also used : ArrayList(java.util.ArrayList) BuiltInCall(org.apache.clerezza.rdf.core.sparql.query.BuiltInCall) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) ConstructQuery(org.apache.clerezza.rdf.core.sparql.query.ConstructQuery) StringFunctionAtom(org.apache.stanbol.rules.manager.atoms.StringFunctionAtom) Expression(org.apache.clerezza.rdf.core.sparql.query.Expression) ClerezzaSparqlObject(org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject)

Example 28 with IObjectAtom

use of org.apache.stanbol.rules.manager.atoms.IObjectAtom in project stanbol by apache.

the class RuleParserImpl method newLiteralAtom.

public final NewLiteralAtom newLiteralAtom() throws ParseException {
    IObjectAtom arg1;
    StringFunctionAtom arg2;
    jj_consume_token(NEW_LITERAL);
    jj_consume_token(LPAR);
    arg1 = iObject();
    jj_consume_token(COMMA);
    arg2 = stringFunctionAtom();
    jj_consume_token(RPAR);
    {
        if (true)
            return new NewLiteralAtom(arg1, arg2);
    }
    throw new Error("Missing return statement in function");
}
Also used : StringFunctionAtom(org.apache.stanbol.rules.manager.atoms.StringFunctionAtom) NewLiteralAtom(org.apache.stanbol.rules.manager.atoms.NewLiteralAtom) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom)

Example 29 with IObjectAtom

use of org.apache.stanbol.rules.manager.atoms.IObjectAtom in project stanbol by apache.

the class RuleParserImpl method isBlankAtom.

public final ComparisonAtom isBlankAtom() throws ParseException {
    IObjectAtom uriRes;
    jj_consume_token(IS_BLANK);
    jj_consume_token(LPAR);
    uriRes = iObject();
    jj_consume_token(RPAR);
    {
        if (true)
            return new IsBlankAtom(uriRes);
    }
    throw new Error("Missing return statement in function");
}
Also used : IsBlankAtom(org.apache.stanbol.rules.manager.atoms.IsBlankAtom) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom)

Example 30 with IObjectAtom

use of org.apache.stanbol.rules.manager.atoms.IObjectAtom in project stanbol by apache.

the class RuleParserImpl method strAtom.

public final StrAtom strAtom() throws ParseException {
    IObjectAtom uri;
    jj_consume_token(STR);
    jj_consume_token(LPAR);
    uri = iObject();
    jj_consume_token(RPAR);
    {
        if (true)
            return new StrAtom(uri);
    }
    throw new Error("Missing return statement in function");
}
Also used : IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) StrAtom(org.apache.stanbol.rules.manager.atoms.StrAtom)

Aggregations

IObjectAtom (org.apache.stanbol.rules.manager.atoms.IObjectAtom)36 RuleAtomCallExeption (org.apache.stanbol.rules.base.api.RuleAtomCallExeption)15 ConstructQuery (org.apache.clerezza.rdf.core.sparql.query.ConstructQuery)8 ClerezzaSparqlObject (org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject)8 Node (com.hp.hpl.jena.graph.Node)7 ClauseEntry (com.hp.hpl.jena.reasoner.rulesys.ClauseEntry)7 ArrayList (java.util.ArrayList)7 NodeClauseEntry (org.apache.stanbol.rules.adapters.jena.NodeClauseEntry)7 StringFunctionAtom (org.apache.stanbol.rules.manager.atoms.StringFunctionAtom)6 IRI (org.apache.clerezza.commons.rdf.IRI)5 TriplePattern (com.hp.hpl.jena.reasoner.TriplePattern)4 BuiltInCall (org.apache.clerezza.rdf.core.sparql.query.BuiltInCall)4 Expression (org.apache.clerezza.rdf.core.sparql.query.Expression)4 ResourceOrVariable (org.apache.clerezza.rdf.core.sparql.query.ResourceOrVariable)4 UriRefOrVariable (org.apache.clerezza.rdf.core.sparql.query.UriRefOrVariable)4 Variable (org.apache.clerezza.rdf.core.sparql.query.Variable)4 SimpleTriplePattern (org.apache.clerezza.rdf.core.sparql.query.impl.SimpleTriplePattern)4 ArgumentSWRLAtom (org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom)4 RuleAtom (org.apache.stanbol.rules.base.api.RuleAtom)4 SPARQLObject (org.apache.stanbol.rules.base.api.SPARQLObject)4