Skip to content

Commit

Permalink
Remove dimX and dimY from StillImageExternalFilevalue
Browse files Browse the repository at this point in the history
  • Loading branch information
seakayone committed Mar 26, 2024
1 parent 3060f6b commit d978fd8
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ package org.knora.webapi.e2e.v2

import org.apache.pekko.http.scaladsl.model._
import org.apache.pekko.http.scaladsl.model.headers.Accept
import org.scalatest.Inspectors.forEvery
import spray.json._

import java.net.URLEncoder
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths

import org.knora.webapi._
import org.knora.webapi.e2e.ClientTestDataCollector
import org.knora.webapi.e2e.TestDataFileContent
Expand All @@ -16,13 +24,6 @@ import org.knora.webapi.messages.store.triplestoremessages.RdfDataObject
import org.knora.webapi.sharedtestdata.SharedOntologyTestDataADM
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.util._
import org.scalatest.Inspectors.forEvery
import spray.json._

import java.net.URLEncoder
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths

class OntologyFormatsE2ESpec extends E2ESpec {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,61 +17,59 @@ object FileModelUtil {
private implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance

def getFileRepresentationClassIri(fileType: FileType): SmartIri = fileType match {
case FileType.DocumentFile(_, _, _) => OntologyConstants.KnoraApiV2Complex.DocumentRepresentation.toSmartIri
case FileType.StillImageFile(_, _) => OntologyConstants.KnoraApiV2Complex.StillImageRepresentation.toSmartIri
case FileType.StillImageExternalFile(_, _, _) =>
OntologyConstants.KnoraApiV2Complex.StillImageRepresentation.toSmartIri
case FileType.MovingImageFile(_, _) => OntologyConstants.KnoraApiV2Complex.MovingImageRepresentation.toSmartIri
case FileType.TextFile => OntologyConstants.KnoraApiV2Complex.TextRepresentation.toSmartIri
case FileType.AudioFile => OntologyConstants.KnoraApiV2Complex.AudioRepresentation.toSmartIri
case FileType.ArchiveFile => OntologyConstants.KnoraApiV2Complex.ArchiveRepresentation.toSmartIri
case FileType.DocumentFile(_, _, _) => OntologyConstants.KnoraApiV2Complex.DocumentRepresentation.toSmartIri
case FileType.StillImageFile(_, _) => OntologyConstants.KnoraApiV2Complex.StillImageRepresentation.toSmartIri
case FileType.StillImageExternalFile(_) => OntologyConstants.KnoraApiV2Complex.StillImageRepresentation.toSmartIri
case FileType.MovingImageFile(_, _) => OntologyConstants.KnoraApiV2Complex.MovingImageRepresentation.toSmartIri
case FileType.TextFile => OntologyConstants.KnoraApiV2Complex.TextRepresentation.toSmartIri
case FileType.AudioFile => OntologyConstants.KnoraApiV2Complex.AudioRepresentation.toSmartIri
case FileType.ArchiveFile => OntologyConstants.KnoraApiV2Complex.ArchiveRepresentation.toSmartIri
}

def getFileRepresentationPropertyIri(fileType: FileType): SmartIri = fileType match {
case FileType.DocumentFile(_, _, _) => OntologyConstants.KnoraApiV2Complex.HasDocumentFileValue.toSmartIri
case FileType.StillImageFile(_, _) => OntologyConstants.KnoraApiV2Complex.HasStillImageFileValue.toSmartIri
case FileType.StillImageExternalFile(_, _, _) =>
OntologyConstants.KnoraApiV2Complex.HasStillImageFileValue.toSmartIri
case FileType.MovingImageFile(_, _) => OntologyConstants.KnoraApiV2Complex.HasMovingImageFileValue.toSmartIri
case FileType.TextFile => OntologyConstants.KnoraApiV2Complex.HasTextFileValue.toSmartIri
case FileType.AudioFile => OntologyConstants.KnoraApiV2Complex.HasAudioFileValue.toSmartIri
case FileType.ArchiveFile => OntologyConstants.KnoraApiV2Complex.HasArchiveFileValue.toSmartIri
case FileType.DocumentFile(_, _, _) => OntologyConstants.KnoraApiV2Complex.HasDocumentFileValue.toSmartIri
case FileType.StillImageFile(_, _) => OntologyConstants.KnoraApiV2Complex.HasStillImageFileValue.toSmartIri
case FileType.StillImageExternalFile(_) => OntologyConstants.KnoraApiV2Complex.HasStillImageFileValue.toSmartIri
case FileType.MovingImageFile(_, _) => OntologyConstants.KnoraApiV2Complex.HasMovingImageFileValue.toSmartIri
case FileType.TextFile => OntologyConstants.KnoraApiV2Complex.HasTextFileValue.toSmartIri
case FileType.AudioFile => OntologyConstants.KnoraApiV2Complex.HasAudioFileValue.toSmartIri
case FileType.ArchiveFile => OntologyConstants.KnoraApiV2Complex.HasArchiveFileValue.toSmartIri
}

def getFileValuePropertyName(fileType: FileType): String = fileType match {
case FileType.DocumentFile(_, _, _) => "knora-api:hasDocumentFileValue"
case FileType.StillImageFile(_, _) => "knora-api:hasStillImageFileValue"
case FileType.StillImageExternalFile(_, _, _) => "knora-api:hasStillImageFileValue"
case FileType.MovingImageFile(_, _) => "knora-api:hasMovingImageFileValue"
case FileType.TextFile => "knora-api:hasTextFileValue"
case FileType.AudioFile => "knora-api:hasAudioFileValue"
case FileType.ArchiveFile => "knora-api:hasArchiveFileValue"
case FileType.DocumentFile(_, _, _) => "knora-api:hasDocumentFileValue"
case FileType.StillImageFile(_, _) => "knora-api:hasStillImageFileValue"
case FileType.StillImageExternalFile(_) => "knora-api:hasStillImageFileValue"
case FileType.MovingImageFile(_, _) => "knora-api:hasMovingImageFileValue"
case FileType.TextFile => "knora-api:hasTextFileValue"
case FileType.AudioFile => "knora-api:hasAudioFileValue"
case FileType.ArchiveFile => "knora-api:hasArchiveFileValue"
}

def getDefaultClassName(fileType: FileType): String = fileType match {
case FileType.DocumentFile(_, _, _) => "DocumentRepresentation"
case FileType.StillImageFile(_, _) => "StillImageRepresentation"
case FileType.StillImageExternalFile(_, _, _) => "StillImageRepresentation"
case FileType.MovingImageFile(_, _) => "MovingImageRepresentation"
case FileType.TextFile => "TextRepresentation"
case FileType.AudioFile => "AudioRepresentation"
case FileType.ArchiveFile => "ArchiveRepresentation"
case FileType.DocumentFile(_, _, _) => "DocumentRepresentation"
case FileType.StillImageFile(_, _) => "StillImageRepresentation"
case FileType.StillImageExternalFile(_) => "StillImageRepresentation"
case FileType.MovingImageFile(_, _) => "MovingImageRepresentation"
case FileType.TextFile => "TextRepresentation"
case FileType.AudioFile => "AudioRepresentation"
case FileType.ArchiveFile => "ArchiveRepresentation"
}

def getFileValueType(fileType: FileType): String = fileType match {
case FileType.DocumentFile(_, _, _) => "knora-api:DocumentFileValue"
case FileType.StillImageFile(_, _) => "knora-api:StillImageFileValue"
case FileType.StillImageExternalFile(_, _, _) => "knora-api:StillImageExternalFileValue"
case FileType.MovingImageFile(_, _) => "knora-api:MovingImageFileValue"
case FileType.TextFile => "knora-api:TextFileValue"
case FileType.AudioFile => "knora-api:AudioFileValue"
case FileType.ArchiveFile => "knora-api:ArchiveFileValue"
case FileType.DocumentFile(_, _, _) => "knora-api:DocumentFileValue"
case FileType.StillImageFile(_, _) => "knora-api:StillImageFileValue"
case FileType.StillImageExternalFile(_) => "knora-api:StillImageExternalFileValue"
case FileType.MovingImageFile(_, _) => "knora-api:MovingImageFileValue"
case FileType.TextFile => "knora-api:TextFileValue"
case FileType.AudioFile => "knora-api:AudioFileValue"
case FileType.ArchiveFile => "knora-api:ArchiveFileValue"
}

def getFileValueTypeIRI(fileType: FileType): SmartIri = fileType match {
case FileType.DocumentFile(_, _, _) => OntologyConstants.KnoraApiV2Complex.DocumentFileValue.toSmartIri
case FileType.StillImageFile(_, _) => OntologyConstants.KnoraApiV2Complex.StillImageFileValue.toSmartIri
case FileType.StillImageExternalFile(_, _, _) =>
case FileType.StillImageExternalFile(_) =>
OntologyConstants.KnoraApiV2Complex.StillImageExternalFileValue.toSmartIri
case FileType.MovingImageFile(_, _) => OntologyConstants.KnoraApiV2Complex.MovingImageFileValue.toSmartIri
case FileType.TextFile => OntologyConstants.KnoraApiV2Complex.TextFileValue.toSmartIri
Expand Down Expand Up @@ -115,7 +113,7 @@ object FileModelUtil {
dimY = dimY,
comment = comment,
)
case FileType.StillImageExternalFile(externalUrl, dimX, dimY) =>
case FileType.StillImageExternalFile(externalUrl) =>
StillImageExternalFileValueContentV2(
ontologySchema = ApiV2Complex,
fileValue = FileValueV2(
Expand All @@ -124,8 +122,6 @@ object FileModelUtil {
originalFilename = originalFilename,
originalMimeType = originalMimeType,
),
dimX = dimX,
dimY = dimY,
externalUrl = externalUrl,
comment = comment,
)
Expand Down Expand Up @@ -219,10 +215,10 @@ object FileType {
dimX: Option[Int] = Some(100),
dimY: Option[Int] = Some(100),
) extends FileType
case class StillImageFile(dimX: Int = 100, dimY: Int = 100) extends FileType
case class StillImageExternalFile(externalUrl: IiifImageRequestUrl, dimX: Int = 100, dimY: Int = 100) extends FileType
case class MovingImageFile(dimX: Int = 100, dimY: Int = 100) extends FileType
case object TextFile extends FileType
case object AudioFile extends FileType
case object ArchiveFile extends FileType
case class StillImageFile(dimX: Int = 100, dimY: Int = 100) extends FileType
case class StillImageExternalFile(externalUrl: IiifImageRequestUrl) extends FileType
case class MovingImageFile(dimX: Int = 100, dimY: Int = 100) extends FileType
case object TextFile extends FileType
case object AudioFile extends FileType
case object ArchiveFile extends FileType
}
Original file line number Diff line number Diff line change
Expand Up @@ -1161,11 +1161,7 @@ class ResourcesResponderV2Spec extends CoreSpec with ImplicitSender {
)
val inputResource: CreateResourceV2 = UploadFileRequest
.make(
fileType = FileType.StillImageExternalFile(
externalUrl = imageRequestUrl,
dimX = 512,
dimY = 256,
),
fileType = FileType.StillImageExternalFile(imageRequestUrl),
internalFilename = "IQUO3t1AABm-TTTTTTTTTTT.jp2",
)
.toMessage(resourceIri = Some(resourceIri))
Expand Down
14 changes: 1 addition & 13 deletions webapi/src/main/resources/knora-ontologies/knora-base.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -2028,12 +2028,6 @@
rdfs:subClassOf :StillImageAbstractFileValue,
[ rdf:type owl:Restriction ;
owl:onProperty :externalUrl ;
owl:cardinality "1"^^xsd:nonNegativeInteger ],
[ rdf:type owl:Restriction ;
owl:onProperty :dimY ;
owl:cardinality "1"^^xsd:nonNegativeInteger ],
[ rdf:type owl:Restriction ;
owl:onProperty :dimX ;
owl:cardinality "1"^^xsd:nonNegativeInteger ] ;
rdfs:comment "A file containing a two-dimensional still image"@en .

Expand All @@ -2042,13 +2036,7 @@

:StillImageAbstractFileValue
rdf:type owl:Class ;
rdfs:subClassOf :FileValue,
[ rdf:type owl:Restriction ;
owl:onProperty :dimY ;
owl:cardinality "1"^^xsd:nonNegativeInteger ],
[ rdf:type owl:Restriction ;
owl:onProperty :dimX ;
owl:cardinality "1"^^xsd:nonNegativeInteger ] ;
rdfs:subClassOf :FileValue ;
rdfs:comment "A file containing a two-dimensional still image"@en .


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1080,11 +1080,9 @@ final case class ConstructResponseUtilV2Live(
case OntologyConstants.KnoraBase.StillImageExternalFileValue =>
ZIO.succeed(
StillImageExternalFileValueContentV2(
ontologySchema = InternalSchema,
fileValue = fileValue,
dimX = valueObject.requireIntObject(OntologyConstants.KnoraBase.DimX.toSmartIri),
dimY = valueObject.requireIntObject(OntologyConstants.KnoraBase.DimY.toSmartIri),
externalUrl = IiifImageRequestUrl.unsafeFrom(
InternalSchema,
fileValue,
IiifImageRequestUrl.unsafeFrom(
valueObject.requireStringObject(OntologyConstants.KnoraBase.ExternalUrl.toSmartIri),
),
comment = valueCommentOption,
Expand Down Expand Up @@ -1680,7 +1678,7 @@ final case class ConstructResponseUtilV2Live(
)
}
} else {
ZIO.succeed(None)
ZIO.none
}
} yield mapping.mappingIri -> MappingAndXSLTransformation(
mapping = mapping.mapping,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2782,10 +2782,8 @@ object StillImageFileValueContentV2 {
case class StillImageExternalFileValueContentV2(
ontologySchema: OntologySchema,
fileValue: FileValueV2,
dimX: Int,
dimY: Int,
externalUrl: IiifImageRequestUrl,
comment: Option[String] = None,
comment: Option[IRI] = None,
) extends FileValueContentV2 {
override def valueType: SmartIri = {
implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance
Expand All @@ -2811,8 +2809,6 @@ case class StillImageExternalFileValueContentV2(
case ApiV2Complex =>
JsonLDObject(
toJsonLDObjectMapInComplexSchema(makeFileUrl) ++ Map(
StillImageFileValueHasDimX -> JsonLDInt(dimX),
StillImageFileValueHasDimY -> JsonLDInt(dimY),
StillImageFileValueHasIIIFBaseUrl -> JsonLDUtil
.datatypeValueToJsonLDObject(

Check warning on line 2813 in webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala#L2810-L2813

Added lines #L2810 - L2813 were not covered by tests
value = {
Expand Down Expand Up @@ -2869,10 +2865,8 @@ object StillImageExternalFileValueContentV2 {
Some("originalFilename"),
Some("originalMimeType"),

Check warning on line 2866 in webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala#L2857-L2866

Added lines #L2857 - L2866 were not covered by tests
),
dimX = 0,
dimY = 0,
comment = comment,
externalUrl = externalUrl,
comment = comment,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@
}

case stillImageFileValue: StillImageExternalFileValueContentV2 => {
<@newValueIri> knora-base:externalUrl """@stillImageFileValue.externalUrl.value.toString""" ;
knora-base:dimX @stillImageFileValue.dimX ;
knora-base:dimY @stillImageFileValue.dimY .
<@newValueIri> knora-base:externalUrl """@stillImageFileValue.externalUrl.value.toString""" .
}

case documentFileValue: DocumentFileValueContentV2 => {
Expand Down

0 comments on commit d978fd8

Please sign in to comment.