[kepler-dev] ontology with imported ontologies bug

Matt Jones jones at nceas.ucsb.edu
Fri Jul 9 17:04:37 PDT 2010


Thanks, Chris.  Being able to import ontologies that import others is
clearly important, so we'll work to incorporate your patches into the Kepler
tree when you send them.  We should also look into giving you write access
to svn so that you can help maintain these things directly if you are
interested.

Matt

On Fri, Jul 9, 2010 at 3:01 PM, Chris Weed <chrisweed at gmail.com> wrote:

> I applied these patches to Kepler 2.0, and it still isn't loading
> correctly, I think there is probably at least one more change that
> needs to be made in OntologyCatalog to load all of the classes
> correctly. I'll probably take a crack at that on monday.
> Chris
>
> On Fri, Jul 9, 2010 at 2:52 PM, Chris Weed <chrisweed at gmail.com> wrote:
> > Kepler 2.0 does not seem to correctly deal with ontologies that import
> > concepts from other ontologies.
> >
> > I was looking through my changes to NamedOntModel from Kepler 1.X Dev,
> > and it looks like I added a method called
> > getNameSpaces() that returns a list of the namespaces from all ontologies
> >
> > public List<String> getNameSpaces() {
> >                List<String> result = new ArrayList<String>();
> >                for(Iterator<Ontology> iter =
> _ontModel.listOntologies();iter.hasNext();)
> >                {
> >                        result.add(iter.next().getNameSpace());
> >                }
> >                return result;
> >        }
> >
> > Then I changed OntologyCatalog's methods getNamedOntClass:
> >
> >
> >        public NamedOntClass getNamedOntClass(SemanticType st) {
> >                String conceptId = st.getConceptId();
> >                String[] parts = conceptId.split("#");
> >                // make sure we have a valid semantic type
> >                if (parts.length != 2) {
> >                        return null;
> >                }
> >                // search for a matching model and class
> >                for (Iterator iter = getNamedOntModels(); iter.hasNext();)
> {
> >                        NamedOntModel m = (NamedOntModel) iter.next();
> >                        //if (m.getNameSpace().equals(parts[0])) {
> >                        //if (m.getNameSpaces().contains(parts[0])) {
> >                        if (startsWith(m.getNameSpaces(),parts[0])) {
> >                                for (Iterator iter2 =
> m.getNamedClasses(false); iter2.hasNext();) {
> >                                        NamedOntClass c = (NamedOntClass)
> iter2.next();
> >                                        if
> (c.getLocalName().equals(parts[1])) {
> >                                                return c;
> >                                        }
> >                                }
> >                        }
> >                }
> >                return null;
> >        }
> >
> >        boolean startsWith(List<String> l,String s)
> >        {
> >                for(Iterator<String> iter = l.iterator();iter.hasNext();)
> >                        if(s.startsWith(iter.next()))
> >                                return true;
> >                return false;
> >        }
> >
> >
> >        public NamedOntClass getNamedOntClass(String namespace, String
> localName) {
> >                if (namespace == null || localName == null) {
> >                        return null;
> >                }
> >                // search for a matching model and class
> >                for (Iterator iter = getNamedOntModels(); iter.hasNext();)
> {
> >                        NamedOntModel m = (NamedOntModel) iter.next();
> >                        String m_nspace = m.getNameSpace() + "#";
> >                        //if (m.getNameSpace().equals(namespace)
> >                        //              || m_nspace.equals(namespace)) {
> >                        if (m.getNameSpaces().contains(namespace)
> >                                        || m_nspace.equals(namespace)) {
> >                                for (Iterator<NamedOntClass> iter2 =
> m.getNamedClasses(false); iter2
> >                                                .hasNext();) {
> >                                        NamedOntClass c = (NamedOntClass)
> iter2.next();
> >                                        if
> (c.getLocalName().equals(localName)) {
> >                                                return c;
> >                                        }
> >                                }
> >                        }
> >                }
> >                return null;
> >        }
> >
> > I am not sure if this is a solution you want to use.
> >
> > FYI
> > Chris
> >
> _______________________________________________
> Kepler-dev mailing list
> Kepler-dev at kepler-project.org
> http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercury.nceas.ucsb.edu/kepler/pipermail/kepler-dev/attachments/20100709/44aa3fe4/attachment.html>


More information about the Kepler-dev mailing list