Good afternoon,
I am working in an application where I have to get all information from a 
ontology, classes, properties, individuals, relations like an ontology editor. 
This ontology could be formed for a lot of ontologies too and I need to have 
these information too to make operations like an ontology editor as Neon 
Toolkit or Protégé.

Firstly I read the  original model and then import the rest of ontologies into 
the initial model , taking all the prefixes from the ontology and trying to get 
using URI the corresponding ontology to get the model.
This is my code. I get it, I obtain all the classes, properties, individuals 
from all ontologies  but when I translate the model to an owl file I can't open 
this with an ontology editor (Neon...)
Someone has any idea?


Thanks


   model.read(in, "http://www.w3.org/1999/02/22-rdf-syntax-ns#";);
   DbImportTest db=new DbImportTest();
   OntModel om = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM,model);
  db.loadImportingOntology(model,om);


public void loadImportingOntology(Model model, OntModel om) {


        OntModelSpec oms = getMaker();
        DbAwareDocumentManager db=new DbAwareDocumentManager( m_maker ) ;
        oms.setDocumentManager( db);



        Map <String,String> mapPrefix= model.getNsPrefixMap();
        Model aux =null;
        for (Map.Entry<String, String> entry : mapPrefix.entrySet())
        {
            System.out.println(entry.getKey() + "/" + entry.getValue());
            String prefix=entry.getKey();
            if (prefix.equals("")==false){
              String ontologyUri=entry.getValue();
              boolean bExist=checkPrefix(prefix);  -> I don't insert prefixes 
like  "xsd", "protege", "owl", "rdf", "rdfs","owl2xml".
              if (bExist==false){
                System.out.println("Ontología a importart:"+ontologyUri);
                try{

                     aux = db.fetchPossiblyCachedImportModel( om, ontologyUri);
                     model.add(aux);
                  }
                  catch (Exception e){
                    System.out.println("Error");
                  }
              }
             }

         }

    }

   protected Model fetchPossiblyCachedImportModel( OntModel om, String 
importURI ) {



      Model in = getModel( importURI );

        // if not cached, we must load it from source
        if (in == null) {
            in = fetchLoadedImportModel( om.getSpecification(), importURI );
        }
        return in;
    }



    protected Model fetchLoadedImportModel( OntModelSpec spec, String importURI 
) {
        ModelMaker maker = spec.getImportModelMaker();
        if (maker.hasModel( importURI )) {
            Model m = maker.getModel( importURI );
            if (!m.isClosed()) {
                return m;
            }
            else {
                // we don't want to hang on to closed models
                maker.removeModel( importURI );
            }
        }

        // otherwise, we use the model maker to get the model anew
        Model m = spec.getImportModelGetter().getModel( importURI, new 
ModelReader() {
            public Model readModel( Model toRead, String URL ) {
                read( toRead, URL, true );
                return toRead;
            }
        } );

        return m;
    }


Urtza Iturraspe Barturen
Investigador / Researcher

OPTIMA - Optimization Modelling & Analytics Area

ICT - European Software Institute Division

TECNALIA
Parque Tecnológico de Bizkaia, Edificio 202
E-48170 Zamudio (Spain)
mov.: 664 00 21 51
tel.: 902 760 002  /  946 430 850 (International calls)
[email protected]<mailto:[email protected]>
www.tecnalia.com<http://www.tecnalia.com/>

[faldon_mail]

**************** AVISO LEGAL  **************** DISCLAIMER ****************
Este mensaje es personal y confidencial y su uso no autorizado está prohibido 
legalmente. Si usted no es el destinatario, proceda a borrarlo, sin reenviarlo 
ni conservarlo.
This message is personal and confidential, unauthorised use is legally 
prohibited. If you are not the intended recipient, delete it without resending 
or backing it.

Reply via email to