CenterForDigitalHumanities / TPEN-services

Services required by TPEN interfaces in order to interact with data
1 stars 0 forks source link

Add, Remove, Update Lines in the databases #94

Open thehabes opened 4 months ago

thehabes commented 4 months ago

The desired behaviors have related actions, so be aware of all changes needed and make sure it all completes. All these are in the "tiny" database.

Action Path (suggestion) notes
add line POST /page/{:id}/appendLine All Annotations must be in an Annotation Page.
The :id is the hexString for the Annotation Page.
Line is added to the end of any existing lines.
add line POST /page/{:id}/prependLine Line is added to the top of the list.
add line POST /line/{:id}/after The :id is the hexString for a sibling Annotation.
The Line is inserted in the list after the Line identified.
add line POST /line/{:id}/before The Line is inserted in the list before the Line identified.
remove line DELETE /line/{:id}/ Remove this Line from the Annotation Page.
update line PUT /line/{:id}/ Replace this document with the payload of the request.

RERUM supports PATCH but this is not built into the "tiny" driver.

When adding, removing, or updating a Line, the items Array in the Annotation Page will be updated, which means a corresponding update to the Annotation Collection with the versioned new id and an overwrite patch to the Project.layers with the new Collection id (local "mongo").

Lines are Annotations, so they need to be JSON-LD like:

{
  "@context": "http://www.w3.org/ns/anno.jsonld",
  "id": "https://store.rerum.io/v1/id/anno1",
  "creator": "https://store.rerum.io/v1/id/agentExample",
  "type": "Annotation",
  "motivation": "supplementing",
  "body": {
    "type": "TextualBody",
    "value": "transcribendo!",
    "format": "text/plain",
    "language": "la"
  },
  "target": "https://manifest/canvas/4#xywh=10,20,145,55"
}

In this sample, @context and type are constant and can be omitted from the request body. If they are included, they should not be overwritten. The value for id can be passed in or generated (as well as _id) and creator should be generated from the authorized User always. motivation and even body are optional - only target is required.