ran some pyl w/ burnettk cullerton

This commit is contained in:
jasquat 2022-11-18 15:06:02 -05:00
parent 2464df4b81
commit e2cfe5cb8a
4 changed files with 24 additions and 20 deletions

View File

@ -1,6 +1,5 @@
"""APIs for dealing with process groups, process models, and process instances."""
import json
import os
import random
import string
import uuid
@ -253,11 +252,11 @@ def process_model_create(
status_code=400,
)
unmodified_process_group_id = un_modify_modified_process_model_id(modified_process_group_id)
process_model_service = ProcessModelService()
process_group = process_model_service.get_process_group(
unmodified_process_group_id
unmodified_process_group_id = un_modify_modified_process_model_id(
modified_process_group_id
)
process_model_service = ProcessModelService()
process_group = process_model_service.get_process_group(unmodified_process_group_id)
if process_group is None:
raise ApiError(
error_code="process_model_could_not_be_created",

View File

@ -49,7 +49,8 @@ class ProcessModelService(FileSystemService):
return False
@staticmethod
def write_json_file(file_path, json_data, indent=4, sort_keys=True):
def write_json_file(file_path: str, json_data: dict, indent: int = 4, sort_keys: bool = True):
"""Write json file."""
with open(file_path, "w") as h_open:
json.dump(json_data, h_open, indent=indent, sort_keys=sort_keys)
@ -81,14 +82,18 @@ class ProcessModelService(FileSystemService):
def save_process_model(self, process_model: ProcessModelInfo) -> None:
"""Save_process_model."""
process_model_path = os.path.abspath(os.path.join(FileSystemService.root_path(), process_model.id))
process_model_path = os.path.abspath(
os.path.join(FileSystemService.root_path(), process_model.id)
)
os.makedirs(process_model_path, exist_ok=True)
json_path = os.path.abspath(os.path.join(process_model_path, self.PROCESS_MODEL_JSON_FILE))
json_path = os.path.abspath(
os.path.join(process_model_path, self.PROCESS_MODEL_JSON_FILE)
)
process_model_id = process_model.id
# we don't save id in the json file
# this allows us to move models around on the filesystem
# the id is determined by its location on the filesystem
delattr(process_model, 'id')
delattr(process_model, "id")
json_data = self.PROCESS_MODEL_SCHEMA.dump(process_model)
self.write_json_file(json_path, json_data)
process_model.id = process_model_id
@ -184,9 +189,7 @@ class ProcessModelService(FileSystemService):
"""Look for a given process_group, and return it."""
if os.path.exists(FileSystemService.root_path()):
process_group_path = os.path.abspath(
os.path.join(
FileSystemService.root_path(), process_group_id
)
os.path.join(FileSystemService.root_path(), process_group_id)
)
if self.is_group(process_group_path):
return self.__scan_process_group(process_group_path)
@ -222,7 +225,7 @@ class ProcessModelService(FileSystemService):
serialized_process_group = process_group.serialized
# we don't store `id` in the json files
# this allows us to move groups around on the filesystem
del serialized_process_group['id']
del serialized_process_group["id"]
self.write_json_file(json_path, serialized_process_group)
return process_group
@ -296,7 +299,7 @@ class ProcessModelService(FileSystemService):
data = json.load(cat_json)
# we don't store `id` in the json files, so we add it back in here
relative_path = os.path.relpath(dir_path, FileSystemService.root_path())
data['id'] = relative_path
data["id"] = relative_path
process_group = ProcessGroup(**data)
if process_group is None:
raise ApiError(
@ -352,7 +355,7 @@ class ProcessModelService(FileSystemService):
data.pop("process_group_id")
# we don't save `id` in the json file, so we add it back in here.
relative_path = os.path.relpath(path, FileSystemService.root_path())
data['id'] = relative_path
data["id"] = relative_path
process_model_info = ProcessModelInfo(**data)
if process_model_info is None:
raise ApiError(
@ -372,7 +375,9 @@ class ProcessModelService(FileSystemService):
display_order=0,
is_review=False,
)
self.write_json_file(json_file_path, self.PROCESS_MODEL_SCHEMA.dump(process_model_info))
self.write_json_file(
json_file_path, self.PROCESS_MODEL_SCHEMA.dump(process_model_info)
)
# we don't store `id` in the json files, so we add it in here
process_model_info.id = name
if process_group:

View File

@ -32,7 +32,9 @@ class TestProcessModelService(BaseTest):
primary_process_id = process_model.primary_process_id
assert primary_process_id == "Process_HelloWorld"
ProcessModelService().update_process_model(process_model, {"display_name": "new_name"})
ProcessModelService().update_process_model(
process_model, {"display_name": "new_name"}
)
assert process_model.display_name == "new_name"
assert process_model.primary_process_id == primary_process_id

View File

@ -837,9 +837,7 @@ export default function ProcessModelEditDiagram() {
};
// if a file name is not given then this is a new model and the ReactDiagramEditor component will handle it
if (
(bpmnXmlForDiagramRendering || !params.file_name) && processModel
) {
if ((bpmnXmlForDiagramRendering || !params.file_name) && processModel) {
const processModelFileName = processModelFile ? processModelFile.name : '';
return (
<>