Skip to content

Commit

Permalink
Merge branch 'main' into wip/add-deprecation-to-release-please
Browse files Browse the repository at this point in the history
  • Loading branch information
BalduinLandolt authored Apr 2, 2024
2 parents eeb6825 + 1beb192 commit a82defb
Show file tree
Hide file tree
Showing 26 changed files with 4,842 additions and 3,560 deletions.
3 changes: 0 additions & 3 deletions docs/01-introduction/example-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ project from scratch, you can adapt these scripts to import your
ontology (and any existing RDF data) into your triplestore for use with
DSP-API.

The syntax of Turtle is fairly simple: it is basically a sequence of
triples. We will consider some details of Turtle syntax as we go along.

## The Incunabula Ontology

Here we will just focus on some of the main aspects of the ontology. An
Expand Down
17 changes: 1 addition & 16 deletions docs/02-dsp-ontologies/knora-base.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ would refer to that property in general, not to any particular instance in which
particular resources. To attach metadata to a specific link in RDF, it is necessary to create an RDF "reification". A
reification makes statements about a particular triple (subject, predicate, object), in this case the triple that
expresses the link between the resources. DSP-API uses reifications of type `kb:LinkValue` (described in
[LinkValue](#linkvalue) to store metadata about links.
[LinkValue](#linkvalue)) to store metadata about links.

For example, suppose a project describes paintings that belong to collections. The project can define an ontology as
follows (expressed here in [Turtle](http://www.w3.org/TR/turtle/) format, and simplified for the purposes of
Expand Down Expand Up @@ -587,21 +587,6 @@ is part of another resource needs to have a property `kb:seqnum` or a subpropert
client can then use this information to leaf through the parts of the compound resource (p.ex. to leaf through the pages
of a book like in [this](../01-introduction/example-project.md#resource-classes) example).

#### isSequenceOf

Similar to `kb:isPartOf` for `kb:StillImageRepresentations`, part-whole-relations can be defined for resources that have
a time dimension by using `kb:isSequenceOf`. You can use it for video or audio resources that are subtypes of
`kb:MovingImageRepresentation` and `kb:AudioRepresentation`.

`kb:isSequenceOf` is intended to be used in combination with the property `kb:hasSequenceBounds` which points to a
`kb:IntervalValue`. This defines the start and end point of the subseqence in relation to the entire audio/video
resource as an [interval](#intervalvalue). When the properties are used in this combination, a dedicated behavior in the
frontend allows to display the sequences alongside the main resource.

There is an important difference between `kb:isSequenceOf` and `kb:isPartOf`: For `kb:isPartOf`, each part *is a*
`kb:StillImageRepresentation` and the whole consists of multiple such parts. In `kb:isSequenceOf` on the other hand, the
whole is one `kb:MovingImageRepresentation` or `kb:AudioRepresentation`. The parts only define which sub-sequence of
this representation they are.

### Text with Standoff Markup

Expand Down
6 changes: 1 addition & 5 deletions docs/03-endpoints/api-admin/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Projects Endpoint

| Scope | Route | Operations | Explanation |
| --------------- | -------------------------------------------------------------- |------------|-----------------------------------------------------------------------------|
| --------------- | -------------------------------------------------------------- | ---------- | --------------------------------------------------------------------------- |
| projects | `/admin/projects` | `GET` | [get all projects](#get-all-projects) |
| projects | `/admin/projects` | `POST` | [create a project](#create-a-new-project) |
| projects | `/admin/projects/shortname/{shortname}` | `GET` | [get a single project](#get-project-by-id) |
Expand Down Expand Up @@ -239,7 +239,6 @@ Example response:
"longname": "Anything Project",
"ontologies": [
"http://0.0.0.0:3333/ontology/0001/something/v2",
"http://0.0.0.0:3333/ontology/0001/sequences/v2",
"http://0.0.0.0:3333/ontology/0001/freetest/v2",
"http://0.0.0.0:3333/ontology/0001/minimal/v2",
"http://0.0.0.0:3333/ontology/0001/anything/v2"
Expand Down Expand Up @@ -310,7 +309,6 @@ Example response:
"longname": "other longname",
"ontologies": [
"http://api.knora.org/ontology/0001/something/v2",
"http://api.knora.org/ontology/0001/sequences/v2",
"http://api.knora.org/ontology/0001/freetest/v2",
"http://api.knora.org/ontology/0001/minimal/v2",
"http://api.knora.org/ontology/0001/anything/v2"
Expand Down Expand Up @@ -365,7 +363,6 @@ Example response:
"longname": "other longname",
"ontologies": [
"http://api.knora.org/ontology/0001/something/v2",
"http://api.knora.org/ontology/0001/sequences/v2",
"http://api.knora.org/ontology/0001/freetest/v2",
"http://api.knora.org/ontology/0001/minimal/v2",
"http://api.knora.org/ontology/0001/anything/v2"
Expand Down Expand Up @@ -641,7 +638,6 @@ Example response:
"longname": "Anything Project",
"ontologies": [
"http://0.0.0.0:3333/ontology/0001/something/v2",
"http://0.0.0.0:3333/ontology/0001/sequences/v2",
"http://0.0.0.0:3333/ontology/0001/freetest/v2",
"http://0.0.0.0:3333/ontology/0001/minimal/v2",
"http://0.0.0.0:3333/ontology/0001/anything/v2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ flowchart BT
hasColor ---> hasValue
hasGeometry ---> hasValue
hasComment ---> hasValue
hasSequenceBounds ---> hasValue
seqnum ---> hasValue
hasExtResValue ---> hasValue
hasLinkToValue ----> hasValue
Expand All @@ -363,14 +362,12 @@ flowchart BT
hasAnnotationOfValue ---> hasLinkToValue
hasRepresentationValue ---> hasLinkToValue
hasStandoffLinkToValue ---> hasLinkToValue
isSequenceOfValue ---> hasLinkToValue
isRegionOfValue ---> hasLinkToValue
isPartOf ---> hasLinkTo
isAnnotationOf ---> hasLinkTo
hasRepresentation ---> hasLinkTo
hasStandoffLinkTo ---> hasLinkTo
isSequenceOf ---> hasLinkTo
isRegionOf ---> hasLinkTo
```

Expand Down Expand Up @@ -565,15 +562,13 @@ flowchart LR
subgraph Links
hasRepresentation
hasLinkTo
isSequenceOf
hasStandoffLinkTo
isPartOf
end
subgraph LinkValues
hasRepresentationValue
hasLinkToValue
isSequenceOfValue
hasStandoffLinkToValue
isPartOfValue
end
Expand All @@ -593,12 +588,10 @@ flowchart LR
Resource --> hasRepresentation --> _Representation
Resource --> hasLinkTo --> _Resource
Resource --> isSequenceOf --> _Resource
Resource --> hasStandoffLinkTo --> _Resource
Resource --> isPartOf --> _Resource
Resource --> hasLinkToValue --> LinkValue
Resource --> isSequenceOfValue --> LinkValue
Resource --> hasStandoffLinkToValue --> LinkValue
Resource --> hasRepresentationValue --> LinkValue
Resource --> isPartOfValue --> LinkValue
Expand Down Expand Up @@ -638,7 +631,6 @@ flowchart LR
%% Relations
na --> deletedBy --> User
na --> seqnum --> IntValue
na --> hasSequenceBounds --> IntervalValue
na --> deleteDate --> date
na --> isDeleted --> boolean
```
18 changes: 17 additions & 1 deletion integration/src/test/scala/org/knora/webapi/E2EZSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ package org.knora.webapi
import zio._
import zio.http._
import zio.json._
import zio.json.ast.Json
import zio.json.ast.JsonCursor
import zio.test._

import org.knora.webapi.core.AppServer
Expand Down Expand Up @@ -49,7 +51,7 @@ abstract class E2EZSpec extends ZIOSpecDefault with TestStartupUtils {
urlFull <- ZIO.fromEither(URL.decode(urlStr)).orDie
_ <- ZIO.logDebug(s"GET ${urlFull.encode}")
bearer = token.map(Header.Authorization.Bearer(_)).toList
response <- client.url(urlFull).addHeaders(Headers(bearer)).get("/").orDie
response <- client.url(urlFull).addHeaders(Headers(bearer)).get("").orDie
} yield response

def sendGetRequestStringOrFail(url: String, token: Option[String] = None): ZIO[env, String, String] =
Expand Down Expand Up @@ -106,4 +108,18 @@ abstract class E2EZSpec extends ZIOSpecDefault with TestStartupUtils {
token <- ZIO.fromOption(result.get("token")).orElseFail("No token in response")
} yield token

def getRootToken: ZIO[env, String, String] =
getToken("[email protected]", "test")

def urlEncode(s: String): String = java.net.URLEncoder.encode(s, "UTF-8")

def getOntologyLastModificationDate(ontlogyIri: String): ZIO[env, String, String] = {
val cursor = JsonCursor.field("knora-api:lastModificationDate").isObject.field("@value").isString
for {
responseStr <- sendGetRequestStringOrFail(s"/v2/ontologies/allentities/${urlEncode(ontlogyIri)}")
responseAst <- ZIO.fromEither(responseStr.fromJson[Json])
lmd <- ZIO.fromEither(responseAst.get(cursor))
} yield lmd.value
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import org.knora.webapi.e2e.TestDataFilePath
import org.knora.webapi.messages.OntologyConstants.KnoraApiV2Complex
import org.knora.webapi.messages.OntologyConstants.KnoraApiV2Simple
import org.knora.webapi.messages.store.triplestoremessages.RdfDataObject
import org.knora.webapi.messages.util.rdf.RdfFormatUtil
import org.knora.webapi.messages.util.rdf.Turtle
import org.knora.webapi.sharedtestdata.SharedOntologyTestDataADM
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.util._
Expand All @@ -45,9 +47,10 @@ class OntologyFormatsE2ESpec extends E2ESpec {
urlPath: String,
fileBasename: String,
clientTestDataBasename: Option[String] = None,
persistTtl: Boolean = false,
) {
private def makeFile(): Path =
Paths.get("..", "test_data", "generated_test_data", "ontologyR2RV2", s"$fileBasename.jsonld")
private def makeFile(fileEnding: String = "jsonld"): Path =
Paths.get("..", "test_data", "generated_test_data", "ontologyR2RV2", s"$fileBasename.$fileEnding")

/**
* If `maybeClientTestDataBasename` is defined, stores the response string in [[org.knora.webapi.e2e.ClientTestDataCollector]].
Expand All @@ -58,6 +61,15 @@ class OntologyFormatsE2ESpec extends E2ESpec {
case None => ()
}

def storeAsTtl = {
val jsonStr = readFile()
val model = parseJsonLd(jsonStr)
val ttlStr = RdfFormatUtil.format(model, Turtle)
val newFile = makeFile("ttl")
Files.createDirectories(newFile.getParent)
FileUtil.writeTextFile(newFile, ttlStr)
}

/**
* Reads the expected response file.
*
Expand All @@ -75,6 +87,9 @@ class OntologyFormatsE2ESpec extends E2ESpec {

Files.createDirectories(newOutputFile.getParent)
FileUtil.writeTextFile(newOutputFile, responseStr)

if (persistTtl) storeAsTtl

()
}
}
Expand Down Expand Up @@ -208,6 +223,7 @@ class OntologyFormatsE2ESpec extends E2ESpec {
s"/v2/ontologies/allentities/${urlEncodeIri(SharedOntologyTestDataADM.ANYTHING_ONTOLOGY_IRI_LocalHost)}",
fileBasename = "anythingOntologyWithValueObjects",
clientTestDataBasename = Some("anything-ontology"),
persistTtl = true,
)

private val anythingThingWithAllLanguages =
Expand Down
Loading

0 comments on commit a82defb

Please sign in to comment.