Class LabbcatAdmin

  • All Implemented Interfaces:
    nzilbb.ag.GraphStore, nzilbb.ag.GraphStoreAdministration, nzilbb.ag.GraphStoreQuery

    public class LabbcatAdmin
    extends LabbcatEdit
    implements nzilbb.ag.GraphStoreAdministration
    Client-side implementation of nzilbb.ag.GraphStoreAdminitration.

    This class inherits the read-write operations of LabbcatEdit and adds some administration operations, including definition of layers, registration of converters, etc., i.e. those that can be performed by users with admin permission.

    e.g.

     // create annotation store client
     LabbcatAdmin store = new LabbcatAdmin("https://labbcat.canterbury.ac.nz", "demo", "demo");
     // get some basic information
     String id = store.getId();
     String[] layers = store.getLayerIds();
     String[] corpora = store.getCorpusIds();
     String[] documents = store.getGraphIdsInCorpus(corpora[0]);
     // delete a document
     store.deleteGraph(documents[0]);
     
    Author:
    Robert Fromont robert@fromont.net.nz
    • Constructor Detail

      • LabbcatAdmin

        public LabbcatAdmin()
        Default constructor.
      • LabbcatAdmin

        public LabbcatAdmin​(String labbcatUrl)
                     throws MalformedURLException
        Constructor from string URL.
        Parameters:
        labbcatUrl - The base URL of the LaBB-CAT server - e.g. https://labbcat.canterbury.ac.nz/demo/
        Throws:
        MalformedURLException - If the URL is invalid.
      • LabbcatAdmin

        public LabbcatAdmin​(String labbcatUrl,
                            String username,
                            String password)
                     throws MalformedURLException
        Constructor with String attributes.
        Parameters:
        labbcatUrl - The base URL of the LaBB-CAT server - e.g. https://labbcat.canterbury.ac.nz/demo/
        username - LaBB-CAT username.
        password - LaBB-CAT password.
        Throws:
        MalformedURLException - If the URL is invalid.
      • LabbcatAdmin

        public LabbcatAdmin​(URL labbcatUrl)
        Constructor from URL.
        Parameters:
        labbcatUrl - The base URL of the LaBB-CAT server - e.g. https://labbcat.canterbury.ac.nz/demo/
      • LabbcatAdmin

        public LabbcatAdmin​(URL labbcatUrl,
                            String username,
                            String password)
        Constructor with attributes.
        Parameters:
        labbcatUrl - The base URL of the LaBB-CAT server - e.g. https://labbcat.canterbury.ac.nz/demo/
        username - LaBB-CAT username.
        password - LaBB-CAT password.
    • Method Detail

      • adminUrl

        public URL adminUrl​(String resource)
                     throws nzilbb.ag.StoreException
        Constructs a store URL for the given resource.
        Parameters:
        resource - The relative name of the resource.
        Returns:
        A URL for the given resource.
        Throws:
        nzilbb.ag.StoreException - If the URL is malformed.
      • registerDeserializer

        public void registerDeserializer​(nzilbb.ag.serialize.GraphDeserializer deserializer)
                                  throws nzilbb.ag.StoreException,
                                         nzilbb.ag.PermissionException
        NOT YET IMPLEMENTED - Registers a transcript deserializer.
        Specified by:
        registerDeserializer in interface nzilbb.ag.GraphStoreAdministration
        Parameters:
        deserializer - The deserializer to register.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
      • deregisterDeserializer

        public void deregisterDeserializer​(nzilbb.ag.serialize.GraphDeserializer deserializer)
                                    throws nzilbb.ag.StoreException,
                                           nzilbb.ag.PermissionException
        NOT YET IMPLEMENTED - De-registers a transcript deserializer.
        Specified by:
        deregisterDeserializer in interface nzilbb.ag.GraphStoreAdministration
        Parameters:
        deserializer - The deserializer to de-register.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
      • getDeserializerDescriptors

        public nzilbb.ag.serialize.SerializationDescriptor[] getDeserializerDescriptors()
                                                                                 throws nzilbb.ag.StoreException,
                                                                                        nzilbb.ag.PermissionException
        NOT YET IMPLEMENTED - Lists the descriptors of all registered deserializers.
        Specified by:
        getDeserializerDescriptors in interface nzilbb.ag.GraphStoreQuery
        Overrides:
        getDeserializerDescriptors in class LabbcatView
        Returns:
        A list of the descriptors of all registered deserializers.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
      • registerSerializer

        public void registerSerializer​(nzilbb.ag.serialize.GraphSerializer serializer)
                                throws nzilbb.ag.StoreException,
                                       nzilbb.ag.PermissionException
        NOT YET IMPLEMENTED - Registers a transcript serializer.
        Specified by:
        registerSerializer in interface nzilbb.ag.GraphStoreAdministration
        Parameters:
        serializer - The serializer to register.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
      • deregisterSerializer

        public void deregisterSerializer​(nzilbb.ag.serialize.GraphSerializer serializer)
                                  throws nzilbb.ag.StoreException,
                                         nzilbb.ag.PermissionException
        NOT YET IMPLEMENTED - De-registers a transcript serializer.
        Specified by:
        deregisterSerializer in interface nzilbb.ag.GraphStoreAdministration
        Parameters:
        serializer - The serializer to de-register.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
      • getSerializerDescriptors

        public nzilbb.ag.serialize.SerializationDescriptor[] getSerializerDescriptors()
                                                                               throws nzilbb.ag.StoreException,
                                                                                      nzilbb.ag.PermissionException
        NOT YET IMPLEMENTED - Lists the descriptors of all registered serializers.
        Specified by:
        getSerializerDescriptors in interface nzilbb.ag.GraphStoreQuery
        Overrides:
        getSerializerDescriptors in class LabbcatView
        Returns:
        A list of the descriptors of all registered serializers.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
      • newLayer

        public nzilbb.ag.Layer newLayer​(nzilbb.ag.Layer layer)
                                 throws nzilbb.ag.StoreException,
                                        nzilbb.ag.PermissionException
        Adds a new layer.
        Specified by:
        newLayer in interface nzilbb.ag.GraphStoreAdministration
        Parameters:
        layer - A new layer definition.
        Returns:
        The resulting layer definition.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
      • generateLayer

        public String generateLayer​(String layerId)
                             throws nzilbb.ag.StoreException,
                                    nzilbb.ag.PermissionException
        Generates annotations on a given layer for all transcripts in the corpus.
        Parameters:
        layerId - The ID of the layer to generate annotations for.
        Returns:
        The thread ID of the the running generation task.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
      • saveLayer

        public nzilbb.ag.Layer saveLayer​(nzilbb.ag.Layer layer)
                                  throws nzilbb.ag.StoreException,
                                         nzilbb.ag.PermissionException
        Saves changes to a layer.
        Specified by:
        saveLayer in interface nzilbb.ag.GraphStoreAdministration
        Parameters:
        layer - A modified layer definition.
        Returns:
        The resulting layer definition.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
      • deleteLayer

        public void deleteLayer​(String id)
                         throws nzilbb.ag.StoreException,
                                nzilbb.ag.PermissionException
        Deletes the given layer, and all associated annotations.
        Specified by:
        deleteLayer in interface nzilbb.ag.GraphStoreAdministration
        Parameters:
        id - The ID layer 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.
      • readCorpora

        public Corpus[] readCorpora​(Integer pageNumber,
                                    Integer pageLength)
                             throws nzilbb.ag.StoreException,
                                    nzilbb.ag.PermissionException
        Reads a list of corpus records.
        Parameters:
        pageNumber - The zero-based page of records to return (if null, all records will be returned).
        pageLength - The length of pages (if null, the default page length is 20).
        Returns:
        A list of corpora.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
        See Also:
        createCorpus(Corpus), readCorpora(), updateCorpus(Corpus), deleteCorpus(Corpus), deleteCorpus(String)
      • createProject

        @Deprecated(since="1.2.0",
                    forRemoval=true)
        public Project createProject​(Project project)
                              throws nzilbb.ag.StoreException,
                                     nzilbb.ag.PermissionException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Projects are now layer categories - a type of Category with classId = "layer". Use createCategory(Category) instead.
        Creates a new project record.
        Parameters:
        project - The project details to save.
        Returns:
        The project just created.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
        See Also:
        createCategory(Category)
      • readProjects

        @Deprecated(since="1.2.0",
                    forRemoval=true)
        public Project[] readProjects()
                               throws nzilbb.ag.StoreException,
                                      nzilbb.ag.PermissionException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Projects are now layer categories - a type of Category with classId = "layer". Use readCategories(String) instead.
        Reads a list of project records.
        Returns:
        A list of projects.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
        See Also:
        readCategories(String)
      • readProjects

        @Deprecated(since="1.2.0",
                    forRemoval=true)
        public Project[] readProjects​(Integer pageNumber,
                                      Integer pageLength)
                               throws nzilbb.ag.StoreException,
                                      nzilbb.ag.PermissionException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Projects are now layer categories - a type of Category with classId = "layer". Use readCategories(String,Integer,Integer) instead.
        Reads a list of project records.
        Parameters:
        pageNumber - The zero-based page of records to return (if null, all records will be returned).
        pageLength - The length of pages (if null, the default page length is 20).
        Returns:
        A list of projects.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
        See Also:
        readCategories(String,Integer,Integer)
      • updateProject

        @Deprecated(since="1.2.0",
                    forRemoval=true)
        public Project updateProject​(Project project)
                              throws nzilbb.ag.StoreException,
                                     nzilbb.ag.PermissionException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Projects are now layer categories - a type of Category with classId = "layer". Use updateCategory(Category) isntead.
        Updates an existing project record.
        Parameters:
        project - The project details to save.
        Returns:
        The project just updated.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
        See Also:
        updateCategory(Category)
      • deleteProject

        @Deprecated(since="1.2.0",
                    forRemoval=true)
        public void deleteProject​(Project project)
                           throws nzilbb.ag.StoreException,
                                  nzilbb.ag.PermissionException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Projects are now layer categories - a type of Category with classId = "layer". Use deleteCategory(Category) instead
        Deletes an existing project record.
        Parameters:
        project - The project to delete.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
        See Also:
        deleteCategory(Category)
      • deleteProject

        @Deprecated(since="1.2.0",
                    forRemoval=true)
        public void deleteProject​(String name)
                           throws nzilbb.ag.StoreException,
                                  nzilbb.ag.PermissionException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Projects are now layer categories - a type of Category with classId = "layer". Use deleteCategory(String,String) instead.
        Deletes an existing project record.
        Parameters:
        name - The name/ID of the project to delete.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
        See Also:
        deleteCategory(String,String)
      • readRoles

        public Role[] readRoles​(Integer pageNumber,
                                Integer pageLength)
                         throws nzilbb.ag.StoreException,
                                nzilbb.ag.PermissionException
        Reads a list of role records.
        Parameters:
        pageNumber - The zero-based page of records to return (if null, all records will be returned).
        pageLength - The length of pages (if null, the default page length is 20).
        Returns:
        A list of roles.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
        See Also:
        createRole(Role), readRoles(), updateRole(Role), deleteRole(Role), deleteRole(String)
      • readSystemAttributes

        public SystemAttribute[] readSystemAttributes()
                                               throws nzilbb.ag.StoreException,
                                                      nzilbb.ag.PermissionException
        Reads a list of system_attribute records.
        Returns:
        A list of system attributes.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
        See Also:
        updateSystemAttribute(SystemAttribute)
      • updateSystemAttribute

        public SystemAttribute updateSystemAttribute​(String attribute,
                                                     String value)
                                              throws nzilbb.ag.StoreException,
                                                     nzilbb.ag.PermissionException
        Updates an existing systemAttribute record.
        Parameters:
        attribute - The ID of the attribute to update.
        value - The new value of the attribute.
        Returns:
        The systemAttribute just updated.
        Throws:
        nzilbb.ag.StoreException - If the attribute doesn't exist or its type is "readonly".
        nzilbb.ag.PermissionException - If the operation is not permitted.
        See Also:
        readSystemAttributes(), updateSystemAttribute(SystemAttribute)
      • updateSystemAttribute

        public SystemAttribute updateSystemAttribute​(SystemAttribute systemAttribute)
                                              throws nzilbb.ag.StoreException,
                                                     nzilbb.ag.PermissionException
        Updates an existing systemAttribute record.
        Parameters:
        systemAttribute - The systemAttribute details to save.
        Returns:
        The systemAttribute just updated.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
        See Also:
        readSystemAttributes(), updateSystemAttribute(String,String)
      • updateInfo

        public void updateInfo​(String html)
                        throws nzilbb.ag.StoreException,
                               nzilbb.ag.PermissionException
        Saves the store's information document.
        Parameters:
        html - An HTML document with information about the corpus as a whole.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
        See Also:
        LabbcatView.getInfo()
      • readUsers

        public User[] readUsers​(Integer pageNumber,
                                Integer pageLength)
                         throws nzilbb.ag.StoreException,
                                nzilbb.ag.PermissionException
        Reads a list of user records.
        Parameters:
        pageNumber - The zero-based page of records to return (if null, all records will be returned).
        pageLength - The length of pages (if null, the default page length is 20).
        Returns:
        A list of users.
        Throws:
        nzilbb.ag.StoreException - If an error prevents the operation.
        nzilbb.ag.PermissionException - If the operation is not permitted.
        See Also:
        createUser(User), readUsers(), updateUser(User), deleteUser(User), deleteUser(String)
      • setPassword

        public void setPassword​(String user,
                                String password,
                                boolean resetPassword)
                         throws nzilbb.ag.StoreException,
                                nzilbb.ag.PermissionException
        Sets a given user's password.
        Parameters:
        user - The ID of the user to update.
        password - The new password.
        resetPassword - Whether the user must reset their password when they next log in.
        Throws:
        nzilbb.ag.StoreException - If an error occurs, e.g. the user does not exist.
        nzilbb.ag.PermissionException - If the current user does not have the 'admin' role.
      • loadLexicon

        public void loadLexicon​(File file,
                                String lexicon,
                                String fieldDelimiter,
                                String fieldNames,
                                String quote,
                                String comment,
                                boolean skipFirstLine)
                         throws nzilbb.ag.StoreException
        Upload a flat lexicon file for lexical tagging.

        By default LaBB-CAT includes a layer manager called the Flat Lexicon Tagger, which can be configured to annotate words with data from a dictionary loaded from a plain text file (e.g. a CSV file). The file must have a 'flat' structure in the sense that it's a simple list of dictionary entries with a fixed number of columns/fields, rather than having a complex structure.

        Parameters:
        file - The lexicon file.
        lexicon - The name for the resulting lexicon. If the named lexicon already exists, it will be completely replaced with the contents of the file (i.e. all existing entries will be deleted befor adding new entries from the file). e.g. 'cmudict'
        fieldDelimiter - The character used to delimit fields in the file. If this is " - ", rows are split on only the *first* space, in line with common dictionary formats. e.g. ',' for Comma Separated Values (CSV) files.
        fieldNames - A list of field names, delimited by fieldDelimiter, e.g. 'Word,Pronunciation'.
        quote - The character used to quote field values (if any), e.g. '"'.
        comment - The character used to indicate a line is a comment (not an entry) (if any) e.g. '#'.
        skipFirstLine - Whether to ignore the first line of the file (because it contains field names).
        Throws:
        nzilbb.ag.StoreException - If the lexicon could not be loaded.
        See Also:
        deleteLexicon(String)