use of org.apache.stanbol.rules.manager.atoms.StringFunctionAtom 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.stanbol.rules.manager.atoms.StringFunctionAtom 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.stanbol.rules.manager.atoms.StringFunctionAtom in project stanbol by apache.
the class StartsWithAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.StartsWithAtom tmp = (org.apache.stanbol.rules.manager.atoms.StartsWithAtom) ruleAtom;
StringFunctionAtom argument = tmp.getArgument();
StringFunctionAtom term = tmp.getTerm();
ClerezzaSparqlObject argument1 = (ClerezzaSparqlObject) adapter.adaptTo(argument, ConstructQuery.class);
ClerezzaSparqlObject argument2 = (ClerezzaSparqlObject) adapter.adaptTo(term, ConstructQuery.class);
List<Expression> argumentExpressions = new ArrayList<Expression>();
argumentExpressions.add((Expression) argument1.getClerezzaObject());
argumentExpressions.add((Expression) argument2.getClerezzaObject());
FunctionCall functionCall = new FunctionCall(new IRI("<http://www.w3.org/2005/xpath-functions#starts-with>"), argumentExpressions);
return (T) new ClerezzaSparqlObject(functionCall);
}
use of org.apache.stanbol.rules.manager.atoms.StringFunctionAtom in project stanbol by apache.
the class UpperCaseAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
String uppercase_result = "uppercase_result" + System.currentTimeMillis();
org.apache.stanbol.rules.manager.atoms.UpperCaseAtom tmp = (org.apache.stanbol.rules.manager.atoms.UpperCaseAtom) ruleAtom;
StringFunctionAtom stringFunction = tmp.getStringFunctionAtom();
OWLDataFactory factory = OWLManager.getOWLDataFactory();
SWRLAtom stringFunctionAtom = (SWRLAtom) adapter.adaptTo(stringFunction, SWRLRule.class);
SWRLDArgument retArgument = factory.getSWRLVariable(IRI.create(Symbols.variablesPrefix + uppercase_result));
;
SWRLDArgument stringArgument;
List<SWRLAtom> listOfArguments = new ArrayList<SWRLAtom>();
if (stringFunctionAtom instanceof HigherOrderSWRLAtom) {
stringArgument = ((HigherOrderSWRLAtom) stringFunctionAtom).getBindableArgument();
listOfArguments.addAll(((HigherOrderSWRLAtom) stringFunctionAtom).getAtoms());
} else if (stringFunctionAtom instanceof ArgumentSWRLAtom) {
SWRLArgument swrlArgument = ((ArgumentSWRLAtom) stringFunctionAtom).getSwrlArgument();
stringArgument = (SWRLDArgument) swrlArgument;
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
List<SWRLDArgument> swrldArguments = new ArrayList<SWRLDArgument>();
swrldArguments.add(retArgument);
swrldArguments.add(stringArgument);
return (T) factory.getSWRLBuiltInAtom(SWRLBuiltInsVocabulary.UPPER_CASE.getIRI(), swrldArguments);
}
use of org.apache.stanbol.rules.manager.atoms.StringFunctionAtom in project stanbol by apache.
the class LowerCaseAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
String lowercase_result = "lowercase_result" + System.currentTimeMillis();
org.apache.stanbol.rules.manager.atoms.UpperCaseAtom tmp = (org.apache.stanbol.rules.manager.atoms.UpperCaseAtom) ruleAtom;
StringFunctionAtom stringFunction = tmp.getStringFunctionAtom();
OWLDataFactory factory = OWLManager.getOWLDataFactory();
SWRLAtom stringFunctionAtom = (SWRLAtom) adapter.adaptTo(stringFunction, SWRLRule.class);
SWRLDArgument retArgument = factory.getSWRLVariable(IRI.create(Symbols.variablesPrefix + lowercase_result));
;
SWRLDArgument stringArgument;
List<SWRLAtom> listOfArguments = new ArrayList<SWRLAtom>();
if (stringFunctionAtom instanceof HigherOrderSWRLAtom) {
stringArgument = ((HigherOrderSWRLAtom) stringFunctionAtom).getBindableArgument();
listOfArguments.addAll(((HigherOrderSWRLAtom) stringFunctionAtom).getAtoms());
} else if (stringFunctionAtom instanceof ArgumentSWRLAtom) {
SWRLArgument swrlArgument = ((ArgumentSWRLAtom) stringFunctionAtom).getSwrlArgument();
stringArgument = (SWRLDArgument) swrlArgument;
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
List<SWRLDArgument> swrldArguments = new ArrayList<SWRLDArgument>();
swrldArguments.add(retArgument);
swrldArguments.add(stringArgument);
return (T) factory.getSWRLBuiltInAtom(SWRLBuiltInsVocabulary.LOWER_CASE.getIRI(), swrldArguments);
}
Aggregations