From 3a74dc9b7bf7df604407a78334377c0bac8b72f7 Mon Sep 17 00:00:00 2001 From: genja Date: Sun, 26 Jul 2026 18:38:32 +0200 Subject: [PATCH] created new DfgProjectsDetails model from the new DFG data models --- .../main/inse/models/dfg_project_details.py | 656 +++++++++++------- .../projects_dfg_v2/project/dfg_project.py | 6 +- webapp/src/app/api/.openapi-generator/FILES | 5 + webapp/src/app/api/model/dfgProjectDetails.ts | 97 ++- .../api/model/dfgProjectInstitutionRole.ts | 25 + webapp/src/app/api/model/dfgProjectPage.ts | 38 +- .../src/app/api/model/dfgProjectPersonRole.ts | 27 + .../api/model/dfgProjectPublicationSummary.ts | 22 + .../app/api/model/dfgProjectSubjectArea.ts | 21 + .../api/model/dfgProjectSubprojectSummary.ts | 26 + 10 files changed, 622 insertions(+), 301 deletions(-) create mode 100644 webapp/src/app/api/model/dfgProjectInstitutionRole.ts create mode 100644 webapp/src/app/api/model/dfgProjectPersonRole.ts create mode 100644 webapp/src/app/api/model/dfgProjectPublicationSummary.ts create mode 100644 webapp/src/app/api/model/dfgProjectSubjectArea.ts create mode 100644 webapp/src/app/api/model/dfgProjectSubprojectSummary.ts diff --git a/service/src/main/inse/models/dfg_project_details.py b/service/src/main/inse/models/dfg_project_details.py index cbf909cb..eef0d7ad 100644 --- a/service/src/main/inse/models/dfg_project_details.py +++ b/service/src/main/inse/models/dfg_project_details.py @@ -1,293 +1,443 @@ # coding: utf-8 """ - DFG Project Clean Model + DFG Project Clean Model (v2) - Summary model that consolidates all scattered person and institution fields - from the raw projects_dfg_all index into clean, unified lists. + Enriched, consolidated model built on top of the structured + projects_dfg_v2 API models (DFGProject / DFGPerson / DFGInstitute), + rather than the old flat projects_dfg_all Elasticsearch index. """ -from typing import Optional, List, Set +from typing import List, Optional from pydantic import BaseModel, ConfigDict, Field +from inse.models.projects_dfg_v2.project.dfg_project import DFGProject +from inse.models.projects_dfg_v2.project.dfg_project_persons_inner import ( + DFGProjectPersonsInner, +) +from inse.models.projects_dfg_v2.project.dfg_project_institutions_inner import ( + DFGProjectInstitutionsInner, +) +from inse.models.projects_dfg_v2.project.dfg_project_subprojects_inner import ( + DFGProjectSubprojectsInner, +) +from inse.models.projects_dfg_v2.project.dfg_project_publications_inner import ( + DFGProjectPublicationsInner, +) +from inse.models.projects_dfg_v2.project.dfg_project_fachgebiete_inner import ( + DFGProjectFachgebieteInner, +) + + +class DfgProjectPersonRole(BaseModel): + """A person associated with the project, together with their role.""" + + model_config = ConfigDict(populate_by_name=True) + + person_id: Optional[int] = Field(default=None, description="DFG person ID") + full_name: Optional[str] = Field(default=None, description="Full name of the person") + orcid_id: Optional[str] = Field( + default=None, + description=( + "ORCID iD, if known. Not present on the project's embedded person " + "record (DFGProjectPersonsInner) -- only populated if the caller " + "cross-references the full DFGPerson record via person_id and " + "calls DfgProjectDetails.enrich_orcids afterwards." + ), + ) + role_key: Optional[str] = Field( + default=None, description="Machine-readable role key (e.g. 'antragsteller')" + ) + role_label_de: Optional[str] = Field(default=None, description="Role label (German)") + role_label_en: Optional[str] = Field(default=None, description="Role label (English)") + affiliation_de: Optional[str] = Field( + default=None, description="Person's affiliation at time of project (German)" + ) + affiliation_en: Optional[str] = Field( + default=None, description="Person's affiliation at time of project (English)" + ) + is_deceased: Optional[bool] = Field(default=None, description="Whether the person is deceased") + is_head: Optional[bool] = Field( + default=None, description="Whether this person is highlighted as the project head" + ) + + @classmethod + def from_inner(cls, p: DFGProjectPersonsInner) -> "DfgProjectPersonRole": + return cls( + person_id=p.person_id, + full_name=p.full_name, + role_key=p.role_key, + role_label_de=p.role_label_de, + role_label_en=p.role_label_en, + affiliation_de=p.affiliation_de, + affiliation_en=p.affiliation_en, + is_deceased=p.is_deceased, + is_head=p.is_head_display, + ) + + +class DfgProjectInstitutionRole(BaseModel): + """An institution associated with the project, together with its role.""" + + model_config = ConfigDict(populate_by_name=True) + + institute_id: Optional[int] = Field(default=None, description="DFG institute ID") + name_de: Optional[str] = Field(default=None, description="Institution name (German)") + name_en: Optional[str] = Field(default=None, description="Institution name (English)") + role_key: Optional[str] = Field(default=None, description="Machine-readable role key") + role_label_de: Optional[str] = Field(default=None, description="Role label (German)") + role_label_en: Optional[str] = Field(default=None, description="Role label (English)") + is_dissolved: Optional[bool] = Field( + default=None, description="Whether the institution has since been dissolved" + ) + is_head: Optional[bool] = Field( + default=None, description="Whether this institution is highlighted as the lead institution" + ) + + @classmethod + def from_inner(cls, i: DFGProjectInstitutionsInner) -> "DfgProjectInstitutionRole": + return cls( + institute_id=i.institute_id, + name_de=i.institute_name_de, + name_en=i.institute_name_en, + role_key=i.role_key, + role_label_de=i.role_label_de, + role_label_en=i.role_label_en, + is_dissolved=i.is_dissolved, + is_head=i.is_head_display, + ) + + +class DfgProjectSubprojectSummary(BaseModel): + """A lightweight reference to a sub-project of this project.""" + + model_config = ConfigDict(populate_by_name=True) + + subproject_id: Optional[int] = None + title_de: Optional[str] = None + title_en: Optional[str] = None + short_title: Optional[str] = None + role_label_de: Optional[str] = Field( + default=None, description="Role of the sub-project lead within the sub-project" + ) + person_full_name: Optional[str] = Field( + default=None, description="Sub-project lead, derived from first/last name fields" + ) + status_de: Optional[str] = None + funding_start: Optional[int] = None + funding_end: Optional[int] = None + + @classmethod + def from_inner(cls, s: DFGProjectSubprojectsInner) -> "DfgProjectSubprojectSummary": + person_full_name = None + if s.person_first_names or s.person_last_name: + person_full_name = " ".join( + part for part in [s.person_first_names, s.person_last_name] if part + ).strip() or None + + return cls( + subproject_id=s.subproject_id, + title_de=s.title_de, + title_en=s.title_en, + short_title=s.short_title, + role_label_de=s.role_label_de, + person_full_name=person_full_name, + status_de=s.status_de, + funding_start=s.funding_start, + funding_end=s.funding_end, + ) + + +class DfgProjectPublicationSummary(BaseModel): + """A lightweight reference to a publication resulting from the project.""" + + model_config = ConfigDict(populate_by_name=True) + + publication_id: Optional[int] = None + title: Optional[str] = None + authors_editors: Optional[str] = None + doi: Optional[str] = None + publication_year: Optional[int] = None + + @classmethod + def from_inner(cls, p: DFGProjectPublicationsInner) -> "DfgProjectPublicationSummary": + return cls( + publication_id=p.publication_id, + title=p.title, + authors_editors=p.authors_editors, + doi=p.doi, + publication_year=p.publication_year, + ) + + +class DfgProjectSubjectArea(BaseModel): + """A single subject-area classification entry (DFG 'Fachsystematik').""" + + model_config = ConfigDict(populate_by_name=True) + + fach: Optional[str] = None + fachgebiet: Optional[str] = None + fachkollegium: Optional[str] = None + wissenschaftsbereich: Optional[str] = None + + @classmethod + def from_inner(cls, f: DFGProjectFachgebieteInner) -> "DfgProjectSubjectArea": + return cls( + fach=f.fach, + fachgebiet=f.fachgebiet, + fachkollegium=f.fachkollegium, + wissenschaftsbereich=f.wissenschaftsbereich, + ) + class DfgProjectDetails(BaseModel): """ - Clean summary model for a DFG project, consolidating all person roles - and institution references into unified lists. + Clean, enriched summary model for a DFG project. """ - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, + + model_config = ConfigDict(populate_by_name=True, validate_assignment=True) + + id: Optional[int] = Field(default=None, description="The DFG project ID") + link: Optional[str] = Field(default=None, description="Canonical DFG link to the project") + page_url: Optional[str] = Field(default=None, description="DFG GEPRIS page URL") + external_link: Optional[str] = Field( + default=None, description="External project website/link, if provided" ) - id: str = Field(description="The ID of the DFG project") - link: Optional[str] = Field(default=None, description="The link to the DFG project") - title: Optional[str] = Field( - default=None, description="The title of the DFG project" + title_de: Optional[str] = Field(default=None, description="Project title (German)") + title_en: Optional[str] = Field(default=None, description="Project title (English)") + description_de: Optional[str] = Field(default=None, description="Project abstract (German)") + description_en: Optional[str] = Field(default=None, description="Project abstract (English)") + final_report_abstract_de: Optional[str] = Field( + default=None, description="Final report abstract (German), if the project has concluded" ) - description: Optional[str] = Field( - default=None, description="The description of the DFG project" + final_report_abstract_en: Optional[str] = Field( + default=None, description="Final report abstract (English), if the project has concluded" ) - project_identifier: Optional[str] = Field( - default=None, - description="The project identifier of the DFG project", - ) + project_identifier_de: Optional[str] = Field(default=None, description="DFG project identifier (German)") + project_identifier_en: Optional[str] = Field(default=None, description="DFG project identifier (English)") - funding_start_date: Optional[str] = Field( - default=None, description="The funding start date of the DFG project" - ) - funding_end_date: Optional[str] = Field( - default=None, description="The funding end date of the DFG project" - ) + funding_start: Optional[int] = Field(default=None, description="Funding start year") + funding_end: Optional[int] = Field(default=None, description="Funding end year") + funding_period_de: Optional[str] = Field(default=None, description="Human-readable funding period (German)") + funding_period_en: Optional[str] = Field(default=None, description="Human-readable funding period (English)") + + funding_type_de: Optional[str] = Field(default=None, description="Funding type / programme (German)") + funding_type_en: Optional[str] = Field(default=None, description="Funding type / programme (English)") + funding_type_key: Optional[str] = Field(default=None, description="Machine-readable funding type key") dfg_procedure: Optional[str] = Field( - default=None, description="The DFG procedure" - ) - subject_area: Optional[str] = Field( - default=None, - description="The subject area classification", - ) - funding_type: Optional[str] = Field( - default=None, description="The type of funding" - ) - international_reference: Optional[str] = Field( - default=None, - - description="International reference", + default=None, description="DFG procedure / template type (e.g. Sachbeihilfe, SFB, GRK)" ) - website: Optional[str] = Field( - default=None, description="The project website" + is_transfer_project: Optional[bool] = Field( + default=None, description="Whether this is a transfer project" ) - # Unified person list: all person names from any role + website_html_de: Optional[str] = Field( + default=None, description="Raw project website HTML content (German), as served by DFG" + ) + website_html_en: Optional[str] = Field( + default=None, description="Raw project website HTML content (English), as served by DFG" + ) + + equipment_group: Optional[str] = Field( + default=None, + description="Large-equipment (Großgerät) group, for equipment-funding projects", + ) + equipment_name: Optional[str] = Field( + default=None, + description="Large-equipment (Großgerät) name, for equipment-funding projects", + ) + + subject_area_de: Optional[str] = Field(default=None, description="Subject area, summary text (German)") + subject_area_en: Optional[str] = Field(default=None, description="Subject area, summary text (English)") + subject_classifications: List[DfgProjectSubjectArea] = Field( + default_factory=list, + description="Detailed DFG subject-area classification entries (Fachsystematik)", + ) + + international_relation_de: Optional[str] = Field( + default=None, description="International reference/cooperation (German)" + ) + international_relation_en: Optional[str] = Field( + default=None, description="International reference/cooperation (English)" + ) + + # Structured, role-aware person and institution lists + persons: List[DfgProjectPersonRole] = Field( + default_factory=list, + description="All persons associated with the project, each with their role", + ) + institutions: List[DfgProjectInstitutionRole] = Field( + default_factory=list, + description="All institutions associated with the project, each with their role", + ) + + # Convenience flat views, derived from the structured lists above associated_persons: List[str] = Field( default_factory=list, - description="All persons associated with the DFG project (any role)", + description="Flat, de-duplicated list of all person full names (convenience view)", ) - - # Unified institution list: all institutions involved - institutions: List[str] = Field( + associated_institutions: List[str] = Field( default_factory=list, - description="All institutions associated with the DFG project", + description="Flat, de-duplicated list of all institution names (convenience view)", ) - # Sub-project reference - subproject_of: Optional[str] = Field( - default=None, - description="Parent project this is a sub-project of", + # Parent / sub-project structure + parent_project_id: Optional[int] = Field(default=None, description="Parent project ID, if this is a sub-project") + parent_title_de: Optional[str] = Field(default=None, description="Parent project title (German)") + parent_title_en: Optional[str] = Field(default=None, description="Parent project title (English)") + subprojects: List[DfgProjectSubprojectSummary] = Field( + default_factory=list, description="Sub-projects of this project, if any" ) + publications: List[DfgProjectPublicationSummary] = Field( + default_factory=list, description="Publications resulting from the project" + ) + + @classmethod + def from_dfg_project(cls, project: DFGProject) -> "DfgProjectDetails": + """ + Build a DfgProjectDetails from a fully-typed DFGProject instance + (e.g. as returned by the projects_dfg_v2 API client). + """ + + persons = [DfgProjectPersonRole.from_inner(p) for p in (project.persons or [])] + institutions = [ + DfgProjectInstitutionRole.from_inner(i) for i in (project.institutions or []) + ] + subprojects = [ + DfgProjectSubprojectSummary.from_inner(s) for s in (project.subprojects or []) + ] + publications = [ + DfgProjectPublicationSummary.from_inner(p) for p in (project.publications or []) + ] + subject_classifications = [ + DfgProjectSubjectArea.from_inner(f) for f in (project.fachgebiete or []) + ] + + # De-duplicated flat views, order-preserving + seen_persons = set() + associated_persons = [] + for p in persons: + if p.full_name and p.full_name not in seen_persons: + seen_persons.add(p.full_name) + associated_persons.append(p.full_name) + + seen_institutions = set() + associated_institutions = [] + for i in institutions: + name = i.name_de or i.name_en + if name and name not in seen_institutions: + seen_institutions.add(name) + associated_institutions.append(name) + + return cls( + id=project.id or project.project_id, + link=project.link, + page_url=project.page_url, + external_link=project.external_link, + title_de=project.title_de, + title_en=project.title_en, + description_de=project.abstract_de, + description_en=project.abstract_en, + final_report_abstract_de=project.final_report_abstract_de, + final_report_abstract_en=project.final_report_abstract_en, + project_identifier_de=project.project_identifier_de, + project_identifier_en=project.project_identifier_en, + funding_start=project.funding_start, + funding_end=project.funding_end, + funding_period_de=project.funding_period_de, + funding_period_en=project.funding_period_en, + funding_type_de=project.funding_type_de, + funding_type_en=project.funding_type_en, + funding_type_key=project.funding_type_key, + dfg_procedure=project.template_type, + is_transfer_project=project.is_transfer_project, + website_html_de=project.website_html_de, + website_html_en=project.website_html_en, + equipment_group=project.equipment_group, + equipment_name=project.equipment_name, + subject_area_de=project.subject_area_de, + subject_area_en=project.subject_area_en, + subject_classifications=subject_classifications, + international_relation_de=project.international_relation_de, + international_relation_en=project.international_relation_en, + persons=persons, + institutions=institutions, + associated_persons=associated_persons, + associated_institutions=associated_institutions, + parent_project_id=project.parent_project_id, + parent_title_de=project.parent_title_de, + parent_title_en=project.parent_title_en, + subprojects=subprojects, + publications=publications, + ) + + @classmethod + def from_dict(cls, obj: dict) -> "DfgProjectDetails": + """Convenience constructor from a raw dict (e.g. a JSON API response body).""" + obj = cls._sanitize_raw_project_dict(obj) + return cls.from_dfg_project(DFGProject.from_dict(obj)) + + @staticmethod + def _sanitize_raw_project_dict(obj: dict) -> dict: + """ + Work around known mismatches between the generated DFGProject model + and the actual shape of API/index data, before handing off to + DFGProject.from_dict (which would otherwise raise a ValidationError + and abort the whole parse). + + Known issue: `subject_classifications` is generated as a single + `DFGProjectFachgebieteInner`, but the real data returns a list (the + same shape as `fachgebiete`). We don't use this field ourselves -- + our own `subject_classifications` is built from `fachgebiete` -- so + it's simply dropped here rather than fixed up, to avoid crashing on + a field we never read. The proper long-term fix is correcting the + OpenAPI spec/generator so this field is typed as a list. + """ + if isinstance(obj.get("subject_classifications"), list): + obj = dict(obj) + obj.pop("subject_classifications", None) + return obj + @classmethod def from_elastic_hit(cls, hit: dict) -> "DfgProjectDetails": """ - Create a DfgProject from an Elasticsearch hit, consolidating all - person and institution fields into unified lists. + Compatibility constructor for callers still reading from an + Elasticsearch hit (e.g. `{"_id": ..., "_source": {...}}`), matching + the old model's from_elastic_hit signature. + + Assumes `_source` is already shaped like a DFGProject document + (flat fields, persons/institutions/etc. as lists) rather than the + old scattered-German-fields Elasticsearch schema. If `_source` + doesn't itself carry an id/project_id, the ES `_id` is injected so + `DfgProjectDetails.id` is never left empty. """ + source = dict(hit.get("_source", {})) - source = hit.get("_source", {}) + if source.get("id") is None and source.get("project_id") is None: + raw_id = hit.get("_id") + if raw_id is not None: + try: + source["id"] = int(raw_id) + except (TypeError, ValueError): + # Non-numeric _id (e.g. a composite/legacy key) - leave + # id unset rather than fail the whole parse. + pass - associated_persons: Set[str] = set() - institutions: Set[str] = set() + return cls.from_dict(source) - # --- Collect all persons and institutions from nested persons array --- - persons_list = source.get("persons", []) - if isinstance(persons_list, list): - for p in persons_list: - if isinstance(p, dict): - full_name = p.get("full_name") - if full_name: - associated_persons.add(full_name.strip()) - - aff_de = p.get("affiliation_de") - if aff_de: - institutions.add(aff_de.strip()) - - aff_en = p.get("affiliation_en") - if aff_en: - institutions.add(aff_en.strip()) - - # --- Collect all persons from every person-related field --- - - # Applicant fields - _add_persons(source, associated_persons, "Antragsteller") # semicolon-separated - _add_person(source, associated_persons, "Antragstellerin") - _add_persons( - source, associated_persons, "Antragstellerinnen" - ) # semicolon-separated - _add_persons( - source, associated_persons, "Antragstellerinnen / Antragsteller" - ) # semicolon-separated - - # Co-applicant fields - _add_persons(source, associated_persons, "Mitantragsteller") - _add_person(source, associated_persons, "Mitantragstellerin") - _add_persons(source, associated_persons, "Mitantragstellerinnen") - _add_persons( - source, associated_persons, "Mitantragstellerinnen / Mitantragsteller" - ) - - # Former applicant fields - _add_persons(source, associated_persons, "Ehemalige Antragsteller") - _add_person(source, associated_persons, "Ehemalige Antragstellerin") - _add_persons(source, associated_persons, "Ehemalige Antragstellerinnen") - _add_persons( - source, - associated_persons, - "Ehemalige Antragstellerinnen / Ehemalige Antragsteller", - ) - _add_person(source, associated_persons, "Ehemaliger Antragsteller") - - # Speaker / coordinator fields - _add_person(source, associated_persons, "Sprecher") - _add_person(source, associated_persons, "Sprecherin") - _add_persons(source, associated_persons, "Sprecherinnen") - _add_persons(source, associated_persons, "Sprecherinnen / Sprecher") - _add_person(source, associated_persons, "Co-Sprecher") - _add_persons(source, associated_persons, "Co-Sprecherinnen / Co-Sprecher") - - # IGK partner speaker fields - _add_person(source, associated_persons, "Sprecher (IGK-Partner)") - _add_person(source, associated_persons, "Sprecherin (IGK-Partner)") - _add_persons( - source, - associated_persons, - "Sprecherinnen (IGK-Partner) / Sprecher (IGK-Partner)", - ) - - # Leader fields - _add_person(source, associated_persons, "Leiter") - _add_person(source, associated_persons, "Leiterin") - _add_persons(source, associated_persons, "Leiterinnen") - _add_persons(source, associated_persons, "Leiterinnen / Leiter") - - # Sub-project leader fields - _add_persons(source, associated_persons, "Teilprojektleiter") - _add_person(source, associated_persons, "Teilprojektleiterin") - _add_persons(source, associated_persons, "Teilprojektleiterinnen") - _add_persons( - source, associated_persons, "Teilprojektleiterinnen / Teilprojektleiter" - ) - - # Participating scientist fields - _add_persons(source, associated_persons, "beteiligte Wissenschaftler") - _add_person(source, associated_persons, "beteiligte Wissenschaftlerin") - _add_persons(source, associated_persons, "beteiligte Wissenschaftlerinnen") - _add_persons( - source, - associated_persons, - "beteiligte Wissenschaftlerinnen / beteiligte Wissenschaftler", - ) - _add_person(source, associated_persons, "beteiligter Wissenschaftler") - - # Participating person fields - _add_person(source, associated_persons, "Beteiligte Person") - _add_persons(source, associated_persons, "Beteiligte Personen") - - # Host fields (for guest researchers) - _add_person(source, associated_persons, "Gastgeber") - _add_person(source, associated_persons, "Gastgeberin") - _add_persons(source, associated_persons, "Gastgeberinnen") - _add_persons(source, associated_persons, "Gastgeberinnen / Gastgeber") - - # Cooperation partner fields - _add_person(source, associated_persons, "Kooperationspartner") - _add_person(source, associated_persons, "Kooperationspartnerin") - _add_persons(source, associated_persons, "Kooperationspartnerinnen") - _add_persons( - source, associated_persons, "Kooperationspartnerinnen / Kooperationspartner" - ) - - # Co-responsible fields - _add_person(source, associated_persons, "Mitverantwortlich") - _add_person(source, associated_persons, "Mitverantwortlich(e)") - _add_persons(source, associated_persons, "Mitverantwortliche") - - # Application partner - _add_person(source, associated_persons, "Anwendungspartner") - - # Foreign co-applicant fields - _add_persons(source, associated_persons, "ausländische Mitantragsteller") - _add_person(source, associated_persons, "ausländischer Mitantragsteller") - - # Person creator (from nested fields) - if "person_creater_name" in source and source["person_creater_name"]: - associated_persons.add(source["person_creater_name"].strip()) - - # Deputy (stellvertr) - nested object - stellvertr = source.get("stellvertr") - if stellvertr and isinstance(stellvertr, dict): - for field in ["stellvertreter", "stellvertreterin"]: - if field in stellvertr and stellvertr[field]: - associated_persons.add(stellvertr[field].strip()) - - # --- Collect all institutions --- - - _add_institution(source, institutions, "Antragstellende Institution") - _add_institution(source, institutions, "Mitantragstellende Institution") - _add_institution(source, institutions, "Beteiligte Einrichtung") - _add_institution(source, institutions, "Beteiligte Hochschule") - _add_institution(source, institutions, "Beteiligte Institution") - _add_institution(source, institutions, "IGK-Partnerinstitution") - _add_institution(source, institutions, "Partnerorganisation") - _add_institution(source, institutions, "Unternehmen") - - # Foreign institution (nested object) - auslaend = source.get("ausländ") - if auslaend and isinstance(auslaend, dict): - for field in [ - "auslaendischeInstitution", - "auslaendischeInstitution2", - "auslaendischesUnternehmen", - "auslaendischesUnternehmen2", - ]: - if field in auslaend and auslaend[field]: - institutions.add(auslaend[field].strip()) - - return cls( - id=hit["_id"], - link=source.get("link") or source.get("page_url"), - title=source.get("title") or source.get("title_de") or source.get("title_en"), - description=source.get("description") or source.get("abstract_de") or source.get("abstract_en"), - project_identifier=source.get("Projektkennung") or source.get("project_identifier_de") or source.get("project_identifier_en"), - funding_start_date=str(source.get("funding_start")) if source.get("funding_start") is not None else None, - funding_end_date=str(source.get("funding_end")) if source.get("funding_end") is not None else None, - dfg_procedure=source.get("DFG-Verfahren") or source.get("template_type"), - subject_area=source.get("Fachliche Zuordnung") or source.get("subject_area_de") or source.get("subject_area_en"), - funding_type=source.get("Förderung") or source.get("funding_type_sort"), - international_reference=source.get("Internationaler Bezug") or source.get("international_relation_de") or source.get("international_relation_en"), - website=source.get("Webseite"), - associated_persons=sorted(associated_persons), # sorted for consistency - institutions=sorted(institutions), - subproject_of=source.get("Teilprojekt zu") or source.get("parent_project_id"), - ) - - -# --- Helper functions for parsing source fields --- - -def _add_person(source: dict, persons: Set[str], field: str) -> None: - """Add a single person value from a field.""" - if field in source and source[field]: - value = source[field].strip() - if value: - persons.add(value) - - -def _add_persons(source: dict, persons: Set[str], field: str) -> None: - """Add persons from a semicolon-separated field.""" - if field in source and source[field]: - for person in source[field].split(";"): - cleaned = person.strip() - if cleaned: - persons.add(cleaned) - - -def _add_institution(source: dict, institutions: Set[str], field: str) -> None: - """Add a single institution value from a field.""" - if field in source and source[field]: - value = source[field].strip() - if value: - institutions.add(value) \ No newline at end of file + def enrich_orcids(self, persons_by_id: dict) -> None: + """ + Fill in orcid_id on each entry in `self.persons`, given a mapping of + person_id -> DFGPersonPerson (or DFGPerson) for the persons involved + in this project + """ + for person in self.persons: + record = persons_by_id.get(person.person_id) + if record is not None: + person.orcid_id = getattr(record, "orcid_id", None) \ No newline at end of file diff --git a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project.py b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project.py index 1fa929ec..f9c978b3 100644 --- a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project.py +++ b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project.py @@ -52,7 +52,7 @@ class DFGProject(BaseModel): funding_type_key: Optional[StrictStr] = None funding_type_sort: Optional[StrictStr] = None id: Optional[StrictInt] = None - institution_roles_order: Optional[StrictStr] = None + institution_roles_order: Optional[list[StrictStr]] = None institutions: Optional[List[DFGProjectInstitutionsInner]] = None international_relation_de: Optional[StrictStr] = None international_relation_en: Optional[StrictStr] = None @@ -62,7 +62,7 @@ class DFGProject(BaseModel): parent_project_id: Optional[StrictInt] = None parent_title_de: Optional[StrictStr] = None parent_title_en: Optional[StrictStr] = None - person_roles_order: Optional[StrictStr] = None + person_roles_order: Optional[list[StrictStr]] = None persons: Optional[List[DFGProjectPersonsInner]] = None project: Optional[DFGProjectProject] = None project_id: Optional[StrictInt] = None @@ -72,7 +72,7 @@ class DFGProject(BaseModel): subject_area_de: Optional[StrictStr] = None subject_area_en: Optional[StrictStr] = None subject_classifications: Optional[DFGProjectFachgebieteInner] = None - subproject_order: Optional[StrictStr] = None + subproject_order: Optional[list[StrictStr]] = None subprojects: Optional[List[DFGProjectSubprojectsInner]] = None template_type: Optional[StrictStr] = None title_de: Optional[StrictStr] = None diff --git a/webapp/src/app/api/.openapi-generator/FILES b/webapp/src/app/api/.openapi-generator/FILES index ebf76e14..f91ffcca 100644 --- a/webapp/src/app/api/.openapi-generator/FILES +++ b/webapp/src/app/api/.openapi-generator/FILES @@ -96,7 +96,12 @@ model/dfgInstitutionSummaryPage.ts model/dfgPersonSummary.ts model/dfgPersonSummaryPage.ts model/dfgProjectDetails.ts +model/dfgProjectInstitutionRole.ts model/dfgProjectPage.ts +model/dfgProjectPersonRole.ts +model/dfgProjectPublicationSummary.ts +model/dfgProjectSubjectArea.ts +model/dfgProjectSubprojectSummary.ts model/dfgProjectSummary.ts model/dfgProjectTopic.ts model/dfgProjectTopics.ts diff --git a/webapp/src/app/api/model/dfgProjectDetails.ts b/webapp/src/app/api/model/dfgProjectDetails.ts index 58ece5f7..9e12dbd6 100644 --- a/webapp/src/app/api/model/dfgProjectDetails.ts +++ b/webapp/src/app/api/model/dfgProjectDetails.ts @@ -1,39 +1,82 @@ /** * 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 { DfgProjectPersonRole } from './dfgProjectPersonRole'; +import { DfgProjectSubprojectSummary } from './dfgProjectSubprojectSummary'; +import { DfgProjectInstitutionRole } from './dfgProjectInstitutionRole'; +import { DfgProjectSubjectArea } from './dfgProjectSubjectArea'; +import { DfgProjectPublicationSummary } from './dfgProjectPublicationSummary'; + /** - * Clean summary model for a DFG project, consolidating all person roles and institution references into unified lists. + * Clean, enriched summary model for a DFG project. */ -export interface DfgProjectDetails { - /** - * The ID of the DFG project - */ - id: string; - link?: string | null; - title?: string | null; - description?: string | null; - project_identifier?: string | null; - funding_start_date?: string | null; - funding_end_date?: string | null; - dfg_procedure?: string | null; - subject_area?: string | null; - funding_type?: string | null; - international_reference?: string | null; - website?: string | null; - /** - * All persons associated with the DFG project (any role) - */ - associated_persons?: Array; - /** - * All institutions associated with the DFG project - */ - institutions?: Array; - subproject_of?: string | null; +export interface DfgProjectDetails { + id?: number | null; + link?: string | null; + page_url?: string | null; + external_link?: string | null; + title_de?: string | null; + title_en?: string | null; + description_de?: string | null; + description_en?: string | null; + final_report_abstract_de?: string | null; + final_report_abstract_en?: string | null; + project_identifier_de?: string | null; + project_identifier_en?: string | null; + funding_start?: number | null; + funding_end?: number | null; + funding_period_de?: string | null; + funding_period_en?: string | null; + funding_type_de?: string | null; + funding_type_en?: string | null; + funding_type_key?: string | null; + dfg_procedure?: string | null; + is_transfer_project?: boolean | null; + website_html_de?: string | null; + website_html_en?: string | null; + equipment_group?: string | null; + equipment_name?: string | null; + subject_area_de?: string | null; + subject_area_en?: string | null; + /** + * Detailed DFG subject-area classification entries (Fachsystematik) + */ + subject_classifications?: Array; + international_relation_de?: string | null; + international_relation_en?: string | null; + /** + * All persons associated with the project, each with their role + */ + persons?: Array; + /** + * All institutions associated with the project, each with their role + */ + institutions?: Array; + /** + * Flat, de-duplicated list of all person full names (convenience view) + */ + associated_persons?: Array; + /** + * Flat, de-duplicated list of all institution names (convenience view) + */ + associated_institutions?: Array; + parent_project_id?: number | null; + parent_title_de?: string | null; + parent_title_en?: string | null; + /** + * Sub-projects of this project, if any + */ + subprojects?: Array; + /** + * Publications resulting from the project + */ + publications?: Array; } + diff --git a/webapp/src/app/api/model/dfgProjectInstitutionRole.ts b/webapp/src/app/api/model/dfgProjectInstitutionRole.ts new file mode 100644 index 00000000..2fab6bb9 --- /dev/null +++ b/webapp/src/app/api/model/dfgProjectInstitutionRole.ts @@ -0,0 +1,25 @@ +/** + * 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. + */ + + +/** + * An institution associated with the project, together with its role. + */ +export interface DfgProjectInstitutionRole { + institute_id?: number | null; + name_de?: string | null; + name_en?: string | null; + role_key?: string | null; + role_label_de?: string | null; + role_label_en?: string | null; + is_dissolved?: boolean | null; + is_head?: boolean | null; +} + diff --git a/webapp/src/app/api/model/dfgProjectPage.ts b/webapp/src/app/api/model/dfgProjectPage.ts index a05d81d2..8f67e170 100644 --- a/webapp/src/app/api/model/dfgProjectPage.ts +++ b/webapp/src/app/api/model/dfgProjectPage.ts @@ -1,7 +1,7 @@ /** * Innovation Search Engine API * - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -9,21 +9,23 @@ */ import { DfgProjectSummary } from './dfgProjectSummary'; -export interface DfgProjectPage { - /** - * The current page number. - */ - page?: number; - /** - * The requested page size. - */ - size?: number; - /** - * The total number of items. - */ - total?: number; - /** - * The DFG projects on this page. - */ - elements?: Array; + +export interface DfgProjectPage { + /** + * The current page number. + */ + page?: number; + /** + * The requested page size. + */ + size?: number; + /** + * The total number of items. + */ + total?: number; + /** + * The DFG projects on this page. + */ + elements?: Array; } + diff --git a/webapp/src/app/api/model/dfgProjectPersonRole.ts b/webapp/src/app/api/model/dfgProjectPersonRole.ts new file mode 100644 index 00000000..3b2daecf --- /dev/null +++ b/webapp/src/app/api/model/dfgProjectPersonRole.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. + */ + + +/** + * A person associated with the project, together with their role. + */ +export interface DfgProjectPersonRole { + person_id?: number | null; + full_name?: string | null; + orcid_id?: string | null; + role_key?: string | null; + role_label_de?: string | null; + role_label_en?: string | null; + affiliation_de?: string | null; + affiliation_en?: string | null; + is_deceased?: boolean | null; + is_head?: boolean | null; +} + diff --git a/webapp/src/app/api/model/dfgProjectPublicationSummary.ts b/webapp/src/app/api/model/dfgProjectPublicationSummary.ts new file mode 100644 index 00000000..f9a8692a --- /dev/null +++ b/webapp/src/app/api/model/dfgProjectPublicationSummary.ts @@ -0,0 +1,22 @@ +/** + * 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. + */ + + +/** + * A lightweight reference to a publication resulting from the project. + */ +export interface DfgProjectPublicationSummary { + publication_id?: number | null; + title?: string | null; + authors_editors?: string | null; + doi?: string | null; + publication_year?: number | null; +} + diff --git a/webapp/src/app/api/model/dfgProjectSubjectArea.ts b/webapp/src/app/api/model/dfgProjectSubjectArea.ts new file mode 100644 index 00000000..c46f610d --- /dev/null +++ b/webapp/src/app/api/model/dfgProjectSubjectArea.ts @@ -0,0 +1,21 @@ +/** + * 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. + */ + + +/** + * A single subject-area classification entry (DFG \'Fachsystematik\'). + */ +export interface DfgProjectSubjectArea { + fach?: string | null; + fachgebiet?: string | null; + fachkollegium?: string | null; + wissenschaftsbereich?: string | null; +} + diff --git a/webapp/src/app/api/model/dfgProjectSubprojectSummary.ts b/webapp/src/app/api/model/dfgProjectSubprojectSummary.ts new file mode 100644 index 00000000..d7d75d43 --- /dev/null +++ b/webapp/src/app/api/model/dfgProjectSubprojectSummary.ts @@ -0,0 +1,26 @@ +/** + * 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. + */ + + +/** + * A lightweight reference to a sub-project of this project. + */ +export interface DfgProjectSubprojectSummary { + subproject_id?: number | null; + title_de?: string | null; + title_en?: string | null; + short_title?: string | null; + role_label_de?: string | null; + person_full_name?: string | null; + status_de?: string | null; + funding_start?: number | null; + funding_end?: number | null; +} +