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


Java Iterations类代码示例

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


Iterations类属于info.aduna.iteration包,在下文中一共展示了Iterations类的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;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:21,代码来源:DbInfoMapper.java

示例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;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:19,代码来源:DbInfoMapper.java

示例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;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:23,代码来源:UserMapper.java

示例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;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:19,代码来源:UserMapper.java

示例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" ) );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:25,代码来源:EngineLoaderTest.java

示例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 );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:27,代码来源:InMemorySesameEngineTest.java

示例7: extractAllStatements

import info.aduna.iteration.Iterations; //导入依赖的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

示例8: testGraphConfiguration

import info.aduna.iteration.Iterations; //导入依赖的package包/类
@Test
//This isn't a good test.  It's simply a cut-and-paste from a test that was failing in a different package in the SameAsVisitor.
public void testGraphConfiguration() throws Exception {
    URI a = vf.createURI(namespace, "a");
    Statement statement = new StatementImpl(a, vf.createURI(namespace, "p"), vf.createLiteral("l"));
    Statement statement2 = new StatementImpl(a, vf.createURI(namespace, "p2"), vf.createLiteral("l"));
    ryaDAO.add(RdfToRyaConversions.convertStatement(statement));
    ryaDAO.add(RdfToRyaConversions.convertStatement(statement2));
    ryaDAO.add(RdfToRyaConversions.convertStatement(new StatementImpl(vf.createURI(namespace, "b"), vf.createURI(namespace, "p"), vf.createLiteral("l"))));
    ryaDAO.add(RdfToRyaConversions.convertStatement(new StatementImpl(vf.createURI(namespace, "c"), vf.createURI(namespace, "n"), vf.createLiteral("l"))));

    // build a connection
    RdfCloudTripleStore store = new RdfCloudTripleStore();
    store.setConf(conf);
    store.setRyaDAO(ryaDAO);

    InferenceEngine inferenceEngine = new InferenceEngine();
    inferenceEngine.setRyaDAO(ryaDAO);
    store.setInferenceEngine(inferenceEngine);
    
    store.initialize();

    System.out.println(Iterations.asList(store.getConnection().getStatements(a, vf.createURI(namespace, "p"), vf.createLiteral("l"), false, new Resource[0])).size());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:25,代码来源:SameAsTest.java

示例9: testGetStatement1

import info.aduna.iteration.Iterations; //导入依赖的package包/类
@Test
public void testGetStatement1()
        throws Exception {
    Resource context1 = conn.getValueFactory().createURI("http://marklogic.com/test/context1");
    Resource context2 = conn.getValueFactory().createURI("http://marklogic.com/test/context2");
    File inputFile1 = new File("src/test/resources/testdata/default-graph-1.ttl");
    conn.add(inputFile1, "http://example.org/example1/", RDFFormat.TURTLE, (Resource) null);
    File inputFile2 = new File("src/test/resources/testdata/default-graph-2.ttl");
    conn.add(inputFile2, "http://example.org/example1/", RDFFormat.TURTLE, context1);
    File inputFile3 = new File("src/test/resources/testdata/default-graph-2.ttl");
    conn.add(inputFile3, "http://example.org/example1/", RDFFormat.TURTLE, context2);

    conn.clear(null, context1);
    RepositoryResult<Statement> statements = conn.getStatements(null, null, null, true);
    Model model = Iterations.addAll(statements, new LinkedHashModel());

    Assert.assertEquals(4, model.size());
    conn.clear();
}
 
开发者ID:marklogic,项目名称:marklogic-sesame,代码行数:20,代码来源:MarkLogicRepositoryConnectionTest.java

示例10: testGetStatementIsEqualToSize

import info.aduna.iteration.Iterations; //导入依赖的package包/类
@Test
public void testGetStatementIsEqualToSize() throws Exception{
    Resource context5 = conn.getValueFactory().createURI("http://marklogic.com/test/context5");

    ValueFactory f= conn.getValueFactory();

    URI alice = f.createURI("http://example.org/people/alice");
    URI bob = f.createURI("http://example.org/people/bob");
    URI name = f.createURI("http://example.org/ontology/name");
    URI person = f.createURI("http://example.org/ontology/Person");
    Literal bobsName = f.createLiteral("Bob");
    Literal alicesName = f.createLiteral("Alice");

    conn.add(alice, RDF.TYPE, person, null, context5);
    conn.add(alice, name, alicesName, null, context5);
    conn.add(bob, RDF.TYPE, person, context5);
    conn.add(bob, name, bobsName, context5);

    RepositoryResult<Statement> statements = conn.getStatements(null, null, null, true, null,context5);
    Model aboutPeople = Iterations.addAll(statements, new LinkedHashModel());

    Assert.assertEquals(conn.size(null,context5),aboutPeople.size());
    conn.clear(null,context5);
}
 
开发者ID:marklogic,项目名称:marklogic-sesame,代码行数:25,代码来源:MarkLogicRepositoryConnectionTest.java

示例11: loadModelABox

import info.aduna.iteration.Iterations; //导入依赖的package包/类
@Override
protected OWLOntology loadModelABox(IRI modelId) throws OWLOntologyCreationException {
	LOG.info("Load model abox: " + modelId + " from database");
	try {
		BigdataSailRepositoryConnection connection = repo.getReadOnlyConnection();
		try {
			//TODO repeated code with loadModel
			RepositoryResult<Resource> graphs = connection.getContextIDs();
			if (!Iterations.asSet(graphs).contains(new URIImpl(modelId.toString()))) {
				throw new OWLOntologyCreationException("No such model in datastore: " + modelId);
			}
			graphs.close();
			RepositoryResult<Statement> statements = 
					connection.getStatements(null, null, null, false, new URIImpl(modelId.toString()));
			OWLOntology abox = loadOntologyDocumentSource(new RioMemoryTripleSource(statements), true);
			statements.close();
			abox = postLoadFileFilter(abox);
			return abox;
		} finally {
			connection.close();
		}	
	} catch (RepositoryException e) {
		throw new OWLOntologyCreationException(e);
	}
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:26,代码来源:BlazegraphMolecularModelManager.java

示例12: flushUpdates

import info.aduna.iteration.Iterations; //导入依赖的package包/类
@Override
public void flushUpdates()
	throws SailException
{
	super.flushUpdates();

	if (this.statementsRemoved) {
		this.logger.debug("statements removed, starting inferencing from scratch");
		clearInferred();
		addAxiomStatements();

		this.newStatements = new GraphImpl();
		Iterations.addAll(getWrappedConnection().getStatements(null, null, null, true), this.newStatements);

		this.statementsRemoved = false;
	}

	doInferencing();
}
 
开发者ID:semweb4j,项目名称:semweb4j,代码行数:20,代码来源:ForwardChainingRDFSInferencerConnection.java

示例13: 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);
	}
}
 
开发者ID:semweb4j,项目名称:semweb4j,代码行数:17,代码来源:RepositoryModel.java

示例14: generateModel

import info.aduna.iteration.Iterations; //导入依赖的package包/类
static Model generateModel(RepositoryResult<Statement> statements) {

		Model model = null;
		try {
			model = Iterations.addAll(statements, new LinkedHashModel());
		} catch (RepositoryException e) {
			e.printStackTrace();
		}

		model.setNamespace("rdf", RDF.NAMESPACE);
		model.setNamespace("rdfs", RDFS.NAMESPACE);
		model.setNamespace("foaf", FOAF.NAMESPACE);
		model.setNamespace("schema", schema);
		model.setNamespace("dbpedia", dbpedia);
		model.setNamespace("dc", dublin);
		return model;
	}
 
开发者ID:therelaxist,项目名称:spring-usc,代码行数:18,代码来源:Homework.java

示例15: 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());
    }
}
 
开发者ID:apache,项目名称:marmotta,代码行数:25,代码来源:ReasoningEngine.java


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