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


Java IRI.generateDocumentIRI方法代碼示例

本文整理匯總了Java中org.semanticweb.owlapi.model.IRI.generateDocumentIRI方法的典型用法代碼示例。如果您正苦於以下問題:Java IRI.generateDocumentIRI方法的具體用法?Java IRI.generateDocumentIRI怎麽用?Java IRI.generateDocumentIRI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.semanticweb.owlapi.model.IRI的用法示例。


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

示例1: testDataPropertyMetadata

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
@Test
public void testDataPropertyMetadata() throws Exception {
	OWLOntologyManager m = OWLManager.createOWLOntologyManager();
	OWLOntology ontology = m.createOntology(IRI.generateDocumentIRI());
	{
		// create a test ontology with one data property
		OWLDataFactory f = m.getOWLDataFactory();
		IRI propIRI = IRI.generateDocumentIRI();
		OWLDataProperty prop = f.getOWLDataProperty(propIRI);
		m.addAxiom(ontology, f.getOWLDeclarationAxiom(prop));
		m.addAxiom(ontology, f.getOWLAnnotationAssertionAxiom(propIRI, f.getOWLAnnotation(f.getRDFSLabel(), f.getOWLLiteral("fake-data-property"))));
	}
	OWLGraphWrapper graph = new OWLGraphWrapper(ontology);
	MolecularModelManager<?> mmm = createM3(graph);
	Pair<List<JsonRelationInfo>,List<JsonRelationInfo>> pair = MolecularModelJsonRenderer.renderProperties(mmm, null, curieHandler);
	List<JsonRelationInfo> dataProperties = pair.getRight();
	assertEquals(1, dataProperties.size());
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:19,代碼來源:DataPropertyTest.java

示例2: enforceEL

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
public static OWLGraphWrapper enforceEL(OWLGraphWrapper graph) {
	Optional<IRI> originalIRI = graph.getSourceOntology().getOntologyID().getOntologyIRI();
	IRI newIRI;
	if(originalIRI.isPresent()) {
		String workIRI = originalIRI.get().toString();
		if (workIRI.endsWith(".owl")) {
			workIRI = workIRI.replace(".owl", "-el.owl");
		}
		else {
			workIRI = workIRI + "-el";
		}
		newIRI = IRI.create(workIRI);
	}
	else {
		newIRI = IRI.generateDocumentIRI();
	}
	return enforceEL(graph, newIRI);
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:19,代碼來源:InferenceBuilder.java

示例3: testDataProperyRenderer

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
@Test
public void testDataProperyRenderer() throws Exception {
	OWLOntologyManager m = OWLManager.createOWLOntologyManager();
	OWLOntology ontology = m.createOntology(IRI.generateDocumentIRI());
	final IRI clsIRI = IRI.generateDocumentIRI();
	final IRI propIRI = IRI.generateDocumentIRI();
	
	// create a test ontology with one data property and one class
	OWLDataFactory f = m.getOWLDataFactory();
	OWLDataProperty prop = f.getOWLDataProperty(propIRI);
	m.addAxiom(ontology, f.getOWLDeclarationAxiom(prop));
	m.addAxiom(ontology, f.getOWLAnnotationAssertionAxiom(propIRI, f.getOWLAnnotation(f.getRDFSLabel(), f.getOWLLiteral("fake-data-property"))));

	OWLClass cls = f.getOWLClass(clsIRI);
	m.addAxiom(ontology, f.getOWLDeclarationAxiom(cls));
	m.addAxiom(ontology, f.getOWLAnnotationAssertionAxiom(clsIRI, f.getOWLAnnotation(f.getRDFSLabel(), f.getOWLLiteral("fake-cls"))));
	
	// graph and m3
	OWLGraphWrapper graph = new OWLGraphWrapper(ontology);
	final UndoMetadata metadata = new UndoMetadata("foo-user");
	UndoAwareMolecularModelManager m3 = createM3(graph);
	
	final ModelContainer model = m3.generateBlankModel(metadata);
	final OWLNamedIndividual individual = m3.createIndividual(model, cls, metadata);
	m3.addDataProperty(model, individual, prop, f.getOWLLiteral(10), metadata);
	
	MolecularModelJsonRenderer r = new MolecularModelJsonRenderer(model, null, curieHandler);
	final JsonModel jsonModel = r.renderModel();
	assertEquals(1, jsonModel.individuals.length);
	assertEquals(1, jsonModel.individuals[0].annotations.length);
	{
		JsonAnnotation ann = jsonModel.individuals[0].annotations[0];
		assertEquals(propIRI.toString(), ann.key);
		assertEquals("10", ann.value);
		assertEquals("xsd:integer", ann.valueType);
	}
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:38,代碼來源:DataPropertyTest.java

示例4: testIRIConversion

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
@Test
public void testIRIConversion() throws Exception {
	IRI evidenceIRI = AnnotationShorthand.evidence.getAnnotationProperty();
	OWLAnnotationProperty p = f.getOWLAnnotationProperty(evidenceIRI);
	IRI iriValue = IRI.generateDocumentIRI();
	OWLAnnotation owlAnnotation = f.getOWLAnnotation(p, iriValue);
	JsonAnnotation json = JsonTools.create(p, owlAnnotation.getValue(), curieHandler);
	assertEquals(AnnotationShorthand.evidence.name(), json.key);
	assertEquals(curieHandler.getCuri(iriValue), json.value);
	assertEquals("IRI", json.valueType);
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:12,代碼來源:MolecularModelJsonRendererTest.java

示例5: testAnnotations

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
@Test
public void testAnnotations() throws Exception {
	// setup test model/ontology
	OWLOntology o = m.createOntology();
	OWLImportsDeclaration importDeclaration = f.getOWLImportsDeclaration(g.getSourceOntology().getOntologyID().getOntologyIRI().get());
	m.applyChange(new AddImport(o, importDeclaration));
	
	final IRI i1IRI = IRI.generateDocumentIRI();
	final OWLNamedIndividual ni1 = f.getOWLNamedIndividual(i1IRI);
	// declare individual
	m.addAxiom(o, f.getOWLDeclarationAxiom(ni1));
	// add annotations
	m.addAxiom(o, f.getOWLAnnotationAssertionAxiom(i1IRI, 
			f.getOWLAnnotation(f.getOWLAnnotationProperty(
					AnnotationShorthand.comment.getAnnotationProperty()), 
					f.getOWLLiteral("Comment 1"))));
	m.addAxiom(o, f.getOWLAnnotationAssertionAxiom(i1IRI, 
			f.getOWLAnnotation(f.getOWLAnnotationProperty(
					AnnotationShorthand.comment.getAnnotationProperty()), 
					f.getOWLLiteral("Comment 2"))));
	// declare type
	m.addAxiom(o, f.getOWLClassAssertionAxiom(g.getOWLClassByIdentifier("GO:0000003"), ni1));
	
	MolecularModelJsonRenderer r = new MolecularModelJsonRenderer(null, o, null, curieHandler);
	
	JsonOwlIndividual jsonOwlIndividualOriginal = r.renderObject(ni1);
	assertEquals(2, jsonOwlIndividualOriginal.annotations.length);
	
	String json = MolecularModelJsonRenderer.renderToJson(jsonOwlIndividualOriginal, true);
	
	JsonOwlIndividual jsonOwlIndividualParse = MolecularModelJsonRenderer.parseFromJson(json, JsonOwlIndividual.class);
	
	assertNotNull(jsonOwlIndividualParse);
	assertEquals(jsonOwlIndividualOriginal, jsonOwlIndividualParse);
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:36,代碼來源:MolecularModelJsonRendererTest.java

示例6: testSimpleClassExpression

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
private void testSimpleClassExpression(OWLClassExpression ce, String expectedJsonType) throws Exception {
	// setup test model/ontology
	OWLOntology o = m.createOntology();
	OWLImportsDeclaration importDeclaration = f.getOWLImportsDeclaration(g.getSourceOntology().getOntologyID().getOntologyIRI().get());
	m.applyChange(new AddImport(o, importDeclaration));
	
	// create indivdual with a ce type
	final IRI i1IRI = IRI.generateDocumentIRI();
	final OWLNamedIndividual ni1 = f.getOWLNamedIndividual(i1IRI);
	// declare individual
	m.addAxiom(o, f.getOWLDeclarationAxiom(ni1));
	// declare type
	m.addAxiom(o, f.getOWLClassAssertionAxiom(ce, ni1));
	
	
	MolecularModelJsonRenderer r = new MolecularModelJsonRenderer(null, o, null, curieHandler);
	
	JsonOwlIndividual jsonOwlIndividualOriginal = r.renderObject(ni1);
	
	String json = MolecularModelJsonRenderer.renderToJson(jsonOwlIndividualOriginal, true);
	assertTrue(json, json.contains("\"type\": \""+expectedJsonType+"\""));
	
	JsonOwlIndividual jsonOwlIndividualParse = MolecularModelJsonRenderer.parseFromJson(json, JsonOwlIndividual.class);
	
	assertNotNull(jsonOwlIndividualParse);
	assertEquals(jsonOwlIndividualOriginal, jsonOwlIndividualParse);
	
	Set<OWLClassExpression> ces = TestJsonOwlObjectParser.parse(new OWLGraphWrapper(o), jsonOwlIndividualParse.type);
	assertEquals(1, ces.size());
	assertEquals(ce, ces.iterator().next());
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:32,代碼來源:MolecularModelJsonRendererTest.java

示例7: addIndividual

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
private static OWLNamedIndividual addIndividual(OWLOntology o, String name, OWLClass typeCls) {
	final IRI iri = IRI.generateDocumentIRI();
	final OWLNamedIndividual ni = f.getOWLNamedIndividual(iri);
	// declare individual
	m.addAxiom(o, f.getOWLDeclarationAxiom(ni));
	if (typeCls != null) {
		m.addAxiom(o, f.getOWLClassAssertionAxiom(typeCls, ni));	
	}
	m.addAxiom(o, f.getOWLAnnotationAssertionAxiom(iri, f.getOWLAnnotation(f.getRDFSLabel(), f.getOWLLiteral(name))));
	
	return ni;
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:13,代碼來源:MolecularModelJsonRendererTest.java

示例8: testUpdateImports

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
@Test
public void testUpdateImports() throws Exception {
	final OWLOntologyManager m = OWLManager.createOWLOntologyManager();
	final OWLDataFactory f = m.getOWLDataFactory();
	
	// setup other import
	final IRI other = IRI.generateDocumentIRI();
	m.createOntology(other);
	
	// setup additional
	final IRI add1 = IRI.generateDocumentIRI();
	m.createOntology(add1);
	final IRI add2 = IRI.generateDocumentIRI();
	m.createOntology(add2);
	final Set<IRI> additional = new HashSet<IRI>();
	additional.add(add1);
	additional.add(add2);
	
	// setup tbox
	final IRI tboxIRI = IRI.generateDocumentIRI();
	m.createOntology(tboxIRI);
	
	// setup abox
	final OWLOntology abox = m.createOntology(IRI.generateDocumentIRI());
	// add initial imports to abox
	m.applyChange(new AddImport(abox, f.getOWLImportsDeclaration(other)));
	
	// update imports
	CoreMolecularModelManager.updateImports(abox, tboxIRI, additional);
	
	// check the resulting imports
	Set<OWLImportsDeclaration> declarations = abox.getImportsDeclarations();
	assertEquals(4, declarations.size());
	Set<IRI> declaredImports = new HashSet<IRI>();
	for (OWLImportsDeclaration importsDeclaration : declarations) {
		declaredImports.add(importsDeclaration.getIRI());
	}
	assertEquals(4, declaredImports.size());
	assertTrue(declaredImports.contains(tboxIRI));
	assertTrue(declaredImports.contains(add1));
	assertTrue(declaredImports.contains(add1));
	assertTrue(declaredImports.contains(other));
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:44,代碼來源:CoreMolecularModelManagerTest.java

示例9: save

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
public void save(File baseFolder, BufferedWriter w) throws IOException, OWLOntologyStorageException {
	w.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
	w.write("<catalog prefer=\"public\" xmlns=\"urn:oasis:names:tc:entity:xmlns:xml:catalog\">\n");
	
	for (OWLOntology ont : ontology.getImportsClosure()) {
		validateImports(ont);
		
		OWLOntologyID ontologyID = ont.getOntologyID();
		IRI actualIRI = null;
		Optional<IRI> optional = ontologyID.getOntologyIRI();
		if (optional.isPresent()) {
			actualIRI = optional.get();
		}

		// Not really sure why this is here, but apparently we can get
		// an ontology without an IRI, in which case we'll generate one
		// that is 'sort of' unique (only fails if two different machines run
		// this tool at the exact same time).
		//
		if (actualIRI == null) {
			IRI generatedIRI = IRI.generateDocumentIRI();
			actualIRI = generatedIRI;
		}
		// Always write the actualIRI
		String actualLocalFile = createLocalFileName(actualIRI);
		IRI outputStream = IRI.create(new File(baseFolder, actualLocalFile));
		ont.getOWLOntologyManager().saveOntology(ont, outputStream);
		
		if (LOGGER.isInfoEnabled()) {
			LOGGER.info("name: "+ actualIRI +" local: "+actualLocalFile);
		}
		w.write("  <uri name=\""+ actualIRI  +"\" uri=\""+ actualLocalFile +"\"/>\n");

		//
		// In case there is a difference between the source document IRI
		// and the IRI of the resolved target (e.g., there is an HTTP
		// redirect from a legacy IRI to a newer IRI), then write an entry
		// in the catalog that points the legacy IRI to the newer, canonical one.
		// Examples of this include:
		//  http://purl.obolibrary.org/obo/so.owl
		// which redirects to:
		//  http://purl.obolibrary.org/obo/so-xp.obo.owl
		//

		IRI 			documentIRI = ont.getOWLOntologyManager().getOntologyDocumentIRI(ont);
		if (documentIRI != actualIRI) {
			String sourceLocalFile = createLocalFileName(actualIRI);
			if (LOGGER.isInfoEnabled()) {
				LOGGER.info("alias: "+ documentIRI + " ==> " + actualIRI + " local: "+ sourceLocalFile);
			}
			w.write("  <uri name=\""+ documentIRI +"\" uri=\""+ sourceLocalFile +"\"/>\n");
		}
	}
	w.write("</catalog>\n");
	w.flush();
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:57,代碼來源:ImportClosureSlurper.java


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