Class LocalProject

All Implemented Interfaces:
IExtendable, Project, ProjectRefresh
Direct Known Subclasses:
DesktopProject, ShadowProject

public class LocalProject extends AbstractProject implements ProjectRefresh
A local on-disk project
  • Field Details

  • Constructor Details

  • Method Details

    • saveProjectData

      protected void saveProjectData() throws IOException
      Save project data
      Throws:
      IOException
    • saveProperties

      protected void saveProperties() throws IOException
      Throws:
      IOException
    • getName

      public String getName()
      Description copied from interface: Project
      The name of the project.
      Specified by:
      getName in interface Project
      Returns:
      project name
    • setName

      public void setName(String name)
      Description copied from interface: Project
      Set project name
      Specified by:
      setName in interface Project
      Parameters:
      name - must match pattern '[ \w\d-]+'
    • getUUID

      public UUID getUUID()
      Description copied from interface: Project
      Project UUID UUID for the project
      Specified by:
      getUUID in interface Project
      Returns:
      uuid
    • setUUID

      public void setUUID(UUID uuid)
      Description copied from interface: Project
      Set project UUID
      Specified by:
      setUUID in interface Project
    • getCorpora

      public List<String> getCorpora()
      Description copied from interface: Project
      Get the list of corpora in this project. Corpus names are returned in alphabetical order.
      Specified by:
      getCorpora in interface Project
      Returns:
      list of corpora
    • addCorpus

      public void addCorpus(String name, String description) throws IOException
      Description copied from interface: Project
      Add a new corpus with the specified name.
      Specified by:
      addCorpus in interface Project
      Throws:
      IOException - if the corpus could not be created
    • renameCorpus

      public void renameCorpus(String corpus, String newName) throws IOException
      Description copied from interface: Project
      Rename a corpus
      Specified by:
      renameCorpus in interface Project
      Throws:
      IOException - if the corpus could not be renamed
    • removeCorpus

      public void removeCorpus(String corpus) throws IOException
      Description copied from interface: Project
      Delete the specified corpus and all sessions it contains.
      Specified by:
      removeCorpus in interface Project
      Throws:
      IOException - if the corpus could not be deleted
    • getCorpusDescription

      public String getCorpusDescription(String corpus)
      Description copied from interface: Project
      Get the description of the specified corpus.
      Specified by:
      getCorpusDescription in interface Project
      Parameters:
      corpus - the corpus name
    • setCorpusDescription

      public void setCorpusDescription(String corpus, String description)
      Description copied from interface: Project
      Set the description for the specified corpus.
      Specified by:
      setCorpusDescription in interface Project
    • hasCustomProjectMediaFolder

      public boolean hasCustomProjectMediaFolder()
      Description copied from interface: Project
      Has a custom project media folder been assigned
      Specified by:
      hasCustomProjectMediaFolder in interface Project
      Returns:
      true if project folder has been customized
    • getProjectMediaFolder

      public String getProjectMediaFolder()
      Description copied from interface: Project
      Get media folder for the project.
      Specified by:
      getProjectMediaFolder in interface Project
    • setProjectMediaFolder

      public void setProjectMediaFolder(String mediaFolder)
      Description copied from interface: Project
      Set media folder for project.
      Specified by:
      setProjectMediaFolder in interface Project
      Parameters:
      mediaFolder - If null sets the media folder back to default.
    • hasCustomCorpusMediaFolder

      public boolean hasCustomCorpusMediaFolder(String corpus)
      Description copied from interface: Project
      Has a custom corpus media folder been assigned
      Specified by:
      hasCustomCorpusMediaFolder in interface Project
      Returns:
      true if a custom media folder is assigned for the given corpus
    • getCorpusMediaFolder

      public String getCorpusMediaFolder(String corpus)
      Description copied from interface: Project
      Get the media folder for the specified corpus.
      Specified by:
      getCorpusMediaFolder in interface Project
      Returns:
      mediaFolder or the project media folder if not specified
    • setCorpusMediaFolder

      public void setCorpusMediaFolder(String corpus, String mediaFolder)
      Description copied from interface: Project
      Set the media folder for the specified corpus.
      Specified by:
      setCorpusMediaFolder in interface Project
    • getCorpusSessions

      public List<String> getCorpusSessions(String corpus)
      Description copied from interface: Project
      Get the session names contained in a corpus in alphabetical order.
      Specified by:
      getCorpusSessions in interface Project
      Returns:
      the list of sessions in the specified corpus
    • getCorpusFolder

      public File getCorpusFolder(String corpus)
    • getSessionFile

      public File getSessionFile(String corpus, String session)
    • openSession

      public Session openSession(String corpus, String session) throws IOException
      Description copied from interface: Project
      Open the specified session. This will create a new session object with the data currently on the storage device.
      Specified by:
      openSession in interface Project
      Returns:
      the session
      Throws:
      IOException
    • openSession

      public Session openSession(String corpus, String session, SessionReader reader) throws IOException
      Description copied from interface: Project
      Open specified session using the provided reader.
      Specified by:
      openSession in interface Project
      Returns:
      the session
      Throws:
      IOException
    • getSessionWriteLock

      public UUID getSessionWriteLock(Session session) throws IOException
      Description copied from interface: Project
      Get a write lock for a session. Before writing a write lock must be obtained from the project.
      Specified by:
      getSessionWriteLock in interface Project
      Returns:
      the session write lock or invalid input: '<' 0 if a write lock was not obtained
      Throws:
      IOException
    • getSessionWriteLock

      public UUID getSessionWriteLock(String corpus, String session) throws IOException
      Description copied from interface: Project
      Get a write lock for a session. Before writing a write lock must be obtained from the project.
      Specified by:
      getSessionWriteLock in interface Project
      Returns:
      the session write lock or null
      Throws:
      IOException
    • checkSessionWriteLock

      protected void checkSessionWriteLock(String corpus, String session, UUID writeLock) throws IOException
      Checks given session write lock
      Throws:
      IOException - if the write lock is not valid
    • releaseSessionWriteLock

      public void releaseSessionWriteLock(Session session, UUID writeLock) throws IOException
      Description copied from interface: Project
      Release the write lock for a session.
      Specified by:
      releaseSessionWriteLock in interface Project
      Throws:
      IOException
    • releaseSessionWriteLock

      public void releaseSessionWriteLock(String corpus, String session, UUID writeLock) throws IOException
      Description copied from interface: Project
      Release the write lock for a session.
      Specified by:
      releaseSessionWriteLock in interface Project
      Throws:
      IOException
    • saveSession

      public void saveSession(Session session, UUID writeLock) throws IOException
      Description copied from interface: Project
      Save a session
      Specified by:
      saveSession in interface Project
      Throws:
      IOException
    • saveSession

      public void saveSession(String corpus, String sessionName, Session session, UUID writeLock) throws IOException
      Description copied from interface: Project
      Save a session to the specified corpus and new sessionName.
      Specified by:
      saveSession in interface Project
      Throws:
      IOException
    • saveSession

      public void saveSession(String corpus, String sessionName, Session session, SessionWriter writer, UUID writeLock) throws IOException
      Description copied from interface: Project
      Save a session writing the file using the given writer.
      Specified by:
      saveSession in interface Project
      Throws:
      IOException
    • removeSession

      public void removeSession(Session session, UUID writeLock) throws IOException
      Description copied from interface: Project
      Remove a session from the project. The writeLock for the session is also released.
      Specified by:
      removeSession in interface Project
      Throws:
      IOException
    • removeSession

      public void removeSession(String corpus, String session, UUID writeLock) throws IOException
      Description copied from interface: Project
      Remove a session from the project. The writeLock for the session is also released.
      Specified by:
      removeSession in interface Project
      Throws:
      IOException
    • getResourceInputStream

      public InputStream getResourceInputStream(String resourceName) throws IOException
      Description copied from interface: Project
      Get an input stream for the specified project resource. The resource name should be a relative path including filename. E.g., 'ca.phon.myplugin/module/corpus/session.dat'
      Specified by:
      getResourceInputStream in interface Project
      Returns:
      an input stream for the specified resource
      Throws:
      IOException
    • getResourceOutputStream

      public OutputStream getResourceOutputStream(String resourceName) throws IOException
      Description copied from interface: Project
      Get an output stream for the specified resource. If the resource does not exist it is created. If the resource already exists it is overwritten.
      Specified by:
      getResourceOutputStream in interface Project
      Returns:
      output stream for the specified resource
      Throws:
      IOException
    • getSessionModificationTime

      public ZonedDateTime getSessionModificationTime(Session session)
      Description copied from interface: Project
      Returns the modification date for the given session
      Specified by:
      getSessionModificationTime in interface Project
      Returns:
      session modification date in system time zone
    • getSessionModificationTime

      public ZonedDateTime getSessionModificationTime(String corpus, String session)
      Description copied from interface: Project
      Returns the modification date for the specified session.
      Specified by:
      getSessionModificationTime in interface Project
      Returns:
      session modification date in system time zone
    • getSessionByteSize

      public long getSessionByteSize(Session session)
      Description copied from interface: Project
      Returns the size on disk for the given session.
      Specified by:
      getSessionByteSize in interface Project
      Returns:
      session size in bytes
    • getSessionByteSize

      public long getSessionByteSize(String corpus, String session)
      Description copied from interface: Project
      Returns the size on disk for the given session.
      Specified by:
      getSessionByteSize in interface Project
      Returns:
      session size in bytes
    • numberOfRecordsInSession

      public int numberOfRecordsInSession(String corpus, String session) throws IOException
      Description copied from interface: Project
      Returns the number of records in a session w/o opening the session. This method is faster than using openSession(corpus, session).numberOfRecords()
      Specified by:
      numberOfRecordsInSession in interface Project
      Returns:
      number of records in the session
      Throws:
      IOException
    • getParticipants

      public Set<Participant> getParticipants(Collection<SessionPath> sessions)
      Description copied from interface: Project
      Return a set of participants which are found in the given collection of Sessions. The participant objects returned by this method will include the ParticipantHistory extension. Participants from two sessions are considered to be the same if their ids, names and roles match. If the speaker for some records is unidenified, a clone of Participant.UNKOWN will be added in the returned set.
      Specified by:
      getParticipants in interface Project
      Returns:
      a set of participants
    • isSessionLocked

      public boolean isSessionLocked(Session session)
      Description copied from interface: Project
      Tells whether the given session is locked
      Specified by:
      isSessionLocked in interface Project
      Returns:
      true if session is locked, false otherwise
    • isSessionLocked

      public boolean isSessionLocked(String corpus, String session)
      Description copied from interface: Project
      Tells wheater the given session is locked
      Specified by:
      isSessionLocked in interface Project
      Returns:
      true if the session is locked, false otherwise
    • getVersion

      public String getVersion()
      Description copied from interface: Project
      Project version
      Specified by:
      getVersion in interface Project
      Returns:
      the project version or 'unk' if not known
    • getLocation

      public String getLocation()
      Description copied from interface: Project
      The location of the project.
      Specified by:
      getLocation in interface Project
      Returns:
      the project location
    • getCorpusPath

      public String getCorpusPath(String corpus)
      Description copied from interface: Project
      Return the path to the given corpus.
      Specified by:
      getCorpusPath in interface Project
    • setCorpusPath

      public void setCorpusPath(String corpus, String path)
      Description copied from interface: Project
      Set path of corpus.
      Specified by:
      setCorpusPath in interface Project
    • getSessionPath

      public String getSessionPath(Session session)
      Description copied from interface: Project
      Get path to the given session.
      Specified by:
      getSessionPath in interface Project
      Returns:
      path to given session
    • getSessionPath

      public String getSessionPath(String corpus, String session)
      Description copied from interface: Project
      Get path to the given session.
      Specified by:
      getSessionPath in interface Project
      Returns:
      path to given session
    • getSessionTemplate

      public Session getSessionTemplate(String corpus) throws IOException
      Description copied from interface: Project
      Get the Session template for the given corpus.
      Specified by:
      getSessionTemplate in interface Project
      Returns:
      session template or null if not found
      Throws:
      IOException
    • saveSessionTemplate

      public void saveSessionTemplate(String corpus, Session template) throws IOException
      Description copied from interface: Project
      Save the Session template for the given corpus.
      Specified by:
      saveSessionTemplate in interface Project
      Throws:
      IOException
    • createSessionFromTemplate

      public Session createSessionFromTemplate(String corpus, String session) throws IOException
      Description copied from interface: Project
      Create a new session from the corpus template (if it exists) This method will also add the session to the specified corpus.
      Specified by:
      createSessionFromTemplate in interface Project
      Returns:
      new Session object
      Throws:
      IOException
    • refresh

      public void refresh()
      Description copied from interface: ProjectRefresh
      Refresh the corpus/session information for a project.
      Specified by:
      refresh in interface ProjectRefresh
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getResourceLocation

      public String getResourceLocation()
      Description copied from interface: Project
      Get the location of the project resources folder.
      Specified by:
      getResourceLocation in interface Project
      Returns:
      location of the resources folder (default: project_folder/__res)
    • setResourceLocation

      public void setResourceLocation(String location)
      Description copied from interface: Project
      Set the location of the project resources folder.
      Specified by:
      setResourceLocation in interface Project