From 84f3314b60305f827f80dae21c44d33accc275e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mats=20Paul=20Ton=C4=8Dik?= Date: Sun, 21 Jun 2026 14:07:39 +0200 Subject: [PATCH] Fixed institution cordis eu funding amount to show the amount actually received not total for project --- .../main/inse/integrations/elasticsearch.py | 51 +++- service/src/main/inse/model.py | 27 ++- service/src/main/inse/projects/model.py | 64 +++++ .../inse/projects/projects_search_client.py | 222 +++++++++++++++++- service/src/main/inse/projects/router.py | 8 +- service/src/main/inse/projects/service.py | 72 +++--- ude_person.http | 50 +++- webapp/src/app/api/.openapi-generator/FILES | 2 + webapp/src/app/api/api/projects.service.ts | 10 +- .../api/model/euOrganizationProjectSummary.ts | 27 +++ .../model/euOrganizationProjectSummaryPage.ts | 31 +++ webapp/src/app/api/model/models.ts | 2 + .../institution-projects.component.html | 16 +- .../institution-projects.component.ts | 41 +++- .../cordis-eu-project-page.resolver.ts | 4 +- 15 files changed, 543 insertions(+), 84 deletions(-) create mode 100644 webapp/src/app/api/model/euOrganizationProjectSummary.ts create mode 100644 webapp/src/app/api/model/euOrganizationProjectSummaryPage.ts diff --git a/service/src/main/inse/integrations/elasticsearch.py b/service/src/main/inse/integrations/elasticsearch.py index 449b748f..bd32501a 100644 --- a/service/src/main/inse/integrations/elasticsearch.py +++ b/service/src/main/inse/integrations/elasticsearch.py @@ -1,16 +1,18 @@ import logging from typing import Any, Dict, List, Optional, Tuple import httpx + +from inse.model import ESCluster, ESIndex from .. import config logger = logging.getLogger(__name__) -def _cluster_credentials(cluster: str) -> Tuple[str, str]: +def _cluster_credentials(cluster: ESCluster) -> Tuple[str, str]: """Retrieves the Elasticsearch URL and API key for the specified cluster from the configuration. Args: - cluster (str): The cluster for which to retrieve credentials. Allowed values are "nes" and "inse". + cluster (ElasticsearchCluster): The cluster for which to retrieve credentials. Allowed values are "nes" and "inse". Raises: ValueError: If the cluster is unknown or the credentials are not set in the configuration. @@ -19,7 +21,7 @@ def _cluster_credentials(cluster: str) -> Tuple[str, str]: Tuple[str, str]: The Elasticsearch URL and API key for the specified cluster. """ - if cluster == "nes": + if cluster == ESCluster.NES: if ( not config.settings.elasticsearch_url or not config.settings.elasticsearch_api_key @@ -28,7 +30,7 @@ def _cluster_credentials(cluster: str) -> Tuple[str, str]: "Elasticsearch URL and API key must be set in the configuration for cluster 'nes'" ) return config.settings.elasticsearch_url, config.settings.elasticsearch_api_key - elif cluster == "inse": + elif cluster == ESCluster.INSE: if ( not config.settings.elasticsearch_inse_url or not config.settings.elasticsearch_inse_api_key @@ -45,8 +47,37 @@ def _cluster_credentials(cluster: str) -> Tuple[str, str]: raise ValueError(f"Unknown cluster: {cluster!r} (allowed: 'nes', 'inse')") +def _index_to_cluster(index: ESIndex) -> ESCluster: + """Determines the Elasticsearch cluster to use based on the specified index. + + Args: + index (ESIndex): The Elasticsearch index for which to determine the cluster. Allowed values are defined in the ESIndex enum. + + Raises: + ValueError: If the index is unknown. + + Returns: + ESCluster: The Elasticsearch cluster to use for the specified index. + """ + + if index in { + ESIndex.OPENALEX_WORKS, + ESIndex.OPENALEX_AUTHORS, + ESIndex.OPENALEX_INSTITUTIONS, + ESIndex.OPENALEX_PUBLICATIONS, + }: + return ESCluster.NES + elif index in { + ESIndex.CORDIS_EU_PROJECTS_WILDCARD, + ESIndex.CORDIS_EU_PUBLICATIONS_WILDCARD, + }: + return ESCluster.INSE + else: + raise ValueError(f"Unknown index: {index!r}") + + def search( - index: str, + index: ESIndex, query_field: Optional[str] = None, query_value: Optional[str] = None, query: Optional[Dict] = None, @@ -56,12 +87,12 @@ def search( sort: Optional[List] = None, body: Optional[Dict] = None, track_total_hits=False, - cluster: str = "nes", + cluster: ESCluster = ESCluster.NES, ) -> Dict[str, Any]: """Searches the specified Elasticsearch index using either a simple query string or a full query body. Args: - index (str): The name of the Elasticsearch index to search. + index (ElasticsearchIndex): The Elasticsearch index to search. query_field (Optional[str], optional): The field to search in. Defaults to None. query_value (Optional[str], optional): The value to search for. Defaults to None. query (Optional[Dict], optional): The full query body. Defaults to None. @@ -71,7 +102,7 @@ def search( sort (Optional[List], optional): The fields to sort by. Defaults to None. body (Optional[Dict], optional): The full query body. Defaults to None. track_total_hits (bool, optional): Whether to track the total number of hits. Defaults to False. - cluster (str, optional): The Elasticsearch cluster to search. Defaults to "nes". + cluster (ElasticsearchCluster, optional): The Elasticsearch cluster to search. Defaults to ElasticsearchCluster.NES. Returns: Dict[str, Any]: The search results. @@ -116,10 +147,10 @@ def search( def get( - index: str, + index: ESIndex, doc_id: str, source: Optional[list] = None, - cluster: str = "nes", + cluster: ESCluster = ESCluster.NES, ) -> dict[str, Any]: elasticsearch_url, api_key = _cluster_credentials(cluster) diff --git a/service/src/main/inse/model.py b/service/src/main/inse/model.py index 669f049f..55d556eb 100644 --- a/service/src/main/inse/model.py +++ b/service/src/main/inse/model.py @@ -1,9 +1,12 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ - This module defines the model classes returned from - our api using pydantic. +This module defines the model classes returned from +our api using pydantic. """ + +from enum import StrEnum + from pydantic import BaseModel from pydantic import ConfigDict from pydantic import Field @@ -13,28 +16,46 @@ from typing import Generic from typing import Optional -T = TypeVar('T', bound=BaseModel) +T = TypeVar("T", bound=BaseModel) + class Entity(BaseModel): id: int = Field(description="The id of the entity.") + class Item(Entity): model_config = ConfigDict(from_attributes=True) name: str = Field(description="The name of the item.") description: str = Field(description="The description of the item.") + class ItemCreate(BaseModel): name: str = Field(description="The name of the item.") description: str = Field(description="The description of the item.") + class Page(BaseModel, Generic[T]): elements: List[T] = Field(default=[], description="The elements of the page.") offset: int = Field(default=0, description="The page offset in elements.") total: int = Field(default=0, description="The total number of elements.") size: int = Field(default=20, description="The page size in elements.") + class ItemPage(Page[Item]): pass +class ESCluster(StrEnum): + NES = "nes" + INSE = "inse" + +class ESIndex(StrEnum): + OPENALEX_WORKS = "openalex-works" + OPENALEX_AUTHORS = "openalex-authors" + OPENALEX_INSTITUTIONS = "openalex-institutions" + OPENALEX_PUBLICATIONS = "openalex-publications" + + CORDIS_EU_ORGANIZATIONS_WILDCARD = "cordis_eu_*_organizations" + CORDIS_EU_PROJECTS_WILDCARD = "cordis_eu_*_projects" + CORDIS_EU_PUBLICATIONS_WILDCARD = "cordis_eu_*_publications" diff --git a/service/src/main/inse/projects/model.py b/service/src/main/inse/projects/model.py index dd75726f..ed58fe8e 100644 --- a/service/src/main/inse/projects/model.py +++ b/service/src/main/inse/projects/model.py @@ -22,6 +22,15 @@ class ProjectsSortBy(StrEnum): FUNDING_END = "funding_end" FUNDING_AMOUNT = "funding_amount" + def to_cordis_eu_project_sort_field(self) -> str: + mapping = { + self.TITLE: "title.keyword", + self.FUNDING_START: "startDate", + self.FUNDING_END: "endDate", + self.FUNDING_AMOUNT: "ecMaxContribution", + } + return mapping.get(self, "title.keyword") + class SortDirection(StrEnum): ASC = "asc" @@ -225,3 +234,58 @@ class FundingProjectPage(Page): elements: List[FundingProject] = Field( default_factory=list, description="The funding projects on this page." ) + + +class EuOrganizationShort(BaseModel): + project_id: str = Field(description="The unique identifier of the project.") + organization_id: str = Field( + description="The unique identifier of the organization." + ) + ec_contribution: Optional[float] = Field( + default=None, + description="The EC contribution amount for the organization in the project.", + ) + + +class EuProjectShort(BaseModel): + id: str = Field(description="The unique identifier of the EU project.") + title: Optional[str] = Field( + default=None, description="The title of the EU project." + ) + start_date: Optional[date] = Field( + default=None, description="The funding start date of the EU project." + ) + end_date: Optional[date] = Field( + default=None, description="The funding end date of the EU project." + ) + acronym: Optional[str] = Field( + default=None, description="The acronym of the EU project." + ) + + +class EuOrganizationProjectSummary(BaseModel): + organization_id: str = Field( + description="The unique identifier of the organization." + ) + project_id: str = Field(description="The unique identifier of the project.") + title: Optional[str] = Field(default=None, description="The title of the project.") + start_date: Optional[date] = Field( + default=None, description="The funding start date of the project." + ) + end_date: Optional[date] = Field( + default=None, description="The funding end date of the project." + ) + acronym: Optional[str] = Field( + default=None, description="The acronym of the project." + ) + ec_contribution: Optional[float] = Field( + default=None, + description="The EC contribution amount for the organization in the project.", + ) + + +class EuOrganizationProjectSummaryPage(Page): + elements: List[EuOrganizationProjectSummary] = Field( + default_factory=list, + description="The organization project summaries on this page.", + ) diff --git a/service/src/main/inse/projects/projects_search_client.py b/service/src/main/inse/projects/projects_search_client.py index 3347fc3c..d11dd659 100644 --- a/service/src/main/inse/projects/projects_search_client.py +++ b/service/src/main/inse/projects/projects_search_client.py @@ -1,6 +1,6 @@ import json import logging -from typing import Any, Dict, List, Optional, Set +from typing import Any, Dict, List, Optional, Set, Tuple import httpx @@ -11,7 +11,10 @@ from inse.projects.model import ( CordisEuProjectPage, DfgProjectPage, DfgProjectSummary, - EuProjectPage, + EuOrganizationProjectSummary, + EuOrganizationProjectSummaryPage, + EuOrganizationShort, + EuProjectShort, FundingProject, FundingProjectPage, ProjectType, @@ -19,11 +22,12 @@ from inse.projects.model import ( ProjectsSortBy, SortDirection, ) -from inse.models.eu_project import EuProject + from inse.models.dfg_project_details import DfgProjectDetails from inse.models.bund_project_details import BundProjectDetails from inse.models.cordis_eu_project import CordisEuProject from inse.integrations import elasticsearch +from inse.model import ESCluster, ESIndex settings = get_settings() @@ -494,7 +498,9 @@ class EuProjectsSearchClient(ProjectsSearchClient): query = {"bool": {"filter": [{"terms": {"qaProcessedDoi": raw_dois}}]}} response = elasticsearch.search( - query=query, index="cordis_eu_*_publications", cluster="inse" + query=query, + index=ESIndex.CORDIS_EU_PUBLICATIONS_WILDCARD, + cluster=ESCluster.INSE, ) logger.debug( @@ -528,7 +534,9 @@ class EuProjectsSearchClient(ProjectsSearchClient): query = {"bool": {"filter": [{"terms": {"id": project_ids}}]}} response = elasticsearch.search( - query=query, index="cordis_eu_*_projects", cluster="inse" + query=query, + index=ESIndex.CORDIS_EU_PROJECTS_WILDCARD, + cluster=ESCluster.INSE, ) hits_block = response.get("hits", {}) @@ -903,3 +911,207 @@ def _hit_to_funding_project(hit: Dict[str, Any]) -> FundingProject: raise ValueError( "The provided hit does not belong to a recognized project index." ) + + +def get_organization_project_contributions_foo( + organization_names: List[str], + projects_filtering_properties: ProjectsFilteringProperties, +) -> EuOrganizationProjectSummaryPage: + # Pagination depending on sorting criteria + # For FUNDING_AMOUNT before on the organization project contributions + # For the rest after the contributions are known on the real projects + + organization_project_contributions = get_organization_project_contributions( + organization_names=organization_names, + ) + + total_projects, projects = get_projects( + project_contributions=list(organization_project_contributions.values()), + projects_filtering_properties=projects_filtering_properties, + ) + + elements: List[EuOrganizationProjectSummary] = _merge_project_data( + projects=projects, contributions=organization_project_contributions + ) + + if projects_filtering_properties.sort_by == ProjectsSortBy.FUNDING_AMOUNT: + elements.sort( + key=lambda x: x.ec_contribution or 0, + reverse=projects_filtering_properties.sort_direction == SortDirection.DESC, + ) + start = projects_filtering_properties.page * projects_filtering_properties.size + end = start + projects_filtering_properties.size + elements = elements[start:end] + + return EuOrganizationProjectSummaryPage( + elements=elements, + total=total_projects, + page=projects_filtering_properties.page, + size=projects_filtering_properties.size, + ) + + +def get_organization_project_contributions( + organization_names: List[str], +) -> Dict[str, EuOrganizationShort]: + + source = ["projectID", "organisationID", "ecContribution"] + + query = { + "terms": { + "name.keyword": [ + name.upper() for name in organization_names if name.strip() + ], + } + } + + response = elasticsearch.search( + index=ESIndex.CORDIS_EU_ORGANIZATIONS_WILDCARD, + cluster=ESCluster.INSE, + source=source, + size=10000, + query=query, + ) + + logger.debug( + f"Received organization project contributions response: {json.dumps(response, indent=2)}" + ) + + organization_project_contributions = _process_organization_project_contributions( + response + ) + + logger.debug( + f"Found organization project contributions for organization names {organization_names}: {organization_project_contributions}" + ) + + return organization_project_contributions + + +def _process_organization_project_contributions( + response: Dict[str, Any], +) -> Dict[str, EuOrganizationShort]: + hits_block = response.get("hits", {}) + project_contributions: Dict[str, EuOrganizationShort] = {} + for hit in hits_block.get("hits", []): + source = hit.get("_source", {}) + project_id = source.get("projectID") + organization_id = source.get("organisationID") + ec_contribution = source.get("ecContribution") + if project_id and organization_id: + project_contributions[project_id] = EuOrganizationShort( + project_id=project_id, + organization_id=organization_id, + ec_contribution=ec_contribution, + ) + return project_contributions + + +def get_projects( + project_contributions: List[EuOrganizationShort], + projects_filtering_properties: ProjectsFilteringProperties, +) -> Tuple[int, Dict[str, EuProjectShort]]: + project_ids = [contribution.project_id for contribution in project_contributions] + + source = ["id", "title", "startDate", "endDate", "acronym"] + + query = { + "terms": { + "id": project_ids, + } + } + + if ( + projects_filtering_properties.query + and projects_filtering_properties.query.strip() + ): + query = { + "bool": { + "must": [ + { + "match_phrase_prefix": { + "title": { + "query": projects_filtering_properties.query, + "max_expansions": 50, + } + } + } + ], + "filter": query, + } + } + + # Project contributions have been filtered before based on ecContribution + if projects_filtering_properties.sort_by == ProjectsSortBy.FUNDING_AMOUNT: + response = elasticsearch.search( + index=ESIndex.CORDIS_EU_PROJECTS_WILDCARD, + cluster=ESCluster.INSE, + source=source, + query=query, + size=10000, + ) + else: + response = elasticsearch.search( + index=ESIndex.CORDIS_EU_PROJECTS_WILDCARD, + cluster=ESCluster.INSE, + source=source, + query=query, + size=projects_filtering_properties.size, + offset=projects_filtering_properties.page + * projects_filtering_properties.size, + sort=[ + { + projects_filtering_properties.sort_by.to_cordis_eu_project_sort_field(): { + "order": projects_filtering_properties.sort_direction + } + } + ], + ) + + return _process_projects_response(response) + + +def _process_projects_response( + response: Dict[str, Any], +) -> Tuple[int, Dict[str, EuProjectShort]]: + hits_block = response.get("hits", {}) + total = hits_block.get("total", {}).get("value", 0) + projects: Dict[str, EuProjectShort] = {} + for hit in hits_block.get("hits", []): + source = hit.get("_source", {}) + project_id = source.get("id") + title = source.get("title") + start_date = source.get("startDate") + end_date = source.get("endDate") + acronym = source.get("acronym") + if not project_id: + continue + projects[project_id] = EuProjectShort( + id=project_id, + title=title, + start_date=start_date, + end_date=end_date, + acronym=acronym, + ) + + return total, projects + + +def _merge_project_data( + projects: Dict[str, EuProjectShort], contributions: Dict[str, EuOrganizationShort] +) -> List[EuOrganizationProjectSummary]: + merged_data = [] + for project_id, project_info in projects.items(): + contribution_info = contributions.get(project_id) + if contribution_info: + merged_entry = EuOrganizationProjectSummary( + project_id=project_id, + title=project_info.title, + start_date=project_info.start_date, + end_date=project_info.end_date, + acronym=project_info.acronym, + organization_id=contribution_info.organization_id, + ec_contribution=contribution_info.ec_contribution, + ) + merged_data.append(merged_entry) + return merged_data diff --git a/service/src/main/inse/projects/router.py b/service/src/main/inse/projects/router.py index 7d6e45f9..568abeae 100644 --- a/service/src/main/inse/projects/router.py +++ b/service/src/main/inse/projects/router.py @@ -8,6 +8,7 @@ from inse.projects.model import ( BundProjectPage, CordisEuProjectPage, DfgProjectPage, + EuOrganizationProjectSummaryPage, FundingProjectPage, InstitutionFunderSummary, ProjectType, @@ -211,7 +212,7 @@ async def get_institution_bund_projects_funding_over_time( responses={ status.HTTP_200_OK: { "description": "Successful Response", - "model": CordisEuProjectPage, + "model": EuOrganizationProjectSummaryPage, }, status.HTTP_404_NOT_FOUND: {"description": "Institution not found"}, }, @@ -226,9 +227,8 @@ async def search_cordis_eu_projects( ProjectsFilteringProperties, Body(description="The filtering properties for the projects search."), ], -) -> CordisEuProjectPage: - return await projects_service.search_cordis_eu_projects( - eu_search_client=eu_search_client, +) -> EuOrganizationProjectSummaryPage: + return projects_service.search_cordis_eu_projects( institutions_search_client=institutions_search_client, projects_filtering_properties=projects_filtering_properties, ) diff --git a/service/src/main/inse/projects/service.py b/service/src/main/inse/projects/service.py index 9dde9e87..a725f0fa 100644 --- a/service/src/main/inse/projects/service.py +++ b/service/src/main/inse/projects/service.py @@ -7,12 +7,13 @@ from inse.projects.projects_search_client import ( CompleteProjectsSearchClient, DfgProjectsSearchClient, EuProjectsSearchClient, + get_organization_project_contributions_foo, ) from inse.projects.model import ( BundProjectPage, CordisEuProjectPage, DfgProjectPage, - EuProjectPage, + EuOrganizationProjectSummaryPage, FundingProjectPage, InstitutionFunderSummary, ProjectType, @@ -99,28 +100,25 @@ async def get_bund_projects_by_institution_id( return response -async def search_cordis_eu_projects( - eu_search_client: EuProjectsSearchClient, +def search_cordis_eu_projects( institutions_search_client: InstitutionsSearchClient, projects_filtering_properties: ProjectsFilteringProperties, -) -> CordisEuProjectPage: +) -> EuOrganizationProjectSummaryPage: if projects_filtering_properties.project_type != "eu": raise ValueError( f"Invalid project type: {projects_filtering_properties.project_type}. Expected 'eu'." ) - return await get_cordis_eu_projects_by_institution_id( - eu_search_client=eu_search_client, + return get_cordis_eu_projects_by_institution_id( institutions_search_client=institutions_search_client, projects_filtering_properties=projects_filtering_properties, ) -async def get_cordis_eu_projects_by_institution_id( - eu_search_client: EuProjectsSearchClient, +def get_cordis_eu_projects_by_institution_id( institutions_search_client: InstitutionsSearchClient, projects_filtering_properties: ProjectsFilteringProperties, -) -> CordisEuProjectPage: +) -> EuOrganizationProjectSummaryPage: if not projects_filtering_properties.raw_oa_institution_id: raise ValueError( "raw_oa_institution_id must be provided to fetch CORDIS EU projects by institution ID" @@ -138,28 +136,14 @@ async def get_cordis_eu_projects_by_institution_id( f"Found institution aliases for institution_id={projects_filtering_properties.raw_oa_institution_id}: {institution_aliases}" ) - institution_eu_organisation_ids = ( - institutions_search_client.get_cordis_eu_organisation_ids_by_oa_institution_id( - projects_filtering_properties.raw_oa_institution_id - ) - ) - if not institution_eu_organisation_ids: - logger.debug( - f"No EU organization IDs found for institution_id={projects_filtering_properties.raw_oa_institution_id}" - ) - return CordisEuProjectPage( - elements=[], - total=0, - page=projects_filtering_properties.page, - size=projects_filtering_properties.size, - ) - - cordis_eu_project_page = await eu_search_client.search_eu_projects( - eu_organisation_ids=institution_eu_organisation_ids, + page = get_organization_project_contributions_foo( + organization_names=institution_aliases, projects_filtering_properties=projects_filtering_properties, ) - return cordis_eu_project_page + logger.debug(f"get_cordis_eu_projects_by_institution_id response: {page}") + + return page async def get_dfg_projects_by_author_id( @@ -199,12 +183,26 @@ async def get_institution_cordis_eu_projects_funding_over_time( raw_oa_institution_id: str, ) -> InstitutionFunderSummary: - cordis_eu_project_page = await search_cordis_eu_projects( - eu_search_client, - institutions_search_client, - ProjectsFilteringProperties( + # cordis_eu_project_page = await search_cordis_eu_projects( + # eu_search_client, + # institutions_search_client, + # ProjectsFilteringProperties( + # project_type=ProjectType.EU, + # raw_oa_institution_id=raw_oa_institution_id, + # page=0, + # size=10000, + # ), + # ) + + institution_aliases = ( + institutions_search_client.get_institution_aliases_by_oa_institution_id( + raw_oa_institution_id + ) + ) + page = get_organization_project_contributions_foo( + organization_names=institution_aliases, + projects_filtering_properties=ProjectsFilteringProperties( project_type=ProjectType.EU, - raw_oa_institution_id=raw_oa_institution_id, page=0, size=10000, ), @@ -212,10 +210,10 @@ async def get_institution_cordis_eu_projects_funding_over_time( return _calculate_funding_over_time( project_type=ProjectType.EU, - projects=cordis_eu_project_page.elements, - funding_start_attr="startDate", - funding_end_attr="endDate", - funding_amount_attr="totalCost", + projects=page.elements, + funding_start_attr="start_date", + funding_end_attr="end_date", + funding_amount_attr="ec_contribution", ) diff --git a/ude_person.http b/ude_person.http index f4691a10..9354020f 100644 --- a/ude_person.http +++ b/ude_person.http @@ -161,6 +161,26 @@ GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_organizations/_search Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw== Content-Type: application/json +{ + "size": 1000, + "query": { + "bool": { + "filter": [ + { + "term": { + "name.keyword": "UNIVERSITAET DUISBURG-ESSEN" + } + } + ] + } + } +} + +### +GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_organizations/_search +Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw== +Content-Type: application/json + { "size": 0, "query": { @@ -183,26 +203,38 @@ Content-Type: application/json } } +### +GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_projects/_mapping +Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw== +Content-Type: application/json + ### GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_organizations/_search Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw== Content-Type: application/json { - "size": 10, "query": { - "bool": { - "filter": [ - { - "term": { - "name.keyword": "UNIVERSITAET DUISBURG-ESSEN" - } - } + "terms": { + "name": [ + "UNIVERSITÄT DUISBURG-ESSEN", + "UNIVERSITY OF DUISBURG-ESSEN", + "UNIVERSITAT DUISBURG-ESSEN", + "UNIVERSITY OF DUISBURG ESSEN", + "UNIVERSITAT DUISBURG-ESSEN", + "UNIVERSITAET DUISBURG ESSEN", + "UNIVERSITÄT DUISBURG ESSEN", + "UNIVERSITAT DUISBURG ESSEN", + "UNIVERSITÄT DUISBURG-ESSEN", + "UNIVERSITAET DUISBURG-ESSEN", + "UNIVERSITY OF DUISBURG-ESSEN" ] } - } + }, + "_source": ["projectID", "organisationID", "ecContribution"] } + ### GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_organizations/_search Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw== diff --git a/webapp/src/app/api/.openapi-generator/FILES b/webapp/src/app/api/.openapi-generator/FILES index a8e4f29f..d188cd69 100644 --- a/webapp/src/app/api/.openapi-generator/FILES +++ b/webapp/src/app/api/.openapi-generator/FILES @@ -59,6 +59,8 @@ model/dehydratedSource.ts model/dfgProjectDetails.ts model/dfgProjectPage.ts model/dfgProjectSummary.ts +model/euOrganizationProjectSummary.ts +model/euOrganizationProjectSummaryPage.ts model/filterInformation.ts model/filterProperties.ts model/funderByAuthor.ts diff --git a/webapp/src/app/api/api/projects.service.ts b/webapp/src/app/api/api/projects.service.ts index b3b91911..9edfb7fe 100644 --- a/webapp/src/app/api/api/projects.service.ts +++ b/webapp/src/app/api/api/projects.service.ts @@ -27,6 +27,8 @@ import { DfgProjectDetails } from '../model/dfgProjectDetails'; // @ts-ignore import { DfgProjectPage } from '../model/dfgProjectPage'; // @ts-ignore +import { EuOrganizationProjectSummaryPage } from '../model/euOrganizationProjectSummaryPage'; +// @ts-ignore import { FundingProjectPage } from '../model/fundingProjectPage'; // @ts-ignore import { HTTPValidationError } from '../model/hTTPValidationError'; @@ -497,9 +499,9 @@ export class ProjectsService 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 searchCordisEuProjects(projectsFilteringProperties: ProjectsFilteringProperties, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public searchCordisEuProjects(projectsFilteringProperties: ProjectsFilteringProperties, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public searchCordisEuProjects(projectsFilteringProperties: ProjectsFilteringProperties, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public searchCordisEuProjects(projectsFilteringProperties: ProjectsFilteringProperties, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public searchCordisEuProjects(projectsFilteringProperties: ProjectsFilteringProperties, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public searchCordisEuProjects(projectsFilteringProperties: ProjectsFilteringProperties, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public searchCordisEuProjects(projectsFilteringProperties: ProjectsFilteringProperties, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (projectsFilteringProperties === null || projectsFilteringProperties === undefined) { throw new Error('Required parameter projectsFilteringProperties was null or undefined when calling searchCordisEuProjects.'); @@ -541,7 +543,7 @@ export class ProjectsService extends BaseService { let localVarPath = `/api/projects/institution/eu/search`; const { basePath, withCredentials } = this.configuration; - return this.httpClient.request('post', `${basePath}${localVarPath}`, + return this.httpClient.request('post', `${basePath}${localVarPath}`, { context: localVarHttpContext, body: projectsFilteringProperties, diff --git a/webapp/src/app/api/model/euOrganizationProjectSummary.ts b/webapp/src/app/api/model/euOrganizationProjectSummary.ts new file mode 100644 index 00000000..3cc10f0a --- /dev/null +++ b/webapp/src/app/api/model/euOrganizationProjectSummary.ts @@ -0,0 +1,27 @@ +/** + * 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. + */ + + +export interface EuOrganizationProjectSummary { + /** + * The unique identifier of the organization. + */ + organization_id: string; + /** + * The unique identifier of the project. + */ + project_id: string; + title?: string | null; + start_date?: string | null; + end_date?: string | null; + acronym?: string | null; + ec_contribution?: number | null; +} + diff --git a/webapp/src/app/api/model/euOrganizationProjectSummaryPage.ts b/webapp/src/app/api/model/euOrganizationProjectSummaryPage.ts new file mode 100644 index 00000000..9d57d5b4 --- /dev/null +++ b/webapp/src/app/api/model/euOrganizationProjectSummaryPage.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 { EuOrganizationProjectSummary } from './euOrganizationProjectSummary'; + + +export interface EuOrganizationProjectSummaryPage { + /** + * The current page number. + */ + page?: number; + /** + * The requested page size. + */ + size?: number; + /** + * The total number of items. + */ + total?: number; + /** + * The organization project summaries on this page. + */ + elements?: Array; +} + diff --git a/webapp/src/app/api/model/models.ts b/webapp/src/app/api/model/models.ts index 60006d17..0dd39ede 100644 --- a/webapp/src/app/api/model/models.ts +++ b/webapp/src/app/api/model/models.ts @@ -38,6 +38,8 @@ export * from './dehydratedSource'; export * from './dfgProjectDetails'; export * from './dfgProjectPage'; export * from './dfgProjectSummary'; +export * from './euOrganizationProjectSummary'; +export * from './euOrganizationProjectSummaryPage'; export * from './filterInformation'; export * from './filterProperties'; export * from './funderByAuthor'; diff --git a/webapp/src/app/modules/institution-projects/institution-projects.component.html b/webapp/src/app/modules/institution-projects/institution-projects.component.html index e4982ec6..ce7c7648 100644 --- a/webapp/src/app/modules/institution-projects/institution-projects.component.html +++ b/webapp/src/app/modules/institution-projects/institution-projects.component.html @@ -75,7 +75,9 @@ undefined " /> + open_in_new + + + + + open_in_new + + diff --git a/webapp/src/app/modules/institution-projects/institution-projects.component.ts b/webapp/src/app/modules/institution-projects/institution-projects.component.ts index 4f547c61..42631284 100644 --- a/webapp/src/app/modules/institution-projects/institution-projects.component.ts +++ b/webapp/src/app/modules/institution-projects/institution-projects.component.ts @@ -8,12 +8,12 @@ import { TemplateRef, viewChild, } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; +import { ActivatedRoute, Router, RouterModule } from '@angular/router'; import { BundProject, BundProjectPage, - CordisEuProject, - CordisEuProjectPage, + EuOrganizationProjectSummary, + EuOrganizationProjectSummaryPage, InstitutionFunderSummary, } from '../../api'; import { MatCardModule } from '@angular/material/card'; @@ -36,6 +36,7 @@ import { InstitutionProjectsFundingGraphComponent } from '../institution-project import { PersonNetworkInfoCardComponent } from '../person-network-info-card/person-network-info-card.component'; type BundProjectRow = { + id: string; topic: string; funding_start: Date; funding_end: Date; @@ -44,6 +45,7 @@ type BundProjectRow = { }; type EuProjectRow = { + id: string; topic: string; funding_start: Date; funding_end: Date; @@ -67,6 +69,7 @@ type EuProjectRow = { MatButtonModule, InstitutionProjectsFundingGraphComponent, PersonNetworkInfoCardComponent, + RouterModule, ], templateUrl: './institution-projects.component.html', styleUrl: './institution-projects.component.scss', @@ -76,13 +79,19 @@ export class InstitutionProjectsComponent implements OnInit { fundingEndTmp = viewChild.required>('fundingEndTmp'); fundingAmountTmp = viewChild.required>('fundingAmountTmp'); - cordisEuProjectPage = input.required(); + cordisEuProjectPage = input.required(); euProjectColumns: GenericColumn[] = []; euProjectData: EuProjectRow[] = []; + euProjectActionsTmp = viewChild.required>( + 'euProjectActionsTmp', + ); bundProjectPage = input.required(); bundProjectColumns: GenericColumn[] = []; bundProjectData: BundProjectRow[] = []; + bundProjectActionsTmp = viewChild.required>( + 'bundProjectActionsTmp', + ); bundProjectsFunding = input.required(); bundTotalFunding = computed(() => { @@ -221,6 +230,12 @@ export class InstitutionProjectsComponent implements OnInit { accessorKey: 'funding_amount', cellTemplate: this.fundingAmountTmp(), }, + { + id: 'actions', + header: '', + type: 'display', + cellTemplate: this.euProjectActionsTmp(), + }, ]; this.bundProjectColumns = [ { @@ -250,22 +265,30 @@ export class InstitutionProjectsComponent implements OnInit { accessorKey: 'funding_amount', cellTemplate: this.fundingAmountTmp(), }, + { + id: 'actions', + header: '', + type: 'display', + cellTemplate: this.bundProjectActionsTmp(), + }, ]; } - transformEuRow(project: CordisEuProject): EuProjectRow { + transformEuRow(project: EuOrganizationProjectSummary): EuProjectRow { return { + id: project.project_id, topic: project.title || '', - funding_start: project.startDate - ? new Date(project.startDate) + funding_start: project.start_date + ? new Date(project.start_date) : new Date(0), - funding_end: project.endDate ? new Date(project.endDate) : new Date(0), - funding_amount: Number(project.totalCost) || 0, + funding_end: project.end_date ? new Date(project.end_date) : new Date(0), + funding_amount: Number(project.ec_contribution) || 0, }; } transformBundRow(project: BundProject): BundProjectRow { return { + id: project.funding_code || '', topic: project.topic || '', funding_start: project.funding_start ? new Date(project.funding_start) diff --git a/webapp/src/app/resolvers/cordis-eu-project-page.resolver.ts b/webapp/src/app/resolvers/cordis-eu-project-page.resolver.ts index 2508fa68..b6a9cfb5 100644 --- a/webapp/src/app/resolvers/cordis-eu-project-page.resolver.ts +++ b/webapp/src/app/resolvers/cordis-eu-project-page.resolver.ts @@ -1,13 +1,13 @@ import { ResolveFn } from '@angular/router'; import { - CordisEuProjectPage, + EuOrganizationProjectSummaryPage, ProjectsService, ProjectsSortBy, SortDirection, } from '../api'; import { inject } from '@angular/core'; -export const cordisEuProjectPageResolver: ResolveFn = ( +export const cordisEuProjectPageResolver: ResolveFn = ( route, state, ) => {