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


Java Model类代码示例

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


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

示例1: getUser

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

示例2: getLinksBetween

import org.openrdf.model.Model; //导入依赖的package包/类
@Override
public Model getLinksBetween( URI subtype, URI objtype ) {
	String query = "CONSTRUCT{ ?s ?p ?o } WHERE { \n"
			+ "  ?mm a semtool:StructureData ;\n"
			+ "    rdf:predicate ?p ;\n"
			+ "    rdfs:domain ?s ;\n"
			+ "    rdfs:range ?o .\n";
	// + "}"

	Map<String, Value> bindings = new HashMap<>();
	if ( !Constants.ANYNODE.equals( subtype ) ) {
		query += "   ?dom a|rdfs:subClassOf* ?s .\n";
		bindings.put( "dom", subtype );
	}
	if ( !Constants.ANYNODE.equals( objtype ) ) {
		query += "   ?ran a|rdfs:subClassOf* ?o .\n";
		bindings.put( "ran", objtype );
	}
	query += "}";

	ModelQueryAdapter modelqa = new ModelQueryAdapter( query );
	modelqa.setBindings( bindings );

	return engine.constructNoEx( modelqa );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:26,代码来源:SemtoolStructureManagerImpl.java

示例3: getConnectedConceptTypes

import org.openrdf.model.Model; //导入依赖的package包/类
@Override
public Model getConnectedConceptTypes( Collection<URI> instances ) {
	final String query = "CONSTRUCT{ ?s ?p ?o } WHERE { \n"
			+ "  ?mm a semtool:StructureData ;\n"
			+ "    rdf:predicate ?p ;\n"
			+ "    rdfs:domain ?s ;\n"
			+ "    rdfs:range ?o .\n";
	String implosion = Utility.implode( instances );

	LinkedHashModel model = new LinkedHashModel();
	ModelQueryAdapter subjects = new ModelQueryAdapter( query
			+ " ?dom a|rdfs:subClassOf* ?s . VALUES ?dom {" + implosion + "} }", model );
	ModelQueryAdapter objects = new ModelQueryAdapter( query
			+ " ?ran a|rdfs:subClassOf* ?o . VALUES ?ran {" + implosion + "} }", model );
	engine.constructNoEx( subjects );
	engine.constructNoEx( objects );

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

示例4: rebuildConceptProps

import org.openrdf.model.Model; //导入依赖的package包/类
private Model rebuildConceptProps( List<URI> concepts ) {
	String cimplosion = Utility.implode( concepts );

	// now see what properties are on concepts and edges
	String query = "SELECT DISTINCT ?type ?prop WHERE {\n"
			+ "  ?s ?prop ?propval . FILTER ( isLiteral( ?propval ) )\n"
			+ "  ?s a|rdfs:subClassOf+ ?type .\n"
			+ "  FILTER ( ?prop != rdfs:label ) .\n"
			+ "} VALUES ?type { " + cimplosion + " }";

	ModelQueryAdapter mqa = new ModelQueryAdapter( query ) {

		@Override
		public void handleTuple( BindingSet set, ValueFactory fac ) {
			URI type = URI.class.cast( set.getValue( "type" ) );
			URI prop = URI.class.cast( set.getValue( "prop" ) );
			result.add( type, prop, Constants.ANYNODE );
		}
	};

	return engine.queryNoEx( mqa );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:23,代码来源:SemtoolStructureManagerImpl.java

示例5: rebuildEdges

import org.openrdf.model.Model; //导入依赖的package包/类
private Model rebuildEdges( List<URI> concepts, List<URI> edges ) {
	String cimplosion = Utility.implode( concepts );
	String eimplosion = Utility.implode( edges );

	// now see what concepts connect to others via our edge types
	String query = "CONSTRUCT { ?stype ?rtype ?otype } WHERE {\n"
			+ "  ?s a|rdfs:subClassOf+ ?stype .\n"
			+ "  ?o a|rdfs:subClassOf+ ?otype .\n"
			+ "  ?r a|rdfs:subPropertyOf+ ?rtype .\n"
			+ "  ?s ?r ?o .\n"
			+ "  VALUES ?stype {" + cimplosion + "} .\n"
			+ "  VALUES ?otype {" + cimplosion + "} .\n"
			+ "  VALUES ?rtype {" + eimplosion + "} .\n"
			+ "}";

	final Model model = engine.constructNoEx( new ModelQueryAdapter( query ) );
	return model;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:19,代码来源:SemtoolStructureManagerImpl.java

示例6: save

import org.openrdf.model.Model; //导入依赖的package包/类
private void save( Model model ) {
	// get old model, which we'll remove
	Model olds = getModel();

	ModificationExecutor eme = new ModificationExecutorAdapter( true ) {

		@Override
		public void exec( RepositoryConnection conn ) throws RepositoryException {
			conn.remove( olds );
			conn.add( model );
		}
	};

	try {
		engine.execute( eme );
	}
	catch ( Exception e ) {
		log.error( e, e );
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:21,代码来源:SemtoolStructureManagerImpl.java

示例7: getConstruct

import org.openrdf.model.Model; //导入依赖的package包/类
public static Model getConstruct( QueryExecutor<Model> query,
		RepositoryConnection rc, boolean dobindings )
		throws RepositoryException, MalformedQueryException, QueryEvaluationException {

	String sparql = processNamespaces( dobindings ? query.getSparql()
			: query.bindAndGetSparql(), query.getNamespaces() );

	GraphQuery tq = rc.prepareGraphQuery( QueryLanguage.SPARQL, sparql );
	tq.setIncludeInferred( query.usesInferred() );
	if ( dobindings ) {
		query.setBindings( tq, rc.getValueFactory() );
	}

	GraphQueryResult gqr = tq.evaluate();
	while ( gqr.hasNext() ) {
		query.getResults().add( gqr.next() );
	}
	gqr.close();

	return query.getResults();
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:22,代码来源:AbstractSesameEngine.java

示例8: getModel

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

示例9: getPerspectiveStatements

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

示例10: getParameterStatements

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

示例11: ttlToStdout

import org.openrdf.model.Model; //导入依赖的package包/类
public static void ttlToStdout( Model model ) {
	TurtleWriter tw = new TurtleWriter( System.out );
	try {
		tw.startRDF();
		for ( Map.Entry<String, String> en : DEFAULTNAMESPACES.entrySet() ) {
			tw.handleNamespace( en.getKey(), en.getValue() );
		}

		for ( Statement s : model ) {
			tw.handleStatement( s );
		}
		tw.endRDF();
	}
	catch ( Exception e ) {
		log.error( e, e );
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:18,代码来源:Utility.java

示例12: testExec3

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

示例13: testGetInstancesNoPropsAvailable

import org.openrdf.model.Model; //导入依赖的package包/类
@Test
public void testGetInstancesNoPropsAvailable() throws Exception {
	// this is just extra stuff that shouldn't be returned in the tests
	final URI REL = OWLB.getRelationUri().build();
	final URI EXTRA = OWLB.build( "AnotherRelType" );
	final URI EXTRAIMPL = DATAB.build( "AnotherRel" );

	final URI ALAN = DATAB.build( "Alan" );
	final URI CADILLAC = DATAB.build( "Cadillac" );

	engine.getRawConnection().add( EXTRA, RDFS.SUBPROPERTYOF, REL );
	engine.getRawConnection().add( EXTRAIMPL, RDF.TYPE, REL );


	Model expected = new LinkedHashModel();
	expected.add( YURI, YPY, YUGO );
	expected.add( ALAN, PURCHASE, CADILLAC );

	Model model = NodeDerivationTools.getInstances( HUMAN, PURCHASE, CAR,
			null, engine );
	assertEquals( expected, model );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:23,代码来源:NodeDerivationToolsTest.java

示例14: testImportXlsModern

import org.openrdf.model.Model; //导入依赖的package包/类
@Test
public void testImportXlsModern() throws Exception {
	engine.setBuilders( UriBuilder.getBuilder( DATAURI ),
			UriBuilder.getBuilder( SCHEMAURI ) );

	EngineLoader el = new EngineLoader();
	el.setDefaultBaseUri( BASEURI, false );
	ImportData errors = new ImportData();
	el.loadToEngine( Arrays.asList( CUSTOM ), engine, true, errors );
	Model owls = el.getMetamodel();
	el.release();

	if ( log.isTraceEnabled() ) {
		File tmpdir = FileUtils.getTempDirectory();
		try ( Writer w = new BufferedWriter( new FileWriter( new File( tmpdir,
				"custom-mm.nt" ) ) ) ) {
			engine.getRawConnection().export( new NTriplesWriter( w ) );
		}
	}

	compareOwls( owls, CUSTOM_EXP, engine.getSchemaBuilder() );
	compareData( engine.getRawConnection(), getExpectedGraph( CUSTOM_EXP ),
			engine.getSchemaBuilder(), engine.getDataBuilder() );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:25,代码来源:EngineLoaderTest.java

示例15: testImportXlsSpecial

import org.openrdf.model.Model; //导入依赖的package包/类
@Test
public void testImportXlsSpecial() throws Exception {
	engine.setBuilders( UriBuilder.getBuilder( DATAURI ),
			UriBuilder.getBuilder( SCHEMAURI ) );

	EngineLoader el = new EngineLoader();
	el.setDefaultBaseUri( BASEURI, false );
	ImportData errors = new ImportData();
	el.loadToEngine( Arrays.asList( TESTSPECIAL ), engine, true, errors );
	Model owls = el.getMetamodel();
	el.release();

	if ( log.isTraceEnabled() ) {
		File tmpdir = FileUtils.getTempDirectory();
		try ( Writer w = new BufferedWriter( new FileWriter( new File( tmpdir,
				"test-special.nt" ) ) ) ) {
			engine.getRawConnection().export( new NTriplesWriter( w ) );
		}
	}

	compareOwls( owls, TESTSPECIAL_EXP, engine.getSchemaBuilder() );
	compareData( engine.getRawConnection(), getExpectedGraph( TESTSPECIAL_EXP ),
			engine.getSchemaBuilder(), engine.getDataBuilder() );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:25,代码来源:EngineLoaderTest.java


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