Java Code Examples for org.openrdf.repository.RepositoryConnection#clear()

The following examples show how to use org.openrdf.repository.RepositoryConnection#clear() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RdfIndexerService.java    From attic-polygene-java with Apache License 2.0 6 votes vote down vote up
private void indexEntityType( final EntityDescriptor entityType,
                              final RepositoryConnection connection
)
    throws RepositoryException
{
    if( entityType.queryable() )
    {
        String uri = Classes.toURI(entityType.types().findFirst().orElse(null));
        final URI compositeURI = getValueFactory().createURI( uri );
        // remove composite type if already present
        connection.clear( compositeURI );

        Iterable<Statement> statements = typeSerializer.serialize( entityType );
        connection.add( statements, compositeURI );
    }
}
 
Example 2
Source File: GraphHandler.java    From cumulusrdf with Apache License 2.0 6 votes vote down vote up
/**
 * Delete data from the graph.
 * 
 * @param repository the Repository object
 * @param request the HttpServletRequest object
 * @param response the HttpServletResponse object
 * @return the EmptySuccessView if successes
 * @throws ClientHTTPException throws when there are errors in getting the name of the Graph
 * @throws ServerHTTPException throws when errors happens update the data
 */
private ModelAndView getDeleteDataResult(final Repository repository,
		final HttpServletRequest request, final HttpServletResponse response)
		throws ClientHTTPException, ServerHTTPException {
	ProtocolUtil.logRequestParameters(request);

	ValueFactory vf = repository.getValueFactory();

	URI graph = getGraphName(request, vf);

	try {
		RepositoryConnection repositoryCon = repository.getConnection();
		synchronized (repositoryCon) {
			repositoryCon.clear(graph);
		}
		repositoryCon.close();
		return new ModelAndView(EmptySuccessView.getInstance());
	} catch (RepositoryException e) {
		throw new ServerHTTPException("Repository update error: " + e.getMessage(), e);
	}
}
 
Example 3
Source File: TripleStoreBlazegraph.java    From powsybl-core with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void clear(String contextName) {
    RepositoryConnection cnx = null;
    try {
        cnx = repo.getConnection();
        cnx.clear(context(cnx, contextName));
    } catch (RepositoryException x) {
        LOG.error("clearing context {} : {}", contextName, x.getMessage());
    } finally {
        closeConnection(cnx, "Clearing context " + contextName);
    }
}
 
Example 4
Source File: RepositoryTestCase.java    From anno4j with Apache License 2.0 5 votes vote down vote up
protected Repository getRepository() throws Exception, RepositoryException {
	Repository repository = createRepository();
	repository.initialize();
	RepositoryConnection con = repository.getConnection();
	try {
		con.setAutoCommit(false);
		con.clear();
		con.clearNamespaces();
		con.setNamespace("test", "urn:test:");
		con.setAutoCommit(true);
	} finally {
		con.close();
	}
	return repository;
}
 
Example 5
Source File: SPARQLQueryTest.java    From database with GNU General Public License v2.0 5 votes vote down vote up
protected Repository createRepository()
	throws Exception
{
	Repository repo = newRepository();
	repo.initialize();
	RepositoryConnection con = repo.getConnection();
	try {
		con.clear();
		con.clearNamespaces();
	}
	finally {
		con.close();
	}
	return repo;
}
 
Example 6
Source File: SPARQLUpdateConformanceTest.java    From database with GNU General Public License v2.0 5 votes vote down vote up
protected Repository createRepository()
	throws Exception
{
	Repository repo = newRepository();
	repo.initialize();
	RepositoryConnection con = repo.getConnection();
	try {
		con.clear();
		con.clearNamespaces();
	}
	finally {
		con.close();
	}
	return repo;
}
 
Example 7
Source File: SPARQLUpdateTest.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates, initializes and clears a repository.
 * 
 * @return an initialized empty repository.
 * @throws Exception
 */
protected Repository createRepository()
	throws Exception
{
	Repository repository = newRepository();
	repository.initialize();
	RepositoryConnection con = repository.getConnection();
	con.clear();
	con.clearNamespaces();
	con.close();
	return repository;
}