本文整理汇总了Java中org.semanticweb.owlapi.model.AddImport类的典型用法代码示例。如果您正苦于以下问题:Java AddImport类的具体用法?Java AddImport怎么用?Java AddImport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AddImport类属于org.semanticweb.owlapi.model包,在下文中一共展示了AddImport类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: translate
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
/**
* Translate the given {@link GafDocument} into an OWL representation of the LEGO model.
*
* @param gaf
* @return lego ontology
* @throws OWLException
* @throws UnknownIdentifierException
*/
public OWLOntology translate(GafDocument gaf) throws OWLException, UnknownIdentifierException {
final OWLOntologyManager m = graph.getManager();
OWLOntology lego = m.createOntology(IRI.generateDocumentIRI());
OWLOntology sourceOntology = graph.getSourceOntology();
OWLOntologyID ontologyID = sourceOntology.getOntologyID();
if (ontologyID != null) {
Optional<IRI> ontologyIRI = ontologyID.getOntologyIRI();
if (ontologyIRI.isPresent()) {
OWLDataFactory f = m.getOWLDataFactory();
OWLImportsDeclaration importDeclaration = f.getOWLImportsDeclaration(ontologyIRI.get());
m.applyChange(new AddImport(lego, importDeclaration ));
}
}
translate(gaf.getGeneAnnotations(), lego);
return lego;
}
开发者ID:geneontology,项目名称:minerva,代码行数:25,代码来源:GafToLegoIndividualTranslator.java
示例2: addImportsFromSupportOntologies
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
public void addImportsFromSupportOntologies() {
OWLOntology sourceOntology = getSourceOntology();
OWLDataFactory factory = getDataFactory();
for (OWLOntology o : getSupportOntologySet()) {
Optional<IRI> ontologyIRI = o.getOntologyID().getOntologyIRI();
if (ontologyIRI.isPresent()) {
OWLImportsDeclaration importsDeclaration = factory.getOWLImportsDeclaration(ontologyIRI.get());
AddImport ai = new AddImport(sourceOntology, importsDeclaration);
LOG.info("Applying: "+ai);
getManager().applyChange(ai);
}
else {
String msg = "Could not add import due to missing ontology id: "+o;
LOG.error(msg);
throw new RuntimeException(msg);
}
}
this.setSupportOntologySet(new HashSet<OWLOntology>());
}
开发者ID:owlcollab,项目名称:owltools,代码行数:20,代码来源:OWLGraphWrapperBasic.java
示例3: handleSupportOntologies
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
private static List<OWLOntologyChange> handleSupportOntologies(OWLGraphWrapper graph)
{
OWLOntology ontology = graph.getSourceOntology();
OWLOntologyManager manager = ontology.getOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
List<OWLOntologyChange> removeImportChanges = new ArrayList<OWLOntologyChange>();
Set<OWLOntology> supportOntologySet = graph.getSupportOntologySet();
for (OWLOntology support : supportOntologySet) {
Optional<IRI> supportIRI = support.getOntologyID().getOntologyIRI();
if(supportIRI.isPresent()) {
IRI ontologyIRI = supportIRI.get();
OWLImportsDeclaration importDeclaration = factory.getOWLImportsDeclaration(ontologyIRI);
ChangeApplied status = manager.applyChange(new AddImport(ontology, importDeclaration));
if (ChangeApplied.SUCCESSFULLY == status) {
// the change was successful, create remove import for later
removeImportChanges.add(new RemoveImport(ontology, importDeclaration));
}
}
}
return removeImportChanges;
}
开发者ID:owlcollab,项目名称:owltools,代码行数:23,代码来源:AssertInferenceTool.java
示例4: init
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
/**
* Initialization consists of setting aboxOntology, if not set - defaults to a new ontology using tbox.
* @throws OWLOntologyCreationException
*/
private void init() throws OWLOntologyCreationException {
// abox -> tbox
if (aboxOntology == null) {
LOG.debug("Creating abox ontology. mgr = "+getOWLOntologyManager());
Optional<IRI> tBoxIRI = tboxOntology.getOntologyID().getOntologyIRI();
if (tBoxIRI.isPresent()) {
IRI ontologyIRI = IRI.create(tBoxIRI.get()+"__abox");
aboxOntology = getOWLOntologyManager().getOntology(ontologyIRI);
if (aboxOntology != null) {
LOG.warn("Clearing existing abox ontology");
getOWLOntologyManager().removeOntology(aboxOntology);
}
aboxOntology = getOWLOntologyManager().createOntology(ontologyIRI);
AddImport ai = new AddImport(aboxOntology,
getOWLDataFactory().getOWLImportsDeclaration(tBoxIRI.get()));
getOWLOntologyManager().applyChange(ai);
}
else {
aboxOntology = getOWLOntologyManager().createOntology();
}
}
if (LOG.isDebugEnabled()) {
LOG.debug(modelId+" manager(T) = "+tboxOntology.getOWLOntologyManager());
LOG.debug(modelId+" manager(A) = "+aboxOntology.getOWLOntologyManager());
LOG.debug(modelId+" id(T) = "+tboxOntology.getOntologyID());
LOG.debug(modelId+" id(A) = "+aboxOntology.getOntologyID());
}
}
开发者ID:geneontology,项目名称:minerva,代码行数:33,代码来源:ModelContainer.java
示例5: testAnnotations
import org.semanticweb.owlapi.model.AddImport; //导入依赖的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.AddImport; //导入依赖的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: addImport
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
@Deprecated
public void addImport(String importedIRIString) {
OWLImportsDeclaration iax = dataFactory.getOWLImportsDeclaration(IRI.create(importedIRIString));
//AddImport addAx = new AddImport(ontology, iax);
AddImport addAx = new AddImport(getOntology(), iax);
manager.applyChange(addAx);
}
开发者ID:owlcollab,项目名称:owltools,代码行数:8,代码来源:Mooncat.java
示例8: addImport
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
/**
* adds an imports declaration between the source ontology and extOnt
*
* @param extOnt
*/
public void addImport(OWLOntology extOnt) {
Optional<IRI> ontologyIRI = extOnt.getOntologyID().getOntologyIRI();
if (ontologyIRI.isPresent()) {
AddImport ai = new AddImport(getSourceOntology(), getDataFactory().getOWLImportsDeclaration(ontologyIRI.get()));
getManager().applyChange(ai);
}
else {
throw new RuntimeException("Could not add ontology as import, missing ontology ID: "+extOnt);
}
}
开发者ID:owlcollab,项目名称:owltools,代码行数:16,代码来源:OWLGraphWrapperBasic.java
示例9: mergeOntology
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
public void mergeOntology(OWLOntology extOnt, LabelPolicy labelPolicy) throws OWLOntologyCreationException {
OWLOntologyManager manager = getManager();
LOG.info("Merging "+extOnt+" policy: "+labelPolicy);
for (OWLAxiom axiom : extOnt.getAxioms()) {
if (labelPolicy != LabelPolicy.ALLOW_DUPLICATES) {
if (axiom instanceof OWLAnnotationAssertionAxiom) {
OWLAnnotationAssertionAxiom aa = (OWLAnnotationAssertionAxiom)axiom;
if (aa.getProperty().isLabel()) {
OWLAnnotationSubject subj = aa.getSubject();
if (subj instanceof IRI) {
Optional<OWLLiteral> label = null;
for (OWLAnnotationAssertionAxiom a1 : sourceOntology.getAnnotationAssertionAxioms(subj)) {
if (a1.getProperty().isLabel()) {
label = a1.getValue().asLiteral();
}
}
if (label != null && label.isPresent()) {
if (labelPolicy == LabelPolicy.PRESERVE_SOURCE) {
LOG.info("Preserving existing label:" +subj+" "+label+" // ditching: "+axiom);
continue;
}
if (labelPolicy == LabelPolicy.PRESERVE_EXT) {
LOG.info("Replacing:" +subj+" "+label+" with: "+axiom);
LOG.error("NOT IMPLEMENTED");
}
}
}
}
}
}
manager.applyChange(new AddAxiom(sourceOntology, axiom));
}
for (OWLImportsDeclaration oid: extOnt.getImportsDeclarations()) {
manager.applyChange(new AddImport(sourceOntology, oid));
}
addCommentToOntology(sourceOntology, "Includes "+summarizeOntology(extOnt));
}
开发者ID:owlcollab,项目名称:owltools,代码行数:38,代码来源:OWLGraphWrapperBasic.java
示例10: convertOntology
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
public OWLOntology convertOntology(Map<Object,Object> m) throws OWLOntologyCreationException {
Set<OWLAxiom> axioms = null;
IRI ontologyIRI = null;
List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
List<IRI> importsIRIs = new ArrayList<IRI>();
for (Object k : m.keySet()) {
if (k.equals("axioms")) {
axioms = convertAxioms((Object[]) m.get(k));
}
else if (k.equals("iri")) {
ontologyIRI = IRI.create((String) m.get(k));
}
else if (k.equals("annotations")) {
// TODO
}
else if (k.equals("imports")) {
IRI importIRI = IRI.create((String) m.get(k));
importsIRIs.add(importIRI);
}
}
OWLOntology ont = manager.createOntology(ontologyIRI);
for (IRI importsIRI : importsIRIs) {
AddImport ai = new AddImport(ont, manager.getOWLDataFactory().getOWLImportsDeclaration(importsIRI));
changes.add(ai);
}
manager.applyChanges(changes);
return ont;
}
开发者ID:owlcollab,项目名称:owltools,代码行数:30,代码来源:OWLGsonParser.java
示例11: test
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
@Test
public void test() throws Exception {
// load the base ontology
ParserWrapper pw = new ParserWrapper();
OWLOntology direct = pw.parseOBO(getResourceIRIString("graph/xref_test.obo"));
OWLGraphWrapper directGraph = new OWLGraphWrapper(direct);
// check that the test class has the expected number of xrefs
OWLClass c = directGraph.getOWLClassByIdentifier("FOO:0001");
List<String> directDefXrefs = directGraph.getDefXref(c);
assertEquals(2, directDefXrefs.size());
List<String> directXrefs = directGraph.getXref(c);
assertEquals(2, directXrefs.size());
// create an ontology using an import
OWLOntologyManager manager = pw.getManager();
OWLDataFactory factory = manager.getOWLDataFactory();
OWLOntology importer = manager.createOntology();
OWLImportsDeclaration importDeclaration = factory.getOWLImportsDeclaration(direct.getOntologyID().getOntologyIRI().orNull());
manager.applyChange(new AddImport(importer, importDeclaration));
OWLGraphWrapper importerGraph = new OWLGraphWrapper(importer);
// check that the wrapper uses also imports for lookups of xrefs
List<String> importedDefXrefs = importerGraph.getDefXref(c);
assertEquals(2, importedDefXrefs.size());
List<String> importedXrefs = importerGraph.getXref(c);
assertEquals(2, importedXrefs.size());
}
开发者ID:owlcollab,项目名称:owltools,代码行数:34,代码来源:ImportedXrefTest.java
示例12: getMergedOntology
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
public OWLOntology getMergedOntology() {
final IRI mergedOntologyIRI = IRI.create(queryOntology.getOntologyID()
.getDefaultDocumentIRI() + "-merged");
final OWLOntologyManager mm = controller.getOWLOntologyManager();
if (mm.contains(mergedOntologyIRI)) {
return mm.getOntology(mergedOntologyIRI);
} else {
try {
final OWLOntology mergedOntology = mm
.createOntology(mergedOntologyIRI);
mm.setOntologyFormat(mergedOntology, new RDFXMLOntologyFormat());
final String mergedOntologyFileName = mergedOntologyIRI
.toURI()
.toString()
.substring(
mergedOntologyIRI.toURI().toString()
.lastIndexOf("/") + 1)
+ ".owl";
mm.setOntologyDocumentIRI(
mergedOntology,
IRI.create(controller.getRuleSpec().getOutputDir()
.toURI()
+ "/" + mergedOntologyFileName));
mm.applyChange(new AddImport(mergedOntology, mm
.getOWLDataFactory().getOWLImportsDeclaration(
queryOntology.getOntologyID()
.getDefaultDocumentIRI())));
return mergedOntology;
} catch (OWLOntologyCreationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
}
开发者ID:psiotwo,项目名称:sdlnot-rules,代码行数:36,代码来源:SparqlDLNotRulesEngine.java
示例13: updateOntology
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
@Override
public void updateOntology( OWLOntology generatedOntology,
IRI generatedOntologyIRI,
IRI previousOntologyIRI,
URI physicalURI) {
final OWLModelManager mm = getOWLModelManager();
IRI iri = generatedOntologyIRI;
OWLOntology generatedOntologyToDelete = null;
final List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
final Collection<OWLOntology> ontologies = mm.getOntologies();
for (OWLOntology oo : ontologies) {
if (iri.equals(oo.getOntologyID().getOntologyIRI())) {
log.info("Removing ontology " + iri);
generatedOntologyToDelete = oo;
}
changes.add(new RemoveImport(oo, getOWLOntologyManager().getOWLDataFactory()
.getOWLImportsDeclaration(iri)));
}
mm.applyChanges(changes);
changes.clear();
if (generatedOntologyToDelete != null) {
if ( !mm.removeOntology(generatedOntologyToDelete) ) {
log.info("Removing ontology " + generatedOntologyToDelete.getOntologyID() + " NOT succesful.");
}
}
changes.add(new SetOntologyID(generatedOntology, iri));
changes.add(new AddImport(generatedOntology, mm.getOWLDataFactory()
.getOWLImportsDeclaration(previousOntologyIRI)));
mm.applyChanges(changes);
mm.setPhysicalURI(generatedOntology, physicalURI);
}
开发者ID:psiotwo,项目名称:sdlnot-rules,代码行数:34,代码来源:SparqlDLNotRulesController.java
示例14: updateOntology
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
@Override
public void updateOntology(
OWLOntology generatedOntology, IRI generatedOntologyIRI, IRI previousOntologyIRI,
URI physicalURI) {
IRI iri = generatedOntologyIRI;
OWLOntology generatedOntologyToDelete = null;
final List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
final Collection<OWLOntology> ontologies = m.getOntologies();
for (OWLOntology oo : ontologies) {
if (iri.equals(oo.getOntologyID().getOntologyIRI())) {
log.info("Removing ontology " + iri);
generatedOntologyToDelete = oo;
}
changes.add(new RemoveImport(oo, getOWLOntologyManager()
.getOWLDataFactory().getOWLImportsDeclaration(iri)));
}
m.applyChanges(changes);
changes.clear();
if (generatedOntologyToDelete != null) {
m.removeOntology(generatedOntologyToDelete);
}
changes.add(new SetOntologyID(generatedOntology, iri));
changes.add(new AddImport(generatedOntology, m.getOWLDataFactory()
.getOWLImportsDeclaration(previousOntologyIRI)));
m.applyChanges(changes);
m.setOntologyDocumentIRI(generatedOntology, IRI.create(physicalURI));
try {
m.saveOntology(generatedOntology);
} catch (OWLOntologyStorageException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
开发者ID:psiotwo,项目名称:sdlnot-rules,代码行数:37,代码来源:SparqlDLNotRulesCLIController.java
示例15: visit
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
public OWLOntologyChange visit(AddImport addImport) {
return new RemoveImport(addImport.getOntology(), addImport.getImportDeclaration());
}
开发者ID:geneontology,项目名称:minerva,代码行数:4,代码来源:ReverseChangeGenerator.java
示例16: testUpdateImports
import org.semanticweb.owlapi.model.AddImport; //导入依赖的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
示例17: visit
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
@Override
public void visit(AddImport change) {
defaultVisit(change);
}
开发者ID:liveontologies,项目名称:elk-reasoner,代码行数:5,代码来源:OwlOntologyChangeProcessorVisitor.java
示例18: visit
import org.semanticweb.owlapi.model.AddImport; //导入依赖的package包/类
@Override
public Boolean visit(AddImport change) {
Objects.requireNonNull(change);
return false;
}
开发者ID:julianmendez,项目名称:jcel,代码行数:6,代码来源:JcelOntologyChangeVisitorEx.java
注:本文中的org.semanticweb.owlapi.model.AddImport类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论