use of org.apache.clerezza.rdf.core.sparql.query.BuiltInCall in project stanbol by apache.
the class IsBlankAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.IsBlankAtom tmp = (org.apache.stanbol.rules.manager.atoms.IsBlankAtom) ruleAtom;
IObjectAtom uriResource = tmp.getUriResource();
ClerezzaSparqlObject argumentCSO = (ClerezzaSparqlObject) adapter.adaptTo(uriResource, ConstructQuery.class);
;
Object arg = argumentCSO.getClerezzaObject();
Expression argumentExpression;
if (arg instanceof Variable) {
argumentExpression = (Variable) arg;
} else if (arg instanceof IRI) {
argumentExpression = new UriRefExpression((IRI) arg);
} else {
throw new RuleAtomCallExeption(getClass());
}
List<Expression> expressions = new ArrayList<Expression>();
expressions.add(argumentExpression);
return (T) new ClerezzaSparqlObject(new BuiltInCall("isBLANK", expressions));
}
use of org.apache.clerezza.rdf.core.sparql.query.BuiltInCall 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();
URIResource variableUriResource = tmp.getVariable();
ClerezzaSparqlObject iriArgument;
iriArgument = (ClerezzaSparqlObject) adapter.adaptTo(parameterFunctionAtom, ConstructQuery.class);
List<Expression> iriArgumentExpressions = new ArrayList<Expression>();
iriArgumentExpressions.add((Expression) iriArgument.getClerezzaObject());
BuiltInCall iriBuiltInCall = new BuiltInCall("IRI", iriArgumentExpressions);
if (variableUriResource instanceof VariableAtom) {
String variableName = ((VariableAtom) variableUriResource).getVariableName();
Variable variable = new Variable(variableName);
List<Expression> bindArgumentExpressions = new ArrayList<Expression>();
bindArgumentExpressions.add(iriBuiltInCall);
bindArgumentExpressions.add(variable);
BuiltInCall bindBuiltInCall = new BuiltInCall("BIND", iriArgumentExpressions);
return (T) new ClerezzaSparqlObject(bindBuiltInCall);
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
}
use of org.apache.clerezza.rdf.core.sparql.query.BuiltInCall in project stanbol by apache.
the class NewLiteralAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.NewLiteralAtom tmp = (org.apache.stanbol.rules.manager.atoms.NewLiteralAtom) 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> bindArgumentExpressions = new ArrayList<Expression>();
bindArgumentExpressions.add((Expression) binding.getClerezzaObject());
bindArgumentExpressions.add((Expression) variable.getClerezzaObject());
BuiltInCall bindBuiltInCall = new BuiltInCall("BIND", bindArgumentExpressions);
return (T) new ClerezzaSparqlObject(bindBuiltInCall);
}
use of org.apache.clerezza.rdf.core.sparql.query.BuiltInCall in project stanbol by apache.
the class NotAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.LowerCaseAtom tmp = (org.apache.stanbol.rules.manager.atoms.LowerCaseAtom) ruleAtom;
StringFunctionAtom argument = tmp.getStringFunctionAtom();
ClerezzaSparqlObject argument1 = (ClerezzaSparqlObject) adapter.adaptTo(argument, ConstructQuery.class);
List<Expression> argumentExpressions = new ArrayList<Expression>();
argumentExpressions.add((Expression) argument1.getClerezzaObject());
BuiltInCall builtInCall = new BuiltInCall("BOUND", argumentExpressions);
UnaryOperation unaryOperation = new UnaryOperation("!", builtInCall);
return (T) new ClerezzaSparqlObject(unaryOperation);
}
use of org.apache.clerezza.rdf.core.sparql.query.BuiltInCall 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 uriResource = tmp.getUriResource();
ClerezzaSparqlObject clerezzaSparqlObject = (ClerezzaSparqlObject) adapter.adaptTo(uriResource, ConstructQuery.class);
List<Expression> expressions = new ArrayList<Expression>();
expressions.add((Expression) clerezzaSparqlObject.getClerezzaObject());
return (T) new ClerezzaSparqlObject(new BuiltInCall("STR", expressions));
}
Aggregations