Search in sources :

Example 1 with TriplePattern

use of com.hp.hpl.jena.reasoner.TriplePattern in project stanbol by apache.

the class BlankNodeAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.BlankNodeAtom tmp = (org.apache.stanbol.rules.manager.atoms.BlankNodeAtom) ruleAtom;
    IObjectAtom argument1 = tmp.getArgument1();
    IObjectAtom argument2 = tmp.getArgument2();
    ClauseEntry argument1CE = adapter.adaptTo(argument1, Rule.class);
    ClauseEntry argument2CE = adapter.adaptTo(argument2, Rule.class);
    Node arg1Node;
    Node arg2Node;
    if (argument1CE instanceof NodeClauseEntry) {
        arg1Node = ((NodeClauseEntry) argument1CE).getNode();
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    if (argument2CE instanceof NodeClauseEntry) {
        arg2Node = ((NodeClauseEntry) argument2CE).getNode();
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    Node blank = Node_RuleVariable.createAnon();
    return (T) new TriplePattern(arg2Node, arg1Node, blank);
}
Also used : Node(com.hp.hpl.jena.graph.Node) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) ClauseEntry(com.hp.hpl.jena.reasoner.rulesys.ClauseEntry) NodeClauseEntry(org.apache.stanbol.rules.adapters.jena.NodeClauseEntry) RuleAtomCallExeption(org.apache.stanbol.rules.base.api.RuleAtomCallExeption) NodeClauseEntry(org.apache.stanbol.rules.adapters.jena.NodeClauseEntry) TriplePattern(com.hp.hpl.jena.reasoner.TriplePattern)

Example 2 with TriplePattern

use of com.hp.hpl.jena.reasoner.TriplePattern in project stanbol by apache.

the class DatavaluedPropertyAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    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();
    ClauseEntry argument2ClauseEntry = adapter.adaptTo(argument2, Rule.class);
    ClauseEntry argument1ClauseEntry = adapter.adaptTo(argument1, Rule.class);
    ClauseEntry datatypePropertyClauseEntry = adapter.adaptTo(datatypeProperty, Rule.class);
    Node subjectNode = null;
    Node predicateNode = null;
    Node objectNode = null;
    if (argument1ClauseEntry instanceof NodeClauseEntry) {
        subjectNode = ((NodeClauseEntry) argument1ClauseEntry).getNode();
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    if (datatypePropertyClauseEntry instanceof NodeClauseEntry) {
        predicateNode = ((NodeClauseEntry) datatypePropertyClauseEntry).getNode();
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    if (argument2ClauseEntry instanceof NodeClauseEntry) {
        objectNode = ((NodeClauseEntry) argument2ClauseEntry).getNode();
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    return (T) new TriplePattern(subjectNode, predicateNode, objectNode);
}
Also used : Node(com.hp.hpl.jena.graph.Node) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) ClauseEntry(com.hp.hpl.jena.reasoner.rulesys.ClauseEntry) NodeClauseEntry(org.apache.stanbol.rules.adapters.jena.NodeClauseEntry) RuleAtomCallExeption(org.apache.stanbol.rules.base.api.RuleAtomCallExeption) NodeClauseEntry(org.apache.stanbol.rules.adapters.jena.NodeClauseEntry) TriplePattern(com.hp.hpl.jena.reasoner.TriplePattern) RuleAtom(org.apache.stanbol.rules.base.api.RuleAtom)

Example 3 with TriplePattern

use of com.hp.hpl.jena.reasoner.TriplePattern in project stanbol by apache.

the class IndividualPropertyAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    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();
    System.out.println(argument1);
    ClauseEntry argument2ClauseEntry = adapter.adaptTo(argument2, Rule.class);
    ClauseEntry argument1ClauseEntry = adapter.adaptTo(argument1, Rule.class);
    ClauseEntry objectPropertyClauseEntry = adapter.adaptTo(objectProperty, Rule.class);
    Node subjectNode;
    Node predicateNode;
    Node objectNode;
    System.out.println(argument1ClauseEntry.getClass());
    if (argument1ClauseEntry instanceof NodeClauseEntry) {
        subjectNode = ((NodeClauseEntry) argument1ClauseEntry).getNode();
    } else if (argument1ClauseEntry instanceof VariableClauseEntry) {
        subjectNode = ((VariableClauseEntry) argument1ClauseEntry).getNode();
        System.out.println("Here");
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    if (objectPropertyClauseEntry instanceof NodeClauseEntry) {
        predicateNode = ((NodeClauseEntry) objectPropertyClauseEntry).getNode();
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    if (argument2ClauseEntry instanceof NodeClauseEntry) {
        objectNode = ((NodeClauseEntry) argument2ClauseEntry).getNode();
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    return (T) new TriplePattern(subjectNode, predicateNode, objectNode);
}
Also used : Node(com.hp.hpl.jena.graph.Node) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) VariableClauseEntry(org.apache.stanbol.rules.adapters.jena.VariableClauseEntry) ClauseEntry(com.hp.hpl.jena.reasoner.rulesys.ClauseEntry) NodeClauseEntry(org.apache.stanbol.rules.adapters.jena.NodeClauseEntry) RuleAtomCallExeption(org.apache.stanbol.rules.base.api.RuleAtomCallExeption) NodeClauseEntry(org.apache.stanbol.rules.adapters.jena.NodeClauseEntry) TriplePattern(com.hp.hpl.jena.reasoner.TriplePattern) VariableClauseEntry(org.apache.stanbol.rules.adapters.jena.VariableClauseEntry)

Example 4 with TriplePattern

use of com.hp.hpl.jena.reasoner.TriplePattern in project stanbol by apache.

the class ClassAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.ClassAtom tmp = (org.apache.stanbol.rules.manager.atoms.ClassAtom) ruleAtom;
    IObjectAtom argument1 = tmp.getArgument1();
    IObjectAtom classResource = tmp.getClassResource();
    ClauseEntry argumentClauseEntry = adapter.adaptTo(argument1, Rule.class);
    ClauseEntry classClauseEntry = adapter.adaptTo(classResource, Rule.class);
    Node argumnetNode;
    Node classNode;
    if (argumentClauseEntry instanceof NodeClauseEntry) {
        argumnetNode = ((NodeClauseEntry) argumentClauseEntry).getNode();
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    if (classClauseEntry instanceof NodeClauseEntry) {
        classNode = ((NodeClauseEntry) classClauseEntry).getNode();
    } else {
        throw new RuleAtomCallExeption(getClass());
    }
    return (T) new TriplePattern(argumnetNode, Node_RuleVariable.createURI(RDF.type.getURI()), classNode);
}
Also used : Node(com.hp.hpl.jena.graph.Node) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) ClauseEntry(com.hp.hpl.jena.reasoner.rulesys.ClauseEntry) NodeClauseEntry(org.apache.stanbol.rules.adapters.jena.NodeClauseEntry) RuleAtomCallExeption(org.apache.stanbol.rules.base.api.RuleAtomCallExeption) NodeClauseEntry(org.apache.stanbol.rules.adapters.jena.NodeClauseEntry) TriplePattern(com.hp.hpl.jena.reasoner.TriplePattern)

Aggregations

Node (com.hp.hpl.jena.graph.Node)4 TriplePattern (com.hp.hpl.jena.reasoner.TriplePattern)4 ClauseEntry (com.hp.hpl.jena.reasoner.rulesys.ClauseEntry)4 NodeClauseEntry (org.apache.stanbol.rules.adapters.jena.NodeClauseEntry)4 RuleAtomCallExeption (org.apache.stanbol.rules.base.api.RuleAtomCallExeption)4 IObjectAtom (org.apache.stanbol.rules.manager.atoms.IObjectAtom)4 VariableClauseEntry (org.apache.stanbol.rules.adapters.jena.VariableClauseEntry)1 RuleAtom (org.apache.stanbol.rules.base.api.RuleAtom)1