Skip to content

Commit

Permalink
rename License Text to License Identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
seakayone committed Jan 20, 2025
1 parent 8276e44 commit b141805
Show file tree
Hide file tree
Showing 20 changed files with 100 additions and 99 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object CopyrightAndLicensesSpec extends E2EZSpec {
private implicit val sf: StringFormatter = StringFormatter.getInitializedTestInstance
private val aCopyrightHolder = CopyrightHolder.unsafeFrom("Universität Basel")
private val someAuthorship = List("Hans Müller", "Gigi DAgostino").map(Authorship.unsafeFrom)
private val aLicenseText = LicenseText.unsafeFrom("CC BY-SA 4.0")
private val aLicenseIdentifier = LicenseIdentifier.unsafeFrom("CC BY-SA 4.0")
private val aLicenseUri = LicenseUri.unsafeFrom("https://creativecommons.org/licenses/by-sa/4.0/")

private val createResourceSuite = suite("Creating Resources")(
Expand All @@ -62,7 +62,7 @@ object CopyrightAndLicensesSpec extends E2EZSpec {
} yield assertTrue(
info.copyrightHolder.isEmpty,
info.authorship.isEmpty,
info.licenseText.isEmpty,
info.licenseIdentifier.isEmpty,
info.licenseUri.isEmpty,
info.licenseDate.contains(LicenseDate.makeNew),
)
Expand All @@ -76,7 +76,7 @@ object CopyrightAndLicensesSpec extends E2EZSpec {
info <- copyrightAndLicenseInfo(createResourceResponseModel)
} yield assertTrue(
info.copyrightHolder.contains(aCopyrightHolder),
info.licenseText.contains(aLicenseText),
info.licenseIdentifier.contains(aLicenseIdentifier),
info.licenseUri.contains(aLicenseUri),
info.licenseDate.contains(LicenseDate.makeNew),
) && assert(info.authorship.getOrElse(List.empty))(hasSameElements(someAuthorship))
Expand All @@ -92,7 +92,7 @@ object CopyrightAndLicensesSpec extends E2EZSpec {
info <- copyrightAndLicenseInfo(getResponseModel)
} yield assertTrue(
info.copyrightHolder.contains(aCopyrightHolder),
info.licenseText.contains(aLicenseText),
info.licenseIdentifier.contains(aLicenseIdentifier),
info.licenseUri.contains(aLicenseUri),
info.licenseDate.contains(LicenseDate.makeNew),
) && assert(info.authorship.getOrElse(List.empty))(hasSameElements(someAuthorship))
Expand All @@ -107,7 +107,7 @@ object CopyrightAndLicensesSpec extends E2EZSpec {
info <- copyrightAndLicenseInfo(valueResponseModel)
} yield assertTrue(
info.copyrightHolder.contains(aCopyrightHolder),
info.licenseText.contains(aLicenseText),
info.licenseIdentifier.contains(aLicenseIdentifier),
info.licenseUri.contains(aLicenseUri),
info.licenseDate.contains(LicenseDate.makeNew),
) && assert(info.authorship.getOrElse(List.empty))(hasSameElements(someAuthorship))
Expand All @@ -128,14 +128,14 @@ object CopyrightAndLicensesSpec extends E2EZSpec {
ResourceClassIri.unsafeFrom("http://0.0.0.0:3333/ontology/0001/anything/v2#ThingPicture".toSmartIri),
aCopyrightHolder,
someAuthorship,
aLicenseText,
aLicenseIdentifier,
aLicenseUri,
).jsonLd,
).filterOrElseWith(_.status.isSuccess)(failResponse(s"Failed to create value"))
createdResourceModel <- getResourceFromApi(resourceId)
info <- copyrightAndLicenseInfo(createdResourceModel)
} yield assertTrue(
info.licenseText.contains(aLicenseText),
info.licenseIdentifier.contains(aLicenseIdentifier),
info.licenseUri.contains(aLicenseUri),
info.licenseDate.contains(LicenseDate.makeNew),
) && assert(info.authorship.getOrElse(List.empty))(hasSameElements(someAuthorship))
Expand All @@ -148,7 +148,7 @@ object CopyrightAndLicensesSpec extends E2EZSpec {
resourceClass: ResourceClassIri,
copyrightHolder: CopyrightHolder,
authorship: List[Authorship],
licenseText: LicenseText,
licenseIdentifier: LicenseIdentifier,
licenseUri: LicenseUri,
) {
def jsonLd: String =
Expand All @@ -169,7 +169,7 @@ object CopyrightAndLicensesSpec extends E2EZSpec {
(KA.FileValueHasFilename, Json.Str("test.jpx")),
(KA.HasCopyrightHolder, Json.Str(copyrightHolder.value)),
(KA.HasAuthorship, Json.Arr(authorship.map(_.value).map(Json.Str.apply): _*)),
(KA.HasLicenseText, Json.Str(licenseText.value)),
(KA.HasLicenseIdentifier, Json.Str(licenseIdentifier.value)),
(KA.HasLicenseUri, ldValue(licenseUri.value, XSD.anyURI)),
),
),
Expand All @@ -187,14 +187,14 @@ object CopyrightAndLicensesSpec extends E2EZSpec {
createStillImageResource(
Some(aCopyrightHolder),
Some(someAuthorship),
Some(aLicenseText),
Some(aLicenseIdentifier),
Some(aLicenseUri),
)

private def createStillImageResource(
copyrightHolder: Option[CopyrightHolder] = None,
authorship: Option[List[Authorship]] = None,
licenseText: Option[LicenseText] = None,
licenseIdentifier: Option[LicenseIdentifier] = None,
licenseUri: Option[LicenseUri] = None,
): ZIO[env, Throwable, Model] = {
val jsonLd = UploadFileRequest
Expand All @@ -203,7 +203,7 @@ object CopyrightAndLicensesSpec extends E2EZSpec {
"internalFilename.jpg",
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseText = licenseText,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
)
.toJsonLd(className = Some("ThingPicture"), ontologyName = "anything")
Expand Down Expand Up @@ -267,19 +267,19 @@ object CopyrightAndLicensesSpec extends E2EZSpec {
final case class CopyrightAndLicenseInfo(
copyrightHolder: Option[CopyrightHolder],
authorship: Option[List[Authorship]],
licenseText: Option[LicenseText],
licenseIdentifier: Option[LicenseIdentifier],
licenseUri: Option[LicenseUri],
licenseDate: Option[LicenseDate],
)

private def copyrightAndLicenseInfo(model: Model) =
for {
copyright <- copyrightValueOption(model).map(_.map(CopyrightHolder.unsafeFrom))
authorship <- authorshipValuesOption(model).map(_.map(_.map(Authorship.unsafeFrom)))
licenseText <- licenseTextValueOption(model).map(_.map(LicenseText.unsafeFrom))
licenseUri <- licenseUriValueOption(model).map(_.map(LicenseUri.unsafeFrom))
licenseDate <- licenseDateValueOption(model).map(_.map(LicenseDate.unsafeFrom))
} yield CopyrightAndLicenseInfo(copyright, authorship, licenseText, licenseUri, licenseDate)
copyright <- copyrightValueOption(model).map(_.map(CopyrightHolder.unsafeFrom))
authorship <- authorshipValuesOption(model).map(_.map(_.map(Authorship.unsafeFrom)))
licenseIdentifier <- licenseIdentifierValueOption(model).map(_.map(LicenseIdentifier.unsafeFrom))
licenseUri <- licenseUriValueOption(model).map(_.map(LicenseUri.unsafeFrom))
licenseDate <- licenseDateValueOption(model).map(_.map(LicenseDate.unsafeFrom))
} yield CopyrightAndLicenseInfo(copyright, authorship, licenseIdentifier, licenseUri, licenseDate)

private def copyrightValueOption(model: Model) =
singleStringValueOption(model, KA.HasCopyrightHolder)
Expand All @@ -293,8 +293,8 @@ object CopyrightAndLicensesSpec extends E2EZSpec {
)
.mapError(Exception(_))

private def licenseTextValueOption(model: Model) =
singleStringValueOption(model, KA.HasLicenseText)
private def licenseIdentifierValueOption(model: Model) =
singleStringValueOption(model, KA.HasLicenseIdentifier)

private def licenseUriValueOption(model: Model) =
singleStringValueOption(model, KA.HasLicenseUri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ 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.CopyrightHolder
import org.knora.webapi.slice.admin.domain.model.Group
import org.knora.webapi.slice.admin.domain.model.LicenseText
import org.knora.webapi.slice.admin.domain.model.LicenseIdentifier
import org.knora.webapi.slice.admin.domain.model.LicenseUri
import org.knora.webapi.slice.admin.domain.model.User
import org.knora.webapi.slice.common.Value.StringValue
Expand Down Expand Up @@ -208,8 +208,8 @@ object IntegrationTestAdminJsonProtocol extends TriplestoreJsonProtocol {
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 @@ -13,7 +13,7 @@ import org.knora.webapi.messages.StringFormatter
import org.knora.webapi.messages.v2.responder.valuemessages.*
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.LicenseText
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

Expand Down Expand Up @@ -89,7 +89,7 @@ object FileModelUtil {
originalMimeType: Option[String],
copyrightHolder: Option[CopyrightHolder] = None,
authorship: Option[List[Authorship]] = None,
licenseText: Option[LicenseText] = None,
licenseIdentifier: Option[LicenseIdentifier] = None,
licenseUri: Option[LicenseUri] = None,
comment: Option[String] = None,
): FileValueContentV2 =
Expand All @@ -104,7 +104,7 @@ object FileModelUtil {
originalMimeType = Some(originalMimeType.getOrElse("application/pdf")),
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseText = licenseText,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
),
pageCount = pageCount,
Expand All @@ -122,7 +122,7 @@ object FileModelUtil {
originalMimeType = originalMimeType,
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseText = licenseText,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
),
dimX = dimX,
Expand All @@ -139,7 +139,7 @@ object FileModelUtil {
originalMimeType = originalMimeType,
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseText = licenseText,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
),
externalUrl = externalUrl,
Expand All @@ -155,7 +155,7 @@ object FileModelUtil {
originalMimeType = internalMimeType,
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseText = licenseText,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
),
)
Expand All @@ -169,7 +169,7 @@ object FileModelUtil {
originalMimeType = internalMimeType,
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseText = licenseText,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
),
)
Expand All @@ -183,7 +183,7 @@ object FileModelUtil {
originalMimeType = internalMimeType,
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseText = licenseText,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
),
)
Expand All @@ -197,7 +197,7 @@ object FileModelUtil {
originalMimeType = internalMimeType,
copyrightHolder = copyrightHolder,
authorship = authorship,
licenseText = licenseText,
licenseIdentifier = licenseIdentifier,
licenseUri = licenseUri,
),
comment = comment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.slice.admin.api.model.Project
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.LicenseText
import org.knora.webapi.slice.admin.domain.model.LicenseIdentifier
import org.knora.webapi.slice.admin.domain.model.LicenseUri

sealed abstract case class UploadFileRequest private (
Expand All @@ -27,7 +27,7 @@ sealed abstract case class UploadFileRequest private (
resourceIRI: Option[String] = None,
copyrightHolder: Option[CopyrightHolder] = None,
authorship: Option[List[Authorship]] = None,
licenseText: Option[LicenseText] = None,
licenseIdentifier: Option[LicenseIdentifier] = None,
licenseUri: Option[LicenseUri] = None,
) { self =>

Expand Down Expand Up @@ -73,7 +73,7 @@ sealed abstract case class UploadFileRequest private (
| "knora-api:fileValueHasFilename" : "$internalFilename"
| $copyrightHolderJson
| $authorshipJson
| ${licenseText.map(l => s""","knora-api:hasLicenseText" : "${l.value}"""").getOrElse("")}
| ${licenseIdentifier.map(l => s""","knora-api:hasLicenseIdentifier" : "${l.value}"""").getOrElse("")}
| ${licenseUri
.map(u => s""", "knora-api:hasLicenseUri" : { "@type" : "xsd:anyURI", "@value":"${u.value}" }""")
.getOrElse("")}
Expand Down Expand Up @@ -147,7 +147,7 @@ sealed abstract case class UploadFileRequest private (
comment = comment,
copyrightHolder = self.copyrightHolder,
authorship = self.authorship,
licenseText = self.licenseText,
licenseIdentifier = self.licenseIdentifier,
licenseUri = self.licenseUri,
)

Expand Down Expand Up @@ -201,7 +201,7 @@ object UploadFileRequest {
resourceIRI: Option[String] = None,
copyrightHolder: Option[CopyrightHolder] = None,
authorship: Option[List[Authorship]] = None,
licenseText: Option[LicenseText] = None,
licenseIdentifier: Option[LicenseIdentifier] = None,
licenseUri: Option[LicenseUri] = None,
): UploadFileRequest =
new UploadFileRequest(
Expand All @@ -211,7 +211,7 @@ object UploadFileRequest {
resourceIRI,
copyrightHolder,
authorship,
licenseText,
licenseIdentifier,
licenseUri,
) {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@
{
"@type": "owl:Restriction",
"owl:onProperty": {
"@id": "knora-api:hasLicenseText"
"@id": "knora-api:hasLicenseIdentifier"
},
"owl:maxCardinality": 1
},
Expand Down Expand Up @@ -1461,13 +1461,13 @@
"@id": "knora-api:hasLicenseDate"
},
{
"rdfs:label": "has license text",
"rdfs:label": "has license identifier",
"rdfs:comment": "Specifies the terms under which a work can be used. This statement may be a reference to a well-known license, such as Creative Commons (e.g. 'CC BY-SA') or a custom license.",
"@type": "owl:DatatypeProperty",
"knora-api:objectType": {
"@id": "xsd:string"
},
"@id": "knora-api:hasLicenseText"
"@id": "knora-api:hasLicenseIdentifier"
},
{
"rdfs:label": "has license URI",
Expand Down
Loading

0 comments on commit b141805

Please sign in to comment.