本文整理汇总了Java中info.aduna.iteration.Iterations.asList方法的典型用法代码示例。如果您正苦于以下问题:Java Iterations.asList方法的具体用法?Java Iterations.asList怎么用?Java Iterations.asList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类info.aduna.iteration.Iterations
的用法示例。
在下文中一共展示了Iterations.asList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDbInfo
import info.aduna.iteration.Iterations; //导入方法依赖的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;
}
示例2: getId
import info.aduna.iteration.Iterations; //导入方法依赖的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;
}
示例3: getUser
import info.aduna.iteration.Iterations; //导入方法依赖的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;
}
示例4: getId
import info.aduna.iteration.Iterations; //导入方法依赖的package包/类
private static Resource getId( User t, RepositoryConnection rc )
throws RepositoryException {
List<Statement> stmts = Iterations.asList( rc.getStatements( null, RDF.TYPE,
FOAF.PERSON, false ) );
Resource idToRemove = null;
for ( Statement s : stmts ) {
Resource sbj = s.getSubject();
List<Statement> individuals
= Iterations.asList( rc.getStatements( sbj, FOAF.ACCOUNT, null, false ) );
for ( Statement ind : individuals ) {
if ( ind.getObject().stringValue().equals( t.getUsername() ) ) {
idToRemove = sbj;
}
}
}
return idToRemove;
}
示例5: compareData
import info.aduna.iteration.Iterations; //导入方法依赖的package包/类
private void compareData( RepositoryConnection testRc, Model expected,
UriBuilder owl, UriBuilder base ) throws Exception {
List<Statement> stmts
= Iterations.asList( testRc.getStatements( null, null, null, false ) );
Model test = new LinkedHashModel( stmts );
assertEquals( "dataset size", expected.size(), test.size() );
compare( "category concept", expected, test, null, RDF.TYPE,
owl.getConceptUri( "Category" ) );
compare( "beverages concept", expected, test,
base.getConceptUri().add( "Category" ).add( "Beverages" ).build(),
null, null );
compare( "dairy products", expected, test,
null, RDFS.LABEL, new LiteralImpl( "Dairy Products" ) );
compare( "chai-beverages link", expected, test,
null, RDFS.LABEL, new LiteralImpl( "Chai Category Beverages" ) );
URI bev
= base.getRelationUri().add( "Category" ).add( "Chai_x_Beverages" ).build();
compare( "chai-beverages category", expected, test,
bev, RDFS.SUBPROPERTYOF, owl.getRelationUri( "Category" ) );
}
示例6: testUpdateDate2
import info.aduna.iteration.Iterations; //导入方法依赖的package包/类
@Test
public void testUpdateDate2() throws Exception {
Repository repo = new SailRepository( new MemoryStore() );
repo.initialize();
RepositoryConnection rc = repo.getConnection();
URI base = Utility.getUniqueUri();
Date now = new Date();
rc.add( new StatementImpl( base, MetadataConstants.DCT_MODIFIED,
rc.getValueFactory().createLiteral( now ) ) );
AbstractSesameEngine.updateLastModifiedDate( rc, null );
List<Statement> stmts = Iterations.asList( eng.getRawConnection().
getStatements( eng.getBaseUri(), MetadataConstants.DCT_MODIFIED,
null, false ) );
Literal val = Literal.class.cast( stmts.get( 0 ).getObject() );
Date upd = getDate( val.calendarValue() );
rc.close();
repo.shutDown();
// the 100 is to remove the ms, which aren't always the same because
// they're not stored in the RDF
assertEquals( now.getTime(), upd.getTime(), 100 );
}
示例7: getNamespaces
import info.aduna.iteration.Iterations; //导入方法依赖的package包/类
@Override
public Map<String,String> getNamespaces() {
assertModel();
Map<String,String> nsMap = new HashMap<String,String>();
try {
RepositoryResult<Namespace> openrdfMap = this.connection.getNamespaces();
openrdfMap.enableDuplicateFilter();
List<Namespace> openrdfList = Iterations.asList(openrdfMap);
for(Namespace openrdfNamespace : openrdfList) {
nsMap.put(openrdfNamespace.getPrefix(), openrdfNamespace.getName());
}
return nsMap;
} catch(RepositoryException e) {
throw new ModelRuntimeException(e);
}
}
示例8: loadPrograms
import info.aduna.iteration.Iterations; //导入方法依赖的package包/类
public void loadPrograms() {
log.info("program configuration changed, reloading ...");
patternRuleMap = HashMultimap.<Pattern,Rule>create();
try {
KiWiReasoningConnection connection = persistence.getConnection();
try {
programs = Iterations.asList(connection.listPrograms());
for(Program p : programs) {
for(Rule rule : p.getRules()) {
for(Pattern pattern : rule.getBody()) {
patternRuleMap.put(pattern,rule);
}
}
}
} finally {
connection.close();
}
} catch (SQLException ex) {
programs = Collections.emptyList();
log.warn("cannot load reasoning programs, reasoning disabled (error message: {})", ex.getMessage());
}
}
示例9: testSinglePattern
import info.aduna.iteration.Iterations; //导入方法依赖的package包/类
@Test
public void testSinglePattern() throws Exception {
ContextAwareConnection con = new ContextAwareConnection(repository, repository.getConnection());
try {
con.setInsertContext(context1);
con.setReadContexts(context1);
con.setRemoveContexts(context1);
Assert.assertTrue(con.hasStatement(subject,predicate1, object11));
Assert.assertFalse(con.hasStatement(subject, predicate2, object21));
String queryStr = "SELECT ?X ?Z WHERE { ?X ?Y ?Z }";
TupleQuery query = con.prepareTupleQuery(QueryLanguage.SPARQL, queryStr);
List<BindingSet> result = Iterations.asList(query.evaluate());
Assert.assertEquals(2,result.size());
con.commit();
} finally {
con.close();
}
}
示例10: testJoinPattern
import info.aduna.iteration.Iterations; //导入方法依赖的package包/类
@Test
public void testJoinPattern() throws Exception {
ContextAwareConnection con = new ContextAwareConnection(repository, repository.getConnection());
try {
con.setInsertContext(context1);
con.setReadContexts(context1);
con.setRemoveContexts(context1);
Assert.assertTrue(con.hasStatement(subject,predicate1, object11));
Assert.assertFalse(con.hasStatement(subject, predicate2, object21));
String queryStr = "SELECT ?X ?Z WHERE { ?X ?P ?Y . ?Y ?P ?Z }";
TupleQuery query = con.prepareTupleQuery(QueryLanguage.SPARQL, queryStr);
List<BindingSet> result = Iterations.asList(query.evaluate());
Assert.assertEquals(1,result.size());
con.commit();
} finally {
con.close();
}
}
示例11: getProgramList
import info.aduna.iteration.Iterations; //导入方法依赖的package包/类
@GET
@Path("/list")
public Response getProgramList() {
try {
List<Program> programs = Iterations.asList(provider.listPrograms());
List<POJOProgram> pgrs = new ArrayList<POJOProgram>();
log.debug("Listing {} reasoning programs", programs.size());
for(Program p : programs) {
POJOProgram pr = new POJOProgram();
pr.setName(p.getName());
pr.setRules(Joiner.on("\n").join(p.getRules()));
pgrs.add(pr);
}
return Response.ok().entity(pgrs).build();
} catch (Exception ex) {
return Response.serverError().build();
}
}
示例12: transformShouldDeleteAllOldStatements
import info.aduna.iteration.Iterations; //导入方法依赖的package包/类
@Test
public void transformShouldDeleteAllOldStatements() throws RepositoryException {
Repository repository = new SailRepository(new MemoryStore());
repository.initialize();
RepositoryConnection con = repository.getConnection();
try {
loadRDFInStore("example_themes.n3", con);
List<Statement> statements = Iterations.asList(con.getStatements(null, new URIImpl("http://www.w3.org/ns/dcat#theme"), null, false, DEFAULT_GRAPH));
ODSValueMapper mapper = new ODSValueMapper();
ODSValueMapperConfig config = new ODSValueMapperConfig();
config.setMappings(getMappingList());
config.setMappedPredicate(new MappedPredicate(ODSVoc.DCAT_DATASET, "http://www.w3.org/ns/dcat#theme", "theme"));
mapper.configure(config);
mapper.transform(repository, DEFAULT_GRAPH, new TransformContext("myid", new HashMap<String, Object>()));
for (Statement s : statements) {
Assert.assertFalse("should not have statement with " + s.getSubject().stringValue(), con.hasStatement(s, false, DEFAULT_GRAPH));
}
} catch (Exception e) {
System.out.println(e.getMessage());
Assert.fail(e.getMessage());
} finally {
con.close();
}
repository.shutDown();
}
示例13: transformShouldInsertNewStatements
import info.aduna.iteration.Iterations; //导入方法依赖的package包/类
@Test
public void transformShouldInsertNewStatements() throws RepositoryException {
Repository repository = new SailRepository(new MemoryStore());
repository.initialize();
RepositoryConnection con = repository.getConnection();
try {
loadRDFInStore("example_themes.n3", con);
List<Statement> statements = Iterations.asList(con.getStatements(null, new URIImpl("http://www.w3.org/ns/dcat#theme"), null, false, DEFAULT_GRAPH));
ODSValueMapper mapper = new ODSValueMapper();
ODSValueMapperConfig config = new ODSValueMapperConfig();
config.setMappedPredicate(new MappedPredicate(ODSVoc.DCAT_DATASET, "http://www.w3.org/ns/dcat#theme", "theme"));
config.setMappings(getMappingList());
mapper.configure(config);
mapper.transform(repository, DEFAULT_GRAPH, new TransformContext("myid", new HashMap<String, Object>()));
for (Statement s : statements) {
Statement newStatement = new StatementImpl(s.getSubject(), s.getPredicate(), MAPPINGS.get(s.getObject().stringValue()));
Assert.assertTrue(con.hasStatement(newStatement, false, DEFAULT_GRAPH));
}
} catch (Exception e) {
Assert.fail(e.getMessage());
} finally {
con.close();
}
repository.shutDown();
}
示例14: extractDatasetInfo
import info.aduna.iteration.Iterations; //导入方法依赖的package包/类
private void extractDatasetInfo(URI graph, org.openrdf.model.Resource catalogUri, Value rawGraph, RepositoryConnection connection) throws RepositoryException, DatatypeConfigurationException {
RepositoryResult<Statement> statements = connection.getStatements(null, ODSVoc.DCAT_CAT_PROP_DATASET, null, false, graph);
Collection<Statement> statementList = Iterations.asList(statements);
for (Statement s : statementList) {
Value rawDatasetUrl = s.getObject();
String rawDatasetId = getRawDatasetId(rawDatasetUrl);
URI catalogRecordUri = valueFactory.createURI(catalogUri.toString() + "record/" + rawDatasetId);
URI harmonizedDatasetUri = valueFactory.createURI(catalogUri.toString() + "dataset/" + rawDatasetId);
connection.add(valueFactory.createStatement(catalogUri, ODSVoc.DCAT_CAT_PROP_RECORD, catalogRecordUri), graph);
connection.add(valueFactory.createStatement(catalogRecordUri, ODSVoc.FOAF_PRIMARYTOPIC, harmonizedDatasetUri), graph);
connection.add(valueFactory.createStatement(catalogRecordUri, ODSVoc.RDFTYPE, ODSVoc.DCAT_CATALOGRECORD), graph);
connection.add(valueFactory.createStatement(catalogRecordUri, ODSVoc.ODS_RAW_DATASET, rawDatasetUrl), graph);
connection.add(valueFactory.createStatement(catalogRecordUri, ODSVoc.DCT_MODIFIED, valueFactory.createLiteral(getXMLNow())), graph);
connection.add(valueFactory.createStatement(harmonizedDatasetUri, ODSVoc.RDFTYPE, ODSVoc.DCAT_DATASET), graph);
connection.add(valueFactory.createStatement(catalogUri, ODSVoc.DCAT_CAT_PROP_DATASET, harmonizedDatasetUri), graph);
}
statements.close();
}
示例15: getAll
import info.aduna.iteration.Iterations; //导入方法依赖的package包/类
@Override
public Collection<DbInfo> getAll() {
RepositoryConnection rc = store.getConnection();
List<DbInfo> databases = new ArrayList<>();
try {
for ( Statement stmt : Iterations.asList( rc.getStatements( null, RDF.TYPE,
WEBDS.DBINFO, false ) ) ) {
databases.add( getDbInfo( stmt.getSubject(), rc ) );
}
}
catch ( RepositoryException e ) {
log.error( e, e );
}
return databases;
}