diff --git a/service/src/main/inse/model.py b/service/src/main/inse/model.py index 83c064c3..882338ad 100644 --- a/service/src/main/inse/model.py +++ b/service/src/main/inse/model.py @@ -52,6 +52,9 @@ class ESIndex(StrEnum): OPENALEX_CONTINENTS = "openalex-continents" OPENALEX_TOPICS = "openalex-topics" OPENALEX_TOPIC_VECTORS = "topicvectors" + OPENALEX_DOMAINS = "openalex-domains" + OPENALEX_FIELDS = "openalex-fields" + OPENALEX_SUBFIELDS = "openalex-subfields" EPO_INDEX = "epo_index_1.0" USPTO_INDEX = "uspto_patents_3.0" diff --git a/service/src/main/inse/projects/projects_search_client.py b/service/src/main/inse/projects/projects_search_client.py index 454622aa..0c8d126d 100644 --- a/service/src/main/inse/projects/projects_search_client.py +++ b/service/src/main/inse/projects/projects_search_client.py @@ -648,7 +648,7 @@ async def search_dfg_projects( # person["institute_name_en"] = institute.get("institute_name_en") # person["address_country_de"] = institute.get("address_country_de") # person["address_country_en"] = institute.get("address_country_en") - print("ENRIECHED",source.get("institutions", [])) + return _complete_response_to_dfg_project_page(response, page, size) def _complete_response_to_dfg_project_page( diff --git a/service/src/main/inse/topics/v2/router.py b/service/src/main/inse/topics/v2/router.py index f382d5a0..0a7fe43a 100644 --- a/service/src/main/inse/topics/v2/router.py +++ b/service/src/main/inse/topics/v2/router.py @@ -4,6 +4,9 @@ from typing import Annotated import inse.topics.v2.service as topics_service from fastapi import APIRouter, Path, Query from inse.model import SortDirection +from inse.models.openalex.domain import Domain +from inse.models.openalex.model_field import ModelField +from inse.models.openalex.subfield import Subfield from inse.models.openalex.topic import Topic from inse.router_prefixes import RouterPrefixes from inse.tags import Tags @@ -78,6 +81,48 @@ async def get_topic_by_id( ) +@router.get( + "/domains/single/{domain_id}", + operation_id="getDomainById", + summary="Returns a domain for a given domain ID.", +) +async def get_domain_by_id( + domain_id: Annotated[ + str, + Path(description="The ID of the domain to retrieve."), + ], +) -> Domain: + return await topics_service.get_domain_by_id_or_raise(domain_id=domain_id) + + +@router.get( + "/fields/single/{field_id}", + operation_id="getFieldById", + summary="Returns a field for a given field ID.", +) +async def get_field_by_id( + field_id: Annotated[ + str, + Path(description="The ID of the field to retrieve."), + ], +) -> ModelField: + return await topics_service.get_field_by_id_or_raise(field_id=field_id) + + +@router.get( + "/subfields/single/{subfield_id}", + operation_id="getSubfieldById", + summary="Returns a subfield for a given subfield ID.", +) +async def get_subfield_by_id( + subfield_id: Annotated[ + str, + Path(description="The ID of the subfield to retrieve."), + ], +) -> Subfield: + return await topics_service.get_subfield_by_id_or_raise(subfield_id=subfield_id) + + @router.get( "/topics/id", operation_id="getTopicsByIds", diff --git a/service/src/main/inse/topics/v2/service.py b/service/src/main/inse/topics/v2/service.py index b73379d8..b10c7d60 100644 --- a/service/src/main/inse/topics/v2/service.py +++ b/service/src/main/inse/topics/v2/service.py @@ -1,6 +1,9 @@ from inse.exceptions import NotFoundException from inse.integrations import elasticsearch from inse.model import ESIndex, SortDirection +from inse.models.openalex.domain import Domain +from inse.models.openalex.model_field import ModelField +from inse.models.openalex.subfield import Subfield from inse.models.openalex.topic import Topic from inse.topics.v2.model import TopicPageV2, TopicSortBy @@ -184,6 +187,117 @@ async def get_topic_by_id_or_raise(raw_oa_topic_id: str) -> Topic: return topic +async def get_domain_by_id(domain_id: str) -> Domain | None: + """Retrieves a domain based on its ID. + + Args: + domain_id (str): The numeric OpenAlex ID of the domain to retrieve (e.g. "4"). + + Returns: + Domain | None: The domain matching the provided ID, or None if not found. + """ + response = await elasticsearch.get( + index=ESIndex.OPENALEX_DOMAINS, + doc_id=domain_id, + source=["id", "display_name", "description"], + ) + if response.get("found"): + return Domain.from_dict(response.get("_source", {})) + return None + + +async def get_domain_by_id_or_raise(domain_id: str) -> Domain: + """Retrieves a domain based on its ID, raising an exception if not found. + + Args: + domain_id (str): The ID of the domain to retrieve. + + Raises: + NotFoundException: If the domain with the specified ID is not found. + + Returns: + Domain: The domain matching the provided ID. + """ + domain = await get_domain_by_id(domain_id) + if domain is None: + raise NotFoundException(f"Domain with ID {domain_id} not found.") + return domain + + +async def get_field_by_id(field_id: str) -> ModelField | None: + """Retrieves a field based on its ID. + + Args: + field_id (str): The numeric OpenAlex ID of the field to retrieve (e.g. "27"). + + Returns: + ModelField | None: The field matching the provided ID, or None if not found. + """ + response = await elasticsearch.get( + index=ESIndex.OPENALEX_FIELDS, + doc_id=field_id, + source=["id", "display_name", "description"], + ) + if response.get("found"): + return ModelField.from_dict(response.get("_source", {})) + return None + + +async def get_field_by_id_or_raise(field_id: str) -> ModelField: + """Retrieves a field based on its ID, raising an exception if not found. + + Args: + field_id (str): The ID of the field to retrieve. + + Raises: + NotFoundException: If the field with the specified ID is not found. + + Returns: + ModelField: The field matching the provided ID. + """ + field = await get_field_by_id(field_id) + if field is None: + raise NotFoundException(f"Field with ID {field_id} not found.") + return field + + +async def get_subfield_by_id(subfield_id: str) -> Subfield | None: + """Retrieves a subfield based on its ID. + + Args: + subfield_id (str): The numeric OpenAlex ID of the subfield to retrieve (e.g. "2743"). + + Returns: + Subfield | None: The subfield matching the provided ID, or None if not found. + """ + response = await elasticsearch.get( + index=ESIndex.OPENALEX_SUBFIELDS, + doc_id=subfield_id, + source=["id", "display_name", "description"], + ) + if response.get("found"): + return Subfield.from_dict(response.get("_source", {})) + return None + + +async def get_subfield_by_id_or_raise(subfield_id: str) -> Subfield: + """Retrieves a subfield based on its ID, raising an exception if not found. + + Args: + subfield_id (str): The ID of the subfield to retrieve. + + Raises: + NotFoundException: If the subfield with the specified ID is not found. + + Returns: + Subfield: The subfield matching the provided ID. + """ + subfield = await get_subfield_by_id(subfield_id) + if subfield is None: + raise NotFoundException(f"Subfield with ID {subfield_id} not found.") + return subfield + + async def get_topics_by_ids(topic_ids: list[str]) -> TopicPageV2: """Retrieves topics based on a list of topic IDs. diff --git a/webapp/src/app/api/api/topicsV2.service.ts b/webapp/src/app/api/api/topicsV2.service.ts index 674c4906..4f378585 100644 --- a/webapp/src/app/api/api/topicsV2.service.ts +++ b/webapp/src/app/api/api/topicsV2.service.ts @@ -1,7 +1,7 @@ /** * Innovation Search Engine API * - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -9,18 +9,30 @@ */ /* tslint:disable:no-unused-variable member-ordering */ -import { Inject, Injectable, Optional } from '@angular/core'; -import { HttpClient, HttpHeaders, HttpParams, - HttpResponse, HttpEvent, HttpParameterCodec, HttpContext - } from '@angular/common/http'; -import { CustomHttpParameterCodec } from '../encoder'; -import { Observable } from 'rxjs'; +import { Inject, Injectable, Optional } from '@angular/core'; +import { + HttpClient, + HttpHeaders, + HttpParams, + HttpResponse, + HttpEvent, + HttpParameterCodec, + HttpContext, +} from '@angular/common/http'; +import { CustomHttpParameterCodec } from '../encoder'; +import { Observable } from 'rxjs'; +// @ts-ignore +import { Domain } from '../model/domain'; // @ts-ignore import { HTTPValidationError } from '../model/hTTPValidationError'; // @ts-ignore +import { ModelField } from '../model/modelField'; +// @ts-ignore import { SortDirection } from '../model/sortDirection'; // @ts-ignore +import { Subfield } from '../model/subfield'; +// @ts-ignore import { Topic } from '../model/topic'; // @ts-ignore import { TopicPageV2 } from '../model/topicPageV2'; @@ -28,261 +40,779 @@ import { TopicPageV2 } from '../model/topicPageV2'; import { TopicSortBy } from '../model/topicSortBy'; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; -import { Configuration } from '../configuration'; +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; import { BaseService } from '../api.base.service'; - - @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class TopicsV2Service extends BaseService { + constructor( + protected httpClient: HttpClient, + @Optional() @Inject(BASE_PATH) basePath: string | string[], + @Optional() configuration?: Configuration, + ) { + super(basePath, configuration); + } - constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: Configuration) { - super(basePath, configuration); + /** + * Returns a paginated list of topics for a given search term based on their display name. + * @endpoint get /api/topics/v2/autocomplete/selector + * @param query A search term to filter topics by (partial matches allowed). + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public autocompleteTopicsForSelector( + query?: string, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable; + public autocompleteTopicsForSelector( + query?: string, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public autocompleteTopicsForSelector( + query?: string, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public autocompleteTopicsForSelector( + query?: string, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + let localVarQueryParameters = new HttpParams({ encoder: this.encoder }); + localVarQueryParameters = this.addToHttpParams( + localVarQueryParameters, + query, + 'query', + ); + + let localVarHeaders = this.defaultHeaders; + + const localVarHttpHeaderAcceptSelected: string | undefined = + options?.httpHeaderAccept ?? + this.configuration.selectHeaderAccept(['application/json']); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Accept', + localVarHttpHeaderAcceptSelected, + ); } - /** - * Returns a paginated list of topics for a given search term based on their display name. - * @endpoint get /api/topics/v2/autocomplete/selector - * @param query A search term to filter topics by (partial matches allowed). - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public autocompleteTopicsForSelector(query?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public autocompleteTopicsForSelector(query?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public autocompleteTopicsForSelector(query?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public autocompleteTopicsForSelector(query?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + const localVarHttpContext: HttpContext = + options?.context ?? new HttpContext(); - let localVarQueryParameters = new HttpParams({encoder: this.encoder}); - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - query, 'query'); + const localVarTransferCache: boolean = options?.transferCache ?? true; - let localVarHeaders = this.defaultHeaders; + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if ( + this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected) + ) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } - const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ - 'application/json' - ]); - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } + let localVarPath = `/api/topics/v2/autocomplete/selector`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request( + 'get', + `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + params: localVarQueryParameters, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }, + ); + } - const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + /** + * Returns a domain for a given domain ID. + * @endpoint get /api/topics/v2/domains/single/{domain_id} + * @param domainId The ID of the domain to retrieve. + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getDomainById( + domainId: string, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable; + public getDomainById( + domainId: string, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public getDomainById( + domainId: string, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public getDomainById( + domainId: string, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + if (domainId === null || domainId === undefined) { + throw new Error( + 'Required parameter domainId was null or undefined when calling getDomainById.', + ); + } - const localVarTransferCache: boolean = options?.transferCache ?? true; + let localVarHeaders = this.defaultHeaders; + const localVarHttpHeaderAcceptSelected: string | undefined = + options?.httpHeaderAccept ?? + this.configuration.selectHeaderAccept(['application/json']); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Accept', + localVarHttpHeaderAcceptSelected, + ); + } - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } + const localVarHttpContext: HttpContext = + options?.context ?? new HttpContext(); - let localVarPath = `/api/topics/v2/autocomplete/selector`; - const { basePath, withCredentials } = this.configuration; - return this.httpClient.request('get', `${basePath}${localVarPath}`, - { - context: localVarHttpContext, - params: localVarQueryParameters, - responseType: responseType_, - ...(withCredentials ? { withCredentials } : {}), - headers: localVarHeaders, - observe: observe, - ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), - reportProgress: reportProgress - } + const localVarTransferCache: boolean = options?.transferCache ?? true; + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if ( + this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected) + ) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/topics/v2/domains/single/${this.configuration.encodeParam({ name: 'domainId', value: domainId, in: 'path', style: 'simple', explode: false, dataType: 'string', dataFormat: undefined })}`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request( + 'get', + `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }, + ); + } + + /** + * Returns a field for a given field ID. + * @endpoint get /api/topics/v2/fields/single/{field_id} + * @param fieldId The ID of the field to retrieve. + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getFieldById( + fieldId: string, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable; + public getFieldById( + fieldId: string, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public getFieldById( + fieldId: string, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public getFieldById( + fieldId: string, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + if (fieldId === null || fieldId === undefined) { + throw new Error( + 'Required parameter fieldId was null or undefined when calling getFieldById.', + ); + } + + let localVarHeaders = this.defaultHeaders; + + const localVarHttpHeaderAcceptSelected: string | undefined = + options?.httpHeaderAccept ?? + this.configuration.selectHeaderAccept(['application/json']); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Accept', + localVarHttpHeaderAcceptSelected, + ); + } + + const localVarHttpContext: HttpContext = + options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if ( + this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected) + ) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/topics/v2/fields/single/${this.configuration.encodeParam({ name: 'fieldId', value: fieldId, in: 'path', style: 'simple', explode: false, dataType: 'string', dataFormat: undefined })}`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request( + 'get', + `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }, + ); + } + + /** + * Returns a subfield for a given subfield ID. + * @endpoint get /api/topics/v2/subfields/single/{subfield_id} + * @param subfieldId The ID of the subfield to retrieve. + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getSubfieldById( + subfieldId: string, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable; + public getSubfieldById( + subfieldId: string, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public getSubfieldById( + subfieldId: string, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public getSubfieldById( + subfieldId: string, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + if (subfieldId === null || subfieldId === undefined) { + throw new Error( + 'Required parameter subfieldId was null or undefined when calling getSubfieldById.', + ); + } + + let localVarHeaders = this.defaultHeaders; + + const localVarHttpHeaderAcceptSelected: string | undefined = + options?.httpHeaderAccept ?? + this.configuration.selectHeaderAccept(['application/json']); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Accept', + localVarHttpHeaderAcceptSelected, + ); + } + + const localVarHttpContext: HttpContext = + options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if ( + this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected) + ) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/topics/v2/subfields/single/${this.configuration.encodeParam({ name: 'subfieldId', value: subfieldId, in: 'path', style: 'simple', explode: false, dataType: 'string', dataFormat: undefined })}`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request( + 'get', + `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }, + ); + } + + /** + * Returns a topic for a given topic ID. + * @endpoint get /api/topics/v2/single/{raw_oa_topic_id} + * @param rawOaTopicId The ID of the topic to retrieve. + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getTopicById( + rawOaTopicId: string, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable; + public getTopicById( + rawOaTopicId: string, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public getTopicById( + rawOaTopicId: string, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public getTopicById( + rawOaTopicId: string, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + if (rawOaTopicId === null || rawOaTopicId === undefined) { + throw new Error( + 'Required parameter rawOaTopicId was null or undefined when calling getTopicById.', + ); + } + + let localVarHeaders = this.defaultHeaders; + + const localVarHttpHeaderAcceptSelected: string | undefined = + options?.httpHeaderAccept ?? + this.configuration.selectHeaderAccept(['application/json']); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Accept', + localVarHttpHeaderAcceptSelected, + ); + } + + const localVarHttpContext: HttpContext = + options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if ( + this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected) + ) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/topics/v2/single/${this.configuration.encodeParam({ name: 'rawOaTopicId', value: rawOaTopicId, in: 'path', style: 'simple', explode: false, dataType: 'string', dataFormat: undefined })}`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request('get', `${basePath}${localVarPath}`, { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }); + } + + /** + * Returns a paginated list of topics for a given list of topic IDs. + * @endpoint get /api/topics/v2/topics/id + * @param topicIds A list of topic IDs to retrieve. + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getTopicsByIds( + topicIds?: Array, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable; + public getTopicsByIds( + topicIds?: Array, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public getTopicsByIds( + topicIds?: Array, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public getTopicsByIds( + topicIds?: Array, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + let localVarQueryParameters = new HttpParams({ encoder: this.encoder }); + if (topicIds) { + topicIds.forEach((element) => { + localVarQueryParameters = this.addToHttpParams( + localVarQueryParameters, + element, + 'topic_ids', ); + }); } - /** - * Returns a topic for a given topic ID. - * @endpoint get /api/topics/v2/single/{raw_oa_topic_id} - * @param rawOaTopicId The ID of the topic to retrieve. - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public getTopicById(rawOaTopicId: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public getTopicById(rawOaTopicId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getTopicById(rawOaTopicId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getTopicById(rawOaTopicId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { - if (rawOaTopicId === null || rawOaTopicId === undefined) { - throw new Error('Required parameter rawOaTopicId was null or undefined when calling getTopicById.'); - } + let localVarHeaders = this.defaultHeaders; - let localVarHeaders = this.defaultHeaders; - - const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ - 'application/json' - ]); - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); - - const localVarTransferCache: boolean = options?.transferCache ?? true; - - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/api/topics/v2/single/${this.configuration.encodeParam({name: "rawOaTopicId", value: rawOaTopicId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; - const { basePath, withCredentials } = this.configuration; - return this.httpClient.request('get', `${basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: responseType_, - ...(withCredentials ? { withCredentials } : {}), - headers: localVarHeaders, - observe: observe, - ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), - reportProgress: reportProgress - } - ); + const localVarHttpHeaderAcceptSelected: string | undefined = + options?.httpHeaderAccept ?? + this.configuration.selectHeaderAccept(['application/json']); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Accept', + localVarHttpHeaderAcceptSelected, + ); } - /** - * Returns a paginated list of topics for a given list of topic IDs. - * @endpoint get /api/topics/v2/topics/id - * @param topicIds A list of topic IDs to retrieve. - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public getTopicsByIds(topicIds?: Array, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public getTopicsByIds(topicIds?: Array, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getTopicsByIds(topicIds?: Array, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getTopicsByIds(topicIds?: Array, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + const localVarHttpContext: HttpContext = + options?.context ?? new HttpContext(); - let localVarQueryParameters = new HttpParams({encoder: this.encoder}); - if (topicIds) { - topicIds.forEach((element) => { - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - element, 'topic_ids'); - }) - } + const localVarTransferCache: boolean = options?.transferCache ?? true; - let localVarHeaders = this.defaultHeaders; - - const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ - 'application/json' - ]); - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); - - const localVarTransferCache: boolean = options?.transferCache ?? true; - - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/api/topics/v2/topics/id`; - const { basePath, withCredentials } = this.configuration; - return this.httpClient.request('get', `${basePath}${localVarPath}`, - { - context: localVarHttpContext, - params: localVarQueryParameters, - responseType: responseType_, - ...(withCredentials ? { withCredentials } : {}), - headers: localVarHeaders, - observe: observe, - ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), - reportProgress: reportProgress - } - ); + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if ( + this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected) + ) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } } - /** - * Searches for topics based on the provided criteria. - * @endpoint get /api/topics/v2/search - * @param searchTerm The term to search for in topic display names. - * @param page The page number to retrieve. - * @param size The number of topics to retrieve per page. - * @param sortBy The field to sort by. - * @param sortDirection The direction to sort. - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public searchTopics(searchTerm?: string, page?: number, size?: number, sortBy?: TopicSortBy, sortDirection?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public searchTopics(searchTerm?: string, page?: number, size?: number, sortBy?: TopicSortBy, sortDirection?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public searchTopics(searchTerm?: string, page?: number, size?: number, sortBy?: TopicSortBy, sortDirection?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public searchTopics(searchTerm?: string, page?: number, size?: number, sortBy?: TopicSortBy, sortDirection?: SortDirection, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + let localVarPath = `/api/topics/v2/topics/id`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request( + 'get', + `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + params: localVarQueryParameters, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }, + ); + } - let localVarQueryParameters = new HttpParams({encoder: this.encoder}); - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - searchTerm, 'search_term'); - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - page, 'page'); - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - size, 'size'); - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - sortBy, 'sort_by'); - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - sortDirection, 'sort_direction'); + /** + * Searches for topics based on the provided criteria. + * @endpoint get /api/topics/v2/search + * @param searchTerm The term to search for in topic display names. + * @param page The page number to retrieve. + * @param size The number of topics to retrieve per page. + * @param sortBy The field to sort by. + * @param sortDirection The direction to sort. + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public searchTopics( + searchTerm?: string, + page?: number, + size?: number, + sortBy?: TopicSortBy, + sortDirection?: SortDirection, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable; + public searchTopics( + searchTerm?: string, + page?: number, + size?: number, + sortBy?: TopicSortBy, + sortDirection?: SortDirection, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public searchTopics( + searchTerm?: string, + page?: number, + size?: number, + sortBy?: TopicSortBy, + sortDirection?: SortDirection, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public searchTopics( + searchTerm?: string, + page?: number, + size?: number, + sortBy?: TopicSortBy, + sortDirection?: SortDirection, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + let localVarQueryParameters = new HttpParams({ encoder: this.encoder }); + localVarQueryParameters = this.addToHttpParams( + localVarQueryParameters, + searchTerm, + 'search_term', + ); + localVarQueryParameters = this.addToHttpParams( + localVarQueryParameters, + page, + 'page', + ); + localVarQueryParameters = this.addToHttpParams( + localVarQueryParameters, + size, + 'size', + ); + localVarQueryParameters = this.addToHttpParams( + localVarQueryParameters, + sortBy, + 'sort_by', + ); + localVarQueryParameters = this.addToHttpParams( + localVarQueryParameters, + sortDirection, + 'sort_direction', + ); - let localVarHeaders = this.defaultHeaders; + let localVarHeaders = this.defaultHeaders; - const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ - 'application/json' - ]); - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); - - const localVarTransferCache: boolean = options?.transferCache ?? true; - - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/api/topics/v2/search`; - const { basePath, withCredentials } = this.configuration; - return this.httpClient.request('get', `${basePath}${localVarPath}`, - { - context: localVarHttpContext, - params: localVarQueryParameters, - responseType: responseType_, - ...(withCredentials ? { withCredentials } : {}), - headers: localVarHeaders, - observe: observe, - ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), - reportProgress: reportProgress - } - ); + const localVarHttpHeaderAcceptSelected: string | undefined = + options?.httpHeaderAccept ?? + this.configuration.selectHeaderAccept(['application/json']); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Accept', + localVarHttpHeaderAcceptSelected, + ); } + const localVarHttpContext: HttpContext = + options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if ( + this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected) + ) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/topics/v2/search`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request( + 'get', + `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + params: localVarQueryParameters, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }, + ); + } } diff --git a/webapp/src/app/api/model/domain.ts b/webapp/src/app/api/model/domain.ts new file mode 100644 index 00000000..3a6c6b03 --- /dev/null +++ b/webapp/src/app/api/model/domain.ts @@ -0,0 +1,29 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { DomainFieldsInner } from './domainFieldsInner'; +import { DomainIds } from './domainIds'; + +/** + * Top-level category in the topic hierarchy (4 total) + */ +export interface Domain { + id?: string | null; + display_name?: string | null; + description?: string | null; + display_name_alternatives?: Array | null; + fields?: Array | null; + siblings?: Array | null; + ids?: DomainIds | null; + works_count?: number | null; + cited_by_count?: number | null; + works_api_url?: string | null; + created_date?: string | null; + updated_date?: string | null; +} diff --git a/webapp/src/app/api/model/domainFieldsInner.ts b/webapp/src/app/api/model/domainFieldsInner.ts new file mode 100644 index 00000000..302feae8 --- /dev/null +++ b/webapp/src/app/api/model/domainFieldsInner.ts @@ -0,0 +1,17 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * DomainFieldsInner + */ +export interface DomainFieldsInner { + id?: string | null; + display_name?: string | null; +} diff --git a/webapp/src/app/api/model/domainIds.ts b/webapp/src/app/api/model/domainIds.ts new file mode 100644 index 00000000..da44d258 --- /dev/null +++ b/webapp/src/app/api/model/domainIds.ts @@ -0,0 +1,18 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * External identifiers: + */ +export interface DomainIds { + openalex?: string | null; + wikidata?: string | null; + wikipedia?: string | null; +} diff --git a/webapp/src/app/api/model/modelField.ts b/webapp/src/app/api/model/modelField.ts new file mode 100644 index 00000000..f0aa2203 --- /dev/null +++ b/webapp/src/app/api/model/modelField.ts @@ -0,0 +1,31 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { DomainFieldsInner } from './domainFieldsInner'; +import { DomainIds } from './domainIds'; +import { WorkTopicDomain } from './workTopicDomain'; + +/** + * Second-level category in the topic hierarchy (26 total) + */ +export interface ModelField { + id?: string | null; + display_name?: string | null; + description?: string | null; + display_name_alternatives?: Array | null; + domain?: WorkTopicDomain | null; + subfields?: Array | null; + siblings?: Array | null; + ids?: DomainIds | null; + works_count?: number | null; + cited_by_count?: number | null; + works_api_url?: string | null; + created_date?: string | null; + updated_date?: string | null; +} diff --git a/webapp/src/app/api/model/models.ts b/webapp/src/app/api/model/models.ts index 3c72f9c1..d6da3737 100644 --- a/webapp/src/app/api/model/models.ts +++ b/webapp/src/app/api/model/models.ts @@ -78,6 +78,9 @@ export * from './dfgProjectSummary'; export * from './dfgProjectTopic'; export * from './dfgProjectTopics'; export * from './dockerHealth'; +export * from './domain'; +export * from './domainFieldsInner'; +export * from './domainIds'; export * from './edge'; export * from './euCordisEurosciVocSummary'; export * from './euCordisOrganizationSelectorPage'; @@ -174,6 +177,7 @@ export * from './matchedTopic'; export * from './mentionedPerson'; export * from './meta'; export * from './model2YrMeanCitedness'; +export * from './modelField'; export * from './newsArticle'; export * from './newsArticleDetail'; export * from './newsPage'; @@ -208,6 +212,9 @@ export * from './score'; export * from './selectedAuthorsRequest'; export * from './sortDirection'; export * from './startCollaborationGraphResponse'; +export * from './subfield'; +export * from './subfieldDomain'; +export * from './subfieldField'; export * from './subfieldShare'; export * from './timespan'; export * from './tokenType'; diff --git a/webapp/src/app/api/model/subfield.ts b/webapp/src/app/api/model/subfield.ts new file mode 100644 index 00000000..ef678f6a --- /dev/null +++ b/webapp/src/app/api/model/subfield.ts @@ -0,0 +1,33 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { DomainFieldsInner } from './domainFieldsInner'; +import { DomainIds } from './domainIds'; +import { SubfieldDomain } from './subfieldDomain'; +import { SubfieldField } from './subfieldField'; + +/** + * Third-level category in the topic hierarchy (254 total) + */ +export interface Subfield { + id?: string | null; + display_name?: string | null; + description?: string | null; + display_name_alternatives?: Array | null; + field?: SubfieldField | null; + domain?: SubfieldDomain | null; + topics?: Array | null; + siblings?: Array | null; + ids?: DomainIds | null; + works_count?: number | null; + cited_by_count?: number | null; + works_api_url?: string | null; + created_date?: string | null; + updated_date?: string | null; +} diff --git a/webapp/src/app/api/model/subfieldDomain.ts b/webapp/src/app/api/model/subfieldDomain.ts new file mode 100644 index 00000000..b2228d75 --- /dev/null +++ b/webapp/src/app/api/model/subfieldDomain.ts @@ -0,0 +1,17 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * The domain containing this subfield (top level of hierarchy). + */ +export interface SubfieldDomain { + id?: string | null; + display_name?: string | null; +} diff --git a/webapp/src/app/api/model/subfieldField.ts b/webapp/src/app/api/model/subfieldField.ts new file mode 100644 index 00000000..8aff75ea --- /dev/null +++ b/webapp/src/app/api/model/subfieldField.ts @@ -0,0 +1,17 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * The field containing this subfield (parent level). + */ +export interface SubfieldField { + id?: string | null; + display_name?: string | null; +} diff --git a/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.html b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.html index 60f5625b..e1439308 100644 --- a/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.html +++ b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.html @@ -35,18 +35,20 @@ - + @if (topic.id) { + - - - - menu_book - Publikationen - - - + + + + menu_book + Publikationen + + + + } diff --git a/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.ts b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.ts index ecf8affe..f6e204c9 100644 --- a/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.ts +++ b/webapp/src/app/shared/ui/app-topic-card/app-topic-card.component.ts @@ -35,7 +35,13 @@ export class AppTopicCardComponent { } subtitle = computed(() => { - return `${this.topic().subfield?.display_name} - ${this.topic().field?.display_name} - ${this.topic().domain?.display_name}`; + return [ + this.topic().subfield?.display_name, + this.topic().field?.display_name, + this.topic().domain?.display_name, + ] + .filter((part) => Boolean(part)) + .join(' - '); }); description = computed(() => { diff --git a/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.ts b/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.ts index 67c6b20e..2315bad7 100644 --- a/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.ts +++ b/webapp/src/app/shared/ui/app-topic-tooltip/app-topic-tooltip.component.ts @@ -24,9 +24,12 @@ export class AppTopicTooltipComponent { const hasCompleteMetrics = Boolean( topicObj && - (topicObj.description || - topicObj.works_count !== undefined || - topicObj.cited_by_count !== undefined), + topicObj.description && + topicObj.works_count !== undefined && + topicObj.cited_by_count !== undefined && + topicObj.subfield && + topicObj.field && + topicObj.domain, ); if (hasCompleteMetrics && topicObj) { diff --git a/webapp/src/app/shared/ui/legend-tooltip/legend-tooltip.component.html b/webapp/src/app/shared/ui/legend-tooltip/legend-tooltip.component.html new file mode 100644 index 00000000..01060734 --- /dev/null +++ b/webapp/src/app/shared/ui/legend-tooltip/legend-tooltip.component.html @@ -0,0 +1,10 @@ +
+
{{ name() }}
+ @if (hierarchy()) { +
{{ hierarchy() }}
+ } + @if (_description()) { +
+

{{ _description() }}

+ } +
diff --git a/webapp/src/app/shared/ui/legend-tooltip/legend-tooltip.component.scss b/webapp/src/app/shared/ui/legend-tooltip/legend-tooltip.component.scss new file mode 100644 index 00000000..a6ab156e --- /dev/null +++ b/webapp/src/app/shared/ui/legend-tooltip/legend-tooltip.component.scss @@ -0,0 +1,46 @@ +:host { + --topic-border: color-mix( + in srgb, + hsl(var(--topic-color)) 72%, + var(--sg-color-mix-base) + ); + --topic-background: color-mix( + in srgb, + hsl(var(--topic-color)) 8%, + var(--sg-color-mix-base) + ); +} + +.legend-tooltip-card { + display: flex; + flex-direction: column; + gap: 0.5rem; + padding: 1rem; + border-radius: var(--sg-radius-sm); + background-color: var(--topic-background); + border: 1px solid var(--topic-border); + color: var(--sg-text); +} + +.legend-tooltip-title { + font-weight: 600; + font-size: 1rem; +} + +.legend-tooltip-hierarchy { + color: var(--sg-text-muted); + font-size: 0.875rem; +} + +.legend-tooltip-divider { + margin: 0; + border: none; + border-top: 1px solid var(--topic-border); +} + +.legend-tooltip-description { + margin: 0; + color: var(--sg-text); + font-size: 0.875rem; + line-height: 1.4; +} diff --git a/webapp/src/app/shared/ui/legend-tooltip/legend-tooltip.component.ts b/webapp/src/app/shared/ui/legend-tooltip/legend-tooltip.component.ts new file mode 100644 index 00000000..c415af24 --- /dev/null +++ b/webapp/src/app/shared/ui/legend-tooltip/legend-tooltip.component.ts @@ -0,0 +1,76 @@ +import { + Component, + computed, + effect, + inject, + input, + signal, +} from '@angular/core'; +import { TopicsV2Service } from '../../../api'; + +@Component({ + host: { + '[style.--topic-color]': 'topicColorVar()', + }, + selector: 'app-legend-tooltip', + standalone: true, + templateUrl: './legend-tooltip.component.html', + styleUrl: './legend-tooltip.component.scss', +}) +export class LegendTooltipComponent { + private readonly topicsService = inject(TopicsV2Service); + + readonly name = input.required(); + readonly hierarchy = input(null); + readonly description = input(null); + readonly fieldId = input(null); + readonly subfieldId = input(null); + readonly color = input(null); + + readonly _description = signal(undefined); + + readonly topicColorVar = computed(() => { + const color = this.color(); + if (!color) return ''; + return color.replace('hsl(', '').replace(')', ''); + }); + + constructor() { + effect(() => { + const description = this.description(); + if (description) { + this._description.set(description); + return; + } + + const rawSubfieldId = this.extractOpenAlexShortId(this.subfieldId()); + if (rawSubfieldId) { + this.topicsService.getSubfieldById(rawSubfieldId).subscribe({ + next: (subfield) => this._description.set(subfield.description), + error: () => this._description.set(undefined), + }); + return; + } + + const rawFieldId = this.extractOpenAlexShortId(this.fieldId()); + if (rawFieldId) { + this.topicsService.getFieldById(rawFieldId).subscribe({ + next: (field) => this._description.set(field.description), + error: () => this._description.set(undefined), + }); + return; + } + + this._description.set(undefined); + }); + } + + private extractOpenAlexShortId( + id: string | null | undefined, + ): string | undefined { + if (!id || !id.includes('openalex.org')) { + return undefined; + } + return id.split('/').pop() || undefined; + } +} diff --git a/webapp/src/app/shared/ui/topic-legend/topic-legend.component.html b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.html index 330ccc2b..83598c47 100644 --- a/webapp/src/app/shared/ui/topic-legend/topic-legend.component.html +++ b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.html @@ -54,10 +54,16 @@ class="topic-legend-field" [class.topic-legend-entry-active]="isFieldActive(group)" [attr.aria-pressed]="selectable ? isFieldActive(group) : null" - [matTooltip]="group.tooltip" - [matTooltipDisabled]="!group.tooltip" - matTooltipClass="topic-chip-tooltip" - matTooltipPosition="above" + [appComponentTooltip]="LegendTooltipComponent" + [tooltipInputs]="{ + name: group.name, + hierarchy: group.domainName, + description: group.description, + fieldId: group.id, + color: group.color, + }" + [tooltipDisabled]="!hasTooltipContent(group.description, group.id)" + [tooltipMaxWidth]="'420px'" (click)="toggleField(group)"> {{ item.name }} diff --git a/webapp/src/app/shared/ui/topic-legend/topic-legend.component.ts b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.ts index ec776260..b28d3e90 100644 --- a/webapp/src/app/shared/ui/topic-legend/topic-legend.component.ts +++ b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.ts @@ -2,6 +2,8 @@ import { CommonModule } from '@angular/common'; import { Component, EventEmitter, Input, Output } from '@angular/core'; import { MatIconModule } from '@angular/material/icon'; import { MatTooltipModule } from '@angular/material/tooltip'; +import { ComponentTooltipDirective } from '../../../directives/component-tooltip.directive'; +import { LegendTooltipComponent } from '../legend-tooltip/legend-tooltip.component'; import { TopicLegendGroup, TopicLegendItem, @@ -13,11 +15,17 @@ export type TopicLegendVariant = 'default' | 'compact'; @Component({ selector: 'app-topic-legend', standalone: true, - imports: [CommonModule, MatIconModule, MatTooltipModule], + imports: [ + CommonModule, + MatIconModule, + MatTooltipModule, + ComponentTooltipDirective, + ], templateUrl: './topic-legend.component.html', styleUrl: './topic-legend.component.scss', }) export class TopicLegendComponent { + readonly LegendTooltipComponent = LegendTooltipComponent; @Input() groups: TopicLegendGroup[] = []; @Input() title = 'Farben nach Fachgebiet'; @Input() infoTooltip = @@ -107,6 +115,10 @@ export class TopicLegendComponent { return item.id; } + hasTooltipContent(description: string, id: string): boolean { + return Boolean(description) || id.includes('openalex.org'); + } + private isActiveLegendId( activeIds: ReadonlySet | readonly string[], id: string,