Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1da8d9085d | ||
|
|
8ecf766aef | ||
|
|
849d4fdab9 | ||
|
|
e6c66e90a6 | ||
|
|
3e1a81e68b | ||
|
|
afd414e004 | ||
|
|
28c79e113a | ||
|
|
4a37c8d041 | ||
|
|
fa9e043076 | ||
|
|
b753f7dd00 | ||
|
|
982e01a26a | ||
|
|
4f3a427332 | ||
|
|
5399cba01a | ||
|
|
4c97983f51 | ||
|
|
9da982acab | ||
|
|
3f6cb911a0 |
Vendored
@@ -31,7 +31,7 @@ task exportOpenApiSpec(type: Exec) {
|
||||
'--entrypoint', 'python',
|
||||
"${imagePrefix}-service:${imageVersion}",
|
||||
'-c',
|
||||
'import json; from inse.service import app; open("/mnt/openapi/inse-service.openapi.json", "w").write(json.dumps(app.openapi(), indent=2))'
|
||||
"import json; from inse.service import app; open('/mnt/openapi/inse-service.openapi.json', 'w').write(json.dumps(app.openapi(), indent=2))"
|
||||
}
|
||||
|
||||
task runServeContainer(type: Exec) {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
from typing import Any, Optional
|
||||
import httpx
|
||||
from .. import config
|
||||
|
||||
|
||||
def search(
|
||||
index: str,
|
||||
query_field: Optional[str] = None,
|
||||
query_value: Optional[str] = None,
|
||||
payload: Optional[dict[str, Any]] = None,
|
||||
) -> dict[str, Any]:
|
||||
|
||||
headers = {
|
||||
"Authorization": f"ApiKey {config.settings.elasticsearch_api_key}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
if payload is None:
|
||||
payload = {
|
||||
"query": {
|
||||
"query_string": {
|
||||
"default_field": query_field,
|
||||
"query": query_value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
with httpx.Client() as client:
|
||||
response = client.post(
|
||||
f"{config.settings.elasticsearch_url.rstrip('/')}/{index}/_search",
|
||||
json=payload,
|
||||
headers=headers
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
@@ -0,0 +1,32 @@
|
||||
from typing import Any
|
||||
import httpx
|
||||
from .. import config
|
||||
|
||||
|
||||
def call(
|
||||
system_prompt: str,
|
||||
user_prompt: str,
|
||||
model: str = None,
|
||||
stream: bool = False,
|
||||
timeout: int = 30
|
||||
) -> str:
|
||||
|
||||
headers = {
|
||||
"Authorization": f"Bearer {config.settings.llm_api_token}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
if model is None:
|
||||
model = config.settings.llm_model
|
||||
|
||||
payload = {
|
||||
"model": model,
|
||||
"prompt": f"{system_prompt}\n{user_prompt}",
|
||||
"stream": stream
|
||||
}
|
||||
|
||||
with httpx.Client(timeout=timeout) as client:
|
||||
response = client.post(config.settings.llm_api_url, json=payload, headers=headers)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
return data.get("response", "")
|
||||
@@ -20,6 +20,8 @@ import json
|
||||
from . import schema
|
||||
from . import model
|
||||
from . import config
|
||||
from .integrations import elasticsearch
|
||||
from .integrations import llm
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
topic_cache_filename: str = "topic_hierarchy_cache.json"
|
||||
@@ -198,12 +200,21 @@ def count_topic_hierarchy(topic_names: List[str]) -> dict:
|
||||
|
||||
### persons
|
||||
|
||||
def search_persons(author_id: Optional[str] = None, query: Optional[str] = None) -> model.PersonSearchResult:
|
||||
headers = {
|
||||
"Authorization": f"ApiKey {config.settings.elasticsearch_api_key}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
def list_persons(page_offset: int = 0, page_size: int = 20, query: Optional[str] = None,
|
||||
include: Optional[set[str]] = None) -> model.PersonPage:
|
||||
payload = _author_list_query(page_offset, page_size, query)
|
||||
data = elasticsearch.search(index="openalex-authors", payload=payload)
|
||||
persons = _parse_person_hits(data, include)
|
||||
total = _extract_total_hits(data)
|
||||
return model.PersonPage(
|
||||
elements=persons,
|
||||
offset=page_offset,
|
||||
size=page_size,
|
||||
total=total
|
||||
)
|
||||
|
||||
def search_persons(author_id: Optional[str] = None, query: Optional[str] = None,
|
||||
include: Optional[set[str]] = None) -> model.PersonSearchResult:
|
||||
if author_id:
|
||||
query_field = "_id"
|
||||
query_value = author_id
|
||||
@@ -213,20 +224,43 @@ def search_persons(author_id: Optional[str] = None, query: Optional[str] = None)
|
||||
else:
|
||||
return "Either author_id or query must be provided"
|
||||
|
||||
payload = {
|
||||
"query": {
|
||||
data = elasticsearch.search(
|
||||
index="openalex-authors",
|
||||
query_field=query_field,
|
||||
query_value=query_value
|
||||
)
|
||||
|
||||
persons = _parse_person_hits(data, include)
|
||||
return model.PersonSearchResult(persons=persons)
|
||||
|
||||
def _author_list_query(page_offset: int, page_size: int, query: Optional[str] = None) -> dict:
|
||||
search_query = {"match_all": {}}
|
||||
if query:
|
||||
search_query = {
|
||||
"query_string": {
|
||||
"default_field": query_field,
|
||||
"query": query_value
|
||||
"fields": ["display_name^3", "display_name_alternatives", "_id", "ids.orcid"],
|
||||
"query": query
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
"from": page_offset,
|
||||
"size": page_size,
|
||||
"query": search_query,
|
||||
"sort": [
|
||||
{"works_count": {"order": "desc", "missing": "_last"}},
|
||||
{"cited_by_count": {"order": "desc", "missing": "_last"}}
|
||||
]
|
||||
}
|
||||
|
||||
with httpx.Client() as client:
|
||||
response = client.post(config.settings.elasticsearch_url + '/openalex-authors/_search', json=payload, headers=headers)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
def _extract_total_hits(data: dict) -> int:
|
||||
total = data.get("hits", {}).get("total", 0)
|
||||
if isinstance(total, dict):
|
||||
return total.get("value", 0)
|
||||
return total
|
||||
|
||||
def _parse_person_hits(data: dict, include: Optional[set[str]] = None) -> List[model.Person]:
|
||||
include_set = {tag.strip().lower() for tag in include} if include else set()
|
||||
persons = []
|
||||
for hit in data.get("hits", {}).get("hits", []):
|
||||
source = hit.get("_source", {})
|
||||
@@ -241,16 +275,43 @@ def search_persons(author_id: Optional[str] = None, query: Optional[str] = None)
|
||||
|
||||
topics = [t.get("display_name", "") for t in source.get("topics", [])]
|
||||
|
||||
persons.append(model.Person(
|
||||
id=hit.get("_id", ""),
|
||||
name=source.get("display_name", ""),
|
||||
works_count=source.get("works_count", 0),
|
||||
cited_by_count=source.get("cited_by_count", 0),
|
||||
affiliations=affiliations,
|
||||
topics=topics
|
||||
))
|
||||
person_data = {
|
||||
"id": hit.get("_id", ""),
|
||||
"name": source.get("display_name", ""),
|
||||
"works_count": source.get("works_count", 0),
|
||||
"cited_by_count": source.get("cited_by_count", 0),
|
||||
"affiliations": affiliations,
|
||||
"topics": topics
|
||||
}
|
||||
|
||||
return model.PersonSearchResult(persons=persons)
|
||||
# Include optional fields based on the include_set
|
||||
if "topics_full" in include_set:
|
||||
person_data["topics_full"] = source.get("topics", [])
|
||||
if "topic_share" in include_set:
|
||||
person_data["topic_share"] = source.get("topic_share", [])
|
||||
if "summary_stats" in include_set:
|
||||
person_data["summary_stats"] = source.get("summary_stats")
|
||||
if "ids" in include_set:
|
||||
person_data["ids"] = source.get("ids")
|
||||
if "last_known_institutions" in include_set:
|
||||
person_data["last_known_institutions"] = source.get("last_known_institutions", [])
|
||||
if "sources" in include_set:
|
||||
person_data["sources"] = source.get("sources", [])
|
||||
if "counts_by_year" in include_set:
|
||||
person_data["counts_by_year"] = source.get("counts_by_year", [])
|
||||
if "works_api_url" in include_set:
|
||||
person_data["works_api_url"] = source.get("works_api_url")
|
||||
if "dates" in include_set:
|
||||
person_data["dates"] = {
|
||||
"created_date": source.get("created_date"),
|
||||
"updated_date": source.get("updated_date")
|
||||
}
|
||||
if "cited_by_count_boost" in include_set:
|
||||
person_data["cited_by_count_boost"] = source.get("cited_by_count_boost")
|
||||
|
||||
persons.append(model.Person(**person_data))
|
||||
|
||||
return persons
|
||||
|
||||
def generate_person_bio(author_id: str) -> str:
|
||||
search_result = search_persons(author_id=author_id)
|
||||
@@ -265,20 +326,5 @@ def generate_person_bio(author_id: str) -> str:
|
||||
system_prompt = "Erstelle eine Beschreibung der Person in 3-5 Sätzen. Gebe nur die Beschreibung zurück, ohne Einleitung oder Schluss."
|
||||
user_prompt = f"Daten zur Person:\n{person_json}"
|
||||
|
||||
headers = {
|
||||
"Authorization": f"Bearer {config.settings.llm_api_token}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
payload = {
|
||||
"model": config.settings.llm_model,
|
||||
"prompt": f"{system_prompt}\n{user_prompt}",
|
||||
"stream": False
|
||||
}
|
||||
|
||||
with httpx.Client(timeout=30.0) as client:
|
||||
response = client.post(config.settings.llm_api_url, json=payload, headers=headers)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
return data.get("response", "")
|
||||
|
||||
return llm.call(system_prompt=system_prompt, user_prompt=user_prompt)
|
||||
|
||||
|
||||
@@ -57,8 +57,20 @@ class Person(BaseModel):
|
||||
cited_by_count: int = Field(description="Number of citations.")
|
||||
affiliations: List[Affiliation] = Field(default=[], description="Affiliations.")
|
||||
topics: List[str] = Field(default=[], description="Research topics.")
|
||||
# Optional detailed information
|
||||
topics_full: Optional[List[dict]] = Field(default=None, description="Detailed topics with hierarchy.")
|
||||
topic_share: Optional[List[dict]] = Field(default=None, description="Topic share distribution.")
|
||||
summary_stats: Optional[dict] = Field(default=None, description="Summary statistics.")
|
||||
ids: Optional[dict] = Field(default=None, description="External identifiers.")
|
||||
last_known_institutions: Optional[List[dict]] = Field(default=None, description="Last known institutions.")
|
||||
sources: Optional[List[dict]] = Field(default=None, description="Sources list.")
|
||||
counts_by_year: Optional[List[dict]] = Field(default=None, description="Counts by year.")
|
||||
works_api_url: Optional[str] = Field(default=None, description="Works API URL.")
|
||||
dates: Optional[dict] = Field(default=None, description="Created and updated dates.")
|
||||
cited_by_count_boost: Optional[int] = Field(default=None, description="Cited by count boost.")
|
||||
|
||||
class PersonSearchResult(BaseModel):
|
||||
persons: List[Person] = Field(default=[], description="List of found persons.")
|
||||
|
||||
|
||||
class PersonPage(Page[Person]):
|
||||
pass
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
service.
|
||||
"""
|
||||
import logging
|
||||
from typing import Annotated, List
|
||||
from typing import Annotated, List, Optional
|
||||
from fastapi import FastAPI
|
||||
from fastapi import Depends
|
||||
from fastapi import Path
|
||||
@@ -39,81 +39,7 @@ app.include_router(works_service.router)
|
||||
async def show_api():
|
||||
return RedirectResponse("api")
|
||||
|
||||
### items
|
||||
|
||||
@app.get('/items',
|
||||
operation_id='getItems',
|
||||
response_model=model.ItemPage,
|
||||
summary='Returns a page of items.',
|
||||
tags=[ 'Items' ])
|
||||
def get_items(page_offset: Annotated[int, Query(alias='pageOffset', description='The page offset.', ge=0)] = 0,
|
||||
page_size: Annotated[int, Query(alias='pageSize', description='The page size.', ge=0, le=1000)] = 100,
|
||||
db: Session = Depends(database.get),
|
||||
principal: security.Principal = Depends(security.roles_allowed(['SUPER_ADMIN', 'UNI_ADMIN']))):
|
||||
return logic.get_page(db, schema.Item, model.Item, page_offset, page_size)
|
||||
|
||||
@app.get('/items/{id}',
|
||||
operation_id='getItem',
|
||||
response_model=model.Item,
|
||||
summary='Returns the item with the id.',
|
||||
responses={ HTTP_404_NOT_FOUND: { 'model' : None }},
|
||||
tags=[ 'Items' ])
|
||||
def get_item(id: Annotated[int, Path(description='The item id.', ge=0)],
|
||||
db: Session = Depends(database.get),
|
||||
principal: security.Principal = Depends(security.roles_allowed(['SUPER_ADMIN', 'UNI_ADMIN']))):
|
||||
return util.raise_not_found_if_none(logic.get_element(db, schema.Item, id))
|
||||
|
||||
@app.post('/items',
|
||||
operation_id='addItem',
|
||||
response_model=model.Item,
|
||||
summary='Adds a new item.',
|
||||
tags=[ 'Items' ])
|
||||
def add_item(item: Annotated[model.ItemCreate, Body(description='The item to add.')],
|
||||
db: Session = Depends(database.get),
|
||||
principal: security.Principal = Depends(security.roles_allowed(['SUPER_ADMIN', 'UNI_ADMIN']))):
|
||||
i = schema.Item()
|
||||
i.name = item.name
|
||||
i.description = item.description
|
||||
try:
|
||||
return logic.insert_element(db, i)
|
||||
finally:
|
||||
db.commit()
|
||||
|
||||
@app.put('/items/{id}',
|
||||
operation_id='updateItem',
|
||||
response_model=model.Item,
|
||||
summary='Updates the item with the id.',
|
||||
responses={ HTTP_404_NOT_FOUND: { 'model' : None }},
|
||||
tags=[ 'Items' ])
|
||||
def update_item(id: Annotated[int, Path(description='The item id.', ge=0)],
|
||||
item: Annotated[model.ItemCreate, Body(description='The item data to update.')],
|
||||
db: Session = Depends(database.get),
|
||||
principal: security.Principal = Depends(security.roles_allowed(['SUPER_ADMIN', 'UNI_ADMIN']))):
|
||||
i = util.raise_not_found_if_none(logic.get_element(db, schema.Item, id))
|
||||
i.name = item.name
|
||||
i.description = item.description
|
||||
db.flush()
|
||||
db.refresh(i)
|
||||
try:
|
||||
return i
|
||||
finally:
|
||||
db.commit()
|
||||
|
||||
@app.delete('/items/{id}',
|
||||
operation_id='deleteItem',
|
||||
summary='Deletes the item with the id.',
|
||||
response_model=None,
|
||||
responses={ HTTP_404_NOT_FOUND: { 'model' : None }},
|
||||
tags=[ 'Items' ])
|
||||
def delete_item(id: Annotated[int, Path(description='The item id.', ge=0)],
|
||||
db: Session = Depends(database.get),
|
||||
principal: security.Principal = Depends(security.roles_allowed(['SUPER_ADMIN', 'UNI_ADMIN']))):
|
||||
util.raise_not_found_if_none(logic.get_element(db, schema.Item, id))
|
||||
try:
|
||||
logic.delete_element(db, schema.Item, id)
|
||||
return Response(status_code=HTTP_200_OK)
|
||||
finally:
|
||||
db.commit()
|
||||
### topics
|
||||
# hierarchy cache (temporaray => should be called by a scheduled job, with new openalex data indexing)
|
||||
@app.get('/topics/cache',
|
||||
@@ -152,14 +78,44 @@ def count_topic_hierarchy(
|
||||
|
||||
### persons
|
||||
|
||||
@app.get('/persons',
|
||||
operation_id='getPersons',
|
||||
response_model=model.PersonPage,
|
||||
summary='Returns a page of OpenAlex authors.',
|
||||
response_model_exclude_none=True,
|
||||
tags=[ 'Persons' ])
|
||||
def get_persons(page_offset: Annotated[int, Query(alias='pageOffset', description='The page offset.', ge=0)] = 0,
|
||||
page_size: Annotated[int, Query(alias='pageSize', description='The page size.', ge=1, le=100)] = 20,
|
||||
query: Annotated[Optional[str], Query(description="Optional author search query.")] = None,
|
||||
include: Annotated[Optional[str], Query(
|
||||
description=(
|
||||
"Comma-separated include tags: topics_full, topic_share, summary_stats, ids, "
|
||||
"last_known_institutions, sources, counts_by_year, works_api_url, dates, "
|
||||
"cited_by_count_boost"
|
||||
),
|
||||
example="topics_full,topic_share"
|
||||
)] = None):
|
||||
include_set = {tag.strip().lower() for tag in include.split(",") if tag.strip()} if include else None
|
||||
return logic.list_persons(page_offset=page_offset, page_size=page_size, query=query, include=include_set)
|
||||
|
||||
@app.get('/persons/search',
|
||||
operation_id='searchPersons',
|
||||
response_model=model.PersonSearchResult,
|
||||
summary='Searches for persons by ID or name.',
|
||||
response_model_exclude_none=True,
|
||||
tags=[ 'Persons' ])
|
||||
def search_persons(author_id: Annotated[str, Query(description="OpenAlex author ID (e.g., A5093075883)")] = None,
|
||||
query: Annotated[str, Query(description="Search query (e.g., Arman AND Arzani)")] = None):
|
||||
return logic.search_persons(author_id, query)
|
||||
query: Annotated[str, Query(description="Search query (e.g., Arman AND Arzani)")] = None,
|
||||
include: Annotated[Optional[str], Query(
|
||||
description=(
|
||||
"Comma-separated include tags: topics_full, topic_share, summary_stats, ids, "
|
||||
"last_known_institutions, sources, counts_by_year, works_api_url, dates, "
|
||||
"cited_by_count_boost"
|
||||
),
|
||||
example="topics_full,topic_share"
|
||||
)] = None):
|
||||
include_set = {tag.strip().lower() for tag in include.split(",") if tag.strip()} if include else None
|
||||
return logic.search_persons(author_id, query, include_set)
|
||||
|
||||
@app.get('/persons/bio',
|
||||
operation_id='generatePersonBio',
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from inse import logic
|
||||
from inse import model
|
||||
from inse.main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_list_persons_searches_openalex_authors(monkeypatch):
|
||||
captured = {}
|
||||
|
||||
def fake_search(index, payload=None, **_):
|
||||
captured["index"] = index
|
||||
captured["payload"] = payload
|
||||
return {
|
||||
"hits": {
|
||||
"total": {"value": 1},
|
||||
"hits": [
|
||||
{
|
||||
"_id": "A5023888391",
|
||||
"_source": {
|
||||
"display_name": "Ada Lovelace",
|
||||
"works_count": 42,
|
||||
"cited_by_count": 1234,
|
||||
"topics": [{"display_name": "Computer Science"}],
|
||||
"affiliations": [
|
||||
{
|
||||
"institution": {
|
||||
"display_name": "University of Example",
|
||||
"country_code": "DE",
|
||||
}
|
||||
}
|
||||
],
|
||||
},
|
||||
}
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
monkeypatch.setattr(logic.elasticsearch, "search", fake_search)
|
||||
|
||||
page = logic.list_persons(page_offset=20, page_size=10, query="Ada")
|
||||
|
||||
assert captured["index"] == "openalex-authors"
|
||||
assert captured["payload"]["from"] == 20
|
||||
assert captured["payload"]["size"] == 10
|
||||
assert captured["payload"]["query"]["query_string"]["query"] == "Ada"
|
||||
assert page.total == 1
|
||||
assert page.elements[0].id == "A5023888391"
|
||||
assert page.elements[0].name == "Ada Lovelace"
|
||||
assert page.elements[0].topics == ["Computer Science"]
|
||||
assert page.elements[0].affiliations[0].institution == "University of Example"
|
||||
|
||||
|
||||
def test_list_persons_uses_match_all_without_query(monkeypatch):
|
||||
captured = {}
|
||||
|
||||
def fake_search(index, payload=None, **_):
|
||||
captured["payload"] = payload
|
||||
return {"hits": {"total": 0, "hits": []}}
|
||||
|
||||
monkeypatch.setattr(logic.elasticsearch, "search", fake_search)
|
||||
|
||||
page = logic.list_persons(page_offset=0, page_size=20)
|
||||
|
||||
assert captured["payload"]["query"] == {"match_all": {}}
|
||||
assert page.elements == []
|
||||
assert page.total == 0
|
||||
|
||||
|
||||
def test_get_persons_endpoint_returns_page(monkeypatch):
|
||||
def fake_list_persons(page_offset=0, page_size=20, query=None, include=None):
|
||||
assert page_offset == 5
|
||||
assert page_size == 10
|
||||
assert query == "Ada"
|
||||
assert include == {"ids"}
|
||||
return model.PersonPage(
|
||||
offset=5,
|
||||
size=10,
|
||||
total=1,
|
||||
elements=[
|
||||
model.Person(
|
||||
id="A5023888391",
|
||||
name="Ada Lovelace",
|
||||
works_count=42,
|
||||
cited_by_count=1234,
|
||||
affiliations=[],
|
||||
topics=[],
|
||||
ids={"openalex": "https://openalex.org/A5023888391"},
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
monkeypatch.setattr(logic, "list_persons", fake_list_persons)
|
||||
|
||||
response = client.get("/inse-service/persons?pageOffset=5&pageSize=10&query=Ada&include=ids")
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["offset"] == 5
|
||||
assert data["size"] == 10
|
||||
assert data["total"] == 1
|
||||
assert data["elements"][0]["name"] == "Ada Lovelace"
|
||||
assert data["elements"][0]["ids"]["openalex"] == "https://openalex.org/A5023888391"
|
||||
@@ -22,11 +22,72 @@ async def get_author_works(
|
||||
author_id: str,
|
||||
page: int,
|
||||
size: int,
|
||||
publication_year: list[int] | None = None,
|
||||
work_type: list[str] | None = None,
|
||||
language: list[str] | None = None,
|
||||
client: OpenAlexWorksSearchClient | None = None,
|
||||
) -> model.WorkPage:
|
||||
search_client = client or OpenAlexWorksSearchClient()
|
||||
data = await _search_author_works_data(
|
||||
search_client,
|
||||
author_id,
|
||||
page,
|
||||
size,
|
||||
publication_year=publication_year,
|
||||
work_type=work_type,
|
||||
language=language,
|
||||
)
|
||||
|
||||
elements, total = _parse_work_search_response(data)
|
||||
return model.WorkPage(elements=elements, page=page, size=size, total=total)
|
||||
|
||||
|
||||
async def get_all_author_works(
|
||||
author_id: str,
|
||||
client: OpenAlexWorksSearchClient | None = None,
|
||||
) -> model.WorkList:
|
||||
search_client = client or OpenAlexWorksSearchClient()
|
||||
page = 1
|
||||
size = 100
|
||||
all_elements: list[model.Work] = []
|
||||
total = 0
|
||||
|
||||
while True:
|
||||
data = await _search_author_works_data(
|
||||
search_client,
|
||||
author_id,
|
||||
page,
|
||||
size,
|
||||
)
|
||||
elements, total = _parse_full_work_search_response(data)
|
||||
all_elements.extend(elements)
|
||||
|
||||
if not elements or len(all_elements) >= total:
|
||||
break
|
||||
|
||||
page += 1
|
||||
|
||||
return model.WorkList(elements=all_elements, total=total)
|
||||
|
||||
|
||||
async def _search_author_works_data(
|
||||
search_client: OpenAlexWorksSearchClient,
|
||||
author_id: str,
|
||||
page: int,
|
||||
size: int,
|
||||
publication_year: list[int] | None = None,
|
||||
work_type: list[str] | None = None,
|
||||
language: list[str] | None = None,
|
||||
) -> dict:
|
||||
try:
|
||||
data = await search_client.search_author_works(author_id, page, size)
|
||||
return await search_client.search_author_works(
|
||||
author_id,
|
||||
page,
|
||||
size,
|
||||
publication_year=publication_year,
|
||||
work_type=work_type,
|
||||
language=language,
|
||||
)
|
||||
except MissingApiKeyError as exc:
|
||||
logger.error("OpenAlex works Elasticsearch API key is not configured.")
|
||||
raise HTTPException(
|
||||
@@ -40,6 +101,8 @@ async def get_author_works(
|
||||
detail="OpenAlex works search request failed.",
|
||||
) from exc
|
||||
|
||||
|
||||
def _parse_work_search_response(data: dict) -> tuple[list[model.WorkSummary], int]:
|
||||
hits = data.get("hits", {})
|
||||
total = hits.get("total", 0)
|
||||
if isinstance(total, dict):
|
||||
@@ -57,7 +120,28 @@ async def get_author_works(
|
||||
detail="OpenAlex works search response could not be parsed.",
|
||||
) from exc
|
||||
|
||||
return model.WorkPage(elements=elements, page=page, size=size, total=total)
|
||||
return elements, total
|
||||
|
||||
|
||||
def _parse_full_work_search_response(data: dict) -> tuple[list[model.Work], int]:
|
||||
hits = data.get("hits", {})
|
||||
total = hits.get("total", 0)
|
||||
if isinstance(total, dict):
|
||||
total = total.get("value", 0)
|
||||
|
||||
try:
|
||||
elements = [
|
||||
model.Work.model_validate(hit.get("_source", {}))
|
||||
for hit in hits.get("hits", [])
|
||||
]
|
||||
except ValidationError as exc:
|
||||
logger.exception("OpenAlex works search response could not be parsed.")
|
||||
raise HTTPException(
|
||||
status_code=HTTP_502_BAD_GATEWAY,
|
||||
detail="OpenAlex works search response could not be parsed.",
|
||||
) from exc
|
||||
|
||||
return elements, total
|
||||
|
||||
|
||||
def _to_work_summary(source: dict) -> dict:
|
||||
|
||||
@@ -211,3 +211,8 @@ class WorkPage(BaseModel):
|
||||
page: int = Field(default=1, 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 works.")
|
||||
|
||||
|
||||
class WorkList(BaseModel):
|
||||
elements: List[Work] = Field(default_factory=list, description="All works.")
|
||||
total: int = Field(default=0, description="The total number of works.")
|
||||
|
||||
@@ -29,19 +29,35 @@ class OpenAlexWorksSearchClient:
|
||||
self.timeout = timeout if timeout is not None else config.settings.openalex_works_search_timeout_seconds
|
||||
self.transport = transport
|
||||
|
||||
def author_works_query(self, author_id: str, page: int, size: int) -> dict[str, Any]:
|
||||
def author_works_query(
|
||||
self,
|
||||
author_id: str,
|
||||
page: int,
|
||||
size: int,
|
||||
publication_year: list[int] | None = None,
|
||||
work_type: list[str] | None = None,
|
||||
language: list[str] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
indexed_author_id = f"https://openalex.org/{author_id.strip()}"
|
||||
filters = self._work_filters(publication_year, work_type, language)
|
||||
return {
|
||||
"from": (page - 1) * size,
|
||||
"size": size,
|
||||
"query": {
|
||||
"nested": {
|
||||
"path": "authorships",
|
||||
"query": {
|
||||
"term": {
|
||||
"authorships.author.id": indexed_author_id,
|
||||
"bool": {
|
||||
"must": [
|
||||
{
|
||||
"nested": {
|
||||
"path": "authorships",
|
||||
"query": {
|
||||
"term": {
|
||||
"authorships.author.id": indexed_author_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
"filter": filters,
|
||||
},
|
||||
},
|
||||
"sort": [
|
||||
@@ -50,7 +66,30 @@ class OpenAlexWorksSearchClient:
|
||||
],
|
||||
}
|
||||
|
||||
async def search_author_works(self, author_id: str, page: int, size: int) -> dict[str, Any]:
|
||||
def _work_filters(
|
||||
self,
|
||||
publication_year: list[int] | None = None,
|
||||
work_type: list[str] | None = None,
|
||||
language: list[str] | None = None,
|
||||
) -> list[dict[str, Any]]:
|
||||
filters: list[dict[str, Any]] = []
|
||||
if publication_year:
|
||||
filters.append({"terms": {"publication_year": publication_year}})
|
||||
if work_type:
|
||||
filters.append({"terms": {"type": work_type}})
|
||||
if language:
|
||||
filters.append({"terms": {"language": language}})
|
||||
return filters
|
||||
|
||||
async def search_author_works(
|
||||
self,
|
||||
author_id: str,
|
||||
page: int,
|
||||
size: int,
|
||||
publication_year: list[int] | None = None,
|
||||
work_type: list[str] | None = None,
|
||||
language: list[str] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
if not self.api_key:
|
||||
raise MissingApiKeyError("OpenAlex works Elasticsearch API key is not configured.")
|
||||
|
||||
@@ -62,7 +101,14 @@ class OpenAlexWorksSearchClient:
|
||||
response = await client.post(
|
||||
f"/{self.index}/_search",
|
||||
headers={"Authorization": f"ApiKey {self.api_key}"},
|
||||
json=self.author_works_query(author_id, page, size),
|
||||
json=self.author_works_query(
|
||||
author_id,
|
||||
page,
|
||||
size,
|
||||
publication_year=publication_year,
|
||||
work_type=work_type,
|
||||
language=language,
|
||||
),
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
|
||||
@@ -26,6 +26,27 @@ async def get_author_works(
|
||||
author_id: Annotated[str, Path(description="The author id, for example A5023888391.")],
|
||||
page: Annotated[int, Query(description="The page number.", ge=1)] = 1,
|
||||
size: Annotated[int, Query(description="The page size.", ge=1, le=100)] = 20,
|
||||
publication_year: Annotated[list[int] | None, Query(description="Filter by publication year. Can be repeated.")] = None,
|
||||
work_type: Annotated[list[str] | None, Query(alias="type", description="Filter by publication type. Can be repeated.")] = None,
|
||||
language: Annotated[list[str] | None, Query(description="Filter by language code. Can be repeated.")] = None,
|
||||
principal: security.Principal = Depends(security.roles_allowed(["SUPER_ADMIN", "UNI_ADMIN"])),
|
||||
):
|
||||
return await logic.get_author_works(author_id, page, size)
|
||||
return await logic.get_author_works(
|
||||
author_id,
|
||||
page,
|
||||
size,
|
||||
publication_year=publication_year,
|
||||
work_type=work_type,
|
||||
language=language,
|
||||
)
|
||||
|
||||
|
||||
@router.get("/{author_id}/works/all",
|
||||
operation_id="getAllAuthorWorks",
|
||||
response_model=model.WorkList,
|
||||
summary="Returns all works for an author.")
|
||||
async def get_all_author_works(
|
||||
author_id: Annotated[str, Path(description="The author id, for example A5023888391.")],
|
||||
principal: security.Principal = Depends(security.roles_allowed(["SUPER_ADMIN", "UNI_ADMIN"])),
|
||||
):
|
||||
return await logic.get_all_author_works(author_id)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import json
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
from fastapi import HTTPException
|
||||
@@ -76,6 +78,73 @@ async def test_get_author_works_maps_elasticsearch_response_to_work_page():
|
||||
assert page.elements[0].topics == ["Machine learning"]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_get_all_author_works_collects_all_pages():
|
||||
requested_pages = []
|
||||
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
payload = json_from_request(request)
|
||||
requested_pages.append(payload["from"] // payload["size"] + 1)
|
||||
page = requested_pages[-1]
|
||||
hits = [
|
||||
{
|
||||
"_source": {
|
||||
"id": f"https://openalex.org/W{page}",
|
||||
"doi": f"https://doi.org/10.1234/example-{page}",
|
||||
"title": f"Example work {page}",
|
||||
"display_name": f"Example work {page}",
|
||||
"type": "article",
|
||||
"language": "en",
|
||||
"publication_year": 2024,
|
||||
"publication_date": "2024-01-01",
|
||||
"cited_by_count": page,
|
||||
"primary_location": {
|
||||
"is_oa": True,
|
||||
"source": {
|
||||
"id": "https://openalex.org/S123",
|
||||
"display_name": "Example Source",
|
||||
},
|
||||
},
|
||||
"authorships": [
|
||||
{
|
||||
"author": {
|
||||
"id": "https://openalex.org/A5023888391",
|
||||
"display_name": "Example Author",
|
||||
},
|
||||
},
|
||||
],
|
||||
"topics": [],
|
||||
}
|
||||
}
|
||||
]
|
||||
return httpx.Response(
|
||||
200,
|
||||
json={
|
||||
"hits": {
|
||||
"total": {"value": 2},
|
||||
"hits": hits,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
client = OpenAlexWorksSearchClient(
|
||||
base_url="https://project.nes.uni-due.de/elastic",
|
||||
api_key="test-key",
|
||||
transport=httpx.MockTransport(handler),
|
||||
)
|
||||
|
||||
works = await logic.get_all_author_works("A5023888391", client=client)
|
||||
|
||||
assert requested_pages == [1, 2]
|
||||
assert works.total == 2
|
||||
assert [work.title for work in works.elements] == ["Example work 1", "Example work 2"]
|
||||
assert works.elements[0].id == "https://openalex.org/W1"
|
||||
assert works.elements[0].display_name == "Example work 1"
|
||||
assert works.elements[0].publication_date == "2024-01-01"
|
||||
assert works.elements[0].primary_location.is_oa is True
|
||||
assert works.elements[0].authorships[0].author.id == "https://openalex.org/A5023888391"
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_get_author_works_maps_missing_api_key_to_service_unavailable():
|
||||
client = OpenAlexWorksSearchClient(api_key="")
|
||||
@@ -101,3 +170,7 @@ async def test_get_author_works_maps_elasticsearch_errors_to_bad_gateway():
|
||||
await logic.get_author_works("A5023888391", page=1, size=20, client=client)
|
||||
|
||||
assert exc.value.status_code == 502
|
||||
|
||||
|
||||
def json_from_request(request: httpx.Request) -> dict:
|
||||
return json.loads(request.content.decode("utf-8"))
|
||||
|
||||
@@ -17,8 +17,29 @@ def test_author_works_query_searches_authorship_author_id():
|
||||
|
||||
assert query["from"] == 25
|
||||
assert query["size"] == 25
|
||||
assert query["query"]["nested"]["path"] == "authorships"
|
||||
assert query["query"]["nested"]["query"]["term"]["authorships.author.id"] == "https://openalex.org/A5023888391"
|
||||
author_query = query["query"]["bool"]["must"][0]["nested"]
|
||||
assert author_query["path"] == "authorships"
|
||||
assert author_query["query"]["term"]["authorships.author.id"] == "https://openalex.org/A5023888391"
|
||||
assert query["query"]["bool"]["filter"] == []
|
||||
|
||||
|
||||
def test_author_works_query_adds_publication_filters():
|
||||
client = OpenAlexWorksSearchClient(api_key="test-key")
|
||||
|
||||
query = client.author_works_query(
|
||||
"A5023888391",
|
||||
page=1,
|
||||
size=20,
|
||||
publication_year=[2023, 2024],
|
||||
work_type=["article", "book-chapter"],
|
||||
language=["en", "de"],
|
||||
)
|
||||
|
||||
assert query["query"]["bool"]["filter"] == [
|
||||
{"terms": {"publication_year": [2023, 2024]}},
|
||||
{"terms": {"type": ["article", "book-chapter"]}},
|
||||
{"terms": {"language": ["en", "de"]}},
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
||||
@@ -12,10 +12,20 @@ client = TestClient(app)
|
||||
def test_get_author_works_returns_page(monkeypatch):
|
||||
config.settings.auth_disabled = True
|
||||
|
||||
async def fake_get_author_works(author_id: str, page: int, size: int):
|
||||
async def fake_get_author_works(
|
||||
author_id: str,
|
||||
page: int,
|
||||
size: int,
|
||||
publication_year: list[int] | None = None,
|
||||
work_type: list[str] | None = None,
|
||||
language: list[str] | None = None,
|
||||
):
|
||||
assert author_id == "A5023888391"
|
||||
assert page == 2
|
||||
assert size == 5
|
||||
assert publication_year == [2023, 2024]
|
||||
assert work_type == ["article"]
|
||||
assert language == ["en"]
|
||||
return model.WorkPage(
|
||||
elements=[
|
||||
model.WorkSummary(
|
||||
@@ -35,7 +45,10 @@ def test_get_author_works_returns_page(monkeypatch):
|
||||
|
||||
monkeypatch.setattr(logic, "get_author_works", fake_get_author_works)
|
||||
|
||||
response = client.get("/inse-service/authors/A5023888391/works?page=2&size=5")
|
||||
response = client.get(
|
||||
"/inse-service/authors/A5023888391/works"
|
||||
"?page=2&size=5&publication_year=2023&publication_year=2024&type=article&language=en"
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
@@ -51,3 +64,45 @@ def test_get_author_works_returns_page(monkeypatch):
|
||||
"cited_by_count": 42,
|
||||
"topics": ["Machine learning"],
|
||||
}
|
||||
|
||||
|
||||
def test_get_all_author_works_returns_list(monkeypatch):
|
||||
config.settings.auth_disabled = True
|
||||
|
||||
async def fake_get_all_author_works(
|
||||
author_id: str,
|
||||
):
|
||||
assert author_id == "A5023888391"
|
||||
return model.WorkList(
|
||||
elements=[
|
||||
model.Work(
|
||||
id="https://openalex.org/W2741809807",
|
||||
doi="https://doi.org/10.7717/peerj.4375",
|
||||
title="Example work",
|
||||
display_name="Example work",
|
||||
type="article",
|
||||
language="en",
|
||||
publication_year=2023,
|
||||
cited_by_count=42,
|
||||
topics=[
|
||||
model.Topic(
|
||||
id="https://openalex.org/T10102",
|
||||
display_name="Machine learning",
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
total=1,
|
||||
)
|
||||
|
||||
monkeypatch.setattr(logic, "get_all_author_works", fake_get_all_author_works)
|
||||
|
||||
response = client.get("/inse-service/authors/A5023888391/works/all")
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["total"] == 1
|
||||
assert data["elements"][0]["id"] == "https://openalex.org/W2741809807"
|
||||
assert data["elements"][0]["title"] == "Example work"
|
||||
assert data["elements"][0]["display_name"] == "Example work"
|
||||
assert data["elements"][0]["topics"][0]["display_name"] == "Machine learning"
|
||||
|
||||
@@ -7,6 +7,8 @@ api/items.service.ts
|
||||
api/items.serviceInterface.ts
|
||||
api/persons.service.ts
|
||||
api/persons.serviceInterface.ts
|
||||
api/topics.service.ts
|
||||
api/topics.serviceInterface.ts
|
||||
api/works.service.ts
|
||||
api/works.serviceInterface.ts
|
||||
configuration.ts
|
||||
@@ -14,18 +16,39 @@ encoder.ts
|
||||
git_push.sh
|
||||
index.ts
|
||||
model/affiliation.ts
|
||||
model/author.ts
|
||||
model/authorship.ts
|
||||
model/award.ts
|
||||
model/biblio.ts
|
||||
model/citation-normalized-percentile.ts
|
||||
model/cited-by-percentile-year.ts
|
||||
model/count-by-year.ts
|
||||
model/funder.ts
|
||||
model/has-content.ts
|
||||
model/http-validation-error.ts
|
||||
model/institution.ts
|
||||
model/item-create.ts
|
||||
model/item-page.ts
|
||||
model/item.ts
|
||||
model/keyword.ts
|
||||
model/location.ts
|
||||
model/mesh.ts
|
||||
model/models.ts
|
||||
model/open-access.ts
|
||||
model/person-bio.ts
|
||||
model/person-search-result.ts
|
||||
model/person.ts
|
||||
model/source.ts
|
||||
model/sustainable-development-goal.ts
|
||||
model/topic-level.ts
|
||||
model/topic.ts
|
||||
model/validation-error-loc-inner.ts
|
||||
model/validation-error.ts
|
||||
model/work-ids.ts
|
||||
model/work-list.ts
|
||||
model/work-page.ts
|
||||
model/work-summary.ts
|
||||
model/work.ts
|
||||
param.ts
|
||||
provide-api.ts
|
||||
variables.ts
|
||||
|
||||
@@ -4,7 +4,10 @@ export * from './items.serviceInterface';
|
||||
export * from './persons.service';
|
||||
import { PersonsOpenApiService } from './persons.service';
|
||||
export * from './persons.serviceInterface';
|
||||
export * from './topics.service';
|
||||
import { TopicsOpenApiService } from './topics.service';
|
||||
export * from './topics.serviceInterface';
|
||||
export * from './works.service';
|
||||
import { WorksOpenApiService } from './works.service';
|
||||
export * from './works.serviceInterface';
|
||||
export const APIS = [ItemsOpenApiService, PersonsOpenApiService, WorksOpenApiService];
|
||||
export const APIS = [ItemsOpenApiService, PersonsOpenApiService, TopicsOpenApiService, WorksOpenApiService];
|
||||
|
||||
@@ -107,19 +107,22 @@ export class PersonsOpenApiService extends BaseService implements PersonsOpenApi
|
||||
* @endpoint get /persons/search
|
||||
* @param authorId OpenAlex author ID (e.g., A5093075883)
|
||||
* @param query Search query (e.g., Arman AND Arzani)
|
||||
* @param include Comma-separated include tags: topics_full, topic_share, summary_stats, ids, last_known_institutions, sources, counts_by_year, works_api_url, dates, cited_by_count_boost
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public searchPersons(authorId?: string, query?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<PersonSearchResult>;
|
||||
public searchPersons(authorId?: string, query?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<PersonSearchResult>>;
|
||||
public searchPersons(authorId?: string, query?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<PersonSearchResult>>;
|
||||
public searchPersons(authorId?: string, query?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
public searchPersons(authorId?: string, query?: string, include?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<PersonSearchResult>;
|
||||
public searchPersons(authorId?: string, query?: string, include?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<PersonSearchResult>>;
|
||||
public searchPersons(authorId?: string, query?: string, include?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<PersonSearchResult>>;
|
||||
public searchPersons(authorId?: string, query?: string, include?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
|
||||
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>authorId, 'author_id');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>query, 'query');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>include, 'include');
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ export interface PersonsOpenApiServiceInterface {
|
||||
* @endpoint get /persons/search
|
||||
* @param authorId OpenAlex author ID (e.g., A5093075883)
|
||||
* @param query Search query (e.g., Arman AND Arzani)
|
||||
* @param include Comma-separated include tags: topics_full, topic_share, summary_stats, ids, last_known_institutions, sources, counts_by_year, works_api_url, dates, cited_by_count_boost
|
||||
*/
|
||||
searchPersons(authorId?: string, query?: string, extraHttpRequestParams?: any): Observable<PersonSearchResult>;
|
||||
searchPersons(authorId?: string, query?: string, include?: string, extraHttpRequestParams?: any): Observable<PersonSearchResult>;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders, HttpParams,
|
||||
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
|
||||
} from '@angular/common/http';
|
||||
import { CustomHttpParameterCodec } from '../encoder';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
// @ts-ignore
|
||||
import { HTTPValidationError } from '../model/http-validation-error';
|
||||
|
||||
// @ts-ignore
|
||||
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||
import { Configuration } from '../configuration';
|
||||
import { BaseService } from '../api.base.service';
|
||||
import {
|
||||
TopicsOpenApiServiceInterface
|
||||
} from './topics.serviceInterface';
|
||||
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TopicsOpenApiService extends BaseService implements TopicsOpenApiServiceInterface {
|
||||
|
||||
constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: Configuration) {
|
||||
super(basePath, configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the topic hierarchy cache.
|
||||
* @endpoint get /topics/cache
|
||||
* @param pageSize Page size for each search page.
|
||||
* @param saveJson Persist cache JSON to data folder.
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public buildTopicCache(pageSize?: number, saveJson?: boolean, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<object>;
|
||||
public buildTopicCache(pageSize?: number, saveJson?: boolean, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<object>>;
|
||||
public buildTopicCache(pageSize?: number, saveJson?: boolean, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<object>>;
|
||||
public buildTopicCache(pageSize?: number, saveJson?: boolean, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
|
||||
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>pageSize, 'page_size');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>saveJson, 'save_json');
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
|
||||
'application/json'
|
||||
]);
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
|
||||
|
||||
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
||||
|
||||
|
||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||
if (localVarHttpHeaderAcceptSelected) {
|
||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||
responseType_ = 'json';
|
||||
} else {
|
||||
responseType_ = 'blob';
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/topics/cache`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<object>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
params: localVarQueryParameters,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts topic hierarchy occurrences from cache.
|
||||
* @endpoint get /topics/count
|
||||
* @param topic Topic names (repeat parameter).
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public countTopicHierarchy(topic: Array<string>, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<object>;
|
||||
public countTopicHierarchy(topic: Array<string>, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<object>>;
|
||||
public countTopicHierarchy(topic: Array<string>, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<object>>;
|
||||
public countTopicHierarchy(topic: Array<string>, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (topic === null || topic === undefined) {
|
||||
throw new Error('Required parameter topic was null or undefined when calling countTopicHierarchy.');
|
||||
}
|
||||
|
||||
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
|
||||
if (topic) {
|
||||
topic.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'topic');
|
||||
})
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
|
||||
'application/json'
|
||||
]);
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
|
||||
|
||||
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
||||
|
||||
|
||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||
if (localVarHttpHeaderAcceptSelected) {
|
||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||
responseType_ = 'json';
|
||||
} else {
|
||||
responseType_ = 'blob';
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/topics/count`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<object>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
params: localVarQueryParameters,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { HttpHeaders } from '@angular/common/http';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { HTTPValidationError } from '../model/models';
|
||||
|
||||
|
||||
import { Configuration } from '../configuration';
|
||||
|
||||
|
||||
|
||||
export interface TopicsOpenApiServiceInterface {
|
||||
defaultHeaders: HttpHeaders;
|
||||
configuration: Configuration;
|
||||
|
||||
/**
|
||||
* Builds the topic hierarchy cache.
|
||||
*
|
||||
* @endpoint get /topics/cache
|
||||
* @param pageSize Page size for each search page.
|
||||
* @param saveJson Persist cache JSON to data folder.
|
||||
*/
|
||||
buildTopicCache(pageSize?: number, saveJson?: boolean, extraHttpRequestParams?: any): Observable<object>;
|
||||
|
||||
/**
|
||||
* Counts topic hierarchy occurrences from cache.
|
||||
*
|
||||
* @endpoint get /topics/count
|
||||
* @param topic Topic names (repeat parameter).
|
||||
*/
|
||||
countTopicHierarchy(topic: Array<string>, extraHttpRequestParams?: any): Observable<object>;
|
||||
|
||||
}
|
||||
@@ -19,6 +19,8 @@ import { Observable } from 'rxjs';
|
||||
// @ts-ignore
|
||||
import { HTTPValidationError } from '../model/http-validation-error';
|
||||
// @ts-ignore
|
||||
import { WorkList } from '../model/work-list';
|
||||
// @ts-ignore
|
||||
import { WorkPage } from '../model/work-page';
|
||||
|
||||
// @ts-ignore
|
||||
@@ -40,19 +42,80 @@ export class WorksOpenApiService extends BaseService implements WorksOpenApiServ
|
||||
super(basePath, configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all works for an author.
|
||||
* @endpoint get /authors/{author_id}/works/all
|
||||
* @param authorId The author id, for example A5023888391.
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getAllAuthorWorks(authorId: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<WorkList>;
|
||||
public getAllAuthorWorks(authorId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<WorkList>>;
|
||||
public getAllAuthorWorks(authorId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<WorkList>>;
|
||||
public getAllAuthorWorks(authorId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (authorId === null || authorId === undefined) {
|
||||
throw new Error('Required parameter authorId was null or undefined when calling getAllAuthorWorks.');
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
// authentication (bearer) required
|
||||
localVarHeaders = this.configuration.addCredentialToHeaders('bearer', 'Authorization', localVarHeaders, 'Bearer ');
|
||||
|
||||
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
|
||||
'application/json'
|
||||
]);
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
|
||||
|
||||
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
||||
|
||||
|
||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||
if (localVarHttpHeaderAcceptSelected) {
|
||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||
responseType_ = 'json';
|
||||
} else {
|
||||
responseType_ = 'blob';
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/authors/${this.configuration.encodeParam({name: "authorId", value: authorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/works/all`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<WorkList>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a page of works for an author.
|
||||
* @endpoint get /authors/{author_id}/works
|
||||
* @param authorId The author id, for example A5023888391.
|
||||
* @param page The page number.
|
||||
* @param size The page size.
|
||||
* @param publicationYear Filter by publication year. Can be repeated.
|
||||
* @param type Filter by publication type. Can be repeated.
|
||||
* @param language Filter by language code. Can be repeated.
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<WorkPage>;
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<WorkPage>>;
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<WorkPage>>;
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<WorkPage>;
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<WorkPage>>;
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<WorkPage>>;
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (authorId === null || authorId === undefined) {
|
||||
throw new Error('Required parameter authorId was null or undefined when calling getAuthorWorks.');
|
||||
}
|
||||
@@ -62,6 +125,24 @@ export class WorksOpenApiService extends BaseService implements WorksOpenApiServ
|
||||
<any>page, 'page');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>size, 'size');
|
||||
if (publicationYear) {
|
||||
publicationYear.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'publication_year');
|
||||
})
|
||||
}
|
||||
if (type) {
|
||||
type.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'type');
|
||||
})
|
||||
}
|
||||
if (language) {
|
||||
language.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'language');
|
||||
})
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import { HttpHeaders } from '@angular/comm
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { HTTPValidationError } from '../model/models';
|
||||
import { WorkList } from '../model/models';
|
||||
import { WorkPage } from '../model/models';
|
||||
|
||||
|
||||
@@ -23,6 +24,14 @@ export interface WorksOpenApiServiceInterface {
|
||||
defaultHeaders: HttpHeaders;
|
||||
configuration: Configuration;
|
||||
|
||||
/**
|
||||
* Returns all works for an author.
|
||||
*
|
||||
* @endpoint get /authors/{author_id}/works/all
|
||||
* @param authorId The author id, for example A5023888391.
|
||||
*/
|
||||
getAllAuthorWorks(authorId: string, extraHttpRequestParams?: any): Observable<WorkList>;
|
||||
|
||||
/**
|
||||
* Returns a page of works for an author.
|
||||
*
|
||||
@@ -30,7 +39,10 @@ export interface WorksOpenApiServiceInterface {
|
||||
* @param authorId The author id, for example A5023888391.
|
||||
* @param page The page number.
|
||||
* @param size The page size.
|
||||
* @param publicationYear Filter by publication year. Can be repeated.
|
||||
* @param type Filter by publication type. Can be repeated.
|
||||
* @param language Filter by language code. Can be repeated.
|
||||
*/
|
||||
getAuthorWorks(authorId: string, page?: number, size?: number, extraHttpRequestParams?: any): Observable<WorkPage>;
|
||||
getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, extraHttpRequestParams?: any): Observable<WorkPage>;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface Author {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
orcid?: string | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { Author } from './author';
|
||||
import { Institution } from './institution';
|
||||
|
||||
|
||||
export interface Authorship {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
author?: Author | null;
|
||||
/**
|
||||
* The author\'s institutions.
|
||||
*/
|
||||
institutions?: Array<Institution>;
|
||||
/**
|
||||
* The author\'s countries.
|
||||
*/
|
||||
countries?: Array<string>;
|
||||
is_corresponding?: boolean | null;
|
||||
raw_author_name?: string | null;
|
||||
/**
|
||||
* The raw affiliation strings.
|
||||
*/
|
||||
raw_affiliation_strings?: Array<string>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface Award {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
funder_award_id?: string | null;
|
||||
funder_id?: string | null;
|
||||
funder_display_name?: string | null;
|
||||
doi?: string | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface Biblio {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
volume?: string | null;
|
||||
issue?: string | null;
|
||||
first_page?: string | null;
|
||||
last_page?: string | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface CitationNormalizedPercentile {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
value?: number | null;
|
||||
is_in_top_1_percent?: boolean | null;
|
||||
is_in_top_10_percent?: boolean | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface CitedByPercentileYear {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
min?: number | null;
|
||||
max?: number | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface CountByYear {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
year?: number | null;
|
||||
/**
|
||||
* The citation count for the year.
|
||||
*/
|
||||
cited_by_count?: number;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface Funder {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
ror?: string | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface HasContent {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
pdf?: boolean | null;
|
||||
grobid_xml?: boolean | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface Institution {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
ror?: string | null;
|
||||
country_code?: string | null;
|
||||
type?: string | null;
|
||||
lineage?: Array<string> | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface Keyword {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
score?: number | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { Source } from './source';
|
||||
|
||||
|
||||
export interface Location {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
is_oa?: boolean | null;
|
||||
landing_page_url?: string | null;
|
||||
pdf_url?: string | null;
|
||||
source?: Source | null;
|
||||
license?: string | null;
|
||||
license_id?: string | null;
|
||||
is_accepted?: boolean | null;
|
||||
is_published?: boolean | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface Mesh {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
descriptor_ui?: string | null;
|
||||
descriptor_name?: string | null;
|
||||
qualifier_ui?: string | null;
|
||||
qualifier_name?: string | null;
|
||||
is_major_topic?: boolean | null;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,33 @@
|
||||
export * from './affiliation';
|
||||
export * from './author';
|
||||
export * from './authorship';
|
||||
export * from './award';
|
||||
export * from './biblio';
|
||||
export * from './citation-normalized-percentile';
|
||||
export * from './cited-by-percentile-year';
|
||||
export * from './count-by-year';
|
||||
export * from './funder';
|
||||
export * from './http-validation-error';
|
||||
export * from './has-content';
|
||||
export * from './institution';
|
||||
export * from './item';
|
||||
export * from './item-create';
|
||||
export * from './item-page';
|
||||
export * from './keyword';
|
||||
export * from './location';
|
||||
export * from './mesh';
|
||||
export * from './open-access';
|
||||
export * from './person';
|
||||
export * from './person-bio';
|
||||
export * from './person-search-result';
|
||||
export * from './source';
|
||||
export * from './sustainable-development-goal';
|
||||
export * from './topic';
|
||||
export * from './topic-level';
|
||||
export * from './validation-error';
|
||||
export * from './validation-error-loc-inner';
|
||||
export * from './work';
|
||||
export * from './work-ids';
|
||||
export * from './work-list';
|
||||
export * from './work-page';
|
||||
export * from './work-summary';
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface OpenAccess {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
is_oa?: boolean | null;
|
||||
oa_url?: string | null;
|
||||
any_repository_has_fulltext?: boolean | null;
|
||||
}
|
||||
|
||||
@@ -35,5 +35,15 @@ export interface Person {
|
||||
* Research topics.
|
||||
*/
|
||||
topics?: Array<string>;
|
||||
topics_full?: Array<object> | null;
|
||||
topic_share?: Array<object> | null;
|
||||
summary_stats?: object | null;
|
||||
ids?: object | null;
|
||||
last_known_institutions?: Array<object> | null;
|
||||
sources?: Array<object> | null;
|
||||
counts_by_year?: Array<object> | null;
|
||||
works_api_url?: string | null;
|
||||
dates?: object | null;
|
||||
cited_by_count_boost?: number | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface Source {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
issn_l?: string | null;
|
||||
issn?: Array<string> | null;
|
||||
is_oa?: boolean | null;
|
||||
is_in_doaj?: boolean | null;
|
||||
is_core?: boolean | null;
|
||||
host_organization?: string | null;
|
||||
host_organization_name?: string | null;
|
||||
host_organization_lineage?: Array<string> | null;
|
||||
type?: string | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface SustainableDevelopmentGoal {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
score?: number | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface TopicLevel {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { TopicLevel } from './topic-level';
|
||||
|
||||
|
||||
export interface Topic {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
score?: number | null;
|
||||
subfield?: TopicLevel | null;
|
||||
field?: TopicLevel | null;
|
||||
domain?: TopicLevel | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface WorkIds {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
openalex?: string | null;
|
||||
doi?: string | null;
|
||||
mag?: number | null;
|
||||
pmid?: string | null;
|
||||
pmcid?: string | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { Work } from './work';
|
||||
|
||||
|
||||
export interface WorkList {
|
||||
/**
|
||||
* All works.
|
||||
*/
|
||||
elements?: Array<Work>;
|
||||
/**
|
||||
* The total number of works.
|
||||
*/
|
||||
total?: number;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* My App Service
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { Biblio } from './biblio';
|
||||
import { CountByYear } from './count-by-year';
|
||||
import { Authorship } from './authorship';
|
||||
import { Keyword } from './keyword';
|
||||
import { Funder } from './funder';
|
||||
import { OpenAccess } from './open-access';
|
||||
import { WorkIds } from './work-ids';
|
||||
import { Mesh } from './mesh';
|
||||
import { SustainableDevelopmentGoal } from './sustainable-development-goal';
|
||||
import { HasContent } from './has-content';
|
||||
import { Award } from './award';
|
||||
import { CitationNormalizedPercentile } from './citation-normalized-percentile';
|
||||
import { Topic } from './topic';
|
||||
import { CitedByPercentileYear } from './cited-by-percentile-year';
|
||||
import { Location } from './location';
|
||||
|
||||
|
||||
export interface Work {
|
||||
[key: string]: any | any;
|
||||
|
||||
|
||||
/**
|
||||
* The external id of the work.
|
||||
*/
|
||||
id: string;
|
||||
doi?: string | null;
|
||||
title?: string | null;
|
||||
display_name?: string | null;
|
||||
publication_year?: number | null;
|
||||
publication_date?: string | null;
|
||||
type?: string | null;
|
||||
language?: string | null;
|
||||
/**
|
||||
* The number of citations.
|
||||
*/
|
||||
cited_by_count?: number;
|
||||
is_retracted?: boolean | null;
|
||||
is_paratext?: boolean | null;
|
||||
primary_location?: Location | null;
|
||||
/**
|
||||
* The work locations.
|
||||
*/
|
||||
locations?: Array<Location>;
|
||||
best_oa_location?: Location | null;
|
||||
open_access?: OpenAccess | null;
|
||||
/**
|
||||
* The authorships.
|
||||
*/
|
||||
authorships?: Array<Authorship>;
|
||||
ids?: WorkIds | null;
|
||||
biblio?: Biblio | null;
|
||||
/**
|
||||
* The inverted abstract index.
|
||||
*/
|
||||
abstract_inverted_index?: { [key: string]: Array<number>; };
|
||||
/**
|
||||
* Referenced work ids.
|
||||
*/
|
||||
referenced_works?: Array<string>;
|
||||
/**
|
||||
* The number of referenced works.
|
||||
*/
|
||||
referenced_works_count?: number;
|
||||
/**
|
||||
* Related work ids.
|
||||
*/
|
||||
related_works?: Array<string>;
|
||||
/**
|
||||
* The topics.
|
||||
*/
|
||||
topics?: Array<Topic>;
|
||||
primary_topic?: Topic | null;
|
||||
/**
|
||||
* The keywords.
|
||||
*/
|
||||
keywords?: Array<Keyword>;
|
||||
/**
|
||||
* The funders.
|
||||
*/
|
||||
funders?: Array<Funder>;
|
||||
/**
|
||||
* The awards.
|
||||
*/
|
||||
awards?: Array<Award>;
|
||||
fwci?: number | null;
|
||||
citation_normalized_percentile?: CitationNormalizedPercentile | null;
|
||||
cited_by_percentile_year?: CitedByPercentileYear | null;
|
||||
/**
|
||||
* Citation counts by year.
|
||||
*/
|
||||
counts_by_year?: Array<CountByYear>;
|
||||
/**
|
||||
* Sustainable development goals.
|
||||
*/
|
||||
sustainable_development_goals?: Array<SustainableDevelopmentGoal>;
|
||||
/**
|
||||
* MeSH terms.
|
||||
*/
|
||||
mesh?: Array<Mesh>;
|
||||
/**
|
||||
* Indexes containing the work.
|
||||
*/
|
||||
indexed_in?: Array<string>;
|
||||
has_content?: HasContent | null;
|
||||
content_url?: string | null;
|
||||
created_date?: string | null;
|
||||
updated_date?: string | null;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,14 @@ export const routes: Routes = [
|
||||
(mod) => mod.DashboardComponent,
|
||||
),
|
||||
},
|
||||
{
|
||||
path: 'persons',
|
||||
canActivate: [userGuard],
|
||||
loadComponent: () =>
|
||||
import('./modules/person-list/person-list.component').then(
|
||||
(mod) => mod.PersonListComponent,
|
||||
),
|
||||
},
|
||||
{
|
||||
path: 'person/:id',
|
||||
canActivate: [userGuard],
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(160deg, #f4f6fb 0%, #e8ecf7 100%);
|
||||
background:
|
||||
radial-gradient(circle at 18% 18%, var(--sg-cyan-soft), transparent 34%),
|
||||
radial-gradient(circle at 82% 76%, var(--sg-coral-soft), transparent 32%),
|
||||
linear-gradient(160deg, #f8faff 0%, #eef4ff 100%);
|
||||
}
|
||||
|
||||
.form {
|
||||
@@ -15,7 +18,7 @@
|
||||
background: white;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 12px rgba(26, 58, 110, 0.10), 0 1px 4px rgba(0,0,0,0.06);
|
||||
box-shadow: 0 2px 12px rgba(23, 32, 51, 0.10), 0 1px 4px rgba(0,0,0,0.06);
|
||||
gap: 20px;
|
||||
padding: 36px 32px 28px;
|
||||
}
|
||||
@@ -23,7 +26,7 @@
|
||||
.form h3 {
|
||||
margin: 0 0 4px;
|
||||
font-weight: 600;
|
||||
color: #1a3a6e;
|
||||
color: var(--sg-primary-strong);
|
||||
}
|
||||
|
||||
.button {
|
||||
@@ -44,9 +47,9 @@
|
||||
height: 2em;
|
||||
text-align: center;
|
||||
font-size: small;
|
||||
color: #585f71;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.error {
|
||||
color: #ba1a1a;
|
||||
color: var(--sg-danger);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<section class="person-list-page">
|
||||
<header class="page-header">
|
||||
<div>
|
||||
<h1>Passende Personen finden</h1>
|
||||
<p>
|
||||
Durchsuchen Sie OpenAlex-Autorinnen und -Autoren nach Namen, Themen oder
|
||||
Kennungen.
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="toolbar">
|
||||
<span class="result-count">{{ resultRange() }}</span>
|
||||
</div>
|
||||
|
||||
<section class="results-panel">
|
||||
<div class="results-head">
|
||||
<strong>{{ total | number: "1.0-0" }} Personen gefunden</strong>
|
||||
<span>Sortiert nach Publikationen und Zitierungen</span>
|
||||
</div>
|
||||
|
||||
@if (loading) {
|
||||
<div class="loading-state">
|
||||
<mat-spinner diameter="40"></mat-spinner>
|
||||
</div>
|
||||
} @else if (persons.length) {
|
||||
<div class="person-grid">
|
||||
@for (person of persons; track person.id) {
|
||||
<article class="person-card">
|
||||
<a
|
||||
class="card-link"
|
||||
[routerLink]="['/person', person.id, 'overview']"
|
||||
>
|
||||
<div class="person-main">
|
||||
<div>
|
||||
<h2>{{ person.name }}</h2>
|
||||
<p>{{ institution(person) }}</p>
|
||||
</div>
|
||||
|
||||
<div class="topic-row">
|
||||
@for (topic of topics(person); track topic) {
|
||||
<span>{{ topic }}</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stats">
|
||||
<span>
|
||||
<mat-icon>article</mat-icon>
|
||||
{{ person.works_count | number: "1.0-0" }} Publikationen
|
||||
</span>
|
||||
<span>
|
||||
<mat-icon>format_quote</mat-icon>
|
||||
{{ person.cited_by_count | number: "1.0-0" }} Zitierungen
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
</article>
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
<div class="empty-state">
|
||||
<mat-icon>person_search</mat-icon>
|
||||
<h2>Keine Personen gefunden</h2>
|
||||
<p>Versuchen Sie einen anderen Suchbegriff.</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
<mat-paginator
|
||||
[length]="total"
|
||||
[pageIndex]="pageIndex"
|
||||
[pageSize]="paginationService.selection"
|
||||
[pageSizeOptions]="paginationService.options"
|
||||
(page)="onPage($event)"
|
||||
aria-label="Personen Seitensteuerung"
|
||||
></mat-paginator>
|
||||
</section>
|
||||
</section>
|
||||
@@ -0,0 +1,285 @@
|
||||
.person-list-page {
|
||||
display: grid;
|
||||
gap: 24px;
|
||||
padding: 32px;
|
||||
background: var(--sg-background);
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
|
||||
gap: 32px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
margin: 0 0 8px;
|
||||
color: var(--sg-primary);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
margin: 0;
|
||||
font-size: 28px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.page-header p:not(.eyebrow) {
|
||||
max-width: 720px;
|
||||
margin: 10px 0 0;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.selection-summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 80px;
|
||||
padding: 18px 20px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
}
|
||||
|
||||
.selection-summary div {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.selection-summary strong {
|
||||
color: var(--sg-text);
|
||||
}
|
||||
|
||||
.selection-summary span {
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.selection-summary mat-icon {
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.toolbar mat-form-field {
|
||||
width: min(100%, 520px);
|
||||
}
|
||||
|
||||
.result-count {
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.results-panel {
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.results-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
min-height: 64px;
|
||||
padding: 0 22px;
|
||||
}
|
||||
|
||||
.results-head strong {
|
||||
color: var(--sg-text);
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.results-head span {
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.person-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.person-card {
|
||||
min-width: 0;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
box-shadow: var(--sg-shadow-sm);
|
||||
transition:
|
||||
border-color 160ms ease,
|
||||
box-shadow 160ms ease,
|
||||
transform 160ms ease;
|
||||
}
|
||||
|
||||
.person-card:hover {
|
||||
border-color: var(--sg-border-strong);
|
||||
box-shadow: var(--sg-shadow-md);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.card-link {
|
||||
display: grid;
|
||||
grid-template-rows: 1fr auto;
|
||||
gap: 18px;
|
||||
min-height: 236px;
|
||||
padding: 20px;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.person-main {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
.person-main h2 {
|
||||
margin: 0 0 6px;
|
||||
font-size: 17px;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.person-main p {
|
||||
display: -webkit-box;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 13px;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
}
|
||||
|
||||
.topic-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.topic-row span {
|
||||
max-width: 100%;
|
||||
padding: 5px 10px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #bcd3ff;
|
||||
border-radius: 6px;
|
||||
background: #eff6ff;
|
||||
color: #064fc4;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.stats {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding-top: 14px;
|
||||
border-top: 1px solid var(--sg-border);
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.stats span {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.stats mat-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.loading-state,
|
||||
.empty-state {
|
||||
display: grid;
|
||||
min-height: 320px;
|
||||
place-items: center;
|
||||
padding: 32px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
align-content: center;
|
||||
gap: 8px;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.empty-state mat-icon {
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
color: var(--sg-text-soft);
|
||||
font-size: 42px;
|
||||
}
|
||||
|
||||
.empty-state h2 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.empty-state p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
mat-paginator {
|
||||
border-top: 1px solid var(--sg-border);
|
||||
}
|
||||
|
||||
@media (max-width: 1280px) {
|
||||
.person-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 860px) {
|
||||
.person-list-page {
|
||||
padding: 24px 16px;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.toolbar,
|
||||
.results-head {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.results-head {
|
||||
justify-content: center;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.result-count {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.person-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 560px) {
|
||||
.stats {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import { Component, OnDestroy, OnInit, inject } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { Subject, debounceTime, distinctUntilChanged, takeUntil } from 'rxjs';
|
||||
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
|
||||
import { Person } from '../../api';
|
||||
import { PaginationService } from '../../shared/services/pagination.service';
|
||||
import { PersonsService } from '../../shared/services/persons.service';
|
||||
import { createLoadError } from '../../shared/utils/errorHandler';
|
||||
|
||||
@Component({
|
||||
selector: 'app-person-list',
|
||||
imports: [
|
||||
CommonModule,
|
||||
MatButtonModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatPaginatorModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatSnackBarModule,
|
||||
ReactiveFormsModule,
|
||||
RouterLink,
|
||||
],
|
||||
templateUrl: './person-list.component.html',
|
||||
styleUrl: './person-list.component.scss',
|
||||
standalone: true,
|
||||
})
|
||||
export class PersonListComponent implements OnInit, OnDestroy {
|
||||
private personsService = inject(PersonsService);
|
||||
private snackBar = inject(MatSnackBar);
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
public paginationService = inject(PaginationService);
|
||||
|
||||
persons: Person[] = [];
|
||||
loading = false;
|
||||
total = 0;
|
||||
pageIndex = 0;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.load();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
load(
|
||||
pageIndex = this.pageIndex,
|
||||
pageSize = this.paginationService.selection,
|
||||
): void {
|
||||
this.loading = true;
|
||||
const pageOffset = pageIndex * pageSize;
|
||||
|
||||
this.personsService
|
||||
.getPersons(pageOffset, pageSize)
|
||||
.subscribe({
|
||||
next: (page) => {
|
||||
this.persons = page.elements ?? [];
|
||||
this.total = page.total ?? 0;
|
||||
this.loading = false;
|
||||
},
|
||||
error: (error) => {
|
||||
this.loading = false;
|
||||
createLoadError(
|
||||
this.snackBar,
|
||||
() => this.load(pageIndex, pageSize),
|
||||
'Personen konnten nicht geladen werden',
|
||||
)(error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onPage(event: PageEvent): void {
|
||||
this.paginationService.selection = event.pageSize;
|
||||
this.pageIndex = event.pageIndex;
|
||||
this.load(event.pageIndex, event.pageSize);
|
||||
}
|
||||
|
||||
institution(person: Person): string {
|
||||
return person.affiliations?.[0]?.institution || 'Keine Institution angegeben';
|
||||
}
|
||||
|
||||
topics(person: Person): string[] {
|
||||
return (person.topics ?? []).slice(0, 3);
|
||||
}
|
||||
|
||||
resultRange(): string {
|
||||
if (!this.total || !this.persons.length) return 'Keine Personen gefunden';
|
||||
|
||||
const start = this.pageIndex * this.paginationService.selection + 1;
|
||||
const end = start + this.persons.length - 1;
|
||||
return `${start}-${end} von ${this.total} Personen`;
|
||||
}
|
||||
}
|
||||
@@ -4,17 +4,39 @@
|
||||
<h6>Publikationen</h6>
|
||||
<p>Übersicht der wissenschaftlichen Veröffentlichungen.</p>
|
||||
</div>
|
||||
<div class="table-actions">
|
||||
<button mat-stroked-button>
|
||||
<mat-icon>filter_alt</mat-icon>
|
||||
Filter
|
||||
<form class="publication-filters" [formGroup]="filterForm">
|
||||
<mat-form-field>
|
||||
<mat-label>Jahr</mat-label>
|
||||
<mat-select formControlName="publicationYears" multiple (selectionChange)="resetAndLoad()">
|
||||
@for (year of publicationYearOptions; track year) {
|
||||
<mat-option [value]="year">{{ year }}</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Typ</mat-label>
|
||||
<mat-select formControlName="types" multiple (selectionChange)="resetAndLoad()">
|
||||
@for (type of typeOptions; track type.value) {
|
||||
<mat-option [value]="type.value">{{ type.label }}</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Sprache</mat-label>
|
||||
<mat-select formControlName="languages" multiple (selectionChange)="resetAndLoad()">
|
||||
@for (language of languageOptions; track language.value) {
|
||||
<mat-option [value]="language.value">{{ language.label }}</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<button mat-stroked-button type="button" (click)="clearFilters()">
|
||||
<mat-icon>filter_alt_off</mat-icon>
|
||||
Zurücksetzen
|
||||
</button>
|
||||
<button mat-stroked-button>
|
||||
<mat-icon>sort</mat-icon>
|
||||
Sortieren nach: Neueste
|
||||
<mat-icon>keyboard_arrow_down</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="table-wrap">
|
||||
@@ -95,6 +117,7 @@
|
||||
<span>{{ publicationRange() }}</span>
|
||||
<mat-paginator
|
||||
[length]="total"
|
||||
[pageIndex]="currentPageIndex"
|
||||
[pageSize]="paginationService.selection"
|
||||
[pageSizeOptions]="paginationService.options"
|
||||
(page)="onPage($event)">
|
||||
|
||||
@@ -25,20 +25,29 @@ h2 {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.table-actions {
|
||||
.publication-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.table-actions button {
|
||||
.publication-filters mat-form-field {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.publication-filters button {
|
||||
height: 42px;
|
||||
border-color: var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
color: var(--sg-text);
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-form-field-subscript-wrapper {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
position: relative;
|
||||
overflow-x: auto;
|
||||
@@ -146,7 +155,12 @@ mat-paginator {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.table-actions {
|
||||
.publication-filters {
|
||||
justify-content: stretch;
|
||||
}
|
||||
|
||||
.publication-filters mat-form-field,
|
||||
.publication-filters button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, inject, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
|
||||
import { MatPaginator, MatPaginatorModule, PageEvent } from '@angular/material/paginator';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
|
||||
import { WorkSummary } from '../../api';
|
||||
import { PublicationsService } from '../../shared/services/publications.service';
|
||||
@@ -19,15 +22,24 @@ import { ChipComponent } from '../../shared/ui/chip/chip.component';
|
||||
MatButtonModule,
|
||||
ChipComponent,
|
||||
MatIconModule,
|
||||
MatFormFieldModule,
|
||||
MatPaginatorModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatSelectModule,
|
||||
MatSnackBarModule,
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
],
|
||||
templateUrl: './person-publications.component.html',
|
||||
styleUrl: './person-publications.component.scss',
|
||||
})
|
||||
export class PersonPublicationsComponent implements OnInit {
|
||||
@ViewChild(MatPaginator) paginator?: MatPaginator;
|
||||
private route = inject(ActivatedRoute);
|
||||
private publicationsService = inject(PublicationsService);
|
||||
public paginationService = inject(PaginationService);
|
||||
private snackBar = inject(MatSnackBar)
|
||||
|
||||
displayedColumns: string[] = [
|
||||
'title',
|
||||
'type',
|
||||
@@ -40,18 +52,47 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
total = 0;
|
||||
loading = false;
|
||||
authorId = '';
|
||||
currentPageIndex = 0;
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private publicationsService: PublicationsService,
|
||||
public paginationService: PaginationService,
|
||||
private snackBar: MatSnackBar,
|
||||
) {}
|
||||
readonly filterForm = new FormGroup({
|
||||
publicationYears: new FormControl<number[]>([], { nonNullable: true }),
|
||||
types: new FormControl<string[]>([], { nonNullable: true }),
|
||||
languages: new FormControl<string[]>([], { nonNullable: true }),
|
||||
});
|
||||
|
||||
readonly publicationYearOptions = this.createPublicationYearOptions();
|
||||
|
||||
readonly typeOptions = [
|
||||
{ value: 'article', label: 'article' },
|
||||
{ value: 'book', label: 'book' },
|
||||
{ value: 'book-chapter', label: 'book-chapter' },
|
||||
{ value: 'dataset', label: 'dataset' },
|
||||
{ value: 'dissertation', label: 'dissertation' },
|
||||
{ value: 'editorial', label: 'editorial' },
|
||||
{ value: 'erratum', label: 'erratum' },
|
||||
{ value: 'letter', label: 'letter' },
|
||||
{ value: 'libguides', label: 'libguides' },
|
||||
{ value: 'other', label: 'other' },
|
||||
{ value: 'paratext', label: 'paratext' },
|
||||
{ value: 'peer-review', label: 'peer-review' },
|
||||
{ value: 'preprint', label: 'preprint' },
|
||||
{ value: 'reference-entry', label: 'reference-entry' },
|
||||
{ value: 'report', label: 'report' },
|
||||
{ value: 'retraction', label: 'retraction' },
|
||||
{ value: 'review', label: 'review' },
|
||||
{ value: 'standard', label: 'standard' },
|
||||
{ value: 'supplementary-materials', label: 'supplementary-materials' },
|
||||
];
|
||||
|
||||
readonly languageOptions = [
|
||||
{ value: 'en', label: 'Englisch' },
|
||||
{ value: 'de', label: 'Deutsch' },
|
||||
];
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.parent?.paramMap.subscribe((params) => {
|
||||
this.authorId = params.get('id') ?? '';
|
||||
this.load();
|
||||
this.resetAndLoad();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -60,7 +101,7 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
|
||||
this.loading = true;
|
||||
this.publicationsService
|
||||
.getAuthorWorks(this.authorId, pageIndex + 1, pageSize)
|
||||
.getAuthorWorks(this.authorId, pageIndex + 1, pageSize, this.filters())
|
||||
.subscribe({
|
||||
next: (page) => {
|
||||
this.publications = page.elements ?? [];
|
||||
@@ -80,9 +121,25 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
|
||||
onPage(event: PageEvent): void {
|
||||
this.paginationService.selection = event.pageSize;
|
||||
this.currentPageIndex = event.pageIndex;
|
||||
this.load(event.pageIndex, event.pageSize);
|
||||
}
|
||||
|
||||
resetAndLoad(): void {
|
||||
this.currentPageIndex = 0;
|
||||
this.paginator?.firstPage();
|
||||
this.load(0, this.paginationService.selection);
|
||||
}
|
||||
|
||||
clearFilters(): void {
|
||||
this.filterForm.reset({
|
||||
publicationYears: [],
|
||||
types: [],
|
||||
languages: [],
|
||||
});
|
||||
this.resetAndLoad();
|
||||
}
|
||||
|
||||
doiUrl(doi: string | null | undefined): string | null {
|
||||
if (!doi) return null;
|
||||
return doi.startsWith('http') ? doi : `https://doi.org/${doi}`;
|
||||
@@ -102,4 +159,17 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
if (normalized.includes('book')) return 'help';
|
||||
return 'info';
|
||||
}
|
||||
|
||||
private filters() {
|
||||
return {
|
||||
publicationYears: this.filterForm.controls.publicationYears.value,
|
||||
types: this.filterForm.controls.types.value,
|
||||
languages: this.filterForm.controls.languages.value,
|
||||
};
|
||||
}
|
||||
|
||||
private createPublicationYearOptions(): number[] {
|
||||
const currentYear = new Date().getFullYear();
|
||||
return Array.from({ length: 90 }, (_, index) => currentYear - index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
}
|
||||
|
||||
.profile-contact .orcid {
|
||||
color: #6cc24a;
|
||||
color: var(--sg-success);
|
||||
}
|
||||
|
||||
.profile-contact a {
|
||||
@@ -119,7 +119,7 @@
|
||||
|
||||
.interest-tags span {
|
||||
padding: 9px 16px;
|
||||
border: 1px solid #a8c0ff;
|
||||
border: 1px solid var(--sg-border-strong);
|
||||
border-radius: 7px;
|
||||
background: #ffffff;
|
||||
color: var(--sg-primary);
|
||||
@@ -162,11 +162,7 @@
|
||||
}
|
||||
|
||||
.profile-card {
|
||||
grid-template-columns: 112px 1fr;
|
||||
}
|
||||
|
||||
.profile-contact {
|
||||
grid-column: 2;
|
||||
grid-template-columns: minmax(240px, 1fr) minmax(260px, 360px);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { Person } from '../../api';
|
||||
import { BASE_PATH } from '../../api/variables';
|
||||
|
||||
export interface PersonPage {
|
||||
elements?: Person[];
|
||||
offset?: number;
|
||||
total?: number;
|
||||
size?: number;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PersonsService {
|
||||
private readonly basePath: string;
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
@Optional() @Inject(BASE_PATH) basePath: string | null,
|
||||
) {
|
||||
this.basePath = basePath ?? '';
|
||||
}
|
||||
|
||||
getPersons(
|
||||
pageOffset: number = 0,
|
||||
pageSize: number = 24,
|
||||
query?: string,
|
||||
): Observable<PersonPage> {
|
||||
let params = new HttpParams()
|
||||
.set('pageOffset', pageOffset)
|
||||
.set('pageSize', pageSize);
|
||||
|
||||
if (query?.trim()) {
|
||||
params = params.set('query', query.trim());
|
||||
}
|
||||
|
||||
return this.http.get<PersonPage>(`${this.basePath}/persons`, { params });
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { WorkPage, WorksOpenApiService } from '../../api';
|
||||
import { WorkList, WorkPage, WorksOpenApiService } from '../../api';
|
||||
|
||||
export interface PublicationFilters {
|
||||
publicationYears?: number[];
|
||||
types?: string[];
|
||||
languages?: string[];
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -13,7 +19,15 @@ export class PublicationsService {
|
||||
authorId: string,
|
||||
page: number = 1,
|
||||
size: number = 10,
|
||||
filters: PublicationFilters = {},
|
||||
): Observable<WorkPage> {
|
||||
return this.worksApi.getAuthorWorks(authorId, page, size);
|
||||
return this.worksApi.getAuthorWorks(
|
||||
authorId,
|
||||
page,
|
||||
size,
|
||||
filters.publicationYears,
|
||||
filters.types,
|
||||
filters.languages,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 10px 8px;
|
||||
border: 2px solid rgba(0, 87, 255, 0.22);
|
||||
border: 2px solid color-mix(in srgb, var(--sg-primary) 22%, transparent);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, #dce8ff, #ffffff);
|
||||
background: linear-gradient(135deg, var(--sg-primary-soft), #ffffff);
|
||||
color: var(--sg-primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import { CredentialService } from '../../services/credential.service';
|
||||
export class AppMenuComponent {
|
||||
navItems = [
|
||||
{ label: 'Dashboard', icon: 'dashboard', route: '/items', disabled: false },
|
||||
{ label: 'Personen', icon: 'groups', route: '/person/0', disabled: false },
|
||||
{ label: 'Personen', icon: 'groups', route: '/persons', disabled: false },
|
||||
];
|
||||
|
||||
constructor(public credentialService: CredentialService) {}
|
||||
|
||||
Reference in New Issue
Block a user