edu.uchsc.ccp.knowtator.util
Class ProjectUtil

java.lang.Object
  extended by edu.uchsc.ccp.knowtator.util.ProjectUtil

public class ProjectUtil
extends Object


Constructor Summary
ProjectUtil()
           
 
Method Summary
static void copyKnowtatorFilesToProjectDirectory(File projectDirectory, File knowtatorProjectDirectory)
           
static void copyKnowtatorFilesToProjectDirectory(Project project)
           
static void copyKnowtatorFilesToProjectDirectory(Project project, File knowtatorProjectDirectory)
           
static Project createNewProject(File newProjectFile)
           
static Project createNewProject(File knowtatorProjectDirectory, File newProjectFile)
           
static void fixKnowtatorProjectPath(Project project)
           
static void fixKnowtatorProjectPath(Project project, File knowtatorProjectDirectory)
          Knowtator annotation projects require that the project knowtator.pprj is a directly included project - i.e.
static File getKnowtatorProjectDirectory()
          This method returns the default location of the knowtator project files: knowtator.pprj, knowtator.pins, knowtator.pont, new-project.pprj, etc.
static Project openProject(String projectFileName)
           
static void saveProject(Project project)
           
static void saveProjectAs(Project project, File projectFile)
           
static void saveProjectAs(Project project, File projectFile, File knowtatorProjectDirectory)
          This method provides a programmatic way to safely save a Knowtator project with a different name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProjectUtil

public ProjectUtil()
Method Detail

openProject

public static Project openProject(String projectFileName)

saveProject

public static void saveProject(Project project)

getKnowtatorProjectDirectory

public static File getKnowtatorProjectDirectory()
This method returns the default location of the knowtator project files: knowtator.pprj, knowtator.pins, knowtator.pont, new-project.pprj, etc. This method will only work from the context of a running Protege application - i.e. it will work if called from Knowtator.java but will not run if you are writing a script that runs from the command line. In such cases you will need to know the location of the knowtator project files to call methods such as saveProjectAs(Project, File, File) , fixKnowtatorProjectPath(Project, File), or createNewProject(File, File). If you need to call one of these methods from a script, then you must find the project files on your file system. If you have knowtator installed, then you can pass in the knowtator plugin directory. If you have a local copy of the source code, then you can find them locally at "resources/knowtator.pprj".

Returns:
the default location of the knowtator project files.

saveProjectAs

public static void saveProjectAs(Project project,
                                 File projectFile)
                          throws IOException
Throws:
IOException
See Also:
getKnowtatorProjectDirectory()

saveProjectAs

public static void saveProjectAs(Project project,
                                 File projectFile,
                                 File knowtatorProjectDirectory)
                          throws IOException
This method provides a programmatic way to safely save a Knowtator project with a different name. Simply changing the name of the files on your file system is problematic for a number of reasons. Using Protege's "Save as" is also problematic for reasons described in #fixKnowtatorProjectPath(Project, String).

NOTE: This method does not update the reference to your text source collection. If your text source collection is referenced by a relative path (by default) then you will need to update the reference.

Parameters:
project - the project to save with a different name
projectFile - the new file name of the project
knowtatorProjectDirectory - see note for getKnowtatorProjectDirectory()
Throws:
IOException
See Also:
saveProjectAs(Project, File)

fixKnowtatorProjectPath

public static void fixKnowtatorProjectPath(Project project)
                                    throws IOException
Throws:
IOException
See Also:
getKnowtatorProjectDirectory()

fixKnowtatorProjectPath

public static void fixKnowtatorProjectPath(Project project,
                                           File knowtatorProjectDirectory)
                                    throws IOException
Knowtator annotation projects require that the project knowtator.pprj is a directly included project - i.e. the annotation project .pprj will include another project called knowtator.pprj. This project is found in the knowtator plugin directory and is copied to your projects directory when you initially set up knowtator and is referenced with a relative path. There are times when Protege will insert an absolute path into this reference to knowtator.pprj (usually when using Protege's "Save As..." menu option.) This often goes undetected until you try to open the project on a different computer in which case the absolute path is often no longer valid. It is possible (and easy - though annoying) to manually fix this problem by editing .pprj. However, this method provides a way to do this programmatically.

Parameters:
project -
knowtatorProjectDirectory - - the name of the directory containing current knowtator project files: knowtator.pprj, knowtator.pont, and knowtator.pins - e.g. "C:\Program Files\Protege_3.3.1\plugins\edu.uchsc.ccp.knowtator"
Throws:
IOException
See Also:
saveProject(Project)

copyKnowtatorFilesToProjectDirectory

public static void copyKnowtatorFilesToProjectDirectory(Project project)
                                                 throws IOException
Throws:
IOException
See Also:
getKnowtatorProjectDirectory()

copyKnowtatorFilesToProjectDirectory

public static void copyKnowtatorFilesToProjectDirectory(Project project,
                                                        File knowtatorProjectDirectory)
                                                 throws IOException
Throws:
IOException

copyKnowtatorFilesToProjectDirectory

public static void copyKnowtatorFilesToProjectDirectory(File projectDirectory,
                                                        File knowtatorProjectDirectory)
                                                 throws IOException
Throws:
IOException

createNewProject

public static Project createNewProject(File newProjectFile)
                                throws IOException
Throws:
IOException
See Also:
getKnowtatorProjectDirectory()

createNewProject

public static Project createNewProject(File knowtatorProjectDirectory,
                                       File newProjectFile)
                                throws IOException
Throws:
IOException