Difference between revisions of "LoadFramesOntologyFromDB"

From Protege Wiki
Jump to: navigation, search
(migrating this page from old cim3 wiki)
 
m
 
Line 1: Line 1:
<span style="font-weight:bold; font-size:18px;">How do I load a Protege-Frames ontology from a Protege Database using the API?</span><br /><br />
+
<span style="font-weight:bold; font-size:18px;">How do I load a Protege-Frames ontology from a Protege database using the API?</span><br /><br />
  
 
'''Method 1'''
 
'''Method 1'''

Latest revision as of 17:54, February 22, 2008

How do I load a Protege-Frames ontology from a Protege database using the API?

Method 1

The simplest way to load a Protege-Frames ontology from a database is to programatically load the project file (.pprj), which already contains all of the necessary database connection information:

Project prj = Project.loadProjectFromFile("/tmp/newspaper.pprj",errors);
KnowledgeBase kb = prj.getKnowledgeBase();
...


Method 2

The second method should be used if there is no project file (.pprj) associated with the Protege-Frames database ontology:

DatabaseKnowledgeBaseFactory factory = new DatabaseKnowledgeBaseFactory();
Collection errors = new ArrayList();

Project project = Project.createNewProject(factory, errors);
//replace the arguments with your own specific values
DatabaseKnowledgeBaseFactory.setSources(project.getSources(), "com.mysql.jdbc.Driver", "jdbc:mysql://localhost/protege", "table", "user", "password");

project.createDomainKnowledgeBase(factory, errors, true);

//the following lines are optional. Use them only if you want to save the project
project.setProjectURI(new URI("file:/tmp/newspaper_saved.pprj"));
project.save(errors);
...