Package ca.phon.project
Interface Project
- All Superinterfaces:
IExtendable
- All Known Implementing Classes:
AbstractProject
,DesktopProject
,LocalProject
,RemoteProject
,ShadowProject
Interface for a phon project.
Projects are responsible for corpus and session
lists as well as managing serialization for
sessions.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a new corpus with the specified name.void
addProjectListener
(ProjectListener listener) createSessionFromTemplate
(String corpus, String session) Create a new session from the corpus template (if it exists) This method will also add the session to the specified corpus.void
void
void
Get the list of corpora in this project.getCorpusDescription
(String corpus) Get the description of the specified corpus.getCorpusMediaFolder
(String corpus) Get the media folder for the specified corpus.getCorpusPath
(String corpus) Return the path to the given corpus.getCorpusSessions
(String corpus) Get the session names contained in a corpus in alphabetical order.The location of the project.getName()
The name of the project.getParticipants
(Collection<SessionPath> sessions) Return a set of participants which are found in the given collection of Sessions.Get media folder for the project.getResourceInputStream
(String resourceName) Get an input stream for the specified project resource.Get the location of the project resources folder.getResourceOutputStream
(String resourceName) Get an output stream for the specified resource.long
getSessionByteSize
(Session session) Returns the size on disk for the given session.long
getSessionByteSize
(String corpus, String session) Returns the size on disk for the given session.getSessionModificationTime
(Session session) Returns the modification date for the given sessiongetSessionModificationTime
(String corpus, String session) Returns the modification date for the specified session.getSessionPath
(Session session) Get path to the given session.getSessionPath
(String corpus, String session) Get path to the given session.getSessionTemplate
(String corpus) Get the Session template for the given corpus.getSessionWriteLock
(Session session) Get a write lock for a session.getSessionWriteLock
(String corpus, String session) Get a write lock for a session.getUUID()
Project UUID UUID for the projectProject versionboolean
hasCustomCorpusMediaFolder
(String corpus) Has a custom corpus media folder been assignedboolean
Has a custom project media folder been assignedboolean
isSessionLocked
(Session session) Tells whether the given session is lockedboolean
isSessionLocked
(String corpus, String session) Tells wheater the given session is lockedint
numberOfRecordsInSession
(String corpus, String session) Returns the number of records in a session w/o opening the session.openSession
(String corpus, String session) Open the specified session.openSession
(String corpus, String session, SessionReader reader) Open specified session using the provided reader.void
releaseSessionWriteLock
(Session session, UUID writeLock) Release the write lock for a session.void
releaseSessionWriteLock
(String corpus, String session, UUID writeLock) Release the write lock for a session.void
removeCorpus
(String corpus) Delete the specified corpus and all sessions it contains.void
removeProjectListener
(ProjectListener listener) void
removeSession
(Session session, UUID writeLock) Remove a session from the project.void
removeSession
(String corpus, String session, UUID writeLock) Remove a session from the project.void
renameCorpus
(String corpus, String newName) Rename a corpusvoid
saveSession
(Session session, UUID writeLock) Save a sessionvoid
saveSession
(String corpus, String sessionName, Session session, SessionWriter writer, UUID writeLock) Save a session writing the file using the given writer.void
saveSession
(String corpus, String sessionName, Session session, UUID writeLock) Save a session to the specified corpus and new sessionName.void
saveSessionTemplate
(String corpus, Session template) Save the Session template for the given corpus.void
setCorpusDescription
(String corpus, String description) Set the description for the specified corpus.void
setCorpusMediaFolder
(String corpus, String mediaFolder) Set the media folder for the specified corpus.void
setCorpusPath
(String corpus, String path) Set path of corpus.void
Set project namevoid
setProjectMediaFolder
(String mediaFolder) Set media folder for project.void
setResourceLocation
(String location) Set the location of the project resources folder.void
Set project UUIDMethods inherited from interface ca.phon.extensions.IExtendable
getExtension, getExtensions, putExtension, removeExtension
-
Method Details
-
getProjectListeners
List<ProjectListener> getProjectListeners() -
addProjectListener
-
removeProjectListener
-
fireProjectStructureChanged
-
fireProjectDataChanged
-
fireProjectWriteLocksChanged
-
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
Set project name- Parameters:
name
- must match pattern '[ \w\d-]+'
-
getUUID
UUID getUUID()Project UUID UUID for the project- Returns:
- uuid
-
setUUID
Set project UUID- Parameters:
uuid
-
-
getCorpora
Get the list of corpora in this project. Corpus names are returned in alphabetical order.- Returns:
- list of corpora
-
addCorpus
Add a new corpus with the specified name.- Parameters:
name
-description
-- Throws:
IOException
- if the corpus could not be created
-
renameCorpus
Rename a corpus- Parameters:
corpus
-newName
-- Throws:
IOException
- if the corpus could not be renamed
-
removeCorpus
Delete the specified corpus and all sessions it contains.- Parameters:
corpus
-- Throws:
IOException
- if the corpus could not be deleted
-
getCorpusDescription
Get the description of the specified corpus.- Parameters:
corpus
- the corpus name
-
setCorpusDescription
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
Set media folder for project.- Parameters:
mediaFolder
- Ifnull
sets the media folder back to default.
-
hasCustomCorpusMediaFolder
Has a custom corpus media folder been assigned- Parameters:
corpus
-- Returns:
true
if a custom media folder is assigned for the given corpus
-
getCorpusMediaFolder
Get the media folder for the specified corpus.- Returns:
- mediaFolder or the project media folder if not specified
-
setCorpusMediaFolder
Set the media folder for the specified corpus.- Parameters:
mediaFolder
-
-
getSessionTemplate
Get the Session template for the given corpus.- Parameters:
corpus
-- Returns:
- session template or
null
if not found - Throws:
IOException
-
saveSessionTemplate
Save the Session template for the given corpus.- Parameters:
corpus
-template
-- Throws:
IOException
-
createSessionFromTemplate
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
Get the session names contained in a corpus in alphabetical order.- Parameters:
corpus
-- Returns:
- the list of sessions in the specified corpus
-
getCorpusPath
Return the path to the given corpus.- Parameters:
corpus
-
-
setCorpusPath
Set path of corpus.- Parameters:
corpus
-path
-
-
numberOfRecordsInSession
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
Return a set of participants which are found in the given collection of Sessions. The participant objects returned by this method will include theParticipantHistory
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
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
Open specified session using the provided reader.- Parameters:
corpus
-session
-reader
-- Returns:
- the session
- Throws:
IOException
-
getSessionPath
Get path to the given session.- Parameters:
session
-- Returns:
- path to given session
-
getSessionPath
Get path to the given session.- Parameters:
corpus
-session
-- Returns:
- path to given session
-
getSessionWriteLock
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
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
Release the write lock for a session.- Parameters:
session
-writeLock
-- Throws:
IOException
-
releaseSessionWriteLock
Release the write lock for a session.- Parameters:
session
-writeLock
-- Throws:
IOException
-
isSessionLocked
Tells whether the given session is locked- Parameters:
session
-- Returns:
true
if session is locked,false
otherwise
-
isSessionLocked
Tells wheater the given session is locked- Parameters:
corpus
-session
-- Returns:
true
if the session is locked,false
otherwise
-
saveSession
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
Remove a session from the project. The writeLock for the session is also released.- Parameters:
session
-writeLock
-- Throws:
IOException
-
removeSession
Remove a session from the project. The writeLock for the session is also released.- Parameters:
session
-writeLock
-- Throws:
IOException
-
getSessionModificationTime
Returns the modification date for the given session- Parameters:
session
-- Returns:
- session modification date in system time zone
-
getSessionModificationTime
Returns the modification date for the specified session.- Parameters:
corpus
-session
-- Returns:
- session modification date in system time zone
-
getSessionByteSize
Returns the size on disk for the given session.- Parameters:
session
-- Returns:
- session size in bytes
-
getSessionByteSize
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
Set the location of the project resources folder.- Parameters:
location
-
-
getResourceInputStream
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
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
-