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

Examples of org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologyScope


        assertEquals(1,ontologyProvider.getStore().listTripleCollections().size());
        OntologyInputSource ois = new RootOntologyIRISource(IRI.create(getClass().getResource(
            "/ontologies/minorcharacters.owl")));

        OntologyScope sc = onManager.getOntologyScopeFactory().createOntologyScope(scopeId, ois);

        Set<Triple> triples = new HashSet<Triple>();

        for (UriRef iri : ontologyProvider.getStore().listTripleCollections()) {
            log.info("{}", iri.toString());
View Full Code Here


    public void storedOntologyOutlivesScope() throws Exception {
        String ephemeralScopeId = "CaducousScope";
        OntologyInputSource<OWLOntology,?> ois = new RootOntologyIRISource(IRI.create(getClass().getResource(
            "/ontologies/nonexistentcharacters.owl")));
        IRI ontologyId = ois.getRootOntology().getOntologyID().getOntologyIRI();
        OntologyScope scope = onManager.getOntologyScopeFactory().createOntologyScope(ephemeralScopeId);
        // Initially, the ontology is not there
        assertNull(ontologyProvider.getKey(ontologyId));
        // Once added, the ontology is there
        scope.getCustomSpace().addOntology(ois);
        assertNotNull(ontologyProvider.getKey(ontologyId));
        // Once removed from the scope, the ontology is still there
        scope.getCustomSpace().removeOntology(ontologyId);
        assertNotNull(ontologyProvider.getKey(ontologyId));
        // Once the scope is killed, the ontology is still there
        // TODO find a more appropriate method to kill scopes?
        scope.tearDown();
        assertNotNull(ontologyProvider.getKey(ontologyId));
    }
View Full Code Here

     * @param scopeID
     * @param rootSource
     */
    private void configureSpace(OntologySpace s, String scopeID, OntologyInputSource<?,?>... ontologySources) {
        // FIXME: ensure that this is not null AND convert to using Strings for scope IDs
        OntologyScope parentScope = registry.getScope(scopeID);

        if (parentScope != null && parentScope instanceof OntologyCollectorListener) s
                .addListener((OntologyCollectorListener) parentScope);
        // Set the supplied ontology's parent as the root for this space.
        if (ontologySources != null) try {
View Full Code Here

     * spaces.
     */
    @Test
    public void testIdentifiers() throws Exception {

        OntologyScope shouldBeNull = null, shouldBeNotNull = null;

        /* First test scope identifiers. */

        // Null identifier (invalid)
        try {
View Full Code Here

    /**
     * Tests that creating an ontology scope with null identifier fails to generate the scope at all.
     */
    @Test
    public void testNullScopeCreation() {
        OntologyScope scope = null;
        try {
            scope = factory.createOntologyScope(null, (OntologyInputSource) null);
        } catch (DuplicateIDException e) {
            fail("Unexpected DuplicateIDException caught while testing scope creation"
                 + " with null parameters.");
View Full Code Here

     * Tests that an ontology scope is correctly generated with both a core space and a custom space. The
     * scope is set up but not registered.
     */
    @Test
    public void testScopeSetup() {
        OntologyScope scope = null;
        try {
            scope = factory.createOntologyScope(scopeId1, src1, src2);
            scope.setUp();
        } catch (DuplicateIDException e) {
            fail("Unexpected DuplicateIDException was caught while testing scope " + e.getDuplicateID());
        }
        assertNotNull(scope);
    }
View Full Code Here

     * Tests that an ontology scope is correctly generated even when missing a custom space. The scope is set
     * up but not registered.
     */
    @Test
    public void testScopeSetupNoCustom() {
        OntologyScope scope = null;
        try {
            scope = factory.createOntologyScope(scopeId2, src1);
            scope.setUp();
        } catch (DuplicateIDException e) {
            fail("Duplicate ID exception caught for scope iri " + src1);
        }

        assertTrue(scope != null && scope.getCoreSpace() != null && scope.getCustomSpace() != null);
    }
View Full Code Here

    @Test
    public void testScopesRendering() {
        ScopeRegistry reg = onManager.getScopeRegistry();
        OntologyScopeFactoryImpl scf = new OntologyScopeFactoryImpl(reg, onManager.getOntologyScopeFactory()
                .getNamespace(), onManager.getOntologySpaceFactory());
        OntologyScope scope = null, scope2 = null;
        try {
            scope = scf.createOntologyScope(scopeId1, src1, src2);
            scope2 = scf.createOntologyScope(scopeId2, src2);
            scope.setUp();
            reg.registerScope(scope);
            scope2.setUp();
            reg.registerScope(scope2);
        } catch (DuplicateIDException e) {
            fail("Duplicate ID exception caught on " + e.getDuplicateID());
View Full Code Here

    @Override
    public OntologyScope createOntologyScope(String scopeID, OntologyInputSource<?,?>... coreSources) throws DuplicateIDException {

        if (registry.containsScope(scopeID)) throw new DuplicateIDException(scopeID,
                "Scope registry already contains ontology scope with ID " + scopeID);
        OntologyScope scope = new OntologyScopeImpl(scopeID, getNamespace(), spaceFactory, coreSources);
        // scope.addOntologyScopeListener(ONManager.get().getOntologyIndex());
        // TODO : manage scopes with null core ontologies
        fireScopeCreated(scope);
        return scope;
    }
View Full Code Here

        scopeMap.remove(id);
        fireScopeDeregistered(scope);
    }

    protected void fireScopeActivationChange(String scopeID, boolean activated) {
        OntologyScope scope = scopeMap.get(scopeID);
        if (activated) for (ScopeEventListener l : scopeListeners)
            l.scopeActivated(scope);
        else for (ScopeEventListener l : scopeListeners)
            l.scopeDeactivated(scope);
    }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologyScope

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.