Commit 48b13b84 authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Update: Implement Zazuko Search (coscine/issues#1644)

parent 3c4cb104
export interface ZazukoResponse {
iri: Graph;
prefixed: string;
graph: Graph;
parts: Part[];
prefixedSplitA: string;
prefixedSplitB: IRISplitB;
iriSplitA: string;
iriSplitB: IRISplitB;
ontologyTitle: string;
label: IRISplitB;
itemText: string;
}
export interface Graph {
value: string;
}
export enum IRISplitB {
IRISplitBTitle = "Title",
Title = "title",
}
export interface Part {
predicate: string;
predicateIRI: string;
object: ObjectClass | string;
objectIRI?: string;
quad: Quad;
}
export interface ObjectClass {
value: string;
datatype?: Graph;
language?: Language;
}
export enum Language {
De = "de",
El = "el",
Empty = "",
En = "en",
Es = "es",
It = "it",
Ja = "ja",
Nl = "nl",
}
export interface Quad {
subject: Graph;
predicate: Graph;
object: ObjectClass;
graph: Graph;
}
......@@ -4,12 +4,13 @@ import {
} from "@/util/api-connection/mockup-api-connection";
import { searchVocabularyTerms as aimsSearchVocabularyTerms } from "@/util/api-connection/aims-api-connection";
import { searchVocabularyTerms as coscineSearchVocabularyTerms } from "@/util/api-connection/coscine-api-connection";
// TODO: Remove eslint disabling when a complete other implementation exists
// eslint-disable-next-line
let searchApplicationProfiles = mockupSearchApplicationProfiles;
// eslint-disable-next-line
let searchVocabularyTerms = aimsSearchVocabularyTerms;
let searchVocabularyTerms = coscineSearchVocabularyTerms;
// eslint-disable-next-line
let storeApplicationProfile = mockupStoreApplicationProfile;
......@@ -17,6 +18,7 @@ const currentLocation = window.location.href;
if (currentLocation.includes("coscine")) {
// TODO: Use different implementation
searchVocabularyTerms = coscineSearchVocabularyTerms;
} else if (currentLocation.includes("aims")) {
// TODO: Use different implementation
searchVocabularyTerms = aimsSearchVocabularyTerms;
......
......@@ -7,7 +7,7 @@ export async function searchVocabularyTerms(
query: string
): Promise<Array<VocabularyTerm>> {
const response = await axios.get(
`https://service.tib.eu/ts4tib/api/search?q=${query}&groupField=iri&start=0&type=property`
`https://service.tib.eu/ts4tib/api/search?q=${encodeURIComponent(query)}&groupField=iri&start=0&type=property`
);
const terminologyServiceResponse =
response.data as TerminologyServiceResponse;
......
import { ZazukoResponse } from "@/types/zazukoResponse";
import VocabularyTerm from "@/types/vocabularyTerm";
import axios from "axios";
export async function searchVocabularyTerms(
query: string
): Promise<Array<VocabularyTerm>> {
const response = await axios.get(
`https://prefix.zazuko.com/api/v1/search?q=${encodeURIComponent(query)}`
);
const zazukoResponse = response.data as ZazukoResponse[];
return zazukoResponse.map((vocab) => {
return {
label: vocab.label,
property: vocab.iriSplitB,
uri: vocab.iri.value,
prefix: vocab.prefixedSplitA,
vocabulary: vocab.graph.value,
} as VocabularyTerm;
});
}
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment