Search in sources :

Example 1 with SWRLIArgument

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());
}
Also used : ArgumentSWRLAtom(org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom) URI(java.net.URI) SWRLIArgument(org.semanticweb.owlapi.model.SWRLIArgument)

Example 2 with SWRLIArgument

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);
}
Also used : ArgumentSWRLAtom(org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) SWRLIArgument(org.semanticweb.owlapi.model.SWRLIArgument) SWRLAtom(org.semanticweb.owlapi.model.SWRLAtom) ArgumentSWRLAtom(org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom) SWRLRule(org.semanticweb.owlapi.model.SWRLRule) OWLClass(org.semanticweb.owlapi.model.OWLClass) RuleAtomCallExeption(org.apache.stanbol.rules.base.api.RuleAtomCallExeption) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory)

Example 3 with SWRLIArgument

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);
}
Also used : ArgumentSWRLAtom(org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) SWRLIArgument(org.semanticweb.owlapi.model.SWRLIArgument) OWLDataProperty(org.semanticweb.owlapi.model.OWLDataProperty) SWRLDArgument(org.semanticweb.owlapi.model.SWRLDArgument) SWRLAtom(org.semanticweb.owlapi.model.SWRLAtom) ArgumentSWRLAtom(org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom) SWRLRule(org.semanticweb.owlapi.model.SWRLRule) RuleAtomCallExeption(org.apache.stanbol.rules.base.api.RuleAtomCallExeption) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory) RuleAtom(org.apache.stanbol.rules.base.api.RuleAtom)

Example 4 with SWRLIArgument

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);
}
Also used : ArgumentSWRLAtom(org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom) OWLObjectProperty(org.semanticweb.owlapi.model.OWLObjectProperty) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) SWRLIArgument(org.semanticweb.owlapi.model.SWRLIArgument) SWRLAtom(org.semanticweb.owlapi.model.SWRLAtom) ArgumentSWRLAtom(org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom) SWRLRule(org.semanticweb.owlapi.model.SWRLRule) RuleAtomCallExeption(org.apache.stanbol.rules.base.api.RuleAtomCallExeption) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory)

Example 5 with SWRLIArgument

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());
}
Also used : ArgumentSWRLAtom(org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom) URI(java.net.URI) SWRLIArgument(org.semanticweb.owlapi.model.SWRLIArgument) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory) OWLIndividual(org.semanticweb.owlapi.model.OWLIndividual)

Aggregations

ArgumentSWRLAtom (org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom)5 SWRLIArgument (org.semanticweb.owlapi.model.SWRLIArgument)5 OWLDataFactory (org.semanticweb.owlapi.model.OWLDataFactory)4 RuleAtomCallExeption (org.apache.stanbol.rules.base.api.RuleAtomCallExeption)3 IObjectAtom (org.apache.stanbol.rules.manager.atoms.IObjectAtom)3 SWRLAtom (org.semanticweb.owlapi.model.SWRLAtom)3 SWRLRule (org.semanticweb.owlapi.model.SWRLRule)3 URI (java.net.URI)2 RuleAtom (org.apache.stanbol.rules.base.api.RuleAtom)1 OWLClass (org.semanticweb.owlapi.model.OWLClass)1 OWLDataProperty (org.semanticweb.owlapi.model.OWLDataProperty)1 OWLIndividual (org.semanticweb.owlapi.model.OWLIndividual)1 OWLObjectProperty (org.semanticweb.owlapi.model.OWLObjectProperty)1 SWRLDArgument (org.semanticweb.owlapi.model.SWRLDArgument)1