edu.cs.ai.kreator.datamodels
Class Project

java.lang.Object
  extended by java.io.File
      extended by edu.cs.ai.kreator.datamodels.AbstractKreatorFile
          extended by edu.cs.ai.kreator.datamodels.Project
All Implemented Interfaces:
StainedListener, java.io.Serializable, java.lang.Comparable<java.io.File>

public class Project
extends AbstractKreatorFile

This class encapsulates sets of knowledgebases, report, scripts, querycollections and examplecollections that belong to one project.

Author:
Sebastian Loh, Matthias Thimm
See Also:
Serialized Form

Field Summary
static java.lang.String extension
          The KReator-Project extension.
 
Fields inherited from class edu.cs.ai.kreator.datamodels.AbstractKreatorFile
fileContent, LOG
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
Project(java.io.File projectFile)
          Constructs a project.
 
Method Summary
 void addDataFile(DataFile file)
           
 boolean containsDataFile(DataFile file)
          Checks if the project contains a given DataFile
static java.io.File createEmptyProjectFile(java.io.File location)
          Creates an empty project file at the given location.
static java.util.List<java.lang.String> getAllSupportedFileExtensions()
          Returns all file extensions, which Projects can have.
 java.util.List<java.lang.String> getCommandHistory()
           
 java.util.List<DataFile> getDataFiles()
           
 java.util.List<java.lang.String> getDelimitedStringAsList(java.lang.String str, java.lang.String delimiter)
          Splits a String by a delimiter.
 java.lang.String getFileContent()
          This method is used to update the KreatorFileListener representation of the KReatorFile.
 java.util.List<KnowledgebaseFile> getKnowledgebases()
           
 int getNumberOfFiles()
          returns the number of files in this project.
 java.util.List<OtherFile> getOtherFiles()
           
 java.util.List<java.lang.String> getQueryHistory()
           
 java.lang.String getRelativePath(java.io.File file)
          Computes the relative path of file targetPath to the path of file basePath
 java.util.List<SampleCollection> getSampleCollections()
           
 java.util.List<KreatorScript> getScripts()
           
 void load()
          Loads the AbstractKreatorFile.
 void loadProject()
           
 boolean removeDataFile(DataFile file)
          Removes a given File from this Project and notifies the listeners.
 void save()
          Saves the AbstractKreatorFile to the file system.
 void setCommandHistory(java.util.List<java.lang.String> history)
           
 void setQueryHistory(java.util.List<java.lang.String> history)
           
 
Methods inherited from class edu.cs.ai.kreator.datamodels.AbstractKreatorFile
addKReatorFileListener, fireModelChanged, removeKReatorFileListener, setFileContent, stainedStatusChanged, viewsAreStained
 
Methods inherited from class java.io.File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

extension

public static final java.lang.String extension
The KReator-Project extension.

See Also:
Constant Field Values
Constructor Detail

Project

public Project(java.io.File projectFile)
        throws java.io.IOException,
               ProjectParsingException
Constructs a project.

Parameters:
controller - a controller.
projectFile - the file of this project.
Throws:
java.io.IOException
ProjectParsingException
Method Detail

getAllSupportedFileExtensions

public static java.util.List<java.lang.String> getAllSupportedFileExtensions()
Returns all file extensions, which Projects can have.

Returns:
all file extensions, which Projects can have.

getNumberOfFiles

public int getNumberOfFiles()
returns the number of files in this project.

Returns:
an int describing the number of files in this project.

load

public void load()
Description copied from class: AbstractKreatorFile
Loads the AbstractKreatorFile.

Specified by:
load in class AbstractKreatorFile

loadProject

public void loadProject()
                 throws ProjectParsingException
Throws:
ProjectParsingException

createEmptyProjectFile

public static java.io.File createEmptyProjectFile(java.io.File location)
                                           throws java.io.IOException,
                                                  UnsupportedFileTypeException
Creates an empty project file at the given location.

Parameters:
location -
Returns:
Throws:
java.io.IOException
UnsupportedFileTypeException

save

public void save()
          throws java.io.IOException
Description copied from class: AbstractKreatorFile
Saves the AbstractKreatorFile to the file system.

Specified by:
save in class AbstractKreatorFile
Throws:
java.io.IOException - if the file could not write on the file system.

addDataFile

public void addDataFile(DataFile file)
                 throws java.io.IOException
Throws:
java.io.IOException

getRelativePath

public java.lang.String getRelativePath(java.io.File file)
Computes the relative path of file targetPath to the path of file basePath

Parameters:
file -
Returns:
The path of the file relative to this project

getDelimitedStringAsList

public java.util.List<java.lang.String> getDelimitedStringAsList(java.lang.String str,
                                                                 java.lang.String delimiter)
Splits a String by a delimiter.
Used by getRelativePath(File)

Parameters:
str -
delimiter -
Returns:
A List of the parts of the String

containsDataFile

public boolean containsDataFile(DataFile file)
Checks if the project contains a given DataFile

Parameters:
file -
Throws:
UnknownFileTypeException

removeDataFile

public boolean removeDataFile(DataFile file)
                       throws java.io.IOException
Removes a given File from this Project and notifies the listeners.

Parameters:
fullPath - the full path of the DataFile
Returns:
true if a entry was removed, false no entry could found.
Throws:
java.io.IOException

getDataFiles

public java.util.List<DataFile> getDataFiles()

getSampleCollections

public java.util.List<SampleCollection> getSampleCollections()

getKnowledgebases

public java.util.List<KnowledgebaseFile> getKnowledgebases()

getOtherFiles

public java.util.List<OtherFile> getOtherFiles()

getScripts

public java.util.List<KreatorScript> getScripts()

setCommandHistory

public void setCommandHistory(java.util.List<java.lang.String> history)
                       throws java.io.IOException
Throws:
java.io.IOException

setQueryHistory

public void setQueryHistory(java.util.List<java.lang.String> history)
                     throws java.io.IOException
Throws:
java.io.IOException

getCommandHistory

public java.util.List<java.lang.String> getCommandHistory()

getQueryHistory

public java.util.List<java.lang.String> getQueryHistory()

getFileContent

public java.lang.String getFileContent()
Description copied from class: AbstractKreatorFile
This method is used to update the KreatorFileListener representation of the KReatorFile.

Overrides:
getFileContent in class AbstractKreatorFile
Returns: