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


Java Model.removeAll方法代码示例

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


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

示例1: bulkUpdate

import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
/**
 * Method called to Chunk the triples into N-Sized batches and post to VIVO.
 * This is designed to work around / handle errors when posting sets of triples
 * over 10,000 to the API.
 *
 * @param namedGraph String with named graph.
 * @param changeModel Jena model with set of changes to sync to store.
 * @param changeType Either add or remove.
 * @return Boolean true if update was successful.
 * @throws IOException
 */
private Boolean bulkUpdate(String namedGraph, Model changeModel, String changeType) throws IOException {
    // Temporary model to hold
    Model tmpModel = ModelFactory.createDefaultModel();
    Integer bSize = Integer.parseInt(batchSize);
    // Use an integer to count triples rather than calling size on the model
    // during each loop.
    Integer size = 0;
    StmtIterator iter = changeModel.listStatements();
    while (iter.hasNext()) {
        Statement stmt = iter.nextStatement();  // get next statement
        tmpModel.add(stmt);
        size++;
        if (size >= bSize) {
            // Submit
            log.info("Submitting " + size + " triples to " + namedGraph);
            submitBatch(tmpModel, namedGraph, changeType);
            // Reset the tmp model.
            tmpModel.removeAll();
            // Reset the counter.
            size = 0;
        }
    }
    log.info("model size:" + tmpModel.size());
    // Submit the remaining statements, if any.
    if (tmpModel.size() > 0) {
        submitBatch(tmpModel, namedGraph, changeType);
    }
    return true;
}
 
开发者ID:lawlesst,项目名称:karma2vivo,代码行数:41,代码来源:VIVOSPARQLClient.java

示例2: collapseAnnotations

import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
private List<Statement> collapseAnnotations(Property property, Model model){
	
	List<Statement> stmts = new ArrayList<Statement>();
	
	Map<String, Map<String,Statement>> literalMap = new HashMap<String, Map<String,Statement>>();
	StmtIterator stmtIt = model.listStatements(null, property, (RDFNode) null);
	stmtIt.forEachRemaining(stmt -> {
		RDFNode obj = stmt.getObject();
		if(obj.isLiteral()){
			Literal lit = obj.asLiteral();
			String lang = lit.getLanguage();
			if(lang == null){
				lang = "null";
			}
			Map<String, Statement> stmtMap = literalMap.get(lang);
			if(stmtMap == null) {
				stmtMap = new HashMap<String, Statement>();
				literalMap.put(lang, stmtMap);
			}
			
			Statement statement = stmtMap.get(lang);
			boolean insert = false;
			if(statement == null) insert = true;
			else{
				String statementLF = ((Literal)statement.getObject()).getLexicalForm();
				String lexicalForm = lit.getLexicalForm();
				if(lexicalForm.length() > statementLF.length()) insert = true;
			}
				
				
			if(insert) stmtMap.put(lang, statement);
		}
		
	});
	
	model.removeAll(null, property, (RDFNode) null);
	
	literalMap.forEach((subject, stmtMap) -> {
		stmtMap.forEach((lang, stmt) -> {
			model.add(stmt);
		});
	});
	
	return stmts;
	
}
 
开发者ID:teamdigitale,项目名称:ontonethub,代码行数:47,代码来源:IndexingJob.java

示例3: keepMaxLengthAnnotationsOnly

import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
private List<Statement> keepMaxLengthAnnotationsOnly(Property property, Model model){
	
	List<Statement> stmts = new ArrayList<Statement>();
	
	Map<Resource, Map<String,Statement>> literalMap = new HashMap<Resource, Map<String,Statement>>();
	StmtIterator stmtIt = model.listStatements(null, property, (RDFNode) null);
	stmtIt.forEachRemaining(stmt -> {
		Resource subj = stmt.getSubject();
		RDFNode obj = stmt.getObject();
		if(obj.isLiteral()){
			Literal lit = obj.asLiteral();
			String lang = lit.getLanguage();
			if(lang == null){
				lang = "null";
			}
			Map<String, Statement> stmtMap = literalMap.get(subj);
			if(stmtMap == null) {
				stmtMap = new HashMap<String, Statement>();
				literalMap.put(subj, stmtMap);
			}
			
			Statement statement = stmtMap.get(lang);
			boolean insert = false;
			if(statement == null) insert = true;
			else{
				String statementLF = ((Literal)statement.getObject()).getLexicalForm();
				String lexicalForm = lit.getLexicalForm();
				if(lexicalForm.length() > statementLF.length()) insert = true;
			}
				
				
			if(insert) stmtMap.put(lang, stmt);
		}
		
	});
	
	model.removeAll(null, property, (RDFNode) null);
	
	literalMap.forEach((subject, stmtMap) -> {
		stmtMap.forEach((lang, stmt) -> {
			model.add(stmt);
		});
	});
	
	return stmts;
	
}
 
开发者ID:teamdigitale,项目名称:ontonethub,代码行数:48,代码来源:IndexingJob.java


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