mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-01-13 02:54:27 +00:00
Store data store specifications in process_group.json (#1040)
This commit is contained in:
parent
330f18fa4a
commit
680fbd9658
@ -17,6 +17,7 @@ from spiffworkflow_backend.models.process_model import ProcessModelInfo
|
|||||||
PROCESS_GROUP_SUPPORTED_KEYS_FOR_DISK_SERIALIZATION = [
|
PROCESS_GROUP_SUPPORTED_KEYS_FOR_DISK_SERIALIZATION = [
|
||||||
"display_name",
|
"display_name",
|
||||||
"description",
|
"description",
|
||||||
|
"data_store_specifications",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ class ProcessGroup:
|
|||||||
description: str | None = None
|
description: str | None = None
|
||||||
process_models: list[ProcessModelInfo] = field(default_factory=list[ProcessModelInfo])
|
process_models: list[ProcessModelInfo] = field(default_factory=list[ProcessModelInfo])
|
||||||
process_groups: list[ProcessGroup] = field(default_factory=list["ProcessGroup"])
|
process_groups: list[ProcessGroup] = field(default_factory=list["ProcessGroup"])
|
||||||
|
data_store_specifications: dict[str, Any] = field(default_factory=dict)
|
||||||
parent_groups: list[ProcessGroupLite] | None = None
|
parent_groups: list[ProcessGroupLite] | None = None
|
||||||
|
|
||||||
# TODO: delete these once they no no longer mentioned in current
|
# TODO: delete these once they no no longer mentioned in current
|
||||||
|
@ -11,6 +11,7 @@ from spiffworkflow_backend.data_stores.kkv import KKVDataStore
|
|||||||
from spiffworkflow_backend.data_stores.typeahead import TypeaheadDataStore
|
from spiffworkflow_backend.data_stores.typeahead import TypeaheadDataStore
|
||||||
from spiffworkflow_backend.exceptions.api_error import ApiError
|
from spiffworkflow_backend.exceptions.api_error import ApiError
|
||||||
from spiffworkflow_backend.models.db import db
|
from spiffworkflow_backend.models.db import db
|
||||||
|
from spiffworkflow_backend.services.process_model_service import ProcessModelService
|
||||||
|
|
||||||
DATA_STORES = {
|
DATA_STORES = {
|
||||||
"json": (JSONDataStore, "JSON Data Store"),
|
"json": (JSONDataStore, "JSON Data Store"),
|
||||||
@ -125,9 +126,34 @@ def _data_store_upsert(body: dict, insert: bool) -> flask.wrappers.Response:
|
|||||||
db.session.add(model)
|
db.session.add(model)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
_write_specification_to_process_group(data_store_type, model)
|
||||||
|
|
||||||
return make_response(jsonify({"ok": True}), 200)
|
return make_response(jsonify({"ok": True}), 200)
|
||||||
|
|
||||||
|
|
||||||
|
def _write_specification_to_process_group(data_store_type: str, model: Any) -> None:
|
||||||
|
# TODO: once the top level is a process group this check should be removed
|
||||||
|
if model.location == "":
|
||||||
|
return
|
||||||
|
|
||||||
|
process_group = ProcessModelService.get_process_group(model.location, False, False)
|
||||||
|
if not process_group:
|
||||||
|
return
|
||||||
|
|
||||||
|
if data_store_type not in process_group.data_store_specifications:
|
||||||
|
process_group.data_store_specifications[data_store_type] = {}
|
||||||
|
|
||||||
|
process_group.data_store_specifications[data_store_type][model.identifier] = {
|
||||||
|
"name": model.name,
|
||||||
|
"identifier": model.identifier,
|
||||||
|
"location": model.location,
|
||||||
|
"schema": model.schema,
|
||||||
|
"description": model.description,
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcessModelService.update_process_group(process_group)
|
||||||
|
|
||||||
|
|
||||||
def data_store_show(data_store_type: str, identifier: str, process_group_identifier: str) -> flask.wrappers.Response:
|
def data_store_show(data_store_type: str, identifier: str, process_group_identifier: str) -> flask.wrappers.Response:
|
||||||
"""Returns a description of a data store."""
|
"""Returns a description of a data store."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user