Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-owl] import (non-interractive) my OWL into RDBMS

Tania Tudorache tudorache at stanford.edu
Fri Mar 20 14:52:59 PDT 2009


Hi Tony,

The exception kind of tells what the problem is. Is the file really 
located at: "*\work\protege\projects\test_forms_owl\imported.owl" ?* **I 
suppose not.

How do you invoke your class? Can you please send the code that you use 
to call the class that you attached to your post?

Please post also the entire exception stack trace.

Tania**


Tony C wrote:
> Hi Tania,
> Thanks for your help. I loaded Eclipse. Attached is my java file 
> (Streaming conversion). When I try to compile in Eclipse I get the 
> following error:
> *Exception in thread "main" java.io.FileNotFoundException: 
> \work\protege\projects\test_forms_owl\imported.owl (The system cannot 
> find the path specified)
>  at java.io.FileInputStream.open(Native Method)
>  at java.io.FileInputStream.<init>(Unknown Source)
>  at java.io.FileInputStream.<init>(Unknown Source)
>  at 
> edu.stanford.smi.protegex.owl.ui.forms.AbsoluteFormsLoader.main(Unknown 
> Source)*
>
> I'm not too sure why I get this error. Someone help. Im simply trying 
> implement a java class that uses one of the methods described here 
>  http://protegewiki.stanford.edu/index.php/ConvertingToDatabaseProject 
> I don't want to use the GUI to import the owl into mysql, I want to 
> run the import (ImpOWL.class) using a unix shell script.
> Cheers
> Tony.
>
> 2009/3/19 Tania Tudorache <tudorache at stanford.edu 
> <mailto:tudorache at stanford.edu>>
>
>     It is very painful to compile using javac in a command window
>     because you need to set up the class path to all the jars in the
>     protege-owl plugin directory and the protege.jar in the protege
>     installation directory.
>
>     Unless you want to use an ant script to compile (you could take
>     one that we already have and adapt it), I would suggest to use a
>     Java development environment like Eclipse that would help you both
>     with the development and the compilation.
>
>     So in your case, you obviously did not set the right classpath,
>     you are missing all the protege jars.
>
>     I've attached a build.xml that we are using the compile a plugin
>     with ant. If you have some ant experience, it should not be too
>     hard to modify. You need to set the PROTEGE_HOME environment
>     variable to the protege installation directory.
>
>     In any case, I think compiling in Eclipse or other Java IDE would
>     be easier.
>
>     Tania
>
>     Tony C wrote:
>
>
>         Hi Tania,
>
>         Here is what I got trying to compile using javac
>
>
>         *cd C:\Program Files\Protege_3.4_rc1\
>
>         C:\Program
>         Files\Protege_3.4_rc1\plugins\edu.stanford.smi.protegex.owl
>
>         C:\Program
>         Files\Protege_3.4_rc1\plugins\edu.stanford.smi.protegex.owl>javac
>         Test.java
>         *Test.java:6: package edu.stanford.smi.protegex.owl.model does
>         not exist
>         import edu.stanford.smi.protegex.owl.model.*;
>         ^
>         Test.java:7: package edu.stanford.smi.protegex.owl.util does
>         not exist
>         import edu.stanford.smi.protegex.owl.util.*;
>         ^
>         Test.java:8: package edu.stanford.smi.protegex.owl.exception
>         does not exist
>         import
>         edu.stanford.smi.protegex.owl.exception.OntologyLoadException;
>          ^
>         Test.java:9: package edu.stanford.smi.protegex.owl.model does
>         not exist
>         import edu.stanford.smi.protegex.owl.model.KnowledgeBaseFactory;
>          ^
>         Test.java:10: package
>         edu.stanford.smi.protegex.owl.database.creator does not ex
>         ist
>         import
>         edu.stanford.smi.protegex.owl.database.creator.OwlDatabaseFromFileCreator
>         ;
>          ^
>         Test.java:11: package driver.com.mysql.jdbc does not exist
>         import driver.com.mysql.jdbc.Driver;
>          ^
>         Test.java:13: cannot find symbol
>         symbol: class runnable
>         public class Test extends runnable
>          ^
>         Test.java:30: cannot find symbol
>         symbol : class OWLModel
>         location: class Test
>          private static OWLModel convertToDatabaseProject(OWLModel
>         fileModel) throws
>         Exception {
>          ^
>         Test.java:30: cannot find symbol
>         symbol : class OWLModel
>         location: class Test
>          private static OWLModel convertToDatabaseProject(OWLModel
>         fileModel) throws
>         Exception {
>          ^
>         Test.java:16: missing method body, or declare abstract
>         private Test();
>          ^
>         Test.java:19: call to super must be first statement in constructor
>          super();
>          ^
>         Test.java:33: cannot find symbol
>         symbol : class Project
>         location: class Test
>          Project fileProject = fileModel.getProject();
>          ^
>         Test.java:34: cannot find symbol
>         symbol : class OWLDatabaseKnowledgeBaseFactory
>         location: class Test
>          OWLDatabaseKnowledgeBaseFactory factory = new
>         OWLDatabaseKnowledgeBaseFa
>         ctory();
>          ^
>         Test.java:34: cannot find symbol
>         symbol : class OWLDatabaseKnowledgeBaseFactory
>         location: class Test
>          OWLDatabaseKnowledgeBaseFactory factory = new
>         OWLDatabaseKnowledgeBaseFa
>         ctory();
>          ^
>         Test.java:35: cannot find symbol
>         symbol : class PropertyList
>         location: class Test
>          PropertyList sources =
>         PropertyList.create(fileProject.getInternalProjec
>         tKnowledgeBase());
>          ^
>         Test.java:35: cannot find symbol
>         symbol : variable PropertyList
>         location: class Test
>          PropertyList sources =
>         PropertyList.create(fileProject.getInternalProjec
>         tKnowledgeBase());
>          ^
>         Test.java:37: cannot find symbol
>         symbol : variable DatabaseKnowledgeBaseFactory
>         location: class Test
>          DatabaseKnowledgeBaseFactory.setSources(sources, driver, url,
>         table, use
>         r, password);
>          ^
>         Test.java:41: cannot find symbol
>         symbol : method displayErrors(java.util.List)
>         location: class Test
>          displayErrors(errors);
>          ^
>         Test.java:51: cannot find symbol
>         symbol : class Project
>         location: class Test
>          Project dbProject = Project.createNewProject(factory, errors);
>          ^
>         Test.java:51: cannot find symbol
>         symbol : variable Project
>         location: class Test
>          Project dbProject = Project.createNewProject(factory, errors);
>          ^
>         Test.java:52: cannot find symbol
>         symbol : variable DatabaseKnowledgeBaseFactory
>         location: class Test
>          DatabaseKnowledgeBaseFactory.setSources(dbProject.getSources(),
>         driver,
>         url, table, user, password);
>          ^
>         Test.java:55: cannot find symbol
>         symbol : variable dbProjectFile
>         location: class Test
>          dbProject.setProjectURI(URIUtilities.createURI(dbProjectFile));
>          ^
>         Test.java:55: cannot find symbol
>         symbol : variable URIUtilities
>         location: class Test
>          dbProject.setProjectURI(URIUtilities.createURI(dbProjectFile));
>          ^
>         Test.java:59: cannot find symbol
>         symbol : method displayErrors(java.util.List)
>         location: class Test
>          displayErrors(errors);
>          ^
>         Test.java:61: cannot find symbol
>         symbol : class OWLModel
>         location: class Test
>          return (OWLModel) dbProject.getKnowledgeBase();
>          ^
>         Test.java:67: cannot find symbol
>         symbol : class OWLModel
>         location: class Test
>          OWLModel convertToDatabaseProject;
>          ^
>         26 errors*
>
>         C:\Program
>         Files\Protege_3.4_rc1\plugins\edu.stanford.smi.protegex.owl>
>         C:\Program
>         Files\Protege_3.4_rc1\plugins\edu.stanford.smi.protegex.owl>
>
>         *
>
>
>         2009/3/19 Tania Tudorache <tudorache at stanford.edu
>         <mailto:tudorache at stanford.edu> <mailto:tudorache at stanford.edu
>         <mailto:tudorache at stanford.edu>>>
>
>
>            You mean the Java classes do not exist?
>
>            You probably do not have all the jars from the protege-owl
>         plugin
>            folder in your build and classpath. They are needed.
>
>            Tania
>
>
>            Tony C wrote:
>
>
>                Hi Tania,
>
>                Please see my class below. I tried it that way.
>
>                Tried compiling it against Protege 3.4 jars.
>                The compiler indicates that none of the classes defined
>         on the
>                link you sent exist.
>
>                Help please.
>                Tony
>
>              
>          //---------------------------------------------------------------------
>                // Runnable Java class that imports
>         /tmp/pizza/pizza.owl into
>                MySQL RDBMS
>              
>          //---------------------------------------------------------------------
>
>                import java.util.*;
>                import edu.stanford.smi.protege.model.*;
>                import edu.stanford.smi.protege.util.*;
>                import
>         edu.stanford.smi.protege.exception.OntologyLoadException;
>                import edu.stanford.smi.protege.model.KnowledgeBaseFactory;
>                import
>              
>          edu.stanford.smi.protegex.owl.database.creator.OwlDatabaseFromFileCreator;
>
>                public class Test extends runnable {
>
>                private Test();
>
>                {
>                 super();
>                }
>
>                private final static String driver =
>         "com.mysql.jdbc.Driver";
>                private final static String url =
>                "jdbc:mysql://localhost/protege";
>                private final static String table = "newtableTest";
>                private final static String user = "root";
>                private final static String password = "";
>                //private final static String uri =
>         "file:/tmp/pizza/pizza.owl";
>                 @SuppressWarnings("unchecked")
>                 private static OWLModel convertToDatabaseProject(OWLModel
>                fileModel) throws Exception {
>                 System.out.println("In Convert to Database Project");
>                 List errors = new ArrayList();
>                 Project fileProject = fileModel.getProject();
>                 OWLDatabaseKnowledgeBaseFactory factory = new
>                OWLDatabaseKnowledgeBaseFactory();
>                 PropertyList sources =
>              
>          PropertyList.create(fileProject.getInternalProjectKnowledgeBase());
>                   DatabaseKnowledgeBaseFactory.setSources(sources, driver,
>                url, table, user, password);
>                 factory.saveKnowledgeBase(fileModel, sources, errors);
>
>                 displayErrors(errors); //forget this and it will be a
>         mystery
>                when things go wrong
>                 if (!errors.isEmpty()) {
>                 return null;
>                 }
>
>                 //Following lines are optional.
>                 //Use them if you want to have a pprj generated for the DB
>                project (you usually want this)
>                 //If not, you can always create a new project from
>         existing
>                sources in the Protege editor
>
>                 Project dbProject = Project.createNewProject(factory,
>         errors);
>                
>         DatabaseKnowledgeBaseFactory.setSources(dbProject.getSources(),
>                driver, url, table, user, password);
>
>                 dbProject.createDomainKnowledgeBase(factory, errors,
>         true);
>                
>         dbProject.setProjectURI(URIUtilities.createURI(dbProjectFile));
>                 dbProject.save(errors);
>
>                 displayErrors(errors); //forget this and it will be a
>         mystery
>                when things go wrong
>                 return (OWLModel) dbProject.getKnowledgeBase();
>                 }
>
>                private static void main()
>                {
>                 String URL="myUrl";
>                 OWLModel convertToDatabaseProject;
>
>                }
>
>                }
>
>                //---------------------
>                // Runnable Java END END
>                //---------------------
>
>                ------------------------------
>
>
>                Message: 4
>                Date: Mon, 16 Mar 2009 16:13:45 -0700
>                From: Tania Tudorache <tudorache at stanford.edu
>         <mailto:tudorache at stanford.edu>
>                <mailto:tudorache at stanford.edu
>         <mailto:tudorache at stanford.edu>>
>         <mailto:tudorache at stanford.edu <mailto:tudorache at stanford.edu>
>
>                <mailto:tudorache at stanford.edu
>         <mailto:tudorache at stanford.edu>>>>
>
>                Subject: Re: [protege-owl] Protege 3 java classes
>                To: User support for the Protege-OWL editor
>                      <protege-owl at lists.stanford.edu
>         <mailto:protege-owl at lists.stanford.edu>
>                <mailto:protege-owl at lists.stanford.edu
>         <mailto:protege-owl at lists.stanford.edu>>
>                <mailto:protege-owl at lists.stanford.edu
>         <mailto:protege-owl at lists.stanford.edu>
>                <mailto:protege-owl at lists.stanford.edu
>         <mailto:protege-owl at lists.stanford.edu>>>>
>                Message-ID: <49BEDD29.2040207 at stanford.edu
>         <mailto:49BEDD29.2040207 at stanford.edu>
>                <mailto:49BEDD29.2040207 at stanford.edu
>         <mailto:49BEDD29.2040207 at stanford.edu>>
>                <mailto:49BEDD29.2040207 at stanford.edu
>         <mailto:49BEDD29.2040207 at stanford.edu>
>                <mailto:49BEDD29.2040207 at stanford.edu
>         <mailto:49BEDD29.2040207 at stanford.edu>>>>
>
>                Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>                Tony,
>
>                I suppose you are asking how to convert an OWL file to
>         the OWL
>                database
>                backend. There are two ways to do that, which are
>         documented
>                on the wiki:
>
>              
>          http://protegewiki.stanford.edu/index.php/ConvertingToDatabaseProject
>
>                Tania
>
>                Tony C wrote:
>                >
>                > hi
>                >
>                > Does anyone know what Protege 3 java classes are called
>                > programatically for importing an OWL file to MySQL?
>                >
>                >
>              
>          ------------------------------------------------------------------------
>                >
>                > _______________________________________________
>                > protege-owl mailing list
>                > protege-owl at lists.stanford.edu
>         <mailto:protege-owl at lists.stanford.edu>
>                <mailto:protege-owl at lists.stanford.edu
>         <mailto:protege-owl at lists.stanford.edu>>
>                <mailto:protege-owl at lists.stanford.edu
>         <mailto:protege-owl at lists.stanford.edu>
>                <mailto:protege-owl at lists.stanford.edu
>         <mailto: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
>                >
>
>
>
>                ------------------------------
>
>                Message: 5
>                Date: Mon, 16 Mar 2009 16:15:42 -0700
>                From: Tania Tudorache <tudorache at stanford.edu
>         <mailto:tudorache at stanford.edu>
>                <mailto:tudorache at stanford.edu
>         <mailto:tudorache at stanford.edu>>
>         <mailto:tudorache at stanford.edu <mailto:tudorache at stanford.edu>
>
>                <mailto:tudorache at stanford.edu
>         <mailto:tudorache at stanford.edu>>>>
>
>                Subject: Re: [protege-owl] import (non-interractive) my OWL
>                into RDBMS
>                To: User support for the Protege-OWL editor
>                      <protege-owl at lists.stanford.edu
>         <mailto:protege-owl at lists.stanford.edu>
>                <mailto:protege-owl at lists.stanford.edu
>         <mailto:protege-owl at lists.stanford.edu>>
>                <mailto:protege-owl at lists.stanford.edu
>         <mailto:protege-owl at lists.stanford.edu>
>                <mailto:protege-owl at lists.stanford.edu
>         <mailto:protege-owl at lists.stanford.edu>>>>
>                Message-ID: <49BEDD9E.2080700 at stanford.edu
>         <mailto:49BEDD9E.2080700 at stanford.edu>
>                <mailto:49BEDD9E.2080700 at stanford.edu
>         <mailto:49BEDD9E.2080700 at stanford.edu>>
>                <mailto:49BEDD9E.2080700 at stanford.edu
>         <mailto:49BEDD9E.2080700 at stanford.edu>
>                <mailto:49BEDD9E.2080700 at stanford.edu
>         <mailto:49BEDD9E.2080700 at stanford.edu>>>>
>
>                Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>                Tony,
>
>                Please see my reply to your other post.
>
>                Tania
>
>                Tony C wrote:
>                > Hi,
>                >
>                > I'm working on a project to import my OWL into RDBMS then
>                make it
>                > accessible via different SQL commands to get the desired
>                outputs; my
>                > intension is to
>                >
>                > 1. load/import my owl file to Mysql with "command line"
>                running as a
>                > UNIX/LINUX script in the backend,
>                > 2. extract the data from the table into various
>         tables (from
>                the LISP
>                > to something easier).
>                >
>                > The protege RDBMS is explained here
>                > http://protege.stanford.edu/doc/design/jdbc_backend.html
>                >
>                > I'm quite happy to import using the same method used
>         by Protege
>                > although I'm not quite sure what faces/slots etc
>         represent in my
>                > ontology. The imported data makes no sense for me at this
>                point until
>                > i can achieve task on point 1 above.
>                >
>                > What I did:
>                >
>                > Recently I imported my OWL file to MySQL database
>         using Protege
>                > (interructively). It all went into one table which is
>         fine by me
>                >
>                > What I would like to do:
>                >
>                > Now I'm trying to do the same operation (load/import
>         my owl
>                file to
>                > Mysql) in non interractive mode; a Linux/Unix shell
>         script
>                that does
>                > the job without GUI clicks.
>                >
>                > I'm pretty sure this is possible but I don't know the
>                essencial java
>                > classes required to make that happen. Can someone help?
>                >
>                > Regards,
>                >
>                > Tony.
>                >
>                >
>              
>          ------------------------------------------------------------------------
>                >
>                > _______________________________________________
>                > protege-owl mailing list
>                > protege-owl at lists.stanford.edu
>         <mailto:protege-owl at lists.stanford.edu>
>                <mailto:protege-owl at lists.stanford.edu
>         <mailto:protege-owl at lists.stanford.edu>>
>                <mailto:protege-owl at lists.stanford.edu
>         <mailto:protege-owl at lists.stanford.edu>
>                <mailto:protege-owl at lists.stanford.edu
>         <mailto: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
>                >
>
>
>
>
>
>
>




More information about the protege-owl mailing list