feat: expose organization hierarchy catalog
This commit is contained in:
@@ -14,6 +14,7 @@ from govoplan_core.core.organizations import (
|
||||
OrganizationFunctionRef,
|
||||
OrganizationFunctionTypeRef,
|
||||
OrganizationFunctionTypeResolution,
|
||||
OrganizationHierarchyCatalogRef,
|
||||
OrganizationHierarchyDirection,
|
||||
OrganizationHierarchyDirectory,
|
||||
OrganizationHierarchyEdgeRef,
|
||||
@@ -279,6 +280,35 @@ class SqlOrganizationDirectory(
|
||||
return None
|
||||
return _unit_type_ref(item)
|
||||
|
||||
def hierarchy_catalog(
|
||||
self,
|
||||
tenant_id: str,
|
||||
) -> OrganizationHierarchyCatalogRef:
|
||||
with self._session() as session:
|
||||
structures = (
|
||||
session.query(OrganizationStructure)
|
||||
.filter(OrganizationStructure.tenant_id == tenant_id)
|
||||
.order_by(OrganizationStructure.name, OrganizationStructure.id)
|
||||
.all()
|
||||
)
|
||||
relation_types = (
|
||||
session.query(OrganizationRelationType)
|
||||
.filter(OrganizationRelationType.tenant_id == tenant_id)
|
||||
.order_by(
|
||||
OrganizationRelationType.structure_id,
|
||||
OrganizationRelationType.name,
|
||||
OrganizationRelationType.id,
|
||||
)
|
||||
.all()
|
||||
)
|
||||
return OrganizationHierarchyCatalogRef(
|
||||
tenant_id=tenant_id,
|
||||
structures=tuple(_structure_ref(item) for item in structures),
|
||||
relation_types=tuple(
|
||||
_relation_type_ref(item) for item in relation_types
|
||||
),
|
||||
)
|
||||
|
||||
def get_function_type(
|
||||
self,
|
||||
tenant_id: str,
|
||||
|
||||
Reference in New Issue
Block a user