use of org.apache.stanbol.rules.manager.atoms.StringFunctionAtom 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);
}
use of org.apache.stanbol.rules.manager.atoms.StringFunctionAtom in project stanbol by apache.
the class ConcatAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.ConcatAtom tmp = (org.apache.stanbol.rules.manager.atoms.ConcatAtom) ruleAtom;
String sparqlConcat = "<http://www.w3.org/2005/xpath-functions#concat>";
StringFunctionAtom argument1 = tmp.getArgument1();
StringFunctionAtom argument2 = tmp.getArgument2();
SPARQLObject sparqlArgument1;
sparqlArgument1 = adapter.adaptTo(argument1, SPARQLObject.class);
SPARQLObject sparqlArgument2 = adapter.adaptTo(argument2, SPARQLObject.class);
String function = sparqlConcat + " (" + sparqlArgument1.getObject() + ", " + sparqlArgument2.getObject() + ")";
return (T) new SPARQLFunction(function);
}
use of org.apache.stanbol.rules.manager.atoms.StringFunctionAtom in project stanbol by apache.
the class LetAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.LetAtom tmp = (org.apache.stanbol.rules.manager.atoms.LetAtom) ruleAtom;
StringFunctionAtom parameterFunctionAtom = tmp.getParameterFunctionAtom();
IObjectAtom variableIObjectAtom = tmp.getVariable();
ClauseEntry parameterClauseEntry = adapter.adaptTo(parameterFunctionAtom, Rule.class);
ClauseEntry variableClauseEntry = adapter.adaptTo(variableIObjectAtom, Rule.class);
List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
Node parameterNode;
Node variableNode;
if (parameterClauseEntry instanceof HigherOrderClauseEntry) {
parameterNode = ((HigherOrderClauseEntry) parameterClauseEntry).getBindableNode();
clauseEntries.addAll(((HigherOrderClauseEntry) parameterClauseEntry).getClauseEntries());
} else if (parameterClauseEntry instanceof NodeClauseEntry) {
parameterNode = ((NodeClauseEntry) parameterClauseEntry).getNode();
} else {
throw new RuleAtomCallExeption(getClass());
}
if (variableClauseEntry instanceof NodeClauseEntry) {
variableNode = ((NodeClauseEntry) variableClauseEntry).getNode();
} else {
throw new RuleAtomCallExeption(getClass());
}
java.util.List<Node> nodes = new ArrayList<Node>();
nodes.add(variableNode);
nodes.add(parameterNode);
ClauseEntry clauseEntry = new Functor("makeSkolem", nodes, BuiltinRegistry.theRegistry);
clauseEntries.add(clauseEntry);
return (T) new HigherOrderClauseEntry(variableNode, clauseEntries);
}
Aggregations