Changed ProcessModelService.get_spec to get_process_model
This commit is contained in:
parent
0afd8e11b5
commit
20810fd999
|
@ -60,7 +60,7 @@ def process_group_show(process_group_id):
|
|||
@admin_blueprint.route("/process-models/<process_model_id>", methods=["GET"])
|
||||
def process_model_show(process_model_id):
|
||||
"""Show_process_model."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
process_model = ProcessModelService().get_process_model(process_model_id)
|
||||
files = SpecFileService.get_files(process_model, extension_filter="bpmn")
|
||||
current_file_name = process_model.primary_file_name
|
||||
bpmn_xml = SpecFileService.get_data(process_model, current_file_name)
|
||||
|
@ -78,7 +78,7 @@ def process_model_show(process_model_id):
|
|||
)
|
||||
def process_model_show_file(process_model_id, file_name):
|
||||
"""Process_model_show_file."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
process_model = ProcessModelService().get_process_model(process_model_id)
|
||||
bpmn_xml = SpecFileService.get_data(process_model, file_name)
|
||||
files = SpecFileService.get_files(process_model, extension_filter="bpmn")
|
||||
return render_template(
|
||||
|
@ -96,7 +96,7 @@ def process_model_show_file(process_model_id, file_name):
|
|||
def process_model_upload_file(process_model_id):
|
||||
"""Process_model_upload_file."""
|
||||
process_model_service = ProcessModelService()
|
||||
process_model = process_model_service.get_spec(process_model_id)
|
||||
process_model = process_model_service.get_process_model(process_model_id)
|
||||
|
||||
if "file" not in request.files:
|
||||
flash("No file part", "error")
|
||||
|
@ -121,7 +121,7 @@ def process_model_upload_file(process_model_id):
|
|||
)
|
||||
def process_model_edit(process_model_id, file_name):
|
||||
"""Edit_bpmn."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
process_model = ProcessModelService().get_process_model(process_model_id)
|
||||
bpmn_xml = SpecFileService.get_data(process_model, file_name)
|
||||
|
||||
return render_template(
|
||||
|
@ -137,7 +137,7 @@ def process_model_edit(process_model_id, file_name):
|
|||
)
|
||||
def process_model_save(process_model_id, file_name):
|
||||
"""Process_model_save."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
process_model = ProcessModelService().get_process_model(process_model_id)
|
||||
SpecFileService.update_file(process_model, file_name, request.get_data())
|
||||
bpmn_xml = SpecFileService.get_data(process_model, process_model.primary_file_name)
|
||||
return render_template(
|
||||
|
@ -159,7 +159,7 @@ def process_model_run(process_model_id):
|
|||
processor.do_engine_steps()
|
||||
result = processor.get_data()
|
||||
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
process_model = ProcessModelService().get_process_model(process_model_id)
|
||||
files = SpecFileService.get_files(process_model, extension_filter="bpmn")
|
||||
current_file_name = process_model.primary_file_name
|
||||
bpmn_xml = SpecFileService.get_data(process_model, process_model.primary_file_name)
|
||||
|
|
|
@ -105,7 +105,7 @@ def process_model_update(process_group_id, process_model_id, body):
|
|||
|
||||
def process_model_show(process_group_id, process_model_id):
|
||||
"""Process_model_show."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id, process_group_id)
|
||||
process_model = ProcessModelService().get_process_model(process_model_id, process_group_id)
|
||||
if process_model is None:
|
||||
raise (
|
||||
ApiError(
|
||||
|
@ -123,7 +123,7 @@ def process_model_show(process_group_id, process_model_id):
|
|||
|
||||
def get_file(process_model_id, file_name):
|
||||
"""Get_file."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
process_model = ProcessModelService().get_process_model(process_model_id)
|
||||
files = SpecFileService.get_files(process_model, file_name)
|
||||
if len(files) == 0:
|
||||
raise ApiError(
|
||||
|
@ -143,7 +143,7 @@ def get_file(process_model_id, file_name):
|
|||
|
||||
def process_model_file_update(process_model_id, file_name):
|
||||
"""Process_model_file_save."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
process_model = ProcessModelService().get_process_model(process_model_id)
|
||||
|
||||
request_file = get_file_from_request()
|
||||
request_file_contents = request_file.stream.read()
|
||||
|
@ -161,7 +161,7 @@ def process_model_file_update(process_model_id, file_name):
|
|||
def add_file(process_model_id):
|
||||
"""Add_file."""
|
||||
process_model_service = ProcessModelService()
|
||||
process_model = process_model_service.get_spec(process_model_id)
|
||||
process_model = process_model_service.get_process_model(process_model_id)
|
||||
request_file = get_file_from_request()
|
||||
file = SpecFileService.add_file(
|
||||
process_model, request_file.filename, request_file.stream.read()
|
||||
|
@ -202,7 +202,7 @@ def process_instance_create(process_group_id, process_model_id):
|
|||
|
||||
def process_instance_list(process_model_id, page=1, per_page=100):
|
||||
"""Process_instance_list."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
process_model = ProcessModelService().get_process_model(process_model_id)
|
||||
if process_model is None:
|
||||
raise (
|
||||
ApiError(
|
||||
|
|
|
@ -101,7 +101,7 @@ class ProcessInstanceProcessor:
|
|||
self.process_model_service = ProcessModelService()
|
||||
spec = None
|
||||
if process_instance_model.bpmn_json is None:
|
||||
spec_info = self.process_model_service.get_spec(
|
||||
spec_info = self.process_model_service.get_process_model(
|
||||
process_instance_model.process_model_identifier
|
||||
)
|
||||
if spec_info is None:
|
||||
|
|
|
@ -51,8 +51,8 @@ class ProcessInstanceService:
|
|||
"""
|
||||
navigation = processor.bpmn_process_instance.get_deep_nav_list()
|
||||
# ProcessInstanceService.update_navigation(navigation, processor)
|
||||
spec_service = ProcessModelService()
|
||||
spec = spec_service.get_spec(processor.process_model_identifier)
|
||||
process_model_service = ProcessModelService()
|
||||
process_model = process_model_service.get_process_model(processor.process_model_identifier)
|
||||
process_instance_api = ProcessInstanceApi(
|
||||
id=processor.get_process_instance_id(),
|
||||
status=processor.get_status(),
|
||||
|
@ -62,8 +62,8 @@ class ProcessInstanceService:
|
|||
total_tasks=len(navigation),
|
||||
completed_tasks=processor.process_instance_model.completed_tasks,
|
||||
last_updated=processor.process_instance_model.last_updated,
|
||||
is_review=spec.is_review,
|
||||
title=spec.display_name,
|
||||
is_review=process_model.is_review,
|
||||
title=process_model.display_name,
|
||||
)
|
||||
if (
|
||||
not next_task
|
||||
|
|
|
@ -52,12 +52,12 @@ class ProcessModelService(FileSystemService):
|
|||
code="existing_instances",
|
||||
message=f"We cannot delete the model `{process_model_id}`, there are existing instances that depend on it.",
|
||||
)
|
||||
spec = self.get_spec(process_model_id)
|
||||
if not spec:
|
||||
process_model = self.get_process_model(process_model_id)
|
||||
if not process_model:
|
||||
return
|
||||
if spec.library:
|
||||
self.__remove_library_references(spec.id)
|
||||
path = self.workflow_path(spec)
|
||||
if process_model.library:
|
||||
self.__remove_library_references(process_model.id)
|
||||
path = self.workflow_path(process_model)
|
||||
shutil.rmtree(path)
|
||||
|
||||
def __remove_library_references(self, spec_id):
|
||||
|
@ -80,17 +80,17 @@ class ProcessModelService(FileSystemService):
|
|||
if os.path.exists(path):
|
||||
return self.__scan_spec(path, FileSystemService.MASTER_SPECIFICATION)
|
||||
|
||||
def get_spec(self, spec_id, group_id=None):
|
||||
"""Get_spec."""
|
||||
def get_process_model(self, process_model_id, group_id=None):
|
||||
"""Get a process model from a model and group id"""
|
||||
if not os.path.exists(FileSystemService.root_path()):
|
||||
return # Nothing to scan yet. There are no files.
|
||||
|
||||
master_spec = self.get_master_spec()
|
||||
if master_spec and master_spec.id == spec_id:
|
||||
if master_spec and master_spec.id == process_model_id:
|
||||
return master_spec
|
||||
if group_id is not None:
|
||||
for process_model in self.get_process_group(group_id).process_models:
|
||||
if spec_id == process_model.id:
|
||||
if process_model_id == process_model.id:
|
||||
return process_model
|
||||
with os.scandir(FileSystemService.root_path()) as process_group_dirs:
|
||||
for item in process_group_dirs:
|
||||
|
@ -98,7 +98,7 @@ class ProcessModelService(FileSystemService):
|
|||
if item.is_dir():
|
||||
with os.scandir(item.path) as spec_dirs:
|
||||
for sd in spec_dirs:
|
||||
if sd.name == spec_id:
|
||||
if sd.name == process_model_id:
|
||||
# Now we have the process_group direcotry, and spec directory
|
||||
process_group = self.__scan_process_group(
|
||||
process_group_dir
|
||||
|
|
|
@ -60,7 +60,7 @@ def load_test_spec(
|
|||
if not master_spec and not library:
|
||||
process_group = assure_process_group_exists(process_group_id)
|
||||
process_group_id = process_group.id
|
||||
workflow_spec = workflow_spec_service.get_spec(dir_name)
|
||||
workflow_spec = workflow_spec_service.get_process_model(dir_name)
|
||||
if workflow_spec:
|
||||
return workflow_spec
|
||||
else:
|
||||
|
|
|
@ -53,7 +53,7 @@ def test_process_model_delete(
|
|||
create_process_model(app, client)
|
||||
|
||||
# assert we have a model
|
||||
process_model = ProcessModelService().get_spec("make_cookies")
|
||||
process_model = ProcessModelService().get_process_model("make_cookies")
|
||||
assert process_model is not None
|
||||
assert process_model.id == "make_cookies"
|
||||
|
||||
|
@ -67,7 +67,7 @@ def test_process_model_delete(
|
|||
assert response.json["ok"] is True
|
||||
|
||||
# assert we no longer have a model
|
||||
process_model = ProcessModelService().get_spec("make_cookies")
|
||||
process_model = ProcessModelService().get_process_model("make_cookies")
|
||||
assert process_model is None
|
||||
|
||||
|
||||
|
@ -112,7 +112,7 @@ def test_process_model_update(
|
|||
) -> None:
|
||||
"""Test_process_model_update."""
|
||||
create_process_model(app, client)
|
||||
process_model = ProcessModelService().get_spec("make_cookies")
|
||||
process_model = ProcessModelService().get_process_model("make_cookies")
|
||||
assert process_model.id == "make_cookies"
|
||||
assert process_model.display_name == "Cooooookies"
|
||||
|
||||
|
|
Loading…
Reference in New Issue