当前位置: 首页>>代码示例>>Java>>正文


Java SailConnection类代码示例

本文整理汇总了Java中org.openrdf.sail.SailConnection的典型用法代码示例。如果您正苦于以下问题:Java SailConnection类的具体用法?Java SailConnection怎么用?Java SailConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SailConnection类属于org.openrdf.sail包,在下文中一共展示了SailConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadTestStatements

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
private static void loadTestStatements() throws Exception {
    final ValueFactory vf = sail.getValueFactory();

    final SailConnection sailConn = sail.getConnection();
    sailConn.begin();
    sailConn.addStatement(vf.createURI("urn:Alice"), vf.createURI("urn:likes"), vf.createURI("urn:icecream"));
    sailConn.addStatement(vf.createURI("urn:Bob"), vf.createURI("urn:likes"), vf.createURI("urn:icecream"));
    sailConn.addStatement(vf.createURI("urn:Charlie"), vf.createURI("urn:likes"), vf.createURI("urn:icecream"));
    sailConn.addStatement(vf.createURI("urn:David"), vf.createURI("urn:likes"), vf.createURI("urn:icecream"));
    sailConn.addStatement(vf.createURI("urn:Eve"), vf.createURI("urn:likes"), vf.createURI("urn:icecream"));
    sailConn.addStatement(vf.createURI("urn:Frank"), vf.createURI("urn:likes"), vf.createURI("urn:icecream"));
    sailConn.addStatement(vf.createURI("urn:George"), vf.createURI("urn:likes"), vf.createURI("urn:icecream"));
    sailConn.addStatement(vf.createURI("urn:Hillary"), vf.createURI("urn:likes"), vf.createURI("urn:icecream"));

    sailConn.addStatement(vf.createURI("urn:Alice"), vf.createURI("urn:hasEyeColor"), vf.createURI("urn:blue"));
    sailConn.addStatement(vf.createURI("urn:Bob"), vf.createURI("urn:hasEyeColor"), vf.createURI("urn:blue"));
    sailConn.addStatement(vf.createURI("urn:Charlie"), vf.createURI("urn:hasEyeColor"), vf.createURI("urn:blue"));
    sailConn.addStatement(vf.createURI("urn:David"), vf.createURI("urn:hasEyeColor"), vf.createURI("urn:blue"));
    sailConn.addStatement(vf.createURI("urn:Eve"), vf.createURI("urn:hasEyeColor"), vf.createURI("urn:blue"));
    sailConn.addStatement(vf.createURI("urn:Frank"), vf.createURI("urn:hasEyeColor"), vf.createURI("urn:blue"));
    sailConn.addStatement(vf.createURI("urn:George"), vf.createURI("urn:hasEyeColor"), vf.createURI("urn:green"));
    sailConn.addStatement(vf.createURI("urn:Hillary"), vf.createURI("urn:hasEyeColor"), vf.createURI("urn:brown"));
    sailConn.commit();
    sailConn.close();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:26,代码来源:QueryBenchmarkRunIT.java

示例2: testGetStatements

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
@Test
public void testGetStatements() throws SailException {
    final SailConnection con = cas.getConnection();
    try {
        con.begin();

        Assert.assertTrue(hasStatement(con, u1, p1, l1));
        Assert.assertFalse(hasStatement(con, u2, p2, l2));

        con.commit();
    } catch (final Throwable t) {
        con.rollback();
        throw t;
    } finally {
        con.close();
    }
}
 
开发者ID:apache,项目名称:marmotta,代码行数:18,代码来源:ContextAwareSailTest.java

示例3: testGetContextIDs

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
@Test
public void testGetContextIDs() throws SailException {
    final SailConnection con = cas.getConnection();
    try {
        con.begin();

        final CloseableIteration<? extends Resource, SailException> cid = con.getContextIDs();
        try {
            assertTrue(cid.hasNext());
            assertThat(cid.next(), CoreMatchers.is(c1));
            assertFalse(cid.hasNext());
        } finally {
            cid.close();
        }

        con.commit();
    } catch (final Throwable t) {
        con.rollback();
        throw t;
    } finally {
        con.close();
    }
}
 
开发者ID:apache,项目名称:marmotta,代码行数:24,代码来源:ContextAwareSailTest.java

示例4: initInference

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
void initInference(SailConnection conn, ValueFactory vf) throws SailException {
    synchronized (this) {
        if (toSub == null) {
            boolean done = false;
            try {
                toSub = new HashMap<String, Collection<String>>();
                toSuper = new HashMap<String, String>();
                for (IndexConfiguration config: indexConfigurations.values()) {
                    String type = config.getMatchType();
                    initInference(conn, vf, type);
                }
                done = true;
            } finally {
                if (!done) {
                    //Don't leave half configured information one failure:
                    toSub = null;
                    toSuper = null;
                }
            }
        }
    }
}
 
开发者ID:meshnetinc,项目名称:gmantic,代码行数:23,代码来源:ElasticSearchIndexerSettings.java

示例5: getConnectionInternal

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
/**
 * Returns a wrapper for the Sail connections of the federation members.
 * 
 * TODO: currently opens connections to *all* federation members,
 *       should better use lazy initialization of the connections.
 *       
 * @return the Sail connection wrapper.
 */
@Override
protected SailConnection getConnectionInternal() throws SailException {
	
	if (!this.initialized)
		throw new IllegalStateException("Sail has not been initialized.");
	
	return new FederationSailConnection(this);
}
 
开发者ID:goerlitz,项目名称:rdffederator,代码行数:17,代码来源:FederationSail.java

示例6: cleanupUnsupported

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
/**
 * Cleanup inferred triples that are no longer supported by any justification.
 */
private void cleanupUnsupported(KiWiReasoningConnection connection) throws SQLException, SailException {
    updateTaskStatus("cleaning up unsupported triples");

    int count = 0, total = 0;

    startTask("Unsupported Triple Cleaner", TASK_GROUP);
    updateTaskStatus("loading unsupported triples");

    CloseableIteration<KiWiTriple,SQLException> tripleIterator = connection.listUnsupportedTriples();
    try {
        if(tripleIterator.hasNext()) {

            updateTaskStatus("deleting unsupported triples");
            SailConnection tc = store.getConnection();
            KiWiSailConnection ic = getWrappedConnection(tc);
            try {
                tc.begin();
                while(tripleIterator.hasNext()) {
                    ic.removeInferredStatement(tripleIterator.next());
                    count++;
                }
                log.debug("removed {} unsupported triples",count);
                tc.commit();
            } catch(SailException ex) {
                ic.rollback();
                throw ex;
            } finally {
                ic.close();
            }
        }
    } finally {
        Iterations.closeCloseable(tripleIterator);

    }
}
 
开发者ID:apache,项目名称:marmotta,代码行数:39,代码来源:ReasoningEngine.java

示例7: getWrappedConnection

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
/**
 * Return the KiWiSailConnection underlying a given sail connection. The method will follow wrapped
 * connections until it finds the KiWiSailConnection, or otherwise throws a SailException.
 * @param connection
 * @return
 */
private KiWiSailConnection getWrappedConnection(SailConnection connection) throws SailException {
    SailConnection it = connection;
    while(it instanceof SailConnectionWrapper) {
        it = ((SailConnectionWrapper) it).getWrappedConnection();
        if(it instanceof KiWiSailConnection) {
            return (KiWiSailConnection) it;
        }
    }
    throw new SailException("no underlying KiWiSailConnection found for connection");
}
 
开发者ID:apache,项目名称:marmotta,代码行数:17,代码来源:ReasoningEngine.java

示例8: getEntry

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
/**
 * Return the cache entry for the given resource, or null if this entry does not exist.
 *
 *
 * @param resource the resource to retrieve the cache entry for
 * @return
 */
@Override
public CacheEntry getEntry(URI resource) {
    try {
        try(LDCachingKiWiPersistenceConnection dbcon = persistence.getConnection()) {

            // load cache entry from database
            CacheEntry ce = dbcon.getCacheEntry(resource.stringValue());

            // if entry exists, load triples for the resource from the cache context of the repository
            if(ce != null) {
                SailConnection con = store.getConnection();
                try {
                    con.begin();

                    Model triples = new TreeModel();
                    ModelCommons.add(triples,con.getStatements(resource,null,null,true,store.getValueFactory().createURI(cacheContext)));
                    ce.setTriples(triples);

                    con.commit();
                } catch(SailException ex) {
                    con.rollback();
                } finally {
                    con.close();
                }
            }
            return ce;

        }

    } catch (SailException | SQLException e) {
        log.error("could not retrieve cached triples from repository",e);
    }

    return null;
}
 
开发者ID:apache,项目名称:marmotta,代码行数:43,代码来源:LDCachingKiWiBackend.java

示例9: putEntry

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
/**
 * Update the cache entry for the given resource with the given entry.
 *
 * @param resource the resource to update
 * @param entry    the entry for the resource
 */
@Override
public void putEntry(URI resource, CacheEntry entry) {
    try {
        try(LDCachingKiWiPersistenceConnection dbcon = persistence.getConnection()) {

            // store cache entry in database
            dbcon.removeCacheEntry(resource.stringValue());

            // update triples in cache
            SailConnection con = store.getConnection();
            try {
                con.begin();

                con.removeStatements(resource, null, null, store.getValueFactory().createURI(cacheContext));
                for(Statement stmt : entry.getTriples()) {
                    con.addStatement(stmt.getSubject(), stmt.getPredicate(), stmt.getObject(), store.getValueFactory().createURI(cacheContext));
                }

                con.commit();

                entry.setResource(store.getValueFactory().createURI(resource.stringValue()));

                dbcon.storeCacheEntry(entry);
            } catch(SailException ex) {
                con.rollback();
            } finally {
                con.close();
            }

        }

    } catch (SailException | SQLException e) {
        log.error("could not retrieve cached triples from repository",e);
    }

}
 
开发者ID:apache,项目名称:marmotta,代码行数:43,代码来源:LDCachingKiWiBackend.java

示例10: removeEntry

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
/**
 * Remove the cache entry for the given resource if it exists. Does nothing otherwise.
 *
 * @param resource the resource to remove the entry for
 */
@Override
public void removeEntry(URI resource) {
    try {
        try(LDCachingKiWiPersistenceConnection dbcon = persistence.getConnection()) {

            // store cache entry in database
            dbcon.removeCacheEntry(resource.stringValue());

            // update triples in cache
            SailConnection con = store.getConnection();
            try {
                con.begin();

                con.removeStatements(resource, null, null, store.getValueFactory().createURI(cacheContext));

                con.commit();
            } catch(SailException ex) {
                con.rollback();
            } finally {
                con.close();
            }

        }

    } catch (SailException | SQLException e) {
        log.error("could not remove cached triples from repository",e);
    }
}
 
开发者ID:apache,项目名称:marmotta,代码行数:34,代码来源:LDCachingKiWiBackend.java

示例11: clear

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
/**
 * Clear all entries in the cache backend.
 */
@Override
public void clear() {
    try {
        try(LDCachingKiWiPersistenceConnection dbcon = persistence.getConnection()) {

            // list all entries and remove them
            CloseableIteration<KiWiCacheEntry, SQLException> entries = dbcon.listAll();
            while (entries.hasNext()) {
                dbcon.removeCacheEntry(entries.next());
            }

            // update triples in cache
            SailConnection con = store.getConnection();
            try {
                con.begin();

                con.removeStatements((Resource) null, null, null, store.getValueFactory().createURI(cacheContext));

                con.commit();
            } catch(SailException ex) {
                con.rollback();
            } finally {
                con.close();
            }

        }

    } catch (SailException | SQLException e) {
        log.error("could not remove cached triples from repository",e);
    }

}
 
开发者ID:apache,项目名称:marmotta,代码行数:36,代码来源:LDCachingKiWiBackend.java

示例12: getWrappedResourceConnection

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
private static ResourceConnection getWrappedResourceConnection(SailConnection connection) {
    if(connection instanceof ResourceConnection) {
        return (ResourceConnection)connection;
    } else if(connection instanceof SailConnectionWrapper) {
        return getWrappedResourceConnection(((SailConnectionWrapper) connection).getWrappedConnection());
    } else {
        return null;
    }

}
 
开发者ID:apache,项目名称:marmotta,代码行数:11,代码来源:ResourceUtils.java

示例13: hasStatement

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
protected static boolean hasStatement(SailConnection con, Resource subj,
URI pred, Value object, Resource... contexts) throws SailException {
    final CloseableIteration<? extends Statement, SailException> stmts = con.getStatements(subj, pred, object, true, contexts);
    try {
        return stmts.hasNext();
    } finally {
        stmts.close();
    }
}
 
开发者ID:apache,项目名称:marmotta,代码行数:10,代码来源:AbstractContextTest.java

示例14: getBaseSailConnection

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
private BigdataSail.BigdataSailConnection getBaseSailConnection(SailConnection con) {
    SailConnection wrapped = con;
    while(wrapped instanceof SailConnectionWrapper) {
        wrapped = ((SailConnectionWrapper) wrapped).getWrappedConnection();
    }
    if(wrapped instanceof BigDataSesame27Sail.BigDataSesame27SailConnection) {
        return ((BigDataSesame27Sail.BigDataSesame27SailConnection) wrapped).getWrapped();
    }
    if(wrapped instanceof BigdataSail.BigdataSailConnection) {
        return (BigdataSail.BigdataSailConnection) wrapped;
    }
    return null;
}
 
开发者ID:apache,项目名称:marmotta,代码行数:14,代码来源:BigDataSesame27Repository.java

示例15: RyaSailRepositoryConnection

import org.openrdf.sail.SailConnection; //导入依赖的package包/类
protected RyaSailRepositoryConnection(SailRepository repository, SailConnection sailConnection) {
    super(repository, sailConnection);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:4,代码来源:RyaSailRepositoryConnection.java


注:本文中的org.openrdf.sail.SailConnection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。