diff --git a/spiffworkflow-backend/bin/update_all_json.py b/spiffworkflow-backend/bin/update_all_json.py index 4e6b1b8aa..d8000c45d 100644 --- a/spiffworkflow-backend/bin/update_all_json.py +++ b/spiffworkflow-backend/bin/update_all_json.py @@ -15,7 +15,7 @@ def main() -> None: "process_group_id": "", "id": f"{group.id}/{process_model.id}", } - ProcessModelService().update_spec(process_model, update_items) + ProcessModelService().update_process_model(process_model, update_items) if __name__ == "__main__": diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index a5b4c0aa3..98d7f68b9 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -270,7 +270,7 @@ def process_model_create( status_code=400, ) - process_model_service.add_spec(process_model_info) + process_model_service.add_process_model(process_model_info) return Response( json.dumps(ProcessModelInfoSchema().dump(process_model_info)), status=201, @@ -307,7 +307,7 @@ def process_model_update( # process_model_identifier = f"{process_group_id}/{process_model_id}" process_model = get_process_model(process_model_identifier) - ProcessModelService().update_spec(process_model, body_filtered) + ProcessModelService().update_process_model(process_model, body_filtered) return ProcessModelInfoSchema().dump(process_model) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/file_system_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/file_system_service.py index 547159e65..863456ac2 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/file_system_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/file_system_service.py @@ -20,8 +20,8 @@ class FileSystemService: """ Simple Service meant for extension that provides some useful methods for dealing with the File system. """ - CAT_JSON_FILE = "process_group.json" - WF_JSON_FILE = "workflow.json" + PROCESS_GROUP_JSON_FILE = "process_group.json" + PROCESS_MODEL_JSON_FILE = "workflow.json" @staticmethod def root_path() -> str: @@ -135,7 +135,7 @@ class FileSystemService: if item.is_file(): if item.name.startswith("."): continue # Ignore hidden files - if item.name == FileSystemService.WF_JSON_FILE: + if item.name == FileSystemService.PROCESS_MODEL_JSON_FILE: continue # Ignore the json files. if file_name is not None and item.name != file_name: continue diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py index 06d0a7d7a..28547b441 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py @@ -36,14 +36,14 @@ class ProcessModelService(FileSystemService): def is_group(self, path: str) -> bool: """Is_group.""" - group_json_path = os.path.join(path, self.CAT_JSON_FILE) + group_json_path = os.path.join(path, self.PROCESS_GROUP_JSON_FILE) if os.path.exists(group_json_path): return True return False def is_model(self, path: str) -> bool: """Is_model.""" - model_json_path = os.path.join(path, self.WF_JSON_FILE) + model_json_path = os.path.join(path, self.PROCESS_MODEL_JSON_FILE) if os.path.exists(model_json_path): return True return False @@ -59,13 +59,13 @@ class ProcessModelService(FileSystemService): end = start + per_page return items[start:end] - def add_spec(self, process_model: ProcessModelInfo) -> None: + def add_process_model(self, process_model: ProcessModelInfo) -> None: """Add_spec.""" display_order = self.next_display_order(process_model) process_model.display_order = display_order self.save_process_model(process_model) - def update_spec( + def update_process_model( self, process_model: ProcessModelInfo, attributes_to_update: dict ) -> None: """Update_spec.""" @@ -78,7 +78,7 @@ class ProcessModelService(FileSystemService): """Save_process_model.""" spec_path = os.path.join(FileSystemService.root_path(), process_model.id) os.makedirs(spec_path, exist_ok=True) - json_path = os.path.join(spec_path, self.WF_JSON_FILE) + json_path = os.path.join(spec_path, self.PROCESS_MODEL_JSON_FILE) with open(json_path, "w") as wf_json: json.dump( self.WF_SCHEMA.dump(process_model), wf_json, indent=4, sort_keys=True @@ -205,7 +205,7 @@ class ProcessModelService(FileSystemService): """Update_process_group.""" cat_path = self.process_group_path(process_group.id) os.makedirs(cat_path, exist_ok=True) - json_path = os.path.join(cat_path, self.CAT_JSON_FILE) + json_path = os.path.join(cat_path, self.PROCESS_GROUP_JSON_FILE) with open(json_path, "w") as cat_json: json.dump( process_group.serialized, @@ -279,7 +279,7 @@ class ProcessModelService(FileSystemService): def __scan_process_group(self, dir_path: str) -> ProcessGroup: """Reads the process_group.json file, and any nested directories.""" - cat_path = os.path.join(dir_path, self.CAT_JSON_FILE) + cat_path = os.path.join(dir_path, self.PROCESS_GROUP_JSON_FILE) if os.path.exists(cat_path): with open(cat_path) as cat_json: data = json.load(cat_json) @@ -329,7 +329,7 @@ class ProcessModelService(FileSystemService): process_group: Optional[ProcessGroup] = None, ) -> ProcessModelInfo: """__scan_spec.""" - spec_path = os.path.join(path, self.WF_JSON_FILE) + spec_path = os.path.join(path, self.PROCESS_MODEL_JSON_FILE) if os.path.exists(spec_path): with open(spec_path) as wf_json: diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/spec_file_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/spec_file_service.py index 2d5bb76e7..044b824bf 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/spec_file_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/spec_file_service.py @@ -171,7 +171,7 @@ class SpecFileService(FileSystemService): ref.is_primary = True if ref.is_primary: - ProcessModelService().update_spec( + ProcessModelService().update_process_model( process_model_info, { "primary_process_id": ref.identifier, diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/helpers/example_data.py b/spiffworkflow-backend/tests/spiffworkflow_backend/helpers/example_data.py index 2e2289df2..befd2602a 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/helpers/example_data.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/helpers/example_data.py @@ -39,7 +39,7 @@ class ExampleDataLoader: is_review=False, ) workflow_spec_service = ProcessModelService() - workflow_spec_service.add_spec(spec) + workflow_spec_service.add_process_model(spec) bpmn_file_name_with_extension = bpmn_file_name if not bpmn_file_name_with_extension: diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py index 5596e72ab..fbbf7deb7 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py @@ -1830,7 +1830,7 @@ class TestProcessApi(BaseTest): process_model = ProcessModelService().get_process_model( process_model_identifier ) - ProcessModelService().update_spec( + ProcessModelService().update_process_model( process_model, {"fault_or_suspend_on_exception": NotificationType.suspend.value}, ) @@ -1885,7 +1885,7 @@ class TestProcessApi(BaseTest): process_model = ProcessModelService().get_process_model( process_model_identifier ) - ProcessModelService().update_spec( + ProcessModelService().update_process_model( process_model, {"exception_notification_addresses": ["with_super_admin_user@example.com"]}, ) diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_model_service.py b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_model_service.py index 438ef89d9..427337753 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_model_service.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_model_service.py @@ -32,7 +32,7 @@ class TestProcessModelService(BaseTest): primary_process_id = process_model.primary_process_id assert primary_process_id == "Process_HelloWorld" - ProcessModelService().update_spec(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