Skip to content

Commit

Permalink
continue
Browse files Browse the repository at this point in the history
  • Loading branch information
BalduinLandolt committed Jun 18, 2024
1 parent 58e7c90 commit 201dbdf
Show file tree
Hide file tree
Showing 3 changed files with 300 additions and 265 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ import java.time.Instant
import java.util.UUID

import dsp.constants.SalsahGui.IRI
import dsp.valueobjects.UuidUtil
import org.knora.webapi.messages.twirl.NewLinkValueInfo
import org.knora.webapi.messages.twirl.NewValueInfo
import org.knora.webapi.messages.twirl.TypeSpecificValueInfo
import org.knora.webapi.messages.twirl.queries.sparql
import org.knora.webapi.messages.util.CalendarNameGregorian
import org.knora.webapi.messages.util.DatePrecisionDay
import org.knora.webapi.slice.resourceinfo.domain.InternalIri
import org.knora.webapi.store.triplestore.api.TriplestoreService
import org.knora.webapi.store.triplestore.api.TriplestoreService.Queries.Update
Expand Down Expand Up @@ -125,8 +128,9 @@ object ResourcesRepoLive {
.isA(iri(newValueInfo.valueTypeIri))
.andHas(KnoraBaseVocab.isDeleted, Rdf.literalOf(false))
.andHas(KnoraBaseVocab.valueHasString, Rdf.literalOf(newValueInfo.valueHasString))
.andHas(KnoraBaseVocab.valueHasUUID, Rdf.literalOf(newValueInfo.valueUUID.toString))
.andHas(KnoraBaseVocab.valueHasUUID, Rdf.literalOf(UuidUtil.base64Encode(newValueInfo.valueUUID)))
.andHas(KnoraBaseVocab.attachedToUser, iri(newValueInfo.valueCreator))
.andHas(KnoraBaseVocab.hasPermissions, Rdf.literalOf(newValueInfo.valuePermissions))
.andHas(KnoraBaseVocab.valueHasOrder, Rdf.literalOf(newValueInfo.valueHasOrder))
.andHas(
KnoraBaseVocab.valueCreationDate,
Expand All @@ -153,15 +157,15 @@ object ResourcesRepoLive {
valuePattern.andHas(KnoraBaseVocab.valueHasDecimal, Rdf.literalOf(valueHasDecimal))
case TypeSpecificValueInfo.BooleanValueInfo(valueHasBoolean) =>
valuePattern.andHas(KnoraBaseVocab.valueHasBoolean, Rdf.literalOf(valueHasBoolean))
case TypeSpecificValueInfo.UriValueInfo(valueHasUri) => ???
case TypeSpecificValueInfo.DateValueInfo(
valueHasStartJDN,
valueHasEndJDN,
valueHasStartPrecision,
valueHasEndPrecision,
valueHasCalendar,
) =>
???
case TypeSpecificValueInfo.UriValueInfo(valueHasUri) =>
valuePattern.andHas(KnoraBaseVocab.valueHasUri, Rdf.literalOf(valueHasUri))
case TypeSpecificValueInfo.DateValueInfo(startJDN, endJDN, startPrecision, endPrecision, calendar) =>
valuePattern
.andHas(KnoraBaseVocab.valueHasStartJDN, Rdf.literalOf(startJDN))
.andHas(KnoraBaseVocab.valueHasEndJDN, Rdf.literalOf(endJDN))
.andHas(KnoraBaseVocab.valueHasStartPrecision, Rdf.literalOf(startPrecision.toString()))
.andHas(KnoraBaseVocab.valueHasEndPrecision, Rdf.literalOf(endPrecision.toString()))
.andHas(KnoraBaseVocab.valueHasCalendar, Rdf.literalOf(calendar.toString()))
case TypeSpecificValueInfo.ColorValueInfo(valueHasColor) => ???
case TypeSpecificValueInfo.GeomValueInfo(valueHasGeometry) => ???
case TypeSpecificValueInfo.StillImageFileValueInfo(
Expand Down Expand Up @@ -229,9 +233,16 @@ object KnoraBaseVocab {
val valueHasOrder = iri(kb + "valueHasOrder")
val valueCreationDate = iri(kb + "valueCreationDate")

val valueHasInteger = iri(kb + "valueHasInteger")
val valueHasBoolean = iri(kb + "valueHasBoolean")
val valueHasDecimal = iri(kb + "valueHasDecimal")
val valueHasInteger = iri(kb + "valueHasInteger")
val valueHasBoolean = iri(kb + "valueHasBoolean")
val valueHasDecimal = iri(kb + "valueHasDecimal")
val valueHasUri = iri(kb + "valueHasUri")
val valueHasStartJDN = iri(kb + "valueHasStartJDN")
val valueHasEndJDN = iri(kb + "valueHasEndJDN")
val valueHasStartPrecision = iri(kb + "valueHasStartPrecision")
val valueHasEndPrecision = iri(kb + "valueHasEndPrecision")
val valueHasCalendar = iri(kb + "valueHasCalendar")

}

object Run extends ZIOAppDefault {
Expand Down Expand Up @@ -293,6 +304,42 @@ object Run extends ZIOAppDefault {
valueHasString = "42.42",
comment = None,
),
// uri value
NewValueInfo(
resourceIri = resourceIri,
propertyIri = "fooUriProp",
valueIri = "fooUriValueIri",
valueTypeIri = "UriValue",
valueUUID = UUID.randomUUID(),
value = TypeSpecificValueInfo.UriValueInfo("http://example.com"),
valuePermissions = permissions,
valueCreator = userIri,
creationDate = creationDate,
valueHasOrder = 4,
valueHasString = "http://example.com",
comment = None,
),
// date value
NewValueInfo(
resourceIri = resourceIri,
propertyIri = "fooDateProp",
valueIri = "fooDateValueIri",
valueTypeIri = "DateValue",
valueUUID = UUID.randomUUID(),
value = TypeSpecificValueInfo.DateValueInfo(
0,
0,
DatePrecisionDay,
DatePrecisionDay,
CalendarNameGregorian,
),
valuePermissions = permissions,
valueCreator = userIri,
creationDate = creationDate,
valueHasOrder = 5,
valueHasString = "2024-01-01T10:00:00.673298Z",
comment = None,
),
)

val resourceDefinition = ResourceReadyToCreate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,42 @@

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX knora-base: <http://www.knora.org/ontology/knora-base#>

INSERT DATA {
GRAPH <@dataNamedGraph> {
<@resourceIri> rdf:type <@resourceClassIri> ;
rdfs:label """@resourceLabel""" ;
knora-base:isDeleted false ;
knora-base:attachedToUser <@creatorIri> ;
knora-base:attachedToProject <@projectIri> ;
rdfs:label """@resourceLabel""" ;
knora-base:hasPermissions "@permissions" ;
knora-base:creationDate "@creationDate"^^xsd:dateTime .

@* Attach the value to the resource. *@

@for(newValueInfo <- newValueInfos) {
# Value: @newValueInfo.valueIri
# Property: @newValueInfo.propertyIri

<@newValueInfo.resourceIri> <@newValueInfo.propertyIri> <@newValueInfo.valueIri> .
@* Construct the value. *@
<@newValueInfo.valueIri> rdf:type <@newValueInfo.valueTypeIri> ;
knora-base:isDeleted false ;
knora-base:valueHasString """@newValueInfo.valueHasString""" ;
knora-base:valueHasUUID "@{UuidUtil.base64Encode(newValueInfo.valueUUID)}" .

@* Insert the value's comment, if given. *@
@newValueInfo.comment.map { commentStr =>
<@newValueInfo.valueIri> knora-base:valueHasComment """@commentStr""" .
}

<@newValueInfo.valueIri> knora-base:attachedToUser <@newValueInfo.valueCreator> ;
knora-base:hasPermissions "@newValueInfo.valuePermissions"^^xsd:string ;
knora-base:valueHasOrder @newValueInfo.valueHasOrder ;
knora-base:valueCreationDate "@newValueInfo.creationDate"^^xsd:dateTime .

@newValueInfo.value match {

case linkValue: LinkValueInfo => {
Expand Down Expand Up @@ -217,19 +229,6 @@ INSERT DATA {
<@newValueInfo.valueIri> knora-base:valueHasGeonameCode """@geonameValue.valueHasGeonameCode""" .
}
}

@* Insert the value's comment, if given. *@
@newValueInfo.comment.map { commentStr =>
<@newValueInfo.valueIri> knora-base:valueHasComment """@commentStr""" .
}

<@newValueInfo.valueIri> knora-base:attachedToUser <@newValueInfo.valueCreator> ;
knora-base:hasPermissions "@newValueInfo.valuePermissions"^^xsd:string ;
knora-base:valueHasOrder @newValueInfo.valueHasOrder ;
knora-base:valueCreationDate "@newValueInfo.creationDate"^^xsd:dateTime .

@* Attach the value to the resource. *@
<@newValueInfo.resourceIri> <@newValueInfo.propertyIri> <@newValueInfo.valueIri> .
}


Expand Down
Loading

0 comments on commit 201dbdf

Please sign in to comment.