本文整理汇总了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;
}
示例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;
}
示例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 );
}
}
示例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 );
}
}