Search in sources :

Example 1 with VariableClauseEntry

use of org.apache.stanbol.rules.adapters.jena.VariableClauseEntry 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)

Aggregations

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