Java 类org.semanticweb.owlapi.model.SetOntologyID 实例源码

项目:owltools    文件:OboOntologyReleaseRunner.java   
private String handleVersion(String ontologyId) {
    // TODO add an option to set/overwrite the version manually via command-line
    // TODO re-use/create a method in obo2owl for creating an version IRI
    String version;
    OWLOntology ontology = mooncat.getOntology();
    OWLOntologyID owlOntologyId = ontology.getOntologyID();
    Optional<IRI> versionIRI = owlOntologyId.getVersionIRI();
    if (versionIRI.isPresent() == false) {
        // set a new version IRI using the current date
        version = OntologyVersionTools.format(new Date());
        versionIRI = Optional.of(IRI.create(Obo2OWLConstants.DEFAULT_IRI_PREFIX+ontologyId+"/"+oortConfig.getVersionSubdirectory()+"/"+version+"/"+ontologyId+".owl"));

        OWLOntologyManager m = mooncat.getManager();
        m.applyChange(new SetOntologyID(ontology, new OWLOntologyID(owlOntologyId.getOntologyIRI(), versionIRI)));
    }
    else {
        String versionIRIString = versionIRI.get().toString();
        version = OntologyVersionTools.parseVersion(versionIRIString);
        if (version == null) {
            // use the whole IRI? escape?
            logError("Could not parse a version from ontolgy version IRI: "+versionIRIString);
            version = versionIRIString;
        }
    }
    return version;
}
项目:minerva    文件:CoreMolecularModelManager.java   
/**
 * Export the ABox, will try to set the ontologyID to the given modelId (to
 * ensure import assumptions are met)
 * 
 * @param model
 * @param ontologyFormat
 * @return modelContent
 * @throws OWLOntologyStorageException
 */
public String exportModel(ModelContainer model, OWLDocumentFormat ontologyFormat) throws OWLOntologyStorageException {
    final OWLOntology aBox = model.getAboxOntology();
    final OWLOntologyManager manager = aBox.getOWLOntologyManager();

    // make sure the exported ontology has an ontologyId and that it maps to the modelId
    final IRI expectedABoxIRI = model.getModelId();
    Optional<IRI> currentABoxIRI = aBox.getOntologyID().getOntologyIRI();
    if (currentABoxIRI.isPresent() == false) {
        manager.applyChange(new SetOntologyID(aBox, expectedABoxIRI));
    }
    else {
        if (expectedABoxIRI.equals(currentABoxIRI) == false) {
            OWLOntologyID ontologyID = new OWLOntologyID(Optional.of(expectedABoxIRI), Optional.of(expectedABoxIRI));
            manager.applyChange(new SetOntologyID(aBox, ontologyID));
        }
    }

    // write the model into a buffer
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    if (ontologyFormat != null) {
        manager.saveOntology(aBox, ontologyFormat, outputStream);
    }
    else {
        manager.saveOntology(aBox, outputStream);
    }

    // extract the string from the buffer
    String modelString = outputStream.toString();
    return modelString;
}
项目:sdlnot-rules    文件:SparqlDLNotRulesController.java   
@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);      
}
项目:sdlnot-rules    文件:SparqlDLNotRulesCLIController.java   
@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();
    }
}
项目:minerva    文件:ReverseChangeGenerator.java   
public OWLOntologyChange visit(SetOntologyID change) {
    return new SetOntologyID(change.getOntology(), change.getOriginalOntologyID());
}
项目:elk-reasoner    文件:OwlOntologyChangeProcessorVisitor.java   
@Override
public void visit(SetOntologyID change) {
    defaultVisit(change);
}
项目:owltools    文件:CommandRunner.java   
private void catOntologies(Opts opts) throws OWLOntologyCreationException, IOException {
     opts.info("[-r|--ref-ont ONT] [-i|--use-imports]", "Catenate ontologies taking only referenced subsets of supporting onts.\n"+
             "        See Mooncat docs");
     Mooncat m = new Mooncat(g);
     ParserWrapper pw = new ParserWrapper();
     String newURI = null;
     while (opts.hasOpts()) {
         //String opt = opts.nextOpt();
         if (opts.nextEq("-r") || opts.nextEq("--ref-ont")) {
             LOG.error("DEPRECATED - list all ref ontologies on main command line");
             String f = opts.nextOpt();
             m.addReferencedOntology(pw.parseOWL(f));
         }
         else if (opts.nextEq("-s") || opts.nextEq("--src-ont")) {
             m.setOntology(pw.parseOWL(opts.nextOpt()));
         }
         else if (opts.nextEq("-p") || opts.nextEq("--prefix")) {
             m.addSourceOntologyPrefix(opts.nextOpt());
         }
         else if (opts.nextEq("-i") || opts.nextEq("--use-imports")) {
             System.out.println("using everything in imports closure");
             g.addSupportOntologiesFromImportsClosure();
         }
         else if (opts.nextEq("-n") || opts.nextEq("--new-uri")) {
             System.out.println("new URI for merged ontology");
             newURI = opts.nextOpt();
         }
         else {
             break;
             //opts.fail();
         }
     }
     //if (m.getReferencedOntologies().size() == 0) {
     // m.setReferencedOntologies(g.getSupportOntologySet());
     //}
     //g.useImportClosureForQueries();
     //for (OWLAxiom ax : m.getClosureAxiomsOfExternalReferencedEntities()) {
     // System.out.println("M_AX:"+ax);
     //}

     m.mergeOntologies();
     m.removeDanglingAxioms();
     if (newURI != null) {
         SetOntologyID soi = new SetOntologyID(g.getSourceOntology(),
                 new OWLOntologyID(Optional.of(IRI.create(newURI)), Optional.<IRI>absent()));
         g.getManager().applyChange(soi);
         /*
HashSet<OWLOntology> cpOnts = new HashSet<OWLOntology>();
LOG.info("srcOnt annots:"+g.getSourceOntology().getAnnotations().size());
cpOnts.add(g.getSourceOntology());
OWLOntology newOnt = g.getManager().createOntology(IRI.create(newURI), cpOnts);
LOG.info("newOnt annots:"+newOnt.getAnnotations().size());

//g.getDataFactory().getOWLOn
g.setSourceOntology(newOnt);
          */
     }
 }
项目:jcel    文件:JcelOntologyChangeVisitorEx.java   
@Override
public Boolean visit(SetOntologyID change) {
    Objects.requireNonNull(change);
    return false;
}