casting a DefaultKnowledgeBase into an OWLModel

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

casting a DefaultKnowledgeBase into an OWLModel

Gandalf-6
Hello,


Casting a DefaultKnowledgeBase into an OWLModel as in the following code
generates a ClassCastException :

public static void main(String[] args) {

Project p = Project.loadProjectFromFile(args[0], new ArrayList());
System.out.println(p.getKnowledgeBase().getClass());
System.out.println(p.getKnowledgeBase().getKnowledgeBaseFactory().getClass());
OWLModel m = (OWLModel)p.getKnowledgeBase();

}

The output of this code sample is :

INFO: No log configuration file available
INFO: Created connection for null
CONFIG: Table myDBProject_INCLUDES already exists
class edu.stanford.smi.protege.model.DefaultKnowledgeBase
class edu.stanford.smi.protege.storage.database.DatabaseKnowledgeBaseFactory
Exception in thread "main" java.lang.ClassCastException:
edu.stanford.smi.protege.model.DefaultKnowledgeBase
        at edu.uncc.geopolis.examples.DBConTest.main(DBConTest.java:18)


In args[0] I pass a Protégé Database .pprj file name. Interestingly
enough, the KB factory is an instance of DatabaseKnowledgeBaseFactory
and one can expect the p.getKnowledgeBase() to return an instance of
OWLDatabseModel that would be cast to OWLModel without any problems.

What am I getting wrong ? Thanks beforehand.

Regards,

GLG

P.S. : I am compiling this code against a recent protege-owl source
code. The .pprj file was generated by Protégé version 3.1.1 Build 216.

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: casting a DefaultKnowledgeBase into an OWLModel

Olivier Dameron
On Wed, 03 May 2006 18:02:12 -0400, Gandalf <[hidden email]> wrote:

> Casting a DefaultKnowledgeBase into an OWLModel as in the following code
> generates a ClassCastException :
>
> public static void main(String[] args) {
>
> Project p = Project.loadProjectFromFile(args[0], new ArrayList());
> System.out.println(p.getKnowledgeBase().getClass());
> System.out.println(p.getKnowledgeBase().getKnowledgeBaseFactory().getClass());
> OWLModel m = (OWLModel)p.getKnowledgeBase();
> }
>
> The output of this code sample is :
>
> INFO: No log configuration file available
> INFO: Created connection for null
> CONFIG: Table myDBProject_INCLUDES already exists
> class edu.stanford.smi.protege.model.DefaultKnowledgeBase
> class edu.stanford.smi.protege.storage.database.DatabaseKnowledgeBaseFactory
> Exception in thread "main" java.lang.ClassCastException:
> edu.stanford.smi.protege.model.DefaultKnowledgeBase
> at edu.uncc.geopolis.examples.DBConTest.main(DBConTest.java:18)
>
>
> In args[0] I pass a Protégé Database .pprj file name. Interestingly
> enough, the KB factory is an instance of DatabaseKnowledgeBaseFactory

Are you sure the project you load (args[0]) is actually an owl ontology ?

Olivier
-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: casting a DefaultKnowledgeBase into an OWLModel

Gandalf-6
Olivier Dameron wrote:

>> In args[0] I pass a Protégé Database .pprj file name. Interestingly
>> enough, the KB factory is an instance of DatabaseKnowledgeBaseFactory
>
> Are you sure the project you load (args[0]) is actually an owl ontology ?


Good point, Olivier. I was passing a "Protégé Database" and not a "OWL
Database".

Thanks for the hint.

GLG

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html