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


Java RepositoryConnection.getStatements方法代码示例

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


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

示例1: tuplePattern

import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
/**
 * Tuple pattern query - find all statements with the pattern, where null is
 * a wild card
 * 
 * @param s
 *            subject (null for wildcard)
 * @param p
 *            predicate (null for wildcard)
 * @param o
 *            object (null for wildcard)
 * @return serialized graph of results
 */
public List tuplePattern(URI s, URI p, Value o) {
	try {
		RepositoryConnection con = therepository.getConnection();
		try {
			RepositoryResult repres = con.getStatements(s, p, o, true, new Resource[0]);
			ArrayList reslist = new ArrayList();
			while (repres.hasNext()) {
				reslist.add(repres.next());
			}
			return reslist;
		} finally {
			con.close();
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:dvcama,项目名称:resource-to-sparqlresult,代码行数:31,代码来源:SimpleGraph.java

示例2: extractAllStatements

import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Override
public LinkedList<Statement> extractAllStatements(Repository repo, int nrTriples) {
	RepositoryConnection con = repo.getConnection();
	
	RepositoryResult<Statement> triples = con.getStatements(null, null,
			null, false);

	LinkedList<Statement> statements = new LinkedList<Statement>();
	try {
		System.out.println("triples to extract: "+nrTriples);
		if(nrTriples == -1)
			Iterations.addAll(triples, statements);
		else {
			int count = 0;
			while(triples.hasNext() && count < nrTriples){
				statements.add(triples.next());
				count++;
			}
		}
	} finally {
		triples.close();
		con.close();
	}
	return statements;
}
 
开发者ID:simonstey,项目名称:SecureLinkedData,代码行数:26,代码来源:Storage.java

示例3: updateLastModifiedDate

import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
public static void updateLastModifiedDate( RepositoryConnection rc,
		Resource baseuri ) {
	// updates the base uri's last modified key
	// 1) if we don't know it already, figure out what our base uri is
	// 2) remove any last modified value
	// 3) add the new last modified value

	ValueFactory vf = rc.getValueFactory();
	try {
		if ( null == baseuri ) {
			RepositoryResult<Statement> rr = rc.getStatements( null, RDF.TYPE,
					SEMTOOL.Database, false );
			List<Statement> stmts = Iterations.asList( rr );
			for ( Statement s : stmts ) {
				baseuri = s.getSubject();
			}
		}

		if ( null == baseuri ) {
			log.warn( "cannot update last modified date when no base uri is set" );
		}
		else {
			rc.remove( baseuri, MetadataConstants.DCT_MODIFIED, null );

			rc.add( new StatementImpl( baseuri, MetadataConstants.DCT_MODIFIED,
					vf.createLiteral( QueryExecutorAdapter.getCal( new Date() ) ) ) );
		}
	}
	catch ( RepositoryException e ) {
		log.warn( "could not update last modified date", e );
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:33,代码来源:AbstractSesameEngine.java

示例4: setRepositoryConnection

import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
/**
 * Method setRepositoryConnection. Sets the repository connection.
 *
 * @param rc RepositoryConnection. The repository connection that this is
 * being set to.
 */
private void setRepositoryConnection( RepositoryConnection rc,
		boolean takeControl ) {

	this.rc = rc;
	iControlMyRc = takeControl;

	try {

		URI baseuri = null;
		// if the baseuri isn't already set, then query the kb for void:Dataset
		RepositoryResult<Statement> rr
				= rc.getStatements( null, RDF.TYPE, SEMTOOL.Database, false );
		List<Statement> stmts = Iterations.asList( rr );
		for ( Statement s : stmts ) {
			baseuri = URI.class.cast( s.getSubject() );
			break;
		}

		if ( null == baseuri ) {
			// no base uri in the DB, so make a new one
			baseuri = getNewBaseUri();
			//rc.begin();
			rc.add( baseuri, RDF.TYPE, SEMTOOL.Database );
			//rc.add(  baseuri, SEMTOOL.ReificationModel, SEMTOOL.SEMTOOL_Reification );
			//rc.commit();
		}

		setBaseUri( baseuri );
	}
	catch ( RepositoryException re ) {
		log.warn( re, re );
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:40,代码来源:InMemorySesameEngine.java


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