Package org.apache.stanbol.ontologymanager.ontonet.api

Examples of org.apache.stanbol.ontologymanager.ontonet.api.OntologyNetworkConfiguration


    private void rebuildSessions() {
        if (ontologyProvider == null) {
            log.warn("No ontology provider supplied. Cannot rebuild sessions");
            return;
        }
        OntologyNetworkConfiguration struct = ontologyProvider.getOntologyNetworkConfiguration();
        for (String sessionId : struct.getSessionIDs()) {
            long before = System.currentTimeMillis();
            log.debug("Rebuilding session with ID \"{}\"", sessionId);
            Session session;
            try {
                session = createSession(sessionId);
            } catch (DuplicateSessionIDException e) {
                log.warn("Session \"{}\" already exists and will be reused.", sessionId);
                session = getSession(sessionId);
            } catch (SessionLimitException e) {
                log.error("Cannot create session {}. Session limit of {} reached.", sessionId,
                    getActiveSessionLimit());
                break;
            }
            // Register even if some ontologies were to fail to be restored afterwards.
            sessionsByID.put(sessionId, session);
            session.setActive(false); // Restored sessions are inactive at first.
            for (OWLOntologyID key : struct.getOntologyKeysForSession(sessionId))
                try {
                    session.addOntology(new StoredOntologySource(key));
                } catch (MissingOntologyException ex) {
                    log.error(
                        "Could not find an ontology with public key {} to be managed by session \"{}\". Proceeding to next ontology.",
                        key, sessionId);
                    continue;
                } catch (Exception ex) {
                    log.error("Exception caught while trying to add ontology with public key " + key
                              + " to rebuilt session \"" + sessionId + "\". Proceeding to next ontology.", ex);
                    continue;
                }
            for (String scopeId : struct.getAttachedScopes(sessionId)) {
                /*
                 * The scope is attached by reference, so we won't have to bother checking if the scope has
                 * been rebuilt by then (which could not happen if the SessionManager is being activated
                 * first).
                 */
 
View Full Code Here


    protected final boolean isOfflineMode() {
        return offlineMode != null;
    }

    private void rebuildScopes() {
        OntologyNetworkConfiguration struct = ontologyProvider.getOntologyNetworkConfiguration();
        for (String scopeId : struct.getScopeIDs()) {
            long before = System.currentTimeMillis();
            log.debug("Rebuilding scope with ID \"{}\".", scopeId);
            Collection<OWLOntologyID> coreOnts = struct.getCoreOntologyKeysForScope(scopeId);
            OntologyInputSource<?>[] srcs = new OntologyInputSource<?>[coreOnts.size()];
            int i = 0;
            for (OWLOntologyID coreOnt : coreOnts) {
                log.debug("Core ontology key : {}", coreOnts);
                srcs[i++] = new StoredOntologySource(coreOnt);
            }
            Scope scope;
            try {
                scope = createOntologyScope(scopeId, srcs);
            } catch (DuplicateIDException e) {
                String dupe = e.getDuplicateID();
                log.warn("Scope \"{}\" already exists and will be reused.", dupe);
                scope = getScope(dupe);
            }
            OntologySpace custom = scope.getCustomSpace();
            // Register even if some ontologies were to fail to be restored afterwards.
            scopeMap.put(scopeId, scope);
            for (OWLOntologyID key : struct.getCustomOntologyKeysForScope(scopeId))
                try {
                    log.debug("Custom ontology key : {}", key);
                    custom.addOntology(new StoredOntologySource(key));
                } catch (MissingOntologyException ex) {
                    log.error(
View Full Code Here

                    }
                }
            }
        }

        return new OntologyNetworkConfiguration(coreOntologies, customOntologies, sessionOntologies,
                attachedScopes);
    }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.ontologymanager.ontonet.api.OntologyNetworkConfiguration

Copyright © 2018 www.massapicom. 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.