Git Access

CATMA uses a Gitlab as its backend. All the data of your CATMA Project are handled as git projects.

CATMA works locally on the git projects. When you synchronize your CATMA Project you actually synchronize the local git projects with their remote counterparts of the Gitlab backend. That means before you access your data via Gitlab/git you should always synchronize your CATMA Project within CATMA.

Make yourself familiar with git and Gitlab first!

Overall Structure

A CATMA Project is equivalent to a GitLab Group.

The CATMA ProjectID is equivalent to the GitLab Group name. The name and the description of your CATMA Project are stored in the Gitlab Group description.

User Management

CATMA uses the user, role and permission management of Gitlab. So if you are working with a team on your CATMA Project you will find all participating team members in the Members section of the corresponding Gitlab Group.

If you have a CATMA account you can use your username and password to login to the Gitlab backend. If you are using a Google account for authentication you currently need to request an access token. But there will be a way to to this directly from within CATMA soon.

Resources

A CATMA Project usually contains several resources. A resource can
either be a Document, an Annotation Collection or a Tagset. All
resources are modelled as GitLab/git projects. A CATMA resource is a Gitlab/git project within the Gitlab Group namespace. In order to avoid confusing a CATMA Project with a Gitlab/git resource project we will use those names throughout this article explicitly.

The root Gitlab/git project

You will find all your CATMA resources as Gitlab/git projects within your Gitlab Group. There is one additional Gitlab/git project in the Gitlab Group which is special: the root Gitlab/git project. Its name is a concatenation of the CATMA ProjectID and _root. Let’s assume you have a CATMA Project named Shakespeare with the ID CATMA_900F812B-69EF-4326-A3E6-58BCFF509719_Shakespeare. Then the root Gitlab/git Project would be named:

CATMA_900F812B-69EF-4326-A3E6-58BCFF509719_Shakespeare_root

So what is this root Gitlab/git project all about? Changes to your resources, e. g. adding Annotations to a Collections are all versioned within the Gitlab/git project that backs a CATMA resource. But what about changes to the structure of your CATMA Project that are made when you add or remove resources. Changes to this structure, the CATMA Project configuration so to speak, are recorded and versioned in the root Gitlab/git project. Luckily git offers a standard way to manage such a configuration: git submodules. So all resources that are part of the current version of your CATMA Project are git submodules of the root Gitlab/git project. We will come to that back later when I talk about how to actually work with your CATMA Project via git. Note for now that CATMA versions your CATMA Project configuration with git submodules.

When you add a resource to your CATMA Project it gets added as Gitlab/git project to the Gitlab Group and it gets added as a git submodule to the root Gitlab/git project.

When you remove a resource from your CATMA Project it gets removed as a submodule from the root Gitlab/git project. It does not get removed as a Gitlab/git project from the Gitlab Group automatically. So if you get back to older versions of your CATMA Project configurations the resources are still available.

The folder structure of the root Gitlab/git project is as follows:

CATMA_900F812B-69EF-4326-A3E6-58BCFF509719_Shakespeare_root
\__ .git
\__ .gitmodules
\__ documents\
\__ collections\
\__ tagsets\

Besides the .git folder with the git management and configuration files there is also a .gitmodules file which maintains the list of git submodules and a subfolder for each of the resource categories of a CATMA Project.

Resource Structure

Documents

The Documents are all within the documents folder of your root Gitlab/git project.

Each Document has its own folder named after the CATMA ID of the Document.

Each Document folder contains four files:

  • header.json – contains metadata of Document
  • CATMA_ID_orig.EXT – the original file that was uploaded with a format specific extension
  • CATMA_ID.txt – the extracted text in UTF-8 plain/text
  • CATMA_ID.json – the indexed types with the start, end and token offset of their tokens, i. e. the word list

The extracted text

The file with the extracted text in UTF-8 plain/text is the most important file as all start and end offset of the Annotations can be resolved against the character offsets of the extracted text.

Tagsets

The Tagsets are all within the tagsets folder of your root Gitlab/git project.

Each Tagset has its own folder named after the CATMA ID of the Tagset.

Each Tagset folder contains a header.json file with some meta data like the Tagset’s name.

Remember a Tagsets contains zero or more Tags that can form a hierarchical structure:

  • A Tag has either no parent (top level Tag) or exactly one parent.
  • A Tag can have zero or more child Tags.

Each Tag has its own folder named after the Tag’s CATMA ID.
Tag folders of Tags that have a parent Tag are located as subfolders of a folder named after the parent Tag’s ID.

This sounds more complicated as it is, because in the end each Tag is represented by a file named propertydefs.json. To load the Tags of a Tagset you just need to parse all propertydefs.json files that can be found in the sub directories of the Tagset’s folder.

The propertydefs.json file contains

  • the name
  • the ID, which is a uuid
  • the parent ID, which is a uuid but can be empty in case of a top level Tag
  • two system Properties
    • the author (catma_markupauthor)
    • the color (catma_displaycolor)

The values of the system Properties are to be found in the property named possibleValueList.

The color is encoded as an integer value containing red, green and blue values encoded as bits: red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7. This corresponds to the color encoding in HTML.

Besides the system Properties a Tag can have zero or more user defined Properties. Each Property has a name and a list of possible or proposal values (possibleValueList) that get presented to the user upon application of a Tag.

Collections

The Collections are all within the collections folder of your root Gitlab/git project.

Each Collection has its own folder named after the CATMA ID of the Collection.

Each Collection folder contains a header.json file with some meta data like the Collections’s name and the ID of the Document it belongs to (sourceDocumentId).

Annotations

The Annotations are located in a subfolder called annotations. Each Annotation has its own file named after the CATMA ID of the Annotation.

Annotations follow the Web Annotation Data Model and are serialized as JSON-LD.
Each Annotation has a type, i. e. its Tag, and one or more references to possibly non adjacent (discontinous markup) text segments. Each Annotation has a timestamp and an author (not to be confused with the author of the Tag). The Annotations inherits the color, the name and the user defined Properties from its Tag. A user defined Property of an Annotation can have zero or more values which are either drawn from the set of possible values of the Tag or defined by the user while annotating (ad hoc values).

Within the Annotation’s file you’ll find a body section with the following subsections:

  • tagset – the URL of the Tagset GitLab/git project. This URL also contains the ID of the Tagset
  • tag – the URL of the Tag GitLab/git project. This URL also contains the ID of the Tag
  • properties – The Properties and their Annotation specific values
    • system – timestamp and author of the Annotation
    • user – user defined Properties with the CATMA ID and a list of values for each Property
  • target – contains a list of TextPosistionSelector selectors with start and end offsets that reference the aformentioned UTF-8 plain/text file with the extracted text

Working with git

The Gitlab backend is accessible at git.catma.de. Once you logged in with your CATMA account credentials you can find in the menu on the left the Access Tokens menu item.

Add a personal access token with the ‘api’ scope enabled.

Make sure you copy the token right after creation and put it somewhere
save. You won’t be able to see the token itself after you left the page!

Now you can work with the Gitlab API.

For example get a list of all of your CATMA Projects:

https://git.catma.de/api/v4/groups/?private_token=THE_TOKEN

or with the parameter GROUPID_OR_NAME set to the CATMA Project ID get a list of all the resource Gitlab/git projects and the root Gitlab/git project:

https://git.catma.de/api/v4/groups/GROUPID_OR_NAME/projects/?private_token=THE_TOKEN

Taking the git URL of the corresponding root Gitlab/git project you can also work with git directly to clone a CATMA Project. Assuming the above mentioned Shakespeare CATMA Project the command would look like this:

git clone --recurse-submodules 
https://git.catma.de/CATMA_900F812B-69EF-4326-A3E6-58BCFF509719_Shakespeare/CATMA_900F812B-69EF-4326-A3E6-58BCFF509719_Shakespeare_root.git

Use the created access token as username and password. Alternatively you can also add an SSH key to your account and clone with SSH.

All you need is the URL of the root Gitlab/git repository. The resources of the current version get initialized automatically by the --recurse-submodules argument.

You can use the cloned repository for backup purposes or to integrate external systems. However, be aware that CATMA can handle only a certain amount of complexity when resolving merge conflicts. You should therefore always resolve conflicts on your side.

CATMA always works on a local-only dev branch. Changes get merged into the local master branch. When synchronizing a CATMA Project the local master branches of the resource git projectes and of the root git project get merged with their remote Gitlab counter parts.

Note that you should take care to stick to the above mentioned folder and file structures and formats to avoid errors.