use of org.semanticweb.owlapi.model.SWRLDArgument 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;
ExpressionAtom argument = tmp.getArgument();
ExpressionAtom term = tmp.getTerm();
OWLDataFactory factory = OWLManager.getOWLDataFactory();
SWRLAtom swrlAtom1 = (SWRLAtom) adapter.adaptTo(argument, SWRLRule.class);
SWRLAtom swrlAtom2 = (SWRLAtom) adapter.adaptTo(term, 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);
return (T) factory.getSWRLBuiltInAtom(SWRLBuiltInsVocabulary.STARTS_WITH.getIRI(), swrldArguments);
}
use of org.semanticweb.owlapi.model.SWRLDArgument in project stanbol by apache.
the class StringAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
org.apache.stanbol.rules.manager.atoms.StringAtom tmp = (org.apache.stanbol.rules.manager.atoms.StringAtom) ruleAtom;
String string = tmp.getString();
OWLDataFactory factory = OWLManager.getOWLDataFactory();
SWRLDArgument swrldArgument = null;
if (string.startsWith(Symbols.variablesPrefix)) {
swrldArgument = factory.getSWRLVariable(IRI.create(string));
} else {
swrldArgument = SWRLLiteralBuilder.getSWRLLiteral(string);
}
return (T) new ArgumentSWRLAtom(swrldArgument, string);
}
Aggregations