"Save As" projects from the API (7N7)
This wiki page explains how a Protege project can be saved under a different name for the following cases: (7VX)
Protege-Frames file projects (7N8)
When saving your Protege frames file project under a different name (for example, "newPrj.pprj"), three new files will be created: (7N9)
- The project file (for example, newPrj.pprj) - that stores the forms information (7NA)
- The pont file - that stores the classes of the ontology (for example, newPrj.pont), and (7NB)
- The pins file - that stores the instances of the ontology (for example, newPrj.pins). (7NC)
You have to call the following methods from the Protege Frames API: (7NN)
Project project = kb.getProject(); project.setProjectFilePath("C://tmp//newPrj.pprj"); //or alternatively: project.setProjectURI(someUri) ClipsKnowledgeBaseFactory.setSourceFiles(project.getSources(), "newPrj.pont", "newsPrj.pins"); ArrayList errors = new ArrayList(); project.save(errors); //handle errors (7NO)
Protege-OWL file projects (7NU)
There are two ways how you can save a project or an OWL file through the Protege OWL API: (7NP)
- Saving only the OWL file (and not the pprj), or (7NQ)
- Saving the OWL file and the pprj file. The pprj file holds the form information (how the GUI elements/widgets are arranged on the display of classes and instances). If you don't want to loose the form information, then use this method. (7NR)
Saving only the OWL file (not the pprj file) (7NW)
You have to call the following methods from the Protege OWL API: (7NT)
//JenaOWLModel jenaOWLModel = ... //for example: jenaOWLModel = (JenaOWLModel)project.getKnowledgeBase() ArrayList errors = new ArrayList(); jenaOWLModel.save(someURI, FileUtils.langXMLAbbrev, errors); //handle errors (7NO)
See below for instructions on how to set the OWL Language (For example, XML, NTriple, N3, etc.). (7OS)
See also the Protege-OWL API - Programmer's Guide (7NX)
Saving the OWL file and the pprj file (7NY)
In this case, two files will be save: (7NZ)
- the project file (for example, newPrj.pprj) - holding the froms information, and (7O0)
- the OWL file (for example, newOWLfile.owl) (7O1)
The name of the pprj file and of the OWL file are not necessarily the same, but it is recommended to use the same name for both of them. (7O2)
You have to call the following methods from the Protege OWL API: (7O3)
//Project project = ... project.setProjectFilePath("C://tmp//newPrj.pprj"); //or alternatively: project.setProjectURI(someUri) JenaKnowledgeBaseFactory.setOWLFileName(project.getSources(), "file:///C:/tmp/newOWLfile.owl"); // this is optional // JenaKnowledgeBaseFactory.setOWLFileLanguage(project.getSources(), FileUtils.langXMLAbbrev); ArrayList errors = new ArrayList(); project.save(errors); //handle errors (7O4)
Setting the OWL Language (7OT)
If you want to set also the OWL file language, you should include the jena.jar in your classpath (FileUtils is defined in jena.jar). The possible languages are: (7OQ)