-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DMP): own resource viewer (DSP-1586) (#434)
* chore(dependencies): update package.lock after npm i * chore(deps): bump dsp-ui version * chore(dmp): init own resource viewer * style(resource): correct position of tab bar * feat(resource): own resource toolbar (copied from ui-lib) * chore(resource): copy property view from ui-lib to own component * refactor(resource): fix compound viewer * test(resource): bug fixes in tests * refactor(resource): clean up code * refactor(resource): clean up code * chore(resource): copy still-image viewer from ui-lib * test(resource): fix test * style(resource): new still image viewer navigation * fix(resource): get rid of console warning * refactor(resource): fix typo * refactor(resource): clean up code * refactor(resource): clean up code * refactor(resource): clean up code * refactor(resource): turn valueOperationEventSubscription into an array * chore(deps): reinstall node modules * chore(deps): reinstall node modules Co-authored-by: mdelez <[email protected]>
- Loading branch information
1 parent
c4726fe
commit 35bd7b3
Showing
20 changed files
with
5,044 additions
and
5,126 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { | ||
ReadResource, | ||
ReadValue, | ||
SystemPropertyDefinition | ||
} from '@dasch-swiss/dsp-js'; | ||
import { PropertyInfoValues } from '@dasch-swiss/dsp-ui'; | ||
|
||
export class DspResource { | ||
|
||
res: ReadResource; | ||
|
||
resProps: PropertyInfoValues[] = []; // array of resource properties | ||
|
||
systemProps: SystemPropertyDefinition[] = []; // array of system properties | ||
|
||
// regions or sequences | ||
incomingAnnotations: ReadResource[] = []; | ||
|
||
// incoming stillImages, movingImages, audio etc. | ||
incomingRepresentations: ReadResource[] = []; | ||
|
||
constructor(resource: ReadResource) { | ||
|
||
this.res = resource; | ||
} | ||
} | ||
|
||
export class DspCompoundPosition { | ||
offset: number; // current offset of search requests | ||
maxOffsets: number; // max offsets in relation to totalPages | ||
position: number; // current item position in offset sequence | ||
page: number; // current and real page number in compound object | ||
totalPages: number; // total pages (part of) in compound object | ||
|
||
constructor(totalPages: number) { | ||
this.totalPages = totalPages; | ||
this.maxOffsets = Math.ceil(totalPages / 25) - 1; | ||
} | ||
} | ||
|
||
export interface PropIriToNameMapping { | ||
[index: string]: string; | ||
} | ||
|
||
export interface PropertyValues { | ||
[index: string]: ReadValue[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { DspApiConnectionToken } from '@dasch-swiss/dsp-ui'; | ||
import { IncomingService } from './incoming.service'; | ||
|
||
describe('IncomingService', () => { | ||
let service: IncomingService; | ||
|
||
beforeEach(() => { | ||
const dspConnSpyObj = { | ||
v2: { | ||
search: jasmine.createSpyObj('search', ['doExtendedSearch']) | ||
} | ||
}; | ||
|
||
TestBed.configureTestingModule({ | ||
providers: [ | ||
{ | ||
provide: DspApiConnectionToken, | ||
useValue: dspConnSpyObj | ||
}, | ||
] | ||
}); | ||
service = TestBed.inject(IncomingService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
|
||
it('should get incoming regions ', () => { | ||
|
||
const dspSpy = TestBed.inject(DspApiConnectionToken); | ||
|
||
const expectedQuery = ` | ||
PREFIX knora-api: <http://api.knora.org/ontology/knora-api/simple/v2#> | ||
CONSTRUCT { | ||
?region knora-api:isMainResource true . | ||
?region knora-api:hasGeometry ?geom . | ||
?region knora-api:hasComment ?comment . | ||
?region knora-api:hasColor ?color . | ||
} WHERE { | ||
?region a knora-api:Region . | ||
?region a knora-api:Resource . | ||
?region knora-api:isRegionOf <http://rdfh.ch/0801/letter> . | ||
knora-api:isRegionOf knora-api:objectType knora-api:Resource . | ||
<http://rdfh.ch/0801/letter> a knora-api:Resource . | ||
?region knora-api:hasGeometry ?geom . | ||
knora-api:hasGeometry knora-api:objectType knora-api:Geom . | ||
?geom a knora-api:Geom . | ||
?region knora-api:hasComment ?comment . | ||
knora-api:hasComment knora-api:objectType xsd:string . | ||
?comment a xsd:string . | ||
?region knora-api:hasColor ?color . | ||
knora-api:hasColor knora-api:objectType knora-api:Color . | ||
?color a knora-api:Color . | ||
} OFFSET 0 | ||
`; | ||
|
||
service.getIncomingRegions('http://rdfh.ch/0801/letter', 0); | ||
|
||
expect(dspSpy.v2.search.doExtendedSearch).toHaveBeenCalledWith(expectedQuery); | ||
|
||
}); | ||
|
||
it('should get incoming StillImageRepresentations ', () => { | ||
|
||
const dspSpy = TestBed.inject(DspApiConnectionToken); | ||
|
||
const expectedQuery = ` | ||
PREFIX knora-api: <http://api.knora.org/ontology/knora-api/simple/v2#> | ||
CONSTRUCT { | ||
?page knora-api:isMainResource true . | ||
?page knora-api:seqnum ?seqnum . | ||
?page knora-api:hasStillImageFile ?file . | ||
} WHERE { | ||
?page a knora-api:StillImageRepresentation . | ||
?page a knora-api:Resource . | ||
?page knora-api:isPartOf <http://rdfh.ch/0801/letter> . | ||
knora-api:isPartOf knora-api:objectType knora-api:Resource . | ||
<http://rdfh.ch/0801/letter> a knora-api:Resource . | ||
?page knora-api:seqnum ?seqnum . | ||
knora-api:seqnum knora-api:objectType xsd:integer . | ||
?seqnum a xsd:integer . | ||
?page knora-api:hasStillImageFile ?file . | ||
knora-api:hasStillImageFile knora-api:objectType knora-api:File . | ||
?file a knora-api:File . | ||
} ORDER BY ?seqnum | ||
OFFSET 1 | ||
`; | ||
|
||
service.getStillImageRepresentationsForCompoundResource('http://rdfh.ch/0801/letter', 1); | ||
|
||
expect(dspSpy.v2.search.doExtendedSearch).toHaveBeenCalledWith(expectedQuery); | ||
|
||
}); | ||
|
||
it('should get incoming Links', () => { | ||
|
||
const dspSpy = TestBed.inject(DspApiConnectionToken); | ||
|
||
const expectedQuery = ` | ||
PREFIX knora-api: <http://api.knora.org/ontology/knora-api/simple/v2#> | ||
CONSTRUCT { | ||
?incomingRes knora-api:isMainResource true . | ||
?incomingRes ?incomingProp <http://rdfh.ch/0801/letter> . | ||
} WHERE { | ||
?incomingRes a knora-api:Resource . | ||
?incomingRes ?incomingProp <http://rdfh.ch/0801/letter> . | ||
<http://rdfh.ch/0801/letter> a knora-api:Resource . | ||
?incomingProp knora-api:objectType knora-api:Resource . | ||
knora-api:isRegionOf knora-api:objectType knora-api:Resource . | ||
knora-api:isPartOf knora-api:objectType knora-api:Resource . | ||
FILTER NOT EXISTS { | ||
?incomingRes knora-api:isRegionOf <http://rdfh.ch/0801/letter> . | ||
} | ||
FILTER NOT EXISTS { | ||
?incomingRes knora-api:isPartOf <http://rdfh.ch/0801/letter> . | ||
} | ||
} OFFSET 0 | ||
`; | ||
|
||
service.getIncomingLinksForResource('http://rdfh.ch/0801/letter', 0); | ||
|
||
expect(dspSpy.v2.search.doExtendedSearch).toHaveBeenCalledWith(expectedQuery); | ||
|
||
}); | ||
|
||
}); |
Oops, something went wrong.