Difference between revisions of "ConvertingToDatabaseProject"

From Protege Wiki
Jump to: navigation, search
(New page: The following routine will convert a owl project to a owl database project. One flaw of this method is that the forms information is lost. We will provide a better version later. <code> ...)
 
Line 1: Line 1:
The following routine will convert a owl project to a owl database project. One flaw of this method is that the forms information is lost.  We will provide a better version later.
+
The following routine will convert a owl project to a owl database project. If you don't need the file model after this call you need to dispose it to save memory.
 +
 
 +
One flaw of this method is that the forms information is lost.  We will provide a better version later.
  
 
<code>
 
<code>

Revision as of 15:28, December 7, 2007

The following routine will convert a owl project to a owl database project. If you don't need the file model after this call you need to dispose it to save memory.

One flaw of this method is that the forms information is lost. We will provide a better version later.

   @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);
       if (!errors.isEmpty()) {
           return null;
       }
       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);        
       return (OWLModel) dbProject.getKnowledgeBase();
   }