Interface Project

All Superinterfaces:
IExtendable
All Known Implementing Classes:
AbstractProject, DesktopProject, LocalProject, RemoteProject, ShadowProject

public interface Project extends IExtendable
Interface for a phon project. Projects are responsible for corpus and session lists as well as managing serialization for sessions.
  • Method Details

    • getProjectListeners

      List<ProjectListener> getProjectListeners()
    • addProjectListener

      void addProjectListener(ProjectListener listener)
    • removeProjectListener

      void removeProjectListener(ProjectListener listener)
    • fireProjectStructureChanged

      void fireProjectStructureChanged(ProjectEvent pe)
    • fireProjectDataChanged

      void fireProjectDataChanged(ProjectEvent pe)
    • fireProjectWriteLocksChanged

      void fireProjectWriteLocksChanged(ProjectEvent pe)
    • getVersion

      String getVersion()
      Project version
      Returns:
      the project version or 'unk' if not known
    • getLocation

      String getLocation()
      The location of the project.
      Returns:
      the project location
    • getName

      String getName()
      The name of the project.
      Returns:
      project name
    • setName

      void setName(String name)
      Set project name
      Parameters:
      name - must match pattern '[ \w\d-]+'
    • getUUID

      UUID getUUID()
      Project UUID UUID for the project
      Returns:
      uuid
    • setUUID

      void setUUID(UUID uuid)
      Set project UUID
      Parameters:
      uuid -
    • getCorpora

      List<String> getCorpora()
      Get the list of corpora in this project. Corpus names are returned in alphabetical order.
      Returns:
      list of corpora
    • addCorpus

      void addCorpus(String name, String description) throws IOException
      Add a new corpus with the specified name.
      Parameters:
      name -
      description -
      Throws:
      IOException - if the corpus could not be created
    • renameCorpus

      void renameCorpus(String corpus, String newName) throws IOException
      Rename a corpus
      Parameters:
      corpus -
      newName -
      Throws:
      IOException - if the corpus could not be renamed
    • removeCorpus

      void removeCorpus(String corpus) throws IOException
      Delete the specified corpus and all sessions it contains.
      Parameters:
      corpus -
      Throws:
      IOException - if the corpus could not be deleted
    • getCorpusDescription

      String getCorpusDescription(String corpus)
      Get the description of the specified corpus.
      Parameters:
      corpus - the corpus name
    • setCorpusDescription

      void setCorpusDescription(String corpus, String description)
      Set the description for the specified corpus.
      Parameters:
      corpus -
      description -
    • hasCustomProjectMediaFolder

      boolean hasCustomProjectMediaFolder()
      Has a custom project media folder been assigned
      Returns:
      true if project folder has been customized
    • getProjectMediaFolder

      String getProjectMediaFolder()
      Get media folder for the project.
    • setProjectMediaFolder

      void setProjectMediaFolder(String mediaFolder)
      Set media folder for project.
      Parameters:
      mediaFolder - If null sets the media folder back to default.
    • hasCustomCorpusMediaFolder

      boolean hasCustomCorpusMediaFolder(String corpus)
      Has a custom corpus media folder been assigned
      Parameters:
      corpus -
      Returns:
      true if a custom media folder is assigned for the given corpus
    • getCorpusMediaFolder

      String getCorpusMediaFolder(String corpus)
      Get the media folder for the specified corpus.
      Returns:
      mediaFolder or the project media folder if not specified
    • setCorpusMediaFolder

      void setCorpusMediaFolder(String corpus, String mediaFolder)
      Set the media folder for the specified corpus.
      Parameters:
      mediaFolder -
    • getSessionTemplate

      Session getSessionTemplate(String corpus) throws IOException
      Get the Session template for the given corpus.
      Parameters:
      corpus -
      Returns:
      session template or null if not found
      Throws:
      IOException
    • saveSessionTemplate

      void saveSessionTemplate(String corpus, Session template) throws IOException
      Save the Session template for the given corpus.
      Parameters:
      corpus -
      template -
      Throws:
      IOException
    • createSessionFromTemplate

      Session createSessionFromTemplate(String corpus, String session) throws IOException
      Create a new session from the corpus template (if it exists) This method will also add the session to the specified corpus.
      Parameters:
      corpus -
      session -
      Returns:
      new Session object
      Throws:
      IOException
    • getCorpusSessions

      List<String> getCorpusSessions(String corpus)
      Get the session names contained in a corpus in alphabetical order.
      Parameters:
      corpus -
      Returns:
      the list of sessions in the specified corpus
    • getCorpusPath

      String getCorpusPath(String corpus)
      Return the path to the given corpus.
      Parameters:
      corpus -
    • setCorpusPath

      void setCorpusPath(String corpus, String path)
      Set path of corpus.
      Parameters:
      corpus -
      path -
    • numberOfRecordsInSession

      int numberOfRecordsInSession(String corpus, String session) throws IOException
      Returns the number of records in a session w/o opening the session. This method is faster than using openSession(corpus, session).numberOfRecords()
      Parameters:
      session -
      Returns:
      number of records in the session
      Throws:
      IOException
    • getParticipants

      Set<Participant> getParticipants(Collection<SessionPath> sessions)
      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.
      Parameters:
      sessions -
      Returns:
      a set of participants
    • openSession

      Session openSession(String corpus, String session) throws IOException
      Open the specified session. This will create a new session object with the data currently on the storage device.
      Parameters:
      corpus -
      session -
      Returns:
      the session
      Throws:
      IOException
    • openSession

      Session openSession(String corpus, String session, SessionReader reader) throws IOException
      Open specified session using the provided reader.
      Parameters:
      corpus -
      session -
      reader -
      Returns:
      the session
      Throws:
      IOException
    • getSessionPath

      String getSessionPath(Session session)
      Get path to the given session.
      Parameters:
      session -
      Returns:
      path to given session
    • getSessionPath

      String getSessionPath(String corpus, String session)
      Get path to the given session.
      Parameters:
      corpus -
      session -
      Returns:
      path to given session
    • getSessionWriteLock

      UUID getSessionWriteLock(Session session) throws IOException
      Get a write lock for a session. Before writing a write lock must be obtained from the project.
      Parameters:
      session -
      Returns:
      the session write lock or invalid input: '<' 0 if a write lock was not obtained
      Throws:
      IOException
    • getSessionWriteLock

      UUID getSessionWriteLock(String corpus, String session) throws IOException
      Get a write lock for a session. Before writing a write lock must be obtained from the project.
      Parameters:
      corpus -
      session -
      Returns:
      the session write lock or null
      Throws:
      IOException
    • releaseSessionWriteLock

      void releaseSessionWriteLock(Session session, UUID writeLock) throws IOException
      Release the write lock for a session.
      Parameters:
      session -
      writeLock -
      Throws:
      IOException
    • releaseSessionWriteLock

      void releaseSessionWriteLock(String corpus, String session, UUID writeLock) throws IOException
      Release the write lock for a session.
      Parameters:
      session -
      writeLock -
      Throws:
      IOException
    • isSessionLocked

      boolean isSessionLocked(Session session)
      Tells whether the given session is locked
      Parameters:
      session -
      Returns:
      true if session is locked, false otherwise
    • isSessionLocked

      boolean isSessionLocked(String corpus, String session)
      Tells wheater the given session is locked
      Parameters:
      corpus -
      session -
      Returns:
      true if the session is locked, false otherwise
    • saveSession

      void saveSession(Session session, UUID writeLock) throws IOException
      Save a session
      Parameters:
      session -
      writeLock -
      Throws:
      IOException
    • saveSession

      void saveSession(String corpus, String sessionName, Session session, UUID writeLock) throws IOException
      Save a session to the specified corpus and new sessionName.
      Parameters:
      corpus -
      sessionName -
      session -
      writeLock -
      Throws:
      IOException
    • saveSession

      void saveSession(String corpus, String sessionName, Session session, SessionWriter writer, UUID writeLock) throws IOException
      Save a session writing the file using the given writer.
      Parameters:
      corpus -
      sessionName -
      session -
      writer -
      writeLock -
      Throws:
      IOException
    • removeSession

      void removeSession(Session session, UUID writeLock) throws IOException
      Remove a session from the project. The writeLock for the session is also released.
      Parameters:
      session -
      writeLock -
      Throws:
      IOException
    • removeSession

      void removeSession(String corpus, String session, UUID writeLock) throws IOException
      Remove a session from the project. The writeLock for the session is also released.
      Parameters:
      session -
      writeLock -
      Throws:
      IOException
    • getSessionModificationTime

      ZonedDateTime getSessionModificationTime(Session session)
      Returns the modification date for the given session
      Parameters:
      session -
      Returns:
      session modification date in system time zone
    • getSessionModificationTime

      ZonedDateTime getSessionModificationTime(String corpus, String session)
      Returns the modification date for the specified session.
      Parameters:
      corpus -
      session -
      Returns:
      session modification date in system time zone
    • getSessionByteSize

      long getSessionByteSize(Session session)
      Returns the size on disk for the given session.
      Parameters:
      session -
      Returns:
      session size in bytes
    • getSessionByteSize

      long getSessionByteSize(String corpus, String session)
      Returns the size on disk for the given session.
      Parameters:
      corpus -
      session -
      Returns:
      session size in bytes
    • getResourceLocation

      String getResourceLocation()
      Get the location of the project resources folder.
      Returns:
      location of the resources folder (default: project_folder/__res)
    • setResourceLocation

      void setResourceLocation(String location)
      Set the location of the project resources folder.
      Parameters:
      location -
    • getResourceInputStream

      InputStream getResourceInputStream(String resourceName) throws IOException
      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'
      Parameters:
      resourceName -
      Returns:
      an input stream for the specified resource
      Throws:
      IOException
    • getResourceOutputStream

      OutputStream getResourceOutputStream(String resourceName) throws IOException
      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.
      Parameters:
      resourceName -
      Returns:
      output stream for the specified resource
      Throws:
      IOException