[kepler-dev] ontology with imported ontologies bug

Chris Weed chrisweed at gmail.com
Fri Jul 9 16:01:43 PDT 2010


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
>


More information about the Kepler-dev mailing list