Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Core module: update textValueHasMapping #87

Merged
merged 21 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
61ae666
fix (core): update textValueHasMapping
flavens Oct 3, 2018
42be5f7
Merge branch 'master' into wip/textValueHasMapping-update
kilchenmann Oct 19, 2018
c430f74
Merge branch 'master' into wip/textValueHasMapping-update
tobiasschweizer Nov 6, 2018
f18f51a
Merge branch 'master' into wip/textValueHasMapping-update
Nov 7, 2018
98abb96
Merge branch 'master' into wip/textValueHasMapping-update
Nov 9, 2018
4a0b708
Merge branch 'master' into wip/textValueHasMapping-update
Nov 14, 2018
9a65258
Merge branch 'master' into wip/textValueHasMapping-update
Nov 15, 2018
193aab0
Merge branch 'master' into wip/textValueHasMapping-update
Nov 19, 2018
a5b55c9
enhancement (knora-core): Expect objects in stillImageFileValueHasIII…
Nov 19, 2018
a055a82
fix (core): fileValueIsPreview is no longer supported, determine qual…
Nov 21, 2018
81ad118
test (viewer): adapt creation of image file value
Nov 21, 2018
6087174
test (core): add test for a StillImageRepresentation (page)
Nov 21, 2018
06a2cf8
test (core): add test for TextfileValue
Nov 21, 2018
720a499
test (json-ld conversion): clarify use of async()
Nov 23, 2018
70e8322
Merge branch 'master' into wip/textValueHasMapping-update
tobiasschweizer Nov 28, 2018
b2a85f5
test (ontology cache): fix biblio shortcode
Nov 28, 2018
f4d63f6
test (ontology cache): update test data
Nov 28, 2018
6aeec42
tests (ontology cache): update beol test data
Nov 28, 2018
d1cedef
test (ontology cache): update anything test data
Nov 28, 2018
4b1d57a
test (ontology cache): update something test data
Nov 28, 2018
71b8dd8
docs (readme): Knora version
Nov 28, 2018
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
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

This is the demo and developing environment for Knora ui modules.

The modules helps to create a graphical user interface for [Knora](https://knora.org) in a quick and simple way. They're written in [Angular](https://angular.io) (v6) including the [material design](https://material.angular.io).
The modules help to create a graphical user interface for [Knora](https://knora.org) in a quick and simple way. They're written in [Angular](https://angular.io) (v6) including the [material design](https://material.angular.io).

Knora itself is a software framework for storing, sharing, and working with primary sources and data in the humanities.

It is developed by the [Digital Humanities Lab](http://dhlab.unibas.ch/) at the [University of Basel](https://unibas.ch/en.html), and is supported by the [Swiss Academy of Humanities and Social Sciences](http://www.sagw.ch/en/sagw.html).

Knora and the Knora ui elements is [free software](http://www.gnu.org/philosophy/free-sw.en.html), released under the [GNU Affero General Public License](http://www.gnu.org/licenses/agpl-3.0.en.html).
Knora and the Knora ui elements are [free software](http://www.gnu.org/philosophy/free-sw.en.html), released under the [GNU Affero General Public License](http://www.gnu.org/licenses/agpl-3.0.en.html).

This version of Knora-ui requires Knora v2.2.0-snapshot (pre-release) or later.

## Already published modules

Expand Down Expand Up @@ -180,3 +182,7 @@ If an inner observable does not complete forkJoin will never emit a value!
https://www.learnrxjs.io/operators/combination/forkjoin.html

> This is why the subscription never worked, because we did not flush all necessary responses. -->

## Required version of Knora

3.0.0 or later
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class KnoraConstants {

public static textValueAsHtml: string = KnoraConstants.KnoraApiV2WithValueObjectPath + 'textValueAsHtml';
public static textValueAsXml: string = KnoraConstants.KnoraApiV2WithValueObjectPath + 'textValueAsXml';
public static textValueHasMapping: string = KnoraConstants.KnoraApiV2WithValueObjectPath + 'textValueHasMapping';
public static textValueHasMapping = KnoraConstants.KnoraApiV2WithValueObjectPath + 'textValueHasMapping';

public static hasStandoffLinkToValue: string = KnoraConstants.KnoraApiV2WithValueObjectPath + 'hasStandoffLinkToValue';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,27 +236,26 @@ describe('ReadPropertyItem', () => {
const imageItem = new ReadStillImageFileValue(
'http://rdfh.ch/00c650d23303/values/af68552c3626',
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#hasImage',
'incunabula_0000003856.jp2',
'incunabula_0000003856.jpg',
'http://localhost:1024/knora',
'http://localhost:1024/knora/incunabula_0000003856.jp2/full/190,270/0/default.jpg',
'http://localhost:1024/knora/incunabula_0000003856.jpg/full/190,270/0/default.jpg',
190,
270,
true);
270);

expect(imageItem.id).toEqual('http://rdfh.ch/00c650d23303/values/af68552c3626');
expect(imageItem.type).toEqual('http://api.knora.org/ontology/knora-api/v2#StillImageFileValue');
expect(imageItem.propIri).toEqual('http://0.0.0.0:3333/ontology/0803/incunabula/v2#hasImage');
expect(imageItem.getClassName()).toEqual('ReadStillImageFileValue');
expect(imageItem.getContent()).toEqual('http://localhost:1024/knora/incunabula_0000003856.jp2/full/190,270/0/default.jpg');
expect(imageItem.getContent()).toEqual('http://localhost:1024/knora/incunabula_0000003856.jpg/full/190,270/0/default.jpg');

expect(imageItem.imageFilename).toEqual('incunabula_0000003856.jp2');
expect(imageItem.imageFilename).toEqual('incunabula_0000003856.jpg');
expect(imageItem.imageServerIIIFBaseURL).toEqual('http://localhost:1024/knora');
expect(imageItem.imagePath).toEqual('http://localhost:1024/knora/incunabula_0000003856.jp2/full/190,270/0/default.jpg');
expect(imageItem.imagePath).toEqual('http://localhost:1024/knora/incunabula_0000003856.jpg/full/190,270/0/default.jpg');
expect(imageItem.dimX).toEqual(190);
expect(imageItem.dimY).toEqual(270);
expect(imageItem.isPreview).toEqual(true);

expect(imageItem.makeIIIFUrl(10)).toEqual('http://localhost:1024/knora/incunabula_0000003856.jp2/full/190,270/0/default.jpg');
expect(imageItem.makeIIIFUrl(10)).toEqual('http://localhost:1024/knora/incunabula_0000003856.jpg/full/190,270/0/default.jpg');
});

it('should create a ReadTextFileValue', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ export class ReadStillImageFileValue implements ReadPropertyItem {
readonly imageServerIIIFBaseURL: string,
readonly imagePath: string,
readonly dimX: number,
readonly dimY: number,
isPreview?: boolean) {
readonly dimY: number) {

this.isPreview = isPreview === undefined ? false : isPreview;
// if the image is a jpeg, it is a preview image
this.isPreview = imageFilename.endsWith('.jpg');

}

Expand Down
159 changes: 156 additions & 3 deletions projects/knora/core/src/lib/services/v2/convert-jsonld.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
import { async } from '@angular/core/testing';
import { ConvertJSONLD } from './convert-jsonld';
import {
ReadBooleanValue, ReadColorValue, ReadDateValue, ReadDecimalValue, ReadIntegerValue, ReadIntervalValue,
ReadLinkValue, ReadListValue, ReadProperties, ReadResource, ReadResourcesSequence, ReadTextValueAsHtml,
ReadTextValueAsString, ReadTextValueAsXml, ReadUriValue
ReadBooleanValue,
ReadColorValue,
ReadDateValue,
ReadDecimalValue,
ReadIntegerValue,
ReadIntervalValue,
ReadLinkValue,
ReadListValue,
ReadProperties,
ReadResource,
ReadResourcesSequence,
ReadStillImageFileValue,
ReadTextFileValue,
ReadTextValueAsHtml,
ReadTextValueAsString,
ReadTextValueAsXml,
ReadUriValue
} from '../../declarations';


describe('ConvertJSONLD', () => {

/**
* The following tests use async() because the JSON-LD processor is involved.
* The data to check for are inside a Promise.
* See https://angular.io/guide/testing#component-with-async-service
*/

it('parse a JSON-LD document representing letter 176-O', async(() => {

const jsonld = require('jsonld');
Expand Down Expand Up @@ -586,6 +607,138 @@ describe('ConvertJSONLD', () => {
});
}));

it('parse a JSON-LD document representing a page with images', async(() => {

const jsonld = require('jsonld');

// http://localhost:3333/v2/resources/http%3A%2F%2Frdfh.ch%2F00505cf0a803
const page: any = require('../../test-data/resources/PageWithImages.json');

const promises = jsonld.promises;
// compact JSON-LD using an empty context: expands all Iris
const promise = promises.compact(page, {});

promise.then((compacted) => {

const receivedResource: ReadResourcesSequence = ConvertJSONLD.createReadResourcesSequenceFromJsonLD(compacted);

expect(receivedResource.numberOfResources).toEqual(1);

const expectedProps: ReadProperties = {
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#description': [
new ReadTextValueAsString(
'http://rdfh.ch/00505cf0a803/values/549527258a26',
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#description',
'Beginn Kapitel 105.\nHolzschnitt identisch mit Kap. 95: In einer Landschaft fasst ein Narr, der ein Zepter in der Linken hält, einem Mann an die Schulter und redet auf ihn ein, er möge die Feiertage missachten, 11.7 x 8.6 cm.'
)
],
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#origname': [
new ReadTextValueAsString(
'http://rdfh.ch/00505cf0a803/values/47da3831980e',
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#origname',
'IBB_1_002758751_0241.tif'
)
],
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#page_comment': [
new ReadTextValueAsString(
'http://rdfh.ch/00505cf0a803/values/1d9257bae428',
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#page_comment',
'Schramm, Bd. 22, Abb. 1200.'
)
],
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#pagenum': [
new ReadTextValueAsString(
'http://rdfh.ch/00505cf0a803/values/fe5c3f85970e',
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#pagenum',
'p7v'
)
],
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#partOfValue': [
new ReadLinkValue('http://rdfh.ch/00505cf0a803/values/a2c239c3-eac5-4f9f-88e9-9411835d11ff',
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#partOfValue',
'http://rdfh.ch/8be1b7cf7103',
new ReadResource('http://rdfh.ch/8be1b7cf7103',
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#book',
'[Das] Narrenschiff (lat.)',
[],
[],
[],
[],
{})
)
],
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#seqnum': [
new ReadIntegerValue(
'http://rdfh.ch/00505cf0a803/values/84b0e5f7970e',
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#seqnum',
241
)
],
'http://api.knora.org/ontology/knora-api/v2#hasStillImageFileValue': [
new ReadStillImageFileValue(
'http://rdfh.ch/00505cf0a803/reps/9e73f9ac2307',
'http://api.knora.org/ontology/knora-api/v2#hasStillImageFileValue',
'incunabula_0000004096.jp2',
'http://localhost:1024/knora',
'http://localhost:1024/knora/incunabula_0000004096.jp2/full/1954,2630/0/default.jpg',
1954,
2630
),
new ReadStillImageFileValue(
'http://rdfh.ch/00505cf0a803/reps/df4da6732307',
'http://api.knora.org/ontology/knora-api/v2#hasStillImageFileValue',
'incunabula_0000004096.jpg',
'http://localhost:1024/knora',
'http://localhost:1024/knora/incunabula_0000004096.jpg/full/95,128/0/default.jpg',
95,
128
)
]
};

const expectedPage = new ReadResource('http://rdfh.ch/00505cf0a803',
'http://0.0.0.0:3333/ontology/0803/incunabula/v2#page',
'p7v',
[],
[],
[],
[],
expectedProps);

expect(receivedResource.resources[0]).toEqual(expectedPage);
});


}));

it('parse a JSON-LD document representing text file value', async(() => {

const jsonld = require('jsonld');

const textfilerepr: any = require('../../test-data/resources/TextfileRepresentation.json');

const promises = jsonld.promises;
// compact JSON-LD using an empty context: expands all Iris
const promise = promises.compact(textfilerepr, {});

promise.then((compacted) => {

const receivedResource: ReadResourcesSequence = ConvertJSONLD.createReadResourcesSequenceFromJsonLD(compacted);

expect(receivedResource.numberOfResources).toEqual(1);

const expectedTextfileValue = new ReadTextFileValue(
'http://rdfh.ch/0802/C9bbwuLORoCZZ1DVek1qCQ/values/DSQxeAI-T8eYlgXynsQWhw',
'http://api.knora.org/ontology/knora-api/v2#hasTextFileValue',
'LZoxQd7xyNT-EC4kgw2gokg',
'http://localhost:1024/server/knora/LZoxQd7xyNT-EC4kgw2gokg'
);

expect(receivedResource.resources[0].properties['http://api.knora.org/ontology/knora-api/v2#hasTextFileValue'][0]).toEqual(expectedTextfileValue);

});
}));

it('parse a JSON-LD document representing a collection of resources and get the Iris of the resource classes contained in it', async(() => {

const jsonld = require('jsonld');
Expand Down
13 changes: 6 additions & 7 deletions projects/knora/core/src/lib/services/v2/convert-jsonld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ export module ConvertJSONLD {
propValue['@id'], propIri, propValue[KnoraConstants.textValueAsHtml], referredResources
);
} else if (
propValue[KnoraConstants.textValueAsXml] !== undefined && propValue[KnoraConstants.textValueHasMapping] !== undefined) {
propValue[KnoraConstants.textValueAsXml] !== undefined && propValue[KnoraConstants.textValueHasMapping]['@id'] !== undefined) {
textValue = new ReadTextValueAsXml(
propValue['@id'], propIri, propValue[KnoraConstants.textValueAsXml], propValue[KnoraConstants.textValueHasMapping]
propValue['@id'], propIri, propValue[KnoraConstants.textValueAsXml], propValue[KnoraConstants.textValueHasMapping]['@id']
);
} else {
// expected text value members not defined
Expand Down Expand Up @@ -198,11 +198,10 @@ export module ConvertJSONLD {
propValue['@id'],
propIri,
propValue[KnoraConstants.fileValueHasFilename],
propValue[KnoraConstants.stillImageFileValueHasIIIFBaseUrl],
propValue[KnoraConstants.fileValueAsUrl],
propValue[KnoraConstants.stillImageFileValueHasIIIFBaseUrl]['@value'],
propValue[KnoraConstants.fileValueAsUrl]['@value'],
propValue[KnoraConstants.stillImageFileValueHasDimX],
propValue[KnoraConstants.stillImageFileValueHasDimY],
propValue[KnoraConstants.fileValueIsPreview] // optional (may be undefined)
propValue[KnoraConstants.stillImageFileValueHasDimY]
);

valueSpecificProp = stillImageFileValue;
Expand All @@ -215,7 +214,7 @@ export module ConvertJSONLD {
propValue['@id'],
propIri,
propValue[KnoraConstants.fileValueHasFilename],
propValue[KnoraConstants.fileValueAsUrl]
propValue[KnoraConstants.fileValueAsUrl]['@value']
);

valueSpecificProp = textFileValue;
Expand Down
Loading