use of org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry in project stanbol by apache.
the class DivisionAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
String div_result = "div_result" + System.currentTimeMillis();
Node arg1Node = null;
Node arg2Node = null;
Node arg3Node = Node_RuleVariable.createVariable(div_result);
org.apache.stanbol.rules.manager.atoms.DivisionAtom tmp = (org.apache.stanbol.rules.manager.atoms.DivisionAtom) ruleAtom;
NumericFunctionAtom numericFunctionAtom1 = tmp.getNumericFunctionAtom1();
NumericFunctionAtom numericFunctionAtom2 = tmp.getNumericFunctionAtom2();
ClauseEntry clauseEntry1 = adapter.adaptTo(numericFunctionAtom1, Rule.class);
ClauseEntry clauseEntry2 = adapter.adaptTo(numericFunctionAtom2, Rule.class);
List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
if (clauseEntry1 instanceof HigherOrderClauseEntry) {
arg1Node = ((HigherOrderClauseEntry) clauseEntry1).getBindableNode();
clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry1).getClauseEntries());
} else if (clauseEntry1 instanceof NodeClauseEntry) {
arg1Node = ((NodeClauseEntry) clauseEntry1).getNode();
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
if (clauseEntry2 instanceof HigherOrderClauseEntry) {
arg2Node = ((HigherOrderClauseEntry) clauseEntry2).getBindableNode();
clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry2).getClauseEntries());
} else if (clauseEntry2 instanceof NodeClauseEntry) {
arg2Node = ((NodeClauseEntry) clauseEntry2).getNode();
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
java.util.List<Node> nodes = new ArrayList<Node>();
nodes.add(arg1Node);
nodes.add(arg2Node);
nodes.add(arg3Node);
ClauseEntry clauseEntry = new Functor("quotient", nodes, BuiltinRegistry.theRegistry);
clauseEntries.add(clauseEntry);
return (T) new HigherOrderClauseEntry(arg3Node, clauseEntries);
}
use of org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry in project stanbol by apache.
the class GreaterEqualThanAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
Node arg1Node = null;
Node arg2Node = null;
org.apache.stanbol.rules.manager.atoms.GreaterEqualThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.GreaterEqualThanAtom) ruleAtom;
ExpressionAtom argument1 = tmp.getArgument1();
ExpressionAtom argument2 = tmp.getArgument2();
ClauseEntry clauseEntry1 = adapter.adaptTo(argument1, Rule.class);
ClauseEntry clauseEntry2 = adapter.adaptTo(argument2, Rule.class);
List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
if (clauseEntry1 instanceof HigherOrderClauseEntry) {
arg1Node = ((HigherOrderClauseEntry) clauseEntry1).getBindableNode();
clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry1).getClauseEntries());
} else if (clauseEntry1 instanceof NodeClauseEntry) {
arg1Node = ((NodeClauseEntry) clauseEntry1).getNode();
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
if (clauseEntry2 instanceof HigherOrderClauseEntry) {
arg2Node = ((HigherOrderClauseEntry) clauseEntry2).getBindableNode();
clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry2).getClauseEntries());
} else if (clauseEntry2 instanceof NodeClauseEntry) {
arg2Node = ((NodeClauseEntry) clauseEntry2).getNode();
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
List<Node> nodes = new ArrayList<Node>();
nodes.add(arg1Node);
nodes.add(arg2Node);
Functor functor = new Functor("ge", nodes, BuiltinRegistry.theRegistry);
clauseEntries.add(functor);
return (T) new HigherOrderClauseEntry(arg1Node, clauseEntries);
}
use of org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry in project stanbol by apache.
the class LessEqualThanAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
Node arg1Node = null;
Node arg2Node = null;
org.apache.stanbol.rules.manager.atoms.LessEqualThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.LessEqualThanAtom) ruleAtom;
ExpressionAtom argument1 = tmp.getArgument1();
ExpressionAtom argument2 = tmp.getArgument2();
ClauseEntry clauseEntry1 = adapter.adaptTo(argument1, Rule.class);
ClauseEntry clauseEntry2 = adapter.adaptTo(argument2, Rule.class);
List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
if (clauseEntry1 instanceof HigherOrderClauseEntry) {
arg1Node = ((HigherOrderClauseEntry) clauseEntry1).getBindableNode();
clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry1).getClauseEntries());
} else if (clauseEntry1 instanceof NodeClauseEntry) {
arg1Node = ((NodeClauseEntry) clauseEntry1).getNode();
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
if (clauseEntry2 instanceof HigherOrderClauseEntry) {
arg2Node = ((HigherOrderClauseEntry) clauseEntry2).getBindableNode();
clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry2).getClauseEntries());
} else if (clauseEntry2 instanceof NodeClauseEntry) {
arg2Node = ((NodeClauseEntry) clauseEntry2).getNode();
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
java.util.List<Node> nodes = new ArrayList<Node>();
nodes.add(arg1Node);
nodes.add(arg2Node);
Functor functor = new Functor("le", nodes, BuiltinRegistry.theRegistry);
clauseEntries.add(functor);
return (T) new HigherOrderClauseEntry(arg1Node, clauseEntries);
}
use of org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry 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 iObjectAtom = tmp.getUriResource();
ClauseEntry iObjectClauseEntry = adapter.adaptTo(iObjectAtom, Rule.class);
if (iObjectClauseEntry instanceof NodeClauseEntry) {
Node node = ((NodeClauseEntry) iObjectClauseEntry).getNode();
Node emptyString = Node_RuleVariable.createLiteral("");
Node bindind = Node_RuleVariable.createVariable("str_reuslt" + System.currentTimeMillis());
List<Node> args = new ArrayList<Node>();
args.add(node);
args.add(emptyString);
args.add(bindind);
Functor functor = new Functor("strConcat", args);
List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
clauseEntries.add(functor);
return (T) new HigherOrderClauseEntry(node, clauseEntries);
} else {
throw new RuleAtomCallExeption(getClass());
}
}
use of org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry in project stanbol by apache.
the class SumAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
String div_result = "sum_result" + System.currentTimeMillis();
Node arg1Node = null;
Node arg2Node = null;
Node arg3Node = Node_RuleVariable.createVariable(div_result);
org.apache.stanbol.rules.manager.atoms.SumAtom tmp = (org.apache.stanbol.rules.manager.atoms.SumAtom) ruleAtom;
NumericFunctionAtom numericFunctionAtom1 = tmp.getNumericFunctionAtom1();
NumericFunctionAtom numericFunctionAtom2 = tmp.getNumericFunctionAtom2();
ClauseEntry clauseEntry1 = adapter.adaptTo(numericFunctionAtom1, Rule.class);
ClauseEntry clauseEntry2 = adapter.adaptTo(numericFunctionAtom2, Rule.class);
List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
if (clauseEntry1 instanceof HigherOrderClauseEntry) {
arg1Node = ((HigherOrderClauseEntry) clauseEntry1).getBindableNode();
clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry1).getClauseEntries());
} else if (clauseEntry1 instanceof NodeClauseEntry) {
arg1Node = ((NodeClauseEntry) clauseEntry1).getNode();
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
if (clauseEntry2 instanceof HigherOrderClauseEntry) {
arg2Node = ((HigherOrderClauseEntry) clauseEntry2).getBindableNode();
clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry2).getClauseEntries());
} else if (clauseEntry2 instanceof NodeClauseEntry) {
arg2Node = ((NodeClauseEntry) clauseEntry2).getNode();
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
java.util.List<Node> nodes = new ArrayList<Node>();
nodes.add(arg1Node);
nodes.add(arg2Node);
nodes.add(arg3Node);
ClauseEntry clauseEntry = new Functor("sum", nodes, BuiltinRegistry.theRegistry);
clauseEntries.add(clauseEntry);
return (T) new HigherOrderClauseEntry(arg3Node, clauseEntries);
}
Aggregations