Package ca.phon.project
Class LocalProject
java.lang.Object
ca.phon.project.AbstractProject
ca.phon.project.LocalProject
- All Implemented Interfaces:
IExtendable
,Project
,ProjectRefresh
- Direct Known Subclasses:
DesktopProject
,ShadowProject
A local on-disk project
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class ca.phon.project.AbstractProject
PROJECT_XML_FILE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a new corpus with the specified name.protected void
checkSessionWriteLock
(String corpus, String session, UUID writeLock) Checks given session write lockcreateSessionFromTemplate
(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.Get the list of corpora in this project.getCorpusDescription
(String corpus) Get the description of the specified corpus.getCorpusFolder
(String 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.getSessionFile
(String corpus, String 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
refresh()
Refresh the corpus/session information for a project.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
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 corpusprotected void
Save project dataprotected void
void
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 UUIDtoString()
Methods inherited from class ca.phon.project.AbstractProject
addProjectListener, fireProjectDataChanged, fireProjectStructureChanged, fireProjectWriteLocksChanged, getExtension, getExtensions, getProjectListeners, loadProjectData, putExtension, removeExtension, removeProjectListener
-
Field Details
-
PREV_PROJECT_PROPERTIES_FILE
- See Also:
-
PROJECT_PROPERTIES_FILE
- See Also:
-
PROJECT_MEDIAFOLDER_PROP
- See Also:
-
CORPUS_MEDIAFOLDER_PROP
- See Also:
-
PROJECT_NAME_PROP
- See Also:
-
PROJECT_UUID_PROP
- See Also:
-
-
Constructor Details
-
LocalProject
- Parameters:
projectFolder
-- Throws:
ProjectConfigurationException
-
-
Method Details
-
saveProjectData
Save project data- Throws:
IOException
-
saveProperties
- Throws:
IOException
-
getName
Description copied from interface:Project
The name of the project. -
setName
Description copied from interface:Project
Set project name -
getUUID
Description copied from interface:Project
Project UUID UUID for the project -
setUUID
Description copied from interface:Project
Set project UUID -
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 interfaceProject
- Returns:
- list of corpora
-
addCorpus
Description copied from interface:Project
Add a new corpus with the specified name.- Specified by:
addCorpus
in interfaceProject
- Throws:
IOException
- if the corpus could not be created
-
renameCorpus
Description copied from interface:Project
Rename a corpus- Specified by:
renameCorpus
in interfaceProject
- Throws:
IOException
- if the corpus could not be renamed
-
removeCorpus
Description copied from interface:Project
Delete the specified corpus and all sessions it contains.- Specified by:
removeCorpus
in interfaceProject
- Throws:
IOException
- if the corpus could not be deleted
-
getCorpusDescription
Description copied from interface:Project
Get the description of the specified corpus.- Specified by:
getCorpusDescription
in interfaceProject
- Parameters:
corpus
- the corpus name
-
setCorpusDescription
Description copied from interface:Project
Set the description for the specified corpus.- Specified by:
setCorpusDescription
in interfaceProject
-
hasCustomProjectMediaFolder
public boolean hasCustomProjectMediaFolder()Description copied from interface:Project
Has a custom project media folder been assigned- Specified by:
hasCustomProjectMediaFolder
in interfaceProject
- Returns:
true
if project folder has been customized
-
getProjectMediaFolder
Description copied from interface:Project
Get media folder for the project.- Specified by:
getProjectMediaFolder
in interfaceProject
-
setProjectMediaFolder
Description copied from interface:Project
Set media folder for project.- Specified by:
setProjectMediaFolder
in interfaceProject
- Parameters:
mediaFolder
- Ifnull
sets the media folder back to default.
-
hasCustomCorpusMediaFolder
Description copied from interface:Project
Has a custom corpus media folder been assigned- Specified by:
hasCustomCorpusMediaFolder
in interfaceProject
- Returns:
true
if a custom media folder is assigned for the given corpus
-
getCorpusMediaFolder
Description copied from interface:Project
Get the media folder for the specified corpus.- Specified by:
getCorpusMediaFolder
in interfaceProject
- Returns:
- mediaFolder or the project media folder if not specified
-
setCorpusMediaFolder
Description copied from interface:Project
Set the media folder for the specified corpus.- Specified by:
setCorpusMediaFolder
in interfaceProject
-
getCorpusSessions
Description copied from interface:Project
Get the session names contained in a corpus in alphabetical order.- Specified by:
getCorpusSessions
in interfaceProject
- Returns:
- the list of sessions in the specified corpus
-
getCorpusFolder
-
getSessionFile
-
openSession
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 interfaceProject
- Returns:
- the session
- Throws:
IOException
-
openSession
Description copied from interface:Project
Open specified session using the provided reader.- Specified by:
openSession
in interfaceProject
- Returns:
- the session
- Throws:
IOException
-
getSessionWriteLock
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 interfaceProject
- Returns:
- the session write lock or invalid input: '<' 0 if a write lock was not obtained
- Throws:
IOException
-
getSessionWriteLock
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 interfaceProject
- 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
Description copied from interface:Project
Release the write lock for a session.- Specified by:
releaseSessionWriteLock
in interfaceProject
- 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 interfaceProject
- Throws:
IOException
-
saveSession
Description copied from interface:Project
Save a session- Specified by:
saveSession
in interfaceProject
- 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 interfaceProject
- 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 interfaceProject
- Throws:
IOException
-
removeSession
Description copied from interface:Project
Remove a session from the project. The writeLock for the session is also released.- Specified by:
removeSession
in interfaceProject
- Throws:
IOException
-
removeSession
Description copied from interface:Project
Remove a session from the project. The writeLock for the session is also released.- Specified by:
removeSession
in interfaceProject
- Throws:
IOException
-
getResourceInputStream
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 interfaceProject
- Returns:
- an input stream for the specified resource
- Throws:
IOException
-
getResourceOutputStream
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 interfaceProject
- Returns:
- output stream for the specified resource
- Throws:
IOException
-
getSessionModificationTime
Description copied from interface:Project
Returns the modification date for the given session- Specified by:
getSessionModificationTime
in interfaceProject
- Returns:
- session modification date in system time zone
-
getSessionModificationTime
Description copied from interface:Project
Returns the modification date for the specified session.- Specified by:
getSessionModificationTime
in interfaceProject
- Returns:
- session modification date in system time zone
-
getSessionByteSize
Description copied from interface:Project
Returns the size on disk for the given session.- Specified by:
getSessionByteSize
in interfaceProject
- Returns:
- session size in bytes
-
getSessionByteSize
Description copied from interface:Project
Returns the size on disk for the given session.- Specified by:
getSessionByteSize
in interfaceProject
- Returns:
- session size in bytes
-
numberOfRecordsInSession
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 interfaceProject
- Returns:
- number of records in the session
- Throws:
IOException
-
getParticipants
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 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.- Specified by:
getParticipants
in interfaceProject
- Returns:
- a set of participants
-
isSessionLocked
Description copied from interface:Project
Tells whether the given session is locked- Specified by:
isSessionLocked
in interfaceProject
- Returns:
true
if session is locked,false
otherwise
-
isSessionLocked
Description copied from interface:Project
Tells wheater the given session is locked- Specified by:
isSessionLocked
in interfaceProject
- Returns:
true
if the session is locked,false
otherwise
-
getVersion
Description copied from interface:Project
Project version- Specified by:
getVersion
in interfaceProject
- Returns:
- the project version or 'unk' if not known
-
getLocation
Description copied from interface:Project
The location of the project.- Specified by:
getLocation
in interfaceProject
- Returns:
- the project location
-
getCorpusPath
Description copied from interface:Project
Return the path to the given corpus.- Specified by:
getCorpusPath
in interfaceProject
-
setCorpusPath
Description copied from interface:Project
Set path of corpus.- Specified by:
setCorpusPath
in interfaceProject
-
getSessionPath
Description copied from interface:Project
Get path to the given session.- Specified by:
getSessionPath
in interfaceProject
- Returns:
- path to given session
-
getSessionPath
Description copied from interface:Project
Get path to the given session.- Specified by:
getSessionPath
in interfaceProject
- Returns:
- path to given session
-
getSessionTemplate
Description copied from interface:Project
Get the Session template for the given corpus.- Specified by:
getSessionTemplate
in interfaceProject
- Returns:
- session template or
null
if not found - Throws:
IOException
-
saveSessionTemplate
Description copied from interface:Project
Save the Session template for the given corpus.- Specified by:
saveSessionTemplate
in interfaceProject
- Throws:
IOException
-
createSessionFromTemplate
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 interfaceProject
- 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 interfaceProjectRefresh
-
toString
-
getResourceLocation
Description copied from interface:Project
Get the location of the project resources folder.- Specified by:
getResourceLocation
in interfaceProject
- Returns:
- location of the resources folder (default:
project_folder/__res
)
-
setResourceLocation
Description copied from interface:Project
Set the location of the project resources folder.- Specified by:
setResourceLocation
in interfaceProject
-