From 5e13a23912215ed80c892af4ed49fa41bad56c77 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 18 Oct 2022 15:55:50 -0400 Subject: [PATCH] Remove the "master_spec" --- .../models/process_model.py | 2 -- .../services/file_system_service.py | 30 ++++------------- .../services/process_model_service.py | 33 ------------------- .../helpers/base_test.py | 1 - .../helpers/example_data.py | 2 -- .../helpers/test_data.py | 7 ++-- 6 files changed, 8 insertions(+), 67 deletions(-) diff --git a/src/spiffworkflow_backend/models/process_model.py b/src/spiffworkflow_backend/models/process_model.py index 9fdc8077..686c5c74 100644 --- a/src/spiffworkflow_backend/models/process_model.py +++ b/src/spiffworkflow_backend/models/process_model.py @@ -31,7 +31,6 @@ class ProcessModelInfo: description: str process_group_id: str = "" process_group: Any | None = None - is_master_spec: bool | None = False standalone: bool | None = False library: bool | None = False primary_file_name: str | None = None @@ -67,7 +66,6 @@ class ProcessModelInfoSchema(Schema): id = marshmallow.fields.String(required=True) display_name = marshmallow.fields.String(required=True) description = marshmallow.fields.String() - is_master_spec = marshmallow.fields.Boolean(required=True) standalone = marshmallow.fields.Boolean(required=True) library = marshmallow.fields.Boolean(required=True) display_order = marshmallow.fields.Integer(allow_none=True) diff --git a/src/spiffworkflow_backend/services/file_system_service.py b/src/spiffworkflow_backend/services/file_system_service.py index 735f13d7..ecd2765e 100644 --- a/src/spiffworkflow_backend/services/file_system_service.py +++ b/src/spiffworkflow_backend/services/file_system_service.py @@ -22,9 +22,8 @@ class FileSystemService: """ LIBRARY_SPECS = "Library Specs" STAND_ALONE_SPECS = "Stand Alone" - MASTER_SPECIFICATION = "Master Specification" REFERENCE_FILES = "Reference Files" - SPECIAL_FOLDERS = [LIBRARY_SPECS, MASTER_SPECIFICATION, REFERENCE_FILES] + SPECIAL_FOLDERS = [LIBRARY_SPECS, REFERENCE_FILES] CAT_JSON_FILE = "process_group.json" WF_JSON_FILE = "workflow.json" @@ -66,32 +65,15 @@ class FileSystemService: @staticmethod def process_group_path_for_spec(spec: ProcessModelInfo) -> str: """Category_path_for_spec.""" - if spec.is_master_spec: - return os.path.join(FileSystemService.root_path()) - elif spec.library: - process_group_path = FileSystemService.process_group_path( - FileSystemService.LIBRARY_SPECS - ) - elif spec.standalone: - process_group_path = FileSystemService.process_group_path( - FileSystemService.STAND_ALONE_SPECS - ) - else: - process_group_path = FileSystemService.process_group_path( - spec.process_group_id - ) - return process_group_path + return FileSystemService.process_group_path( + spec.process_group_id + ) @staticmethod def workflow_path(spec: ProcessModelInfo) -> str: """Workflow_path.""" - if spec.is_master_spec: - return os.path.join( - FileSystemService.root_path(), FileSystemService.MASTER_SPECIFICATION - ) - else: - process_group_path = FileSystemService.process_group_path_for_spec(spec) - return os.path.join(process_group_path, spec.id) + process_group_path = FileSystemService.process_group_path_for_spec(spec) + return os.path.join(process_group_path, spec.id) @staticmethod def full_path_to_process_model_file(spec: ProcessModelInfo, file_name: str) -> str: diff --git a/src/spiffworkflow_backend/services/process_model_service.py b/src/spiffworkflow_backend/services/process_model_service.py index c48c9d98..019a5d8b 100644 --- a/src/spiffworkflow_backend/services/process_model_service.py +++ b/src/spiffworkflow_backend/services/process_model_service.py @@ -63,12 +63,6 @@ class ProcessModelService(FileSystemService): def save_process_model(self, process_model: ProcessModelInfo) -> None: """Save_process_model.""" spec_path = self.workflow_path(process_model) - if ( - process_model.is_master_spec - or process_model.library - or process_model.standalone - ): - process_model.process_group_id = "" os.makedirs(spec_path, exist_ok=True) json_path = os.path.join(spec_path, self.WF_JSON_FILE) with open(json_path, "w") as wf_json: @@ -90,20 +84,6 @@ class ProcessModelService(FileSystemService): path = self.workflow_path(process_model) shutil.rmtree(path) - @property - def master_spec(self) -> Optional[ProcessModelInfo]: - """Master_spec.""" - return self.get_master_spec() - - def get_master_spec(self) -> Optional[ProcessModelInfo]: - """Get_master_spec.""" - path = os.path.join( - FileSystemService.root_path(), FileSystemService.MASTER_SPECIFICATION - ) - if os.path.exists(path): - return self.__scan_spec(path, FileSystemService.MASTER_SPECIFICATION) - return None - @classmethod def get_process_model_from_relative_path( cls, relative_path: str @@ -121,9 +101,6 @@ class ProcessModelService(FileSystemService): if not os.path.exists(FileSystemService.root_path()): raise ProcessEntityNotFoundError("process_model_not_found") - master_spec = self.get_master_spec() - if master_spec and master_spec.id == process_model_id: - return master_spec if group_id is not None: process_group = self.get_process_group(group_id) if process_group is not None: @@ -240,14 +217,6 @@ class ProcessModelService(FileSystemService): process_groups = [] for item in directory_items: if item.is_dir() and not item.name[0] == ".": - # if item.name == self.REFERENCE_FILES: - # continue - # elif item.name == self.MASTER_SPECIFICATION: - # continue - # elif item.name == self.LIBRARY_SPECS: - # continue - # elif item.name == self.STAND_ALONE_SPECS: - # continue process_groups.append(self.__scan_process_group(item)) return process_groups @@ -292,7 +261,6 @@ class ProcessModelService(FileSystemService): ) -> ProcessModelInfo: """__scan_spec.""" spec_path = os.path.join(path, self.WF_JSON_FILE) - is_master = FileSystemService.MASTER_SPECIFICATION in spec_path if os.path.exists(spec_path): with open(spec_path) as wf_json: @@ -314,7 +282,6 @@ class ProcessModelService(FileSystemService): id=name, library=False, standalone=False, - is_master_spec=is_master, display_name=name, description="", display_order=0, diff --git a/tests/spiffworkflow_backend/helpers/base_test.py b/tests/spiffworkflow_backend/helpers/base_test.py index 05cfdec4..a4ffb85d 100644 --- a/tests/spiffworkflow_backend/helpers/base_test.py +++ b/tests/spiffworkflow_backend/helpers/base_test.py @@ -117,7 +117,6 @@ class BaseTest: process_group_id=process_group.id, standalone=False, is_review=False, - is_master_spec=False, libraries=[], library=False, primary_process_id=primary_process_id, diff --git a/tests/spiffworkflow_backend/helpers/example_data.py b/tests/spiffworkflow_backend/helpers/example_data.py index 811d51fe..55252528 100644 --- a/tests/spiffworkflow_backend/helpers/example_data.py +++ b/tests/spiffworkflow_backend/helpers/example_data.py @@ -18,7 +18,6 @@ class ExampleDataLoader: process_model_id: str, display_name: str = "", description: str = "", - master_spec: bool = False, process_group_id: str = "", display_order: int = 0, from_tests: bool = False, @@ -38,7 +37,6 @@ class ExampleDataLoader: description=description, process_group_id=process_group_id, display_order=display_order, - is_master_spec=master_spec, standalone=standalone, library=library, is_review=False, diff --git a/tests/spiffworkflow_backend/helpers/test_data.py b/tests/spiffworkflow_backend/helpers/test_data.py index aa0d3436..659e42fa 100644 --- a/tests/spiffworkflow_backend/helpers/test_data.py +++ b/tests/spiffworkflow_backend/helpers/test_data.py @@ -37,7 +37,6 @@ def assure_process_group_exists(process_group_id: Optional[str] = None) -> Proce def load_test_spec( process_model_id: str, - master_spec: bool = False, process_group_id: Optional[str] = None, library: bool = False, bpmn_file_name: Optional[str] = None, @@ -48,9 +47,8 @@ def load_test_spec( process_model_service = ProcessModelService() if process_group_id is None: process_group_id = "test_process_group_id" - if not master_spec and not library: - process_group = assure_process_group_exists(process_group_id) - process_group_id = process_group.id + process_group = assure_process_group_exists(process_group_id) + process_group_id = process_group.id try: return process_model_service.get_process_model( @@ -59,7 +57,6 @@ def load_test_spec( except ProcessEntityNotFoundError: spec = ExampleDataLoader().create_spec( process_model_id=process_model_id, - master_spec=master_spec, from_tests=True, display_name=process_model_id, process_group_id=process_group_id,