use of org.semanticweb.owlapi.model.SWRLIArgument 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;
URI uri = tmp.getURI();
return (T) new ArgumentSWRLAtom((SWRLIArgument) OWLManager.getOWLDataFactory().getSWRLVariable(IRI.create(uri.toString())), uri.toString());
}
use of org.semanticweb.owlapi.model.SWRLIArgument in project stanbol by apache.
the class ClassAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.ClassAtom tmp = (org.apache.stanbol.rules.manager.atoms.ClassAtom) ruleAtom;
OWLDataFactory factory = OWLManager.getOWLDataFactory();
IObjectAtom classResource = tmp.getClassResource();
IObjectAtom argument = tmp.getArgument1();
SWRLAtom classResourceAtom = (SWRLAtom) adapter.adaptTo(classResource, SWRLRule.class);
SWRLAtom argumentAtom = (SWRLAtom) adapter.adaptTo(argument, SWRLRule.class);
OWLClass classPredicate;
SWRLIArgument argumentResource;
if (classResourceAtom instanceof ArgumentSWRLAtom) {
classPredicate = factory.getOWLClass(IRI.create(((ArgumentSWRLAtom) classResourceAtom).getId()));
} else {
throw new RuleAtomCallExeption(getClass());
}
if (argumentAtom instanceof ArgumentSWRLAtom) {
argumentResource = (SWRLIArgument) ((ArgumentSWRLAtom) argumentAtom).getSwrlArgument();
} else {
throw new RuleAtomCallExeption(getClass());
}
return (T) factory.getSWRLClassAtom(classPredicate, argumentResource);
}
use of org.semanticweb.owlapi.model.SWRLIArgument in project stanbol by apache.
the class DatavaluedPropertyAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnsupportedTypeForExportException, UnavailableRuleObjectException {
org.apache.stanbol.rules.manager.atoms.DatavaluedPropertyAtom tmp = (org.apache.stanbol.rules.manager.atoms.DatavaluedPropertyAtom) ruleAtom;
IObjectAtom argument1 = tmp.getArgument1();
IObjectAtom datatypeProperty = tmp.getDatatypeProperty();
RuleAtom argument2 = tmp.getArgument2();
SWRLAtom arg1Atom = (SWRLAtom) adapter.adaptTo(argument1, SWRLRule.class);
SWRLAtom predicateAtom = (SWRLAtom) adapter.adaptTo(datatypeProperty, SWRLRule.class);
SWRLAtom arg2Atom = (SWRLAtom) adapter.adaptTo(argument2, SWRLRule.class);
OWLDataFactory factory = OWLManager.getOWLDataFactory();
OWLDataProperty owlDataProperty;
SWRLIArgument swrliArgument;
SWRLDArgument swrldArgument;
if (predicateAtom instanceof ArgumentSWRLAtom) {
owlDataProperty = factory.getOWLDataProperty(IRI.create(((ArgumentSWRLAtom) predicateAtom).getId()));
} else {
throw new RuleAtomCallExeption(getClass());
}
if (arg1Atom instanceof ArgumentSWRLAtom) {
swrliArgument = (SWRLIArgument) ((ArgumentSWRLAtom) arg1Atom).getSwrlArgument();
} else {
throw new RuleAtomCallExeption(getClass());
}
if (arg2Atom instanceof ArgumentSWRLAtom) {
swrldArgument = (SWRLDArgument) ((ArgumentSWRLAtom) arg2Atom).getSwrlArgument();
} else {
throw new RuleAtomCallExeption(getClass());
}
return (T) factory.getSWRLDataPropertyAtom(owlDataProperty, swrliArgument, swrldArgument);
}
use of org.semanticweb.owlapi.model.SWRLIArgument in project stanbol by apache.
the class IndividualPropertyAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnsupportedTypeForExportException, UnavailableRuleObjectException {
org.apache.stanbol.rules.manager.atoms.IndividualPropertyAtom tmp = (org.apache.stanbol.rules.manager.atoms.IndividualPropertyAtom) ruleAtom;
IObjectAtom argument1 = tmp.getArgument1();
IObjectAtom argument2 = tmp.getArgument2();
IObjectAtom objectProperty = tmp.getObjectProperty();
SWRLAtom predicateAtom = (SWRLAtom) adapter.adaptTo(objectProperty, SWRLRule.class);
SWRLAtom subjectAtom = (SWRLAtom) adapter.adaptTo(argument1, SWRLRule.class);
SWRLAtom objectAtom = (SWRLAtom) adapter.adaptTo(argument2, SWRLRule.class);
OWLDataFactory factory = OWLManager.getOWLDataFactory();
OWLObjectProperty owlObjectProperty;
SWRLIArgument swrliArgument1;
SWRLIArgument swrliArgument2;
if (predicateAtom instanceof ArgumentSWRLAtom) {
owlObjectProperty = factory.getOWLObjectProperty(IRI.create(((ArgumentSWRLAtom) predicateAtom).getId()));
} else {
throw new RuleAtomCallExeption(getClass());
}
if (subjectAtom instanceof ArgumentSWRLAtom) {
swrliArgument1 = (SWRLIArgument) ((ArgumentSWRLAtom) subjectAtom).getSwrlArgument();
} else {
throw new RuleAtomCallExeption(getClass());
}
if (objectAtom instanceof ArgumentSWRLAtom) {
swrliArgument2 = (SWRLIArgument) ((ArgumentSWRLAtom) objectAtom).getSwrlArgument();
} else {
throw new RuleAtomCallExeption(getClass());
}
return (T) factory.getSWRLObjectPropertyAtom(owlObjectProperty, swrliArgument1, swrliArgument2);
}
use of org.semanticweb.owlapi.model.SWRLIArgument in project stanbol by apache.
the class ResourceAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.ResourceAtom tmp = (org.apache.stanbol.rules.manager.atoms.ResourceAtom) ruleAtom;
URI uri = tmp.getURI();
OWLDataFactory factory = OWLManager.getOWLDataFactory();
OWLIndividual owlIndividual = factory.getOWLNamedIndividual(IRI.create(uri.toString()));
SWRLIArgument swrliArgument = factory.getSWRLIndividualArgument(owlIndividual);
return (T) new ArgumentSWRLAtom(swrliArgument, uri.toString());
}
Aggregations