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


Java RepositoryException类代码示例

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


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

示例1: rewrite

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
/**
 * Rewrite a given query to add inference.
 *
 * @param ql the query language used for the query
 * @param query the query to rewrite
 * @param baseuri a base URI to use for the query
 * @return rewritten query that includes inference
 * @throws MalformedQueryException if the query is malformed
 * @throws RepositoryException if there was a problem while rewriting
 */
public Query rewrite(QueryLanguage ql, String query, String baseuri)
		throws MalformedQueryException, RepositoryException {
	// parse query using Sesame
	QueryParserFactory f = QueryParserRegistry.getInstance().get(ql);
	QueryParser parser = f.getParser();
	ParsedQuery parsed = parser.parseQuery(query, baseuri);
	// get SPARQL algebra expression from parsed query
	TupleExpr expr = parsed.getTupleExpr();
	// rewrite query using visitor pattern
	RuleTransformationVisitor visitor
			= new RuleTransformationVisitor(rules);
	expr.visit(visitor);
	// return new query based on rewritten algebra expression
	return getExprQuery(parsed, expr);
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:26,代码来源:QueryRewriter.java

示例2: addToGraphstore

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
/**
 * Helper method for handleAdd.
 */
private void addToGraphstore(
		RepositoryConnection conn,
		InputStream in,
		String base,
		RDFFormat format,
		Resource dctx,
		boolean chunked) throws IOException, RDFParseException,
		RDFHandlerException, RepositoryException {
	if (chunked) {
		RDFParser parser = getRDFParser(format);
		parser.setRDFHandler(
				new ChunkedCommitHandler(conn, chunksize, dctx));
		parser.parse(in, base);
	} else {
		if (dctx != null) {
			conn.add(in, base, format, dctx);
		} else {
			conn.add(in, base, format);
		}
	}
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:25,代码来源:GraphStore.java

示例3: write

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
/**
 * Called by JAX-RS upon building a response.
 *
 * @param out the {@link OutputStream} to write the triples to
 * @throws IOException if there was an error during communication
 * @throws WebApplicationException if there was an error while serialising
 */
@Override
public void write(OutputStream out)
		throws IOException, WebApplicationException {
	try {
		// get an RDF writer to stream the triples
		RDFWriter writer = factory.getWriter(out);
		// export triples from graphs
		conn.export(writer, contexts);
		conn.close();
	} catch (RepositoryException | RDFHandlerException ex) {
		// server error
		close(conn, ex);
		throw new WebApplicationException(ex);
	}
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:23,代码来源:RDFStreamingOutput.java

示例4: write

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
/**
 * Called by JAX-RS upon building a response.
 *
 * @param out the {@link OutputStream} to write the triples to
 * @throws IOException if there was an error during communication
 * @throws WebApplicationException if there was an error while serialising
 */
@Override
public void write(OutputStream out)
		throws IOException, WebApplicationException {
	try {
		RDFWriter writer = factory.getWriter(out);
		// evaluate query and stream result
		query.evaluate(writer);
		conn.close();
	} catch (RepositoryException |
			 QueryEvaluationException |
			 RDFHandlerException ex) {
		// server error
		close(conn, ex);
		throw new WebApplicationException(ex);
	}
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:24,代码来源:SPARQLGraphStreamingOutput.java

示例5: handleStatement

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
/**
 * Handles a statement.
 * 
 * The statements will be added up until chunk size is reached.
 * After a chunk of statements is added the transaction will be committed
 * and new transaction will be started.
 * @param stmnt
 * @throws RDFHandlerException 
 */
@Override
public void handleStatement(Statement stmnt) throws RDFHandlerException {
	try {
		// check if triple should be added to a specific graph
		if (dctx != null) {
			conn.add(stmnt, dctx);
		} else {
			conn.add(stmnt);
		}
		// check if chunk size is reached and transaction should be
		// committed
		count++;
		if (count >= size) {
			count = 0;
			conn.commit();
			conn.begin();
		}
	} catch (RepositoryException ex) {
		throw new RDFHandlerException(ex);
	}
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:31,代码来源:ChunkedCommitHandler.java

示例6: before

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
@Before
public void before()
		throws RepositoryException, IOException, RDFParseException,
		       MalformedQueryException, QueryResultParseException,
			   QueryResultHandlerException {
	repo = new SailRepository(new MemoryStore());
	repo.initialize();
	conn = repo.getConnection();
	vf = conn.getValueFactory();
	conn.add(getResource(data), "file://", RDFFormat.TURTLE);
	SPARQLResultsXMLParserFactory factory =
			new SPARQLResultsXMLParserFactory();
	parser = factory.getParser();
	parser.setValueFactory(vf);
	List<Rule> rules;
	rules = Rules.fromOntology(getResource(data));
	QueryRewriter rewriter = new QueryRewriter(conn, rules);
	query = (TupleQuery) rewriter.rewrite(QueryLanguage.SPARQL, queryString);
	nonInfQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
	System.out.println("== QUERY (" + this.name + ") ==");
	System.out.println(nonInfQuery);
	System.out.println("== REWRITTEN QUERY (" + this.name + ") ==");
	System.out.println(query);
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:25,代码来源:SPARQLInferenceTest.java

示例7: setUp

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws IOException, RepositoryException, RDFParseException {
	int port;
	try (final ServerSocket serverSocket = new ServerSocket(0)) {
		port = serverSocket.getLocalPort();
	}
	server = CommunityServerBuilder.server()
		.onPort(port)
		.withThirdPartyJaxRsPackage("de.unikiel.inf.comsys.neo4j", "/rdf")
		.build();
	server.start();
	GraphDatabaseService db = server.getDatabase().getGraph();
	Repository rep = RepositoryRegistry.getInstance(db).getRepository();
	conn = rep.getConnection();
	InputStream testdata = RDFServerExtensionTest.class.getResourceAsStream("/sp2b.n3");
	conn.add(testdata, "http://example.com/", RDFFormat.N3);
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:18,代码来源:RDFServerExtensionTest.java

示例8: getAllPossibleProperties

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
protected static Collection<URI> getAllPossibleProperties( URI type, IEngine engine ) {
	String query = "SELECT DISTINCT ?pred WHERE { ?s ?pred ?o . ?s a ?type . FILTER ( isLiteral( ?o ) ) }";
	ListQueryAdapter<URI> qa = OneVarListQueryAdapter.getUriList( query, "pred" );
	qa.bind( "type", type );

	List<URI> props = new ArrayList<>();
	props.add( Constants.ANYNODE );
	try {
		props.addAll( engine.query( qa ) );
	}
	catch ( RepositoryException | MalformedQueryException | QueryEvaluationException e ) {
		log.error( e, e );
	}

	return props;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:17,代码来源:NodeEdgeBasePopup.java

示例9: remove

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
@Override
public void remove( DbInfo t ) throws Exception {
	RepositoryConnection rc = store.getConnection();

	Resource idToRemove = getId( t, rc );
	if ( null != idToRemove ) {
		try{
			rc.begin();
			rc.remove( idToRemove, null, null );
			rc.commit();
		}
		catch( RepositoryException re ){
			rc.rollback();
			throw re;
		}
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:18,代码来源:DbInfoMapper.java

示例10: update

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
@Override
public void update( DbInfo data ) throws Exception {
	RepositoryConnection rc = store.getConnection();
	Resource id = getId( data, rc );
	if ( null != id ) {
		try{
			rc.begin();
			rc.remove( id, null, null );
			rc.add( getCreateStatements( id, data, rc.getValueFactory() ) );
			rc.commit();
		}
		catch( RepositoryException re ){
			rc.rollback();
			throw re;
		}
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:18,代码来源:DbInfoMapper.java

示例11: getDbInfo

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
public static DbInfo getDbInfo( Resource id, RepositoryConnection rc )
		throws RepositoryException {

	DbInfo dbi = new DbInfo();
	for ( Statement stmt : Iterations.asList( rc.getStatements( id, null, null, false ) ) ) {
		URI pred = stmt.getPredicate();
		String val = stmt.getObject().stringValue();
		if ( DATA_PREDICATE.equals( pred ) ) {
			dbi.setDataUrl( val );
		}
		else if ( INSIGHTS_PREDICATE.equals( pred ) ) {
			dbi.setInsightsUrl( val );
		}
		else if ( RDFS.LABEL.equals( pred ) ) {
			dbi.setName( val );
		}
	}

	return dbi;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:21,代码来源:DbInfoMapper.java

示例12: getId

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
public static Resource getId( DbInfo t, RepositoryConnection rc )
		throws RepositoryException {
	List<Statement> stmts = Iterations.asList( rc.getStatements( null, RDF.TYPE,
			WEBDS.DBINFO, false ) );
	Resource idToRemove = null;
	for ( Statement s : stmts ) {
		Resource sbj = s.getSubject();
		List<Statement> individuals
				= Iterations.asList( rc.getStatements( sbj, RDFS.LABEL, null, false ) );
		for ( Statement ind : individuals ) {
			if ( ind.getObject().stringValue().equals( t.getName() ) ) {
				idToRemove = sbj;
			}
		}
	}

	return idToRemove;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:19,代码来源:DbInfoMapper.java

示例13: update

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
@Override
public void update( User user ) throws Exception {
	RepositoryConnection rc = store.getConnection();
	try {
		Map<URI, DbAccess> accesses = getAccesses( user );

		Resource id = getId( user, rc );
		if ( null != id ) {
			rc.begin();
			rc.remove( id, null, null );
			rc.add( getCreateStatements( id, user, rc.getValueFactory() ) );

			addAccesses( id, accesses, rc );
			rc.commit();
		}
	}
	catch ( RepositoryException e ) {
		log.error( e, e );
		try {
			rc.rollback();
		}
		catch ( Exception x ) {
			log.warn( x, x );
		}
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:27,代码来源:UserMapper.java

示例14: setAccesses

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
/**
 * Sets the access level from the given map. To remove access from a DB, user
 * {@link DbAccess#NONE}.
 *
 * @param user
 * @param access a mapping of URIs (either {@link DbInfo#getDataUrl()} or
 * {@link DbInfo#getInsightsUrl()}) and the access given
 */
public void setAccesses( User user, Map<URI, DbAccess> access ) {
	RepositoryConnection rc = store.getConnection();

	try {
		rc.begin();
		Resource id = getId( user, rc );
		addAccesses( id, access, rc );
		rc.commit();
	}
	catch ( RepositoryException e ) {
		log.error( e, e );
		try {
			rc.rollback();
		}
		catch ( Exception x ) {
			log.warn( x, x );
		}
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:28,代码来源:UserMapper.java

示例15: getUser

import org.openrdf.repository.RepositoryException; //导入依赖的package包/类
private static User getUser( Resource id, RepositoryConnection rc )
		throws RepositoryException {

	LinkedHashModel model = new LinkedHashModel( Iterations.asList(
			rc.getStatements( id, null, null, false ) ) );
	org.openrdf.model.Model namer = model.filter( id, FOAF.ACCOUNT, null );
	RemoteUserImpl user = new RemoteUserImpl( namer.objectString() );
	model.removeAll( namer );

	for ( Statement stmt : model ) {
		URI pred = stmt.getPredicate();
		String val = stmt.getObject().stringValue();

		for ( Map.Entry<UserProperty, URI> en : PROPMAP.entrySet() ) {
			if ( en.getValue().equals( pred ) ) {
				user.setProperty( en.getKey(), val );
			}
		}
	}

	return user;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:23,代码来源:UserMapper.java


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