Package org.semanticweb.owlapi.model

Examples of org.semanticweb.owlapi.model.AddImport


        // for creating an new import statement.
        if (!oChild.isAnonymous() && rewritePrefix != null
        /* && rewritePrefix.isAbsolute() */) {
            IRI impIri = IRI.create(rewritePrefix + "/" + oChild.getOntologyID().getOntologyIRI());
            OWLImportsDeclaration imp = factory.getOWLImportsDeclaration(impIri);
            ontologyManager.applyChange(new AddImport(oParent, imp));
        }
        // Anonymous, with physicalIRI. A plain import statement is added.
        else if (childSrc.hasPhysicalIRI()) {
            OWLImportsDeclaration imp = factory.getOWLImportsDeclaration(childSrc.getPhysicalIRI());
            ontologyManager.applyChange(new AddImport(oParent, imp));
        }

        // Anonymous and no physical IRI (e.g. in memory). Copy all axioms and
        // import statements.
        else {
            ontologyManager.addAxioms(oParent, oChild.getAxioms());
            for (OWLImportsDeclaration imp : oChild.getImportsDeclarations())
                ontologyManager.applyChange(new AddImport(oParent, factory.getOWLImportsDeclaration(imp
                        .getIRI())));
        }
        return oParent;
    }
View Full Code Here


                if (o.isAnonymous() && importIri == null) {
                    logger.warn("KReS :: [NONFATAL] Anonymous import target "
                                + o.getOntologyID()
                                + " not mapped to physical IRI. Will add extracted axioms to parent ontology.");
                    for (OWLImportsDeclaration im : o.getImportsDeclarations())
                        changes.add(new AddImport(parent, im));
                    for (OWLAxiom im : o.getAxioms())
                        changes.add(new AddAxiom(parent, im));
                } else if (importIri != null) {
                    // An anonymous ontology can still be imported if it has a
                    // valid document IRI.
                    changes.add(new AddImport(parent, owlFactory.getOWLImportsDeclaration(importIri)));
                }
            }

        } // End subtrees cycle.
View Full Code Here

        List<OWLOntologyChange> additions = new LinkedList<OWLOntologyChange>();
        OWLDataFactory auxfactory = inowl.getOWLOntologyManager().getOWLDataFactory();

        while(importedonto.hasNext()){
            OWLOntology auxonto = importedonto.next();
            additions.add(new AddImport(toadd,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
        }

        if(additions.size()==0){
            Iterator<OWLImportsDeclaration> importedontob = inowl.getImportsDeclarations().iterator();
            additions = new LinkedList<OWLOntologyChange>();
            auxfactory = inowl.getOWLOntologyManager().getOWLDataFactory();

            while(importedontob.hasNext()){
                OWLImportsDeclaration  auxontob = importedontob.next();
                additions.add(new AddImport(toadd,auxontob));
            }
        }

        return additions;
    }
View Full Code Here

                    ontologyIri = o.getOntologyID().getDefaultDocumentIRI();
                }

                IRI physIRI = IRI.create(base + ontologyIri);

                changes.add(new AddImport(root, df.getOWLImportsDeclaration(physIRI)));
            }
            ontologyManager.applyChanges(changes);
        }
        // return rootOntology;
        return root;
View Full Code Here

                    List<OWLOntologyChange> additions = new LinkedList<OWLOntologyChange>();
                    OWLDataFactory auxfactory = onto.getOWLOntologyManager().getOWLDataFactory();

                    while (importedonto.hasNext()) {
                        OWLOntology auxonto = importedonto.next();
                        additions.add(new AddImport(newmodel, auxfactory.getOWLImportsDeclaration(auxonto
                                .getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
                    }

                    if (!additions.isEmpty()) newmodel.getOWLOntologyManager().applyChanges(additions);

                    while (keys.hasNext()) {
                        OWLNamedIndividual ind = factory.getOWLNamedIndividual(keys.next());
                        Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
                        newmodel.getOWLOntologyManager().addAxioms(newmodel, ax);
                    }

                    // try {
                    // OWLManager.createOWLOntologyManager().saveOntology(
                    // newmodel,
                    // newmodel.getOWLOntologyManager()
                    // .getOntologyFormat(newmodel),
                    // System.out);
                    // } catch (OWLOntologyStorageException e) {
                    // // TODO Auto-generated catch block
                    // e.printStackTrace();
                    // }

                    ResponseBuilder rb = Response.ok(newmodel);
                    MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null);
                    if (mediaType != null) rb.header(HttpHeaders.CONTENT_TYPE, mediaType);
                    addCORSOrigin(servletContext, rb, headers);
                    return rb.build();
                }

            } else {

                HashMap<IRI,String> rule = recipe.getRule(IRI.create(uri));

                if (rule == null) {
                    ResponseBuilder rb = Response.status(Status.NOT_FOUND);
                    MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null);
                    if (mediaType != null) rb.header(HttpHeaders.CONTENT_TYPE, mediaType);
                    addCORSOrigin(servletContext, rb, headers);
                    return rb.build();
                } else {
                    OWLOntology onto = ruleStore.getOntology();

                    OWLDataFactory factory = onto.getOWLOntologyManager().getOWLDataFactory();
                    OWLNamedIndividual ind = factory.getOWLNamedIndividual(IRI.create(uri));
                    Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
                    OWLOntology newmodel = OWLManager.createOWLOntologyManager().createOntology(
                        onto.getOntologyID());

                    Iterator<OWLOntology> importedonto = onto.getDirectImports().iterator();
                    List<OWLOntologyChange> additions = new LinkedList<OWLOntologyChange>();
                    OWLDataFactory auxfactory = onto.getOWLOntologyManager().getOWLDataFactory();

                    while (importedonto.hasNext()) {
                        OWLOntology auxonto = importedonto.next();
                        additions.add(new AddImport(newmodel, auxfactory.getOWLImportsDeclaration(auxonto
                                .getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
                    }

                    if (!additions.isEmpty()) newmodel.getOWLOntologyManager().applyChanges(additions);
View Full Code Here

                base += "/";

                // The key set of managedOntologies contains the ontology IRIs, not their storage keys.
                for (IRI ontologyIri : managedOntologies) {
                    IRI physIRI = IRI.create(base + ontologyIri);
                    changes.add(new AddImport(root, df.getOWLImportsDeclaration(physIRI)));
                }

                ontologyManager.applyChanges(changes);
            }
View Full Code Here

                String tid = getID();
                if (backwardPathLength > 0) tid = tid.split("/")[0];

                IRI target = IRI.create((managed ? ns + "/" + tid + "/" : URIUtils.upOne(ns) + "/") + s);
                changes.add(new AddImport(o, df.getOWLImportsDeclaration(target)));
            }
            o.getOWLOntologyManager().applyChanges(changes);
        }

        return o;
View Full Code Here

        List<OWLOntologyChange> additions = new LinkedList<OWLOntologyChange>();
        OWLDataFactory auxfactory = inowl.getOWLOntologyManager().getOWLDataFactory();

        while(importedonto.hasNext()){
            OWLOntology auxonto = importedonto.next();
            additions.add(new AddImport(toadd,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
        }

        if(additions.size()==0){
            Iterator<OWLImportsDeclaration> importedontob = inowl.getImportsDeclarations().iterator();
            additions = new LinkedList<OWLOntologyChange>();
            auxfactory = inowl.getOWLOntologyManager().getOWLDataFactory();

            while(importedontob.hasNext()){
                OWLImportsDeclaration  auxontob = importedontob.next();
                additions.add(new AddImport(toadd,auxontob));
            }
        }

        return additions;
    }
View Full Code Here

        List<OWLOntologyChange> additions = new LinkedList<OWLOntologyChange>();
        OWLDataFactory auxfactory = inowl.getOWLOntologyManager().getOWLDataFactory();
   
        while(importedonto.hasNext()){
            OWLOntology auxonto = importedonto.next();
            additions.add(new AddImport(toadd,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
        }
   
        if(additions.size()==0){
            Iterator<OWLImportsDeclaration> importedontob = inowl.getImportsDeclarations().iterator();
            additions = new LinkedList<OWLOntologyChange>();
            auxfactory = inowl.getOWLOntologyManager().getOWLDataFactory();
     
            while(importedontob.hasNext()){
                OWLImportsDeclaration  auxontob = importedontob.next();
                additions.add(new AddImport(toadd,auxontob));
            }
        }
   
        return additions;
    }
View Full Code Here

                    List<OWLOntologyChange> additions = new LinkedList<OWLOntologyChange>();
                    OWLDataFactory auxfactory = onto.getOWLOntologyManager().getOWLDataFactory();

                    while (importedonto.hasNext()) {
                        OWLOntology auxonto = importedonto.next();
                        additions.add(new AddImport(newmodel, auxfactory.getOWLImportsDeclaration(auxonto
                                .getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
                    }

                    if (!additions.isEmpty()) newmodel.getOWLOntologyManager().applyChanges(additions);

                    for (int i = 0; i < recipe.size(); i++) {
                        OWLNamedIndividual ind = factory.getOWLNamedIndividual(recipe.get(i));
                        Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
                        newmodel.getOWLOntologyManager().addAxioms(newmodel, ax);

                    }

                    // try {
                    // OWLManager.createOWLOntologyManager().saveOntology(
                    // newmodel,
                    // newmodel.getOWLOntologyManager()
                    // .getOntologyFormat(newmodel),
                    // System.out);
                    // } catch (OWLOntologyStorageException e) {
                    // // TODO Auto-generated catch block
                    // e.printStackTrace();
                    // }
                    ResponseBuilder rb = Response.ok(newmodel);
                    MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null);
                    if (mediaType != null) rb.header(HttpHeaders.CONTENT_TYPE, mediaType);
                    addCORSOrigin(servletContext, rb, headers);
                    return rb.build();
                }

            } else {

                HashMap<IRI,String> recipe = rule.getRecipe(IRI.create(uri));

                if (recipe == null) {
                    // The recipe deos not exists in the manager
                    ResponseBuilder rb = Response.status(Status.NOT_FOUND);
                    MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null);
                    if (mediaType != null) rb.header(HttpHeaders.CONTENT_TYPE, mediaType);
                    addCORSOrigin(servletContext, rb, headers);
                    return rb.build();
                } else {
                    // The recipe is retrieved (import declarations point to
                    // KReS Services)
                    OWLOntology onto = ruleStore.getOntology();

                    OWLDataFactory factory = onto.getOWLOntologyManager().getOWLDataFactory();
                    OWLObjectProperty prop = factory.getOWLObjectProperty(IRI
                            .create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"));
                    OWLNamedIndividual ind = factory.getOWLNamedIndividual(IRI.create(uri));
                    Set<OWLIndividual> value = ind.getObjectPropertyValues(prop, onto);
                    Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);

                    Iterator<OWLIndividual> iter = value.iterator();

                    OWLOntology newmodel = OWLManager.createOWLOntologyManager().createOntology(
                        onto.getOntologyID());

                    Iterator<OWLOntology> importedonto = onto.getDirectImports().iterator();
                    List<OWLOntologyChange> additions = new LinkedList<OWLOntologyChange>();
                    OWLDataFactory auxfactory = onto.getOWLOntologyManager().getOWLDataFactory();

                    while (importedonto.hasNext()) {
                        OWLOntology auxonto = importedonto.next();
                        additions.add(new AddImport(newmodel, auxfactory.getOWLImportsDeclaration(auxonto
                                .getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
                    }

                    if (!additions.isEmpty()) newmodel.getOWLOntologyManager().applyChanges(additions);
View Full Code Here

TOP

Related Classes of org.semanticweb.owlapi.model.AddImport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.