use of org.apache.stanbol.rules.manager.atoms.ExpressionAtom in project stanbol by apache.
the class GreaterThanAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.GreaterThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.GreaterThanAtom) 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.getIRI(), swrldArguments);
return (T) swrlBuiltInAtom;
}
use of org.apache.stanbol.rules.manager.atoms.ExpressionAtom 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();
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.LESS_THAN_OR_EQUAL.getIRI(), swrldArguments);
return (T) swrlBuiltInAtom;
}
use of org.apache.stanbol.rules.manager.atoms.ExpressionAtom in project stanbol by apache.
the class LessThanAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.LessThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.LessThanAtom) 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.LESS_THAN.getIRI(), swrldArguments);
return (T) swrlBuiltInAtom;
}
use of org.apache.stanbol.rules.manager.atoms.ExpressionAtom in project stanbol by apache.
the class SameAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.SameAtom tmp = (org.apache.stanbol.rules.manager.atoms.SameAtom) ruleAtom;
ExpressionAtom argument1 = tmp.getStringFunctionAtom1();
ExpressionAtom argument2 = tmp.getStringFunctionAtom2();
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.EQUAL.getIRI(), swrldArguments);
return (T) swrlBuiltInAtom;
}
use of org.apache.stanbol.rules.manager.atoms.ExpressionAtom in project stanbol by apache.
the class RuleParserImpl method greaterThanAtom.
public final GreaterThanAtom greaterThanAtom() throws ParseException {
ExpressionAtom obj1;
ExpressionAtom obj2;
jj_consume_token(GREATERTHAN);
jj_consume_token(LPAR);
obj1 = expressionAtom();
jj_consume_token(COMMA);
obj2 = expressionAtom();
jj_consume_token(RPAR);
{
if (true)
return new GreaterThanAtom(obj1, obj2);
}
throw new Error("Missing return statement in function");
}
Aggregations