diff --git a/service/src/main/inse/authors/v2/model.py b/service/src/main/inse/authors/v2/model.py new file mode 100644 index 00000000..fdb0c63f --- /dev/null +++ b/service/src/main/inse/authors/v2/model.py @@ -0,0 +1,8 @@ +from inse.model import Page +from inse.models.openalex.author import Author + + +class AuthorPage(Page[Author]): + """A paginated response containing a list of authors.""" + + pass diff --git a/service/src/main/inse/authors/v2/router.py b/service/src/main/inse/authors/v2/router.py new file mode 100644 index 00000000..74fce377 --- /dev/null +++ b/service/src/main/inse/authors/v2/router.py @@ -0,0 +1,47 @@ +import logging +from typing import Annotated + +from fastapi import APIRouter, Query + +from inse.tags import Tags +from inse.authors.v2.model import AuthorPage + +import inse.authors.v2.service as authors_service + + +AUTHORS_V2_PREFIX = "/api/v2/authors" + +logger = logging.getLogger(__name__) + + +router = APIRouter(prefix=AUTHORS_V2_PREFIX, tags=[Tags.AUTHORS_V2]) + + +@router.get( + "/authors/id", + operation_id="getAuthorsByIds", + summary="Returns a paginated list of authors for a given list of author IDs.", +) +async def get_authors_by_ids( + author_ids: Annotated[ + list[str], + Query(description="A list of author IDs to retrieve."), + ] = [], +) -> AuthorPage: + return await authors_service.get_authors_by_ids(author_ids=author_ids or []) + + +@router.get( + "/autocomplete/selector", + operation_id="autocompleteAuthorsForSelector", + summary="Returns a paginated list of authors for a given search term based on their display name.", +) +async def autocomplete_authors_for_selector( + query: Annotated[ + str, + Query( + description="A search term to filter authors by (partial matches allowed)." + ), + ] = "", +) -> AuthorPage: + return await authors_service.autocomplete_authors_for_selector(query=query) diff --git a/service/src/main/inse/authors/v2/service.py b/service/src/main/inse/authors/v2/service.py new file mode 100644 index 00000000..428d7fed --- /dev/null +++ b/service/src/main/inse/authors/v2/service.py @@ -0,0 +1,97 @@ +from typing import Dict, List, Optional + +from inse.authors.v2.model import AuthorPage +from inse.integrations import elasticsearch +from inse.model import ESIndex +from inse.models.openalex.author import Author + + +async def search_authors( + page: int = 0, + size: int = 10, + query: Optional[Dict] = None, + source: Optional[List[str]] = None, + sort: Optional[List[dict]] = None, + body: Optional[dict] = None, +) -> AuthorPage: + """Searches for authors in the OpenAlex Elasticsearch index based on the provided parameters. + + Args: + page (int, optional): The page number for pagination (0-indexed). Defaults to 0. + size (int, optional): The number of results to return per page. Defaults to 10. + query (Optional[Dict], optional): The search query. Defaults to None. + source (Optional[List[str]], optional): The fields to include in the response. Defaults to None. + sort (Optional[List[dict]], optional): The sorting criteria. Defaults to None. + body (Optional[dict], optional): The request body for the search query. Defaults to None. + + Returns: + AuthorPage: A page of authors matching the search criteria. + """ + + response = await elasticsearch.search( + ESIndex.OPENALEX_AUTHORS, + query=query, + source=source, + size=size, + offset=size * page, + sort=sort, + body=body, + ) + + hits_block = response.get("hits", {}) + hits = hits_block.get("hits", []) + authors: List[Author] = [] + for hit in hits: + _source = hit.get("_source", {}) + authors.append(Author.from_dict(_source)) # type: ignore + return AuthorPage(elements=authors, total=len(authors), page=page, size=size) + + +async def autocomplete_authors_for_selector(query: str) -> AuthorPage: + """Autocompletes authors based on a search term for use in a selector component. + + Args: + query (str): The search term to filter authors by (partial matches allowed). + + Returns: + AuthorPage: A page of authors matching the search criteria. + """ + + return await search_authors( + page=0, + size=10, + query={"match_phrase_prefix": {"display_name": query}}, + source=[ + "id", + "display_name", + "orcid", + "last_known_institutions", + "works_count", + ], + ) + + +async def get_authors_by_ids(author_ids: List[str]) -> AuthorPage: + """Retrieves authors based on a list of author IDs. + + Args: + author_ids (List[str]): A list of author IDs to retrieve. + + Returns: + AuthorPage: A page of authors matching the provided IDs. + """ + if not author_ids: + return AuthorPage(elements=[], total=0, page=0, size=0) + + return await search_authors( + page=0, + size=len(author_ids), + query={"terms": {"id": author_ids}}, + source=[ + "id", + "display_name", + "orcid", + "last_known_institutions", + "works_count", + ], + ) diff --git a/service/src/main/inse/institutions/v2/model.py b/service/src/main/inse/institutions/v2/model.py new file mode 100644 index 00000000..8f7572ec --- /dev/null +++ b/service/src/main/inse/institutions/v2/model.py @@ -0,0 +1,8 @@ +from inse.model import Page +from inse.models.openalex.institution import Institution + + +class InstitutionPageV2(Page[Institution]): + """A paginated response containing a list of institutions.""" + + pass diff --git a/service/src/main/inse/institutions/v2/router.py b/service/src/main/inse/institutions/v2/router.py new file mode 100644 index 00000000..d86074b9 --- /dev/null +++ b/service/src/main/inse/institutions/v2/router.py @@ -0,0 +1,49 @@ +import logging +from typing import Annotated + +from fastapi import APIRouter, Query + +from inse.institutions.v2.model import InstitutionPageV2 +from inse.tags import Tags + + +logger = logging.getLogger(__name__) + + +INSTITUTIONS_v2_PREFIX = "/api/v2/institutions" + +router = APIRouter(prefix=INSTITUTIONS_v2_PREFIX, tags=[Tags.INSTITUTIONS_V2]) + + +@router.get( + "/ids", + operation_id="getInstitutionsByIds", + summary="Returns a list of institutions based on their IDs.", +) +async def get_institutions_by_ids( + institution_ids: Annotated[ + list[str], + Query(description="A list of institution IDs to retrieve."), + ] = [], +) -> InstitutionPageV2: + from inse.institutions.v2.service import get_institutions_by_ids + + return await get_institutions_by_ids(institution_ids=institution_ids or []) + + +@router.get( + "/autocomplete/selector", + operation_id="getInstitutionAutocompleteForSelector", + summary="Returns a list of institutions based on a search term for autocomplete functionality.", +) +async def get_institution_autocomplete( + query: Annotated[ + str, + Query( + description="A search term to filter institutions by (partial matches allowed)." + ), + ] = "", +) -> InstitutionPageV2: + from inse.institutions.v2.service import autocomplete_institutions_for_selector + + return await autocomplete_institutions_for_selector(query=query) diff --git a/service/src/main/inse/institutions/v2/service.py b/service/src/main/inse/institutions/v2/service.py new file mode 100644 index 00000000..47554ece --- /dev/null +++ b/service/src/main/inse/institutions/v2/service.py @@ -0,0 +1,141 @@ +import logging +from typing import Dict, List, Optional + +from inse.integrations import elasticsearch +from inse.model import ESIndex +from inse.models.openalex.institution import Institution +from inse.institutions.v2.model import InstitutionPageV2 + + +logger = logging.getLogger(__name__) + + +async def search_institutions( + page: int = 0, + size: int = 10, + query: Optional[Dict] = None, + source: Optional[List[str]] = None, + sort: Optional[List[Dict]] = None, + body: Optional[Dict] = None, +) -> InstitutionPageV2: + """Searches for institutions in the OpenAlex Elasticsearch index based on the provided parameters. + + Args: + page (int, optional): The page number to retrieve. Defaults to 0. + size (int, optional): The number of institutions to retrieve per page. Defaults to 10. + query (Optional[Dict], optional): The search query to filter institutions by. Defaults to None. + source (Optional[List[str]], optional): A list of fields to include in the response. Defaults to None. + sort (Optional[List[Dict]], optional): A list of sorting criteria. Defaults to None. + body (Optional[Dict], optional): The request body for the Elasticsearch search query. Defaults to None. + + Returns: + InstitutionPageV2: A page of institutions matching the search criteria. + """ + response = await elasticsearch.search( + ESIndex.OPENALEX_INSTITUTIONS, + query=query, + source=source, + size=size, + offset=size * page, + sort=sort, + body=body, + ) + + hits_block = response.get("hits", {}) + hits = hits_block.get("hits", []) + institutions: List[Institution] = [] + for hit in hits: + _source = hit.get("_source", {}) + institutions.append(Institution.from_dict(_source)) # type: ignore + return InstitutionPageV2( + elements=institutions, total=len(institutions), page=page, size=size + ) + + +async def get_institutions_by_ids(institution_ids: List[str]) -> InstitutionPageV2: + """Retrieves institutions based on a list of institution IDs. + + Args: + institution_ids (List[str]): A list of institution IDs to retrieve. + + Returns: + InstitutionPageV2: A page of institutions matching the provided IDs. + """ + logger.debug(f"Fetching institutions for IDs: {institution_ids}") + if not institution_ids: + return InstitutionPageV2(elements=[], total=0, page=0, size=0) + + return await search_institutions( + page=0, + size=len(institution_ids), + query={"terms": {"id": institution_ids}}, + source=[ + "id", + "display_name", + "display_name_alternatives", + "country_code", + "type", + "ror", + ], + ) + + +async def autocomplete_institutions( + query: str, page: int = 0, size: int = 10, source: Optional[List[str]] = None +) -> InstitutionPageV2: + """Autocompletes institutions based on a search term. + + Args: + query (str): The search term to autocomplete institutions with. + page (int, optional): The page number to retrieve. Defaults to 0. + size (int, optional): The number of institutions to retrieve per page. Defaults to 10. + source (Optional[List[str]], optional): A list of fields to include in the response. Defaults to None. + + Returns: + InstitutionPageV2: A page of institutions matching the autocomplete criteria. + """ + logger.debug(f"Autocomplete institutions for query: {query}") + if not query: + return InstitutionPageV2(elements=[], total=0, page=0, size=0) + + return await search_institutions( + page=page, + size=size, + query={ + "bool": { + "should": [ + {"match_phrase_prefix": {"display_name": query}}, + {"match_phrase_prefix": {"display_name_alternatives": query}}, + ] + } + }, + source=source, + ) + + +async def autocomplete_institutions_for_selector( + query: str, page: int = 0, size: int = 10 +) -> InstitutionPageV2: + """Autocompletes institutions based on a search term for use in a selector component. + + Args: + query (str): The search term to filter institutions by (partial matches allowed). + page (int, optional): The page number to retrieve. Defaults to 0. + size (int, optional): The number of institutions to retrieve per page. Defaults to 10. + + Returns: + InstitutionPageV2: A page of institutions matching the autocomplete criteria. + """ + return await autocomplete_institutions( + query=query, + page=page, + size=size, + source=[ + "id", + "display_name", + "display_name_alternatives", + "country_code", + "type", + "ror", + ], + ) diff --git a/service/src/main/inse/main.py b/service/src/main/inse/main.py index 1e9c0a78..1fa1b997 100644 --- a/service/src/main/inse/main.py +++ b/service/src/main/inse/main.py @@ -54,6 +54,9 @@ from inse.patents.service import ( ) from inse.works.v2.router import router as works_v2_router +from inse.authors.v2.router import router as authors_v2_router +from inse.institutions.v2.router import router as institutions_v2_router +from inse.topics.v2.router import router as topics_v2_router logger = logging.getLogger(__name__) @@ -102,7 +105,11 @@ app.include_router(service_router) app.include_router(auth_router) app.include_router(account_management_router) app.include_router(organization_management_router) + app.include_router(works_v2_router) +app.include_router(authors_v2_router) +app.include_router(institutions_v2_router) +app.include_router(topics_v2_router) app.include_router(dashboard_router) app.include_router(bookmarks_router) diff --git a/service/src/main/inse/model.py b/service/src/main/inse/model.py index 310324dd..80921560 100644 --- a/service/src/main/inse/model.py +++ b/service/src/main/inse/model.py @@ -28,6 +28,8 @@ T = TypeVar("T", bound=BaseModel) class Page(BaseModel, Generic[T]): + """A generic page model that represents a paginated response containing elements of type T.""" + elements: List[T] = Field(default=[], description="The elements of the page.") page: int = Field(default=0, description="The page number. (0-based)") size: int = Field(default=20, description="The page size in elements.") @@ -114,4 +116,3 @@ class ESIndex(StrEnum): PROJECTS_CORDIS_EU_H2020_TOPICS = "projects_cordiseu_h2020_openalex_topics" PROJECTS_CORDIS_EU_HEUROPE_TOPICS = "projects_cordiseu_heurope_openalex_topics" PATENTS_OPENALEX_KEYWORDS = "patents_openalex_keywords" - diff --git a/service/src/main/inse/tags.py b/service/src/main/inse/tags.py index a5411f63..5eb73000 100644 --- a/service/src/main/inse/tags.py +++ b/service/src/main/inse/tags.py @@ -7,7 +7,6 @@ class Tags(StrEnum): INSTITUTIONS = "Institutions" TOPICS = "Topics" WORKS = "Works" - WORKS_V2 = "Works V2" NEWS = "News" PROJECTS = "Projects" AUTH = "Auth" @@ -15,3 +14,8 @@ class Tags(StrEnum): ORGANIZATION = "Organization" UNIVERSITY_RANKINGS = "University Rankings" DASHBOARD = "Dashboard" + + AUTHORS_V2 = "Authors V2" + INSTITUTIONS_V2 = "Institutions V2" + TOPICS_V2 = "Topics V2" + WORKS_V2 = "Works V2" diff --git a/service/src/main/inse/topics/v2/model.py b/service/src/main/inse/topics/v2/model.py new file mode 100644 index 00000000..92931d63 --- /dev/null +++ b/service/src/main/inse/topics/v2/model.py @@ -0,0 +1,6 @@ +from inse.model import Page +from inse.models.openalex.topic import Topic + + +class TopicPageV2(Page[Topic]): + pass diff --git a/service/src/main/inse/topics/v2/router.py b/service/src/main/inse/topics/v2/router.py new file mode 100644 index 00000000..fa571324 --- /dev/null +++ b/service/src/main/inse/topics/v2/router.py @@ -0,0 +1,47 @@ +import logging +from typing import Annotated + +from fastapi import APIRouter, Query + +from inse.tags import Tags + +import inse.topics.v2.service as topics_service +from inse.topics.v2.model import TopicPageV2 + + +TOPICS_V2_PREFIX = "/api/v2/topics" + +logger = logging.getLogger(__name__) + + +router = APIRouter(prefix=TOPICS_V2_PREFIX, tags=[Tags.TOPICS_V2]) + + +@router.get( + "/topics/id", + operation_id="getTopicsByIds", + summary="Returns a paginated list of topics for a given list of topic IDs.", +) +async def get_topics_by_ids( + topic_ids: Annotated[ + list[str], + Query(description="A list of topic IDs to retrieve."), + ] = [], +) -> TopicPageV2: + return await topics_service.get_topics_by_ids(topic_ids=topic_ids or []) + + +@router.get( + "/autocomplete/selector", + operation_id="autocompleteTopicsForSelector", + summary="Returns a paginated list of topics for a given search term based on their display name.", +) +async def autocomplete_topics_for_selector( + query: Annotated[ + str, + Query( + description="A search term to filter topics by (partial matches allowed)." + ), + ] = "", +) -> TopicPageV2: + return await topics_service.autocomplete_topics_for_selector(query=query) diff --git a/service/src/main/inse/topics/v2/service.py b/service/src/main/inse/topics/v2/service.py new file mode 100644 index 00000000..ab1715d5 --- /dev/null +++ b/service/src/main/inse/topics/v2/service.py @@ -0,0 +1,95 @@ +from typing import Dict, List, Optional + +from inse.integrations import elasticsearch +from inse.model import ESIndex +from inse.models.openalex.topic import Topic +from inse.topics.v2.model import TopicPageV2 + + +async def search_topics( + page: int = 0, + size: int = 10, + query: Optional[Dict] = None, + source: Optional[List[str]] = None, + sort: Optional[List[Dict]] = None, + body: Optional[Dict] = None, +) -> TopicPageV2: + """Searches for topics based on the provided criteria. + + Args: + page (int, optional): The page number to retrieve. Defaults to 0. + size (int, optional): The number of topics to retrieve per page. Defaults to 10. + query (Optional[Dict], optional): The search query. Defaults to None. + source (Optional[List[str]], optional): A list of fields to include in the response. Defaults to None. + sort (Optional[List[Dict]], optional): A list of sort criteria. Defaults to None. + body (Optional[Dict], optional): The request body for the search query. Defaults to None. + + Returns: + TopicPageV2: A page of topics matching the search criteria. + """ + response = await elasticsearch.search( + ESIndex.OPENALEX_TOPICS, + query=query, + source=source, + size=size, + offset=size * page, + sort=sort, + body=body, + ) + + hits_block = response.get("hits", {}) + hits = hits_block.get("hits", []) + topics: List[Topic] = [] + for hit in hits: + _source = hit.get("_source", {}) + topics.append(Topic.from_dict(_source)) # type: ignore + return TopicPageV2(elements=topics, total=len(topics), page=page, size=size) + + +async def autocomplete_topics_for_selector(query: str) -> TopicPageV2: + """Autocompletes topics based on a search term for use in a selector component. + + Args: + query (str): The search term to filter topics by (partial matches allowed). + + Returns: + TopicPageV2: A page of topics matching the autocomplete criteria. + """ + return await search_topics( + page=0, + size=10, + query={"match_phrase_prefix": {"display_name": query}}, + source=[ + "id", + "display_name", + "subfield", + "field", + "domain", + ], + ) + + +async def get_topics_by_ids(topic_ids: List[str]) -> TopicPageV2: + """Retrieves topics based on a list of topic IDs. + + Args: + topic_ids (List[str]): A list of topic IDs to retrieve. + + Returns: + TopicPageV2: A page of topics matching the provided IDs. + """ + if not topic_ids: + return TopicPageV2(elements=[], total=0, page=0, size=0) + + return await search_topics( + page=0, + size=len(topic_ids), + query={"terms": {"id": topic_ids}}, + source=[ + "id", + "display_name", + "subfield", + "field", + "domain", + ], + ) diff --git a/service/src/main/inse/works/v2/model.py b/service/src/main/inse/works/v2/model.py index 90ce1b31..f1d732d1 100644 --- a/service/src/main/inse/works/v2/model.py +++ b/service/src/main/inse/works/v2/model.py @@ -17,7 +17,7 @@ class WorkSortBy(StrEnum): CITED_BY_COUNT = "cited_by_count" -class WorkPage(Page[Work]): +class WorkPageV2(Page[Work]): pass diff --git a/service/src/main/inse/works/v2/router.py b/service/src/main/inse/works/v2/router.py index 36a43677..f2f130bf 100644 --- a/service/src/main/inse/works/v2/router.py +++ b/service/src/main/inse/works/v2/router.py @@ -1,5 +1,5 @@ import logging -from typing import Annotated, List +from typing import Annotated from fastapi import APIRouter, Path, Query @@ -9,13 +9,9 @@ from inse.works.v2.model import ( WorkClassification, WorkClassificationMergePage, WorkClassificationPage, - WorkPage, + WorkPageV2, WorkSortBy, ) -from inse.models.openalex.work_topic import WorkTopic -from inse.models.openalex.institution import Institution -from inse.models.openalex.author import Author -from inse.models.openalex.topic import Topic from inse.auth.model import AccessTokenMetadata from inse.auth.service import CurrentUserAccessTokenPayloadDep @@ -70,7 +66,7 @@ async def get_author_works( sort_order: Annotated[ SortDirection, Query(description="The order to sort by.") ] = SortDirection.DESCENDING, -) -> WorkPage: +) -> WorkPageV2: from inse.works.v2.service import get_author_works return await get_author_works( @@ -133,7 +129,7 @@ async def get_institution_works( sort_order: Annotated[ SortDirection, Query(description="The order to sort by.") ] = SortDirection.DESCENDING, -) -> WorkPage: +) -> WorkPageV2: from inse.works.v2.service import get_institution_works return await get_institution_works( @@ -151,108 +147,6 @@ async def get_institution_works( ) -@router.get( - "/topics/search", - operation_id="getWorkTopicsByIds", - summary="Returns a list of work topics based on their IDs.", -) -async def get_work_topics_by_ids( - topic_ids: Annotated[ - list[str], - Query(description="A list of topic IDs to retrieve."), - ] = [], -) -> List[WorkTopic]: - from inse.works.v2.service import get_work_topics_by_ids - - return await get_work_topics_by_ids(topic_ids=topic_ids or []) - - -@router.get( - "/institutions/search", - operation_id="getInstitutionsByIds", - summary="Returns a list of institutions based on their IDs.", -) -async def get_institutions_by_ids( - institution_ids: Annotated[ - list[str], - Query(description="A list of institution IDs to retrieve."), - ] = [], -) -> List[Institution]: - from inse.works.v2.service import get_work_institutions_by_ids - - return await get_work_institutions_by_ids(institution_ids=institution_ids or []) - - -@router.get( - "/authors/search", - operation_id="getAuthorsByIds", - summary="Returns a list of authors based on their IDs.", -) -async def get_authors_by_ids( - author_ids: Annotated[ - list[str], - Query(description="A list of author IDs to retrieve."), - ] = [], -) -> List[Author]: - from inse.works.v2.service import get_work_authors_by_ids - - return await get_work_authors_by_ids(author_ids=author_ids or []) - - -@router.get( - "/topics/autocomplete", - operation_id="getTopicAutocomplete", - summary="Returns a list of work topics based on a search term for autocomplete functionality.", -) -async def get_topic_autocomplete( - query: Annotated[ - str, - Query( - description="A search term to filter topics by (partial matches allowed)." - ), - ] = "", -) -> List[Topic]: - from inse.works.v2.service import search_topics - - return await search_topics(query=query) - - -@router.get( - "/institutions/autocomplete", - operation_id="getInstitutionAutocomplete", - summary="Returns a list of institutions based on a search term for autocomplete functionality.", -) -async def get_institution_autocomplete( - query: Annotated[ - str, - Query( - description="A search term to filter institutions by (partial matches allowed)." - ), - ] = "", -) -> List[Institution]: - from inse.works.v2.service import search_institutions - - return await search_institutions(query=query) - - -@router.get( - "/authors/autocomplete", - operation_id="getAuthorAutocomplete", - summary="Returns a list of authors based on a search term for autocomplete functionality.", -) -async def get_author_autocomplete( - query: Annotated[ - str, - Query( - description="A search term to filter authors by (partial matches allowed)." - ), - ] = "", -) -> List[Author]: - from inse.works.v2.service import search_authors - - return await search_authors(query=query) - - @router.get( "/classification/author/{raw_oa_author_id}", operation_id="getWorkClassificationsByAuthorId", diff --git a/service/src/main/inse/works/v2/service.py b/service/src/main/inse/works/v2/service.py index 98a2f8aa..5232efe2 100644 --- a/service/src/main/inse/works/v2/service.py +++ b/service/src/main/inse/works/v2/service.py @@ -8,21 +8,25 @@ from inse.works.v2.model import ( WorkClassificationPage, WorkClassificationMerge, WorkClassificationMergePage, - WorkPage, + WorkPageV2, WorkSortBy, ) -from inse.models.openalex.work_topic import WorkTopic -from inse.models.openalex.institution import Institution from inse.models.openalex.work import Work -from inse.models.openalex.author import Author -from inse.models.openalex.topic import Topic from inse.auth.model import AccessTokenMetadata logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) -def _authors_nested_query(author_ids: List[str]) -> dict: +def _authors_nested_query(author_ids: List[str]) -> Dict: + """Returns a nested query for filtering works by a list of author IDs. + + Args: + author_ids (List[str]): A list of author IDs to filter by. + + Returns: + Dict: A nested query for filtering works by the specified author IDs. + """ prefixed = [_prefix_id(aid) for aid in author_ids] return { "nested": { @@ -32,7 +36,15 @@ def _authors_nested_query(author_ids: List[str]) -> dict: } -def _institutions_nested_query(institution_ids: List[str]) -> dict: +def _institutions_nested_query(institution_ids: List[str]) -> Dict: + """Returns a nested query for filtering works by a list of institution IDs. + + Args: + institution_ids (List[str]): A list of institution IDs to filter by. + + Returns: + Dict: A nested query for filtering works by the specified institution IDs. + """ prefixed = [_prefix_id(iid) for iid in institution_ids] return { "nested": { @@ -47,7 +59,15 @@ def _institutions_nested_query(institution_ids: List[str]) -> dict: } -def _title_query(title: str) -> dict: +def _title_query(title: str) -> Dict: + """Returns a query for filtering works by title using a multi-match query. + + Args: + title (str): The title to filter works by. + + Returns: + Dict: A multi-match query for filtering works by the specified title. + """ return { "multi_match": { "query": title, @@ -62,13 +82,23 @@ def _title_query(title: str) -> dict: def _apply_common_filters( - must: list, + must: List, publication_years: Optional[List[int]], publication_types: Optional[List[str]], language_codes: Optional[List[str]], topic_ids: Optional[List[str]], title: Optional[str] = None, ) -> None: + """Applies common filters to the provided list of must conditions for filtering works. + + Args: + must (list): A list of must conditions to which the common filters will be appended. + publication_years (Optional[List[int]]): A list of publication years to filter by. + publication_types (Optional[List[str]]): A list of publication types to filter by. + language_codes (Optional[List[str]]): A list of language codes to filter by. + topic_ids (Optional[List[str]]): A list of topic IDs to filter by. + title (Optional[str], optional): The title to filter works by. Defaults to None. + """ if publication_years: must.append({"terms": {"publication_year": publication_years}}) if publication_types: @@ -83,17 +113,41 @@ def _apply_common_filters( must.append(_title_query(title)) -def _build_sort(sort_by: WorkSortBy, sort_order: SortDirection) -> list: +def _build_sort(sort_by: WorkSortBy, sort_order: SortDirection) -> List[Dict]: + """Builds a sort criteria list for sorting works based on the specified sort_by and sort_order. + + Args: + sort_by (WorkSortBy): The field to sort by. + sort_order (SortDirection): The direction to sort in. + + Returns: + List[Dict]: A list of sort criteria. + """ if sort_by == WorkSortBy.TITLE: return [{"title.keyword": sort_order.value}] return [{sort_by.value: sort_order.value}] async def _execute_works_search( - must: list, page: int, size: int, sort_by: WorkSortBy, sort_order: SortDirection -) -> WorkPage: - response = await elasticsearch.search( - ESIndex.OPENALEX_WORKS_WILDCARD, + must: List[Dict], + page: int, + size: int, + sort_by: WorkSortBy, + sort_order: SortDirection, +) -> WorkPageV2: + """Executes a search for works based on the provided must conditions, pagination, and sorting criteria. + + Args: + must (List[Dict]): A list of must conditions for filtering works. + page (int): The page number for pagination. + size (int): The number of results per page. + sort_by (WorkSortBy): The field to sort by. + sort_order (SortDirection): The direction to sort in. + + Returns: + WorkPageV2: The page of works matching the search criteria. + """ + return await search_works( source=[ "id", "title", @@ -108,21 +162,11 @@ async def _execute_works_search( "topics", ], query={"bool": {"must": must}}, + page=page, size=size, - offset=page * size, sort=_build_sort(sort_by, sort_order), ) - hits_block = response.get("hits", {}) - total = hits_block.get("total", {}).get("value", 0) - elements: List[Work] = [] - for hit in hits_block.get("hits", []): - work = Work.from_dict(hit.get("_source", {})) # type: ignore - if work is not None: - elements.append(work) - - return WorkPage(elements=elements, total=total, page=page, size=size) - async def get_works( page: int, @@ -138,7 +182,30 @@ async def get_works( language_codes: Optional[List[str]] = None, sort_by: WorkSortBy = WorkSortBy.PUBLICATION_YEAR, sort_order: SortDirection = SortDirection.DESCENDING, -) -> WorkPage: +) -> WorkPageV2: + """Searches for works based on the provided criteria. + + Args: + page (int): The page number for pagination. + size (int): The number of results per page. + raw_oa_author_id (Optional[str], optional): The ID of the author to filter by. Defaults to None. + raw_oa_institution_id (Optional[str], optional): The ID of the institution to filter by. Defaults to None. + title (Optional[str], optional): The title of the works to filter by. Defaults to None. + author_ids (Optional[List[str]], optional): A list of author IDs to filter by. Defaults to None. + institution_ids (Optional[List[str]], optional): A list of institution IDs to filter by. Defaults to None. + publication_years (Optional[List[int]], optional): A list of publication years to filter by. Defaults to None. + publication_types (Optional[List[str]], optional): A list of publication types to filter by. Defaults to None. + topic_ids (Optional[List[str]], optional): A list of topic IDs to filter by. Defaults to None. + language_codes (Optional[List[str]], optional): A list of language codes to filter by. Defaults to None. + sort_by (WorkSortBy, optional): The field to sort by. Defaults to WorkSortBy.PUBLICATION_YEAR. + sort_order (SortDirection, optional): The direction to sort in. Defaults to SortDirection.DESCENDING. + + Raises: + ValueError: If neither raw_oa_author_id nor raw_oa_institution_id is provided. + + Returns: + WorkPageV2: The page of works matching the criteria. + """ if not raw_oa_author_id and not raw_oa_institution_id: raise ValueError( "get_works requires at least one of raw_oa_author_id or raw_oa_institution_id" @@ -175,7 +242,26 @@ async def get_author_works( language_codes: Optional[List[str]] = None, sort_by: WorkSortBy = WorkSortBy.PUBLICATION_YEAR, sort_order: SortDirection = SortDirection.DESCENDING, -) -> WorkPage: +) -> WorkPageV2: + """Retrieves works for a specific author based on the provided criteria. + + Args: + raw_oa_author_id (str): The ID of the author for whom to retrieve works. + page (int): The page number of the results to retrieve. + size (int): The number of results per page. + title (str, optional): The title of the works to filter by. Defaults to "". + publication_years (Optional[List[int]], optional): A list of publication years to filter by. Defaults to None. + publication_types (Optional[List[str]], optional): A list of publication types to filter by. Defaults to None. + institution_ids (Optional[List[str]], optional): A list of institution IDs to filter by. Defaults to None. + topic_ids (Optional[List[str]], optional): A list of topic IDs to filter by. Defaults to None. + language_codes (Optional[List[str]], optional): A list of language codes to filter by. Defaults to None. + sort_by (WorkSortBy, optional): The field by which to sort the results. Defaults to WorkSortBy.PUBLICATION_YEAR. + sort_order (SortDirection, optional): The direction to sort in. Defaults to SortDirection.DESCENDING. + + Returns: + WorkPageV2: The page of works matching the criteria. + """ + return await get_works( page=page, size=size, @@ -203,7 +289,26 @@ async def get_institution_works( language_codes: Optional[List[str]] = None, sort_by: WorkSortBy = WorkSortBy.PUBLICATION_YEAR, sort_order: SortDirection = SortDirection.DESCENDING, -) -> WorkPage: +) -> WorkPageV2: + """Retrieves works for a specific institution based on the provided criteria. + + Args: + raw_oa_institution_id (str): The ID of the institution for whom to retrieve works. + page (int): The page number of the results to retrieve. + size (int): The number of results per page. + title (str, optional): The title of the works to filter by. Defaults to "". + publication_years (Optional[List[int]], optional): A list of publication years to filter by. Defaults to None. + publication_types (Optional[List[str]], optional): A list of publication types to filter by. Defaults to None. + author_ids (Optional[List[str]], optional): A list of author IDs to filter by. Defaults to None. + topic_ids (Optional[List[str]], optional): A list of topic IDs to filter by. Defaults to None. + language_codes (Optional[List[str]], optional): A list of language codes to filter by. Defaults to None. + sort_by (WorkSortBy, optional): The field by which to sort the results. Defaults to WorkSortBy.PUBLICATION_YEAR. + sort_order (SortDirection, optional): The direction to sort in. Defaults to SortDirection.DESCENDING. + + Returns: + WorkPageV2: The page of works matching the criteria. + """ + return await get_works( page=page, size=size, @@ -219,189 +324,18 @@ async def get_institution_works( ) -async def get_work_topics_by_ids(topic_ids: List[str]) -> List[WorkTopic]: - logger.debug(f"Fetching work topics for IDs: {topic_ids}") - if not topic_ids: - return [] - - must = [{"terms": {"id": topic_ids}}] - - response = await elasticsearch.search( - ESIndex.OPENALEX_TOPICS, - source=["id", "display_name", "field", "domain"], - query={"bool": {"must": must}}, - size=len(topic_ids), - ) - - logger.debug(f"Elasticsearch response for work topics {topic_ids}: {response}") - hits_block = response.get("hits", {}) - hits = hits_block.get("hits", []) - topics: List[WorkTopic] = [] - for hit in hits: - source = hit.get("_source", {}) - logger.debug(f"Hit source for work topic {source.get('id', '')}: {source}") - topics.append(WorkTopic.from_dict(source)) # type: ignore - return topics - - -async def get_work_institutions_by_ids(institution_ids: List[str]) -> List[Institution]: - logger.debug(f"Fetching institutions for IDs: {institution_ids}") - if not institution_ids: - return [] - - must = [{"terms": {"id": institution_ids}}] - - response = await elasticsearch.search( - ESIndex.OPENALEX_INSTITUTIONS, - source=[ - "id", - "display_name", - "display_name_alternatives", - "country_code", - "type", - "ror", - ], - query={"bool": {"must": must}}, - size=len(institution_ids), - ) - - logger.debug( - f"Elasticsearch response for institutions {institution_ids}: {response}" - ) - hits_block = response.get("hits", {}) - hits = hits_block.get("hits", []) - institutions: List[Institution] = [] - for hit in hits: - source = hit.get("_source", {}) - logger.debug(f"Hit source for institution {source.get('id', '')}: {source}") - institutions.append(Institution.from_dict(source)) # type: ignore - return institutions - - -async def get_work_authors_by_ids(author_ids: List[str]) -> List[Author]: - logger.debug(f"Fetching authors for IDs: {author_ids}") - if not author_ids: - return [] - - must = [{"terms": {"id": author_ids}}] - - response = await elasticsearch.search( - ESIndex.OPENALEX_AUTHORS, - source=[ - "id", - "display_name", - "orcid", - "last_known_institutions", - "works_count", - ], - query={"bool": {"must": must}}, - size=len(author_ids), - ) - - logger.debug(f"Elasticsearch response for authors {author_ids}: {response}") - hits_block = response.get("hits", {}) - hits = hits_block.get("hits", []) - authors: List[Author] = [] - for hit in hits: - source = hit.get("_source", {}) - logger.debug(f"Hit source for author {source.get('id', '')}: {source}") - authors.append(Author.from_dict(source)) # type: ignore - return authors - - -async def search_topics( - query: str, - size: int = 10, -) -> List[Topic]: - response = await elasticsearch.search( - ESIndex.OPENALEX_TOPICS, - source=[ - "id", - "display_name", - "subfield", - "field", - "domain", - ], - query={"match_bool_prefix": {"display_name": query}}, - size=min(size, 10), - ) - - hits_block = response.get("hits", {}) - elements: List[Topic] = [] - for hit in hits_block.get("hits", []): - topic = Topic.from_dict(hit.get("_source", {})) # type: ignore - if topic is not None: - elements.append(topic) - - return elements - - -async def search_institutions( - query: str, - size: int = 10, -) -> List[Institution]: - response = await elasticsearch.search( - ESIndex.OPENALEX_INSTITUTIONS, - source=[ - "id", - "display_name", - "display_name_alternatives", - "country_code", - "type", - "ror", - ], - query={ - "bool": { - "should": [ - {"match_bool_prefix": {"display_name": query}}, - {"match_bool_prefix": {"display_name_alternatives": query}}, - ], - "minimum_should_match": 1, - } - }, - size=min(size, 10), - ) - - hits_block = response.get("hits", {}) - elements: List[Institution] = [] - for hit in hits_block.get("hits", []): - institution = Institution.from_dict(hit.get("_source", {})) # type: ignore - if institution is not None: - elements.append(institution) - - return elements - - -async def search_authors( - query: str, - size: int = 10, -) -> List[Author]: - response = await elasticsearch.search( - ESIndex.OPENALEX_AUTHORS, - source=[ - "id", - "display_name", - "orcid", - "last_known_institutions", - "works_count", - ], - query={"match_phrase_prefix": {"display_name": query}}, - size=min(size, 10), - ) - - hits_block = response.get("hits", {}) - elements: List[Author] = [] - for hit in hits_block.get("hits", []): - author = Author.from_dict(hit.get("_source", {})) # type: ignore - if author is not None: - elements.append(author) - - return elements - - async def get_work_classifications_by_author_id( access_token_metadata: AccessTokenMetadata, raw_oa_author_id: str ) -> WorkClassificationMergePage: + """Retrieves work classifications for a specific author, filtered by the effective institution ID from the access token metadata. + + Args: + access_token_metadata (AccessTokenMetadata): The access token metadata containing the effective institution ID. + raw_oa_author_id (str): The ID of the author for whom to retrieve work classifications. + + Returns: + WorkClassificationMergePage: The page of work classifications matching the criteria. + """ raw_account_institution_id = access_token_metadata.effective_institution_id work_page = await _get_work_ids_with_publication_year_for_author_id( @@ -467,19 +401,26 @@ async def get_work_classifications_by_author_id( async def get_work( raw_oa_work_id: str, source: Optional[List[str]] = None ) -> Work | None: - response = await elasticsearch.search( - ESIndex.OPENALEX_WORKS_WILDCARD, + """Retrieves a work based on its OpenAlex ID. + + Args: + raw_oa_work_id (str): The ID of the work to retrieve. + source (Optional[List[str]], optional): A list of fields to include in the response. Defaults to None. + + Returns: + Work | None: The retrieved work, or None if not found. + """ + + work_page = await search_works( query={"term": {"id": _prefix_id(raw_oa_work_id)}}, source=source, + page=0, size=1, ) + if work_page.elements: + return work_page.elements[0] - hits = response.get("hits", {}).get("hits", []) - if not hits: - return None - work = Work.from_dict(hits[0].get("_source", {})) # type: ignore - logger.debug(f"Quux {work}") - return work + return None async def search_works( @@ -487,13 +428,27 @@ async def search_works( source: Optional[List[str]] = None, page: int = 0, size: int = 10, -) -> WorkPage: + sort: Optional[List[Dict]] = None, +) -> WorkPageV2: + """Searches for works based on the provided criteria. + + Args: + query (Optional[Dict], optional): The search query. Defaults to None. + source (Optional[List[str]], optional): A list of fields to include in the response. Defaults to None. + page (int, optional): The page number. Defaults to 0. + size (int, optional): The number of results per page. Defaults to 10. + sort (Optional[List[Dict]], optional): The sorting criteria. Defaults to None. + + Returns: + WorkPageV2: The page of works matching the criteria. + """ response = await elasticsearch.search( ESIndex.OPENALEX_WORKS_WILDCARD, source=source, query=query, size=size, offset=page * size, + sort=sort, ) hits_block = response.get("hits", {}) @@ -504,12 +459,21 @@ async def search_works( if work is not None: works.append(work) - return WorkPage(elements=works, total=total, page=page, size=size) + return WorkPageV2(elements=works, total=total, page=page, size=size) async def _get_work_ids_with_publication_year_for_author_id( raw_oa_author_id: str, -) -> WorkPage: +) -> WorkPageV2: + """Retrieves works for a specific author, including only those works that have a publication year and are associated with the specified author ID. + + Args: + raw_oa_author_id (str): The ID of the author for which to retrieve works. + + Returns: + WorkPageV2: The page of works matching the criteria. + """ + return await search_works( query={ "nested": { @@ -526,9 +490,19 @@ async def _get_work_ids_with_publication_year_for_author_id( async def _get_works_by_work_ids_and_institution_id( work_ids: List[str], raw_oa_institution_id: str | None -) -> WorkPage: +) -> WorkPageV2: + """Retrieves works based on a list of work IDs and filters them by the specified institution ID. + + Args: + work_ids (List[str]): The list of work IDs to retrieve. + raw_oa_institution_id (str | None): The ID of the institution by which to filter the works. + + Returns: + WorkPageV2: The page of works matching the criteria. + """ + if not work_ids or not raw_oa_institution_id: - return WorkPage(elements=[], total=0, page=0, size=0) + return WorkPageV2(elements=[], total=0, page=0, size=0) prefixed_work_ids = [_prefix_id(wid) for wid in work_ids] prefixed_institution_id = _prefix_id(raw_oa_institution_id) @@ -566,6 +540,16 @@ async def _get_works_by_work_ids_and_institution_id( def _work_has_authorship_with_institution_id( work: Work, institution_id: str | None ) -> bool: + """Checks if a work has at least one authorship associated with the specified institution ID. + + Args: + work (Work): The work to check for authorships. + institution_id (str | None): The ID of the institution to check for. + + Returns: + bool: True if the work has at least one authorship associated with the specified institution ID, False otherwise. + """ + if not institution_id: return False @@ -583,6 +567,17 @@ async def search_work_classifications( page: int = 0, size: int = 10, ) -> WorkClassificationPage: + """Searches for work classifications based on the provided criteria. + + Args: + query (Optional[Dict], optional): The search query. Defaults to None. + source (Optional[List[str]], optional): The fields to include in the response. Defaults to None. + page (int, optional): The page number. Defaults to 0. + size (int, optional): The number of results per page. Defaults to 10. + + Returns: + WorkClassificationPage: The page of work classifications matching the criteria. + """ response = await elasticsearch.search( ESIndex.WORK_CLASSIFICATIONS, source=source, @@ -609,6 +604,17 @@ async def _get_work_classifications_by_work_ids( page: int = 0, size: int = 10000, ) -> WorkClassificationPage: + """Retrieves work classifications based on a list of work IDs. + + Args: + work_ids (List[str]): The list of work IDs to retrieve classifications for. + page (int, optional): The page number. Defaults to 0. + size (int, optional): The number of results per page. Defaults to 10000. + + Returns: + WorkClassificationPage: The page of work classifications matching the criteria. + """ + work_ids = [_prefix_id(wid) for wid in work_ids] return await search_work_classifications( @@ -636,6 +642,17 @@ async def get_work_classifications_by_work_ids( page: int = 0, size: int = 10000, ) -> WorkClassificationPage: + """Retrieves work classifications for a list of work IDs, filtered by the effective institution ID from the access token metadata. + + Args: + access_token_metadata (AccessTokenMetadata): The access token metadata containing the effective institution ID. + work_ids (List[str]): The list of work IDs to retrieve classifications for. + page (int, optional): The page number. Defaults to 0. + size (int, optional): The number of results per page. Defaults to 10000. + + Returns: + WorkClassificationPage: The page of work classifications matching the criteria. + """ raw_account_institution_id = access_token_metadata.effective_institution_id work_page = await _get_works_by_work_ids_and_institution_id( @@ -654,14 +671,22 @@ async def get_work_classifications_by_work_ids( async def _get_work_classification_by_work_id( raw_oa_work_id: str, source: Optional[List[str]] = None ) -> Optional[WorkClassification]: + """Retrieves a work classification for a specific work ID. + + Args: + raw_oa_work_id (str): The work ID for which to retrieve classification. + source (Optional[List[str]], optional): The fields to include in the response. Defaults to None. + + Returns: + Optional[WorkClassification]: The work classification if found, otherwise None. + """ + response = await elasticsearch.get( ESIndex.WORK_CLASSIFICATIONS, doc_id=raw_oa_work_id, source=source, ) - logger.debug(f"Baz {response}") - _source = response.get("_source") if _source: return WorkClassification.from_dict(_source) @@ -673,6 +698,16 @@ async def get_work_classification_by_work_id( access_token_metadata: AccessTokenMetadata, raw_oa_work_id: str, ) -> Optional[WorkClassification]: + """Retrieves a work classification for a specific work ID, filtered by the effective institution ID from the access token metadata. + + Args: + access_token_metadata (AccessTokenMetadata): The access token metadata containing the effective institution ID. + raw_oa_work_id (str): The work ID for which to retrieve classification. + + Returns: + Optional[WorkClassification]: The work classification if found, otherwise None. + """ + raw_account_institution_id = access_token_metadata.effective_institution_id if not raw_account_institution_id: return None @@ -698,6 +733,14 @@ async def get_work_classification_by_work_id( def _prefix_id(raw_id: str) -> str: + """Adds the OpenAlex prefix to an ID if it does not already have it. + + Args: + raw_id (str): The ID to prefix. + + Returns: + str: The ID with the OpenAlex prefix added if it was missing. + """ if not raw_id.startswith("https://openalex.org/"): return f"https://openalex.org/{raw_id}" return raw_id diff --git a/webapp/src/app/api/.openapi-generator/FILES b/webapp/src/app/api/.openapi-generator/FILES index ec19cea4..d8298f31 100644 --- a/webapp/src/app/api/.openapi-generator/FILES +++ b/webapp/src/app/api/.openapi-generator/FILES @@ -5,12 +5,14 @@ api.base.service.ts api.module.ts api/api.ts api/auth.service.ts +api/authorsV2.service.ts api/bookmarks.service.ts api/companyConnections.service.ts api/dashboard.service.ts api/funding.service.ts api/iNSEService.service.ts api/institutions.service.ts +api/institutionsV2.service.ts api/keywords.service.ts api/news.service.ts api/organization.service.ts @@ -19,6 +21,7 @@ api/personNetwork.service.ts api/persons.service.ts api/projects.service.ts api/topics.service.ts +api/topicsV2.service.ts api/universityRankings.service.ts api/works.service.ts api/worksV2.service.ts @@ -36,6 +39,7 @@ model/authorAffiliationsInner.ts model/authorCountsByYearInner.ts model/authorIds.ts model/authorNetworkNode.ts +model/authorPage.ts model/authorParsedLongestName.ts model/authorPositionCount.ts model/authorSummaryStats.ts @@ -126,9 +130,7 @@ model/hEUWebLink.ts model/hTTPValidationError.ts model/idTokenMetadata.ts model/inseAccountManagementModelOrganizationProfile.ts -model/inseModelsOpenalexWorkPageWorkPage.ts model/inseOrganizationManagementModelOrganizationProfile.ts -model/inseWorksV2ModelWorkPage.ts model/institution.ts model/institutionFunderSummary.ts model/institutionGeo.ts @@ -136,6 +138,7 @@ model/institutionIds.ts model/institutionInformation.ts model/institutionNetworkNode.ts model/institutionPage.ts +model/institutionPageV2.ts model/institutionsListResponse.ts model/ipcClassification.ts model/keywordEntry.ts @@ -202,6 +205,7 @@ model/topicHeatmap.ts model/topicHeatmapField.ts model/topicHeatmapValue.ts model/topicIds.ts +model/topicPageV2.ts model/topicSubfield.ts model/topicYearlyData.ts model/topics.ts @@ -240,6 +244,8 @@ model/workIds.ts model/workKeyword.ts model/workMeshInner.ts model/workNetworkNode.ts +model/workPage.ts +model/workPageV2.ts model/workPrimaryCategory.ts model/workSortBy.ts model/workSustainableDevelopmentGoalsInner.ts diff --git a/webapp/src/app/api/api/api.ts b/webapp/src/app/api/api/api.ts index 3a480162..5fe8de7d 100644 --- a/webapp/src/app/api/api/api.ts +++ b/webapp/src/app/api/api/api.ts @@ -1,5 +1,7 @@ export * from './auth.service'; import { AuthService } from './auth.service'; +export * from './authorsV2.service'; +import { AuthorsV2Service } from './authorsV2.service'; export * from './bookmarks.service'; import { BookmarksService } from './bookmarks.service'; export * from './companyConnections.service'; @@ -12,6 +14,8 @@ export * from './iNSEService.service'; import { INSEServiceService } from './iNSEService.service'; export * from './institutions.service'; import { InstitutionsService } from './institutions.service'; +export * from './institutionsV2.service'; +import { InstitutionsV2Service } from './institutionsV2.service'; export * from './keywords.service'; import { KeywordsService } from './keywords.service'; export * from './news.service'; @@ -28,10 +32,12 @@ export * from './projects.service'; import { ProjectsService } from './projects.service'; export * from './topics.service'; import { TopicsService } from './topics.service'; +export * from './topicsV2.service'; +import { TopicsV2Service } from './topicsV2.service'; export * from './universityRankings.service'; import { UniversityRankingsService } from './universityRankings.service'; export * from './works.service'; import { WorksService } from './works.service'; export * from './worksV2.service'; import { WorksV2Service } from './worksV2.service'; -export const APIS = [AuthService, BookmarksService, CompanyConnectionsService, DashboardService, FundingService, INSEServiceService, InstitutionsService, KeywordsService, NewsService, OrganizationService, PatentsService, PersonNetworkService, PersonsService, ProjectsService, TopicsService, UniversityRankingsService, WorksService, WorksV2Service]; +export const APIS = [AuthService, AuthorsV2Service, BookmarksService, CompanyConnectionsService, DashboardService, FundingService, INSEServiceService, InstitutionsService, InstitutionsV2Service, KeywordsService, NewsService, OrganizationService, PatentsService, PersonNetworkService, PersonsService, ProjectsService, TopicsService, TopicsV2Service, UniversityRankingsService, WorksService, WorksV2Service]; diff --git a/webapp/src/app/api/api/authorsV2.service.ts b/webapp/src/app/api/api/authorsV2.service.ts new file mode 100644 index 00000000..9b1deb23 --- /dev/null +++ b/webapp/src/app/api/api/authorsV2.service.ts @@ -0,0 +1,158 @@ +/** + * 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. + */ +/* 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'; + +// @ts-ignore +import { AuthorPage } from '../model/authorPage'; +// @ts-ignore +import { HTTPValidationError } from '../model/hTTPValidationError'; + +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; +import { BaseService } from '../api.base.service'; + + + +@Injectable({ + providedIn: 'root' +}) +export class AuthorsV2Service extends BaseService { + + constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: Configuration) { + super(basePath, configuration); + } + + /** + * Returns a paginated list of authors for a given search term based on their display name. + * @endpoint get /api/v2/authors/autocomplete/selector + * @param query A search term to filter authors 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 autocompleteAuthorsForSelector(query?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public autocompleteAuthorsForSelector(query?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public autocompleteAuthorsForSelector(query?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public autocompleteAuthorsForSelector(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); + } + + 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/v2/authors/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 + } + ); + } + + /** + * Returns a paginated list of authors for a given list of author IDs. + * @endpoint get /api/v2/authors/authors/id + * @param authorIds A list of author 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 getAuthorsByIds(authorIds?: Array, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getAuthorsByIds(authorIds?: Array, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getAuthorsByIds(authorIds?: Array, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getAuthorsByIds(authorIds?: Array, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarQueryParameters = new HttpParams({encoder: this.encoder}); + if (authorIds) { + authorIds.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'author_ids'); + }) + } + + 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/v2/authors/authors/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 + } + ); + } + +} diff --git a/webapp/src/app/api/api/institutionsV2.service.ts b/webapp/src/app/api/api/institutionsV2.service.ts new file mode 100644 index 00000000..d0e3c555 --- /dev/null +++ b/webapp/src/app/api/api/institutionsV2.service.ts @@ -0,0 +1,158 @@ +/** + * 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. + */ +/* 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'; + +// @ts-ignore +import { HTTPValidationError } from '../model/hTTPValidationError'; +// @ts-ignore +import { InstitutionPageV2 } from '../model/institutionPageV2'; + +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; +import { BaseService } from '../api.base.service'; + + + +@Injectable({ + providedIn: 'root' +}) +export class InstitutionsV2Service extends BaseService { + + constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: Configuration) { + super(basePath, configuration); + } + + /** + * Returns a list of institutions based on a search term for autocomplete functionality. + * @endpoint get /api/v2/institutions/autocomplete/selector + * @param query A search term to filter institutions 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 getInstitutionAutocompleteForSelector(query?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getInstitutionAutocompleteForSelector(query?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getInstitutionAutocompleteForSelector(query?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getInstitutionAutocompleteForSelector(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); + } + + 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/v2/institutions/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 + } + ); + } + + /** + * Returns a list of institutions based on their IDs. + * @endpoint get /api/v2/institutions/ids + * @param institutionIds A list of institution 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 getInstitutionsByIds(institutionIds?: Array, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getInstitutionsByIds(institutionIds?: Array, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getInstitutionsByIds(institutionIds?: Array, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getInstitutionsByIds(institutionIds?: Array, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarQueryParameters = new HttpParams({encoder: this.encoder}); + if (institutionIds) { + institutionIds.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'institution_ids'); + }) + } + + 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/v2/institutions/ids`; + 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/api/topicsV2.service.ts b/webapp/src/app/api/api/topicsV2.service.ts new file mode 100644 index 00000000..f082e67b --- /dev/null +++ b/webapp/src/app/api/api/topicsV2.service.ts @@ -0,0 +1,158 @@ +/** + * 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. + */ +/* 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'; + +// @ts-ignore +import { HTTPValidationError } from '../model/hTTPValidationError'; +// @ts-ignore +import { TopicPageV2 } from '../model/topicPageV2'; + +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; +import { BaseService } from '../api.base.service'; + + + +@Injectable({ + providedIn: 'root' +}) +export class TopicsV2Service extends BaseService { + + 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/v2/topics/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); + } + + 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/v2/topics/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 + } + ); + } + + /** + * Returns a paginated list of topics for a given list of topic IDs. + * @endpoint get /api/v2/topics/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'); + }) + } + + 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/v2/topics/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 + } + ); + } + +} diff --git a/webapp/src/app/api/api/works.service.ts b/webapp/src/app/api/api/works.service.ts index 80b60de6..186ae663 100644 --- a/webapp/src/app/api/api/works.service.ts +++ b/webapp/src/app/api/api/works.service.ts @@ -19,14 +19,14 @@ import { Observable } from 'rxjs'; // @ts-ignore import { HTTPValidationError } from '../model/hTTPValidationError'; // @ts-ignore -import { InseModelsOpenalexWorkPageWorkPage } from '../model/inseModelsOpenalexWorkPageWorkPage'; -// @ts-ignore import { TopicCount } from '../model/topicCount'; // @ts-ignore import { TopicsByTime } from '../model/topicsByTime'; // @ts-ignore import { Work } from '../model/work'; // @ts-ignore +import { WorkPage } from '../model/workPage'; +// @ts-ignore import { WorksListResponse } from '../model/worksListResponse'; // @ts-ignore @@ -115,9 +115,9 @@ export class WorksService extends BaseService { * @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 getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array, type?: Array, language?: Array, institutionId?: Array, topicId?: Array, sort?: 'year' | 'citations', observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array, type?: Array, language?: Array, institutionId?: Array, topicId?: Array, sort?: 'year' | 'citations', observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array, type?: Array, language?: Array, institutionId?: Array, topicId?: Array, sort?: 'year' | 'citations', observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array, type?: Array, language?: Array, institutionId?: Array, topicId?: Array, sort?: 'year' | 'citations', observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array, type?: Array, language?: Array, institutionId?: Array, topicId?: Array, sort?: 'year' | 'citations', observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array, type?: Array, language?: Array, institutionId?: Array, topicId?: Array, sort?: 'year' | 'citations', observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array, type?: Array, language?: Array, institutionId?: Array, topicId?: Array, sort?: 'year' | 'citations', observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (authorId === null || authorId === undefined) { throw new Error('Required parameter authorId was null or undefined when calling getAuthorWorks.'); @@ -188,7 +188,7 @@ export class WorksService extends BaseService { let localVarPath = `/api/works/${this.configuration.encodeParam({name: "authorId", value: authorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; const { basePath, withCredentials } = this.configuration; - return this.httpClient.request('get', `${basePath}${localVarPath}`, + return this.httpClient.request('get', `${basePath}${localVarPath}`, { context: localVarHttpContext, params: localVarQueryParameters, diff --git a/webapp/src/app/api/api/worksV2.service.ts b/webapp/src/app/api/api/worksV2.service.ts index 7f765d70..bfa0187a 100644 --- a/webapp/src/app/api/api/worksV2.service.ts +++ b/webapp/src/app/api/api/worksV2.service.ts @@ -16,28 +16,20 @@ import { HttpClient, HttpHeaders, HttpParams, import { CustomHttpParameterCodec } from '../encoder'; import { Observable } from 'rxjs'; -// @ts-ignore -import { Author } from '../model/author'; // @ts-ignore import { HTTPValidationError } from '../model/hTTPValidationError'; // @ts-ignore -import { InseWorksV2ModelWorkPage } from '../model/inseWorksV2ModelWorkPage'; -// @ts-ignore -import { Institution } from '../model/institution'; -// @ts-ignore import { SortDirection } from '../model/sortDirection'; // @ts-ignore -import { Topic } from '../model/topic'; -// @ts-ignore import { WorkClassification } from '../model/workClassification'; // @ts-ignore import { WorkClassificationMergePage } from '../model/workClassificationMergePage'; // @ts-ignore import { WorkClassificationPage } from '../model/workClassificationPage'; // @ts-ignore -import { WorkSortBy } from '../model/workSortBy'; +import { WorkPageV2 } from '../model/workPageV2'; // @ts-ignore -import { WorkTopic } from '../model/workTopic'; +import { WorkSortBy } from '../model/workSortBy'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; @@ -55,63 +47,6 @@ export class WorksV2Service extends BaseService { super(basePath, configuration); } - /** - * Returns a list of authors based on a search term for autocomplete functionality. - * @endpoint get /api/v2/works/authors/autocomplete - * @param query A search term to filter authors 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 getAuthorAutocomplete(query?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getAuthorAutocomplete(query?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getAuthorAutocomplete(query?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getAuthorAutocomplete(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); - } - - 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/v2/works/authors/autocomplete`; - 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 - } - ); - } - /** * Returns a paginated list of works for a given author based on their ID. * @endpoint get /api/v2/works/author/{raw_oa_author_id} @@ -129,9 +64,9 @@ export class WorksV2Service extends BaseService { * @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 getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, title?: string, publicationYears?: Array, publicationTypes?: Array, institutionIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, title?: string, publicationYears?: Array, publicationTypes?: Array, institutionIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, title?: string, publicationYears?: Array, publicationTypes?: Array, institutionIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, title?: string, publicationYears?: Array, publicationTypes?: Array, institutionIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, title?: string, publicationYears?: Array, publicationTypes?: Array, institutionIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, title?: string, publicationYears?: Array, publicationTypes?: Array, institutionIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, title?: string, publicationYears?: Array, publicationTypes?: Array, institutionIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (rawOaAuthorId === null || rawOaAuthorId === undefined) { throw new Error('Required parameter rawOaAuthorId was null or undefined when calling getAuthorWorkPage.'); @@ -206,125 +141,7 @@ export class WorksV2Service extends BaseService { let localVarPath = `/api/v2/works/author/${this.configuration.encodeParam({name: "rawOaAuthorId", value: rawOaAuthorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; 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 - } - ); - } - - /** - * Returns a list of authors based on their IDs. - * @endpoint get /api/v2/works/authors/search - * @param authorIds A list of author 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 getAuthorsByIds(authorIds?: Array, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getAuthorsByIds(authorIds?: Array, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getAuthorsByIds(authorIds?: Array, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getAuthorsByIds(authorIds?: Array, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { - - let localVarQueryParameters = new HttpParams({encoder: this.encoder}); - if (authorIds) { - authorIds.forEach((element) => { - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - element, 'author_ids'); - }) - } - - 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/v2/works/authors/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 - } - ); - } - - /** - * Returns a list of institutions based on a search term for autocomplete functionality. - * @endpoint get /api/v2/works/institutions/autocomplete - * @param query A search term to filter institutions 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 getInstitutionAutocomplete(query?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getInstitutionAutocomplete(query?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getInstitutionAutocomplete(query?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getInstitutionAutocomplete(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); - } - - 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/v2/works/institutions/autocomplete`; - const { basePath, withCredentials } = this.configuration; - return this.httpClient.request>('get', `${basePath}${localVarPath}`, + return this.httpClient.request('get', `${basePath}${localVarPath}`, { context: localVarHttpContext, params: localVarQueryParameters, @@ -355,9 +172,9 @@ export class WorksV2Service extends BaseService { * @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 getInstitutionWorkPage(rawOaInstitutionId: string, page?: number, title?: string, size?: number, publicationYears?: Array, publicationTypes?: Array, authorIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public getInstitutionWorkPage(rawOaInstitutionId: string, page?: number, title?: string, size?: number, publicationYears?: Array, publicationTypes?: Array, authorIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getInstitutionWorkPage(rawOaInstitutionId: string, page?: number, title?: string, size?: number, publicationYears?: Array, publicationTypes?: Array, authorIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getInstitutionWorkPage(rawOaInstitutionId: string, page?: number, title?: string, size?: number, publicationYears?: Array, publicationTypes?: Array, authorIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getInstitutionWorkPage(rawOaInstitutionId: string, page?: number, title?: string, size?: number, publicationYears?: Array, publicationTypes?: Array, authorIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getInstitutionWorkPage(rawOaInstitutionId: string, page?: number, title?: string, size?: number, publicationYears?: Array, publicationTypes?: Array, authorIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public getInstitutionWorkPage(rawOaInstitutionId: string, page?: number, title?: string, size?: number, publicationYears?: Array, publicationTypes?: Array, authorIds?: Array, topicIds?: Array, languageCodes?: Array, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (rawOaInstitutionId === null || rawOaInstitutionId === undefined) { throw new Error('Required parameter rawOaInstitutionId was null or undefined when calling getInstitutionWorkPage.'); @@ -432,125 +249,7 @@ export class WorksV2Service extends BaseService { let localVarPath = `/api/v2/works/institution/${this.configuration.encodeParam({name: "rawOaInstitutionId", value: rawOaInstitutionId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; 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 - } - ); - } - - /** - * Returns a list of institutions based on their IDs. - * @endpoint get /api/v2/works/institutions/search - * @param institutionIds A list of institution 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 getInstitutionsByIds(institutionIds?: Array, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getInstitutionsByIds(institutionIds?: Array, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getInstitutionsByIds(institutionIds?: Array, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getInstitutionsByIds(institutionIds?: Array, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { - - let localVarQueryParameters = new HttpParams({encoder: this.encoder}); - if (institutionIds) { - institutionIds.forEach((element) => { - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - element, 'institution_ids'); - }) - } - - 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/v2/works/institutions/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 - } - ); - } - - /** - * Returns a list of work topics based on a search term for autocomplete functionality. - * @endpoint get /api/v2/works/topics/autocomplete - * @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 getTopicAutocomplete(query?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getTopicAutocomplete(query?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getTopicAutocomplete(query?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getTopicAutocomplete(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); - } - - 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/v2/works/topics/autocomplete`; - const { basePath, withCredentials } = this.configuration; - return this.httpClient.request>('get', `${basePath}${localVarPath}`, + return this.httpClient.request('get', `${basePath}${localVarPath}`, { context: localVarHttpContext, params: localVarQueryParameters, @@ -753,65 +452,4 @@ export class WorksV2Service extends BaseService { ); } - /** - * Returns a list of work topics based on their IDs. - * @endpoint get /api/v2/works/topics/search - * @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 getWorkTopicsByIds(topicIds?: Array, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getWorkTopicsByIds(topicIds?: Array, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getWorkTopicsByIds(topicIds?: Array, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getWorkTopicsByIds(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'); - }) - } - - 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/v2/works/topics/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/authorPage.ts b/webapp/src/app/api/model/authorPage.ts new file mode 100644 index 00000000..456cadbc --- /dev/null +++ b/webapp/src/app/api/model/authorPage.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 { Author } from './author'; + + +export interface AuthorPage { + /** + * The elements of the page. + */ + elements?: Array; + /** + * The page number. (0-based) + */ + page?: number; + /** + * The page size in elements. + */ + size?: number; + /** + * The total number of elements. + */ + total?: number; +} + diff --git a/webapp/src/app/api/model/institutionPageV2.ts b/webapp/src/app/api/model/institutionPageV2.ts new file mode 100644 index 00000000..8fe4ca78 --- /dev/null +++ b/webapp/src/app/api/model/institutionPageV2.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 { Institution } from './institution'; + + +export interface InstitutionPageV2 { + /** + * The elements of the page. + */ + elements?: Array; + /** + * The page number. (0-based) + */ + page?: number; + /** + * The page size in elements. + */ + size?: number; + /** + * The total number of elements. + */ + total?: number; +} + diff --git a/webapp/src/app/api/model/models.ts b/webapp/src/app/api/model/models.ts index 2c309d51..94963831 100644 --- a/webapp/src/app/api/model/models.ts +++ b/webapp/src/app/api/model/models.ts @@ -8,6 +8,7 @@ export * from './authorAffiliationsInner'; export * from './authorCountsByYearInner'; export * from './authorIds'; export * from './authorNetworkNode'; +export * from './authorPage'; export * from './authorParsedLongestName'; export * from './authorPositionCount'; export * from './authorSummaryStats'; @@ -98,9 +99,7 @@ export * from './hEUWebLink'; export * from './hTTPValidationError'; export * from './idTokenMetadata'; export * from './inseAccountManagementModelOrganizationProfile'; -export * from './inseModelsOpenalexWorkPageWorkPage'; export * from './inseOrganizationManagementModelOrganizationProfile'; -export * from './inseWorksV2ModelWorkPage'; export * from './institution'; export * from './institutionFunderSummary'; export * from './institutionGeo'; @@ -108,6 +107,7 @@ export * from './institutionIds'; export * from './institutionInformation'; export * from './institutionNetworkNode'; export * from './institutionPage'; +export * from './institutionPageV2'; export * from './institutionsListResponse'; export * from './ipcClassification'; export * from './keywordEntry'; @@ -173,6 +173,7 @@ export * from './topicHeatmap'; export * from './topicHeatmapField'; export * from './topicHeatmapValue'; export * from './topicIds'; +export * from './topicPageV2'; export * from './topicSubfield'; export * from './topicYearlyData'; export * from './topics'; @@ -211,6 +212,8 @@ export * from './workIds'; export * from './workKeyword'; export * from './workMeshInner'; export * from './workNetworkNode'; +export * from './workPage'; +export * from './workPageV2'; export * from './workPrimaryCategory'; export * from './workSortBy'; export * from './workSustainableDevelopmentGoalsInner'; diff --git a/webapp/src/app/api/model/topicPageV2.ts b/webapp/src/app/api/model/topicPageV2.ts new file mode 100644 index 00000000..67f1272b --- /dev/null +++ b/webapp/src/app/api/model/topicPageV2.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 { Topic } from './topic'; + + +export interface TopicPageV2 { + /** + * The elements of the page. + */ + elements?: Array; + /** + * The page number. (0-based) + */ + page?: number; + /** + * The page size in elements. + */ + size?: number; + /** + * The total number of elements. + */ + total?: number; +} + diff --git a/webapp/src/app/api/model/inseModelsOpenalexWorkPageWorkPage.ts b/webapp/src/app/api/model/workPage.ts similarity index 92% rename from webapp/src/app/api/model/inseModelsOpenalexWorkPageWorkPage.ts rename to webapp/src/app/api/model/workPage.ts index ee69dead..8490c3ab 100644 --- a/webapp/src/app/api/model/inseModelsOpenalexWorkPageWorkPage.ts +++ b/webapp/src/app/api/model/workPage.ts @@ -10,7 +10,7 @@ import { Work } from './work'; -export interface InseModelsOpenalexWorkPageWorkPage { +export interface WorkPage { /** * Total number of works matching the query */ diff --git a/webapp/src/app/api/model/inseWorksV2ModelWorkPage.ts b/webapp/src/app/api/model/workPageV2.ts similarity index 92% rename from webapp/src/app/api/model/inseWorksV2ModelWorkPage.ts rename to webapp/src/app/api/model/workPageV2.ts index 77c44c5a..a22b6855 100644 --- a/webapp/src/app/api/model/inseWorksV2ModelWorkPage.ts +++ b/webapp/src/app/api/model/workPageV2.ts @@ -10,7 +10,7 @@ import { Work } from './work'; -export interface InseWorksV2ModelWorkPage { +export interface WorkPageV2 { /** * The elements of the page. */ diff --git a/webapp/src/app/app.routes.ts b/webapp/src/app/app.routes.ts index d482fd84..63377968 100644 --- a/webapp/src/app/app.routes.ts +++ b/webapp/src/app/app.routes.ts @@ -385,8 +385,8 @@ export const routes: Routes = [ ), runGuardsAndResolvers: 'always', resolve: { - selectedTopics: selectedTopicsResolver, - selectedInstitutions: selectedInstitutionsResolver, + selectedTopicsPage: selectedTopicsResolver, + selectedInstitutionsPage: selectedInstitutionsResolver, authorWorkPage: workPageResolver, authorWorkClassificationMergePage: authorWorkClassificationPageResolver, }, @@ -511,8 +511,8 @@ export const routes: Routes = [ (mod) => mod.InstitutionPublicationsComponent, ), resolve: { - selectedAuthors: selectedAuthorsResolver, - selectedTopics: selectedTopicsResolver, + selectedAuthorsPage: selectedAuthorsResolver, + selectedTopicsPage: selectedTopicsResolver, institutionWorkPage: workPageResolver, }, data: { diff --git a/webapp/src/app/modules/institution-publications/institution-publications.component.html b/webapp/src/app/modules/institution-publications/institution-publications.component.html index 73037c00..a3c99e51 100644 --- a/webapp/src/app/modules/institution-publications/institution-publications.component.html +++ b/webapp/src/app/modules/institution-publications/institution-publications.component.html @@ -1,7 +1,7 @@
(); - selectedAuthors = input.required>(); - selectedTopics = input.required>(); + institutionWorkPage = input.required(); + selectedAuthorsPage = input.required(); + selectedTopicsPage = input.required(); total = computed(() => this.institutionWorkPage().total ?? 0); } diff --git a/webapp/src/app/modules/person-publications/person-publications.component.html b/webapp/src/app/modules/person-publications/person-publications.component.html index 56b40d05..f601cc07 100644 --- a/webapp/src/app/modules/person-publications/person-publications.component.html +++ b/webapp/src/app/modules/person-publications/person-publications.component.html @@ -58,8 +58,8 @@
(); + authorWorkPage = input.required(); total = computed(() => this.authorWorkPage().total ?? 0); elements = computed(() => this.authorWorkPage().elements ?? []); - selectedInstitutions = input.required>(); - selectedTopics = input.required>(); + selectedInstitutionsPage = input.required(); + selectedTopicsPage = input.required(); authorWorkClassificationMergePage = input.required(); diff --git a/webapp/src/app/resolvers/selected-authors.resolver.ts b/webapp/src/app/resolvers/selected-authors.resolver.ts index 0ca91d49..975c217c 100644 --- a/webapp/src/app/resolvers/selected-authors.resolver.ts +++ b/webapp/src/app/resolvers/selected-authors.resolver.ts @@ -1,8 +1,8 @@ import { ResolveFn } from '@angular/router'; -import { Author, WorksV2Service } from '../api'; +import { Author, AuthorPage, AuthorsV2Service, WorksV2Service } from '../api'; import { inject } from '@angular/core'; -export const selectedAuthorsResolver: ResolveFn> = ( +export const selectedAuthorsResolver: ResolveFn = ( route, state, ) => { @@ -11,10 +11,10 @@ export const selectedAuthorsResolver: ResolveFn> = ( const authorIds = route.queryParamMap.getAll(authorIdQueryParamKey); if (authorIds.length === 0) { - return []; + return { elements: [] }; } - return inject(WorksV2Service).getAuthorsByIds( + return inject(AuthorsV2Service).getAuthorsByIds( authorIds.map((id) => id.trim()).filter((id) => id.length > 0), ); }; diff --git a/webapp/src/app/resolvers/selected-institutions.resolver.ts b/webapp/src/app/resolvers/selected-institutions.resolver.ts index 1caa739f..d6217869 100644 --- a/webapp/src/app/resolvers/selected-institutions.resolver.ts +++ b/webapp/src/app/resolvers/selected-institutions.resolver.ts @@ -1,8 +1,8 @@ import { inject } from '@angular/core'; import { ResolveFn } from '@angular/router'; -import { Institution, WorksV2Service } from '../api'; +import { InstitutionPageV2, InstitutionsV2Service } from '../api'; -export const selectedInstitutionsResolver: ResolveFn> = ( +export const selectedInstitutionsResolver: ResolveFn = ( route, state, ) => { @@ -10,11 +10,8 @@ export const selectedInstitutionsResolver: ResolveFn> = ( (route.data['institutionIdQueryParamKey'] as string) || 'institutionId'; const institutionIds = route.queryParamMap.getAll(institutionIdQueryParamKey); - if (institutionIds.length === 0) { - return []; - } - return inject(WorksV2Service).getInstitutionsByIds( + return inject(InstitutionsV2Service).getInstitutionsByIds( institutionIds.map((id) => id.trim()).filter((id) => id.length > 0), ); }; diff --git a/webapp/src/app/resolvers/selected-topics.resolver.ts b/webapp/src/app/resolvers/selected-topics.resolver.ts index 05bcc4aa..aebb5b30 100644 --- a/webapp/src/app/resolvers/selected-topics.resolver.ts +++ b/webapp/src/app/resolvers/selected-topics.resolver.ts @@ -1,20 +1,14 @@ import { inject } from '@angular/core'; import { ResolveFn } from '@angular/router'; -import { WorksV2Service, WorkTopic } from '../api'; +import { TopicPageV2, TopicsV2Service } from '../api'; -export const selectedTopicsResolver: ResolveFn> = ( - route, - state, -) => { +export const selectedTopicsResolver: ResolveFn = (route, state) => { const topicIdQueryParamKey = (route.data['topicIdQueryParamKey'] as string) || 'topicId'; const topicIds = route.queryParamMap.getAll(topicIdQueryParamKey); - if (topicIds.length === 0) { - return []; - } - return inject(WorksV2Service).getWorkTopicsByIds( + return inject(TopicsV2Service).getTopicsByIds( topicIds.map((id) => id.trim()).filter((id) => id.length > 0), ); }; diff --git a/webapp/src/app/resolvers/work-page.resolver.ts b/webapp/src/app/resolvers/work-page.resolver.ts index 8776efa0..1d186e9e 100644 --- a/webapp/src/app/resolvers/work-page.resolver.ts +++ b/webapp/src/app/resolvers/work-page.resolver.ts @@ -4,7 +4,7 @@ import { RouterStateSnapshot, } from '@angular/router'; import { - InseWorksV2ModelWorkPage, + WorkPageV2, SortDirection, WorkSortBy, WorksV2Service, @@ -31,7 +31,7 @@ export const workQueryParamKeys = { sortDirection: 'sort_direction', } as const; -export const workPageResolver: ResolveFn = ( +export const workPageResolver: ResolveFn = ( route: ActivatedRouteSnapshot, state: RouterStateSnapshot, ) => { diff --git a/webapp/src/app/shared/ui/publication-filters/publication-filters.component.ts b/webapp/src/app/shared/ui/publication-filters/publication-filters.component.ts index f8c8d4c8..7cecd142 100644 --- a/webapp/src/app/shared/ui/publication-filters/publication-filters.component.ts +++ b/webapp/src/app/shared/ui/publication-filters/publication-filters.component.ts @@ -1,8 +1,15 @@ import { Component, computed, input } from '@angular/core'; import { SearchableTopicSelectComponent } from '../searchable-topic-select/searchable-topic-select.component'; import { SearchableYearSelectComponent } from '../searchable-year-select/searchable-year-select.component'; -import { Author, Institution, Topic } from '../../../api'; -import { ActivatedRoute, Router } from '@angular/router'; +import { + Author, + AuthorPage, + Institution, + InstitutionPageV2, + Topic, + TopicPageV2, +} from '../../../api'; +import { Router } from '@angular/router'; import { workQueryParamKeys } from '../../../resolvers/work-page.resolver'; import { toSignal } from '@angular/core/rxjs-interop'; import { SearchableInstitutionSelectComponent } from '../searchable-institution-select/searchable-institution-select.component'; @@ -47,9 +54,18 @@ import { MatIconModule } from '@angular/material/icon'; export class PublicationFilterComponent { constructor(private readonly router: Router) {} - selectedAuthors = input([]); - selectedTopics = input([]); - selectedInstitutions = input([]); + selectedAuthorsPage = input(); + selectedAuthors = computed( + () => this.selectedAuthorsPage()?.elements || [], + ); + selectedTopicsPage = input(); + selectedTopics = computed( + () => this.selectedTopicsPage()?.elements || [], + ); + selectedInstitutionsPage = input(); + selectedInstitutions = computed( + () => this.selectedInstitutionsPage()?.elements || [], + ); showTitleFilter = input(true); showYearFilter = input(true); @@ -96,6 +112,17 @@ export class PublicationFilterComponent { return author ? author.display_name : value; }, }, + { + id: 'institutions', + queryParamKey: workQueryParamKeys.institutionId, + icon: 'business', + valueFormatter: (value: string) => { + const institution = this.selectedInstitutions().find( + (i) => i.id === value, + ); + return institution ? institution.display_name : value; + }, + }, { id: 'topics', queryParamKey: workQueryParamKeys.topicId, diff --git a/webapp/src/app/shared/ui/publication-table/publication-table.component.ts b/webapp/src/app/shared/ui/publication-table/publication-table.component.ts index 8c066a1b..e0e6984e 100644 --- a/webapp/src/app/shared/ui/publication-table/publication-table.component.ts +++ b/webapp/src/app/shared/ui/publication-table/publication-table.component.ts @@ -15,7 +15,7 @@ import { } from '../data-table/data-table.component'; import { DehydratedAuthor, - InseWorksV2ModelWorkPage, + WorkPageV2, Institution, Work, WorkClassification, @@ -53,7 +53,7 @@ import { WorkPrimaryCategoryPipe } from '../../pipes/work-primary-category.pipe' styleUrl: './publication-table.component.scss', }) export class PublicationTableComponent implements OnInit { - page = input.required(); + page = input.required(); authorFilterEnabled = input(false); institutionFilterEnabled = input(false); diff --git a/webapp/src/app/shared/ui/searchable-author-select/searchable-author-select.component.ts b/webapp/src/app/shared/ui/searchable-author-select/searchable-author-select.component.ts index f19cda84..715c9702 100644 --- a/webapp/src/app/shared/ui/searchable-author-select/searchable-author-select.component.ts +++ b/webapp/src/app/shared/ui/searchable-author-select/searchable-author-select.component.ts @@ -1,5 +1,5 @@ import { Component, inject, input, output } from '@angular/core'; -import { Author, WorksV2Service } from '../../../api'; +import { Author, AuthorPage, AuthorsV2Service } from '../../../api'; import { Observable } from 'rxjs'; import { SearchableSelectComponent } from '../searchable-select/searchable-select.component'; @@ -10,15 +10,15 @@ import { SearchableSelectComponent } from '../searchable-select/searchable-selec styleUrl: './searchable-author-select.component.scss', }) export class SearchableAuthorSelectComponent { - private readonly worksV2Service = inject(WorksV2Service); + private readonly authorsV2Service = inject(AuthorsV2Service); label = input('Authoren'); selectedAuthors = input.required(); handleAuthorSelectChange = output(); - fetchAuthors = (searchTerm: string): Observable => { - return this.worksV2Service.getAuthorAutocomplete(searchTerm); + fetchAuthors = (searchTerm: string): Observable => { + return this.authorsV2Service.autocompleteAuthorsForSelector(searchTerm); }; getAuthorLabel = (author: Author): string => { diff --git a/webapp/src/app/shared/ui/searchable-institution-select/searchable-institution-select.component.ts b/webapp/src/app/shared/ui/searchable-institution-select/searchable-institution-select.component.ts index f67ec1b0..4d3c204b 100644 --- a/webapp/src/app/shared/ui/searchable-institution-select/searchable-institution-select.component.ts +++ b/webapp/src/app/shared/ui/searchable-institution-select/searchable-institution-select.component.ts @@ -1,5 +1,5 @@ import { Component, inject, input, output } from '@angular/core'; -import { Institution, WorksV2Service } from '../../../api'; +import { Institution, InstitutionsV2Service, TopicPageV2 } from '../../../api'; import { Observable } from 'rxjs'; import { SearchableSelectComponent } from '../searchable-select/searchable-select.component'; @@ -10,15 +10,17 @@ import { SearchableSelectComponent } from '../searchable-select/searchable-selec styleUrl: './searchable-institution-select.component.scss', }) export class SearchableInstitutionSelectComponent { - private readonly worksV2Service = inject(WorksV2Service); + private readonly institutionsV2Service = inject(InstitutionsV2Service); label = input('Institutionen'); selectedInstitutions = input.required(); handleInstitutionSelectChange = output(); - fetchInstitutions = (searchTerm: string): Observable => { - return this.worksV2Service.getInstitutionAutocomplete(searchTerm); + fetchInstitutions = (searchTerm: string): Observable => { + return this.institutionsV2Service.getInstitutionAutocompleteForSelector( + searchTerm, + ); }; getInstitutionLabel = (institution: Institution): string => { diff --git a/webapp/src/app/shared/ui/searchable-language-select/searchable-language-select.component.ts b/webapp/src/app/shared/ui/searchable-language-select/searchable-language-select.component.ts index 9033d162..b670faf9 100644 --- a/webapp/src/app/shared/ui/searchable-language-select/searchable-language-select.component.ts +++ b/webapp/src/app/shared/ui/searchable-language-select/searchable-language-select.component.ts @@ -24,6 +24,12 @@ export const findLanguageById = (id: string): Language | undefined => { return languages.find((language) => language.code === id); }; +type LanguagePage = { + elements?: Language[]; + page?: number; + size?: number; + total?: number; +}; @Component({ selector: 'app-searchable-language-select', imports: [SearchableSelectComponent], @@ -36,13 +42,13 @@ export class SearchableLanguageSelectComponent { handleLanguageSelectChange = output(); - fetchLanguages = (searchTerm: string): Observable => { - return new Observable((observer) => { - observer.next( - languages.filter((language) => + fetchLanguages = (searchTerm: string): Observable => { + return new Observable((observer) => { + observer.next({ + elements: languages.filter((language) => language.name.toLowerCase().includes(searchTerm.toLowerCase()), ), - ); + }); observer.complete(); }); }; diff --git a/webapp/src/app/shared/ui/searchable-select/searchable-select.component.html b/webapp/src/app/shared/ui/searchable-select/searchable-select.component.html index 4a359964..738488b9 100644 --- a/webapp/src/app/shared/ui/searchable-select/searchable-select.component.html +++ b/webapp/src/app/shared/ui/searchable-select/searchable-select.component.html @@ -52,7 +52,7 @@ } - @for (element of fetchedElements(); track getSelectValue()(element)) { + @for (element of fetchedElements().elements; track getSelectValue()(element)) { {{ getSelectLabel()(element) }} @if (getSelectDescription()) { diff --git a/webapp/src/app/shared/ui/searchable-select/searchable-select.component.ts b/webapp/src/app/shared/ui/searchable-select/searchable-select.component.ts index b369887d..28b6b388 100644 --- a/webapp/src/app/shared/ui/searchable-select/searchable-select.component.ts +++ b/webapp/src/app/shared/ui/searchable-select/searchable-select.component.ts @@ -24,6 +24,13 @@ import { } from 'rxjs'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +type Page = { + elements?: T[]; + page?: number; + size?: number; + total?: number; +}; + @Component({ selector: 'app-searchable-select', imports: [ @@ -43,7 +50,7 @@ export class SearchableSelectComponent { _elements = computed(() => { const predefined = this.selectedElements(); const fetched = this.fetchedElements(); - return [...predefined, ...fetched]; + return [...predefined, ...fetched.elements!]; }); isLoading = signal(false); @@ -51,8 +58,8 @@ export class SearchableSelectComponent { label = input.required(); selectedLabel = input('Ausgewählt'); fetchedLabel = input('Verfügbar'); - fetchElements = input<(searchTerm: string) => Observable>(); - fetchedElements = signal([]); + fetchElements = input<(searchTerm: string) => Observable>>(); + fetchedElements = signal>({ elements: [] }); selectedElements = input([]); getSelectLabel = input.required<(element: T) => string>(); getSelectValue = input.required<(element: T) => string>(); @@ -72,9 +79,9 @@ export class SearchableSelectComponent { switchMap((term) => { const fetchFn = this.fetchElements(); if (!fetchFn) { - return of([] as T[]); + return of({ elements: [] } as Page); } - return fetchFn(term).pipe(catchError(() => of([] as T[]))); + return fetchFn(term).pipe(catchError(() => of({ elements: [] } as Page))); }), tap(() => this.isLoading.set(false)), takeUntilDestroyed(this.destroyRef), @@ -89,6 +96,6 @@ export class SearchableSelectComponent { _clearSearchValue(): void { this.searchValue = ''; - this.fetchedElements.set([]); + this.fetchedElements.set({ elements: [] }); } } diff --git a/webapp/src/app/shared/ui/searchable-topic-select/searchable-topic-select.component.ts b/webapp/src/app/shared/ui/searchable-topic-select/searchable-topic-select.component.ts index c6aecfae..36dcb0ac 100644 --- a/webapp/src/app/shared/ui/searchable-topic-select/searchable-topic-select.component.ts +++ b/webapp/src/app/shared/ui/searchable-topic-select/searchable-topic-select.component.ts @@ -1,6 +1,6 @@ import { Component, inject, input, output } from '@angular/core'; import { SearchableSelectComponent } from '../searchable-select/searchable-select.component'; -import { Topic, WorksV2Service } from '../../../api'; +import { Topic, TopicPageV2, TopicsV2Service } from '../../../api'; import { Observable } from 'rxjs'; @Component({ @@ -10,15 +10,15 @@ import { Observable } from 'rxjs'; styleUrl: './searchable-topic-select.component.scss', }) export class SearchableTopicSelectComponent { - private readonly worksV2Service = inject(WorksV2Service); + private readonly topicsV2Service = inject(TopicsV2Service); label = input('Themen'); selectedTopics = input.required(); handleTopicSelectChange = output(); - fetchTopics = (searchTerm: string): Observable => { - return this.worksV2Service.getTopicAutocomplete(searchTerm); + fetchTopics = (searchTerm: string): Observable => { + return this.topicsV2Service.autocompleteTopicsForSelector(searchTerm); }; getTopicLabel = (topic: Topic): string => { diff --git a/webapp/src/app/shared/ui/searchable-work-type-select/searchable-work-type-select.component.ts b/webapp/src/app/shared/ui/searchable-work-type-select/searchable-work-type-select.component.ts index 6b255bd0..fdf0c38c 100644 --- a/webapp/src/app/shared/ui/searchable-work-type-select/searchable-work-type-select.component.ts +++ b/webapp/src/app/shared/ui/searchable-work-type-select/searchable-work-type-select.component.ts @@ -33,6 +33,13 @@ export const findWorkTypeById = (id: string): WorkType | undefined => { return workTypes.find((workType) => workType.id === id); }; +type WorkTypePage = { + elements?: WorkType[]; + page?: number; + size?: number; + total?: number; +}; + @Component({ selector: 'app-searchable-work-type-select', imports: [SearchableSelectComponent], @@ -45,13 +52,13 @@ export class SearchableWorkTypeSelectComponent { handleWorkTypeSelectChange = output(); - fetchWorkTypes = (searchTerm: string): Observable => { - return new Observable((observer) => { - observer.next( - workTypes.filter((workType) => + fetchWorkTypes = (searchTerm: string): Observable => { + return new Observable((observer) => { + observer.next({ + elements: workTypes.filter((workType) => workType.name.toLowerCase().includes(searchTerm.toLowerCase()), ), - ); + }); observer.complete(); }); }; diff --git a/webapp/src/app/shared/ui/searchable-year-select/searchable-year-select.component.ts b/webapp/src/app/shared/ui/searchable-year-select/searchable-year-select.component.ts index 3382af33..d214dd31 100644 --- a/webapp/src/app/shared/ui/searchable-year-select/searchable-year-select.component.ts +++ b/webapp/src/app/shared/ui/searchable-year-select/searchable-year-select.component.ts @@ -2,6 +2,13 @@ import { Component, input, output } from '@angular/core'; import { SearchableSelectComponent } from '../searchable-select/searchable-select.component'; import { Observable } from 'rxjs'; +type YearPage = { + elements?: number[]; + page?: number; + size?: number; + total?: number; +}; + @Component({ selector: 'app-searchable-year-select', imports: [SearchableSelectComponent], @@ -16,16 +23,16 @@ export class SearchableYearSelectComponent { handleYearSelectChange = output(); - fetchYears = (searchTerm: string): Observable => { + fetchYears = (searchTerm: string): Observable => { const years: number[] = []; for (let year = this.endYear(); year >= this.startYear(); year--) { years.push(year); } - return new Observable((observer) => { - observer.next( - years.filter((year) => year.toString().includes(searchTerm)), - ); + return new Observable((observer) => { + observer.next({ + elements: years.filter((year) => year.toString().includes(searchTerm)), + }); observer.complete(); }); };