Interface MutableProject

All Known Implementing Classes:
DesktopProject, LocalProject, ShadowProject

public interface MutableProject
Interface for Project mutability. This is an extension for Projects which allow modification of the project data.
  • Method Details

    • setName

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

      void setUUID(UUID uuid)
      Set project UUID
      Parameters:
      uuid - UUID for the project
    • addCorpus

      void addCorpus(String name) throws IOException
      Add corpus folder with given name
      Parameters:
      name - the name of the corpus
      Throws:
      IOException
    • addCorpus

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

      void renameCorpus(String corpus, String newName) throws IOException
      Rename a corpus
      Parameters:
      corpus - the corpus to rename
      newName - the new name for the corpus
      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 - the corpus to delete
      Throws:
      IOException - if the corpus could not be deleted
    • setCorpusDescription

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

      SessionWriteLock getSessionWriteLock(Session session) throws IOException
      Get a write lock for a session. Before writing a write lock must be obtained from the project. Example:
           try(SessionWriteLock writeLock = project.getSessionWriteLock(session)) {
            // do some work with the session
           } catch (IOException e) {
            // handle exception
           }
       
      Parameters:
      session - the session to lock
      Returns:
      the session write lock or invalid input: '<' 0 if a write lock was not obtained
      Throws:
      IOException
    • getSessionWriteLock

      SessionWriteLock 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. See getSessionWriteLock(Session) for more information on how to use the write lock.
      Parameters:
      corpus - the corpus name
      session - the session to lock
      Returns:
      the session write lock or null
      Throws:
      IOException
    • releaseSessionWriteLock

      void releaseSessionWriteLock(Session session, SessionWriteLock writeLock) throws IOException
      Release the write lock for a session. See getSessionWriteLock(Session) for more information on how to use the write lock.
      Parameters:
      session - the session to unlock
      writeLock - the write lock to release
      Throws:
      IOException
    • releaseSessionWriteLock

      void releaseSessionWriteLock(String corpus, String session, SessionWriteLock writeLock) throws IOException
      Release the write lock for a session. See releaseSessionWriteLock(Session, SessionWriteLock) for more information on how to use the write lock.
      Parameters:
      session - the session to unlock
      writeLock - the write lock to release
      Throws:
      IOException
    • isSessionLocked

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

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

      void saveSession(Session session, SessionWriteLock writeLock) throws IOException
      Save a session with the provided writeLock. Example:
           try(SessionWriteLock writeLock = project.getSessionWriteLock(session)) {
            project.saveSession(session, writeLock);
           } catch (IOException e) {
            // handle exception
           }
           
      The write lock is auto-closeable and will be released when the try block is exited. To manually release the write lock, call the releaseSessionWriteLock(Session, SessionWriteLock) method or use the close() method on the write lock.
      Parameters:
      session - the session to save
      writeLock - the write lock for the session
      Throws:
      IOException
    • saveSession

      void saveSession(String corpus, String sessionName, Session session, SessionWriteLock writeLock) throws IOException
      Save a session to the specified corpus and new sessionName. See saveSession(Session, SessionWriteLock) for more information on how to use the write lock.
      Parameters:
      corpus - the corpus name
      sessionName - the name of the session
      session - the session to save
      writeLock - the write lock for the session
      Throws:
      IOException
    • saveSession

      void saveSession(String corpus, String sessionName, Session session, SessionWriter writer, SessionWriteLock writeLock) throws IOException
      Save a session writing the file using the given writer. See saveSession(Session, SessionWriteLock) for more information on how to use the write lock.
      Parameters:
      corpus - the corpus name
      sessionName - the name of the session
      session - the session to save
      writer - the session writer to use
      writeLock - the write lock for the session
      Throws:
      IOException
    • removeSession

      void removeSession(Session session, SessionWriteLock writeLock) throws IOException
      Remove a session from the project. The writeLock for the session is also released. See removeSession(Session, SessionWriteLock) for more information on how to use the write lock.
      Parameters:
      session - the session to remove
      writeLock - the write lock for the session
      Throws:
      IOException
    • removeSession

      void removeSession(String corpus, String session, SessionWriteLock writeLock) throws IOException
      Remove a session from the project. The writeLock for the session is also released. See removeSession(Session, SessionWriteLock) for more information on how to use the write lock.
      Parameters:
      session - the session to remove
      writeLock - the write lock for the session
      Throws:
      IOException