Examples of RegistryItem


Examples of org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem

    @Override
    public Set<Library> getLibraries() {
        Set<Library> results = new HashSet<Library>();
        for (IRI key : population.keySet()) {
            RegistryItem item = population.get(key);
            if (item instanceof Library) results.add((Library) item);
        }
        return results;
    }
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem

    }

    @Override
    public Set<Library> getLibraries(IRI ontologyID) {
        Set<Library> results = new HashSet<Library>();
        RegistryItem ri = population.get(ontologyID);
        if (ri != null) for (RegistryItem item : ri.getParents())
            if (item instanceof Library) results.add((Library) item);
        return results;
    }
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem

        return results;
    }

    @Override
    public Library getLibrary(IRI id) {
        RegistryItem item = population.get(id);
        if (item != null && item instanceof Library) return (Library) item;
        return null;
    }
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem

    @Override
    public Set<Registry> getRegistries() {
        Set<Registry> results = new HashSet<Registry>();
        for (IRI key : population.keySet()) {
            RegistryItem item = population.get(key);
            if (item instanceof Registry) results.add((Registry) item);
        }
        return results;
    }
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem

        return results;
    }

    @Override
    public Registry getRegistry(IRI id) {
        RegistryItem item = population.get(id);
        return item != null && item instanceof Registry ? (Registry) item : null;
    }
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem

        }
    }

    protected Library populateLibrary(OWLNamedObject ind, Set<OWLOntology> registries) throws RegistryContentException {
        IRI libId = ind.getIRI();
        RegistryItem lib = null;
        if (population.containsKey(libId)) {
            // We are not allowing multityping either.
            lib = population.get(libId);
            if (!(lib instanceof Library)) throw new RegistryContentException(
                    "Inconsistent multityping: for item " + libId + " : {" + Library.class + ", "
                            + lib.getClass() + "}");
        } else {
            lib = riFactory.createLibrary(ind);
            try {
                population.put(lib.getIRI(), lib);
            } catch (Exception e) {
                log.error("Invalid identifier for library item " + lib, e);
                return null;
            }
        }
        // EXIT nodes.
        Set<OWLNamedObject> ironts = new HashSet<OWLNamedObject>();
        OWLDataFactory df = OWLManager.getOWLDataFactory();
        for (OWLOntology o : registries) {
            if (ind instanceof OWLIndividual) {
                // Get usages of hasOntology as an object property
                for (OWLIndividual value : ((OWLIndividual) ind).getObjectPropertyValues(hasOntology, o))
                    if (value.isNamed()) ironts.add(value.asOWLNamedIndividual());
                // Get usages of hasOntology as an annotation property
                for (OWLAnnotationAssertionAxiom ann : o.getAnnotationAssertionAxioms(ind.getIRI()))
                    if (hasOntologyAnn.equals(ann.getProperty())) {
                        OWLAnnotationValue value = ann.getValue();
                        if (value instanceof OWLNamedObject) ironts.add((OWLNamedObject) value);
                        else if (value instanceof IRI) ironts.add(df.getOWLNamedIndividual((IRI) value));
                    }
            }
        }
        for (OWLNamedObject iront : ironts) {
            IRI childId = iront.getIRI();
            // If some populate*() method has created it, it will be there.
            RegistryItem ront = population.get(childId);
            // Otherwise populating it will also put it in population.
            if (ront == null) ront = populateOntology(iront, registries);
            lib.addChild(ront);
            if (ontologyIndex.get(childId) == null) ontologyIndex.put(childId, new HashSet<IRI>());
            ontologyIndex.get(childId).add(libId);
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem

        return (Library) lib;
    }

    protected RegistryOntology populateOntology(OWLNamedObject ind, Set<OWLOntology> registries) throws RegistryContentException {
        IRI ontId = ind.getIRI();
        RegistryItem ront = null;
        if (population.containsKey(ontId)) {
            // We are not allowing multityping either.
            ront = population.get(ontId);
            if (!(ront instanceof RegistryOntology)) throw new RegistryContentException(
                    "Inconsistent multityping: for item " + ontId + " : {" + RegistryOntology.class + ", "
                            + ront.getClass() + "}");
        } else {
            ront = riFactory.createRegistryOntology(ind);
            try {
                population.put(ront.getIRI(), ront);
            } catch (Exception e) {
                log.error("Invalid identifier for library item " + ront, e);
                return null;
            }
        }
        // EXIT nodes.
        Set<OWLNamedObject> libs = new HashSet<OWLNamedObject>();
        OWLDataFactory df = OWLManager.getOWLDataFactory();
        for (OWLOntology o : registries) {
            if (ind instanceof OWLIndividual) {
                // Get usages of isOntologyOf as an object property
                for (OWLIndividual value : ((OWLIndividual) ind).getObjectPropertyValues(isOntologyOf, o))
                    if (value.isNamed()) libs.add(value.asOWLNamedIndividual());
                // Get usages of isOntologyOf as an annotation property
                for (OWLAnnotationAssertionAxiom ann : o.getAnnotationAssertionAxioms(ind.getIRI()))
                    if (isOntologyOfAnn.equals(ann.getProperty())) {
                        OWLAnnotationValue value = ann.getValue();
                        if (value instanceof OWLNamedObject) libs.add((OWLNamedObject) value);
                        else if (value instanceof IRI) libs.add(df.getOWLNamedIndividual((IRI) value));
                    }
            }
        }
        for (OWLNamedObject ilib : libs) {
            IRI parentId = ilib.getIRI();
            // If some populate*() method has created it, it will be there.
            RegistryItem rlib = population.get(parentId);
            // Otherwise populating it will also put it in population.
            if (rlib == null) rlib = populateLibrary(ilib, registries);
            ront.addParent(rlib);
            if (ontologyIndex.get(ontId) == null) ontologyIndex.put(ontId, new HashSet<IRI>());
            ontologyIndex.get(ontId).add(parentId);
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem

        // Just scan all individuals. Recurse in case the registry imports more registries.
        for (OWLIndividual ind : registry.getIndividualsInSignature(true)) {
            // We do not allow anonymous registry items.
            if (ind.isAnonymous()) continue;
            RegistryItem item = null;
            // IRI id = ind.asOWLNamedIndividual().getIRI();
            Type t = RegistryUtils.getType(ind, closure);
            if (t == null) {
                log.warn("Undetermined type for registry ontology individual {}", ind);
                continue;
            }
            switch (t) {
                case LIBRARY:
                    log.debug("Found library for individual {}", ind);
                    // Create the library and attach to parent and children
                    item = populateLibrary(ind.asOWLNamedIndividual(), closure);
                    reg.addChild(item);
                    item.addRegistryContentListener(this);
                    break;
                case ONTOLOGY:
                    log.debug("Found ontology for individual {}", ind);
                    // Create the ontology and attach to parent
                    item = populateOntology(ind.asOWLNamedIndividual(), closure);
                    item.addRegistryContentListener(this);
                    // We don't know where to attach it within this method.
                    break;
                default:
                    break;
            }
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem

        // If no listener has saved the day by loading the ontologies by now, an exception will be thrown.
        if (!loaded) throw new LibraryContentNotLoadedException(this);

        O ontology = null;

        RegistryItem child = getChild(id);
        if (child instanceof RegistryOntology) {
            ontology = getCache().getStoredOntology(((RegistryOntology) child).getIRI(), returnType);
        }
        return ontology;
    }
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem

        return (Library) lib;
    }

    protected RegistryOntology populateOntology(OWLNamedObject ind, Set<OWLOntology> registries) throws RegistryContentException {
        IRI ontId = ind.getIRI();
        RegistryItem ront = null;
        if (population.containsKey(ontId)) {
            // We are not allowing multityping either.
            ront = population.get(ontId);
            if (!(ront instanceof RegistryOntology)) throw new RegistryContentException(
                    "Inconsistent multityping: for item " + ontId + " : {" + RegistryOntology.class + ", "
                            + ront.getClass() + "}");
        } else {
            ront = riFactory.createRegistryOntology(ind);
            try {
                population.put(ront.getIRI(), ront);
            } catch (Exception e) {
                log.error("Invalid identifier for library item " + ront, e);
                return null;
            }
        }
        // EXIT nodes.
        Set<OWLNamedObject> libs = new HashSet<OWLNamedObject>();
        OWLDataFactory df = OWLManager.getOWLDataFactory();
        for (OWLOntology o : registries) {
            if (ind instanceof OWLIndividual) {
                // Get usages of isOntologyOf as an object property
                for (OWLIndividual value : ((OWLIndividual) ind).getObjectPropertyValues(isOntologyOf, o))
                    if (value.isNamed()) libs.add(value.asOWLNamedIndividual());
                // Get usages of isOntologyOf as an annotation property
                for (OWLAnnotationAssertionAxiom ann : o.getAnnotationAssertionAxioms(ind.getIRI()))
                    if (isOntologyOfAnn.equals(ann.getProperty())) {
                        OWLAnnotationValue value = ann.getValue();
                        if (value instanceof OWLNamedObject) libs.add((OWLNamedObject) value);
                        else if (value instanceof IRI) libs.add(df.getOWLNamedIndividual((IRI) value));
                    }
            }
        }
        for (OWLNamedObject ilib : libs) {
            IRI parentId = ilib.getIRI();
            // If some populate*() method has created it, it will be there.
            RegistryItem rlib = population.get(parentId);
            // Otherwise populating it will also put it in population.
            if (rlib == null) rlib = populateLibrary(ilib, registries);
            ront.addParent(rlib);
            if (ontologyIndex.get(ontId) == null) ontologyIndex.put(ontId, new HashSet<IRI>());
            ontologyIndex.get(ontId).add(parentId);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.