Search in sources :

Example 96 with OWLClass

use of org.semanticweb.owlapi.model.OWLClass in project molgenis by molgenis.

the class OntologyLoader method getChildClass.

public Set<OWLClass> getChildClass(OWLClass cls) {
    Set<OWLClass> listOfClasses = new HashSet<>();
    for (OWLSubClassOfAxiom axiom : ontology.getSubClassAxiomsForSuperClass(cls)) {
        OWLClassExpression expression = axiom.getSubClass();
        if (!expression.isAnonymous()) {
            OWLClass asOWLClass = expression.asOWLClass();
            listOfClasses.add(asOWLClass);
        }
    }
    return listOfClasses;
}
Also used : OWLSubClassOfAxiom(org.semanticweb.owlapi.model.OWLSubClassOfAxiom) OWLClass(org.semanticweb.owlapi.model.OWLClass) OWLClassExpression(org.semanticweb.owlapi.model.OWLClassExpression) HashSet(java.util.HashSet)

Example 97 with OWLClass

use of org.semanticweb.owlapi.model.OWLClass in project molgenis by molgenis.

the class OntologyRepositoryCollection method createNodePaths.

/**
 * Creates {@link OntologyTermNodePathMetadata} {@link Entity}s for an entire ontology tree and
 * writes them to the {@link #nodePathsPerOntologyTerm} {@link Multimap}.
 */
private void createNodePaths() {
    TreeTraverser<OWLClassContainer> traverser = new TreeTraverser<OWLClassContainer>() {

        @Override
        public Iterable<OWLClassContainer> children(OWLClassContainer container) {
            int count = 0;
            List<OWLClassContainer> containers = new ArrayList<>();
            for (OWLClass childClass : loader.getChildClass(container.getOwlClass())) {
                containers.add(new OWLClassContainer(childClass, constructNodePath(container.getNodePath(), count), false));
                count++;
            }
            return containers;
        }
    };
    OWLClass pseudoRootClass = loader.createClass(PSEUDO_ROOT_CLASS_LABEL, loader.getRootClasses());
    for (OWLClassContainer container : traverser.preOrderTraversal(new OWLClassContainer(pseudoRootClass, PSEUDO_ROOT_CLASS_NODEPATH, true))) {
        OWLClass ontologyTerm = container.getOwlClass();
        String ontologyTermNodePath = container.getNodePath();
        String ontologyTermIRI = ontologyTerm.getIRI().toString();
        OntologyTermNodePath nodePathEntity = createNodePathEntity(container, ontologyTermNodePath);
        nodePathsPerOntologyTerm.put(ontologyTermIRI, nodePathEntity);
    }
}
Also used : TreeTraverser(com.google.common.collect.TreeTraverser) OntologyTermNodePath(org.molgenis.ontology.core.meta.OntologyTermNodePath) ArrayList(java.util.ArrayList) OWLClass(org.semanticweb.owlapi.model.OWLClass) OWLClassContainer(org.molgenis.ontology.core.utils.OWLClassContainer)

Example 98 with OWLClass

use of org.semanticweb.owlapi.model.OWLClass in project webprotege by protegeproject.

the class DataFactory_TestCase method test_getFreshEntityReturnsFreshEntityWithNoLangTag.

@Test
public void test_getFreshEntityReturnsFreshEntityWithNoLangTag() {
    OWLClass cls = DataFactory.getFreshOWLEntity(EntityType.CLASS, "X", Optional.empty());
    assertTrue(DataFactory.isFreshEntity(cls));
    assertEquals("X", DataFactory.getFreshEntityShortName(cls));
    assertEquals(Optional.empty(), DataFactory.getFreshEntityLangTag(cls));
}
Also used : OWLClass(org.semanticweb.owlapi.model.OWLClass) Test(org.junit.Test)

Example 99 with OWLClass

use of org.semanticweb.owlapi.model.OWLClass in project webprotege by protegeproject.

the class DataFactory_TestCase method test_getFreshEntityReturnsFreshEntity.

@Test
public void test_getFreshEntityReturnsFreshEntity() {
    OWLClass cls = DataFactory.getFreshOWLEntity(EntityType.CLASS, "X", Optional.empty());
    assertTrue(DataFactory.isFreshEntity(cls));
    assertEquals("X", DataFactory.getFreshEntityShortName(cls));
}
Also used : OWLClass(org.semanticweb.owlapi.model.OWLClass) Test(org.junit.Test)

Example 100 with OWLClass

use of org.semanticweb.owlapi.model.OWLClass in project webprotege by protegeproject.

the class FormSubjectFactoryDescriptorPresenter method getDescriptor.

@Nonnull
public Optional<FormSubjectFactoryDescriptor> getDescriptor() {
    EntityType<?> entityType = view.getEntityType();
    OWLClass parent = view.getParentClass().map(OWLClassData::getEntity).orElse(null);
    return Optional.of(FormSubjectFactoryDescriptor.get(entityType, parent, Optional.empty()));
}
Also used : OWLClass(org.semanticweb.owlapi.model.OWLClass) Nonnull(javax.annotation.Nonnull)

Aggregations

OWLClass (org.semanticweb.owlapi.model.OWLClass)163 OWLNamedIndividual (org.semanticweb.owlapi.model.OWLNamedIndividual)85 Set (java.util.Set)64 Collectors (java.util.stream.Collectors)62 List (java.util.List)59 ValidationError (com.opensimulationplatform.core.validation.ValidationError)53 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)29 OWLDataFactory (org.semanticweb.owlapi.model.OWLDataFactory)20 OWLOntologyManager (org.semanticweb.owlapi.model.OWLOntologyManager)20 OWLOntologyCreationException (org.semanticweb.owlapi.model.OWLOntologyCreationException)18 IRI (org.semanticweb.owlapi.model.IRI)17 HashSet (java.util.HashSet)16 OWLAxiom (org.semanticweb.owlapi.model.OWLAxiom)16 OWLObjectProperty (org.semanticweb.owlapi.model.OWLObjectProperty)14 OWLAnnotation (org.semanticweb.owlapi.model.OWLAnnotation)13 OWLDataProperty (org.semanticweb.owlapi.model.OWLDataProperty)13 OWLAnnotationProperty (org.semanticweb.owlapi.model.OWLAnnotationProperty)11 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)9 OWLAnnotationAssertionAxiom (org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom)8