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


Java StatementImpl类代码示例

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


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

示例1: getCreateStatements

import org.openrdf.model.impl.StatementImpl; //导入依赖的package包/类
private static Collection<Statement> getCreateStatements( Resource id, User t,
		ValueFactory vf ) {
	List<Statement> stmts = new ArrayList<>();
	stmts.add( new StatementImpl( id, RDF.TYPE, FOAF.PERSON ) );
	stmts.add( new StatementImpl( id, FOAF.ACCOUNT, vf.createLiteral( t.getUsername() ) ) );

	for ( Map.Entry<UserProperty, URI> en : PROPMAP.entrySet() ) {
		UserProperty prop = en.getKey();

		String str = t.getProperty( prop );
		if ( !str.trim().isEmpty() ) {
			stmts.add( new StatementImpl( id, en.getValue(), vf.createLiteral( str ) ) );
		}
	}

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

示例2: getCopier

import org.openrdf.model.impl.StatementImpl; //导入依赖的package包/类
private static RepositoryCopier getCopier( RepositoryConnection conn,
		Map<URI, URI> fromto, URI schema, URI data ) {
	final UriBuilder owlb = UriBuilder.getBuilder( schema );
	final UriBuilder datab = UriBuilder.getBuilder( data );

	return new RepositoryCopier( conn ) {

		@Override
		public void handleStatement( Statement stmt ) throws RDFHandlerException {
			URI sub = URI.class.cast( stmt.getSubject() );
			URI pred = stmt.getPredicate();
			Value obj = stmt.getObject();

			sub = upgrade( sub, fromto, owlb, datab );
			pred = upgrade( pred, fromto, owlb, datab );
			if ( obj instanceof URI ) {
				obj = upgrade( URI.class.cast( obj ), fromto, owlb, datab );
			}

			super.handleStatement( new StatementImpl( sub, pred, obj ) );
		}
	};
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:24,代码来源:LegacyUpgrader.java

示例3: getModel

import org.openrdf.model.impl.StatementImpl; //导入依赖的package包/类
public static Model getModel( InsightManager im, User user ) {
	Model statements = new LinkedHashModel();
	int idx = 0;

	RDFParser parser = new TurtleParser();
	StatementCollector coll = new StatementCollector();
	parser.setRDFHandler( coll );
	try ( InputStream is = IEngine.class.getResourceAsStream( "/models/sempers.ttl" ) ) {
		parser.parse( is, SEMPERS.BASE_URI );
	}
	catch ( Exception e ) {
		log.warn( "could not include sempers.ttl ontology in statements", e );
	}

	statements.addAll( coll.getStatements() );

	ValueFactory vf = new ValueFactoryImpl();
	for ( Perspective p : im.getPerspectives() ) {
		statements.addAll( getStatements( p, user ) );
		statements.add( new StatementImpl( p.getId(), OLO.index,
				vf.createLiteral( idx++ ) ) );
	}

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

示例4: getPerspectiveStatements

import org.openrdf.model.impl.StatementImpl; //导入依赖的package包/类
protected static Model getPerspectiveStatements( Perspective p,
		ValueFactory vf, UriBuilder urib, User user ) {

	Model statements = new LinkedHashModel();
	URI pid = p.getId();
	Date now = new Date();

	statements.add( new StatementImpl( pid, RDF.TYPE, SEMPERS.Perspective ) );
	statements.add( new StatementImpl( pid, RDFS.LABEL,
			vf.createLiteral( p.getLabel() ) ) );
	if ( null != p.getDescription() ) {
		statements.add( new StatementImpl( pid, DCTERMS.DESCRIPTION,
				vf.createLiteral( p.getDescription() ) ) );
	}

	statements.add( new StatementImpl( pid, DCTERMS.CREATED,
			vf.createLiteral( now ) ) );
	statements.add( new StatementImpl( pid, DCTERMS.MODIFIED,
			vf.createLiteral( now ) ) );
	statements.add( new StatementImpl( pid, DCTERMS.CREATOR,
			vf.createLiteral( getAuthorInfo( user ) ) ) );

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

示例5: getParameterStatements

import org.openrdf.model.impl.StatementImpl; //导入依赖的package包/类
protected static Model getParameterStatements( Parameter parameter,
		URI predicateUri, URI queryUri, ValueFactory vf, UriBuilder urib,
		User user ) {

	Model statements = new LinkedHashModel();

	URI pid = parameter.getId();

	statements.add( new StatementImpl( pid, RDFS.LABEL,
			vf.createLiteral( parameter.getLabel() ) ) );

	statements.add( new StatementImpl( pid, SPL.predicate, predicateUri ) );
	statements.add( new StatementImpl( pid, SP.query, queryUri ) );

	statements.add( new StatementImpl( predicateUri, RDFS.LABEL,
			vf.createLiteral( parameter.getLabel() ) ) );
	statements.add( new StatementImpl( queryUri, SP.text,
			vf.createLiteral( parameter.getDefaultQuery() ) ) );

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

示例6: testExec3

import org.openrdf.model.impl.StatementImpl; //导入依赖的package包/类
@Test
public void testExec3() throws Exception {
	InMemorySesameEngine eng = InMemorySesameEngine.open();
	StatementAddingExecutor sae = new StatementAddingExecutor(
			Arrays.asList( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
							new LiteralImpl( "label" ) ) ), true );
	sae.resetStatements( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
			new LiteralImpl( "tester" ) ) );

	Model before = eng.toModel();
	eng.execute( sae );
	Model after = eng.toModel();
	eng.closeDB();
	assertTrue( ( before.size() + 1 ) == after.size() );

	assertTrue( after.contains( RDFS.DOMAIN, RDFS.LABEL, new LiteralImpl( "tester" ) ) );
	assertFalse( after.contains( RDFS.DOMAIN, RDFS.LABEL, new LiteralImpl( "label" ) ) );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:19,代码来源:StatementAddingExecutorTest.java

示例7: setUp

import org.openrdf.model.impl.StatementImpl; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	Repository fromrepo = new SailRepository( new MemoryStore() );
	Repository torepo = new SailRepository( new MemoryStore() );

	fromrepo.initialize();
	torepo.initialize();

	from = fromrepo.getConnection();
	to = torepo.getConnection();

	from.add( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
			new LiteralImpl( "test" ) ) );
	from.add( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
			new LiteralImpl( "test2" ) ) );
	from.setNamespace( OWL.PREFIX, OWL.NAMESPACE );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:18,代码来源:RepositoryCopierTest.java

示例8: testClear

import org.openrdf.model.impl.StatementImpl; //导入依赖的package包/类
@Test
public void testClear() throws Exception {
	StatementAddingExecutor sae = new StatementAddingExecutor();
	sae.addStatement( new StatementImpl( RDFS.DATATYPE, RDFS.LABEL,
			new LiteralImpl( "test label" ) ) );
	eng.execute( sae );

	ListQueryAdapter<URI> q
			= OneVarListQueryAdapter.getUriList( "SELECT ?s WHERE { ?s rdfs:label ?o }" );

	List<URI> addeduris = new ArrayList<>( eng.queryNoEx( q ) );
	q.clear();

	EngineUtil2.clear( eng );
	List<URI> newuris = eng.queryNoEx( q );

	assertNotEquals( addeduris, newuris );
	assertTrue( newuris.isEmpty() );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:20,代码来源:EngineUtil2Test.java

示例9: setUp

import org.openrdf.model.impl.StatementImpl; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	eng = InMemorySesameEngine.open();

	RepositoryConnection rc = eng.getRawConnection();
	rc.begin();
	rc.add( DATA, null, RDFFormat.NTRIPLES );
	rc.add( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
			new LiteralImpl( "label" ) ) );

	rc.remove( eng.getBaseUri(), MetadataConstants.DCT_MODIFIED, null );
	rc.add( eng.getBaseUri(), MetadataConstants.DCT_MODIFIED,
			rc.getValueFactory().createLiteral( new Date() ) );

	rc.commit();
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:17,代码来源:InMemorySesameEngineTest.java

示例10: testUpdateDate2

import org.openrdf.model.impl.StatementImpl; //导入依赖的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

示例11: testGetLabels

import org.openrdf.model.impl.StatementImpl; //导入依赖的package包/类
@Test
public void testGetLabels() throws Exception {
	InMemorySesameEngine eng = InMemorySesameEngine.open();
	eng.getRawConnection().begin();
	eng.getRawConnection().add( new StatementImpl( RDFS.ISDEFINEDBY,
			RDFS.LABEL, new LiteralImpl( "my label" ) ) );
	eng.getRawConnection().add( new StatementImpl( RDFS.MEMBER,
			RDFS.LABEL, new LiteralImpl( "my label 2" ) ) );
	eng.getRawConnection().commit();

	String label = Utility.getInstanceLabel( RDFS.ISDEFINEDBY, eng );
	assertEquals( "my label", label );

	Map<Resource, String> labels = Utility.getInstanceLabels( null, eng );
	assertTrue( labels.isEmpty() );

	labels = Utility.getInstanceLabels( Arrays.asList(
			RDFS.MEMBER, RDFS.DOMAIN ), eng );
	assertEquals( "domain", labels.get( RDFS.DOMAIN ) );
	assertEquals( "my label 2", labels.get( RDFS.MEMBER ) );

	labels = Utility.getInstanceLabels( Arrays.asList( RDFS.ISDEFINEDBY,
			RDFS.LITERAL ), null );
	assertEquals( 2, labels.size() );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:26,代码来源:UtilityTest.java

示例12: testRemoveElementsSinceLevel

import org.openrdf.model.impl.StatementImpl; //导入依赖的package包/类
@Test
public void testRemoveElementsSinceLevel() {
	GraphDataModel gdm = new GraphDataModel();
	gdm.addGraphLevel( Arrays.asList( YURI ), eng, 1 );
	Model m = new LinkedHashModel();
	m.add( new StatementImpl( YURI, YPY, YUGO ) );
	gdm.addGraphLevel( m, eng, 2 );

	List<SEMOSSVertex> list = new ArrayList<>( gdm.getGraph().getVertices() );
	Collections.sort( list, VERTCOMP );

	SEMOSSVertex yuri = list.get( 1 );
	SEMOSSVertex yugo = list.get( 0 );

	assertTrue( gdm.presentAtLevel( yuri, 2 ) );
	assertTrue( gdm.presentAtLevel( yugo, 2 ) );
	assertEquals( 1, gdm.getGraph().getEdgeCount() );

	gdm.removeElementsSinceLevel( 1 );

	assertTrue( gdm.getGraph().getEdges().isEmpty() );
	assertEquals( yuri, gdm.getGraph().getVertices().iterator().next() );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:24,代码来源:GraphDataModelTest.java

示例13: addPredicateEdges

import org.openrdf.model.impl.StatementImpl; //导入依赖的package包/类
/**
 * Query for all triples involving a given predicate and add corresponding edges to a
 * {@link Graph} in one or both directions.
 * @param predicate Find all connections via this predicate URI
 * @param dir Direction of interest: for a matching triple, if {@link Direction#OUT} add an edge
 *      from subject to object; if {@link Direction#IN} add an edge from object to subject;
 *      if {@link Direction#BOTH} add both.
 * @param graph A TinkerPop graph
 * @param edgeName Label that will be given to all added edges
 * @throws QueryEvaluationException
 */
private void addPredicateEdges(final URI predicate, final Direction dir, final Graph graph, final String edgeName)
        throws QueryEvaluationException {
    final CloseableIteration<Statement, QueryEvaluationException> iter = RyaDAOHelper.query(ryaDAO,
            null, predicate, null, conf);
    try {
        while (iter.hasNext()) {
            final Statement st = iter.next();
            if (Direction.OUT.equals(dir) || Direction.BOTH.equals(dir)) {
                addStatementEdge(graph, edgeName, st);
            }
            if (Direction.IN.equals(dir) || Direction.BOTH.equals(dir)) {
                addStatementEdge(graph, edgeName, new StatementImpl((Resource) st.getObject(),
                        st.getPredicate(), st.getSubject()));
            }
        }
    } finally {
        if (iter != null) {
            iter.close();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:33,代码来源:InferenceEngine.java

示例14: testGraphConfiguration

import org.openrdf.model.impl.StatementImpl; //导入依赖的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

示例15: testInsertData

import org.openrdf.model.impl.StatementImpl; //导入依赖的package包/类
public void testInsertData() throws Exception {
    URI cpu = vf.createURI(litdupsNS, "cpu");
    URI loadPerc = vf.createURI(litdupsNS, "loadPerc");
    URI uri1 = vf.createURI(litdupsNS, "uri1");
    URI uri2 = vf.createURI(litdupsNS, "uri2");
    List<Statement> insert = new ArrayList<Statement>();
    insert.add(new StatementImpl(cpu, loadPerc, uri1));
    insert.add(new StatementImpl(cpu, loadPerc, uri2));

    resultEndpoint.expectedBodiesReceived(true);
    template.sendBody(insert);
    assertMockEndpointsSatisfied();

    resultEndpoint.expectedMessageCount(2);
    String query = "select * where {" +
            "<" + cpu.toString() + "> ?p ?o1." +
            "}";
    template.sendBodyAndHeader(null, CbSailComponent.SPARQL_QUERY_PROP, query);
    assertMockEndpointsSatisfied();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:21,代码来源:CbSailTest.java


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