Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add copyright holder and authorship to filevalue #3459

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3fae03d
Move Copyright and Licenses relevant models out of the KnoraProject
seakayone Jan 13, 2025
45be470
add Authorship value class
seakayone Jan 13, 2025
7229819
add LicenseDate value class
seakayone Jan 13, 2025
d432041
rename copyright attribution to copyright holder
seakayone Jan 13, 2025
20a92b1
add hasAuthorship and hasLicenseDate
seakayone Jan 14, 2025
fc95a2c
update knora-base version
seakayone Jan 14, 2025
c5c732f
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Jan 14, 2025
378290d
add ResourcesResponderV2 test for copyright and licenses infos
seakayone Jan 14, 2025
b1ea5cd
add date writing and reading
seakayone Jan 14, 2025
24eceb1
add authorship writing
seakayone Jan 14, 2025
12e6ee2
Move create resource with copyright and license test to CopyrightAndL…
seakayone Jan 15, 2025
c24ab55
cleanup
seakayone Jan 15, 2025
7576819
fix ontology
seakayone Jan 15, 2025
e032bf9
remove debug logging
seakayone Jan 15, 2025
325a085
Set licenseDate when creating the FileValueV2
seakayone Jan 15, 2025
c3da9b7
regenerate knoraApiOntologySimple.jsonld
seakayone Jan 15, 2025
406295b
rm unused imports
seakayone Jan 15, 2025
7c33ce5
regenerate knoraApiOntologySimple.jsonld
seakayone Jan 15, 2025
6d0af29
reuse FileValueV2
seakayone Jan 15, 2025
ff0ef95
simplify
seakayone Jan 15, 2025
b34dc5e
rm unused import
seakayone Jan 15, 2025
3a3de35
fmt
seakayone Jan 15, 2025
3d141f2
fix test
seakayone Jan 15, 2025
ab41f28
rm unused import
seakayone Jan 15, 2025
8b2cb43
fix test
seakayone Jan 15, 2025
49b7dae
add test for updating values
seakayone Jan 15, 2025
66dfa59
rm unused import
seakayone Jan 15, 2025
22011c0
fmt
seakayone Jan 15, 2025
0b30428
refine LicenseDate assertion
seakayone Jan 15, 2025
054b8e2
replace String concatenation with building proper jsonld
seakayone Jan 15, 2025
36e2fa0
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Jan 17, 2025
8276e44
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Jan 20, 2025
b141805
rename License Text to License Identifier
seakayone Jan 20, 2025
2e54510
fmt
seakayone Jan 20, 2025
c3c1955
rm redundant braces
seakayone Jan 20, 2025
9b473ec
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Jan 23, 2025
9c5eae9
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Jan 24, 2025
28996c3
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

### Enhancements

* Split license into licenseText and licenseUri (DEV-4398) ([#3436](https://github.com/dasch-swiss/dsp-api/issues/3436)) ([76d2db2](https://github.com/dasch-swiss/dsp-api/commit/76d2db25a75ffd43294e2d1d25e98f53f5d0e275))
* Split license into licenseIdentifier and licenseUri (DEV-4398) ([#3436](https://github.com/dasch-swiss/dsp-api/issues/3436)) ([76d2db2](https://github.com/dasch-swiss/dsp-api/commit/76d2db25a75ffd43294e2d1d25e98f53f5d0e275))


### Bug Fixes
Expand Down
3 changes: 3 additions & 0 deletions integration/src/test/scala/org/knora/webapi/E2EZSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ abstract class E2EZSpec extends ZIOSpecDefault with TestStartupUtils {
response <- client.url(urlFull).addHeaders(Headers(bearer)).get("").orDie
} yield response

def sendPutRequestAsRoot(url: String, data: String): ZIO[env, String, Response] =
sendPutRequestAsRoot(url, Body.fromString(data))

def sendPutRequestAsRoot(url: String, body: Body): URIO[env, Response] =
for {
token <- getRootToken.mapError(Exception(_)).orDie
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,11 @@ import org.knora.webapi.slice.admin.api.model.Project
import org.knora.webapi.slice.admin.api.model.ProjectAdminMembersGetResponseADM
import org.knora.webapi.slice.admin.api.model.ProjectMembersGetResponseADM
import org.knora.webapi.slice.admin.api.model.ProjectOperationResponseADM
import org.knora.webapi.slice.admin.domain.model.*
import org.knora.webapi.slice.admin.domain.model.Group
import org.knora.webapi.slice.admin.domain.model.KnoraProject.CopyrightAttribution
import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseText
import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseUri
import org.knora.webapi.slice.admin.domain.model.KnoraProject.Longname
import org.knora.webapi.slice.admin.domain.model.KnoraProject.Shortcode
import org.knora.webapi.slice.admin.domain.model.KnoraProject.Shortname
import org.knora.webapi.slice.admin.domain.model.User
import org.knora.webapi.slice.common.Value.StringValue

/**
Expand Down Expand Up @@ -207,12 +204,12 @@ object IntegrationTestAdminJsonProtocol extends TriplestoreJsonProtocol {
case _ => throw DeserializationException("Value must be a JSON string.")
}

implicit object CopyrightAttributionFormat extends StringValueFormat[CopyrightAttribution] {
override val from: String => Either[String, CopyrightAttribution] = CopyrightAttribution.from
implicit object CopyrightHolderFormat extends StringValueFormat[CopyrightHolder] {
override val from: String => Either[String, CopyrightHolder] = CopyrightHolder.from
}

implicit object LicenseTextFormat extends StringValueFormat[LicenseText] {
override val from: String => Either[String, LicenseText] = LicenseText.from
implicit object LicenseIdentifierFormat extends StringValueFormat[LicenseIdentifier] {
override val from: String => Either[String, LicenseIdentifier] = LicenseIdentifier.from
}

implicit object LicenseUriFormat extends StringValueFormat[LicenseUri] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import org.knora.webapi.messages.OntologyConstants
import org.knora.webapi.messages.SmartIri
import org.knora.webapi.messages.StringFormatter
import org.knora.webapi.messages.v2.responder.valuemessages.*
import org.knora.webapi.slice.admin.domain.model.KnoraProject.CopyrightAttribution
import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseText
import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseUri
import org.knora.webapi.slice.admin.domain.model.Authorship
import org.knora.webapi.slice.admin.domain.model.CopyrightHolder
import org.knora.webapi.slice.admin.domain.model.LicenseIdentifier
import org.knora.webapi.slice.admin.domain.model.LicenseUri
import org.knora.webapi.slice.resources.IiifImageRequestUrl

object FileModelUtil {
Expand Down Expand Up @@ -86,10 +87,11 @@ object FileModelUtil {
internalMimeType: Option[String],
originalFilename: Option[String],
originalMimeType: Option[String],
comment: Option[String],
copyrightAttribution: Option[CopyrightAttribution],
licenseText: Option[LicenseText],
licenseUri: Option[LicenseUri],
copyrightHolder: Option[CopyrightHolder] = None,
authorship: Option[List[Authorship]] = None,
licenseIdentifier: Option[LicenseIdentifier] = None,
licenseUri: Option[LicenseUri] = None,
comment: Option[String] = None,
): FileValueContentV2 =
fileType match {
case FileType.DocumentFile(pageCount, dimX, dimY) =>
Expand All @@ -100,9 +102,10 @@ object FileModelUtil {
internalMimeType = internalMimeType.getOrElse("application/pdf"),
originalFilename = originalFilename,
originalMimeType = Some(originalMimeType.getOrElse("application/pdf")),
copyrightAttribution,
licenseText,
licenseUri,
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
),
pageCount = pageCount,
dimX = dimX,
Expand All @@ -117,9 +120,10 @@ object FileModelUtil {
internalMimeType = internalMimeType.getOrElse("image/jp2"),
originalFilename = originalFilename,
originalMimeType = originalMimeType,
copyrightAttribution,
licenseText,
licenseUri,
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
),
dimX = dimX,
dimY = dimY,
Expand All @@ -133,9 +137,10 @@ object FileModelUtil {
internalMimeType = internalMimeType.getOrElse("image/jp2"),
originalFilename = originalFilename,
originalMimeType = originalMimeType,
copyrightAttribution,
licenseText,
licenseUri,
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
),
externalUrl = externalUrl,
comment = comment,
Expand All @@ -148,9 +153,10 @@ object FileModelUtil {
internalMimeType = internalMimeType.get,
originalFilename = originalFilename,
originalMimeType = internalMimeType,
copyrightAttribution,
licenseText,
licenseUri,
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
),
)
case FileType.TextFile =>
Expand All @@ -161,9 +167,10 @@ object FileModelUtil {
internalMimeType = internalMimeType.get,
originalFilename = originalFilename,
originalMimeType = internalMimeType,
copyrightAttribution,
licenseText,
licenseUri,
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
),
)
case FileType.AudioFile =>
Expand All @@ -174,9 +181,10 @@ object FileModelUtil {
internalMimeType = internalMimeType.get,
originalFilename = originalFilename,
originalMimeType = internalMimeType,
copyrightAttribution,
licenseText,
licenseUri,
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
),
)
case FileType.ArchiveFile =>
Expand All @@ -187,9 +195,10 @@ object FileModelUtil {
internalMimeType = internalMimeType.getOrElse("application/zip"),
originalFilename = originalFilename,
originalMimeType = internalMimeType,
copyrightAttribution,
licenseText,
licenseUri,
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
),
comment = comment,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@ import org.knora.webapi.messages.v2.responder.resourcemessages.CreateResourceV2
import org.knora.webapi.messages.v2.responder.resourcemessages.CreateValueInNewResourceV2
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.slice.admin.api.model.Project
import org.knora.webapi.slice.admin.domain.model.KnoraProject.CopyrightAttribution
import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseText
import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseUri
import org.knora.webapi.slice.admin.domain.model.KnoraProject.Shortcode
import org.knora.webapi.slice.admin.domain.model.*
import org.knora.webapi.slice.admin.domain.model.KnoraProject.*

sealed abstract case class UploadFileRequest private (
fileType: FileType,
internalFilename: String,
label: String,
resourceIRI: Option[String] = None,
copyrightAttribution: Option[CopyrightAttribution] = None,
licenseText: Option[LicenseText] = None,
copyrightHolder: Option[CopyrightHolder] = None,
authorship: Option[List[Authorship]] = None,
licenseIdentifier: Option[LicenseIdentifier] = None,
licenseUri: Option[LicenseUri] = None,
) {
) { self =>

/**
* Create a JSON-LD serialization of the request. This can be used for e2e and integration tests.
Expand Down Expand Up @@ -57,22 +56,32 @@ sealed abstract case class UploadFileRequest private (
case None => ""
}

s"""{
| $resorceIRIOrEmptyString"@type" : "$ontologyName:$classNameWithDefaults",
| "$fileValuePropertyName" : {
| "@type" : "$fileValueType",
| "knora-api:fileValueHasFilename" : "$internalFilename"
| ${copyrightAttribution.map(ca => s""","knora-api:hasCopyrightAttribution" : "${ca.value}"""").getOrElse("")}
| ${licenseText.map(l => s""","knora-api:hasLicenseText" : "${l.value}"""").getOrElse("")}
| ${licenseUri
.map(u => s""", "knora-api:hasLicenseUri" : { "@type" : "xsd:anyURI", "@value":"${u.value}" }""")
.getOrElse("")}
| },
| "knora-api:attachedToProject" : {
| "@id" : "http://rdfh.ch/projects/$shortcode"
| },
| "rdfs:label" : "$label",
| $context}""".stripMargin
val copyrightHolderJson =
copyrightHolder.map(ca => s""","knora-api:hasCopyrightHolder" : "${ca.value}"""").getOrElse("")
val authorshipJson = authorship
.filter(_.nonEmpty)
.map(a => s""","knora-api:hasAuthorship" : [ ${a.map(_.value).mkString("\"", "\",\"", "\"")} ]""")
.getOrElse("")

val jsonLd =
s"""{
| $resorceIRIOrEmptyString"@type" : "$ontologyName:$classNameWithDefaults",
| "$fileValuePropertyName" : {
| "@type" : "$fileValueType",
| "knora-api:fileValueHasFilename" : "$internalFilename"
| $copyrightHolderJson
| $authorshipJson
| ${licenseIdentifier.map(l => s""","knora-api:hasLicenseIdentifier" : "${l.value}"""").getOrElse("")}
| ${licenseUri
.map(u => s""", "knora-api:hasLicenseUri" : { "@type" : "xsd:anyURI", "@value":"${u.value}" }""")
.getOrElse("")}
| },
| "knora-api:attachedToProject" : {
| "@id" : "http://rdfh.ch/projects/$shortcode"
| },
| "rdfs:label" : "$label",
| $context}""".stripMargin
jsonLd
}

/**
Expand Down Expand Up @@ -116,9 +125,6 @@ sealed abstract case class UploadFileRequest private (
resourceClassIRI: Option[SmartIri] = None,
valuePropertyIRI: Option[SmartIri] = None,
project: Option[Project] = None,
copyrightAttribution: Option[CopyrightAttribution] = None,
licenseText: Option[LicenseText] = None,
licenseUri: Option[LicenseUri] = None,
): CreateResourceV2 = {
implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance

Expand All @@ -137,9 +143,10 @@ sealed abstract case class UploadFileRequest private (
originalFilename = originalFilename,
originalMimeType = originalMimeType,
comment = comment,
copyrightAttribution,
licenseText,
licenseUri,
copyrightHolder = self.copyrightHolder,
authorship = self.authorship,
licenseIdentifier = self.licenseIdentifier,
licenseUri = self.licenseUri,
)

val values = List(
Expand Down Expand Up @@ -190,17 +197,19 @@ object UploadFileRequest {
internalFilename: String,
label: String = "test label",
resourceIRI: Option[String] = None,
copyrightAttribution: Option[CopyrightAttribution] = None,
licenseText: Option[LicenseText] = None,
copyrightHolder: Option[CopyrightHolder] = None,
authorship: Option[List[Authorship]] = None,
licenseIdentifier: Option[LicenseIdentifier] = None,
licenseUri: Option[LicenseUri] = None,
): UploadFileRequest =
new UploadFileRequest(
fileType,
internalFilename,
label,
resourceIRI,
copyrightAttribution,
licenseText,
copyrightHolder,
authorship,
licenseIdentifier,
licenseUri,
) {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import org.knora.webapi.models.filemodels.*
import org.knora.webapi.responders.v2.ResourcesResponseCheckerV2.compareReadResourcesSequenceV2Response
import org.knora.webapi.routing.UnsafeZioRun
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.slice.admin.domain.model.User
import org.knora.webapi.slice.admin.domain.model.*
import org.knora.webapi.slice.resources.IiifImageRequestUrl
import org.knora.webapi.store.triplestore.api.TriplestoreService
import org.knora.webapi.store.triplestore.api.TriplestoreService.Queries.Ask
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4318,10 +4318,6 @@ class ValuesResponderV2Spec extends CoreSpec with ImplicitSender {
Some(mimeTypeJP2),
Some("test.tiff"),
Some(mimeTypeTIFF),
None,
None,
None,
None,
),
),
anythingUser1,
Expand Down Expand Up @@ -4370,10 +4366,6 @@ class ValuesResponderV2Spec extends CoreSpec with ImplicitSender {
Some(internalMimeType),
originalFilename,
originalMimeType,
None,
None,
None,
None,
),
),
anythingUser1,
Expand Down
Loading
Loading