當前位置: 首頁>>代碼示例>>Java>>正文


Java SHACLFunctions類代碼示例

本文整理匯總了Java中org.topbraid.shacl.arq.SHACLFunctions的典型用法代碼示例。如果您正苦於以下問題:Java SHACLFunctions類的具體用法?Java SHACLFunctions怎麽用?Java SHACLFunctions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SHACLFunctions類屬於org.topbraid.shacl.arq包,在下文中一共展示了SHACLFunctions類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getSHACLModel

import org.topbraid.shacl.arq.SHACLFunctions; //導入依賴的package包/類
public static Model getSHACLModel() {
	if(shaclModel == null) {
		
		shaclModel = JenaUtil.createDefaultModel();
		
		InputStream shaclTTL = SHACLSystemModel.class.getResourceAsStream("/rdf/shacl.ttl");
		shaclModel.read(shaclTTL, SH.BASE_URI, FileUtils.langTurtle);
		
		InputStream dashTTL = SHACLSystemModel.class.getResourceAsStream("/rdf/dash.ttl");
		shaclModel.read(dashTTL, SH.BASE_URI, FileUtils.langTurtle);
		
		InputStream toshTTL = SHACLSystemModel.class.getResourceAsStream("/rdf/tosh.ttl");
		shaclModel.read(toshTTL, SH.BASE_URI, FileUtils.langTurtle);
		
		shaclModel.add(SystemTriples.getVocabularyModel());
		
		SHACLFunctions.registerFunctions(shaclModel);
	}
	return shaclModel;
}
 
開發者ID:TopQuadrant,項目名稱:shacl,代碼行數:21,代碼來源:SHACLSystemModel.java

示例2: validate

import org.topbraid.shacl.arq.SHACLFunctions; //導入依賴的package包/類
public Model validate(Model dataModel, Model shapesModel) throws Exception {
	Model shaclModel = SHACLSystemModel.getSHACLModel();
	MultiUnion unionGraph = new MultiUnion(new Graph[] {
		shaclModel.getGraph(),
		dataModel.getGraph(),
		shapesModel.getGraph()
	});
	Model all = ModelFactory.createModelForGraph(unionGraph);

	// Make sure all sh:Functions are registered
	SHACLFunctions.registerFunctions(all);
	
	URI shapesGraphURI = URI.create("urn:x-shacl-shapes-graph:" + UUID.randomUUID().toString());
	Dataset dataset = ARQFactory.get().getDataset(dataModel);
	dataset.addNamedModel(shapesGraphURI.toString(), all);
       
	Model results = new ModelConstraintValidator().validateModel(dataset, shapesGraphURI, null, true, null, null).getModel();
       results.setNsPrefixes(all);
	return results; 
}
 
開發者ID:labra,項目名稱:shaclRunner,代碼行數:21,代碼來源:ShaclValidator.java

示例3: getSHACLModel

import org.topbraid.shacl.arq.SHACLFunctions; //導入依賴的package包/類
public static Model getSHACLModel() {
	if(shaclModel == null) {
		
		shaclModel = JenaUtil.createDefaultModel();
		
		InputStream shaclTTL = SHACLSystemModel.class.getResourceAsStream("/etc/shacl.ttl");
		shaclModel.read(shaclTTL, SH.BASE_URI, FileUtils.langTurtle);
		
		InputStream dashTTL = SHACLSystemModel.class.getResourceAsStream("/etc/dash.ttl");
		shaclModel.read(dashTTL, SH.BASE_URI, FileUtils.langTurtle);
		
		InputStream toshTTL = SHACLSystemModel.class.getResourceAsStream("/etc/tosh.ttl");
		shaclModel.read(toshTTL, SH.BASE_URI, FileUtils.langTurtle);
		
		shaclModel.add(SystemTriples.getVocabularyModel());
		
		SHACLFunctions.registerFunctions(shaclModel);
	}
	return shaclModel;
}
 
開發者ID:labra,項目名稱:shaclRunner,代碼行數:21,代碼來源:SHACLSystemModel.java

示例4: validateModel

import org.topbraid.shacl.arq.SHACLFunctions; //導入依賴的package包/類
/**
 * Validates a given data Model against all shapes from a given shapes Model.
 * If the shapesModel does not include the system graph triples then these will be added.
 * Entailment regimes are applied prior to validation.
 * @param dataModel  the data Model
 * @param shapesModel  the shapes Model
 * @param validateShapes  true to also validate any shapes in the data Model (false is faster)
 * @return an instance of sh:ValidationReport in a results Model
 */
public static Resource validateModel(Model dataModel, Model shapesModel, boolean validateShapes) {
	
	// Ensure that the SHACL, DASH and TOSH graphs are present in the shapes Model
	if(!shapesModel.contains(TOSH.hasShape, RDF.type, (RDFNode)null)) { // Heuristic
		Model unionModel = SHACLSystemModel.getSHACLModel();
		MultiUnion unionGraph = new MultiUnion(new Graph[] {
			unionModel.getGraph(),
			shapesModel.getGraph()
		});
		shapesModel = ModelFactory.createModelForGraph(unionGraph);
	}

	// Make sure all sh:Functions are registered
	SHACLFunctions.registerFunctions(shapesModel);
	
	// Create Dataset that contains both the data model and the shapes model
	// (here, using a temporary URI for the shapes graph)
	URI shapesGraphURI = URI.create("urn:x-shacl-shapes-graph:" + UUID.randomUUID().toString());
	Dataset dataset = ARQFactory.get().getDataset(dataModel);
	dataset.addNamedModel(shapesGraphURI.toString(), shapesModel);

	ShapesGraph shapesGraph = new ShapesGraph(shapesModel);
	if(!validateShapes) {
		shapesGraph.setShapeFilter(new ExcludeMetaShapesFilter());
	}
	ValidationEngine engine = ValidationEngineFactory.get().create(dataset, shapesGraphURI, shapesGraph, null);
	try {
		engine.applyEntailments();
		return engine.validateAll();
	}
	catch(InterruptedException ex) {
		return null;
	}
}
 
開發者ID:TopQuadrant,項目名稱:shacl,代碼行數:44,代碼來源:ValidationUtil.java

示例5: getValidationModel

import org.topbraid.shacl.arq.SHACLFunctions; //導入依賴的package包/類
/***************************************************************************
 * Public Static Methods
 **************************************************************************/
public static Model getValidationModel(Model shapesModel)
{
    MultiUnion unionGraph = new MultiUnion(new Graph[] {
        getSHACL().getGraph(), shapesModel.getGraph()
    });
    Model m = ModelFactory.createModelForGraph(unionGraph);

    // Make sure all sh:Functions are registered
    // Note that we don't perform validation of the shape definitions themselves.
    // To do that, activate the following line to make sure that all required triples are present:
    // dataModel = SHACLUtil.withDefaultValueTypeInferences(shapesModel);
    SHACLFunctions.registerFunctions(m);
    return m;
}
 
開發者ID:hugomanguinhas,項目名稱:europeana,代碼行數:18,代碼來源:TopBraidValidator.java


注:本文中的org.topbraid.shacl.arq.SHACLFunctions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。