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


Java Model.addAll方法代码示例

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


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

示例1: 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

示例2: SaveRdf

import org.openrdf.model.Model; //导入方法依赖的package包/类
/**
 * Saves as RDF the graph created.
 *
 * @throws RepositoryException
 * @throws RDFHandlerException
 * @throws IOException
 */
private void SaveRdf() throws RepositoryException, RDFHandlerException, IOException {
    RepositoryResult statements = src.getStatements(null, null, null, true);

    Model model = new LinkedHashModel();

    java.util.ArrayList arr = new java.util.ArrayList();
    while (statements.hasNext()) {
        arr.add(statements.next());
    }
    model.addAll(arr);

    model.setNamespace("rdf", RDF.NAMESPACE);
    model.setNamespace("rdfs", RDFS.NAMESPACE);
    model.setNamespace("xsd", XMLSchema.NAMESPACE);
    model.setNamespace("foaf", FOAF.NAMESPACE);
    model.setNamespace("ex", "");

    Rio.write(model, new java.io.FileWriter(new java.io.File(outputFileName),false), RDFFormat.TURTLE);
    
    CloseAllConnections();
}
 
开发者ID:ale003,项目名称:testGraphDbs,代码行数:29,代码来源:GenerateRdf.java

示例3: addTranslations

import org.openrdf.model.Model; //导入方法依赖的package包/类
/**
 * Add translations to the translation cache
 * Only adds new translations
 *
 * @param statementList
 * @throws RepositoryException
 */
public void addTranslations(Collection<TranslatedStatement> statementList) throws RepositoryException {
  Model translations = new LinkedHashModel();
  for (TranslatedStatement s : statementList) {
    String orig = s.getOriginalStatement().getObject().stringValue();
    String trans = s.getTranslatedStatement().getObject().stringValue();
    translations.addAll(modelTranslation(orig, trans));
  }
  con.add(translations, translatorCache);
}
 
开发者ID:nvdk,项目名称:ods-lodms-plugins,代码行数:17,代码来源:TranslationCache.java

示例4: createEdgeProps

import org.openrdf.model.Model; //导入方法依赖的package包/类
private Model createEdgeProps( List<URI> concepts, List<URI> edges,
		Map<String, URI> structurelkp, UriBuilder schema,
		Map<Resource, String> labels ) {
	String cimplosion = Utility.implode( concepts );
	String eimplosion = Utility.implode( edges );

	String propq = "SELECT DISTINCT ?stype ?rtype ?otype ?prop WHERE {\n"
			+ "  ?s a|rdfs:subClassOf+ ?stype .\n"
			+ "  ?o a|rdfs:subClassOf+ ?otype .\n"
			+ "  ?r a|rdfs:subPropertyOf+ ?rtype .\n"
			+ "  ?s ?r ?o .\n"
			+ "  ?r ?prop ?propval . FILTER( ?prop != rdfs:label && isLiteral( ?propval ) ) .\n"
			+ "  VALUES ?stype {" + cimplosion + "} .\n"
			+ "  VALUES ?otype {" + cimplosion + "} .\n"
			+ "  VALUES ?rtype {" + eimplosion + "} .\n"
			+ "}";

	Model model = new LinkedHashModel();

	VoidQueryAdapter vqa = new VoidQueryAdapter( propq ) {
		@Override
		public void handleTuple( BindingSet set, ValueFactory fac ) {
			URI domain = URI.class.cast( set.getValue( "stype" ) );
			URI pred = URI.class.cast( set.getValue( "rtype" ) );
			URI range = URI.class.cast( set.getValue( "otype" ) );
			URI prop = URI.class.cast( set.getValue( "prop" ) );

			String sub = labels.get( domain );
			String rel = labels.get( pred );
			String obj = labels.get( range );
			String name = sub + "_" + rel + "_" + obj;

			model.addAll( getPropStructure( pred, domain, range, prop, schema,
					structurelkp, name ) );

		}
	};

	engine.queryNoEx( vqa );

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

示例5: getStatements

import org.openrdf.model.Model; //导入方法依赖的package包/类
/**
 * Converts the Perspective, its Insights and Parameters (and ordering!) to
 * Statements for adding to a Repository. If any Perspective, Insight, or
 * Parameter is missing an ID, a new one will be generated for it, and set on
 * the object
 *
 * @param p the perspective to convert.
 * @param user
 * @return a list of statements that completely represent the perspective tree
 */
public static Model getStatements( Perspective p, User user ) {
	Model statements = new LinkedHashModel();
	UriBuilder urib = UriBuilder.getBuilder( SEMPERS.NAMESPACE );

	// if we're creating statements, mark our repository as an insights db
	statements.add( new StatementImpl( SEMPERS.INSIGHT_DB, RDF.TYPE,
			SEMPERS.INSIGHT_CORE_TYPE ) );

	ValueFactory vf = new ValueFactoryImpl();

	if ( null == p.getId() ) {
		p.setId( urib.build( p.getLabel() ) );
	}
	statements.addAll( getPerspectiveStatements( p, vf, urib, user ) );

	for ( Insight i : p.getInsights() ) {
		final String piname = p.getLabel() + "-" + i.getLabel();

		if ( null == i.getId() ) {
			i.setId( urib.build( piname ) );
		}
		statements.addAll( getInsightStatements( i, vf, urib, user ) );

		for ( Parameter a : i.getInsightParameters() ) {
			final String pianame = piname + "-" + a.getLabel();

			URI predicateUri = urib.build( pianame + "-pred" );
			URI queryUri = urib.build( pianame + "-query" );

			if ( null == a.getId() ) {
				a.setId( urib.build( pianame ) );
			}

			statements.addAll( getParameterStatements( a, predicateUri, queryUri,
					vf, urib, user ) );
		}

		statements.addAll( getConstraintStatements( i, i.getInsightParameters() ) );
	}

	statements.addAll( getOrderingStatements( p, p.getInsights(), vf, urib ) );

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


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