Skip to content

Commit

Permalink
continue
Browse files Browse the repository at this point in the history
  • Loading branch information
BalduinLandolt committed Jun 19, 2024
1 parent d720a95 commit 52f8b35
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ INSERT DATA {
knora-base:hasPermissions "@permissions" ;
knora-base:creationDate "@creationDate"^^xsd:dateTime .

@* Attach the value to the resource. *@

@* Attach the value to the resource. *@
@for(newValueInfo <- newValueInfos) {
# Value: @newValueInfo.valueIri
# Property: @newValueInfo.propertyIri

<@newValueInfo.resourceIri> <@newValueInfo.propertyIri> <@newValueInfo.valueIri> .
}

@for(newValueInfo <- newValueInfos) {
@* Construct the value. *@
<@newValueInfo.valueIri> rdf:type <@newValueInfo.valueTypeIri> ;
knora-base:isDeleted false ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,10 +1034,64 @@ object ResourcesRepoLiveSpec extends ZIOSpecDefault {
},
)

val createResourceWithMultipleValuesTest = test("Create a resource with multiple values") {
val resource = resourceDefinition.copy(newValueInfos = List(intValueDefinition, boolValueDefinition))
val expected = Update(
s"""|
|PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|PREFIX knora-base: <http://www.knora.org/ontology/knora-base#>
|
|INSERT DATA {
| GRAPH <${graphIri.value}> {
| <$resourceIri> rdf:type <$resourceClassIri> ;
| rdfs:label "$label" ;
| knora-base:isDeleted false ;
| knora-base:attachedToUser <$userIri> ;
| knora-base:attachedToProject <$projectIri> ;
| knora-base:hasPermissions "$permissions" ;
| knora-base:creationDate "$creationDate"^^xsd:dateTime ;
| <foo:hasInt> <foo:IntValueIri> ;
| <foo:hasBoolean> <foo:BooleanValueIri> .
| <foo:IntValueIri> rdf:type <http://www.knora.org/ontology/knora-base#IntValue> ;
| knora-base:isDeleted false ;
| knora-base:valueHasString "42" ;
| knora-base:valueHasUUID "${UuidUtil.base64Encode(intValueDefinition.valueUUID)}" ;
| knora-base:attachedToUser <$valueCreator> ;
| knora-base:hasPermissions "$valuePermissions" ;
| knora-base:valueHasOrder 1 ;
| knora-base:valueCreationDate "$valueCreationDate"^^xsd:dateTime ;
| knora-base:valueHasInteger 42 .
| <foo:BooleanValueIri> rdf:type <http://www.knora.org/ontology/knora-base#BooleanValue> ;
| knora-base:isDeleted false ;
| knora-base:valueHasString "true" ;
| knora-base:valueHasUUID "${UuidUtil.base64Encode(boolValueDefinition.valueUUID)}" ;
| knora-base:attachedToUser <$valueCreator> ;
| knora-base:hasPermissions "$valuePermissions" ;
| knora-base:valueHasOrder 1 ;
| knora-base:valueCreationDate "$valueCreationDate"^^xsd:dateTime ;
| knora-base:valueHasBoolean true .
| }
|}
|""".stripMargin,
)

val result = ResourcesRepoLive.createNewResourceQuery(graphIri, resource, projectIri, userIri)
val reference = ResourcesRepoLive.createNewResourceQueryTwirl(
dataGraphIri = graphIri,
resourceToCreate = resource,
projectIri = projectIri,
creatorIri = userIri,
)
assertUpdateQueriesEqual(expected, result) && assertUpdateQueriesEqual(reference, result)
}

val tests: Spec[StringFormatter, Nothing] =
suite("ResourcesRepoLiveSpec")(
createResourceWithoutValuesTest,
createResourceWithValueSuite,
createResourceWithMultipleValuesTest,
// test("Create new resource query with links") {
// val graphIri = InternalIri("fooGraph")
// val projectIri = "fooProject"
Expand Down

0 comments on commit 52f8b35

Please sign in to comment.