Search in sources :

Example 31 with IObjectAtom

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

the class RuleParserImpl method individualPropertyAtom.

public final IndividualPropertyAtom individualPropertyAtom() throws ParseException {
    IObjectAtom uri1;
    IObjectAtom uri2;
    IObjectAtom uri3;
    jj_consume_token(HAS);
    jj_consume_token(LPAR);
    uri1 = iObject();
    jj_consume_token(COMMA);
    uri2 = iObject();
    jj_consume_token(COMMA);
    uri3 = iObject();
    jj_consume_token(RPAR);
    {
        if (true)
            return new IndividualPropertyAtom(uri1, uri2, uri3);
    }
    throw new Error("Missing return statement in function");
}
Also used : IndividualPropertyAtom(org.apache.stanbol.rules.manager.atoms.IndividualPropertyAtom) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom)

Example 32 with IObjectAtom

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

the class RuleParserImpl method classAtom.

public final ClassAtom classAtom() throws ParseException {
    IObjectAtom uri1;
    IObjectAtom uri2;
    jj_consume_token(IS);
    jj_consume_token(LPAR);
    uri1 = iObject();
    jj_consume_token(COMMA);
    uri2 = iObject();
    jj_consume_token(RPAR);
    {
        if (true)
            return new ClassAtom(uri1, uri2);
    }
    throw new Error("Missing return statement in function");
}
Also used : ClassAtom(org.apache.stanbol.rules.manager.atoms.ClassAtom) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom)

Example 33 with IObjectAtom

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

the class RuleParserImpl method literal.

public final ExpressionAtom literal() throws ParseException {
    ExpressionAtom literal;
    IObjectAtom typedLiteral;
    switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
        case STRING:
            literal = getString();
            typedLiteral = typedLiteral();
            break;
        case NUM:
            literal = getInt();
            typedLiteral = typedLiteral();
            break;
        default:
            jj_la1[13] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
    }
    if (typedLiteral != null) {
        {
            if (true)
                return new TypedLiteralAtom(literal, typedLiteral);
        }
    } else {
        {
            if (true)
                return literal;
        }
    }
    throw new Error("Missing return statement in function");
}
Also used : TypedLiteralAtom(org.apache.stanbol.rules.manager.atoms.TypedLiteralAtom) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) ExpressionAtom(org.apache.stanbol.rules.manager.atoms.ExpressionAtom)

Example 34 with IObjectAtom

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

the class DatavaluedPropertyAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnsupportedTypeForExportException, UnavailableRuleObjectException {
    org.apache.stanbol.rules.manager.atoms.DatavaluedPropertyAtom tmp = (org.apache.stanbol.rules.manager.atoms.DatavaluedPropertyAtom) ruleAtom;
    IObjectAtom argument1 = tmp.getArgument1();
    IObjectAtom datatypeProperty = tmp.getDatatypeProperty();
    RuleAtom argument2 = tmp.getArgument2();
    SWRLAtom arg1Atom = (SWRLAtom) adapter.adaptTo(argument1, SWRLRule.class);
    SWRLAtom predicateAtom = (SWRLAtom) adapter.adaptTo(datatypeProperty, SWRLRule.class);
    SWRLAtom arg2Atom = (SWRLAtom) adapter.adaptTo(argument2, SWRLRule.class);
    OWLDataFactory factory = OWLManager.getOWLDataFactory();
    OWLDataProperty owlDataProperty;
    SWRLIArgument swrliArgument;
    SWRLDArgument swrldArgument;
    if (predicateAtom instanceof ArgumentSWRLAtom) {
        owlDataProperty = factory.getOWLDataProperty(IRI.create(((ArgumentSWRLAtom) predicateAtom).getId()));
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    if (arg1Atom instanceof ArgumentSWRLAtom) {
        swrliArgument = (SWRLIArgument) ((ArgumentSWRLAtom) arg1Atom).getSwrlArgument();
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    if (arg2Atom instanceof ArgumentSWRLAtom) {
        swrldArgument = (SWRLDArgument) ((ArgumentSWRLAtom) arg2Atom).getSwrlArgument();
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    return (T) factory.getSWRLDataPropertyAtom(owlDataProperty, swrliArgument, swrldArgument);
}
Also used : ArgumentSWRLAtom(org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) SWRLIArgument(org.semanticweb.owlapi.model.SWRLIArgument) OWLDataProperty(org.semanticweb.owlapi.model.OWLDataProperty) SWRLDArgument(org.semanticweb.owlapi.model.SWRLDArgument) SWRLAtom(org.semanticweb.owlapi.model.SWRLAtom) ArgumentSWRLAtom(org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom) SWRLRule(org.semanticweb.owlapi.model.SWRLRule) RuleAtomCallExeption(org.apache.stanbol.rules.base.api.RuleAtomCallExeption) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory) RuleAtom(org.apache.stanbol.rules.base.api.RuleAtom)

Example 35 with IObjectAtom

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

the class IndividualPropertyAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnsupportedTypeForExportException, UnavailableRuleObjectException {
    org.apache.stanbol.rules.manager.atoms.IndividualPropertyAtom tmp = (org.apache.stanbol.rules.manager.atoms.IndividualPropertyAtom) ruleAtom;
    IObjectAtom argument1 = tmp.getArgument1();
    IObjectAtom argument2 = tmp.getArgument2();
    IObjectAtom objectProperty = tmp.getObjectProperty();
    SWRLAtom predicateAtom = (SWRLAtom) adapter.adaptTo(objectProperty, SWRLRule.class);
    SWRLAtom subjectAtom = (SWRLAtom) adapter.adaptTo(argument1, SWRLRule.class);
    SWRLAtom objectAtom = (SWRLAtom) adapter.adaptTo(argument2, SWRLRule.class);
    OWLDataFactory factory = OWLManager.getOWLDataFactory();
    OWLObjectProperty owlObjectProperty;
    SWRLIArgument swrliArgument1;
    SWRLIArgument swrliArgument2;
    if (predicateAtom instanceof ArgumentSWRLAtom) {
        owlObjectProperty = factory.getOWLObjectProperty(IRI.create(((ArgumentSWRLAtom) predicateAtom).getId()));
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    if (subjectAtom instanceof ArgumentSWRLAtom) {
        swrliArgument1 = (SWRLIArgument) ((ArgumentSWRLAtom) subjectAtom).getSwrlArgument();
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    if (objectAtom instanceof ArgumentSWRLAtom) {
        swrliArgument2 = (SWRLIArgument) ((ArgumentSWRLAtom) objectAtom).getSwrlArgument();
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    return (T) factory.getSWRLObjectPropertyAtom(owlObjectProperty, swrliArgument1, swrliArgument2);
}
Also used : ArgumentSWRLAtom(org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom) OWLObjectProperty(org.semanticweb.owlapi.model.OWLObjectProperty) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) SWRLIArgument(org.semanticweb.owlapi.model.SWRLIArgument) SWRLAtom(org.semanticweb.owlapi.model.SWRLAtom) ArgumentSWRLAtom(org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom) SWRLRule(org.semanticweb.owlapi.model.SWRLRule) RuleAtomCallExeption(org.apache.stanbol.rules.base.api.RuleAtomCallExeption) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory)

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