From e6e9628837b309d529753f6d6bf4caa2eb2e1f6f Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 11 Aug 2026 11:48:18 +0200 Subject: [PATCH] organization-feature --- service/src/main/inse/auth/model.py | 19 + service/src/main/inse/auth/service.py | 18 +- service/src/main/inse/database.py | 24 + .../inse/organization_management/model.py | 18 + .../inse/organization_management/router.py | 13 + .../inse/organization_management/service.py | 273 +++++- .../organization_management/test_service.py | 181 +++- webapp/src/app/api/.openapi-generator/FILES | 2 + .../src/app/api/api/organization.service.ts | 911 +++++++++++++----- .../api/model/createOrganizationRequest.ts | 11 +- ...ationManagementModelOrganizationProfile.ts | 17 +- .../app/api/model/institutionAssociation.ts | 23 + .../model/institutionAssociationsResponse.ts | 16 + webapp/src/app/api/model/models.ts | 2 + .../api/model/updateOrganizationRequest.ts | 13 +- .../modules/accounts/accounts.component.html | 27 +- .../modules/accounts/accounts.component.scss | 35 + .../institution-removal-dialog.component.ts | 65 ++ .../organization-dialog.component.html | 90 +- .../organization-dialog.component.scss | 96 +- .../organization-dialog.component.ts | 286 +++++- .../organizations.component.html | 51 +- .../organizations.component.scss | 15 +- .../organizations/organizations.component.ts | 78 +- .../organizations-organizations.resolver.ts | 106 +- .../query-param-selector.component.html | 2 +- webapp/src/styles.scss | 5 +- 27 files changed, 2012 insertions(+), 385 deletions(-) create mode 100644 webapp/src/app/api/model/institutionAssociation.ts create mode 100644 webapp/src/app/api/model/institutionAssociationsResponse.ts create mode 100644 webapp/src/app/modules/organizations/organization-dialog/institution-removal-dialog.component.ts diff --git a/service/src/main/inse/auth/model.py b/service/src/main/inse/auth/model.py index d78caf5b..b0b5c346 100644 --- a/service/src/main/inse/auth/model.py +++ b/service/src/main/inse/auth/model.py @@ -88,6 +88,25 @@ class Organization(Durable, table=True): accounts: list["Account"] = Relationship(back_populates="organization") +class OrganizationInstitution(SQLModel, table=True): + __tablename__ = "organization_institution" + __table_args__ = ( + UniqueConstraint( + "organization_id", + "position", + name="uq_organization_institution_position", + ), + ) + + organization_id: uuid.UUID = Field( + foreign_key="organization.id", + primary_key=True, + index=True, + ) + openalex_institution_id: str = Field(primary_key=True, index=True) + position: int = Field(nullable=False) + + class Account(Durable, table=True): @model_validator(mode="before") @classmethod diff --git a/service/src/main/inse/auth/service.py b/service/src/main/inse/auth/service.py index 4898ebef..1b271e67 100644 --- a/service/src/main/inse/auth/service.py +++ b/service/src/main/inse/auth/service.py @@ -22,6 +22,7 @@ from inse.auth.model import ( IdTokenMetadata, LoginResponse, Organization, + OrganizationInstitution, OtkResponse, RefreshTokenMetadata, Secret, @@ -98,9 +99,12 @@ def create_predefined_accounts(session: Session, file_path: str): with open(file_path, "r") as file: data: dict[str, Any] = json.loads(file.read()) for organization_data in data.get("organizations", []): - organization_id = organization_data.get("id") - if organization_id is not None: - organization_id = uuid.UUID(organization_id) + organization_id_value = organization_data.get("id") + organization_id = ( + uuid.UUID(organization_id_value) + if organization_id_value is not None + else uuid.uuid4() + ) organization_name = organization_data["name"] openalex_institution_id = organization_data.get( "openalex_institution_id" @@ -113,6 +117,14 @@ def create_predefined_accounts(session: Session, file_path: str): openalex_institution_id=openalex_institution_id, ) session.add(organization) + if openalex_institution_id: + session.add( + OrganizationInstitution( + organization_id=organization.id, + openalex_institution_id=openalex_institution_id, + position=0, + ) + ) for account_data in data.get("accounts", []): organization_id = uuid.UUID(account_data["organization_id"]) roles = normalize_roles( diff --git a/service/src/main/inse/database.py b/service/src/main/inse/database.py index 4fd5a269..5f4a75c9 100644 --- a/service/src/main/inse/database.py +++ b/service/src/main/inse/database.py @@ -107,6 +107,30 @@ def create_db_and_tables(): ) ) + # Preserve the former single institution as the first manually selected + # institution. + # The legacy column remains synchronized for portal sections that have not yet + # been migrated to organization-wide institution lists. + with engine.begin() as connection: + connection.execute( + text( + """ + INSERT INTO organization_institution ( + organization_id, openalex_institution_id, position + ) + SELECT id, openalex_institution_id, 0 + FROM organization + WHERE openalex_institution_id IS NOT NULL + AND TRIM(openalex_institution_id) != '' + AND NOT EXISTS ( + SELECT 1 + FROM organization_institution oi + WHERE oi.organization_id = organization.id + ) + """ + ) + ) + def get_session(): """Yields a database session for use in FastAPI endpoints. diff --git a/service/src/main/inse/organization_management/model.py b/service/src/main/inse/organization_management/model.py index 8357daa9..e4de2f2e 100644 --- a/service/src/main/inse/organization_management/model.py +++ b/service/src/main/inse/organization_management/model.py @@ -1,4 +1,5 @@ import uuid +from typing import Literal from pydantic import BaseModel, Field @@ -7,6 +8,7 @@ class OrganizationProfile(BaseModel): id: uuid.UUID name: str other_inst_id: str | None = None + selected_openalex_institution_ids: list[str] = Field(default_factory=list) deleted: bool member_count: int @@ -21,9 +23,25 @@ class OrganizationPage(BaseModel): class CreateOrganizationRequest(BaseModel): name: str = Field(min_length=1) other_inst_id: str | None = None + selected_openalex_institution_ids: list[str] | None = None class UpdateOrganizationRequest(BaseModel): name: str | None = Field(default=None, min_length=1) other_inst_id: str | None = None + selected_openalex_institution_ids: list[str] | None = None deleted: bool | None = None + + +class InstitutionAssociation(BaseModel): + id: str + display_name: str + relationship: Literal["child", "related"] + + +class InstitutionAssociationsResponse(BaseModel): + id: str + display_name: str + associated_institutions: list[InstitutionAssociation] = Field( + default_factory=list + ) diff --git a/service/src/main/inse/organization_management/router.py b/service/src/main/inse/organization_management/router.py index 5232ca66..32086e0e 100644 --- a/service/src/main/inse/organization_management/router.py +++ b/service/src/main/inse/organization_management/router.py @@ -11,6 +11,7 @@ from inse.tags import Tags from . import service from .model import ( CreateOrganizationRequest, + InstitutionAssociationsResponse, OrganizationPage, OrganizationProfile, UpdateOrganizationRequest, @@ -19,6 +20,18 @@ from .model import ( router = APIRouter(prefix="/api/organizations", tags=[Tags.ORGANIZATION]) +@router.get( + "/institutions/associations", + operation_id="getOrganizationInstitutionAssociations", + response_model=list[InstitutionAssociationsResponse], +) +async def get_organization_institution_associations( + institution_ids: list[str] = Query(), + access_token: AccessTokenMetadata = auth_service.CurrentUserAccessTokenPayloadDep, +) -> list[InstitutionAssociationsResponse]: + return await service.get_institution_associations(access_token, institution_ids) + + @router.get("", operation_id="getOrganisations", response_model=OrganizationPage) async def get_organizations( page: int = Query(default=0, ge=0), diff --git a/service/src/main/inse/organization_management/service.py b/service/src/main/inse/organization_management/service.py index dcb06c30..072db92a 100644 --- a/service/src/main/inse/organization_management/service.py +++ b/service/src/main/inse/organization_management/service.py @@ -1,18 +1,43 @@ +import logging +import re import uuid from fastapi import HTTPException, status from sqlmodel import Session, func, select -from inse.auth.model import AccessTokenMetadata, Account, Organization, UserRole +from inse.auth.model import ( + AccessTokenMetadata, + Account, + Organization, + OrganizationInstitution, + UserRole, +) +from inse.integrations import elasticsearch +from inse.model import ESIndex from .model import ( CreateOrganizationRequest, + InstitutionAssociation, + InstitutionAssociationsResponse, OrganizationPage, OrganizationProfile, UpdateOrganizationRequest, ) +logger = logging.getLogger(__name__) +OPENALEX_INSTITUTION_ID_PATTERN = re.compile( + r"^(?:https?://openalex\.org/)?(I\d+)/?$", re.IGNORECASE +) +KNOWN_ASSOCIATION_TYPES = { + "parent", + "child", + "related", + "predecessor", + "successor", +} + + def _require_super_admin(access_token: AccessTokenMetadata) -> None: if access_token.effective_role != UserRole.SUPER_ADMIN: raise HTTPException( @@ -31,6 +56,27 @@ def _normalize_name(name: str) -> str: return normalized_name +def _normalize_institution_id(institution_id: str) -> str: + match = OPENALEX_INSTITUTION_ID_PATTERN.fullmatch(institution_id.strip()) + if match is None: + raise HTTPException( + status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + detail=f"Invalid OpenAlex institution ID: {institution_id}", + ) + return f"I{match.group(1)[1:]}" + + +def _normalize_institution_ids(institution_ids: list[str]) -> list[str]: + normalized: list[str] = [] + seen: set[str] = set() + for institution_id in institution_ids: + clean_id = _normalize_institution_id(institution_id) + if clean_id not in seen: + normalized.append(clean_id) + seen.add(clean_id) + return normalized + + def _ensure_name_available( session: Session, name: str, @@ -79,18 +125,76 @@ def _member_counts( return {organization_id: count for organization_id, count in rows} +def _institution_data( + session: Session, organization_ids: list[uuid.UUID] +) -> dict[uuid.UUID, list[str]]: + ids_by_organization: dict[uuid.UUID, list[str]] = { + organization_id: [] for organization_id in organization_ids + } + if not organization_ids: + return ids_by_organization + + institution_rows = session.exec( + select(OrganizationInstitution) + .where(OrganizationInstitution.organization_id.in_(organization_ids)) + .order_by( + OrganizationInstitution.organization_id, + OrganizationInstitution.position, + ) + ).all() + for row in institution_rows: + ids_by_organization[row.organization_id].append( + row.openalex_institution_id + ) + + return ids_by_organization + + def _to_profile( - organization: Organization, member_count: int + organization: Organization, + member_count: int, + institution_ids: list[str], ) -> OrganizationProfile: + if not institution_ids and organization.openalex_institution_id: + legacy_id = _normalize_institution_id(organization.openalex_institution_id) + institution_ids = [legacy_id] return OrganizationProfile( id=organization.id, name=organization.name, - other_inst_id=organization.openalex_institution_id, + other_inst_id=institution_ids[0] if institution_ids else None, + selected_openalex_institution_ids=institution_ids, deleted=organization.deleted, member_count=member_count, ) +def _replace_organization_institutions( + session: Session, + organization: Organization, + institution_ids: list[str], +) -> None: + normalized_ids = _normalize_institution_ids(institution_ids) + for row in session.exec( + select(OrganizationInstitution).where( + OrganizationInstitution.organization_id == organization.id + ) + ).all(): + session.delete(row) + session.flush() + + for position, institution_id in enumerate(normalized_ids): + session.add( + OrganizationInstitution( + organization_id=organization.id, + openalex_institution_id=institution_id, + position=position, + ) + ) + organization.openalex_institution_id = ( + normalized_ids[0] if normalized_ids else None + ) + + def _deactivate_organization_accounts( session: Session, organization_id: uuid.UUID ) -> None: @@ -106,6 +210,27 @@ def _deactivate_organization_accounts( session.add(account) +def _ensure_not_current_organization( + session: Session, + access_token: AccessTokenMetadata, + organization_id: uuid.UUID, +) -> None: + protected_organization_ids = {access_token.effective_organization_id} + if access_token.real_account_id is not None: + real_account = session.get(Account, access_token.real_account_id) + if real_account is not None: + protected_organization_ids.add(real_account.organization_id) + + if organization_id in protected_organization_ids: + raise HTTPException( + status_code=status.HTTP_409_CONFLICT, + detail=( + "The organization of the real or effective account " + "cannot be deleted." + ), + ) + + def get_organizations( session: Session, access_token: AccessTokenMetadata, @@ -130,10 +255,15 @@ def get_organizations( ).all() organization_ids = [organization.id for organization in organizations] counts = _member_counts(session, organization_ids) + institution_ids = _institution_data(session, organization_ids) return OrganizationPage( items=[ - _to_profile(organization, counts.get(organization.id, 0)) + _to_profile( + organization, + counts.get(organization.id, 0), + institution_ids.get(organization.id, []), + ) for organization in organizations ], total=total, @@ -153,12 +283,25 @@ def create_organization( organization = Organization( name=name, - openalex_institution_id=(payload.other_inst_id or '').strip() or None, ) session.add(organization) + session.flush() + requested_ids = payload.selected_openalex_institution_ids + if requested_ids is None: + requested_ids = [payload.other_inst_id] if payload.other_inst_id else [] + _replace_organization_institutions( + session, + organization, + requested_ids, + ) session.commit() session.refresh(organization) - return _to_profile(organization, 0) + institution_ids = _institution_data(session, [organization.id]) + return _to_profile( + organization, + 0, + institution_ids[organization.id], + ) def update_organization( @@ -174,10 +317,21 @@ def update_organization( name = _normalize_name(payload.name) _ensure_name_available(session, name, organization.id) organization.name = name - if payload.other_inst_id is not None: - organization.openalex_institution_id = payload.other_inst_id.strip() or None + if payload.selected_openalex_institution_ids is not None: + _replace_organization_institutions( + session, + organization, + payload.selected_openalex_institution_ids, + ) + elif payload.other_inst_id is not None: + _replace_organization_institutions( + session, + organization, + [payload.other_inst_id] if payload.other_inst_id.strip() else [], + ) if payload.deleted is not None: if payload.deleted and not organization.deleted: + _ensure_not_current_organization(session, access_token, organization.id) _deactivate_organization_accounts(session, organization.id) organization.deleted = payload.deleted @@ -185,7 +339,107 @@ def update_organization( session.commit() session.refresh(organization) counts = _member_counts(session, [organization.id]) - return _to_profile(organization, counts.get(organization.id, 0)) + institution_ids = _institution_data(session, [organization.id]) + return _to_profile( + organization, + counts.get(organization.id, 0), + institution_ids[organization.id], + ) + + +async def get_institution_associations( + access_token: AccessTokenMetadata, + institution_ids: list[str], +) -> list[InstitutionAssociationsResponse]: + _require_super_admin(access_token) + clean_ids = _normalize_institution_ids(institution_ids) + if not clean_ids: + return [] + + response = await elasticsearch.search( + index=ESIndex.OPENALEX_INSTITUTIONS, + query={ + "terms": { + "id": [ + f"https://openalex.org/{institution_id}" + for institution_id in clean_ids + ] + } + }, + source=["id", "display_name", "associated_institutions"], + size=len(clean_ids), + ) + sources_by_id: dict[str, dict] = {} + for hit in response.get("hits", {}).get("hits", []): + source = hit.get("_source") or {} + raw_id = source.get("id") + if isinstance(raw_id, str): + sources_by_id[_normalize_institution_id(raw_id)] = source + + missing_id = next( + ( + institution_id + for institution_id in clean_ids + if institution_id not in sources_by_id + ), + None, + ) + if missing_id is not None: + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail=f"OpenAlex institution {missing_id} not found.", + ) + + results: list[InstitutionAssociationsResponse] = [] + for clean_id in clean_ids: + source = sources_by_id[clean_id] + display_name = source.get("display_name") + if not isinstance(display_name, str) or not display_name.strip(): + raise HTTPException( + status_code=status.HTTP_502_BAD_GATEWAY, + detail=f"OpenAlex institution {clean_id} has no display name.", + ) + + associations_by_id: dict[str, InstitutionAssociation] = {} + for association in source.get("associated_institutions") or []: + if not isinstance(association, dict): + continue + relationship = str(association.get("relationship") or "").lower() + if relationship not in KNOWN_ASSOCIATION_TYPES: + logger.warning( + "Ignoring unknown OpenAlex institution relationship %r for %s", + relationship, + clean_id, + ) + continue + if relationship not in {"child", "related"}: + continue + raw_association_id = association.get("id") + association_name = association.get("display_name") + if not isinstance(raw_association_id, str) or not isinstance( + association_name, str + ): + continue + associated_id = _normalize_institution_id(raw_association_id) + candidate = InstitutionAssociation( + id=associated_id, + display_name=association_name, + relationship=relationship, + ) + existing = associations_by_id.get(associated_id) + if existing is None or ( + existing.relationship == "related" and relationship == "child" + ): + associations_by_id[associated_id] = candidate + + results.append( + InstitutionAssociationsResponse( + id=clean_id, + display_name=display_name, + associated_institutions=list(associations_by_id.values()), + ) + ) + return results def delete_organization( @@ -196,6 +450,7 @@ def delete_organization( _require_super_admin(access_token) organization = _get_organization_or_404(session, organization_id) if not organization.deleted: + _ensure_not_current_organization(session, access_token, organization.id) _deactivate_organization_accounts(session, organization.id) organization.deleted = True session.add(organization) diff --git a/service/src/main/inse/organization_management/test_service.py b/service/src/main/inse/organization_management/test_service.py index a7ce6ff6..cd4ccdef 100644 --- a/service/src/main/inse/organization_management/test_service.py +++ b/service/src/main/inse/organization_management/test_service.py @@ -1,10 +1,16 @@ +import asyncio from types import SimpleNamespace import pytest from fastapi import HTTPException -from sqlmodel import Session, SQLModel, create_engine +from sqlmodel import Session, SQLModel, create_engine, select -from inse.auth.model import Account, Organization, UserRole +from inse.auth.model import ( + Account, + Organization, + OrganizationInstitution, + UserRole, +) from inse.organization_management import service from inse.organization_management.model import ( CreateOrganizationRequest, @@ -22,10 +28,11 @@ def session(): yield database_session -def token(role: UserRole, organization_id): +def token(role: UserRole, organization_id, real_account_id=None): return SimpleNamespace( effective_role=role, effective_organization_id=organization_id, + real_account_id=real_account_id, ) @@ -105,8 +112,115 @@ def test_superadmin_can_create_update_and_soft_delete(session): assert session.get(Organization, created.id).deleted is True +def test_organization_stores_ordered_selected_institution_ids(session): + scope = Organization(name="Scope") + session.add(scope) + session.commit() + + created = service.create_organization( + session, + token(UserRole.SUPER_ADMIN, scope.id), + CreateOrganizationRequest( + name="Institution list", + selected_openalex_institution_ids=[ + "https://openalex.org/I123", + "I456", + "I123", + ], + ), + ) + + assert created.selected_openalex_institution_ids == ["I123", "I456"] + assert created.other_inst_id == "I123" + assert session.get(Organization, created.id).openalex_institution_id == "I123" + rows = session.exec( + select(OrganizationInstitution) + .where(OrganizationInstitution.organization_id == created.id) + .order_by(OrganizationInstitution.position) + ).all() + assert [row.openalex_institution_id for row in rows] == ["I123", "I456"] + + +def test_empty_institution_list_clears_legacy_primary_institution(session): + organization = Organization(name="Organization", openalex_institution_id="I123") + session.add(organization) + session.commit() + + updated = service.update_organization( + session, + token(UserRole.SUPER_ADMIN, organization.id), + organization.id, + UpdateOrganizationRequest(selected_openalex_institution_ids=[]), + ) + + assert updated.selected_openalex_institution_ids == [] + assert updated.other_inst_id is None + assert session.get(Organization, organization.id).openalex_institution_id is None + + +def test_association_expansion_adds_only_child_and_related_with_child_priority( + monkeypatch, +): + async def fake_search(**kwargs): + return { + "hits": { + "hits": [ + { + "_source": { + "id": "https://openalex.org/I100", + "display_name": "Selected institution", + "associated_institutions": [ + { + "id": "https://openalex.org/I200", + "display_name": "Duplicate", + "relationship": "related", + }, + { + "id": "https://openalex.org/I200", + "display_name": "Duplicate", + "relationship": "child", + }, + { + "id": "https://openalex.org/I300", + "display_name": "Related", + "relationship": "related", + }, + { + "id": "https://openalex.org/I400", + "display_name": "Parent", + "relationship": "parent", + }, + { + "id": "https://openalex.org/I500", + "display_name": "Successor", + "relationship": "successor", + }, + ], + }, + } + ], + }, + } + + monkeypatch.setattr(service.elasticsearch, "search", fake_search) + + result = asyncio.run( + service.get_institution_associations( + token(UserRole.SUPER_ADMIN, None), ["https://openalex.org/I100"] + ) + ) + + assert result[0].id == "I100" + assert [ + (association.id, association.relationship) + for association in result[0].associated_institutions + ] == [("I200", "child"), ("I300", "related")] + + def test_deleting_organization_deactivates_all_its_accounts(session): + admin_scope = Organization(name="Admin scope for delete") organization = Organization(name="Organization to delete") + session.add(admin_scope) session.add(organization) session.flush() active_account = Account( @@ -129,7 +243,7 @@ def test_deleting_organization_deactivates_all_its_accounts(session): session.commit() service.delete_organization( - session, token(UserRole.SUPER_ADMIN, organization.id), organization.id + session, token(UserRole.SUPER_ADMIN, admin_scope.id), organization.id ) session.refresh(active_account) @@ -141,7 +255,9 @@ def test_deleting_organization_deactivates_all_its_accounts(session): def test_marking_organization_deleted_deactivates_its_accounts(session): + admin_scope = Organization(name="Admin scope for update") organization = Organization(name="Organization to update") + session.add(admin_scope) session.add(organization) session.flush() account = Account( @@ -155,7 +271,7 @@ def test_marking_organization_deleted_deactivates_its_accounts(session): service.update_organization( session, - token(UserRole.SUPER_ADMIN, organization.id), + token(UserRole.SUPER_ADMIN, admin_scope.id), organization.id, UpdateOrganizationRequest(deleted=True), ) @@ -165,6 +281,61 @@ def test_marking_organization_deleted_deactivates_its_accounts(session): assert account.epoch == 1 +@pytest.mark.parametrize("delete_via_update", [False, True]) +def test_current_organization_cannot_be_deleted(session, delete_via_update): + organization = Organization(name="Current organization") + session.add(organization) + session.commit() + access_token = token(UserRole.SUPER_ADMIN, organization.id) + + with pytest.raises(HTTPException) as error: + if delete_via_update: + service.update_organization( + session, + access_token, + organization.id, + UpdateOrganizationRequest(deleted=True), + ) + else: + service.delete_organization(session, access_token, organization.id) + + assert error.value.status_code == 409 + assert session.get(Organization, organization.id).deleted is False + + +def test_real_account_organization_cannot_be_deleted_while_impersonating(session): + real_organization = Organization(name="Real organization") + effective_organization = Organization(name="Effective organization") + session.add(real_organization) + session.add(effective_organization) + session.flush() + real_account = Account( + email="real-superadmin@example.org", + name="Real superadmin", + password_hash="hash", + organization_id=real_organization.id, + roles=[UserRole.SUPER_ADMIN], + ) + session.add(real_account) + session.commit() + + access_token = token( + UserRole.SUPER_ADMIN, + effective_organization.id, + real_account.id, + ) + with pytest.raises(HTTPException) as error: + service.delete_organization( + session, + access_token, + real_organization.id, + ) + + assert error.value.status_code == 409 + assert session.get(Organization, real_organization.id).deleted is False + assert session.get(Account, real_account.id).activated is True + + @pytest.mark.parametrize("role", [UserRole.ADMIN, UserRole.MANAGER, UserRole.USER]) def test_only_superadmin_can_create_organizations(session, role): organization = Organization(name="Scope") diff --git a/webapp/src/app/api/.openapi-generator/FILES b/webapp/src/app/api/.openapi-generator/FILES index 3c0e087f..d1763419 100644 --- a/webapp/src/app/api/.openapi-generator/FILES +++ b/webapp/src/app/api/.openapi-generator/FILES @@ -169,6 +169,8 @@ model/idTokenMetadata.ts model/inseAccountManagementModelOrganizationProfile.ts model/inseOrganizationManagementModelOrganizationProfile.ts model/institution.ts +model/institutionAssociation.ts +model/institutionAssociationsResponse.ts model/institutionFunderSummary.ts model/institutionGeo.ts model/institutionIds.ts diff --git a/webapp/src/app/api/api/organization.service.ts b/webapp/src/app/api/api/organization.service.ts index 14fb942d..1d3c7319 100644 --- a/webapp/src/app/api/api/organization.service.ts +++ b/webapp/src/app/api/api/organization.service.ts @@ -1,7 +1,7 @@ /** * Innovation Search Engine API * - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -9,12 +9,18 @@ */ /* 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'; +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 { CreateOrganizationRequest } from '../model/createOrganizationRequest'; @@ -23,292 +29,679 @@ import { HTTPValidationError } from '../model/hTTPValidationError'; // @ts-ignore import { InseOrganizationManagementModelOrganizationProfile } from '../model/inseOrganizationManagementModelOrganizationProfile'; // @ts-ignore +import { InstitutionAssociationsResponse } from '../model/institutionAssociationsResponse'; +// @ts-ignore import { OrganizationPage } from '../model/organizationPage'; // @ts-ignore import { UpdateOrganizationRequest } from '../model/updateOrganizationRequest'; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; -import { Configuration } from '../configuration'; +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; import { BaseService } from '../api.base.service'; - - @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class OrganizationService extends BaseService { + constructor( + protected httpClient: HttpClient, + @Optional() @Inject(BASE_PATH) basePath: string | string[], + @Optional() configuration?: Configuration, + ) { + super(basePath, configuration); + } - constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: Configuration) { - super(basePath, configuration); + /** + * Create Organization + * @endpoint post /api/organizations + * @param createOrganizationRequest + * @param secureFgpAcc + * @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 createOrganisation( + createOrganizationRequest: CreateOrganizationRequest, + secureFgpAcc?: string, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable; + public createOrganisation( + createOrganizationRequest: CreateOrganizationRequest, + secureFgpAcc?: string, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable< + HttpResponse + >; + public createOrganisation( + createOrganizationRequest: CreateOrganizationRequest, + secureFgpAcc?: string, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public createOrganisation( + createOrganizationRequest: CreateOrganizationRequest, + secureFgpAcc?: string, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + if ( + createOrganizationRequest === null || + createOrganizationRequest === undefined + ) { + throw new Error( + 'Required parameter createOrganizationRequest was null or undefined when calling createOrganisation.', + ); } - /** - * Create Organization - * @endpoint post /api/organizations - * @param createOrganizationRequest - * @param secureFgpAcc - * @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 createOrganisation(createOrganizationRequest: CreateOrganizationRequest, secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public createOrganisation(createOrganizationRequest: CreateOrganizationRequest, secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public createOrganisation(createOrganizationRequest: CreateOrganizationRequest, secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public createOrganisation(createOrganizationRequest: CreateOrganizationRequest, secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { - if (createOrganizationRequest === null || createOrganizationRequest === undefined) { - throw new Error('Required parameter createOrganizationRequest was null or undefined when calling createOrganisation.'); - } + let localVarHeaders = this.defaultHeaders; - let localVarHeaders = this.defaultHeaders; + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders( + 'HTTPBearer', + 'Authorization', + localVarHeaders, + 'Bearer ', + ); - // authentication (HTTPBearer) required - localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', 'Authorization', localVarHeaders, 'Bearer '); + const localVarHttpHeaderAcceptSelected: string | undefined = + options?.httpHeaderAccept ?? + this.configuration.selectHeaderAccept(['application/json']); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Accept', + localVarHttpHeaderAcceptSelected, + ); + } - 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 localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + const localVarTransferCache: boolean = options?.transferCache ?? true; - const localVarTransferCache: boolean = options?.transferCache ?? true; + // to determine the Content-Type header + const consumes: string[] = ['application/json']; + const httpContentTypeSelected: string | undefined = + this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Content-Type', + httpContentTypeSelected, + ); + } + 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'; + } + } - // to determine the Content-Type header - const consumes: string[] = [ - 'application/json' - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } + let localVarPath = `/api/organizations`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request( + 'post', + `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: createOrganizationRequest, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }, + ); + } - 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'; - } - } + /** + * Delete Organization + * @endpoint delete /api/organizations/{organization_id} + * @param organizationId + * @param secureFgpAcc + * @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 deleteOrganisation( + organizationId: string, + secureFgpAcc?: string, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable; + public deleteOrganisation( + organizationId: string, + secureFgpAcc?: string, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public deleteOrganisation( + organizationId: string, + secureFgpAcc?: string, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public deleteOrganisation( + organizationId: string, + secureFgpAcc?: string, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + if (organizationId === null || organizationId === undefined) { + throw new Error( + 'Required parameter organizationId was null or undefined when calling deleteOrganisation.', + ); + } - let localVarPath = `/api/organizations`; - const { basePath, withCredentials } = this.configuration; - return this.httpClient.request('post', `${basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: createOrganizationRequest, - responseType: responseType_, - ...(withCredentials ? { withCredentials } : {}), - headers: localVarHeaders, - observe: observe, - ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), - reportProgress: reportProgress - } + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders( + 'HTTPBearer', + '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 = `/api/organizations/${this.configuration.encodeParam({ name: 'organizationId', value: organizationId, in: 'path', style: 'simple', explode: false, dataType: 'string', dataFormat: 'uuid' })}`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request( + 'delete', + `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }, + ); + } + + /** + * Get Organizations + * @endpoint get /api/organizations + * @param page + * @param pageSize + * @param offset + * @param secureFgpAcc + * @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 getOrganisations( + page?: number, + pageSize?: number, + offset?: number, + secureFgpAcc?: string, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable; + public getOrganisations( + page?: number, + pageSize?: number, + offset?: number, + secureFgpAcc?: string, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public getOrganisations( + page?: number, + pageSize?: number, + offset?: number, + secureFgpAcc?: string, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public getOrganisations( + page?: number, + pageSize?: number, + offset?: number, + secureFgpAcc?: string, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + let localVarQueryParameters = new HttpParams({ encoder: this.encoder }); + localVarQueryParameters = this.addToHttpParams( + localVarQueryParameters, + page, + 'page', + ); + localVarQueryParameters = this.addToHttpParams( + localVarQueryParameters, + pageSize, + 'page_size', + ); + localVarQueryParameters = this.addToHttpParams( + localVarQueryParameters, + offset, + 'offset', + ); + + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders( + 'HTTPBearer', + '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 = `/api/organizations`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request( + 'get', + `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + params: localVarQueryParameters, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }, + ); + } + + /** + * Get Organization Institution Associations + * @endpoint get /api/organizations/institutions/associations + * @param institutionIds + * @param secureFgpAcc + * @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 getOrganizationInstitutionAssociations( + institutionIds: Array, + secureFgpAcc?: string, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public getOrganizationInstitutionAssociations( + institutionIds: Array, + secureFgpAcc?: string, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>>; + public getOrganizationInstitutionAssociations( + institutionIds: Array, + secureFgpAcc?: string, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>>; + public getOrganizationInstitutionAssociations( + institutionIds: Array, + secureFgpAcc?: string, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + if (institutionIds === null || institutionIds === undefined) { + throw new Error( + 'Required parameter institutionIds was null or undefined when calling getOrganizationInstitutionAssociations.', + ); + } + + let localVarQueryParameters = new HttpParams({ encoder: this.encoder }); + if (institutionIds) { + institutionIds.forEach((element) => { + localVarQueryParameters = this.addToHttpParams( + localVarQueryParameters, + element, + 'institution_ids', ); + }); } - /** - * Delete Organization - * @endpoint delete /api/organizations/{organization_id} - * @param organizationId - * @param secureFgpAcc - * @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 deleteOrganisation(organizationId: string, secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public deleteOrganisation(organizationId: string, secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public deleteOrganisation(organizationId: string, secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public deleteOrganisation(organizationId: string, secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { - if (organizationId === null || organizationId === undefined) { - throw new Error('Required parameter organizationId was null or undefined when calling deleteOrganisation.'); - } + let localVarHeaders = this.defaultHeaders; - let localVarHeaders = this.defaultHeaders; + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders( + 'HTTPBearer', + 'Authorization', + localVarHeaders, + 'Bearer ', + ); - // authentication (HTTPBearer) required - localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', '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 = `/api/organizations/${this.configuration.encodeParam({name: "organizationId", value: organizationId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: "uuid"})}`; - const { basePath, withCredentials } = this.configuration; - return this.httpClient.request('delete', `${basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: responseType_, - ...(withCredentials ? { withCredentials } : {}), - headers: localVarHeaders, - observe: observe, - ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), - reportProgress: reportProgress - } - ); + const localVarHttpHeaderAcceptSelected: string | undefined = + options?.httpHeaderAccept ?? + this.configuration.selectHeaderAccept(['application/json']); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Accept', + localVarHttpHeaderAcceptSelected, + ); } - /** - * Get Organizations - * @endpoint get /api/organizations - * @param page - * @param pageSize - * @param offset - * @param secureFgpAcc - * @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 getOrganisations(page?: number, pageSize?: number, offset?: number, secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public getOrganisations(page?: number, pageSize?: number, offset?: number, secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getOrganisations(page?: number, pageSize?: number, offset?: number, secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getOrganisations(page?: number, pageSize?: number, offset?: number, secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + const localVarHttpContext: HttpContext = + options?.context ?? new HttpContext(); - let localVarQueryParameters = new HttpParams({encoder: this.encoder}); - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - page, 'page'); - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - pageSize, 'page_size'); - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - offset, 'offset'); + const localVarTransferCache: boolean = options?.transferCache ?? true; - let localVarHeaders = this.defaultHeaders; - - // authentication (HTTPBearer) required - localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', '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 = `/api/organizations`; - const { basePath, withCredentials } = this.configuration; - return this.httpClient.request('get', `${basePath}${localVarPath}`, - { - context: localVarHttpContext, - params: localVarQueryParameters, - responseType: responseType_, - ...(withCredentials ? { withCredentials } : {}), - headers: localVarHeaders, - observe: observe, - ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), - reportProgress: reportProgress - } - ); + 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'; + } } - /** - * Update Organization - * @endpoint put /api/organizations/{organization_id} - * @param organizationId - * @param updateOrganizationRequest - * @param secureFgpAcc - * @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 updateOrganisation(organizationId: string, updateOrganizationRequest: UpdateOrganizationRequest, secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public updateOrganisation(organizationId: string, updateOrganizationRequest: UpdateOrganizationRequest, secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public updateOrganisation(organizationId: string, updateOrganizationRequest: UpdateOrganizationRequest, secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public updateOrganisation(organizationId: string, updateOrganizationRequest: UpdateOrganizationRequest, secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { - if (organizationId === null || organizationId === undefined) { - throw new Error('Required parameter organizationId was null or undefined when calling updateOrganisation.'); - } - if (updateOrganizationRequest === null || updateOrganizationRequest === undefined) { - throw new Error('Required parameter updateOrganizationRequest was null or undefined when calling updateOrganisation.'); - } + let localVarPath = `/api/organizations/institutions/associations`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request>( + 'get', + `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + params: localVarQueryParameters, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }, + ); + } - let localVarHeaders = this.defaultHeaders; - - // authentication (HTTPBearer) required - localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', '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; - - - // to determine the Content-Type header - const consumes: string[] = [ - 'application/json' - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/api/organizations/${this.configuration.encodeParam({name: "organizationId", value: organizationId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: "uuid"})}`; - const { basePath, withCredentials } = this.configuration; - return this.httpClient.request('put', `${basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: updateOrganizationRequest, - responseType: responseType_, - ...(withCredentials ? { withCredentials } : {}), - headers: localVarHeaders, - observe: observe, - ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), - reportProgress: reportProgress - } - ); + /** + * Update Organization + * @endpoint put /api/organizations/{organization_id} + * @param organizationId + * @param updateOrganizationRequest + * @param secureFgpAcc + * @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 updateOrganisation( + organizationId: string, + updateOrganizationRequest: UpdateOrganizationRequest, + secureFgpAcc?: string, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable; + public updateOrganisation( + organizationId: string, + updateOrganizationRequest: UpdateOrganizationRequest, + secureFgpAcc?: string, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable< + HttpResponse + >; + public updateOrganisation( + organizationId: string, + updateOrganizationRequest: UpdateOrganizationRequest, + secureFgpAcc?: string, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public updateOrganisation( + organizationId: string, + updateOrganizationRequest: UpdateOrganizationRequest, + secureFgpAcc?: string, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + if (organizationId === null || organizationId === undefined) { + throw new Error( + 'Required parameter organizationId was null or undefined when calling updateOrganisation.', + ); + } + if ( + updateOrganizationRequest === null || + updateOrganizationRequest === undefined + ) { + throw new Error( + 'Required parameter updateOrganizationRequest was null or undefined when calling updateOrganisation.', + ); } + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders( + 'HTTPBearer', + '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; + + // to determine the Content-Type header + const consumes: string[] = ['application/json']; + const httpContentTypeSelected: string | undefined = + this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Content-Type', + httpContentTypeSelected, + ); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if ( + this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected) + ) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/organizations/${this.configuration.encodeParam({ name: 'organizationId', value: organizationId, in: 'path', style: 'simple', explode: false, dataType: 'string', dataFormat: 'uuid' })}`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request( + 'put', + `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: updateOrganizationRequest, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }, + ); + } } diff --git a/webapp/src/app/api/model/createOrganizationRequest.ts b/webapp/src/app/api/model/createOrganizationRequest.ts index fffb5457..d59b0c3f 100644 --- a/webapp/src/app/api/model/createOrganizationRequest.ts +++ b/webapp/src/app/api/model/createOrganizationRequest.ts @@ -1,16 +1,15 @@ /** * Innovation Search Engine API * - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - -export interface CreateOrganizationRequest { - name: string; - other_inst_id?: string | null; +export interface CreateOrganizationRequest { + name: string; + other_inst_id?: string | null; + selected_openalex_institution_ids?: Array | null; } - diff --git a/webapp/src/app/api/model/inseOrganizationManagementModelOrganizationProfile.ts b/webapp/src/app/api/model/inseOrganizationManagementModelOrganizationProfile.ts index 404df0f9..2b6e1e7c 100644 --- a/webapp/src/app/api/model/inseOrganizationManagementModelOrganizationProfile.ts +++ b/webapp/src/app/api/model/inseOrganizationManagementModelOrganizationProfile.ts @@ -1,19 +1,18 @@ /** * Innovation Search Engine API * - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - -export interface InseOrganizationManagementModelOrganizationProfile { - id: string; - name: string; - other_inst_id?: string | null; - deleted: boolean; - member_count: number; +export interface InseOrganizationManagementModelOrganizationProfile { + id: string; + name: string; + other_inst_id?: string | null; + selected_openalex_institution_ids?: Array; + deleted: boolean; + member_count: number; } - diff --git a/webapp/src/app/api/model/institutionAssociation.ts b/webapp/src/app/api/model/institutionAssociation.ts new file mode 100644 index 00000000..11b0b37e --- /dev/null +++ b/webapp/src/app/api/model/institutionAssociation.ts @@ -0,0 +1,23 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +export interface InstitutionAssociation { + id: string; + display_name: string; + relationship: InstitutionAssociation.RelationshipEnum; +} +export namespace InstitutionAssociation { + export const RelationshipEnum = { + Child: 'child', + Related: 'related', + } as const; + export type RelationshipEnum = + (typeof RelationshipEnum)[keyof typeof RelationshipEnum]; +} diff --git a/webapp/src/app/api/model/institutionAssociationsResponse.ts b/webapp/src/app/api/model/institutionAssociationsResponse.ts new file mode 100644 index 00000000..6bcd3c56 --- /dev/null +++ b/webapp/src/app/api/model/institutionAssociationsResponse.ts @@ -0,0 +1,16 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { InstitutionAssociation } from './institutionAssociation'; + +export interface InstitutionAssociationsResponse { + id: string; + display_name: string; + associated_institutions?: Array; +} diff --git a/webapp/src/app/api/model/models.ts b/webapp/src/app/api/model/models.ts index afed834d..3c72f9c1 100644 --- a/webapp/src/app/api/model/models.ts +++ b/webapp/src/app/api/model/models.ts @@ -134,6 +134,8 @@ export * from './idTokenMetadata'; export * from './inseAccountManagementModelOrganizationProfile'; export * from './inseOrganizationManagementModelOrganizationProfile'; export * from './institution'; +export * from './institutionAssociation'; +export * from './institutionAssociationsResponse'; export * from './institutionFunderSummary'; export * from './institutionGeo'; export * from './institutionIds'; diff --git a/webapp/src/app/api/model/updateOrganizationRequest.ts b/webapp/src/app/api/model/updateOrganizationRequest.ts index e12063b6..eede4ba0 100644 --- a/webapp/src/app/api/model/updateOrganizationRequest.ts +++ b/webapp/src/app/api/model/updateOrganizationRequest.ts @@ -1,17 +1,16 @@ /** * Innovation Search Engine API * - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - -export interface UpdateOrganizationRequest { - name?: string | null; - other_inst_id?: string | null; - deleted?: boolean | null; +export interface UpdateOrganizationRequest { + name?: string | null; + other_inst_id?: string | null; + selected_openalex_institution_ids?: Array | null; + deleted?: boolean | null; } - diff --git a/webapp/src/app/modules/accounts/accounts.component.html b/webapp/src/app/modules/accounts/accounts.component.html index 8c88c468..fbab8c8f 100644 --- a/webapp/src/app/modules/accounts/accounts.component.html +++ b/webapp/src/app/modules/accounts/accounts.component.html @@ -10,8 +10,22 @@ }}

+ + +