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(external iiif urls): implement reading and creating of external iiif url #642

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 33 additions & 1 deletion src/api/v2/values/values-endpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ import { ReadBooleanValue } from "../../../models/v2/resources/values/read/read-
import { ReadColorValue } from "../../../models/v2/resources/values/read/read-color-value";
import { KnoraDate, ReadDateValue } from "../../../models/v2/resources/values/read/read-date-value";
import { ReadDecimalValue } from "../../../models/v2/resources/values/read/read-decimal-value";
import { ReadStillImageFileValue } from "../../../models/v2/resources/values/read/read-file-value";
import {
ReadStillImageExternalFileValue,
ReadStillImageFileValue
} from "../../../models/v2/resources/values/read/read-file-value";
import { ReadGeomValue } from "../../../models/v2/resources/values/read/read-geom-value";
import { ReadGeonameValue } from "../../../models/v2/resources/values/read/read-geoname-value";
import { ReadIntValue } from "../../../models/v2/resources/values/read/read-int-value";
Expand Down Expand Up @@ -490,6 +493,35 @@ describe("ValuesEndpoint", () => {

});

it("should read an external image file value", done => {

knoraApiConnection.v2.values.getValue("http://rdfh.ch/0803/RRjceJu5S86zfc_-ZrIEtg", "1-COzXfuTXiwDJ_2GZxeoQ").subscribe(
(res: ReadResource) => {
const externalImageVal = res.getValuesAs("http://api.knora.org/ontology/knora-api/v2#hasStillImageFileValue", ReadStillImageExternalFileValue);
expect(externalImageVal.length).toEqual(1);
expect(externalImageVal[0].externalUrl).toEqual("https://ids.lib.harvard.edu/ids/iiif/24209711/full/105,/0/default.jpg");

expect(getResourceClassDefinitionFromCacheSpy).toHaveBeenCalledTimes(1);
expect(getResourceClassDefinitionFromCacheSpy).toHaveBeenCalledWith("http://0.0.0.0:3333/ontology/0001/anything/v2#ThingPicture");

expect(getListNodeFromCacheSpy).toHaveBeenCalledTimes(0);

done();
}
);

const request = jasmine.Ajax.requests.mostRecent();

const resource = require("../../../../test/data/api/v2/manually-generated/get-still-image-external-file-value-response.json");

request.respondWith(MockAjaxCall.mockResponse(JSON.stringify(resource)));

expect(request.url).toBe("http://0.0.0.0:3333/v2/values/http%3A%2F%2Frdfh.ch%2F0803%2FRRjceJu5S86zfc_-ZrIEtg/1-COzXfuTXiwDJ_2GZxeoQ");

expect(request.method).toEqual("GET");

});

it("should read a geometry value", done => {

knoraApiConnection.v2.values.getValue("http://rdfh.ch/0001/H6gBWUuJSuuO-CilHV8kQw", "we-ybmj-SRen-91n4RaDOQ").subscribe(
Expand Down
18 changes: 10 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ export { ReadBooleanValue } from "./models/v2/resources/values/read/read-boolean
export { ReadColorValue } from "./models/v2/resources/values/read/read-color-value";
export { ReadDateValue, KnoraDate, KnoraPeriod, Precision } from "./models/v2/resources/values/read/read-date-value";
export { ReadDecimalValue } from "./models/v2/resources/values/read/read-decimal-value";
export {
export {
ReadFileValue,
ReadAudioFileValue,
ReadDocumentFileValue,
ReadMovingImageFileValue,
ReadStillImageFileValue,
ReadStillImageExternalFileValue,
ReadArchiveFileValue,
ReadTextFileValue
} from "./models/v2/resources/values/read/read-file-value";
Expand All @@ -182,9 +183,9 @@ export { ReadIntervalValue } from "./models/v2/resources/values/read/read-interv
export { ReadLinkValue } from "./models/v2/resources/values/read/read-link-value";
export { ReadListValue } from "./models/v2/resources/values/read/read-list-value";
export {
ReadTextValue,
ReadTextValueAsString,
ReadTextValueAsHtml,
ReadTextValue,
ReadTextValueAsString,
ReadTextValueAsHtml,
ReadTextValueAsXml
} from "./models/v2/resources/values/read/read-text-value";
export { ReadUriValue } from "./models/v2/resources/values/read/read-uri-value";
Expand All @@ -197,7 +198,7 @@ export { UpdateBooleanValue } from "./models/v2/resources/values/update/update-b
export { UpdateColorValue } from "./models/v2/resources/values/update/update-color-value";
export { UpdateDateValue } from "./models/v2/resources/values/update/update-date-value";
export { UpdateDecimalValue } from "./models/v2/resources/values/update/update-decimal-value";
export {
export {
UpdateFileValue,
UpdateAudioFileValue,
UpdateDocumentFileValue,
Expand All @@ -211,7 +212,7 @@ export { UpdateIntValue } from "./models/v2/resources/values/update/update-int-v
export { UpdateIntervalValue } from "./models/v2/resources/values/update/update-interval-value";
export { UpdateLinkValue } from "./models/v2/resources/values/update/update-link-value";
export { UpdateListValue } from "./models/v2/resources/values/update/update-list-value";
export {
export {
UpdateTextValueAsString,
UpdateTextValueAsXml,
UpdateTextValueAsHtml
Expand All @@ -225,12 +226,13 @@ export { CreateBooleanValue } from "./models/v2/resources/values/create/create-b
export { CreateColorValue } from "./models/v2/resources/values/create/create-color-value";
export { CreateDateValue } from "./models/v2/resources/values/create/create-date-value";
export { CreateDecimalValue } from "./models/v2/resources/values/create/create-decimal-value";
export {
export {
CreateFileValue,
CreateAudioFileValue,
CreateDocumentFileValue,
CreateMovingImageFileValue,
CreateStillImageFileValue,
CreateStillImageExternalFileValue,
CreateTextFileValue,
CreateArchiveFileValue
} from "./models/v2/resources/values/create/create-file-value";
Expand All @@ -239,7 +241,7 @@ export { CreateIntValue } from "./models/v2/resources/values/create/create-int-v
export { CreateIntervalValue } from "./models/v2/resources/values/create/create-interval-value";
export { CreateLinkValue } from "./models/v2/resources/values/create/create-link-value";
export { CreateListValue } from "./models/v2/resources/values/create/create-list-value";
export {
export {
CreateTextValueAsString,
CreateTextValueAsXml
} from "./models/v2/resources/values/create/create-text-value";
Expand Down
3 changes: 3 additions & 0 deletions src/models/v2/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class Constants {
static DDDFileValue = Constants.KnoraApiV2 + Constants.HashDelimiter + "DDDFileValue";
static DocumentFileValue = Constants.KnoraApiV2 + Constants.HashDelimiter + "DocumentFileValue";
static StillImageFileValue = Constants.KnoraApiV2 + Constants.HashDelimiter + "StillImageFileValue";
static StillImageExternalFileValue = Constants.KnoraApiV2 + Constants.HashDelimiter + "StillImageExternalFileValue";
static MovingImageFileValue = Constants.KnoraApiV2 + Constants.HashDelimiter + "MovingImageFileValue";
static TextFileValue = Constants.KnoraApiV2 + Constants.HashDelimiter + "TextFileValue";
static ArchiveFileValue = Constants.KnoraApiV2 + Constants.HashDelimiter + "ArchiveFileValue";
Expand Down Expand Up @@ -128,6 +129,8 @@ export class Constants {
static StillImageFileValueHasDimX = Constants.KnoraApiV2 + Constants.HashDelimiter + "stillImageFileValueHasDimX";
static StillImageFileValueHasDimY = Constants.KnoraApiV2 + Constants.HashDelimiter + "stillImageFileValueHasDimY";
static StillImageFileValueHasIIIFBaseUrl = Constants.KnoraApiV2 + Constants.HashDelimiter + "stillImageFileValueHasIIIFBaseUrl";
static FileValueHasExternalUrl = Constants.KnoraApiV2 + Constants.HashDelimiter + "fileValueHasExternalUrl";
static StillImageFileValueHasExternalUrl = Constants.KnoraApiV2 + Constants.HashDelimiter + "stillImageFileValueHasExternalUrl";
static AudioFileValueHasDuration = Constants.KnoraApiV2 + Constants.HashDelimiter + "audioFileValueHasDuration";
static MovingImageFileValueHasDimX = Constants.KnoraApiV2 + Constants.HashDelimiter + "movingImageFileValueHasDimX";
static MovingImageFileValueHasDimY = Constants.KnoraApiV2 + Constants.HashDelimiter + "movingImageFileValueHasDimY";
Expand Down
9 changes: 9 additions & 0 deletions src/models/v2/resources/ResourcesConversionUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
ReadAudioFileValue,
ReadDocumentFileValue,
ReadMovingImageFileValue,
ReadStillImageExternalFileValue,
ReadStillImageFileValue,
ReadTextFileValue
} from "./values/read/read-file-value";
Expand Down Expand Up @@ -459,6 +460,14 @@ export namespace ResourcesConversionUtil {
break;
}

case Constants.StillImageExternalFileValue: {
const extStillImageVal = handleSimpleValue(valueJsonld, ReadStillImageExternalFileValue, jsonConvert);
value = extStillImageVal.pipe(map((val: ReadStillImageExternalFileValue) => {
return val;
}));
break;
}

case Constants.ArchiveFileValue: {
const archiveVal = handleSimpleValue(valueJsonld, ReadArchiveFileValue, jsonConvert);
value = archiveVal.pipe(map((val: ReadArchiveFileValue) => {
Expand Down
18 changes: 16 additions & 2 deletions src/models/v2/resources/values/create/create-file-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ export class CreateStillImageFileValue extends CreateFileValue {

constructor() {
super(Constants.StillImageFileValue);

}

}

/**
* @category Model V2
*/
@JsonObject("CreateStillImageExternalFileValue")
export class CreateStillImageExternalFileValue extends CreateFileValue {
@JsonProperty(Constants.FileValueHasExternalUrl, String, true)
externalUrl?: string = "";
constructor() {
super(Constants.StillImageExternalFileValue);
}

}
Expand All @@ -77,9 +91,9 @@ export class CreateTextFileValue extends CreateFileValue {
*/
@JsonObject("CreateArchiveFileValue")
export class CreateArchiveFileValue extends CreateFileValue {

constructor() {
super(Constants.ArchiveFileValue);
}

}
11 changes: 11 additions & 0 deletions src/models/v2/resources/values/read/read-file-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ export class ReadStillImageFileValue extends ReadFileValue {

}

/**
* @category Model V2
*/
@JsonObject("ReadStillImageExternalFileValue")
export class ReadStillImageExternalFileValue extends ReadFileValue {
@JsonProperty(Constants.StillImageFileValueHasExternalUrl, UriConverter, true)
externalUrl: string = "";

}


/**
* @category Model V2
*/
Expand Down
17 changes: 15 additions & 2 deletions src/models/v2/resources/values/update/update-file-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ export class UpdateStillImageFileValue extends UpdateFileValue {

}

/**
* @category Model V2
*/
@JsonObject("UpdateStillImageExternalFileValue")
export class UpdateExternalStillImageFileValue extends UpdateFileValue {
@JsonProperty(Constants.StillImageFileValueHasExternalUrl, String, true)
externalUrl?: string = "";
constructor() {
super(Constants.StillImageAbstractFileValue);
}
}


/**
* @category Model V2
*/
Expand All @@ -79,9 +92,9 @@ export class UpdateTextFileValue extends UpdateFileValue {
*/
@JsonObject("UpdateArchiveFileValue")
export class UpdateArchiveFileValue extends UpdateFileValue {

constructor() {
super(Constants.ArchiveFileValue);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"knora-api:arkUrl": {
"@value": "http://0.0.0.0:3336/ark:/72163/1/0001/a=thing=picture1",
"@type": "xsd:anyURI"
},
"knora-api:versionArkUrl": {
"@value": "http://0.0.0.0:3336/ark:/72163/1/0001/a=thing=picture1.20110302T150510Z",
"@type": "xsd:anyURI"
},
"knora-api:attachedToProject": {
"@id": "http://rdfh.ch/projects/0001"
},
"knora-api:userHasPermission": "CR",
"knora-api:creationDate": {
"@value": "2024-08-05T15:20:29.932538430Z",
"@type": "xsd:dateTimeStamp"
},
"knora-api:attachedToUser": {
"@id": "http://rdfh.ch/users/9XBCrDV3SRa7kS1WwynB4Q"
},
"knora-api:hasPermissions": "CR knora-admin:Creator|M knora-admin:ProjectMember|RV knora-admin:UnknownUser",
"@type": "anything:ThingPicture",
"@id": "http://rdfh.ch/0001/a-thing-picture",
"rdfs:label": "A thing with an external iiif picture",
"knora-api:hasStillImageFileValue": {
"knora-api:arkUrl": {
"@value": "http://0.0.0.0:3336/ark:/72163/1/0803/RRjceJu5S86zfc_=ZrIEtgK/1=COzXfuTXiwDJ_2GZxeoQR",
"@type": "xsd:anyURI"
},
"knora-api:versionArkUrl": {
"@value": "http://0.0.0.0:3336/ark:/72163/1/0803/RRjceJu5S86zfc_=ZrIEtgK/1=COzXfuTXiwDJ_2GZxeoQR.20240805T15202993253843Z",
"@type": "xsd:anyURI"
},
"knora-api:userHasPermission": "CR",
"knora-api:valueCreationDate": {
"@value": "2024-08-05T15:20:29.932538430Z",
"@type": "xsd:dateTimeStamp"
},
"knora-api:valueHasUUID": "1-COzXfuTXiwDJ_2GZxeoQ",
"knora-api:stillImageFileValueHasIIIFBaseUrl": {
"@value": "https://ids.lib.harvard.edu",
"@type": "xsd:anyURI"
},
"@id": "http://rdfh.ch/0803/RRjceJu5S86zfc_-ZrIEtg/values/1-COzXfuTXiwDJ_2GZxeoQ",
"knora-api:stillImageFileValueHasExternalUrl": {
"@value": "https://ids.lib.harvard.edu/ids/iiif/24209711/full/105,/0/default.jpg",
"@type": "xsd:anyURI"
},
"knora-api:attachedToUser": {
"@id": "http://rdfh.ch/users/9XBCrDV3SRa7kS1WwynB4Q"
},
"knora-api:fileValueAsUrl": {
"@value": "https://ids.lib.harvard.edu/ids/iiif/24209711/full/105,/0/default.jpg",
"@type": "xsd:anyURI"
},
"knora-api:hasPermissions": "M knora-admin:Creator,knora-admin:ProjectMember|V knora-admin:KnownUser,knora-admin:UnknownUser",
"@type": "knora-api:StillImageExternalFileValue",
"knora-api:fileValueHasFilename": "internalFilename"
},
"@context": {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"knora-api": "http://api.knora.org/ontology/knora-api/v2#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"anything": "http://0.0.0.0:3333/ontology/0001/anything/v2#"
}
}
37 changes: 1 addition & 36 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,36 +1 @@
{
"compilerOptions": {
"declaration": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"lib": [
"es6",
"dom"
],
"module": "es6",
"removeComments": false,
"target": "es5",
"resolveJsonModule": true,
"moduleResolution": "node",
"sourceMap": true,
"strictNullChecks": true,
"noImplicitAny": true,
"outDir": "build"
},
"exclude": [
"build",
"coverage",
"dist",
"node_modules",
"test",
"**/*.spec.ts",
"test-framework"
],
"files": [
"index.ts"
],
"include": [
"src/**/*.ts"
]
}
{"compilerOptions":{"declaration":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"lib":["es6","dom"],"module":"es6","removeComments":false,"target":"es5","resolveJsonModule":true,"moduleResolution":"node","sourceMap":true,"strictNullChecks":true,"noImplicitAny":true,"outDir":"build"},"exclude":["build","coverage"],"files":["index.ts"],"include":["src/**/*.ts"]}
Loading