use of org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject in project stanbol by apache.
the class UpperCaseAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.UpperCaseAtom tmp = (org.apache.stanbol.rules.manager.atoms.UpperCaseAtom) ruleAtom;
StringFunctionAtom argument = tmp.getStringFunctionAtom();
ClerezzaSparqlObject argument1 = (ClerezzaSparqlObject) adapter.adaptTo(argument, ConstructQuery.class);
List<Expression> argumentExpressions = new ArrayList<Expression>();
argumentExpressions.add((Expression) argument1.getClerezzaObject());
FunctionCall functionCall = new FunctionCall(new IRI("<http://www.w3.org/2005/xpath-functions#upper-case>"), argumentExpressions);
return (T) new ClerezzaSparqlObject(functionCall);
}
use of org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject in project stanbol by apache.
the class VariableAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
org.apache.stanbol.rules.manager.atoms.VariableAtom tmp = (org.apache.stanbol.rules.manager.atoms.VariableAtom) ruleAtom;
String variableName = tmp.getVariableName();
Variable variable = new Variable(variableName);
return (T) new ClerezzaSparqlObject(variable);
}
use of org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject 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 objectProperty = tmp.getObjectProperty();
IObjectAtom argument2 = tmp.getArgument2();
ClerezzaSparqlObject argument1CSO = (ClerezzaSparqlObject) adapter.adaptTo(argument1, ConstructQuery.class);
ClerezzaSparqlObject datatypePropertyCSO = (ClerezzaSparqlObject) adapter.adaptTo(objectProperty, ConstructQuery.class);
ClerezzaSparqlObject argument2CSO = (ClerezzaSparqlObject) adapter.adaptTo(argument2, ConstructQuery.class);
Object arg1 = argument1CSO.getClerezzaObject();
Object dt = datatypePropertyCSO.getClerezzaObject();
Object arg2 = argument2CSO.getClerezzaObject();
UriRefOrVariable subject;
UriRefOrVariable predicate;
ResourceOrVariable object;
if (arg1 instanceof Variable) {
subject = new UriRefOrVariable((Variable) arg1);
} else if (arg1 instanceof IRI) {
subject = new UriRefOrVariable((IRI) arg1);
} else {
throw new RuleAtomCallExeption(getClass());
}
if (dt instanceof Variable) {
predicate = new UriRefOrVariable((Variable) dt);
} else if (dt instanceof IRI) {
predicate = new UriRefOrVariable((IRI) dt);
} else {
throw new RuleAtomCallExeption(getClass());
}
if (arg2 instanceof Variable) {
object = new UriRefOrVariable((Variable) arg2);
} else if (dt instanceof IRI) {
object = new UriRefOrVariable((IRI) arg2);
} else {
throw new RuleAtomCallExeption(getClass());
}
return (T) new ClerezzaSparqlObject(new SimpleTriplePattern(subject, predicate, object));
}
use of org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject in project stanbol by apache.
the class LengthAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.LengthAtom tmp = (org.apache.stanbol.rules.manager.atoms.LengthAtom) ruleAtom;
StringFunctionAtom argument = tmp.getStringFunctionAtom();
ClerezzaSparqlObject argument1 = (ClerezzaSparqlObject) adapter.adaptTo(argument, ConstructQuery.class);
List<Expression> argumentExpressions = new ArrayList<Expression>();
argumentExpressions.add((Expression) argument1.getClerezzaObject());
FunctionCall functionCall = new FunctionCall(new IRI("<http://www.w3.org/2005/xpath-functions#string-length>"), argumentExpressions);
return (T) new ClerezzaSparqlObject(functionCall);
}
use of org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject in project stanbol by apache.
the class LessEqualThanAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.LessEqualThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.LessEqualThanAtom) ruleAtom;
ExpressionAtom argument1 = tmp.getArgument1();
ExpressionAtom argument2 = tmp.getArgument2();
ClerezzaSparqlObject clerezzaArgument1 = (ClerezzaSparqlObject) adapter.adaptTo(argument1, ConstructQuery.class);
ClerezzaSparqlObject clerezzaArgument2 = (ClerezzaSparqlObject) adapter.adaptTo(argument2, ConstructQuery.class);
Expression lhe = (Expression) clerezzaArgument1.getClerezzaObject();
Expression rhe = (Expression) clerezzaArgument2.getClerezzaObject();
return (T) new ClerezzaSparqlObject(new BinaryOperation("<=", lhe, rhe));
}
Aggregations