mirror of
https://github.com/sartography/spiffworkflow-backend.git
synced 2025-02-24 21:38:22 +00:00
Separate process_instance_create into process_instance_create and process_instance_run
Add get_process_instance Add ProcessInstanceModelSchema
This commit is contained in:
parent
8bbf15ed29
commit
5974640e01
@ -107,6 +107,30 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel):
|
||||
}
|
||||
|
||||
|
||||
class ProcessInstanceModelSchema(Schema):
|
||||
|
||||
class Meta:
|
||||
model = ProcessInstanceModel
|
||||
fields = [
|
||||
"id",
|
||||
"process_model_identifier",
|
||||
"process_group_identifier",
|
||||
"process_initiator_id",
|
||||
# "process_initiator",
|
||||
"bpmn_json",
|
||||
"start_in_seconds",
|
||||
"end_in_seconds",
|
||||
"updated_at_in_seconds",
|
||||
"created_at_in_seconds",
|
||||
"status"
|
||||
]
|
||||
|
||||
status = marshmallow.fields.Method('get_status', dump_only=True)
|
||||
|
||||
def get_status(self, obj):
|
||||
return obj.status.value
|
||||
|
||||
|
||||
class ProcessInstanceApi:
|
||||
"""ProcessInstanceApi."""
|
||||
|
||||
|
@ -23,7 +23,7 @@ from spiffworkflow_backend.models.file import FileType
|
||||
from spiffworkflow_backend.models.principal import PrincipalModel
|
||||
from spiffworkflow_backend.models.process_group import ProcessGroupSchema
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceApiSchema
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel, ProcessInstanceModelSchema
|
||||
from spiffworkflow_backend.models.process_model import ProcessModelInfoSchema
|
||||
from spiffworkflow_backend.services.error_handling_service import ErrorHandlingService
|
||||
from spiffworkflow_backend.services.process_instance_processor import (
|
||||
@ -262,6 +262,21 @@ def process_instance_create(
|
||||
process_instance = ProcessInstanceService.create_process_instance(
|
||||
process_model_id, g.user, process_group_identifier=process_group_id
|
||||
)
|
||||
return Response(
|
||||
json.dumps(ProcessInstanceModelSchema().dump(process_instance)),
|
||||
status=201,
|
||||
mimetype="application/json"
|
||||
)
|
||||
|
||||
|
||||
def process_instance_run(
|
||||
process_group_id: str,
|
||||
process_model_id: str,
|
||||
process_instance_id: str,
|
||||
do_engine_steps: bool = None
|
||||
|
||||
) -> flask.wrappers.Response:
|
||||
process_instance = ProcessInstanceService().get_process_instance(process_instance_id)
|
||||
processor = ProcessInstanceProcessor(process_instance)
|
||||
|
||||
try:
|
||||
@ -281,15 +296,6 @@ def process_instance_create(
|
||||
json.dumps(process_instance_metadata), status=201, mimetype="application/json"
|
||||
)
|
||||
|
||||
def process_instance_run(
|
||||
process_group_id: str,
|
||||
process_model_id: str,
|
||||
process_instance_id: str,
|
||||
do_engine_steps: bool
|
||||
|
||||
) -> flask.wrappers.Response:
|
||||
...
|
||||
|
||||
|
||||
def process_instance_list(
|
||||
process_group_id: str,
|
||||
|
@ -125,3 +125,7 @@ class ProcessInstanceService:
|
||||
return {}
|
||||
else:
|
||||
return {}
|
||||
|
||||
def get_process_instance(self, process_instance_id):
|
||||
result = db.session.query(ProcessInstanceModel).filter(ProcessInstanceModel.id == process_instance_id).first()
|
||||
return result
|
||||
|
Loading…
x
Reference in New Issue
Block a user