use of org.apache.stanbol.rules.manager.atoms.ExpressionAtom in project stanbol by apache.
the class RuleParserImpl method lessEqualThanAtom.
public final LessEqualThanAtom lessEqualThanAtom() throws ParseException {
ExpressionAtom obj1;
ExpressionAtom obj2;
jj_consume_token(LESSEQUALTHAN);
jj_consume_token(LPAR);
obj1 = expressionAtom();
jj_consume_token(COMMA);
obj2 = expressionAtom();
jj_consume_token(RPAR);
{
if (true)
return new LessEqualThanAtom(obj1, obj2);
}
throw new Error("Missing return statement in function");
}
use of org.apache.stanbol.rules.manager.atoms.ExpressionAtom in project stanbol by apache.
the class RuleParserImpl method expressionAtom.
public final ExpressionAtom expressionAtom() throws ParseException {
ExpressionAtom expressionAtom;
switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case SUBSTRING:
case UPPERCASE:
case LOWERCASE:
case CONCAT:
case NAMESPACE:
case LOCALNAME:
case STR:
case CREATE_LABEL:
case PROP:
case VARIABLE:
case STRING:
expressionAtom = stringFunctionAtom();
break;
case LENGTH:
case PLUS:
case MINUS:
case NUM:
expressionAtom = numericFunctionAtom();
break;
default:
jj_la1[6] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{
if (true)
return expressionAtom;
}
throw new Error("Missing return statement in function");
}
use of org.apache.stanbol.rules.manager.atoms.ExpressionAtom in project stanbol by apache.
the class GreaterEqualThanAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.GreaterEqualThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.GreaterEqualThanAtom) ruleAtom;
ExpressionAtom argument1 = tmp.getArgument1();
ExpressionAtom argument2 = tmp.getArgument2();
OWLDataFactory factory = OWLManager.getOWLDataFactory();
SWRLAtom swrlAtom1 = (SWRLAtom) adapter.adaptTo(argument1, SWRLRule.class);
SWRLAtom swrlAtom2 = (SWRLAtom) adapter.adaptTo(argument2, SWRLRule.class);
SWRLDArgument swrldArgument1;
SWRLDArgument swrldArgument2;
List<SWRLAtom> listOfArguments = new ArrayList<SWRLAtom>();
if (swrlAtom1 instanceof HigherOrderSWRLAtom) {
swrldArgument1 = ((HigherOrderSWRLAtom) swrlAtom1).getBindableArgument();
listOfArguments.addAll(((HigherOrderSWRLAtom) swrlAtom1).getAtoms());
} else if (swrlAtom1 instanceof ArgumentSWRLAtom) {
SWRLArgument swrlArgument = ((ArgumentSWRLAtom) swrlAtom1).getSwrlArgument();
swrldArgument1 = (SWRLDArgument) swrlArgument;
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
if (swrlAtom2 instanceof HigherOrderSWRLAtom) {
swrldArgument2 = ((HigherOrderSWRLAtom) swrlAtom2).getBindableArgument();
listOfArguments.addAll(((HigherOrderSWRLAtom) swrlAtom2).getAtoms());
} else if (swrlAtom2 instanceof ArgumentSWRLAtom) {
SWRLArgument swrlArgument = ((ArgumentSWRLAtom) swrlAtom2).getSwrlArgument();
swrldArgument2 = (SWRLDArgument) swrlArgument;
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
List<SWRLDArgument> swrldArguments = new ArrayList<SWRLDArgument>();
swrldArguments.add(swrldArgument1);
swrldArguments.add(swrldArgument2);
SWRLBuiltInAtom swrlBuiltInAtom = factory.getSWRLBuiltInAtom(SWRLBuiltInsVocabulary.GREATER_THAN_OR_EQUAL.getIRI(), swrldArguments);
return (T) swrlBuiltInAtom;
}
use of org.apache.stanbol.rules.manager.atoms.ExpressionAtom in project stanbol by apache.
the class MultiplicationAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
String mul_result = "mul_result" + System.currentTimeMillis();
org.apache.stanbol.rules.manager.atoms.MultiplicationAtom tmp = (org.apache.stanbol.rules.manager.atoms.MultiplicationAtom) ruleAtom;
ExpressionAtom argument1 = tmp.getNumericFunctionAtom1();
ExpressionAtom argument2 = tmp.getNumericFunctionAtom2();
OWLDataFactory factory = OWLManager.getOWLDataFactory();
SWRLAtom swrlAtom1 = (SWRLAtom) adapter.adaptTo(argument1, SWRLRule.class);
SWRLAtom swrlAtom2 = (SWRLAtom) adapter.adaptTo(argument2, SWRLRule.class);
SWRLDArgument swrldArgument1 = factory.getSWRLVariable(IRI.create(Symbols.variablesPrefix + mul_result));
SWRLDArgument swrldArgument2;
SWRLDArgument swrldArgument3;
List<SWRLAtom> listOfArguments = new ArrayList<SWRLAtom>();
if (swrlAtom1 instanceof HigherOrderSWRLAtom) {
swrldArgument2 = ((HigherOrderSWRLAtom) swrlAtom1).getBindableArgument();
listOfArguments.addAll(((HigherOrderSWRLAtom) swrlAtom1).getAtoms());
} else if (swrlAtom1 instanceof ArgumentSWRLAtom) {
SWRLArgument swrlArgument = ((ArgumentSWRLAtom) swrlAtom1).getSwrlArgument();
swrldArgument2 = (SWRLDArgument) swrlArgument;
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
if (swrlAtom2 instanceof HigherOrderSWRLAtom) {
swrldArgument3 = ((HigherOrderSWRLAtom) swrlAtom2).getBindableArgument();
listOfArguments.addAll(((HigherOrderSWRLAtom) swrlAtom2).getAtoms());
} else if (swrlAtom2 instanceof ArgumentSWRLAtom) {
SWRLArgument swrlArgument = ((ArgumentSWRLAtom) swrlAtom2).getSwrlArgument();
swrldArgument3 = (SWRLDArgument) swrlArgument;
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
List<SWRLDArgument> swrldArguments = new ArrayList<SWRLDArgument>();
swrldArguments.add(swrldArgument1);
swrldArguments.add(swrldArgument2);
swrldArguments.add(swrldArgument3);
SWRLBuiltInAtom swrlBuiltInAtom = factory.getSWRLBuiltInAtom(SWRLBuiltInsVocabulary.MULTIPLY.getIRI(), swrldArguments);
listOfArguments.add(swrlBuiltInAtom);
return (T) new HigherOrderSWRLAtom(swrldArgument1, listOfArguments);
}
use of org.apache.stanbol.rules.manager.atoms.ExpressionAtom in project stanbol by apache.
the class TypedLiteralAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.TypedLiteralAtom tmp = (org.apache.stanbol.rules.manager.atoms.TypedLiteralAtom) ruleAtom;
ExpressionAtom valueExpression = tmp.getValue();
URIResource xsdTypeResource = tmp.getXsdType();
SPARQLObject sparqlObject = null;
sparqlObject = adapter.adaptTo(valueExpression, SPARQLObject.class);
String value = sparqlObject.getObject();
if (!value.startsWith("\"")) {
value = "\"" + value;
}
if (!value.endsWith("\"")) {
value += "\"";
}
String xsdType = "<" + xsdTypeResource.getURI().toString() + ">";
return (T) new SPARQLFunction(value + "^^" + xsdType);
}
Aggregations