Package org.apache.stanbol.ontologymanager.servicesapi.session

Examples of org.apache.stanbol.ontologymanager.servicesapi.session.SessionManager


        /*
         * We have to do it like this because we cannot make this class a Component and reference ONManager
         * and SessionManager, otherwise an activation cycle will occur.
         */
        ScopeManager scopeManager = ScopeManagerImpl.get(); // FIXME get rid of this.
        SessionManager sessionManager = SessionManagerImpl.get();
        String prefix_scope = _NS_STANBOL_INTERNAL + Scope.shortName + "/", prefix_session = _NS_STANBOL_INTERNAL
                                                                                             + Session.shortName
                                                                                             + "/";

        // TODO check when not explicitly typed.
        SpaceType spaceType;
        if (meta.contains(new TripleImpl(candidate, RDF.type, SPACE_URIREF))) {
            Resource rScope;
            Iterator<Triple> parentSeeker = meta.filter(candidate, IS_SPACE_CORE_OF_URIREF, null);
            if (parentSeeker.hasNext()) {
                rScope = parentSeeker.next().getObject();
                spaceType = SpaceType.CORE;
            } else {
                parentSeeker = meta.filter(candidate, IS_SPACE_CUSTOM_OF_URIREF, null);
                if (parentSeeker.hasNext()) {
                    rScope = parentSeeker.next().getObject();
                    spaceType = SpaceType.CUSTOM;
                } else {
                    parentSeeker = meta.filter(null, HAS_SPACE_CORE_URIREF, candidate);
                    if (parentSeeker.hasNext()) {
                        rScope = parentSeeker.next().getSubject();
                        spaceType = SpaceType.CORE;
                    } else {
                        parentSeeker = meta.filter(null, HAS_SPACE_CUSTOM_URIREF, candidate);
                        if (parentSeeker.hasNext()) {
                            rScope = parentSeeker.next().getSubject();
                            spaceType = SpaceType.CUSTOM;
                        } else throw new InvalidMetaGraphStateException("Ontology space " + candidate
                                                                        + " does not declare a parent scope.");
                    }
                }
            }
            if (!(rScope instanceof UriRef)) throw new InvalidMetaGraphStateException(
                    rScope + " is not a legal scope identifier.");
            String scopeId = ((UriRef) rScope).getUnicodeString().substring(prefix_scope.length());
            Scope scope = scopeManager.getScope(scopeId);
            switch (spaceType) {
                case CORE:
                    handles.add(scope.getCoreSpace());
                    break;
                case CUSTOM:
                    handles.add(scope.getCustomSpace());
                    break;
            }
        } else if (meta.contains(new TripleImpl(candidate, RDF.type, SESSION_URIREF))) {
            String sessionId = ((UriRef) candidate).getUnicodeString().substring(prefix_session.length());
            handles.add(sessionManager.getSession(sessionId));
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.ontologymanager.servicesapi.session.SessionManager

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.