feature/keywords-analysis #282
@@ -1003,13 +1003,13 @@ async def search_eu_cordis_projects(
|
||||
body={
|
||||
"size": size,
|
||||
"from": page * size,
|
||||
"track_total_hits": True,
|
||||
"_source": [
|
||||
"id",
|
||||
"title",
|
||||
"acronym",
|
||||
"objective",
|
||||
"keywords",
|
||||
"topics",
|
||||
"frameworkProgramme",
|
||||
"fundingScheme",
|
||||
"status",
|
||||
@@ -1019,12 +1019,28 @@ async def search_eu_cordis_projects(
|
||||
"totalCost",
|
||||
],
|
||||
"query": query,
|
||||
"highlight": {
|
||||
"fields": {
|
||||
"title": {},
|
||||
"acronym": {},
|
||||
"objective": {},
|
||||
"keywords": {},
|
||||
"topics": {},
|
||||
},
|
||||
"pre_tags": ["<em>"],
|
||||
"post_tags": ["</em>"],
|
||||
"require_field_match": True,
|
||||
},
|
||||
"sort": [
|
||||
{
|
||||
sort_field: {
|
||||
"order": sort_direction,
|
||||
"missing": "_last",
|
||||
"unmapped_type": "keyword" if sort_field.endswith(".keyword") else "date",
|
||||
"unmapped_type": (
|
||||
"keyword"
|
||||
if sort_field.endswith(".keyword")
|
||||
else "date"
|
||||
),
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -1148,7 +1164,6 @@ async def get_eu_cordis_projects_funding_data(
|
||||
while True:
|
||||
body: dict[str, Any] = {
|
||||
"size": page_size,
|
||||
"track_total_hits": False,
|
||||
"_source": ["id", "startDate", "endDate", "ecMaxContribution"],
|
||||
"query": query,
|
||||
"sort": [{"id": {"order": "asc", "unmapped_type": "keyword"}}],
|
||||
|
||||
@@ -128,51 +128,42 @@ async def get_bund_project_ids_by_topic_ids(topic_ids: list[str]) -> list[str]:
|
||||
|
||||
project_topics: dict[str, set[str]] = defaultdict(set)
|
||||
|
||||
page_size = 1000
|
||||
from_ = 0
|
||||
body = {
|
||||
"size": 10000,
|
||||
"_source": ["project_id", "topic_matches"],
|
||||
"query": {
|
||||
"terms": {
|
||||
"topic_matches.topic_id.keyword": topic_ids
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
while True:
|
||||
body = {
|
||||
"size": page_size,
|
||||
"from": from_,
|
||||
"_source": ["project_id", "topic_matches"],
|
||||
"query": {
|
||||
"terms": {
|
||||
"topic_matches.topic_id.keyword": topic_ids
|
||||
}
|
||||
},
|
||||
}
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.PROJECTS_BUND_TOPICS,
|
||||
cluster=ESCluster.INSE,
|
||||
body=body,
|
||||
)
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.PROJECTS_BUND_TOPICS,
|
||||
cluster=ESCluster.INSE,
|
||||
body=body,
|
||||
)
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
if not hits:
|
||||
break
|
||||
|
||||
for hit in hits:
|
||||
source = hit["_source"]
|
||||
for hit in hits:
|
||||
source = hit["_source"]
|
||||
|
||||
project_id = source.get("project_id")
|
||||
if not project_id:
|
||||
continue
|
||||
project_id = source.get("project_id")
|
||||
if not project_id:
|
||||
continue
|
||||
|
||||
topic_matches = source.get("topic_matches") or []
|
||||
topic_matches = source.get("topic_matches") or []
|
||||
|
||||
if isinstance(topic_matches, dict):
|
||||
topic_matches = [topic_matches]
|
||||
if isinstance(topic_matches, dict):
|
||||
topic_matches = [topic_matches]
|
||||
|
||||
for match in topic_matches:
|
||||
topic_id = match.get("topic_id")
|
||||
if topic_id in required_topics:
|
||||
project_topics[project_id].add(topic_id)
|
||||
for match in topic_matches:
|
||||
topic_id = match.get("topic_id")
|
||||
if topic_id in required_topics:
|
||||
project_topics[project_id].add(topic_id)
|
||||
|
||||
if len(hits) < page_size:
|
||||
break
|
||||
|
||||
from_ += page_size
|
||||
|
||||
return [
|
||||
project_id
|
||||
@@ -191,52 +182,43 @@ async def get_dfg_project_ids_by_topic_ids(topic_ids: list[str]) -> list[str]:
|
||||
|
||||
project_topics: dict[str, set[str]] = defaultdict(set)
|
||||
|
||||
page_size = 1000
|
||||
from_ = 0
|
||||
|
||||
while True:
|
||||
body = {
|
||||
"size": page_size,
|
||||
"from": from_,
|
||||
"_source": ["project_id", "topic_matches"],
|
||||
"query": {
|
||||
"terms": {
|
||||
"topic_matches.topic_id.keyword": topic_ids
|
||||
}
|
||||
},
|
||||
}
|
||||
body = {
|
||||
"size": 10000,
|
||||
"_source": ["project_id", "topic_matches"],
|
||||
"query": {
|
||||
"terms": {
|
||||
"topic_matches.topic_id.keyword": topic_ids
|
||||
}
|
||||
},
|
||||
}
|
||||
print("BODY", body)
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.PROJECTS_DFG_TOPICS,
|
||||
cluster=ESCluster.INSE,
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.PROJECTS_DFG_TOPICS,
|
||||
cluster=ESCluster.INSE,
|
||||
body=body,
|
||||
)
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
if not hits:
|
||||
break
|
||||
|
||||
for hit in hits:
|
||||
source = hit["_source"]
|
||||
for hit in hits:
|
||||
source = hit["_source"]
|
||||
|
||||
project_id = source.get("project_id")
|
||||
if not project_id:
|
||||
continue
|
||||
project_id = source.get("project_id")
|
||||
if not project_id:
|
||||
continue
|
||||
|
||||
topic_matches = source.get("topic_matches") or []
|
||||
topic_matches = source.get("topic_matches") or []
|
||||
|
||||
if isinstance(topic_matches, dict):
|
||||
topic_matches = [topic_matches]
|
||||
if isinstance(topic_matches, dict):
|
||||
topic_matches = [topic_matches]
|
||||
|
||||
for match in topic_matches:
|
||||
topic_id = match.get("topic_id")
|
||||
if topic_id in required_topics:
|
||||
project_topics[project_id].add(topic_id)
|
||||
for match in topic_matches:
|
||||
topic_id = match.get("topic_id")
|
||||
if topic_id in required_topics:
|
||||
project_topics[project_id].add(topic_id)
|
||||
|
||||
if len(hits) < page_size:
|
||||
break
|
||||
|
||||
from_ += page_size
|
||||
|
||||
return [
|
||||
project_id
|
||||
@@ -271,17 +253,34 @@ async def get_openalex_topics_for_bund_projects(project_ids: list[str]) -> dict[
|
||||
|
||||
lookup: dict[str, list[dict]] = {}
|
||||
for hit in response.get("hits", {}).get("hits", []):
|
||||
src = hit["_source"]
|
||||
pid = src.get("project_id")
|
||||
if pid:
|
||||
lookup[pid] = src.get("topic_matches", [])
|
||||
return lookup
|
||||
src = hit["_source"]
|
||||
pid = src.get("project_id")
|
||||
|
||||
if not pid:
|
||||
continue
|
||||
|
||||
pid = str(pid)
|
||||
|
||||
if pid not in lookup:
|
||||
lookup[pid] = {}
|
||||
|
||||
for topic in src.get("topic_matches", []):
|
||||
topic_id = topic.get("topic_id")
|
||||
|
||||
if topic_id:
|
||||
lookup[pid][str(topic_id)] = topic
|
||||
|
||||
result = {
|
||||
pid: list(topics.values())
|
||||
for pid, topics in lookup.items()
|
||||
}
|
||||
return result
|
||||
async def get_openalex_topics_for_dfg_projects(
|
||||
project_ids: list[str],
|
||||
) -> dict[str, list[dict]]:
|
||||
"""
|
||||
Retrieve OpenAlex topic details for a list of DFG project IDs.
|
||||
Returns a dict mapping `project_id` -> list of topic_match objects.
|
||||
Retrieve unique OpenAlex topic details for a list of DFG project IDs.
|
||||
Returns a dict mapping `project_id` -> unique list of topic_match objects.
|
||||
"""
|
||||
if not project_ids:
|
||||
return {}
|
||||
@@ -293,23 +292,41 @@ async def get_openalex_topics_for_dfg_projects(
|
||||
"project_id.keyword": project_ids
|
||||
}
|
||||
},
|
||||
"_source": ["project_id", "topic_matches"]
|
||||
"_source": ["project_id", "topic_matches"],
|
||||
}
|
||||
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.PROJECTS_DFG_TOPICS,
|
||||
body=body,
|
||||
cluster=ESCluster.INSE
|
||||
cluster=ESCluster.INSE,
|
||||
)
|
||||
|
||||
lookup: dict[str, list[dict]] = {}
|
||||
lookup: dict[str, dict[str, dict]] = {}
|
||||
|
||||
for hit in response.get("hits", {}).get("hits", []):
|
||||
src = hit["_source"]
|
||||
pid = src.get("project_id")
|
||||
if pid:
|
||||
lookup[str(pid)] = src.get("topic_matches", [])
|
||||
|
||||
return lookup
|
||||
if not pid:
|
||||
continue
|
||||
|
||||
pid = str(pid)
|
||||
|
||||
if pid not in lookup:
|
||||
lookup[pid] = {}
|
||||
|
||||
for topic in src.get("topic_matches", []):
|
||||
topic_id = topic.get("topic_id")
|
||||
|
||||
if topic_id:
|
||||
lookup[pid][str(topic_id)] = topic
|
||||
|
||||
result = {
|
||||
pid: list(topics.values())
|
||||
for pid, topics in lookup.items()
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
async def get_person_institutes(
|
||||
person_ids: list[int],
|
||||
|
||||
@@ -73,7 +73,25 @@ class Page(BaseModel):
|
||||
page: int = Field(default=0, description="The current page number.")
|
||||
size: int = Field(default=20, description="The requested page size.")
|
||||
total: int = Field(default=0, description="The total number of items.")
|
||||
class BundProjectHighlight(BaseModel):
|
||||
"""Highlighted matching fragments from a BUND project search."""
|
||||
|
||||
joint_project: list[str] = Field(
|
||||
default_factory=list,
|
||||
description='Highlights from the Elasticsearch field "Verbundprojekt".',
|
||||
)
|
||||
topic: list[str] = Field(
|
||||
default_factory=list,
|
||||
description='Highlights from the Elasticsearch field "Thema".',
|
||||
)
|
||||
recipient: list[str] = Field(
|
||||
default_factory=list,
|
||||
description='Highlights from the Elasticsearch field "Zuwendungsempfänger".',
|
||||
)
|
||||
implementing_agency: list[str] = Field(
|
||||
default_factory=list,
|
||||
description='Highlights from the Elasticsearch field "Ausführende Stelle".',
|
||||
)
|
||||
class BundProjectSummary(BundProject):
|
||||
oa_topics: list[Topic] | None = Field(
|
||||
default=None,
|
||||
@@ -86,22 +104,34 @@ class BundProjectSummary(BundProject):
|
||||
description="The executing agency / recipient institution for this project, "
|
||||
"derived from the project's own agency fields.",
|
||||
)
|
||||
highlight: BundProjectHighlight | None = Field(
|
||||
default=None,
|
||||
description="Highlighted matching fragments from the project search.",
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_hit(cls, hit: dict) -> "BundProjectSummary":
|
||||
def from_hit(cls, hit: dict[str, Any]) -> "BundProjectSummary":
|
||||
"""Create a BundProjectSummary from an Elasticsearch hit."""
|
||||
|
||||
source = hit.get("_source", {})
|
||||
|
||||
|
||||
|
||||
topics_raw = source.get("oa_topics") or []
|
||||
oa_topics = None
|
||||
if isinstance(topics_raw, list) and topics_raw:
|
||||
|
||||
if isinstance(topics_raw, list) and topics_raw:
|
||||
sorted_topics_raw = sorted(
|
||||
(t for t in topics_raw if isinstance(t, dict)),
|
||||
key=lambda t: t.get("rank") if t.get("rank") is not None else float("inf"),
|
||||
(topic for topic in topics_raw if isinstance(topic, dict)),
|
||||
key=lambda topic: (
|
||||
topic.get("rank")
|
||||
if topic.get("rank") is not None
|
||||
else float("inf")
|
||||
),
|
||||
)
|
||||
oa_topics = [cls._topic_from_match(t) for t in sorted_topics_raw]
|
||||
oa_topics = [
|
||||
cls._topic_from_match(topic)
|
||||
for topic in sorted_topics_raw
|
||||
]
|
||||
|
||||
return cls(
|
||||
funding_code=source.get("Förderkennzeichen"),
|
||||
department=source.get("Ressort"),
|
||||
@@ -119,7 +149,9 @@ class BundProjectSummary(BundProject):
|
||||
implementing_agency=source.get("Ausführende Stelle"),
|
||||
topic=source.get("Thema"),
|
||||
performance_plan_system=source.get("Leistungsplansystematik"),
|
||||
performance_plan_system_text=source.get("Klartext Leistungsplansystematik"),
|
||||
performance_plan_system_text=source.get(
|
||||
"Klartext Leistungsplansystematik"
|
||||
),
|
||||
funding_start=source.get("funding_start"),
|
||||
funding_end=source.get("funding_end"),
|
||||
grant_amount=source.get("Fördersumme"),
|
||||
@@ -133,8 +165,61 @@ class BundProjectSummary(BundProject):
|
||||
duration=source.get("Laufzeit"),
|
||||
oa_topics=oa_topics,
|
||||
institution=BundInstitutionSummary.from_source(source),
|
||||
highlight=cls._highlight_from_hit(hit),
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _highlight_fragments(value: Any) -> list[str]:
|
||||
"""Normalize an Elasticsearch highlight value to a list of strings."""
|
||||
|
||||
if isinstance(value, str):
|
||||
return [value]
|
||||
|
||||
if isinstance(value, list):
|
||||
return [
|
||||
fragment
|
||||
for fragment in value
|
||||
if isinstance(fragment, str)
|
||||
]
|
||||
|
||||
return []
|
||||
|
||||
|
||||
@classmethod
|
||||
def _highlight_from_hit(
|
||||
cls,
|
||||
hit: dict[str, Any],
|
||||
) -> BundProjectHighlight | None:
|
||||
"""Extract BUND project highlights from an Elasticsearch hit."""
|
||||
|
||||
raw_highlight = hit.get("highlight")
|
||||
if not isinstance(raw_highlight, dict):
|
||||
return None
|
||||
|
||||
highlight = BundProjectHighlight(
|
||||
joint_project=cls._highlight_fragments(
|
||||
raw_highlight.get("Verbundprojekt")
|
||||
),
|
||||
topic=cls._highlight_fragments(
|
||||
raw_highlight.get("Thema")
|
||||
),
|
||||
recipient=cls._highlight_fragments(
|
||||
raw_highlight.get("Zuwendungsempfänger")
|
||||
),
|
||||
implementing_agency=cls._highlight_fragments(
|
||||
raw_highlight.get("Ausführende Stelle")
|
||||
),
|
||||
)
|
||||
|
||||
has_highlights = any(
|
||||
(
|
||||
highlight.joint_project,
|
||||
highlight.topic,
|
||||
highlight.recipient,
|
||||
highlight.implementing_agency,
|
||||
)
|
||||
)
|
||||
|
||||
return highlight if has_highlights else None
|
||||
@staticmethod
|
||||
def _topic_from_match(match: dict[str, Any]) -> Topic:
|
||||
"""Builds a Topic model from a flattened topic_match dict.
|
||||
@@ -163,16 +248,42 @@ class BundProjectPage(Page):
|
||||
default_factory=list, description="The bund projects on this page."
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
class BundProjectList(BaseModel):
|
||||
elements: list[BundProjectSummary] = Field(
|
||||
default_factory=list, description="All bund projects."
|
||||
)
|
||||
total: int = Field(default=0, description="The total number of bund projects.")
|
||||
class DfgSubjectClassificationHighlight(BaseModel):
|
||||
"""A highlighted nested subject classification."""
|
||||
|
||||
|
||||
query: str = Field(
|
||||
description="The keyword/inner_hits group which produced this match.",
|
||||
)
|
||||
|
||||
offset: int | None = Field(
|
||||
default=None,
|
||||
description="Index of the matched item in subject_classifications.",
|
||||
)
|
||||
|
||||
fach: list[str] = Field(default_factory=list)
|
||||
fachkollegium: list[str] = Field(default_factory=list)
|
||||
fachgebiet: list[str] = Field(default_factory=list)
|
||||
fachgebiet_de: list[str] = Field(default_factory=list)
|
||||
wissenschaftsbereich: list[str] = Field(default_factory=list)
|
||||
|
||||
|
||||
class DfgProjectHighlight(BaseModel):
|
||||
"""Highlighted fragments returned for a DFG project."""
|
||||
|
||||
title_de: list[str] = Field(default_factory=list)
|
||||
title_en: list[str] = Field(default_factory=list)
|
||||
|
||||
abstract_de: list[str] = Field(default_factory=list)
|
||||
abstract_en: list[str] = Field(default_factory=list)
|
||||
|
||||
subject_classifications: list[DfgSubjectClassificationHighlight] = Field(
|
||||
default_factory=list,
|
||||
)
|
||||
class DfgInstitutionSummary(BaseModel):
|
||||
"""A summary of a DFG institution."""
|
||||
id: int
|
||||
@@ -205,16 +316,22 @@ class DfgProjectSummary(BaseModel):
|
||||
description="The link to the DFG project details."
|
||||
)
|
||||
|
||||
title: str | None = Field(
|
||||
title_de: str | None = Field(
|
||||
default=None,
|
||||
description="The title of the DFG project."
|
||||
description="The title of the DFG project in German."
|
||||
)
|
||||
|
||||
professional_classification: str | None = Field(
|
||||
title_en: str | None = Field(
|
||||
default=None,
|
||||
description="The professional classification of the DFG project."
|
||||
description="The title of the DFG project in English."
|
||||
)
|
||||
|
||||
|
||||
subject_classifications_raw: str | None = Field(
|
||||
default=None,
|
||||
description="The subject classifications of the DFG project."
|
||||
)
|
||||
abstract_de: str | None = Field( default=None, description="The abstract of the DFG project in German.")
|
||||
abstract_en: str | None = Field( default=None, description="The abstract of the DFG project in English.")
|
||||
|
||||
funding_start: str | None = Field(
|
||||
default=None,
|
||||
@@ -246,11 +363,17 @@ class DfgProjectSummary(BaseModel):
|
||||
default=None,
|
||||
description="The topics associated with the DFG project.",
|
||||
)
|
||||
highlight: DfgProjectHighlight | None = Field(
|
||||
default=None,
|
||||
description="Highlighted matching fragments.",
|
||||
)
|
||||
@classmethod
|
||||
def from_hit(cls, hit: dict) -> "DfgProjectSummary":
|
||||
source = hit.get("_source", {})
|
||||
fields = hit.get("fields", {})
|
||||
|
||||
|
||||
source_id = source.get("id")
|
||||
project_id = source_id if source_id is not None else hit.get("_id", "")
|
||||
|
||||
names = []
|
||||
institutions = {}
|
||||
project_persons = []
|
||||
@@ -338,7 +461,6 @@ class DfgProjectSummary(BaseModel):
|
||||
)
|
||||
)
|
||||
topics_raw = source.get("topics") or []
|
||||
print(f"Raw topics for DFG project {hit.get('_id', '')}: {topics_raw}")
|
||||
topics = None
|
||||
if isinstance(topics_raw, list) and topics_raw:
|
||||
# Sort by rank if present, so the most relevant topic comes first
|
||||
@@ -348,34 +470,51 @@ class DfgProjectSummary(BaseModel):
|
||||
)
|
||||
topics = [cls._topic_from_match(t) for t in sorted_topics_raw]
|
||||
|
||||
|
||||
subject_classifications = source.get("subject_classifications")
|
||||
if not isinstance(subject_classifications, list):
|
||||
subject_classifications = []
|
||||
|
||||
return cls(
|
||||
id=hit.get("_id", ""),
|
||||
id=str(project_id),
|
||||
|
||||
link=source.get("link") or source.get("page_url"),
|
||||
title=(
|
||||
source.get("title")
|
||||
or source.get("title_de")
|
||||
or source.get("title_en")
|
||||
),
|
||||
professional_classification=(
|
||||
source.get("Fachliche Zuordnung")
|
||||
or source.get("subject_area_de")
|
||||
page_url=source.get("page_url"),
|
||||
|
||||
title_de=source.get("title_de"),
|
||||
title_en=source.get("title_en"),
|
||||
|
||||
abstract_de=source.get("abstract_de"),
|
||||
abstract_en=source.get("abstract_en"),
|
||||
|
||||
subject_classifications_raw=(
|
||||
source.get("subject_area_de")
|
||||
or source.get("subject_area_en")
|
||||
),
|
||||
|
||||
funding_start=(
|
||||
str(source.get("funding_start"))
|
||||
str(source["funding_start"])
|
||||
if source.get("funding_start") is not None
|
||||
else None
|
||||
),
|
||||
funding_end=(
|
||||
str(source.get("funding_end"))
|
||||
str(source["funding_end"])
|
||||
if source.get("funding_end") is not None
|
||||
else None
|
||||
),
|
||||
|
||||
institutions=list(institutions.values()),
|
||||
names=names,
|
||||
persons=project_persons,
|
||||
subject_classifications=[DFGProjectFachgebieteInner.from_dict(cls) for cls in source.get('subject_classifications', [])],
|
||||
topics=topics
|
||||
|
||||
subject_classifications=[
|
||||
DFGProjectFachgebieteInner.from_dict(classification)
|
||||
for classification in subject_classifications
|
||||
if isinstance(classification, dict)
|
||||
],
|
||||
|
||||
topics=topics or [],
|
||||
highlight=cls._highlight_from_hit(hit),
|
||||
)
|
||||
@staticmethod
|
||||
def _topic_from_match(match: dict[str, Any]) -> Topic:
|
||||
@@ -412,13 +551,146 @@ class DfgProjectSummary(BaseModel):
|
||||
field=field,
|
||||
subfield=subfield,
|
||||
)
|
||||
@staticmethod
|
||||
def _highlight_fragments(value: Any) -> list[str]:
|
||||
"""Normalize an Elasticsearch highlight value."""
|
||||
|
||||
if isinstance(value, str):
|
||||
return [value]
|
||||
|
||||
if isinstance(value, list):
|
||||
return [
|
||||
fragment
|
||||
for fragment in value
|
||||
if isinstance(fragment, str)
|
||||
]
|
||||
|
||||
return []
|
||||
|
||||
|
||||
@classmethod
|
||||
def _highlight_from_hit(
|
||||
cls,
|
||||
hit: dict[str, Any],
|
||||
) -> DfgProjectHighlight | None:
|
||||
"""Parse top-level and nested highlights from an Elasticsearch hit."""
|
||||
|
||||
raw_highlight = hit.get("highlight")
|
||||
if not isinstance(raw_highlight, dict):
|
||||
raw_highlight = {}
|
||||
|
||||
result = DfgProjectHighlight(
|
||||
title_de=cls._highlight_fragments(
|
||||
raw_highlight.get("title_de")
|
||||
),
|
||||
title_en=cls._highlight_fragments(
|
||||
raw_highlight.get("title_en")
|
||||
),
|
||||
abstract_de=cls._highlight_fragments(
|
||||
raw_highlight.get("abstract_de")
|
||||
),
|
||||
abstract_en=cls._highlight_fragments(
|
||||
raw_highlight.get("abstract_en")
|
||||
),
|
||||
)
|
||||
|
||||
raw_inner_hits = hit.get("inner_hits")
|
||||
|
||||
if isinstance(raw_inner_hits, dict):
|
||||
for query_name, inner_hit_group in raw_inner_hits.items():
|
||||
if not isinstance(inner_hit_group, dict):
|
||||
continue
|
||||
|
||||
inner_hits_block = inner_hit_group.get("hits")
|
||||
if not isinstance(inner_hits_block, dict):
|
||||
continue
|
||||
|
||||
nested_hits = inner_hits_block.get("hits", [])
|
||||
if not isinstance(nested_hits, list):
|
||||
continue
|
||||
|
||||
for nested_hit in nested_hits:
|
||||
if not isinstance(nested_hit, dict):
|
||||
continue
|
||||
|
||||
nested_highlight = nested_hit.get("highlight")
|
||||
if not isinstance(nested_highlight, dict):
|
||||
continue
|
||||
|
||||
nested_metadata = nested_hit.get("_nested")
|
||||
offset = None
|
||||
|
||||
if isinstance(nested_metadata, dict):
|
||||
raw_offset = nested_metadata.get("offset")
|
||||
if isinstance(raw_offset, int):
|
||||
offset = raw_offset
|
||||
|
||||
parsed_nested_highlight = (
|
||||
DfgSubjectClassificationHighlight(
|
||||
query=str(query_name),
|
||||
offset=offset,
|
||||
fach=cls._highlight_fragments(
|
||||
nested_highlight.get(
|
||||
"subject_classifications.fach"
|
||||
)
|
||||
),
|
||||
fachkollegium=cls._highlight_fragments(
|
||||
nested_highlight.get(
|
||||
"subject_classifications.fachkollegium"
|
||||
)
|
||||
),
|
||||
fachgebiet=cls._highlight_fragments(
|
||||
nested_highlight.get(
|
||||
"subject_classifications.fachgebiet"
|
||||
)
|
||||
),
|
||||
fachgebiet_de=cls._highlight_fragments(
|
||||
nested_highlight.get(
|
||||
"subject_classifications.fachgebiet_de"
|
||||
)
|
||||
),
|
||||
wissenschaftsbereich=cls._highlight_fragments(
|
||||
nested_highlight.get(
|
||||
"subject_classifications."
|
||||
"wissenschaftsbereich"
|
||||
)
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
# Do not expose empty nested highlight objects.
|
||||
has_nested_fragments = any(
|
||||
(
|
||||
parsed_nested_highlight.fach,
|
||||
parsed_nested_highlight.fachkollegium,
|
||||
parsed_nested_highlight.fachgebiet,
|
||||
parsed_nested_highlight.fachgebiet_de,
|
||||
parsed_nested_highlight.wissenschaftsbereich,
|
||||
)
|
||||
)
|
||||
|
||||
if has_nested_fragments:
|
||||
result.subject_classifications.append(
|
||||
parsed_nested_highlight
|
||||
)
|
||||
|
||||
has_highlights = any(
|
||||
(
|
||||
result.title_de,
|
||||
result.title_en,
|
||||
result.abstract_de,
|
||||
result.abstract_en,
|
||||
result.subject_classifications,
|
||||
)
|
||||
)
|
||||
|
||||
return result if has_highlights else None
|
||||
|
||||
class DfgProjectPage(Page):
|
||||
elements: list[DfgProjectSummary] = Field(
|
||||
default_factory=list, description="The DFG projects on this page."
|
||||
)
|
||||
|
||||
|
||||
class InstitutionFunderSummary(BaseModel):
|
||||
type: ProjectType = Field(
|
||||
description="The type of funding data (e.g., 'bund', 'eu', 'dfg')."
|
||||
@@ -706,7 +978,20 @@ class EuCordisEurosciVocSummary(BaseModel):
|
||||
description=source.get("description"),
|
||||
path=source.get("path"),
|
||||
)
|
||||
class EuCordisProjectHighlight(BaseModel):
|
||||
"""Highlighted fragments returned by Elasticsearch."""
|
||||
|
||||
title: list[str] = Field(default_factory=list)
|
||||
acronym: list[str] = Field(default_factory=list)
|
||||
objective: list[str] = Field(default_factory=list)
|
||||
keywords: list[str] = Field(default_factory=list)
|
||||
|
||||
# Elasticsearch source/highlight field is "topics", but "topics" is already
|
||||
# used by the API model for mapped OpenAlex Topic objects.
|
||||
cordis_topic_text: list[str] = Field(
|
||||
default_factory=list,
|
||||
description="Highlighted fragments from the CORDIS topics text field.",
|
||||
)
|
||||
|
||||
class EuCordisProjectSummary(BaseModel):
|
||||
id: str
|
||||
@@ -731,7 +1016,18 @@ class EuCordisProjectSummary(BaseModel):
|
||||
cordis_topics: list[EuCordisTopicSummary] = Field(default_factory=list)
|
||||
eurosci_voc: list[EuCordisEurosciVocSummary] = Field(default_factory=list)
|
||||
topics: list[Topic] = Field(default_factory=list, description="Mapped OpenAlex topics.")
|
||||
|
||||
cordis_topic_text: str | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"Original CORDIS topics text from the Elasticsearch project "
|
||||
"document, for example 'MSCA-IF-2018'."
|
||||
),
|
||||
)
|
||||
highlight: EuCordisProjectHighlight | None = Field(
|
||||
default=None,
|
||||
description="Highlighted matching fragments from the project search.",
|
||||
)
|
||||
@classmethod
|
||||
@classmethod
|
||||
def from_hit(
|
||||
cls,
|
||||
@@ -743,16 +1039,23 @@ class EuCordisProjectSummary(BaseModel):
|
||||
topics: list[Topic] | None = None,
|
||||
) -> "EuCordisProjectSummary":
|
||||
source = hit.get("_source", {})
|
||||
project_type = EuCordisProjectType.from_index_name(hit.get("_index", ""))
|
||||
project_type = EuCordisProjectType.from_index_name(
|
||||
hit.get("_index", "")
|
||||
)
|
||||
|
||||
project_id = source.get("id")
|
||||
if project_id is None:
|
||||
project_id = hit.get("_id", "")
|
||||
|
||||
return cls(
|
||||
id=source.get("id") or hit.get("_id", ""),
|
||||
id=str(project_id),
|
||||
project_type=project_type,
|
||||
|
||||
title=source.get("title"),
|
||||
acronym=source.get("acronym"),
|
||||
objective=source.get("objective"),
|
||||
keywords=source.get("keywords"),
|
||||
cordis_topic_text=source.get("topics"),
|
||||
|
||||
framework_programme=source.get("frameworkProgramme"),
|
||||
funding_scheme=source.get("fundingScheme"),
|
||||
@@ -764,13 +1067,71 @@ class EuCordisProjectSummary(BaseModel):
|
||||
ec_max_contribution=source.get("ecMaxContribution"),
|
||||
total_cost=source.get("totalCost"),
|
||||
|
||||
authors=authors or None,
|
||||
authors=authors,
|
||||
organizations=organizations or [],
|
||||
cordis_topics=cordis_topics or [],
|
||||
eurosci_voc=eurosci_voc or [],
|
||||
topics=topics or [],
|
||||
|
||||
highlight=cls._highlight_from_hit(hit),
|
||||
)
|
||||
@staticmethod
|
||||
def _highlight_fragments(value: Any) -> list[str]:
|
||||
"""Normalize an Elasticsearch highlight value to a list of strings."""
|
||||
|
||||
if isinstance(value, str):
|
||||
return [value]
|
||||
|
||||
if isinstance(value, list):
|
||||
return [
|
||||
fragment
|
||||
for fragment in value
|
||||
if isinstance(fragment, str)
|
||||
]
|
||||
|
||||
return []
|
||||
|
||||
|
||||
@classmethod
|
||||
def _highlight_from_hit(
|
||||
cls,
|
||||
hit: dict[str, Any],
|
||||
) -> EuCordisProjectHighlight | None:
|
||||
"""Extract project highlights from an Elasticsearch hit."""
|
||||
|
||||
raw_highlight = hit.get("highlight")
|
||||
if not isinstance(raw_highlight, dict):
|
||||
return None
|
||||
|
||||
highlight = EuCordisProjectHighlight(
|
||||
title=cls._highlight_fragments(
|
||||
raw_highlight.get("title")
|
||||
),
|
||||
acronym=cls._highlight_fragments(
|
||||
raw_highlight.get("acronym")
|
||||
),
|
||||
objective=cls._highlight_fragments(
|
||||
raw_highlight.get("objective")
|
||||
),
|
||||
keywords=cls._highlight_fragments(
|
||||
raw_highlight.get("keywords")
|
||||
),
|
||||
cordis_topic_text=cls._highlight_fragments(
|
||||
raw_highlight.get("topics")
|
||||
),
|
||||
)
|
||||
|
||||
has_highlights = any(
|
||||
(
|
||||
highlight.title,
|
||||
highlight.acronym,
|
||||
highlight.objective,
|
||||
highlight.keywords,
|
||||
highlight.cordis_topic_text,
|
||||
)
|
||||
)
|
||||
|
||||
return highlight if has_highlights else None
|
||||
@staticmethod
|
||||
def topic_from_match(match: dict[str, Any]) -> Topic:
|
||||
domain_name = match.get("domain")
|
||||
|
||||
@@ -100,7 +100,6 @@ async def search_bund_projects(
|
||||
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.PROJECTS_BUND_V1,
|
||||
track_total_hits=True,
|
||||
query=query,
|
||||
sort=sort,
|
||||
size=filter_properties.size,
|
||||
@@ -401,7 +400,6 @@ async def search_dfg_projects(
|
||||
body: dict[str, Any] = {
|
||||
"size": size,
|
||||
"from": from_,
|
||||
"track_total_hits": True,
|
||||
"_source": [
|
||||
"id",
|
||||
"link",
|
||||
@@ -409,9 +407,10 @@ async def search_dfg_projects(
|
||||
"title",
|
||||
"title_de",
|
||||
"title_en",
|
||||
"abstract_de",
|
||||
"abstract_en",
|
||||
"funding_start",
|
||||
"funding_end",
|
||||
"Fachliche Zuordnung",
|
||||
"subject_area_de",
|
||||
"subject_area_en",
|
||||
"persons",
|
||||
@@ -441,23 +440,57 @@ async def search_dfg_projects(
|
||||
if keyword.strip() == "":
|
||||
continue
|
||||
keyword_clauses.append(
|
||||
{
|
||||
"multi_match": {
|
||||
"query": keyword,
|
||||
"fields": [
|
||||
"title", "title_de", "title_en",
|
||||
"abstract_de", "abstract_en",
|
||||
"subject_area_de", "subject_area_en",
|
||||
"subject_classifications.fach",
|
||||
"subject_classifications.fachkollegium",
|
||||
"subject_classifications.fachgebiet",
|
||||
"subject_classifications.fachgebiet_de",
|
||||
"subject_classifications.wissenschaftsbereich",
|
||||
],
|
||||
"type": "phrase_prefix",
|
||||
"max_expansions": 100,
|
||||
}
|
||||
{
|
||||
"bool": {
|
||||
"should": [
|
||||
{
|
||||
"multi_match": {
|
||||
"query": keyword,
|
||||
"fields": [
|
||||
"title_de",
|
||||
"title_en",
|
||||
"abstract_de",
|
||||
"abstract_en",
|
||||
],
|
||||
"type": "phrase_prefix",
|
||||
"max_expansions": 100,
|
||||
}
|
||||
},
|
||||
{
|
||||
"nested": {
|
||||
"path": "subject_classifications",
|
||||
"query": {
|
||||
"multi_match": {
|
||||
"query": keyword,
|
||||
"fields": [
|
||||
"subject_classifications.fach",
|
||||
"subject_classifications.fachkollegium",
|
||||
"subject_classifications.fachgebiet",
|
||||
"subject_classifications.fachgebiet_de",
|
||||
"subject_classifications.wissenschaftsbereich",
|
||||
],
|
||||
"type": "phrase_prefix",
|
||||
"max_expansions": 100,
|
||||
}
|
||||
},
|
||||
"inner_hits": {
|
||||
"name": keyword,
|
||||
"highlight": {
|
||||
"fields": {
|
||||
"subject_classifications.fach": {},
|
||||
"subject_classifications.fachkollegium": {},
|
||||
"subject_classifications.fachgebiet": {},
|
||||
"subject_classifications.fachgebiet_de": {},
|
||||
"subject_classifications.wissenschaftsbereich": {},
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
}
|
||||
)
|
||||
if keyword_clauses:
|
||||
must_clauses.append({"bool": {"must": keyword_clauses}})
|
||||
@@ -553,7 +586,7 @@ async def search_dfg_projects(
|
||||
}
|
||||
}
|
||||
)
|
||||
print("MATCHING_INSTITUTION_IDS", matching_institution_ids)
|
||||
#print("MATCHING_INSTITUTION_IDS", matching_institution_ids)
|
||||
|
||||
if institution_ids:
|
||||
#prevously we were filtering by person_ids, but now we are filtering by institution_ids directly
|
||||
@@ -605,14 +638,28 @@ async def search_dfg_projects(
|
||||
sort_config = {"id": {"order": sort_direction}}
|
||||
|
||||
body["sort"] = [sort_config]
|
||||
|
||||
#Add highlighting for the title and abstract fields
|
||||
body["highlight"] = {
|
||||
"fields": {
|
||||
"title_de": {},
|
||||
"title_en": {},
|
||||
"abstract_de": {},
|
||||
"abstract_en": {},
|
||||
},
|
||||
"pre_tags": ["<em>"],
|
||||
"post_tags": ["</em>"],
|
||||
"require_field_match": True,
|
||||
}
|
||||
# print(f"Executing DFG project search with body: {json.dumps(body, indent=2)}")
|
||||
# === Execute Search ===
|
||||
# print(f"Executing DFG project search with body: {body}")
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.DFG_PROJECTS,
|
||||
body=body,
|
||||
cluster=ESCluster.INSE,
|
||||
)
|
||||
|
||||
# print(f"Received DFG project search response: {response}")
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
|
||||
if skip_enrichment:
|
||||
@@ -1037,13 +1084,24 @@ async def search_bund_projects_with_filters(
|
||||
sort_config = {"Förderkennzeichen.keyword": {"order": sort_direction}}
|
||||
|
||||
body["sort"] = [sort_config]
|
||||
#Add highlighting for the title and abstract fields
|
||||
body["highlight"] = {
|
||||
"fields": {
|
||||
"Verbundprojekt": {},
|
||||
"Thema": {},
|
||||
"Zuwendungsempfänger": {},
|
||||
"Ausführende Stelle": {},
|
||||
},
|
||||
"pre_tags": ["<em>"],
|
||||
"post_tags": ["</em>"],
|
||||
"require_field_match": True,
|
||||
}
|
||||
# print(f"Executing BUND project search with body: {json.dumps(body, indent=2)}")
|
||||
# === Execute Search ===
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.PROJECTS_BUND_V1,
|
||||
body=body,
|
||||
cluster=ESCluster.INSE,
|
||||
track_total_hits=True,
|
||||
)
|
||||
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
@@ -1177,7 +1235,6 @@ async def search_all_projects(
|
||||
offset=offset,
|
||||
query=query,
|
||||
sort=sort,
|
||||
track_total_hits=True,
|
||||
)
|
||||
return _response_to_funding_project_page(response=response, page=page, size=size)
|
||||
|
||||
|
||||
@@ -73,8 +73,10 @@ model/bodyResetPassword.ts
|
||||
model/bundInstitutionSummary.ts
|
||||
model/bundInstitutionSummaryPage.ts
|
||||
model/bundProjectDetails.ts
|
||||
model/bundProjectHighlight.ts
|
||||
model/bundProjectPage.ts
|
||||
model/bundProjectSummary.ts
|
||||
model/bundProjectTopics.ts
|
||||
model/careerMetrics.ts
|
||||
model/careerStage.ts
|
||||
model/collaborationGraph.ts
|
||||
@@ -102,6 +104,7 @@ model/dfgInstitutionSummaryPage.ts
|
||||
model/dfgPersonSummary.ts
|
||||
model/dfgPersonSummaryPage.ts
|
||||
model/dfgProjectDetails.ts
|
||||
model/dfgProjectHighlight.ts
|
||||
model/dfgProjectInstitutionRole.ts
|
||||
model/dfgProjectKeyword.ts
|
||||
model/dfgProjectPage.ts
|
||||
@@ -112,12 +115,17 @@ model/dfgProjectSubprojectSummary.ts
|
||||
model/dfgProjectSummary.ts
|
||||
model/dfgProjectTopic.ts
|
||||
model/dfgProjectTopics.ts
|
||||
model/dfgSubjectClassificationHighlight.ts
|
||||
model/dockerHealth.ts
|
||||
model/domain.ts
|
||||
model/domainFieldsInner.ts
|
||||
model/domainIds.ts
|
||||
model/edge.ts
|
||||
model/euCordisEurosciVocSummary.ts
|
||||
model/euCordisOrganizationSelectorPage.ts
|
||||
model/euCordisOrganizationSelectorSummary.ts
|
||||
model/euCordisOrganizationSummary.ts
|
||||
model/euCordisProjectHighlight.ts
|
||||
model/euCordisProjectResponse.ts
|
||||
model/euCordisProjectSearchPage.ts
|
||||
model/euCordisProjectSummary.ts
|
||||
@@ -125,6 +133,7 @@ model/euCordisProjectType.ts
|
||||
model/euCordisTopicSummary.ts
|
||||
model/euProjectData.ts
|
||||
model/euProjectStatusStatistics.ts
|
||||
model/euProjectTopics.ts
|
||||
model/extractedKeywords.ts
|
||||
model/extractedKeywordsLLM.ts
|
||||
model/extractedKeywordsResponse.ts
|
||||
@@ -209,6 +218,7 @@ model/matchedTopic.ts
|
||||
model/mentionedPerson.ts
|
||||
model/meta.ts
|
||||
model/model2YrMeanCitedness.ts
|
||||
model/modelField.ts
|
||||
model/models.ts
|
||||
model/newsArticle.ts
|
||||
model/newsArticleDetail.ts
|
||||
@@ -244,10 +254,14 @@ model/score.ts
|
||||
model/selectedAuthorsRequest.ts
|
||||
model/sortDirection.ts
|
||||
model/startCollaborationGraphResponse.ts
|
||||
model/subfield.ts
|
||||
model/subfieldDomain.ts
|
||||
model/subfieldField.ts
|
||||
model/subfieldShare.ts
|
||||
model/timespan.ts
|
||||
model/tokenType.ts
|
||||
model/topAuthor.ts
|
||||
model/topAuthorAnalysis.ts
|
||||
model/topAuthorStatistics.ts
|
||||
model/topInstitutionItem.ts
|
||||
model/topTopicItem.ts
|
||||
|
||||
@@ -25,6 +25,8 @@ import { Observable } from 'rxjs';
|
||||
// @ts-ignore
|
||||
import { BmbfProjectStatusStatistics } from '../model/bmbfProjectStatusStatistics';
|
||||
// @ts-ignore
|
||||
import { BundProjectTopics } from '../model/bundProjectTopics';
|
||||
// @ts-ignore
|
||||
import { DashboardStatisticValue } from '../model/dashboardStatisticValue';
|
||||
// @ts-ignore
|
||||
import { DashboardStatistics } from '../model/dashboardStatistics';
|
||||
@@ -35,8 +37,12 @@ import { DfgProjectTopics } from '../model/dfgProjectTopics';
|
||||
// @ts-ignore
|
||||
import { EuProjectStatusStatistics } from '../model/euProjectStatusStatistics';
|
||||
// @ts-ignore
|
||||
import { EuProjectTopics } from '../model/euProjectTopics';
|
||||
// @ts-ignore
|
||||
import { HTTPValidationError } from '../model/hTTPValidationError';
|
||||
// @ts-ignore
|
||||
import { TopAuthorAnalysis } from '../model/topAuthorAnalysis';
|
||||
// @ts-ignore
|
||||
import { TopAuthorStatistics } from '../model/topAuthorStatistics';
|
||||
// @ts-ignore
|
||||
import { TopicHeatmap } from '../model/topicHeatmap';
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Highlighted matching fragments from a BUND project search.
|
||||
*/
|
||||
export interface BundProjectHighlight {
|
||||
/**
|
||||
* Highlights from the Elasticsearch field \"Verbundprojekt\".
|
||||
*/
|
||||
joint_project?: Array<string>;
|
||||
/**
|
||||
* Highlights from the Elasticsearch field \"Thema\".
|
||||
*/
|
||||
topic?: Array<string>;
|
||||
/**
|
||||
* Highlights from the Elasticsearch field \"Zuwendungsempfänger\".
|
||||
*/
|
||||
recipient?: Array<string>;
|
||||
/**
|
||||
* Highlights from the Elasticsearch field \"Ausführende Stelle\".
|
||||
*/
|
||||
implementing_agency?: Array<string>;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { BundProjectHighlight } from './bundProjectHighlight';
|
||||
import { Topic } from './topic';
|
||||
import { BundInstitutionSummary } from './bundInstitutionSummary';
|
||||
|
||||
@@ -41,4 +42,5 @@ export interface BundProjectSummary {
|
||||
duration?: string | null;
|
||||
oa_topics?: Array<Topic> | null;
|
||||
institution?: BundInstitutionSummary | null;
|
||||
highlight?: BundProjectHighlight | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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 { DfgProjectTopic } from './dfgProjectTopic';
|
||||
|
||||
|
||||
export interface BundProjectTopics {
|
||||
institution_id: string;
|
||||
organization_name: string;
|
||||
project_count: number;
|
||||
matched_project_count: number;
|
||||
topics: Array<DfgProjectTopic>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 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 { DfgSubjectClassificationHighlight } from './dfgSubjectClassificationHighlight';
|
||||
|
||||
|
||||
/**
|
||||
* Highlighted fragments returned for a DFG project.
|
||||
*/
|
||||
export interface DfgProjectHighlight {
|
||||
title_de?: Array<string>;
|
||||
title_en?: Array<string>;
|
||||
abstract_de?: Array<string>;
|
||||
abstract_en?: Array<string>;
|
||||
subject_classifications?: Array<DfgSubjectClassificationHighlight>;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
import { DfgInstitutionSummary } from './dfgInstitutionSummary';
|
||||
import { DFGProjectFachgebieteInner } from './dFGProjectFachgebieteInner';
|
||||
import { DfgProjectHighlight } from './dfgProjectHighlight';
|
||||
import { Topic } from './topic';
|
||||
import { DfgPersonSummary } from './dfgPersonSummary';
|
||||
|
||||
@@ -19,8 +20,11 @@ export interface DfgProjectSummary {
|
||||
*/
|
||||
id: string;
|
||||
link?: string | null;
|
||||
title?: string | null;
|
||||
professional_classification?: string | null;
|
||||
title_de?: string | null;
|
||||
title_en?: string | null;
|
||||
subject_classifications_raw?: string | null;
|
||||
abstract_de?: string | null;
|
||||
abstract_en?: string | null;
|
||||
funding_start?: string | null;
|
||||
funding_end?: string | null;
|
||||
/**
|
||||
@@ -37,5 +41,6 @@ export interface DfgProjectSummary {
|
||||
persons?: Array<DfgPersonSummary>;
|
||||
subject_classifications?: Array<DFGProjectFachgebieteInner> | null;
|
||||
topics?: Array<Topic> | null;
|
||||
highlight?: DfgProjectHighlight | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,5 +16,7 @@ export interface DfgProjectTopic {
|
||||
field?: string | null;
|
||||
domain?: string | null;
|
||||
project_count: number;
|
||||
field_project_count: number;
|
||||
subfield_project_count: number;
|
||||
keywords: Array<DfgProjectKeyword>;
|
||||
}
|
||||
|
||||
@@ -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 highlighted nested subject classification.
|
||||
*/
|
||||
export interface DfgSubjectClassificationHighlight {
|
||||
/**
|
||||
* The keyword/inner_hits group which produced this match.
|
||||
*/
|
||||
query: string;
|
||||
offset?: number | null;
|
||||
fach?: Array<string>;
|
||||
fachkollegium?: Array<string>;
|
||||
fachgebiet?: Array<string>;
|
||||
fachgebiet_de?: Array<string>;
|
||||
wissenschaftsbereich?: Array<string>;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Highlighted fragments returned by Elasticsearch.
|
||||
*/
|
||||
export interface EuCordisProjectHighlight {
|
||||
title?: Array<string>;
|
||||
acronym?: Array<string>;
|
||||
objective?: Array<string>;
|
||||
keywords?: Array<string>;
|
||||
/**
|
||||
* Highlighted fragments from the CORDIS topics text field.
|
||||
*/
|
||||
cordis_topic_text?: Array<string>;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
import { EuCordisTopicSummary } from './euCordisTopicSummary';
|
||||
import { AuthorPage } from './authorPage';
|
||||
import { EuCordisProjectHighlight } from './euCordisProjectHighlight';
|
||||
import { EuCordisEurosciVocSummary } from './euCordisEurosciVocSummary';
|
||||
import { Topic } from './topic';
|
||||
import { EuCordisOrganizationSummary } from './euCordisOrganizationSummary';
|
||||
@@ -37,6 +38,8 @@ export interface EuCordisProjectSummary {
|
||||
* Mapped OpenAlex topics.
|
||||
*/
|
||||
topics?: Array<Topic>;
|
||||
cordis_topic_text?: string | null;
|
||||
highlight?: EuCordisProjectHighlight | null;
|
||||
}
|
||||
export namespace EuCordisProjectSummary {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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 { DfgProjectTopic } from './dfgProjectTopic';
|
||||
|
||||
|
||||
export interface EuProjectTopics {
|
||||
institution_id: string;
|
||||
organization_name: string;
|
||||
project_count: number;
|
||||
matched_project_count: number;
|
||||
topics: Array<DfgProjectTopic>;
|
||||
}
|
||||
|
||||
@@ -1,31 +1,33 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { WorkTopicDomain } from './workTopicDomain';
|
||||
import { DomainFieldsInner } from './domainFieldsInner';
|
||||
import { DomainIds } from './domainIds';
|
||||
import { WorkTopicDomain } from './workTopicDomain';
|
||||
|
||||
|
||||
/**
|
||||
* Second-level category in the topic hierarchy (26 total)
|
||||
*/
|
||||
export interface ModelField {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
description?: string | null;
|
||||
display_name_alternatives?: Array<string> | null;
|
||||
domain?: WorkTopicDomain | null;
|
||||
subfields?: Array<DomainFieldsInner> | null;
|
||||
siblings?: Array<DomainFieldsInner> | null;
|
||||
ids?: DomainIds | null;
|
||||
works_count?: number | null;
|
||||
cited_by_count?: number | null;
|
||||
works_api_url?: string | null;
|
||||
created_date?: string | null;
|
||||
updated_date?: string | null;
|
||||
export interface ModelField {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
description?: string | null;
|
||||
display_name_alternatives?: Array<string> | null;
|
||||
domain?: WorkTopicDomain | null;
|
||||
subfields?: Array<DomainFieldsInner> | null;
|
||||
siblings?: Array<DomainFieldsInner> | null;
|
||||
ids?: DomainIds | null;
|
||||
works_count?: number | null;
|
||||
cited_by_count?: number | null;
|
||||
works_api_url?: string | null;
|
||||
created_date?: string | null;
|
||||
updated_date?: string | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,10 @@ export * from './bodyResetPassword';
|
||||
export * from './bundInstitutionSummary';
|
||||
export * from './bundInstitutionSummaryPage';
|
||||
export * from './bundProjectDetails';
|
||||
export * from './bundProjectHighlight';
|
||||
export * from './bundProjectPage';
|
||||
export * from './bundProjectSummary';
|
||||
export * from './bundProjectTopics';
|
||||
export * from './careerMetrics';
|
||||
export * from './careerStage';
|
||||
export * from './collaborationGraph';
|
||||
@@ -67,6 +69,7 @@ export * from './dfgInstitutionSummaryPage';
|
||||
export * from './dfgPersonSummary';
|
||||
export * from './dfgPersonSummaryPage';
|
||||
export * from './dfgProjectDetails';
|
||||
export * from './dfgProjectHighlight';
|
||||
export * from './dfgProjectInstitutionRole';
|
||||
export * from './dfgProjectKeyword';
|
||||
export * from './dfgProjectPage';
|
||||
@@ -77,6 +80,7 @@ export * from './dfgProjectSubprojectSummary';
|
||||
export * from './dfgProjectSummary';
|
||||
export * from './dfgProjectTopic';
|
||||
export * from './dfgProjectTopics';
|
||||
export * from './dfgSubjectClassificationHighlight';
|
||||
export * from './dockerHealth';
|
||||
export * from './domain';
|
||||
export * from './domainFieldsInner';
|
||||
@@ -86,6 +90,7 @@ export * from './euCordisEurosciVocSummary';
|
||||
export * from './euCordisOrganizationSelectorPage';
|
||||
export * from './euCordisOrganizationSelectorSummary';
|
||||
export * from './euCordisOrganizationSummary';
|
||||
export * from './euCordisProjectHighlight';
|
||||
export * from './euCordisProjectResponse';
|
||||
export * from './euCordisProjectSearchPage';
|
||||
export * from './euCordisProjectSummary';
|
||||
@@ -93,6 +98,7 @@ export * from './euCordisProjectType';
|
||||
export * from './euCordisTopicSummary';
|
||||
export * from './euProjectData';
|
||||
export * from './euProjectStatusStatistics';
|
||||
export * from './euProjectTopics';
|
||||
export * from './extractedKeywords';
|
||||
export * from './extractedKeywordsLLM';
|
||||
export * from './extractedKeywordsResponse';
|
||||
@@ -221,6 +227,7 @@ export * from './subfieldShare';
|
||||
export * from './timespan';
|
||||
export * from './tokenType';
|
||||
export * from './topAuthor';
|
||||
export * from './topAuthorAnalysis';
|
||||
export * from './topAuthorStatistics';
|
||||
export * from './topInstitutionItem';
|
||||
export * from './topTopicItem';
|
||||
|
||||
@@ -1,33 +1,35 @@
|
||||
/**
|
||||
* 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 { SubfieldField } from './subfieldField';
|
||||
import { DomainFieldsInner } from './domainFieldsInner';
|
||||
import { DomainIds } from './domainIds';
|
||||
import { SubfieldDomain } from './subfieldDomain';
|
||||
import { SubfieldField } from './subfieldField';
|
||||
|
||||
|
||||
/**
|
||||
* Third-level category in the topic hierarchy (254 total)
|
||||
*/
|
||||
export interface Subfield {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
description?: string | null;
|
||||
display_name_alternatives?: Array<string> | null;
|
||||
field?: SubfieldField | null;
|
||||
domain?: SubfieldDomain | null;
|
||||
topics?: Array<DomainFieldsInner> | null;
|
||||
siblings?: Array<DomainFieldsInner> | null;
|
||||
ids?: DomainIds | null;
|
||||
works_count?: number | null;
|
||||
cited_by_count?: number | null;
|
||||
works_api_url?: string | null;
|
||||
created_date?: string | null;
|
||||
updated_date?: string | null;
|
||||
export interface Subfield {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
description?: string | null;
|
||||
display_name_alternatives?: Array<string> | null;
|
||||
field?: SubfieldField | null;
|
||||
domain?: SubfieldDomain | null;
|
||||
topics?: Array<DomainFieldsInner> | null;
|
||||
siblings?: Array<DomainFieldsInner> | null;
|
||||
ids?: DomainIds | null;
|
||||
works_count?: number | null;
|
||||
cited_by_count?: number | null;
|
||||
works_api_url?: string | null;
|
||||
created_date?: string | null;
|
||||
updated_date?: string | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { TopAuthor } from './topAuthor';
|
||||
|
||||
|
||||
export interface TopAuthorAnalysis {
|
||||
institution_id: string;
|
||||
authors: Array<TopAuthor>;
|
||||
}
|
||||
|
||||
+11
-1
@@ -127,7 +127,17 @@ export class SearchResultsStateService {
|
||||
});
|
||||
|
||||
readonly keywordsList = this.keywords;
|
||||
|
||||
readonly keywordTopicMap = computed(() => {
|
||||
const map = new Map<string, Topic>();
|
||||
for (const entry of this.selectedKeywordEntries()) {
|
||||
const keyword = entry.llm_keyword?.keyword?.trim().toLowerCase();
|
||||
const topic = entry.topic_mapping?.topic;
|
||||
if (keyword && topic) {
|
||||
map.set(keyword, topic);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
});
|
||||
// Parallel topic-name list for trend dashboard strategies. Entries
|
||||
// without a resolvable keyword are skipped when building the lookup map
|
||||
// so they can never collide on an `undefined` key and shadow a real one.
|
||||
|
||||
@@ -55,10 +55,11 @@
|
||||
|
||||
<div class="article-body">
|
||||
@if (article.full_content) {
|
||||
<p
|
||||
<app-highlighted-text
|
||||
#articleBody
|
||||
class="content"
|
||||
[innerHTML]="highlightedContent"></p>
|
||||
[content]="article.full_content"
|
||||
[highlights]="articleHighlights" />
|
||||
} @else {
|
||||
<p class="placeholder">Kein Inhalt verfügbar.</p>
|
||||
}
|
||||
|
||||
@@ -598,26 +598,3 @@ main {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
:host ::ng-deep .kw-mark {
|
||||
background: transparent;
|
||||
color: var(--t);
|
||||
text-decoration: underline;
|
||||
text-decoration-color: var(--t);
|
||||
text-decoration-style: solid;
|
||||
text-decoration-thickness: 2px;
|
||||
text-underline-offset: 2px;
|
||||
font-weight: inherit;
|
||||
border-radius: 2px;
|
||||
padding: 0 1px;
|
||||
cursor: help;
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover {
|
||||
background: color-mix(in srgb, var(--t) 15%, var(--sg-color-mix-base));
|
||||
}
|
||||
|
||||
&.kw-flash {
|
||||
animation: kw-flash 2.4s ease-out forwards;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
||||
|
||||
import {
|
||||
HighlightedTextComponent,
|
||||
HighlightTerm,
|
||||
} from '../../shared/ui/highlighted-text/highlighted-text.component';
|
||||
import { WorksService } from '../../api';
|
||||
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
import {
|
||||
@@ -58,21 +60,21 @@ interface NewsArticleDetail {
|
||||
MatTooltipModule,
|
||||
RouterLink,
|
||||
LoadingComponent,
|
||||
HighlightedTextComponent,
|
||||
],
|
||||
templateUrl: './news-detail.component.html',
|
||||
styleUrl: './news-detail.component.scss',
|
||||
})
|
||||
export class NewsDetailComponent implements OnInit {
|
||||
@ViewChild('articleBody') articleBodyRef?: ElementRef<HTMLElement>;
|
||||
@ViewChild('articleBody', { read: ElementRef })
|
||||
articleBodyRef?: ElementRef<HTMLElement>;
|
||||
private readonly router = inject(Router);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly httpClient = inject(HttpClient);
|
||||
private readonly worksService = inject(WorksService);
|
||||
private readonly sanitizer = inject(DomSanitizer);
|
||||
|
||||
article: NewsArticleDetail | null = null;
|
||||
highlightedContent: SafeHtml = this.sanitizer.bypassSecurityTrustHtml('');
|
||||
loading = false;
|
||||
notFound = false;
|
||||
|
||||
@@ -176,7 +178,6 @@ export class NewsDetailComponent implements OnInit {
|
||||
.subscribe({
|
||||
next: (article) => {
|
||||
this.article = article;
|
||||
this.highlightedContent = this.buildHighlightedContent(article);
|
||||
this.expandedTopicId = null;
|
||||
this.personsPage = 0;
|
||||
this.loading = false;
|
||||
@@ -188,15 +189,33 @@ export class NewsDetailComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
private buildHighlightedContent(article: NewsArticleDetail): SafeHtml {
|
||||
const text = article.full_content;
|
||||
if (!text) return this.sanitizer.bypassSecurityTrustHtml('');
|
||||
get articleHighlights(): HighlightTerm[] {
|
||||
const article = this.article;
|
||||
if (!article) return [];
|
||||
|
||||
return this.sanitizer.bypassSecurityTrustHtml(
|
||||
highlightKeywords(
|
||||
text,
|
||||
topicKeywordColors(article.topics, article.keywords),
|
||||
),
|
||||
);
|
||||
const topicByKeyword = new Map<string, MatchedTopic>();
|
||||
for (const topic of article.topics ?? []) {
|
||||
if (topic.source_keyword) {
|
||||
topicByKeyword.set(topic.source_keyword.toLowerCase(), topic);
|
||||
}
|
||||
}
|
||||
|
||||
const highlights: HighlightTerm[] = [];
|
||||
for (const keyword of article.keywords ?? []) {
|
||||
const topic = topicByKeyword.get(keyword.toLowerCase());
|
||||
if (!topic) continue;
|
||||
|
||||
highlights.push({
|
||||
term: keyword,
|
||||
topic: {
|
||||
id: topic.id,
|
||||
name: topic.display_name,
|
||||
field_name: topic.field_name,
|
||||
domain_name: topic.domain_name,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return highlights;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,41 +138,10 @@
|
||||
}
|
||||
<!-- Fachsystematik -->
|
||||
@if (getSubjectClassifications().length > 0) {
|
||||
<mat-card appearance="outlined" class="card">
|
||||
<div class="section-header">
|
||||
<mat-icon>category</mat-icon>
|
||||
<h2>Fachsystematik</h2>
|
||||
<span class="count-badge">{{
|
||||
getSubjectClassifications().length
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="classification-list">
|
||||
@for (entry of getSubjectClassifications(); track $index) {
|
||||
<div class="classification-path">
|
||||
@for (
|
||||
segment of getClassificationParentSegments(entry);
|
||||
track $index
|
||||
) {
|
||||
<span class="classification-segment">{{ segment }}</span>
|
||||
<mat-icon class="classification-separator"
|
||||
>chevron_right</mat-icon
|
||||
>
|
||||
}
|
||||
<div class="classification-leaf-group">
|
||||
@for (
|
||||
leaf of getClassificationLeafSegments(entry);
|
||||
track $index
|
||||
) {
|
||||
<span
|
||||
class="classification-segment classification-segment--leaf">
|
||||
{{ leaf }}
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</mat-card>
|
||||
<app-dfg-classification
|
||||
[classifications]="
|
||||
getSubjectClassifications()
|
||||
"></app-dfg-classification>
|
||||
}
|
||||
<!-- Beteiligte Personen -->
|
||||
<mat-card appearance="outlined" class="card">
|
||||
|
||||
@@ -473,56 +473,6 @@ h1 {
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.classification-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
padding: 16px 20px 20px;
|
||||
}
|
||||
|
||||
.classification-path {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 2px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
}
|
||||
|
||||
.classification-segment {
|
||||
font-size: 12px;
|
||||
line-height: 1.3;
|
||||
padding: 3px 10px;
|
||||
border-radius: 10px;
|
||||
background: var(--sg-surface-soft);
|
||||
color: var(--sg-text-muted);
|
||||
white-space: nowrap;
|
||||
|
||||
&--leaf {
|
||||
background: var(--sg-primary-soft);
|
||||
color: var(--sg-text);
|
||||
font-weight: 500;
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
|
||||
.classification-leaf-group {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.classification-separator {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
font-size: 16px;
|
||||
color: var(--sg-text-muted);
|
||||
flex-shrink: 0;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.website-html {
|
||||
padding: 16px 20px 20px;
|
||||
font-size: 14px;
|
||||
|
||||
@@ -10,7 +10,7 @@ import { DfgProjectInstitutionRole } from '../../../api/model/dfgProjectInstitut
|
||||
import { DfgProjectPersonRole } from '../../../api/model/dfgProjectPersonRole';
|
||||
import { DFGProjectFachgebieteInner } from '../../../api/model/dFGProjectFachgebieteInner';
|
||||
import { ProjectOaTopicsComponent } from '../../../shared/ui/project-oa-topics/project-oa-topics.component';
|
||||
|
||||
import { DfgClassificationComponent } from '../../../shared/ui/dfg-classification/dfg-classification.component';
|
||||
@Component({
|
||||
selector: 'app-dfg-details',
|
||||
standalone: true,
|
||||
@@ -19,6 +19,7 @@ import { ProjectOaTopicsComponent } from '../../../shared/ui/project-oa-topics/p
|
||||
MatCardModule,
|
||||
MatIconModule,
|
||||
ProjectOaTopicsComponent,
|
||||
DfgClassificationComponent,
|
||||
],
|
||||
templateUrl: './dfg-details.component.html',
|
||||
styleUrl: './dfg-details.component.scss',
|
||||
@@ -154,29 +155,9 @@ export class DfgDetailsComponent implements OnInit {
|
||||
this.getInstitutionsList().length
|
||||
);
|
||||
}
|
||||
|
||||
//(DFG Fachsystematik)
|
||||
|
||||
getSubjectClassifications(): DFGProjectFachgebieteInner[] {
|
||||
return this.dfgProject?.subject_classifications ?? [];
|
||||
}
|
||||
|
||||
getClassificationParentSegments(entry: DFGProjectFachgebieteInner): string[] {
|
||||
return [
|
||||
entry.wissenschaftsbereich,
|
||||
entry.fachkollegium,
|
||||
entry.fachgebiet,
|
||||
].filter((part): part is string => !!part);
|
||||
}
|
||||
|
||||
getClassificationLeafSegments(entry: DFGProjectFachgebieteInner): string[] {
|
||||
if (!entry.fach) return [];
|
||||
return entry.fach
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter((s) => !!s);
|
||||
}
|
||||
|
||||
// --- Subprojects & publications ---
|
||||
|
||||
getSubprojects(): DfgProjectSubprojectSummary[] {
|
||||
|
||||
@@ -58,16 +58,46 @@
|
||||
icon="group"
|
||||
[size]="200"
|
||||
[diameter]="200" />
|
||||
} @else if (resolverState.isResolvingFromOutside('/person/')) {
|
||||
} @else if (resolverState.isResolvingFromOutside('/person')) {
|
||||
<app-loading
|
||||
text="Personendaten werden geladen..."
|
||||
icon="person"
|
||||
[size]="200"
|
||||
[diameter]="200" />
|
||||
} @else if (resolverState.isResolvingFromOutside('/projects/')) {
|
||||
} @else if (resolverState.isResolvingFromOutside('/publications')) {
|
||||
<app-loading
|
||||
text="Publikationsdaten werden geladen..."
|
||||
icon="menu_book"
|
||||
[size]="200"
|
||||
[diameter]="200" />
|
||||
} @else if (resolverState.isResolvingFromOutside('/projects')) {
|
||||
<app-loading
|
||||
text="Projektdaten werden geladen..."
|
||||
icon="article"
|
||||
icon="work"
|
||||
[size]="200"
|
||||
[diameter]="200" />
|
||||
} @else if (resolverState.isResolvingFromOutside('/institutions')) {
|
||||
<app-loading
|
||||
text="Institutionen werden geladen..."
|
||||
icon="school"
|
||||
[size]="200"
|
||||
[diameter]="200" />
|
||||
} @else if (resolverState.isResolvingFromOutside('/patents')) {
|
||||
<app-loading
|
||||
text="Patente werden geladen..."
|
||||
icon="workspace_premium"
|
||||
[size]="200"
|
||||
[diameter]="200" />
|
||||
} @else if (resolverState.isResolvingFromOutside('/news')) {
|
||||
<app-loading
|
||||
text="Nachrichten werden geladen..."
|
||||
icon="newspaper"
|
||||
[size]="200"
|
||||
[diameter]="200" />
|
||||
} @else if (resolverState.isResolvingFromOutside('/topics')) {
|
||||
<app-loading
|
||||
text="Themen werden geladen..."
|
||||
icon="topic"
|
||||
[size]="200"
|
||||
[diameter]="200" />
|
||||
} @else {
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
</ng-template>
|
||||
|
||||
<ng-template #topicsTmp let-project>
|
||||
@let projectTopics = project.oa_topics ?? [];
|
||||
@let projectTopics = getProjectTopics(project);
|
||||
@let isTopicsExpanded = isProjectTopicsExpanded(project);
|
||||
@let visibleTopics =
|
||||
isTopicsExpanded ? projectTopics : projectTopics.slice(0, 3);
|
||||
|
||||
@@ -102,6 +102,9 @@ export class BundProjectTableComponent implements OnInit {
|
||||
selectedTopicIdsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.topicId);
|
||||
});
|
||||
selectedTopicMatchesQueryParams = computed(() => {
|
||||
return this.queryParamMap().get('topics')?.split(',') || [];
|
||||
});
|
||||
selectedFundingTypesQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.funding_type);
|
||||
});
|
||||
@@ -225,7 +228,19 @@ export class BundProjectTableComponent implements OnInit {
|
||||
getProjectInstitutions(project: BundProjectSummary): any[] {
|
||||
return project.institution ? [project.institution] : [];
|
||||
}
|
||||
|
||||
getProjectTopics(project: BundProjectSummary): Topic[] {
|
||||
const topics = (project as any).oa_topics ?? [];
|
||||
const activeTopics = topics.filter((topic: Topic) =>
|
||||
this.isTopicActive(topic),
|
||||
);
|
||||
return topics.sort((a: Topic, b: Topic) =>
|
||||
activeTopics.includes(a) && !activeTopics.includes(b)
|
||||
? -1
|
||||
: !activeTopics.includes(a) && activeTopics.includes(b)
|
||||
? 1
|
||||
: 0,
|
||||
);
|
||||
}
|
||||
isInstitutionActive(
|
||||
institution_name: string | number | null | undefined,
|
||||
): boolean {
|
||||
@@ -293,8 +308,9 @@ export class BundProjectTableComponent implements OnInit {
|
||||
isTopicActive(topic: Topic): boolean {
|
||||
return (
|
||||
!!topic.id &&
|
||||
this.authorFilterEnabled() &&
|
||||
this.selectedTopicIdsQueryParams().includes(topic.id)
|
||||
this.topicFilterEnabled() &&
|
||||
(this.selectedTopicIdsQueryParams().includes(topic.id) ||
|
||||
this.selectedTopicMatchesQueryParams().includes(topic.id))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
@if (classifications().length > 0) {
|
||||
<mat-card appearance="outlined" class="card">
|
||||
<div class="section-header">
|
||||
<mat-icon>category</mat-icon>
|
||||
<h2>Fachsystematik</h2>
|
||||
<span class="count-badge">{{ classifications().length }}</span>
|
||||
</div>
|
||||
<div class="classification-list">
|
||||
@for (entry of classifications(); track $index) {
|
||||
<div class="classification-path">
|
||||
@for (
|
||||
segment of getClassificationParentSegments(entry);
|
||||
track $index
|
||||
) {
|
||||
<span class="classification-segment">{{ segment }}</span>
|
||||
<mat-icon class="classification-separator">chevron_right</mat-icon>
|
||||
}
|
||||
<div class="classification-leaf-group">
|
||||
@for (leaf of getClassificationLeafSegments(entry); track $index) {
|
||||
<span class="classification-segment classification-segment--leaf">
|
||||
{{ leaf }}
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</mat-card>
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
.card {
|
||||
margin-bottom: 24px;
|
||||
background: var(--sg-card-bg) !important;
|
||||
border-color: var(--sg-border) !important;
|
||||
border-radius: var(--sg-radius-md) !important;
|
||||
}
|
||||
|
||||
.card ::ng-deep .mat-mdc-card-content {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 16px 20px 12px;
|
||||
border-bottom: 1px solid var(--sg-border);
|
||||
}
|
||||
|
||||
.section-header mat-icon {
|
||||
color: var(--sg-text-muted);
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.section-header h2 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--sg-text);
|
||||
}
|
||||
|
||||
.count-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 24px;
|
||||
height: 24px;
|
||||
padding: 0 8px;
|
||||
margin-left: auto;
|
||||
background: var(--sg-primary-soft);
|
||||
border-radius: 12px;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.classification-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
padding: 16px 20px 20px;
|
||||
}
|
||||
|
||||
.classification-path {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 2px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
}
|
||||
|
||||
.classification-segment {
|
||||
font-size: 12px;
|
||||
line-height: 1.3;
|
||||
padding: 3px 10px;
|
||||
border-radius: 10px;
|
||||
background: var(--sg-surface-soft);
|
||||
color: var(--sg-text-muted);
|
||||
white-space: nowrap;
|
||||
|
||||
&--leaf {
|
||||
background: var(--sg-primary-soft);
|
||||
color: var(--sg-text);
|
||||
font-weight: 500;
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
|
||||
.classification-leaf-group {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.classification-separator {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
font-size: 16px;
|
||||
color: var(--sg-text-muted);
|
||||
flex-shrink: 0;
|
||||
opacity: 0.5;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Component, input } from '@angular/core';
|
||||
import { DFGProjectFachgebieteInner } from '../../../api';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@Component({
|
||||
selector: 'app-dfg-classification',
|
||||
imports: [MatIconModule, MatCardModule],
|
||||
templateUrl: './dfg-classification.component.html',
|
||||
styleUrl: './dfg-classification.component.scss',
|
||||
})
|
||||
export class DfgClassificationComponent {
|
||||
classifications = input.required<Array<DFGProjectFachgebieteInner>>();
|
||||
|
||||
getClassificationParentSegments(entry: DFGProjectFachgebieteInner): string[] {
|
||||
return [
|
||||
entry.wissenschaftsbereich,
|
||||
entry.fachkollegium,
|
||||
entry.fachgebiet,
|
||||
].filter((part): part is string => !!part);
|
||||
}
|
||||
|
||||
getClassificationLeafSegments(entry: DFGProjectFachgebieteInner): string[] {
|
||||
if (!entry.fach) return [];
|
||||
return entry.fach
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter((s) => !!s);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<app-data-table
|
||||
[columns]="columns"
|
||||
[data]="elements()"
|
||||
[detailTemplate]="expandedProject"
|
||||
[queryParamSortKey]="queryParamKeys.sortBy"
|
||||
[queryParamSortDirectionKey]="queryParamKeys.sortDirection" />
|
||||
|
||||
@@ -9,7 +10,9 @@
|
||||
queryParamPageKey="page"
|
||||
queryParamSizeKey="size"
|
||||
[pageSizeOptions]="[10, 25, 50]" />
|
||||
|
||||
<ng-template #titleTmp let-element>
|
||||
<span class="panel-field__text">{{ element.title_de }}</span>
|
||||
</ng-template>
|
||||
<ng-template #fundingEndTmp let-element>
|
||||
<span>
|
||||
{{
|
||||
@@ -42,12 +45,11 @@
|
||||
<span
|
||||
class="publication-institution-tag classification-tag"
|
||||
[matTooltip]="getClassificationTooltipText(classification)"
|
||||
matTooltipPosition="above"
|
||||
[attr.aria-label]="getClassificationTooltipText(classification)">
|
||||
matTooltipPosition="above">
|
||||
<mat-icon class="institution-icon">category</mat-icon>
|
||||
<span class="institution-name">{{
|
||||
getClassificationFullChain(classification)
|
||||
}}</span>
|
||||
<span class="institution-name">
|
||||
{{ getClassificationFullChain(classification) }}</span
|
||||
>
|
||||
</span>
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
@@ -60,7 +62,115 @@
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #expandedProject let-project>
|
||||
<section class="project-panel" aria-label="Weitere Projektdetails">
|
||||
<header class="project-panel__header">
|
||||
<div class="language-toggle" role="group" aria-label="Sprache wählen">
|
||||
<button
|
||||
type="button"
|
||||
class="language-toggle__button"
|
||||
[class.active]="getPanelLanguage(project) === 'de'"
|
||||
(click)="setPanelLanguage(project, 'de')">
|
||||
DE
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="language-toggle__button"
|
||||
[class.active]="getPanelLanguage(project) === 'en'"
|
||||
(click)="setPanelLanguage(project, 'en')">
|
||||
EN
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
<mat-divider />
|
||||
<div class="project-panel__content">
|
||||
@if (getPanelLanguage(project) === 'de') {
|
||||
@if (project.title_de) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Titel</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.title_de"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(project.highlight?.title_de)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
|
||||
@if (project.abstract_de) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Zusammenfassung</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.abstract_de"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(project.highlight?.abstract_de)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
} @else {
|
||||
@if (project.title_en) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Title</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.title_en"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(project.highlight?.title_en)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
|
||||
@if (project.abstract_en) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Abstract</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.abstract_en"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(project.highlight?.abstract_en)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
}
|
||||
|
||||
@if (!hasAnyPanelContent(project)) {
|
||||
<div class="project-panel__empty">
|
||||
<mat-icon aria-hidden="true">info</mat-icon>
|
||||
<span>Keine weiteren Angaben vorhanden.</span>
|
||||
</div>
|
||||
}
|
||||
@if (getProjectClassifications(project).length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Fachsystematik</h4>
|
||||
@for (
|
||||
classification of getProjectClassifications(project);
|
||||
track $index
|
||||
) {
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="getClassificationFullChain(classification)"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
getClassificationHighlightTerms(project, $index)
|
||||
)
|
||||
" />
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
</article>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
</ng-template>
|
||||
<ng-template #authorsTmp let-project>
|
||||
@let projectAuthors = getProjectAuthors(project);
|
||||
@let isProjectAuthorsExpanded = isProjectPersonsExpanded(project);
|
||||
@@ -130,7 +240,7 @@
|
||||
</ng-template>
|
||||
|
||||
<ng-template #topicsTmp let-project>
|
||||
@let projectTopics = project.topics ?? [];
|
||||
@let projectTopics = getProjectTopics(project);
|
||||
@let isTopicsExpanded = isProjectTopicsExpanded(project);
|
||||
@let visibleTopics =
|
||||
isTopicsExpanded ? projectTopics : projectTopics.slice(0, 3);
|
||||
|
||||
@@ -203,3 +203,249 @@
|
||||
padding: 16px;
|
||||
}
|
||||
}
|
||||
// ------------------------
|
||||
// Expanded project highlights
|
||||
// ------------------------
|
||||
|
||||
.project-highlight-details {
|
||||
width: 100%;
|
||||
padding: 10px 14px 12px;
|
||||
color: var(--sg-text);
|
||||
background: var(--sg-background);
|
||||
border-top: 1px solid var(--sg-border);
|
||||
}
|
||||
|
||||
.highlight-header {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.highlight-header__title {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 7px;
|
||||
|
||||
> mat-icon {
|
||||
flex: 0 0 auto;
|
||||
width: 19px;
|
||||
height: 19px;
|
||||
color: var(--sg-primary);
|
||||
font-size: 19px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 1px 0 0;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 10px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
}
|
||||
|
||||
.highlight-content-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.highlight-section {
|
||||
min-width: 0;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 5px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.highlight-section__header,
|
||||
.classification-highlight-section__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 7px;
|
||||
min-height: 32px;
|
||||
padding: 4px 7px;
|
||||
background: var(--sg-primary-soft);
|
||||
border-bottom: 1px solid var(--sg-border);
|
||||
}
|
||||
|
||||
.highlight-section__heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
gap: 5px;
|
||||
|
||||
mat-icon {
|
||||
flex: 0 0 auto;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
color: var(--sg-primary);
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
h4 {
|
||||
margin: 0;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
.language-toggle {
|
||||
display: inline-flex;
|
||||
flex: 0 0 auto;
|
||||
padding: 1px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 4px;
|
||||
background: var(--sg-background);
|
||||
}
|
||||
|
||||
.language-toggle__button {
|
||||
min-width: 27px;
|
||||
padding: 2px 5px;
|
||||
border: 0;
|
||||
border-radius: 3px;
|
||||
color: var(--sg-text-muted);
|
||||
background: transparent;
|
||||
font-family: inherit;
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
color: var(--sg-primary);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: var(--sg-background);
|
||||
background: var(--sg-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.language-label {
|
||||
flex: 0 0 auto;
|
||||
padding: 2px 5px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 3px;
|
||||
color: var(--sg-text-muted);
|
||||
background: var(--sg-background);
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.highlight-section__body {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
padding: 6px 7px;
|
||||
}
|
||||
|
||||
.highlight-snippet {
|
||||
margin: 0;
|
||||
padding: 4px 6px;
|
||||
border-left: 2px solid var(--sg-primary);
|
||||
border-radius: 0 3px 3px 0;
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--sg-primary-soft) 55%,
|
||||
var(--sg-background)
|
||||
);
|
||||
font-size: 11px;
|
||||
line-height: 1.4;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
// ------------------------
|
||||
// Expanded project panel
|
||||
// ------------------------
|
||||
|
||||
.project-panel {
|
||||
width: 100%;
|
||||
padding: 12px 16px 14px;
|
||||
color: var(--sg-text);
|
||||
background: var(--sg-background);
|
||||
border-top: 1px solid var(--sg-border);
|
||||
}
|
||||
|
||||
.project-panel__header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.project-panel__heading {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
|
||||
> mat-icon {
|
||||
flex: 0 0 auto;
|
||||
width: 19px;
|
||||
height: 19px;
|
||||
color: var(--sg-primary);
|
||||
font-size: 19px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 1px 0 0;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 11px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
}
|
||||
|
||||
.project-panel__content {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.panel-field {
|
||||
min-width: 0;
|
||||
|
||||
&--full {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
}
|
||||
|
||||
.panel-field__label {
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.panel-field__text {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.project-panel__empty {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
grid-column: 1 / -1;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 12px;
|
||||
|
||||
mat-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,15 @@ import { MatTooltip } from '@angular/material/tooltip';
|
||||
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
import { SkTextDirective } from '../../../custom-directives/sk-text.directive';
|
||||
import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overflow-toggle.component';
|
||||
import { SearchResultsStateService } from '../../../modules/keywords-search/search-results/search-results-state.service';
|
||||
import { TopicHierarchyColorInput } from '../../../resolvers/utils/topic-colors';
|
||||
import {
|
||||
HighlightedTextComponent,
|
||||
HighlightTerm,
|
||||
} from '../highlighted-text/highlighted-text.component';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
type HighlightLanguage = 'de' | 'en';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dfg-project-table',
|
||||
imports: [
|
||||
@@ -37,6 +46,8 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl
|
||||
MatTooltip,
|
||||
AppTopicChipComponent,
|
||||
SkTextDirective,
|
||||
HighlightedTextComponent,
|
||||
MatDividerModule,
|
||||
],
|
||||
templateUrl: './dfg-project-table.component.html',
|
||||
styleUrl: './dfg-project-table.component.scss',
|
||||
@@ -44,7 +55,10 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl
|
||||
export class DfgProjectTableComponent implements OnInit {
|
||||
private readonly activatedRoute = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
|
||||
private readonly searchResultsStateService = inject(
|
||||
SearchResultsStateService,
|
||||
{ optional: true },
|
||||
);
|
||||
page = input.required<DfgProjectPage>();
|
||||
authorFilterEnabled = input<boolean>(false);
|
||||
institutionFilterEnabled = input<boolean>(false);
|
||||
@@ -96,10 +110,24 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
selectedTopicIdsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.topicId);
|
||||
});
|
||||
|
||||
selectedTopicMatchesQueryParams = computed(() => {
|
||||
return this.queryParamMap().get('topics')?.split(',') || [];
|
||||
});
|
||||
keywordTopicMap = computed(() => {
|
||||
return (
|
||||
this.searchResultsStateService?.keywordTopicMap() ??
|
||||
new Map<string, Topic>()
|
||||
);
|
||||
});
|
||||
ngOnInit(): void {
|
||||
this.columns = [
|
||||
{ id: 'title', header: 'Titel', type: 'accessor', accessorKey: 'title' },
|
||||
{
|
||||
id: 'title',
|
||||
header: 'Titel',
|
||||
type: 'accessor',
|
||||
accessorKey: 'title_de',
|
||||
cellTemplate: this.titleTmp(),
|
||||
},
|
||||
{
|
||||
id: 'funding_start',
|
||||
header: 'Förderbeginn',
|
||||
@@ -127,7 +155,7 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
cellTemplate: this.institutionsTmp(),
|
||||
},
|
||||
{
|
||||
id: 'professional_classification',
|
||||
id: 'subject_classifications_raw',
|
||||
header: 'Fachsystematik',
|
||||
type: 'display',
|
||||
cellTemplate: this.detailRowTmp(),
|
||||
@@ -159,7 +187,15 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
getProjectAuthors(project: DfgProjectSummary): DfgPersonSummary[] {
|
||||
return project.persons?.filter((a): a is DfgPersonSummary => !!a) || [];
|
||||
const selectedAuthorIds = this.selectedAuthorIdsQueryParams();
|
||||
const authors = project.persons || [];
|
||||
return authors.sort((a, b) => {
|
||||
const aActive = selectedAuthorIds.includes(String(a.person_id));
|
||||
const bActive = selectedAuthorIds.includes(String(b.person_id));
|
||||
if (aActive && !bActive) return -1;
|
||||
if (!aActive && bActive) return 1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
toggleProjectAuthorsExpansion(project: DfgProjectSummary): void {
|
||||
@@ -230,7 +266,7 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
|
||||
getProjectInstitutions(project: DfgProjectSummary): any[] {
|
||||
const institutions = new Map<string, any>();
|
||||
|
||||
const selectedInstitutionIds = this.selectedInstitutionIdsQueryParams();
|
||||
for (const institution of project.institutions ?? []) {
|
||||
const id = this.getProjectInstitutionId(institution);
|
||||
if (!id) continue;
|
||||
@@ -239,9 +275,11 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
}
|
||||
|
||||
return Array.from(institutions.values()).sort((a, b) =>
|
||||
this.getProjectInstitutionName(a).localeCompare(
|
||||
this.getProjectInstitutionName(b),
|
||||
),
|
||||
selectedInstitutionIds.includes(this.getProjectInstitutionId(a) ?? '')
|
||||
? -1
|
||||
: selectedInstitutionIds.includes(this.getProjectInstitutionId(b) ?? '')
|
||||
? 1
|
||||
: 0,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -320,8 +358,9 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
isTopicActive(topic: Topic): boolean {
|
||||
return (
|
||||
!!topic.id &&
|
||||
this.authorFilterEnabled() &&
|
||||
this.selectedTopicIdsQueryParams().includes(topic.id)
|
||||
this.topicFilterEnabled() &&
|
||||
(this.selectedTopicIdsQueryParams().includes(topic.id) ||
|
||||
this.selectedTopicMatchesQueryParams().includes(topic.id))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -364,6 +403,19 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
|
||||
return this.expandedProjectTopicsId.includes(project.id);
|
||||
}
|
||||
getProjectTopics(project: DfgProjectSummary): Topic[] {
|
||||
const topics = (project as any).topics ?? [];
|
||||
const activeTopics = topics.filter((topic: Topic) =>
|
||||
this.isTopicActive(topic),
|
||||
);
|
||||
return topics.sort((a: Topic, b: Topic) =>
|
||||
activeTopics.includes(a) && !activeTopics.includes(b)
|
||||
? -1
|
||||
: !activeTopics.includes(a) && activeTopics.includes(b)
|
||||
? 1
|
||||
: 0,
|
||||
);
|
||||
}
|
||||
expandedProjectClassificationsId: string[] = [];
|
||||
//classifications
|
||||
getProjectClassifications(project: DfgProjectSummary): any[] {
|
||||
@@ -399,4 +451,117 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
getClassificationTooltipText(classification: any): string {
|
||||
return this.getClassificationFullChain(classification);
|
||||
}
|
||||
|
||||
private readonly selectedPanelLanguage = new Map<string, HighlightLanguage>();
|
||||
|
||||
getPanelLanguage(project: DfgProjectSummary): HighlightLanguage {
|
||||
if (!project.id) return 'de';
|
||||
return this.selectedPanelLanguage.get(project.id) ?? 'de';
|
||||
}
|
||||
|
||||
setPanelLanguage(
|
||||
project: DfgProjectSummary,
|
||||
language: HighlightLanguage,
|
||||
): void {
|
||||
if (!project.id) return;
|
||||
this.selectedPanelLanguage.set(project.id, language);
|
||||
}
|
||||
|
||||
hasAnyPanelContent(project: DfgProjectSummary): boolean {
|
||||
const language = this.getPanelLanguage(project);
|
||||
|
||||
const hasLocalizedContent =
|
||||
language === 'de'
|
||||
? !!project.title_de || !!project.abstract_de
|
||||
: !!project.title_en || !!project.abstract_en;
|
||||
|
||||
return hasLocalizedContent || !!project.subject_classifications_raw?.length;
|
||||
}
|
||||
getClassificationHighlightTerms(
|
||||
project: DfgProjectSummary,
|
||||
index: number,
|
||||
): string[] {
|
||||
const classificationHighlights =
|
||||
project.highlight?.subject_classifications ?? [];
|
||||
const terms = new Set<string>();
|
||||
|
||||
for (const highlight of classificationHighlights) {
|
||||
if (highlight.offset !== index) continue;
|
||||
|
||||
for (const fragments of [
|
||||
highlight.wissenschaftsbereich,
|
||||
highlight.fachkollegium,
|
||||
highlight.fachgebiet,
|
||||
highlight.fachgebiet_de,
|
||||
highlight.fach,
|
||||
]) {
|
||||
for (const term of this.extractHighlightTerms(fragments)) {
|
||||
terms.add(term);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(terms);
|
||||
}
|
||||
/**
|
||||
* Extracts the distinct matched terms out of Elasticsearch-style
|
||||
* highlight fragments (terms wrapped in <em>...</em>).
|
||||
*/
|
||||
extractHighlightTerms(fragments: string[] | null | undefined): string[] {
|
||||
const terms = new Set<string>();
|
||||
|
||||
for (const fragment of fragments ?? []) {
|
||||
if (typeof fragment !== 'string') continue;
|
||||
|
||||
const matches = fragment.matchAll(/<em>(.*?)<\/em>/gi);
|
||||
for (const match of matches) {
|
||||
const term = match[1]?.trim();
|
||||
if (term) {
|
||||
terms.add(term);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(terms);
|
||||
}
|
||||
|
||||
getHighlightTerms(terms: string[] | null | undefined): HighlightTerm[] {
|
||||
return (terms ?? []).map((term) => ({
|
||||
term,
|
||||
topic: this.resolveTopicForTerm(term),
|
||||
}));
|
||||
}
|
||||
|
||||
private resolveTopicForTerm(term: string): TopicHierarchyColorInput | null {
|
||||
const topic =
|
||||
this.keywordTopicMap().get(term) ??
|
||||
this.keywordTopicMap().get(term.toLowerCase());
|
||||
//Attempt to find a topic for the term by checking if the term is a substring of any keyword in the keywordTopicMap
|
||||
if (!topic) {
|
||||
for (const [keyword, mappedTopic] of this.keywordTopicMap()) {
|
||||
if (
|
||||
keyword.toLowerCase().includes(term.toLowerCase()) ||
|
||||
term.toLowerCase().includes(keyword.toLowerCase())
|
||||
) {
|
||||
return {
|
||||
id: mappedTopic.id,
|
||||
name: mappedTopic.display_name,
|
||||
field_id: mappedTopic.field?.id,
|
||||
field_name: mappedTopic.field?.display_name,
|
||||
domain_id: mappedTopic.domain?.id,
|
||||
domain_name: mappedTopic.domain?.display_name,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!topic) return null;
|
||||
return {
|
||||
id: topic.id,
|
||||
name: topic.display_name,
|
||||
field_id: topic.field?.id,
|
||||
field_name: topic.field?.display_name,
|
||||
domain_id: topic.domain?.id,
|
||||
domain_name: topic.domain?.display_name,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
@let visibleTopics = isExpanded ? projectTopics : projectTopics.slice(0, 3);
|
||||
|
||||
<div class="topic-chips" aria-label="Themen" style="padding: 0.5rem 0">
|
||||
@for (topic of visibleTopics; track topic.id ?? $index) {
|
||||
@for (topic of visibleTopics; track $index) {
|
||||
<app-topic-chip-2
|
||||
size="mini"
|
||||
[topic]="topic"
|
||||
|
||||
@@ -88,6 +88,9 @@ export class EuProjectTableComponent {
|
||||
selectedTopicIdsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.topicId);
|
||||
});
|
||||
selectedTopicMatchesQueryParams = computed(() => {
|
||||
return this.queryParamMap().get('topics')?.split(',') || [];
|
||||
});
|
||||
selectedTypesQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.projectType);
|
||||
});
|
||||
@@ -238,7 +241,15 @@ export class EuProjectTableComponent {
|
||||
// -------------------------
|
||||
|
||||
getProjectAuthors(project: EuCordisProjectSummary): Author[] {
|
||||
return project.authors?.elements ?? [];
|
||||
const selectedAuthorIds = this.selectedAuthorIdsQueryParams();
|
||||
const authors = project.authors?.elements ?? [];
|
||||
return authors.sort((a, b) => {
|
||||
const aActive = selectedAuthorIds.includes(String(a.id));
|
||||
const bActive = selectedAuthorIds.includes(String(b.id));
|
||||
if (aActive && !bActive) return -1;
|
||||
if (!aActive && bActive) return 1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
getAuthorTrackId(author: any, index: number): string {
|
||||
return String(
|
||||
@@ -334,7 +345,7 @@ export class EuProjectTableComponent {
|
||||
if (!Array.isArray(organizations)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const selectedOrganizationIds = this.selectedOrganizationIdsQueryParams();
|
||||
const byId = new Map<string, EuCordisOrganizationSummary>();
|
||||
|
||||
for (const organization of organizations) {
|
||||
@@ -345,7 +356,11 @@ export class EuProjectTableComponent {
|
||||
}
|
||||
|
||||
return Array.from(byId.values()).sort((a, b) =>
|
||||
this.getOrganizationName(a).localeCompare(this.getOrganizationName(b)),
|
||||
selectedOrganizationIds.includes(this.getOrganizationId(a) ?? '')
|
||||
? -1
|
||||
: selectedOrganizationIds.includes(this.getOrganizationId(b) ?? '')
|
||||
? 1
|
||||
: 0,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -427,7 +442,16 @@ export class EuProjectTableComponent {
|
||||
|
||||
getProjectTopics(project: EuCordisProjectSummary): Topic[] {
|
||||
const topics = (project as any).topics ?? [];
|
||||
return Array.isArray(topics) ? topics : [];
|
||||
const activeTopics = topics.filter((topic: Topic) =>
|
||||
this.isTopicActive(topic),
|
||||
);
|
||||
return topics.sort((a: Topic, b: Topic) =>
|
||||
activeTopics.includes(a) && !activeTopics.includes(b)
|
||||
? -1
|
||||
: !activeTopics.includes(a) && activeTopics.includes(b)
|
||||
? 1
|
||||
: 0,
|
||||
);
|
||||
}
|
||||
|
||||
getWorkTopicColor(topic: Topic): string {
|
||||
@@ -445,7 +469,8 @@ export class EuProjectTableComponent {
|
||||
return (
|
||||
!!topic.id &&
|
||||
this.topicFilterEnabled() &&
|
||||
this.selectedTopicIdsQueryParams().includes(topic.id)
|
||||
(this.selectedTopicIdsQueryParams().includes(topic.id) ||
|
||||
this.selectedTopicMatchesQueryParams().includes(topic.id))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<p>highlighted-text works!</p>
|
||||
@@ -0,0 +1,129 @@
|
||||
import { Component, computed, inject, input } from '@angular/core';
|
||||
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
||||
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
import { TopicHierarchyColorInput } from '../../../resolvers/utils/topic-colors';
|
||||
export interface HighlightTerm {
|
||||
/** Literal text to search for and wrap in a <mark>. */
|
||||
term: string;
|
||||
/** Colors this term via topicHierarchyColor. Omit for a plain highlight. */
|
||||
topic?: TopicHierarchyColorInput | null;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-highlighted-text',
|
||||
standalone: true,
|
||||
template: '',
|
||||
host: {
|
||||
'[innerHTML]': 'highlightedHtml()',
|
||||
},
|
||||
styles: [':host { display: block; }'],
|
||||
})
|
||||
export class HighlightedTextComponent {
|
||||
private readonly sanitizer = inject(DomSanitizer);
|
||||
|
||||
content = input<string | null | undefined>('');
|
||||
highlights = input<HighlightTerm[]>([]);
|
||||
|
||||
protected readonly highlightedHtml = computed<SafeHtml>(() => {
|
||||
const text = this.content();
|
||||
if (!text) return this.sanitizer.bypassSecurityTrustHtml('');
|
||||
|
||||
return this.sanitizer.bypassSecurityTrustHtml(
|
||||
this.buildHtml(text, this.highlights()),
|
||||
);
|
||||
});
|
||||
|
||||
private buildHtml(text: string, highlights: HighlightTerm[]): string {
|
||||
const escapedText = this.escapeHtml(text);
|
||||
const terms = this.dedupeAndSortTerms(highlights);
|
||||
if (!terms.length) return escapedText;
|
||||
|
||||
const regex = this.buildMatchRegex(terms);
|
||||
|
||||
// Single combined pass: scans the original text once and never
|
||||
// re-scans already-inserted <mark> markup, so a short term can't
|
||||
// accidentally match inside a previously-injected style/data attribute.
|
||||
return escapedText.replace(regex, (matched) => {
|
||||
const origin = this.findOriginTerm(matched, terms);
|
||||
if (!origin) return matched;
|
||||
|
||||
const dataKw = this.escapeHtml(origin.term);
|
||||
|
||||
if (!origin.topic) {
|
||||
return `<mark class="app-highlight-mark" data-kw="${dataKw}">${matched}</mark>`;
|
||||
}
|
||||
|
||||
const color = topicHierarchyColor({
|
||||
id: origin.topic.id,
|
||||
name: origin.topic.name,
|
||||
field_id: origin.topic.field_id,
|
||||
field_name: origin.topic.field_name,
|
||||
domain_id: origin.topic.domain_id,
|
||||
domain_name: origin.topic.domain_name,
|
||||
});
|
||||
|
||||
return `<mark class="app-highlight-mark app-highlight-mark--topic" style="--t:${color}" data-kw="${dataKw}">${matched}</mark>`;
|
||||
});
|
||||
}
|
||||
|
||||
/** Dedupes by term (case-insensitive, first occurrence wins), longest-first. */
|
||||
private dedupeAndSortTerms(highlights: HighlightTerm[]): HighlightTerm[] {
|
||||
const byKey = new Map<string, HighlightTerm>();
|
||||
|
||||
for (const highlight of highlights) {
|
||||
const term = highlight?.term?.trim();
|
||||
if (!term) continue;
|
||||
|
||||
const key = term.toLowerCase();
|
||||
if (!byKey.has(key)) {
|
||||
byKey.set(key, { ...highlight, term });
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(byKey.values()).sort(
|
||||
(a, b) => b.term.length - a.term.length,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Short/acronym-like terms (<=3 chars, or ALL CAPS) match exactly.
|
||||
* Longer terms also swallow a trailing suffix (plural/case endings).
|
||||
*/
|
||||
private buildMatchRegex(terms: HighlightTerm[]): RegExp {
|
||||
const before = '(?<![\\w\\u00C0-\\u024F])';
|
||||
const alternatives = terms.map(({ term }) => {
|
||||
const escaped = this.escapeRegex(this.escapeHtml(term));
|
||||
const acronymLike =
|
||||
term.length <= 3 ||
|
||||
(term === term.toUpperCase() && term !== term.toLowerCase());
|
||||
|
||||
return acronymLike
|
||||
? `${escaped}(?![\\w\\u00C0-\\u024F])`
|
||||
: `${escaped}[\\w\\u00C0-\\u024F]*`;
|
||||
});
|
||||
|
||||
return new RegExp(`${before}(?:${alternatives.join('|')})`, 'gi');
|
||||
}
|
||||
|
||||
private findOriginTerm(
|
||||
matched: string,
|
||||
terms: HighlightTerm[],
|
||||
): HighlightTerm | undefined {
|
||||
const matchedLower = matched.toLowerCase();
|
||||
return terms.find(({ term }) =>
|
||||
matchedLower.startsWith(term.toLowerCase()),
|
||||
);
|
||||
}
|
||||
|
||||
private escapeHtml(text: string): string {
|
||||
return text
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
}
|
||||
|
||||
private escapeRegex(text: string): string {
|
||||
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
}
|
||||
@@ -482,6 +482,43 @@ html.dark-theme {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
/* highlighted text */
|
||||
.app-highlight-mark {
|
||||
background-color: rgba(255, 214, 0, 0.35);
|
||||
border-radius: 2px;
|
||||
padding: 0 1px;
|
||||
}
|
||||
|
||||
.app-highlight-mark--topic {
|
||||
background: transparent;
|
||||
color: var(--t);
|
||||
text-decoration: underline;
|
||||
text-decoration-color: var(--t);
|
||||
text-decoration-thickness: 2px;
|
||||
text-underline-offset: 2px;
|
||||
font-weight: inherit;
|
||||
border-radius: 2px;
|
||||
padding: 0 1px;
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover {
|
||||
background: color-mix(in srgb, var(--t) 15%, var(--sg-color-mix-base));
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes kw-flash {
|
||||
0%,
|
||||
40% {
|
||||
background: color-mix(in srgb, var(--t) 45%, var(--sg-color-mix-base));
|
||||
}
|
||||
100% {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
.kw-flash {
|
||||
animation: kw-flash 2.4s ease-out forwards;
|
||||
}
|
||||
/* Theme-aware text skeleton */
|
||||
.sk-text-loading {
|
||||
display: inline-block;
|
||||
|
||||
Reference in New Issue
Block a user