Class SqlGraphStore
- java.lang.Object
-
- nzilbb.labbcat.server.db.SqlGraphStore
-
- All Implemented Interfaces:
nzilbb.ag.GraphStore
,nzilbb.ag.GraphStoreQuery
- Direct Known Subclasses:
SqlGraphStoreAdministration
public class SqlGraphStore extends Object implements nzilbb.ag.GraphStore
Graph store that uses a relational database as its back end.- Author:
- Robert Fromont robert@fromont.net.nz
-
-
Constructor Summary
Constructors Constructor Description SqlGraphStore()
Default constructor.SqlGraphStore(String baseUrl, File files, String connectString, String databaseUser, String password, String storeUser)
Constructor with connection parameters.SqlGraphStore(String baseUrl, File files, Connection connection, String user)
Deprecated.SqlGraphStore(String baseUrl, File files, nzilbb.sql.ConnectionFactory db, String user)
Constructor with connection.SqlGraphStore(String baseUrl, Connection connection, String user)
Deprecated.SqlGraphStore(String baseUrl, nzilbb.sql.ConnectionFactory db, String user)
Constructor with connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String[]
aggregateMatchingAnnotations(String operation, String expression)
Identifies a list of annotations that match a particular pattern, and aggregates their labels.File
annotationDataFile(nzilbb.ag.Annotation annotation, nzilbb.ag.Graph graph, String mimeType)
Get the location of the annotation's data file, if any.long
countAnnotations(String id, String layerId, Integer maxOrdinal)
Gets the number of annotations on the given layer of the given transcript, but only those with an ordinal less than or equal to the given maximum.int
countMatchingAnnotations(String expression)
Counts the number of annotations that match a particular pattern.int
countMatchingParticipantIds(String expression)
Counts the number of participants that match a particular pattern.int
countMatchingTranscriptIds(String expression)
Counts the number of transcript IDs that match a particular pattern.String
createAnnotation(String id, String fromId, String toId, String layerId, String label, Integer confidence, String parentId)
Creates an annotation starting at fromId and ending at toId.int
deleteMatchingAnnotations(String expression)
Deletes all annotations that match a particular pattern.void
deleteMedia(String id, String fileName)
Delete a given media or document file.void
deleteParticipant(String id)
Deletes the given participant, and all associated meta-data.void
deleteTranscript(String id)
Deletes the given transcript, and all associated files.nzilbb.ag.serialize.GraphDeserializer
deserializerForFilesSuffix(String suffix)
Gets the deserializer for the given file suffix (extension).nzilbb.ag.serialize.GraphDeserializer
deserializerForMimeType(String mimeType)
Gets the deserializer for the given MIME type.void
destroyAnnotation(String id, String annotationId)
Destroys the annotation with the given ID.void
finalize()
Called when the object is garbage-collected.void
generateMissingMedia(String id)
Generates any media files that are not marked "on demand" and for which there are available conversions.nzilbb.ag.Anchor[]
getAnchors(String id, String[] anchorIds)
Gets the given anchors in the given transcript.nzilbb.ag.Annotation[]
getAnnotations(String id, String layerId, Integer maxOrdinal, Integer pageLength, Integer pageNumber)
Gets the annotations on the given layer of the given transcript, but only those with an ordinal less than or equal to the given maximum..nzilbb.ag.automation.Annotator
getAnnotator(String annotatorId)
Gets an instance of the annotator with the given ID.nzilbb.ag.automation.util.AnnotatorDescriptor
getAnnotatorDescriptor(String annotatorId)
Gets a descriptor of the annotator with the given ID.nzilbb.ag.automation.util.AnnotatorDescriptor[]
getAnnotatorDescriptors()
Lists descriptors of all annotators that are installed.File
getAnnotatorDir()
Returns the location of the annotators directory.String
getAnnotatorTaskParameters(String taskId)
Supplies the given task's parameter string.Map<String,String>
getAnnotatorTasks(String annotatorId)
Supplies a list of automation tasks for the identified annotator.nzilbb.ag.MediaFile[]
getAvailableMedia(String id)
List the media available for the given transcript.String
getBaseUrl()
Getter forbaseUrl
: URL prefix for file access.Connection
getConnection()
Getter forconnection
: Database connection.String[]
getCorpusIds()
Gets a list of corpus IDs.nzilbb.sql.ConnectionFactory
getDb()
Getter fordb
: Factory for generating connections to the database.nzilbb.ag.serialize.SerializationDescriptor[]
getDeserializerDescriptors()
Lists the descriptors of all registered deserializers.HashMap<String,nzilbb.ag.serialize.GraphDeserializer>
getDeserializersByMimeType()
Getter fordeserializersByMimeType
: Registered deserializers, keyed by MIME type.HashMap<String,nzilbb.ag.serialize.GraphDeserializer>
getDeserializersBySuffix()
Getter fordeserializersBySuffix
: Registered deserializers, keyed by file suffix (extension).boolean
getDisconnectWhenFinished()
Getter fordisconnectWhenFinished
: Whether to disconnect the connection when garbage collected.nzilbb.ag.MediaFile[]
getEpisodeDocuments(String id)
Get a list of documents associated with the episode of the given transcript.File
getFiles()
Getter forfiles
: Root directory for file structure.nzilbb.ag.Graph
getFragment(String transcriptId, double start, double end, String[] layerIds)
Gets a fragment of a transcript, given its ID and the start/end offsets that define the desired fragment, and containing only the given layers.nzilbb.ag.Graph
getFragment(String transcriptId, String annotationId)
Gets a fragment of a transcript, given its ID and the ID of an annotation in it that defines the desired fragment.nzilbb.ag.Graph
getFragment(String transcriptId, String annotationId, String[] layerIds)
Gets a fragment of a transcript, given its ID and the ID of an annotation in it that defines the desired fragment, and containing only the given layers.nzilbb.util.MonitorableSeries<nzilbb.ag.Graph>
getFragmentSeries(String seriesId, String[] layerIds)
Gets a series of fragments, given the series' ID, and only the given layers.String
getId()
GraphStore method and getter forid
: The store's ID.nzilbb.ag.Layer
getLayer(String id)
Gets a layer definition.String[]
getLayerIds()
Gets a list of layer IDs (annotation 'types').nzilbb.ag.Layer[]
getLayers()
Gets a list of layer definitions.void
getMatchAnnotations(Iterator<String> matchIds, String[] layerIds, int targetOffset, int annotationsPerLayer, Consumer<nzilbb.ag.Annotation[]> consumer)
Gets the annotations on given layers for a set of match IDs.void
getMatchAnnotations(Iterator<String> matchIds, Map<String,Integer> layerIdToMaxAnnotations, Set<String> anchorStartLayers, Set<String> anchorEndLayers, int targetOffset, Consumer<nzilbb.ag.Annotation[]> consumer)
Gets the annotations on given layers for a set of match IDs.nzilbb.ag.Annotation[]
getMatchingAnnotations(String expression, Integer pageLength, Integer pageNumber)
Gets a list of annotations that match a particular pattern.nzilbb.ag.Annotation[]
getMatchingAnnotations(String expression, Integer pageLength, Integer pageNumber, boolean setGraph)
Gets a list of annotations that match a particular pattern.String[]
getMatchingParticipantIds(String expression)
Gets a list of IDs of participants that match a particular pattern.String[]
getMatchingParticipantIds(String expression, Integer pageLength, Integer pageNumber)
Gets a list of IDs of participants that match a particular pattern.String[]
getMatchingTranscriptIds(String expression, Integer pageLength, Integer pageNumber, String order)
Gets a list of IDs of transcripts that match a particular pattern.String
getMedia(String id, String trackSuffix, String mimeType)
Gets a given media track for a given transcript.String
getMedia(String id, String trackSuffix, String mimeType, Double startOffset, Double endOffset)
Gets a given media track for a given was not found in the store..nzilbb.ag.MediaTrackDefinition[]
getMediaTracks()
List the predefined media tracks available for transcripts.nzilbb.ag.Annotation
getParticipant(String id, String[] layerIds)
Gets the participant record specified by the given identifier.String[]
getParticipantIds()
Gets a list of participant IDs.Boolean
getPermissionsSpecified()
Getter forpermissionsSpecified
: Whether transcript-access permissions are specified (i.e.nzilbb.ag.Schema
getSchema()
Gets the layer schema.nzilbb.ag.serialize.SerializationDescriptor[]
getSerializerDescriptors()
Lists the descriptors of all registered serializers.HashMap<String,nzilbb.ag.serialize.GraphSerializer>
getSerializersByMimeType()
Getter forserializersByMimeType
: Registered serializers, keyed by MIME type.HashMap<String,nzilbb.ag.serialize.GraphSerializer>
getSerializersBySuffix()
Getter forserializersBySuffix
: Registered serializers, keyed by file suffix (extension).File
getSerializersDirectory()
Getter forserializersDirectory
: Root directory for serializers.String
getSource(String id)
Gets the source file for the given transcript.String
getSystemAttribute(String name)
Gets the value of a system attribute.nzilbb.ag.automation.Transcriber
getTranscriber(String transcriberId)
Gets an instance of the transcriber with the given ID.nzilbb.ag.automation.util.AnnotatorDescriptor
getTranscriberDescriptor(String transcriberId)
Gets a descriptor of the transcriber with the given ID.nzilbb.ag.automation.util.AnnotatorDescriptor[]
getTranscriberDescriptors()
Lists descriptors of all transcribers that are installed.nzilbb.ag.Graph
getTranscript(String id)
Gets a transcript given its ID.nzilbb.ag.Graph
getTranscript(String id, String[] layerIds)
Gets a transcript given its ID, containing only the given layers.String[]
getTranscriptIds()
Gets a list of transcript IDs.String[]
getTranscriptIdsInCorpus(String id)
Gets a list of transcript IDs in the given corpus.String[]
getTranscriptIdsWithParticipant(String id)
Gets a list of IDs of transcripts that include the given participant.String
getUser()
Getter foruser
: ID of the user querying the store.HashSet<String>
getUserRoles()
Getter foruserRoles
: Roles the user fulfills.nzilbb.ag.MediaFile
saveEpisodeDocument(String id, String url)
Saves the given document for the episode of the given transcript.nzilbb.ag.MediaFile
saveMedia(String id, String mediaUrl, String trackSuffix)
Saves the given media for the given transcript.boolean
saveParticipant(nzilbb.ag.Annotation participant)
Saves a participant, and all its tags, to the database.void
saveSource(String id, String url)
Saves the given source file for the given transcript.boolean
saveTranscript(nzilbb.ag.Graph transcript)
Saves the given transcript.nzilbb.ag.serialize.GraphSerializer
serializerForFilesSuffix(String suffix)
Gets the serializer for the given file suffix (extension).nzilbb.ag.serialize.GraphSerializer
serializerForMimeType(String mimeType)
Gets the serializer for the given MIME type.SqlGraphStore
setBaseUrl(String newBaseUrl)
Setter forbaseUrl
: URL prefix for file access.SqlGraphStore
setConnection(Connection newConnection)
Setter forconnection
: Database connection.SqlGraphStore
setDb(nzilbb.sql.ConnectionFactory newDb)
Setter fordb
: Factory for generating connections to the database.SqlGraphStore
setDeserializersByMimeType(HashMap<String,nzilbb.ag.serialize.GraphDeserializer> newDeserializersByMimeType)
Setter fordeserializersByMimeType
: Registered deserializers, keyed by MIME type.SqlGraphStore
setDeserializersBySuffix(HashMap<String,nzilbb.ag.serialize.GraphDeserializer> newDeserializersBySuffix)
Setter fordeserializersBySuffix
: Registered deserializers, keyed by file suffix (extension).SqlGraphStore
setDisconnectWhenFinished(boolean newDisconnectWhenFinished)
Setter fordisconnectWhenFinished
: Whether to disconnect the connection when garbage collected.SqlGraphStore
setFiles(File newFiles)
Setter forfiles
: Root directory for file structure.SqlGraphStore
setId(String newId)
Setter forid
: The store's ID.SqlGraphStore
setSerializersByMimeType(HashMap<String,nzilbb.ag.serialize.GraphSerializer> newSerializersByMimeType)
Setter forserializersByMimeType
: Registered serializers, keyed by MIME type.SqlGraphStore
setSerializersBySuffix(HashMap<String,nzilbb.ag.serialize.GraphSerializer> newSerializersBySuffix)
Setter forserializersBySuffix
: Registered serializers, keyed by file suffix (extension).SqlGraphStore
setSerializersDirectory(File newSerializersDirectory)
Setter forserializersDirectory
: Root directory for serializers.SqlGraphStore
setUser(String newUser)
Setter foruser
: ID of the user querying the store.int
tagMatchingAnnotations(String expression, String layerId, String label, Integer confidence)
Identifies a list of annotations that match a particular pattern, and tags them on the given layer with the given label.String
urlForAnnotationFile(nzilbb.ag.Annotation annotation, nzilbb.ag.Graph graph, String mimeType)
Returns a URL for the given annotation.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface nzilbb.ag.GraphStoreQuery
countAnnotations, countMatchingGraphIds, getAnnotations, getAnnotations, getAnnotations, getGraph, getGraph, getGraphIds, getGraphIdsInCorpus, getGraphIdsWithParticipant, getMatchingAnnotations, getMatchingGraphIds, getMatchingGraphIds, getMatchingGraphIds, getMatchingTranscriptIds, getMatchingTranscriptIds, getParticipant
-
-
-
-
Constructor Detail
-
SqlGraphStore
public SqlGraphStore()
Default constructor.
-
SqlGraphStore
@Deprecated public SqlGraphStore(String baseUrl, Connection connection, String user) throws SQLException
Deprecated.Constructor with connection.- Parameters:
baseUrl
- URL prefix for file access.connection
- An opened database connection.user
- ID of the user- Throws:
SQLException
-
SqlGraphStore
@Deprecated public SqlGraphStore(String baseUrl, File files, Connection connection, String user) throws SQLException
Deprecated.Constructor with connection.- Parameters:
baseUrl
- URL prefix for file access.files
- Root directory for file structure.connection
- An opened database connection.user
- ID of the user- Throws:
SQLException
-
SqlGraphStore
public SqlGraphStore(String baseUrl, nzilbb.sql.ConnectionFactory db, String user) throws SQLException
Constructor with connection.- Parameters:
baseUrl
- URL prefix for file access.db
- A database connection factory.user
- ID of the user- Throws:
SQLException
-
SqlGraphStore
public SqlGraphStore(String baseUrl, File files, nzilbb.sql.ConnectionFactory db, String user) throws SQLException
Constructor with connection.- Parameters:
baseUrl
- URL prefix for file access.files
- Root directory for file structure.db
- A database connection factory.user
- ID of the user- Throws:
SQLException
-
SqlGraphStore
public SqlGraphStore(String baseUrl, File files, String connectString, String databaseUser, String password, String storeUser) throws SQLException
Constructor with connection parameters.- Parameters:
baseUrl
- URL prefix for file access.files
- Root directory for file structure.connectString
- The database connection string.databaseUser
- The database username.password
- The databa password.storeUser
- ID of the user- Throws:
SQLException
- If an error occurs during connection.
-
-
Method Detail
-
getBaseUrl
public String getBaseUrl()
Getter forbaseUrl
: URL prefix for file access.- Returns:
- URL prefix for file access.
-
setBaseUrl
public SqlGraphStore setBaseUrl(String newBaseUrl)
Setter forbaseUrl
: URL prefix for file access.- Parameters:
newBaseUrl
- URL prefix for file access.
-
getFiles
public File getFiles()
Getter forfiles
: Root directory for file structure.- Returns:
- Root directory for file structure.
-
setFiles
public SqlGraphStore setFiles(File newFiles)
Setter forfiles
: Root directory for file structure.- Parameters:
newFiles
- Root directory for file structure.
-
getAnnotatorDir
public File getAnnotatorDir()
Returns the location of the annotators directory.- Returns:
- The annotator installation directory.
-
getConnection
public Connection getConnection()
Getter forconnection
: Database connection.- Returns:
- Database connection.
-
setConnection
public SqlGraphStore setConnection(Connection newConnection)
Setter forconnection
: Database connection.- Parameters:
newConnection
- Database connection.
-
getDb
public nzilbb.sql.ConnectionFactory getDb()
Getter fordb
: Factory for generating connections to the database.- Returns:
- Factory for generating connections to the database.
-
setDb
public SqlGraphStore setDb(nzilbb.sql.ConnectionFactory newDb) throws SQLException
Setter fordb
: Factory for generating connections to the database.- Parameters:
newDb
- Factory for generating connections to the database.- Throws:
SQLException
-
getPermissionsSpecified
public Boolean getPermissionsSpecified()
Getter forpermissionsSpecified
: Whether transcript-access permissions are specified (i.e. there are rows in role_permission).- Returns:
- Whether transcript-access permissions are specified (i.e. there are rows in role_permission).
-
getDisconnectWhenFinished
public boolean getDisconnectWhenFinished()
Getter fordisconnectWhenFinished
: Whether to disconnect the connection when garbage collected.- Returns:
- Whether to disconnect the connection when garbage collected.
-
setDisconnectWhenFinished
public SqlGraphStore setDisconnectWhenFinished(boolean newDisconnectWhenFinished)
Setter fordisconnectWhenFinished
: Whether to disconnect the connection when garbage collected.- Parameters:
newDisconnectWhenFinished
- Whether to disconnect the connection when garbage collected.
-
getId
public String getId() throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
GraphStore method and getter forid
: The store's ID.- Specified by:
getId
in interfacenzilbb.ag.GraphStoreQuery
- Returns:
- The store's ID.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
setId
public SqlGraphStore setId(String newId)
Setter forid
: The store's ID.- Parameters:
newId
- The store's ID.
-
getUser
public String getUser()
Getter foruser
: ID of the user querying the store.- Returns:
- ID of the user querying the store.
-
setUser
public SqlGraphStore setUser(String newUser)
Setter foruser
: ID of the user querying the store.- Parameters:
newUser
- ID of the user querying the store.
-
getUserRoles
public HashSet<String> getUserRoles()
Getter foruserRoles
: Roles the user fulfills.- Returns:
- Roles the user fulfills.
-
finalize
public void finalize()
Called when the object is garbage-collected.
-
getLayerIds
public String[] getLayerIds() throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets a list of layer IDs (annotation 'types').- Specified by:
getLayerIds
in interfacenzilbb.ag.GraphStoreQuery
- Returns:
- A list of layer IDs.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getLayers
public nzilbb.ag.Layer[] getLayers() throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets a list of layer definitions.- Specified by:
getLayers
in interfacenzilbb.ag.GraphStoreQuery
- Returns:
- A list of layer definitions.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getSchema
public nzilbb.ag.Schema getSchema() throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets the layer schema. For performance reasons, this implementation only retrieves/builds the schema once, and always returns a clone of that original object.- Specified by:
getSchema
in interfacenzilbb.ag.GraphStoreQuery
- Returns:
- A schema defining the layers and how they relate to each other.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getLayer
public nzilbb.ag.Layer getLayer(String id) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets a layer definition.- Specified by:
getLayer
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
id
- ID of the layer to get the definition for.- Returns:
- The definition of the given layer.
LaBB-CAT extends the
Layer.validLabels
funcionality by supporting an alternative layer attribute: validLabelsDefinition, which is an array of label definitions, each definition being a map of string to string or integer. Each label definition is expected to have the following attributes:- label
- what the underlying label is in LaBB-CAT (i.e. the DISC label, for a DISC layer)
- display
- the symbol in the transcript, for the label (e.g. the IPA version of the label)
- selector
- the symbol on the label helper, for the label (e.g. the IPA version of the label) - if there's no selector specified, then the value for display is used, and if there's no value for display specified, then there's no option on the label helper (so that type-able consonants like p, b, t, d etc. don't take up space on the label helper)
- description
- tool-tip text that appears if you hover the mouse over the IPA symbol in the helper
- category
- the broad category of the symbol, for organizing the layout of the helper
- subcategory
- the narrower category of the symbol, for listing subgroups of symbols together
- display_order
- the order to process/list the labels in
validLabelsDefinition is returned if there is a hierarchical set of options defined. Either way, validLabels (specifying the valid labels and their 'display' values) is always returned.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getCorpusIds
public String[] getCorpusIds() throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets a list of corpus IDs.- Specified by:
getCorpusIds
in interfacenzilbb.ag.GraphStoreQuery
- Returns:
- A list of corpus IDs.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getParticipantIds
public String[] getParticipantIds() throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets a list of participant IDs.- Specified by:
getParticipantIds
in interfacenzilbb.ag.GraphStoreQuery
- Returns:
- A list of participant IDs.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getParticipant
public nzilbb.ag.Annotation getParticipant(String id, String[] layerIds) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets the participant record specified by the given identifier.- Specified by:
getParticipant
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
id
- The ID of the participant, which could be their name or their database annotation ID.layerIds
- The IDs of the participant attribute layers to load, or null if only participant data is required.- Returns:
- An annotation representing the participant, or null if the participant was not found.
- Throws:
nzilbb.ag.StoreException
nzilbb.ag.PermissionException
-
saveParticipant
public boolean saveParticipant(nzilbb.ag.Annotation participant) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Saves a participant, and all its tags, to the database. The participant is represented by an Annotation that isn't assumed to be part of a graph.If a participant with the corresponding ID does not exist, a new participant record is created.
- Specified by:
saveParticipant
in interfacenzilbb.ag.GraphStore
- Parameters:
participant
-- Returns:
- true if changes were saved, false if there were no changes to save.
- Throws:
nzilbb.ag.StoreException
- If an error prevents the participant from being saved.nzilbb.ag.PermissionException
- If saving the participant is not permitted.
-
getTranscriptIds
public String[] getTranscriptIds() throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets a list of transcript IDs.- Specified by:
getTranscriptIds
in interfacenzilbb.ag.GraphStoreQuery
- Returns:
- A list of transcript IDs.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getTranscriptIdsInCorpus
public String[] getTranscriptIdsInCorpus(String id) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets a list of transcript IDs in the given corpus.- Specified by:
getTranscriptIdsInCorpus
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
id
- A corpus ID.- Returns:
- A list of transcript IDs.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getTranscriptIdsWithParticipant
public String[] getTranscriptIdsWithParticipant(String id) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets a list of IDs of transcripts that include the given participant.- Specified by:
getTranscriptIdsWithParticipant
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
id
- A participant ID.- Returns:
- A list of transcript IDs.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
countMatchingParticipantIds
public int countMatchingParticipantIds(String expression) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Counts the number of participants that match a particular pattern.- Specified by:
countMatchingParticipantIds
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
expression
- An expression that determines which participants match.The expression language is loosely based on JavaScript; expressions such as the following can be used:
/Ada.+/.test(id)
labels('corpus').includes('CC')
labels('participant_languages').includes('en')
labels('transcript_language').includes('en')
!/Ada.+/.test(id) && first('corpus').label == 'CC'
all('transcript_rating').length > 2
all('participant_rating').length = 0
!annotators('transcript_rating').includes('labbcat')
first('participant_gender').label == 'NA'
- Returns:
- The number of matching participants.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getMatchingParticipantIds
public String[] getMatchingParticipantIds(String expression) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets a list of IDs of participants that match a particular pattern.- Specified by:
getMatchingParticipantIds
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
expression
- An expression that determines which participants match.The expression language is loosely based on JavaScript; expressions such as the following can be used:
/Ada.+/.test(id)
labels('corpus').includes('CC')
labels('participant_languages').includes('en')
labels('transcript_language').includes('en')
!/Ada.+/.test(id) && first('corpus').label == 'CC'
all('transcript_rating').length > 2
all('participant_rating').length = 0
!annotators('transcript_rating').includes('labbcat')
first('participant_gender').label == 'NA'
all('transcript').length == 0
- Returns:
- A list of participant IDs.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getMatchingParticipantIds
public String[] getMatchingParticipantIds(String expression, Integer pageLength, Integer pageNumber) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets a list of IDs of participants that match a particular pattern.- Specified by:
getMatchingParticipantIds
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
expression
- An expression that determines which participants match.The expression language is loosely based on JavaScript; expressions such as the following can be used:
/Ada.+/.test(id)
labels('corpus').includes('CC')
labels('participant_languages').includes('en')
labels('transcript_language').includes('en')
!/Ada.+/.test(id) && first('corpus').label == 'CC'
all('transcript_rating').length > 2
all('participant_rating').length = 0
!annotators('transcript_rating').includes('labbcat')
first('participant_gender').label == 'NA'
all('transcript').length == 0
pageLength
- The maximum number of IDs to return, or null to return all.pageNumber
- The page number to return, or null to return the first page.- Returns:
- A list of participant IDs.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
countMatchingTranscriptIds
public int countMatchingTranscriptIds(String expression) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Counts the number of transcript IDs that match a particular pattern.- Specified by:
countMatchingTranscriptIds
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
expression
- An expression that determines which transcripts match.The expression language is loosely based on JavaScript; expressions such as the following can be used:
/Ada.+/.test(id)
labels('participant').includes('Robert')
['CC', 'IA', 'MU'].includes(first('corpus').label)
first('episode').label == 'Ada Aitcheson'
first('transcript_scribe').label == 'Robert'
first('participant_languages').label == 'en'
first('noise').label == 'bell'
labels('transcript_languages').includes('en')
labels('participant_languages').includes('en')
labels('noise').includes('bell')
all('transcript_languages').length gt; 1
all('participant_languages').length gt; 1
all('word').length > 100
annotators('transcript_rating').includes('Robert')
!/Ada.+/.test(id) && first('corpus').label == 'CC' && labels('participant').includes('Robert')
- Returns:
- The number of matching transcripts.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getMatchingTranscriptIds
public String[] getMatchingTranscriptIds(String expression, Integer pageLength, Integer pageNumber, String order) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets a list of IDs of transcripts that match a particular pattern.- Specified by:
getMatchingTranscriptIds
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
expression
- An expression that determines which transcripts match.The expression language is loosely based on JavaScript; expressions such as the following can be used:
/Ada.+/.test(id)
labels('participant').includes('Robert')
['CC', 'IA', 'MU'].includes(first('corpus').label)
first('episode').label == 'Ada Aitcheson'
first('transcript_scribe').label == 'Robert'
first('participant_languages').label == 'en'
first('noise').label == 'bell'
labels('transcript_languages').includes('en')
labels('participant_languages').includes('en')
labels('noise').includes('bell')
all('transcript_languages').length gt; 1
all('participant_languages').length gt; 1
all('word').length > 100
annotators('transcript_rating').includes('Robert')
!/Ada.+/.test(id) && first('corpus').label == 'CC' && labels('participant').includes('Robert')
pageLength
- The maximum number of IDs to return, or null to return all.pageNumber
- The zero-based page number to return, or null to return the first page.order
- The ordering for the list of IDs, a string containing a comma-separated list of epxressions, which may be appended by " ASC" or " DESC", or null for transcript ID order.- Returns:
- A list of transcript IDs.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getTranscript
public nzilbb.ag.Graph getTranscript(String id) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Gets a transcript given its ID.- Specified by:
getTranscript
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
id
- The given transcript ID.- Returns:
- The identified transcript with annotations from all layers.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript was not found in the store.
-
getTranscript
public nzilbb.ag.Graph getTranscript(String id, String[] layerIds) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Gets a transcript given its ID, containing only the given layers.- Specified by:
getTranscript
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
id
- The given transcript ID.layerIds
- The IDs of the layers to load, or null if only transcript data is required.- Returns:
- The identified transcript.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript was not found in the store.
-
getFragment
public nzilbb.ag.Graph getFragment(String transcriptId, String annotationId) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Gets a fragment of a transcript, given its ID and the ID of an annotation in it that defines the desired fragment.The given annotation defines both the start and end anchors of the fragment, and also which annotations on descendant layers will be included. So the resulting fragment will include:
- the given defining annotation
- its parent annotation, and all ancestors, but their anchors are included only if the defining annotation t-includes the ancestor
- all descendants of the defining annotation or any of its ancestors, which are t-included by the defining annotation (but not annotations that the defining annotation t-includes but which aren't directly related, so in the case of simultaneous speech, only the words of the speaker of the defining utterance will be included, not words spoken by other speakers.
- Specified by:
getFragment
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
transcriptId
- The ID of the transcript.annotationId
- The ID of an annotation that defines the bounds of the fragment.- Returns:
- The identified transcript fragment.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript was not found in the store.
-
countAnnotations
public long countAnnotations(String id, String layerId, Integer maxOrdinal) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Gets the number of annotations on the given layer of the given transcript, but only those with an ordinal less than or equal to the given maximum.- Specified by:
countAnnotations
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
id
- The ID of the transcript.layerId
- The ID of the layer.maxOrdinal
- The maximum ordinal for the counted annotations. e.g. a maxOrdinal of 1 will ensure that only the first annotation for each parent is couned. If maxOrdinal is null, then all annotations are counted, regardless of their ordinal.- Returns:
- A (possibly empty) array of annotations.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript was not found in the store.
-
getAnnotations
public nzilbb.ag.Annotation[] getAnnotations(String id, String layerId, Integer maxOrdinal, Integer pageLength, Integer pageNumber) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Gets the annotations on the given layer of the given transcript, but only those with an ordinal less than or equal to the given maximum..- Specified by:
getAnnotations
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
id
- The ID of the transcript.layerId
- The ID of the layer.maxOrdinal
- The maximum ordinal for the returned annotations. e.g. a maxOrdinal of 1 will ensure that only the first annotation for each parent is returned. If maxOrdinal is null, then all annotations are returned, regardless of their ordinal.pageLength
- The maximum number of IDs to return, or null to return all.pageNumber
- The page number to return, or null to return the first page.- Returns:
- A (possibly empty) array of annotations.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript was not found in the store.
-
countMatchingAnnotations
public int countMatchingAnnotations(String expression) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Counts the number of annotations that match a particular pattern.- Specified by:
countMatchingAnnotations
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
expression
- An expression that determines which participants match.- Returns:
- The number of matching annotations.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getMatchingAnnotations
public nzilbb.ag.Annotation[] getMatchingAnnotations(String expression, Integer pageLength, Integer pageNumber) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets a list of annotations that match a particular pattern.- Specified by:
getMatchingAnnotations
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
expression
- An expression that determines which transcripts match.pageLength
- The maximum number of annotations to return, or null to return all.pageNumber
- The page number to return, or null to return the first page.- Returns:
- A list of matching
Annotation
s. - Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getMatchingAnnotations
public nzilbb.ag.Annotation[] getMatchingAnnotations(String expression, Integer pageLength, Integer pageNumber, boolean setGraph) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets a list of annotations that match a particular pattern.- Parameters:
expression
- An expression that determines which transcripts match.pageLength
- The maximum number of annotations to return, or null to return all.pageNumber
- The page number to return, or null to return the first page.setGraph
- true to include the graph of all returned annotations, false otherwise.- Returns:
- A list of matching
Annotation
s. - Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
aggregateMatchingAnnotations
public String[] aggregateMatchingAnnotations(String operation, String expression) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Identifies a list of annotations that match a particular pattern, and aggregates their labels.This allows for counting, listing distinct labels, etc.
- Specified by:
aggregateMatchingAnnotations
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
operation
- The aggregation operation(s) - e.g.- DISTINCT
- List the distinct labels (case/accent insensitive).
- DISTINCT BINARY
- List the distinct labels (case/accent sensitive).
- MAX
- Return the highest label.
- MIN
- Return the lowest label.
- COUNT
- Return the number of annotations.
- COUNT DISTINCT
- Return the number of distinct labels (case/accent insensitive).
- COUNT DISTINCT BINARY
- Return the number of distinct labels (case/accent sensitive).
expression
- An expression that determines which annotations match.The expression language is loosely based on JavaScript; expressions such as the following can be used:
layer.id == 'orthography'
graph.id == 'AdaAicheson-01.trs' && layer.id == 'orthography'
NB all expressions must match by either id or layer.id.
- Returns:
- A list of results. This may have a single element (e.g. when
operation ==
COUNT
), or may be a (long) list of labels (e.g. when operation ==DISTINCT
. If there are multiple operations then the array will contain a multiple of the number of matching annotations. (e.g. if operation ==DISTINCT,COUNT
then the array will have twice the number of elements as there are distinct words, even-indexed elements are the word labels, and odd-indexed elements are the counts.) - Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getMatchAnnotations
public void getMatchAnnotations(Iterator<String> matchIds, String[] layerIds, int targetOffset, int annotationsPerLayer, Consumer<nzilbb.ag.Annotation[]> consumer) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets the annotations on given layers for a set of match IDs.- Specified by:
getMatchAnnotations
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
matchIds
- An iterator that supplies match IDs - these may be the contents of the MatchId column in exported search results, token URLs, or annotation IDs.layerIds
- The layer IDs of the layers to get.targetOffset
- Which token to get the annotations of; 0 means the match target itself, 1 means the token after the target, -1 means the token before the target, etc.annotationsPerLayer
- The number of annotations per layer to get; if there's a smaller number of annotations available, the unfilled array elements will be null.consumer
- A consumer for handling the resulting annotations. Consumer.accept() will be invoked once for each element returned by the matchIds iterator, with an array ofAnnotation
objects. The size of this array will be layerIds.length * annotationsPerLayer, and will be filled in with the available annotations for each layer; when annotations are not available, null is supplied.- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getMatchAnnotations
public void getMatchAnnotations(Iterator<String> matchIds, Map<String,Integer> layerIdToMaxAnnotations, Set<String> anchorStartLayers, Set<String> anchorEndLayers, int targetOffset, Consumer<nzilbb.ag.Annotation[]> consumer) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets the annotations on given layers for a set of match IDs.- Parameters:
matchIds
- An iterator that supplies match IDs - these may be the contents of the MatchId column in exported search results, token URLs, or annotation IDs.layerIdToMaxAnnotations
- A map where the keys are the layer IDs of the layers to get, and each value is the maximum number of annotations to retrieve for that layer.anchorStartLayers
- A set of layer IDs identifying which layer annotations must share a start anchor with the target.anchorEndLayers
- A set of layer IDs identifying which layer annotations must share a end anchor with the target.targetOffset
- Which token to get the annotations of; 0 means the match target itself, 1 means the token after the target, -1 means the token before the target, etc.consumer
- A consumer for handling the resulting annotations. Consumer.accept() will be invoked once for each element returned by the matchIds iterator, with an array ofAnnotation
objects. The size of this array will be the sum of the values in layerIds, and will be filled in with the available annotations for each layer; when annotations are not available, null is supplied.- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
deleteMatchingAnnotations
public int deleteMatchingAnnotations(String expression) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Deletes all annotations that match a particular pattern.- Specified by:
deleteMatchingAnnotations
in interfacenzilbb.ag.GraphStore
- Parameters:
expression
- An expression that determines which annotations match.The expression language is loosely based on JavaScript; expressions such as the following can be used:
layer.id == 'pronunciation' && first('orthography').label == 'the'
first('language').label == 'en' && layer.id == 'pronunciation' && first('orthography').label == 'the'
NB all expressions must match by either id or layer.id.
- Returns:
- The number of new annotations deleted.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
tagMatchingAnnotations
public int tagMatchingAnnotations(String expression, String layerId, String label, Integer confidence) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Identifies a list of annotations that match a particular pattern, and tags them on the given layer with the given label. If the specified layer ID does not allow peers, all existing tags will be deleted. Otherwise, tagging does not affect any existing tags on the matching annotations.- Specified by:
tagMatchingAnnotations
in interfacenzilbb.ag.GraphStore
- Parameters:
expression
- An expression that determines which annotations match.The expression language is loosely based on JavaScript; expressions such as the following can be used:
layer.id == 'word' && label == 'foo'
first('language').label == 'en' && layer.id == 'orthography' && label == 'word'
NB all expressions must match by either id or layer.id.
layerId
- The layer ID of the resulting annotation.label
- The label of the resulting annotation.confidence
- The confidence rating.- Returns:
- The number of new annotations added.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getAnchors
public nzilbb.ag.Anchor[] getAnchors(String id, String[] anchorIds) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Gets the given anchors in the given transcript.- Specified by:
getAnchors
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
id
- The ID of the transcript.anchorIds
- An array of anchor IDs.- Returns:
- A (possibly empty) array of anchors.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript was not found in the store.
-
getFragment
public nzilbb.ag.Graph getFragment(String transcriptId, String annotationId, String[] layerIds) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Gets a fragment of a transcript, given its ID and the ID of an annotation in it that defines the desired fragment, and containing only the given layers.The given annotation defines both the start and end anchors of the fragment, and also which annotations on descendant layers will be included. So the resulting fragment will include:
- the given defining annotation
- its parent annotation, and all ancestors, but their anchors are included only if the defining annotation t-includes the ancestor
- all descendants of the defining annotation or any of its ancestors, in the given layers, which are t-included by the defining annotation (but not annotations from those layers that the defining annotation t-includes but which aren't directly related, so in the case of simultaneous speech, only the words of the speaker of the defining utterance will be included, not words spoken by other speakers.
Layer
definition appear in transcript'sSchema
, whether or not they're mentioned in the layerId list.- Specified by:
getFragment
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
transcriptId
- The ID of the transcript.annotationId
- The ID of an annotation that defines the bounds of the fragment.layerIds
- The IDs of the layers to load, or null if only transcript data is required.- Returns:
- The identified transcript fragment.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript was not found in the store.
-
getFragment
public nzilbb.ag.Graph getFragment(String transcriptId, double start, double end, String[] layerIds) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Gets a fragment of a transcript, given its ID and the start/end offsets that define the desired fragment, and containing only the given layers.- Specified by:
getFragment
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
transcriptId
- The ID of the transcript.start
- The start offset of the fragment.end
- The end offset of the fragment.layerIds
- The IDs of the layers to load, or null if only transcript data is required.- Returns:
- The identified transcript fragment.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript was not found in the store.
-
getFragmentSeries
public nzilbb.util.MonitorableSeries<nzilbb.ag.Graph> getFragmentSeries(String seriesId, String[] layerIds) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Gets a series of fragments, given the series' ID, and only the given layers.This implementation expects seriesId to be a current result.search_id.
The fragments are created lazily as required, so this method should return quickly.
- Specified by:
getFragmentSeries
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
seriesId
- The ID of the series.layerIds
- The IDs of the layers to load, or null if only transcript data is required.- Returns:
- An enumerable series of fragments.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.nzilbb.ag.GraphNotFoundException
- If the series identified by seriesId was not found in the store.
-
saveTranscript
public boolean saveTranscript(nzilbb.ag.Graph transcript) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Saves the given transcript. The graph can be partial e.g. include only some of the layers that the stored version of the transcript contains, or be a fragment.The graph deltas are assumed to be set correctly, so if this is a new transcript, then
Graph.getChange()
should return Change.Operation.Create, if it's an update, Change.Operation.Update, and to delete, Change.Operation.Delete. Correspondingly, allAnchor
s andAnnotation
s should have their changes set also. IfGraph.getChanges()
returns no changes, no action will be taken, and this method returns false.After this method has executed,
Graph.commit()
is not called - this must be done by the caller, if they want changes to be committed.- Specified by:
saveTranscript
in interfacenzilbb.ag.GraphStore
- Parameters:
transcript
- The transcript to save.- Returns:
- true if changes were saved, false if there were no changes to save.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript was not found in the store.
-
annotationDataFile
public File annotationDataFile(nzilbb.ag.Annotation annotation, nzilbb.ag.Graph graph, String mimeType) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Get the location of the annotation's data file, if any.Layers that have a MIME type as their type (e.g. "image/png") allow each annotation to represent binary data, which is implemented by storing it in the file system as a file. This method returns the location of that file, if it were to be present.
The location is structured: files/{corpus}/{episode}/{ext}/{transcript}/{layer}/{annotation.id}.{ext}
- Parameters:
annotation
- The annotation to determine the data file location of.graph
- Annotation graph with at least corpus and episode layers loaded.mimeType
- The layer's MIME type.- Returns:
- The location of the file containing the annotation's data, which may or may not exist.
- Throws:
nzilbb.ag.StoreException
nzilbb.ag.PermissionException
nzilbb.ag.GraphNotFoundException
-
urlForAnnotationFile
public String urlForAnnotationFile(nzilbb.ag.Annotation annotation, nzilbb.ag.Graph graph, String mimeType) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Returns a URL for the given annotation.- Parameters:
annotation
-graph
- Annotation graph with at least corpus and episode layers loaded.mimeType
- The layer's MIME type.- Returns:
- A URL to the file, which will be an http:// URL if
baseUrl
is set, and a file:// URL otherwise, but will be null if the annotation has no data file, or the user doesn't have access to the corresponding media. - Throws:
nzilbb.ag.StoreException
nzilbb.ag.PermissionException
nzilbb.ag.GraphNotFoundException
-
createAnnotation
public String createAnnotation(String id, String fromId, String toId, String layerId, String label, Integer confidence, String parentId) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Creates an annotation starting at fromId and ending at toId.- Specified by:
createAnnotation
in interfacenzilbb.ag.GraphStore
- Parameters:
id
- The ID of the transcript.fromId
- The start anchor's ID, which can be null if the layer is a tag layer.toId
- The end anchor's ID, which can be null if the layer is a tag layer.layerId
- The layer ID of the resulting annotation.label
- The label of the resulting annotation.confidence
- The confidence rating.parentId
- The new annotation's parent's ID.- Returns:
- The ID of the new annotation.
- Throws:
nzilbb.ag.StoreException
nzilbb.ag.PermissionException
nzilbb.ag.GraphNotFoundException
-
destroyAnnotation
public void destroyAnnotation(String id, String annotationId) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Destroys the annotation with the given ID.- Specified by:
destroyAnnotation
in interfacenzilbb.ag.GraphStore
- Parameters:
id
- The ID of the transcript.annotationId
- The annotation's ID.- Throws:
nzilbb.ag.StoreException
nzilbb.ag.PermissionException
nzilbb.ag.GraphNotFoundException
-
getMediaTracks
public nzilbb.ag.MediaTrackDefinition[] getMediaTracks() throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
List the predefined media tracks available for transcripts.- Specified by:
getMediaTracks
in interfacenzilbb.ag.GraphStoreQuery
- Returns:
- An ordered list of media track definitions.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getAvailableMedia
public nzilbb.ag.MediaFile[] getAvailableMedia(String id) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
List the media available for the given transcript.- Specified by:
getAvailableMedia
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
id
- The transcript ID.- Returns:
- List of media files available for the given transcript.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript was not found in the store.
-
getMedia
public String getMedia(String id, String trackSuffix, String mimeType) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Gets a given media track for a given transcript.- Specified by:
getMedia
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
id
- The transcript ID.trackSuffix
- The track suffix of the media - seeMediaTrackDefinition.suffix
.mimeType
- The MIME type of the media, which may include parameters for type conversion, e.g. "audio/wav; samplerate=16000".- Returns:
- A URL to the given media for the given transcript, or null if the given media doesn't exist.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript was not found in the store.
-
getMedia
public String getMedia(String id, String trackSuffix, String mimeType, Double startOffset, Double endOffset) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Gets a given media track for a given was not found in the store..- Specified by:
getMedia
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
id
- The transcript ID.trackSuffix
- The track suffix of the media - seeMediaTrackDefinition.suffix
.mimeType
- The MIME type of the media, which may include parameters for type conversion, e.g. "audio/wav; samplerate=16000"startOffset
- The start offset of the media sample, or null for the start of the whole recording.endOffset
- The end offset of the media sample, or null for the end of the whole recording.- Returns:
- A URL to the given media for the given transcript, or null if the given media doesn't exist.
- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript was not found in the store.
-
saveMedia
public nzilbb.ag.MediaFile saveMedia(String id, String mediaUrl, String trackSuffix) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Saves the given media for the given transcript.- Specified by:
saveMedia
in interfacenzilbb.ag.GraphStore
- Parameters:
id
- The transcript IDmediaUrl
- A URL to the media content. If this is a file: URL, the file will be moved rather than copied, if possible. Otherwise, the content will be downloaded.trackSuffix
- The track suffix of the media - seeMediaTrackDefinition.suffix
.- Throws:
nzilbb.ag.StoreException
- If an error prevents the media from being saved.nzilbb.ag.PermissionException
- If saving the media is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript doesn't exist.
-
saveSource
public void saveSource(String id, String url) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Saves the given source file for the given transcript.- Specified by:
saveSource
in interfacenzilbb.ag.GraphStore
- Parameters:
id
- The transcript IDurl
- A URL to the transcript.- Throws:
nzilbb.ag.StoreException
- If an error prevents the media from being saved.nzilbb.ag.PermissionException
- If saving the media is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript doesn't exist.
-
getSource
public String getSource(String id) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Gets the source file for the given transcript.- Parameters:
id
- The transcript ID- Returns:
- A URL to the transcript.
- Throws:
nzilbb.ag.StoreException
- If an error prevents the media from being saved.nzilbb.ag.PermissionException
- If saving the media is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript doesn't exist.
-
saveEpisodeDocument
public nzilbb.ag.MediaFile saveEpisodeDocument(String id, String url) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Saves the given document for the episode of the given transcript.- Specified by:
saveEpisodeDocument
in interfacenzilbb.ag.GraphStore
- Parameters:
id
- The transcript IDurl
- A URL to the document.- Throws:
nzilbb.ag.StoreException
- If an error prevents the media from being saved.nzilbb.ag.PermissionException
- If saving the media is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript doesn't exist.
-
getEpisodeDocuments
public nzilbb.ag.MediaFile[] getEpisodeDocuments(String id) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Get a list of documents associated with the episode of the given transcript.- Specified by:
getEpisodeDocuments
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
id
- The transcript ID.- Returns:
- List of document files/URLs.
- Throws:
nzilbb.ag.StoreException
- If an error prevents the media from being saved.nzilbb.ag.PermissionException
- If saving the media is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript doesn't exist.
-
deleteMedia
public void deleteMedia(String id, String fileName) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Delete a given media or document file.- Specified by:
deleteMedia
in interfacenzilbb.ag.GraphStore
- Parameters:
id
- The associated transcript ID.fileName
- The media file name, e.g.MediaFile.name
.- Throws:
nzilbb.ag.StoreException
nzilbb.ag.PermissionException
nzilbb.ag.GraphNotFoundException
-
generateMissingMedia
public void generateMissingMedia(String id) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Generates any media files that are not marked "on demand" and for which there are available conversions.This implementation starts conversion processes, and returns immediately, so new files may not exist immediately after the method returns.
- Parameters:
id
- The transcript ID.- Throws:
nzilbb.ag.StoreException
- If an error occurs.nzilbb.ag.PermissionException
- If the operation is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript was not found in the store.
-
deleteTranscript
public void deleteTranscript(String id) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Deletes the given transcript, and all associated files.- Specified by:
deleteTranscript
in interfacenzilbb.ag.GraphStore
- Parameters:
id
- The ID transcript to delete.- Throws:
nzilbb.ag.StoreException
- If an error prevents the transcript from being saved.nzilbb.ag.PermissionException
- If saving the transcript is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript doesn't exist.
-
deleteParticipant
public void deleteParticipant(String id) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException, nzilbb.ag.GraphNotFoundException
Deletes the given participant, and all associated meta-data.- Specified by:
deleteParticipant
in interfacenzilbb.ag.GraphStore
- Parameters:
id
- The ID participant to delete.- Throws:
nzilbb.ag.StoreException
- If an error prevents the transcript from being saved.nzilbb.ag.PermissionException
- If saving the transcript is not permitted.nzilbb.ag.GraphNotFoundException
- If the transcript doesn't exist.
-
getSystemAttribute
public String getSystemAttribute(String name) throws SQLException
Gets the value of a system attribute.- Parameters:
name
- Attribute name.- Returns:
- The value of the system attribute, or null if there is no value.
- Throws:
SQLException
-
getSerializersDirectory
public File getSerializersDirectory()
Getter forserializersDirectory
: Root directory for serializers.- Returns:
- Root directory for serializers.
-
setSerializersDirectory
public SqlGraphStore setSerializersDirectory(File newSerializersDirectory)
Setter forserializersDirectory
: Root directory for serializers.- Parameters:
newSerializersDirectory
- Root directory for serializers.
-
getDeserializersByMimeType
public HashMap<String,nzilbb.ag.serialize.GraphDeserializer> getDeserializersByMimeType()
Getter fordeserializersByMimeType
: Registered deserializers, keyed by MIME type.- Returns:
- Registered deserializers, keyed by MIME type.
-
setDeserializersByMimeType
public SqlGraphStore setDeserializersByMimeType(HashMap<String,nzilbb.ag.serialize.GraphDeserializer> newDeserializersByMimeType)
Setter fordeserializersByMimeType
: Registered deserializers, keyed by MIME type.- Parameters:
newDeserializersByMimeType
- Registered deserializers, keyed by MIME type.
-
getDeserializersBySuffix
public HashMap<String,nzilbb.ag.serialize.GraphDeserializer> getDeserializersBySuffix()
Getter fordeserializersBySuffix
: Registered deserializers, keyed by file suffix (extension).- Returns:
- Registered deserializers, keyed by file suffix (extension).
-
setDeserializersBySuffix
public SqlGraphStore setDeserializersBySuffix(HashMap<String,nzilbb.ag.serialize.GraphDeserializer> newDeserializersBySuffix)
Setter fordeserializersBySuffix
: Registered deserializers, keyed by file suffix (extension).- Parameters:
newDeserializersBySuffix
- Registered deserializers, keyed by file suffix (extension).
-
getSerializersByMimeType
public HashMap<String,nzilbb.ag.serialize.GraphSerializer> getSerializersByMimeType()
Getter forserializersByMimeType
: Registered serializers, keyed by MIME type.- Returns:
- Registered serializers, keyed by MIME type.
-
setSerializersByMimeType
public SqlGraphStore setSerializersByMimeType(HashMap<String,nzilbb.ag.serialize.GraphSerializer> newSerializersByMimeType)
Setter forserializersByMimeType
: Registered serializers, keyed by MIME type.- Parameters:
newSerializersByMimeType
- Registered serializers, keyed by MIME type.
-
getSerializersBySuffix
public HashMap<String,nzilbb.ag.serialize.GraphSerializer> getSerializersBySuffix()
Getter forserializersBySuffix
: Registered serializers, keyed by file suffix (extension).- Returns:
- Registered serializers, keyed by file suffix (extension).
-
setSerializersBySuffix
public SqlGraphStore setSerializersBySuffix(HashMap<String,nzilbb.ag.serialize.GraphSerializer> newSerializersBySuffix)
Setter forserializersBySuffix
: Registered serializers, keyed by file suffix (extension).- Parameters:
newSerializersBySuffix
- Registered serializers, keyed by file suffix (extension).
-
getSerializerDescriptors
public nzilbb.ag.serialize.SerializationDescriptor[] getSerializerDescriptors() throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Lists the descriptors of all registered serializers.Serializers are modules that export annotation structures as a specific file format, e.g. Praat TextGrid, plain text, etc.
- Specified by:
getSerializerDescriptors
in interfacenzilbb.ag.GraphStoreQuery
- Returns:
- A list of the descriptors of all registered serializers.
- Throws:
nzilbb.ag.StoreException
- If an error prevents the operation from completing.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getDeserializerDescriptors
public nzilbb.ag.serialize.SerializationDescriptor[] getDeserializerDescriptors() throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Lists the descriptors of all registered deserializers.Deserializers are modules that import annotation structures from a specific file format, e.g. Praat TextGrid, plain text, etc.
- Specified by:
getDeserializerDescriptors
in interfacenzilbb.ag.GraphStoreQuery
- Returns:
- A list of the descriptors of all registered deserializers.
- Throws:
nzilbb.ag.StoreException
- If an error prevents the descriptors from being listed.nzilbb.ag.PermissionException
- If listing the deserializers is not permitted.
-
getAnnotatorDescriptors
public nzilbb.ag.automation.util.AnnotatorDescriptor[] getAnnotatorDescriptors()
Lists descriptors of all annotators that are installed.- Returns:
- A list of descriptors of all annotators that are installed.
-
getAnnotator
public nzilbb.ag.automation.Annotator getAnnotator(String annotatorId)
Gets an instance of the annotator with the given ID.- Parameters:
annotatorId
-- Returns:
- An instance of the given annotator, or null if there is no registered annotator with the given ID.
-
getAnnotatorDescriptor
public nzilbb.ag.automation.util.AnnotatorDescriptor getAnnotatorDescriptor(String annotatorId)
Gets a descriptor of the annotator with the given ID.- Parameters:
annotatorId
- The ID of the annotator.- Returns:
- A descriptor of the given annotator, or null if there is no registered annotator with the given ID.
-
getAnnotatorTasks
public Map<String,String> getAnnotatorTasks(String annotatorId) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Supplies a list of automation tasks for the identified annotator.- Parameters:
annotatorId
- The ID of the annotator.- Returns:
- A map of task IDs to descriptions.
- Throws:
nzilbb.ag.StoreException
- If an error prevents the operation.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getAnnotatorTaskParameters
public String getAnnotatorTaskParameters(String taskId) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Supplies the given task's parameter string.- Parameters:
taskId
- The ID of the automation task.- Returns:
- The task parameters, serialized as a string, or null if the taskId does not exist.
- Throws:
nzilbb.ag.StoreException
- If an error prevents the operation.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
getTranscriberDescriptors
public nzilbb.ag.automation.util.AnnotatorDescriptor[] getTranscriberDescriptors()
Lists descriptors of all transcribers that are installed.- Specified by:
getTranscriberDescriptors
in interfacenzilbb.ag.GraphStoreQuery
- Returns:
- A list of descriptors of all transcribers that are installed.
-
getTranscriber
public nzilbb.ag.automation.Transcriber getTranscriber(String transcriberId)
Gets an instance of the transcriber with the given ID.- Parameters:
transcriberId
-- Returns:
- An instance of the given transcriber, or null if there is no registered transcriber with the given ID.
-
getTranscriberDescriptor
public nzilbb.ag.automation.util.AnnotatorDescriptor getTranscriberDescriptor(String transcriberId)
Gets a descriptor of the transcriber with the given ID.- Parameters:
transcriberId
-- Returns:
- A descriptor of the given transcriber, or null if there is no registered transcriber with the given ID.
-
deserializerForMimeType
public nzilbb.ag.serialize.GraphDeserializer deserializerForMimeType(String mimeType) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets the deserializer for the given MIME type.- Specified by:
deserializerForMimeType
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
mimeType
- The MIME type.- Returns:
- The deserializer for the given MIME type, or null if none is registered.
- Throws:
nzilbb.ag.StoreException
- If an error prevents the operation from completing.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
deserializerForFilesSuffix
public nzilbb.ag.serialize.GraphDeserializer deserializerForFilesSuffix(String suffix) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets the deserializer for the given file suffix (extension).- Specified by:
deserializerForFilesSuffix
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
suffix
- The file extension.- Returns:
- The deserializer for the given suffix, or null if none is registered.
- Throws:
nzilbb.ag.StoreException
- If an error prevents the operation from completing.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
serializerForMimeType
public nzilbb.ag.serialize.GraphSerializer serializerForMimeType(String mimeType) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets the serializer for the given MIME type.- Specified by:
serializerForMimeType
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
mimeType
- The MIME type.- Returns:
- The serializer for the given MIME type, or null if none is registered.
- Throws:
nzilbb.ag.StoreException
- If an error prevents the operation from completing.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
serializerForFilesSuffix
public nzilbb.ag.serialize.GraphSerializer serializerForFilesSuffix(String suffix) throws nzilbb.ag.StoreException, nzilbb.ag.PermissionException
Gets the serializer for the given file suffix (extension).- Specified by:
serializerForFilesSuffix
in interfacenzilbb.ag.GraphStoreQuery
- Parameters:
suffix
- The file extension.- Returns:
- The serializer for the given suffix, or null if none is registered.
- Throws:
nzilbb.ag.StoreException
- If an error prevents the operation from completing.nzilbb.ag.PermissionException
- If the operation is not permitted.
-
-