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 LegalInfo (authorship, copyright holder, license) to FileValue (DEV-4502) #3459

Merged
merged 73 commits into from
Feb 18, 2025
Merged
Changes from 1 commit
Commits
Show all changes
73 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
ec0dbf5
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Jan 28, 2025
a7d8af4
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Jan 28, 2025
3310b0c
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Jan 29, 2025
4294ed6
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Jan 31, 2025
d0dd27d
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 3, 2025
b5a2d42
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 3, 2025
e8dcd90
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 4, 2025
3ee520c
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 5, 2025
d75104a
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 5, 2025
574e7ab
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 6, 2025
2f01a33
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 6, 2025
5815e91
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 6, 2025
42cfedb
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 7, 2025
7c4627f
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 7, 2025
036a707
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 10, 2025
386a23d
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 10, 2025
8b682d3
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 10, 2025
cea6df8
add LicenseIri model
seakayone Feb 12, 2025
97a7d27
rm license date
seakayone Feb 12, 2025
1bbd11c
rm license uri from filevalue
seakayone Feb 12, 2025
6183a75
replace FileValue.LicenseIdentifier by LicenseIri
seakayone Feb 12, 2025
d350bb1
replace FileValue.LicenseIdentifier by LicenseIri
seakayone Feb 13, 2025
cf9a9ca
replace FileValue.LicenseIdentifier by LicenseIri
seakayone Feb 13, 2025
27f26a0
rm unused code
seakayone Feb 13, 2025
1e3eb05
rm unused code
seakayone Feb 13, 2025
56fc36b
rm unused code
seakayone Feb 13, 2025
0397807
add License model to knora-base
seakayone Feb 13, 2025
b64a15f
rerun OntologyFormatsE2ESpec
seakayone Feb 13, 2025
e9e5512
rename LegalInfo
seakayone Feb 13, 2025
6aac122
fmt
seakayone Feb 13, 2025
13f9a0f
move json codecs to companion
seakayone Feb 13, 2025
fd42939
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 13, 2025
b78ac82
rm unused code
seakayone Feb 14, 2025
44d746f
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 17, 2025
2d37e60
Merge branch 'main' into feat/add-copyright-holder-and-authorship-to-…
seakayone Feb 17, 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
Prev Previous commit
Next Next commit
add ResourcesResponderV2 test for copyright and licenses infos
seakayone committed Jan 14, 2025

Unverified

This user has not yet uploaded their public signing key.
commit 378290df6c557e0451664419b35388982b3500c2
Original file line number Diff line number Diff line change
@@ -27,9 +27,11 @@ sealed abstract case class UploadFileRequest private (
label: String,
resourceIRI: Option[String] = None,
copyrightHolder: Option[CopyrightHolder] = None,
authorship: Option[List[Authorship]] = None,
licenseText: Option[LicenseText] = None,
licenseUri: Option[LicenseUri] = None,
) {
licenseDate: Option[LicenseDate] = None,
) { self =>

/**
* Create a JSON-LD serialization of the request. This can be used for e2e and integration tests.
@@ -64,10 +66,17 @@ sealed abstract case class UploadFileRequest private (
| "@type" : "$fileValueType",
| "knora-api:fileValueHasFilename" : "$internalFilename"
| ${copyrightHolder.map(ca => s""","knora-api:hasCopyrightHolder" : "${ca.value}"""").getOrElse("")}
| ${authorship
.filter(_.nonEmpty)
.map(a => s""","knora-api:hasAuthorship" : [ ${a.map(_.value).mkString("\"", ",", " \"")} ]""")
.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("")}
| ${licenseDate
.map(d => s""", "knora-api:hasLicenseDate" : { "@type" : "xsd:date", "@value":"${d.value.toString}" }""")
.getOrElse("")}
| },
| "knora-api:attachedToProject" : {
| "@id" : "http://rdfh.ch/projects/$shortcode"
@@ -117,11 +126,6 @@ sealed abstract case class UploadFileRequest private (
resourceClassIRI: Option[SmartIri] = None,
valuePropertyIRI: Option[SmartIri] = None,
project: Option[Project] = None,
copyrightHolder: Option[CopyrightHolder] = None,
authorship: Option[List[Authorship]] = None,
licenseText: Option[LicenseText] = None,
licenseUri: Option[LicenseUri] = None,
licenseDate: Option[LicenseDate] = None,
): CreateResourceV2 = {
implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance

@@ -140,11 +144,11 @@ sealed abstract case class UploadFileRequest private (
originalFilename = originalFilename,
originalMimeType = originalMimeType,
comment = comment,
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseText = licenseText,
licenseUri = licenseUri,
licenseDate = licenseDate,
copyrightHolder = self.copyrightHolder,
authorship = self.authorship,
licenseText = self.licenseText,
licenseUri = self.licenseUri,
licenseDate = self.licenseDate,
)

val values = List(
@@ -196,17 +200,21 @@ object UploadFileRequest {
label: String = "test label",
resourceIRI: Option[String] = None,
copyrightHolder: Option[CopyrightHolder] = None,
authorship: Option[List[Authorship]] = None,
licenseText: Option[LicenseText] = None,
licenseUri: Option[LicenseUri] = None,
licenseDate: Option[LicenseDate] = None,
): UploadFileRequest =
new UploadFileRequest(
fileType,
internalFilename,
label,
resourceIRI,
copyrightHolder,
authorship,
licenseText,
licenseUri,
licenseDate,
) {}
}

Original file line number Diff line number Diff line change
@@ -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
@@ -1144,6 +1144,52 @@ class ResourcesResponderV2Spec extends CoreSpec with ImplicitSender {
)
}

"create a still image file value with copyright and license information" in {
val resourceIri: IRI = stringFormatter.makeRandomResourceIri(SharedTestDataADM.anythingProject.shortcode)

val copyrightHolder = CopyrightHolder.unsafeFrom("The University of Basel")
val authorship = List("Hans Meier", "Peter Müller").map(Authorship.unsafeFrom)
val licenseText = LicenseText.unsafeFrom("CC BY-SA 4.0")
val licenseUri = LicenseUri.unsafeFrom("https://creativecommons.org/licenses/by-sa/4.0/")
val licenseDate = LicenseDate.unsafeFrom("2020-01-01")

val inputResource = UploadFileRequest
.make(
fileType = FileType.StillImageFile(
dimX = 512,
dimY = 256,
),
internalFilename = "bar.jp2",
copyrightHolder = Some(copyrightHolder),
authorship = Some(authorship),
licenseText = Some(licenseText),
licenseUri = Some(licenseUri),
licenseDate = Some(licenseDate),
)
.toMessage(resourceIri = Some(resourceIri))

val _ = UnsafeZioRun.runOrThrow(
resourcesResponderV2(
_.createResource(CreateResourceRequestV2(inputResource, anythingUserProfile, UUID.randomUUID)).logError,
),
)

val actual: ReadResourceV2 = getResource(resourceIri)
val fileValue: FileValueV2 =
actual.values.head._2
.map(_.valueContent)
.collect { case sifvc: StillImageFileValueContentV2 => sifvc }
.map(_.fileValue)
.head

assert(fileValue.copyrightHolder.contains(copyrightHolder))
assert(fileValue.licenseText.contains(licenseText))
assert(fileValue.licenseUri.contains(licenseUri))
// not (yet) working:
// assert(fileValue.licenseDate.contains(licenseDate))
// assert(fileValue.authorship.contains(authorship))
}

"create a resource with an external still image file value" in {
val resourceIri: IRI = stringFormatter.makeRandomResourceIri(SharedTestDataADM.anythingProject.shortcode)