Re: How do I use DatabaseKnowledgeBaseFactory?
Stefan Göhring <stefan.goehring <at> gmx.de>
2006-11-01 19:20:16 GMT
Hi Tania,
thanks now I found all the info I was looking for you. Thanks!
I oversaw that the protege-owl sources
(http://protege.stanford.edu/download/registered.html) include the
javadoc. Because I'm not alway connected to the net I needed a
downloadable version.
Stefan
Tania Tudorache schrieb:
> Hi Stefan,
>
> Stefan Göhring wrote:
>> Hey Tania!
>> Thank you so much for your help! It works perfectly now.
>> I am using the harder way because my app won't have access to the pprj file.
>>
>> Did I oversee some documentation or is there none for this procedure? Is
>> there some further documentation than the protégé-owl api programmer's
>> guide and the javadoc?
>>
> There are still the wiki pages
> (http://protege.cim3.net/cgi-bin/wiki.pl/), where both developers and
> users document different topics.
> Some programming issues are described here:
> http://protege.cim3.net/cgi-bin/wiki.pl?ProgrammingTipsAndTricks
>
>> I would like to download the javadoc and the owl source files on my
>> computer to use them with eclipse, but i can't find where to get a
>> zipped javadoc and I'm obviously too silly to use the cvs import utility
>> of eclipse to get the sources...
>> any hints?
>>
>>
> You find the sources and the javadoc of the latest Protege beta on the
> Download page:
> http://protege.stanford.edu/download/registered.html
>
> Cheers,
> Tania
>
>
>> Greeting from rainy Germany,
>> Stefan
>>
>> Tania Tudorache schrieb:
>>
>>> Stefan,
>>>
>>> The simplest way to read/write to an OWL database, is to load
>>> programmatically the project (pprj file), which already contains all
>>> database connection information:
>>>
>>> Project prj = Project.loadProjectFromFile("/home/pizza_db.pprj",errors);
>>> OWLModel owlModel = (OWLModel) prj.getKnowledgeBase();
>>> ....
>>>
>>> The harder way to do the same is to use the factory:
>>>
>>> OWLDatabaseKnowledgeBaseFactory factory = new
>>> OWLDatabaseKnowledgeBaseFactory();
>>> Project prj = Project.createNewProject(factory, errors);
>>> OWLDatabaseKnowledgeBaseFactory.setSources(prj.getSources(),
>>> "com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/protege", "pizza",
>>> "user", "password");
>>> prj.createDomainKnowledgeBase(factory, errors, true);
>>>
>>> OWLModel owlModel = (OWLModel) prj.getKnowledgeBase();
>>> ....
>>>
>>> I hope this helps.
>>>
>>> Tania
>>>
>>> Stefan Göhring wrote:
>>>
>>>> Hi protege-owl programmers!
>>>>
>>>> I am trying to learn the use the protege-owl api, but I can't answer the
>>>> following questions by using goole, protege owl guide and javadoc.
>>>> Searching for "DatabaseKnowledgeBaseFactory" in this newsgroup just
>>>> brought up one unanswered thread.
>>>>
>>>> My small app shold be able to read from and write in an owl database
>>>> created by protege 3.2b. For that I use the protege owl jars from the
>>>> plugins dir, the base protege jar file and the same jdbc connector i use
>>>> with protege.
>>>>
>>>> This is the important code snippet:
>>>>
>>>> DatabaseKnowledgeBaseFactory dbFactory = new DatabaseKnowledgeBaseFactory();
>>>> KnowledgeBase kb = dbFactory.createKnowledgeBase(new ArrayList());
>>>> dbFactory.loadKnowledgeBase(kb, "com.mysql.jdbc.Driver",
>>>> "jdbc:mysql://localhost/protege", "root", "", "logiktest", new ArrayList());
>>>> OWLDatabaseModel owlModel = new OWLDatabaseModel(dbFactory);
>>>>
>>>> System.out.println(printerFriendlyCollection(owlModel.getUserDefinedOWLNamedClasses()));
>>>>
>>>> private String printerFriendlyCollection(Collection c){
>>>> String s = "";
>>>> Iterator it = c.iterator();
>>>> while(it.hasNext()){
>>>> RDFResource next = (RDFResource)it.next();
>>>> s+=next.getName()+"\n";
>>>> }
>>>> return s;
>>>> }
>>>>
>>>> I use new ArrayList() for the error collection - I do not know what kind
>>>> of collection I have to pass, so I just used an empty one and hoped to
>>>> understand it with a following error code.
>>>>
>>>> I get the following error executing this code:
>>>>
>>>>
>>>> CONFIG: Protege 3.2 Build 318, JVM 1.5.0_06-b05, memory=66M, Windows XP,
>>>> encoding=UTF-8, language=de, country=DE
>>>> WARNING: Look and feel not found:
>>>> com.jgoodies.looks.plastic.PlasticLookAndFeel --
>>>> SystemUtilities.setLookAndFeel()
>>>> WARNING: Plugins directory not found: D:\Eigene
>>>> Dateien\develop\java\projects\protege owl test\plugins --
>>>> PluginUtilities.findPluginsDirectory()
>>>> WARNING: Unable to load knowledgebase -- java.lang.NullPointerException
>>>> at
>>>>
edu.stanford.smi.protege.storage.database.DatabaseKnowledgeBaseFactory.initializeKB(Unknown
>>>> Source)
>>>> at
>>>>
edu.stanford.smi.protege.storage.database.DatabaseKnowledgeBaseFactory.loadKnowledgeBase(Unknown
>>>> Source)
>>>> at OWLDatabaseTest.<init>(OWLDatabaseTest.java:30)
>>>> at OWLDatabaseTest.main(OWLDatabaseTest.java:13)
>>>>
>>>> Any ideas, solution proposals or links to tutorials?
>>>>
>>>> Greetings,
>>>> Stefan Göhring
>>>>
>>>> _______________________________________________
>>>> protege-owl mailing list
>>>> protege-owl <at> lists.stanford.edu
>>>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>>>
>>>> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> protege-owl mailing list
>>> protege-owl <at> lists.stanford.edu
>>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>>
>>> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>>>
>>>
>> _______________________________________________
>> protege-owl mailing list
>> protege-owl <at> lists.stanford.edu
>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>
>> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>>
>>
>
> _______________________________________________
> protege-owl mailing list
> protege-owl <at> lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>
_______________________________________________
protege-owl mailing list
protege-owl <at> lists.stanford.edu
https://mailman.stanford.edu/mailman/listinfo/protege-owl
Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03