Skip to content

Commit

Permalink
Merge branch 'main' into feature/dev-4379-opening-a-segment-of-an-aud…
Browse files Browse the repository at this point in the history
…iovideo-in-new-tab-the-link-says
  • Loading branch information
irmastnt authored Nov 26, 2024
2 parents 30d37dd + 37f3565 commit 432dc43
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -657,13 +657,21 @@ export class AdvancedSearchStoreService extends ComponentStore<AdvancedSearchSta
}

onSearch(): string {
const ontoIri = this.get(state => state.ontologies)[0].iri;
const selectedResourceClass = this.get(state => state.selectedResourceClass);
const propertyFormList = this.get(state => state.propertyFormList);
const orderByList = this.get(state => state.propertiesOrderByList);
const resourceClasses = this.get(state => state.resourceClasses).map(resClass => resClass.iri);

this._storeSnapshotInLocalStorage();

return this._gravsearchService.generateGravSearchQuery(selectedResourceClass?.iri, propertyFormList, orderByList);
return this._gravsearchService.generateGravSearchQuery(
ontoIri,
resourceClasses,
selectedResourceClass?.iri,
propertyFormList,
orderByList
);
}

onReset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@ import { Operators, OrderByItem, PropertyFormItem } from '../advanced-search-sto
})
export class GravsearchService {
generateGravSearchQuery(
ontoIri: string,
resourceClasses: string[],
resourceClassIri: string | undefined,
properties: PropertyFormItem[],
orderByList: OrderByItem[]
): string {
// class restriction for the resource searched for
let restrictToResourceClass = '';
const ontoShortCode = ontoIri.match(/\/([^/]+)\/v2$/)![1];

// if given, create the class restriction for the main resource
if (resourceClassIri !== undefined) {
restrictToResourceClass = `?mainRes a <${resourceClassIri}> .`;
}
restrictToResourceClass =
resourceClassIri !== undefined
? `?mainRes a <${resourceClassIri}> .`
: resourceClasses
.map(resourceClass => `{ ?mainRes a ${ontoShortCode}:${resourceClass.split('#').pop()} . }`)
.join(' UNION ');

const propertyStrings: GravsearchPropertyString[] = properties.map((prop, index) =>
this._propertyStringHelper(prop, index)
Expand Down Expand Up @@ -48,6 +54,7 @@ export class GravsearchService {

const gravSearch =
'PREFIX knora-api: <http://api.knora.org/ontology/knora-api/v2#>\n' +
`PREFIX ${ontoShortCode}: <${ontoIri}#>\n` +
'CONSTRUCT {\n' +
'?mainRes knora-api:isMainResource true .\n' +
`${propertyStrings.map(prop => prop.constructString).join('\n')}\n` +
Expand Down
10 changes: 7 additions & 3 deletions libs/vre/shared/app-ontology/src/lib/ontology.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy
private ngUnsubscribe = new Subject<void>();

// all resource classes in the current ontology
ontoClasses: ClassDefinition[];
ontoClasses: ResourceClassDefinitionWithAllLanguages[];
// expand the resource class cards
expandClasses = true;

Expand Down Expand Up @@ -278,7 +278,7 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy
}
}

private initOntoClasses(allOntoClasses: ClassDefinition[]) {
private initOntoClasses(allOntoClasses: ResourceClassDefinitionWithAllLanguages[]) {
// reset the ontology classes
this.ontoClasses = [];

Expand Down Expand Up @@ -358,7 +358,11 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy
this.initView(ontology);
this._dspApiConnection.v2.ontologyCache.reloadCachedItem(ontology.id);
// grab the onto class information to display
this.initOntoClasses(getAllEntityDefinitionsAsArray(ontology.classes));
this.initOntoClasses(
ontology.getClassDefinitionsByType<ResourceClassDefinitionWithAllLanguages>(
ResourceClassDefinitionWithAllLanguages
)
);
// grab the onto properties information to display
this.initOntoProperties(ontology, getAllEntityDefinitionsAsArray(ontology.properties));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- class card header -->
<mat-card-header class="resource-class-header" cdkDragHandle>
<mat-card-title [matTooltip]="resourceClass.comment" matTooltipPosition="above">
{{ resourceClass.label | appTruncate: 24 }}
{{ classLabel | appTruncate: 24 }}
</mat-card-title>
<mat-card-subtitle>
<span [matTooltip]="'id: ' + resourceClass.id" matTooltipPosition="above" matTooltipClass="wide-tooltip">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import {
} from '@angular/core';
import {
CanDoResponse,
ClassDefinition,
Constants,
KnoraApiConnection,
PropertyDefinition,
ReadOntology,
ResourceClassDefinitionWithAllLanguages,
ResourcePropertyDefinitionWithAllLanguages,
} from '@dasch-swiss/dsp-js';
import { DspApiConnectionToken, RouteConstants } from '@dasch-swiss/vre/shared/app-config';
import { DefaultClass, DefaultResourceClasses } from '@dasch-swiss/vre/shared/app-helper-services';
import { DefaultClass, DefaultResourceClasses, LocalizationService } from '@dasch-swiss/vre/shared/app-helper-services';
import { NotificationService } from '@dasch-swiss/vre/shared/app-notification';
import {
OntologiesSelectors,
Expand All @@ -44,7 +44,7 @@ export class ResourceClassInfoComponent implements OnInit, OnDestroy {
// open / close res class card
@Input() expanded = false;

@Input() resourceClass: ClassDefinition;
@Input() resourceClass: ResourceClassDefinitionWithAllLanguages;

@Input() projectUuid: string;

Expand Down Expand Up @@ -73,6 +73,8 @@ export class ResourceClassInfoComponent implements OnInit, OnDestroy {

classCanBeDeleted: boolean;

classLabel: string;

subClassOfLabel = '';

readonly defaultClasses: DefaultClass[] = DefaultResourceClasses.data;
Expand All @@ -88,6 +90,7 @@ export class ResourceClassInfoComponent implements OnInit, OnDestroy {
constructor(
@Inject(DspApiConnectionToken)
private _dspApiConnection: KnoraApiConnection,
private _localizationService: LocalizationService,
private _notification: NotificationService,
private _store: Store,
private _actions$: Actions
Expand All @@ -99,6 +102,7 @@ export class ResourceClassInfoComponent implements OnInit, OnDestroy {
this.translateSubClassOfIri(this.resourceClass.subClassOf);
// check if the class can be deleted
this.canBeDeleted();
this.getOntologiesLabelsInPreferredLanguage();
}

ngOnDestroy() {
Expand Down Expand Up @@ -149,6 +153,12 @@ export class ResourceClassInfoComponent implements OnInit, OnDestroy {
return propsToDisplay;
}

getOntologiesLabelsInPreferredLanguage(): void {
const preferredLanguage = this._localizationService.getCurrentLanguage();
const preferedLabelLiteral = this.resourceClass.labels.find(l => l.language === preferredLanguage);
this.classLabel = preferedLabelLiteral ? preferedLabelLiteral.value : this.resourceClass.label || '';
}

/**
* translates iris from "subclass of" array
* - display label from default resource classes (as part of DSP System Project)
Expand Down
Loading

0 comments on commit 432dc43

Please sign in to comment.