From 2c751a7825293c4c17469109abc046f078f24718 Mon Sep 17 00:00:00 2001 From: burnettk Date: Thu, 24 Nov 2022 12:28:53 -0500 Subject: [PATCH] remove column --- spiffworkflow-backend/migrations/env.py | 2 ++ .../versions/{37079935891c_.py => 568f5fe2c9f8_.py} | 9 +++------ .../spiffworkflow_backend/models/process_instance.py | 7 ++++--- .../services/process_model_service.py | 8 ++++---- .../tests/spiffworkflow_backend/helpers/base_test.py | 10 +++++++++- 5 files changed, 22 insertions(+), 14 deletions(-) rename spiffworkflow-backend/migrations/versions/{37079935891c_.py => 568f5fe2c9f8_.py} (97%) diff --git a/spiffworkflow-backend/migrations/env.py b/spiffworkflow-backend/migrations/env.py index 630e381a..68feded2 100644 --- a/spiffworkflow-backend/migrations/env.py +++ b/spiffworkflow-backend/migrations/env.py @@ -1,3 +1,5 @@ +from __future__ import with_statement + import logging from logging.config import fileConfig diff --git a/spiffworkflow-backend/migrations/versions/37079935891c_.py b/spiffworkflow-backend/migrations/versions/568f5fe2c9f8_.py similarity index 97% rename from spiffworkflow-backend/migrations/versions/37079935891c_.py rename to spiffworkflow-backend/migrations/versions/568f5fe2c9f8_.py index 7bd8ff31..bfd7fc2b 100644 --- a/spiffworkflow-backend/migrations/versions/37079935891c_.py +++ b/spiffworkflow-backend/migrations/versions/568f5fe2c9f8_.py @@ -1,8 +1,8 @@ """empty message -Revision ID: 37079935891c +Revision ID: 568f5fe2c9f8 Revises: -Create Date: 2022-11-24 11:44:47.149204 +Create Date: 2022-11-24 12:11:46.669020 """ from alembic import op @@ -10,7 +10,7 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '37079935891c' +revision = '568f5fe2c9f8' down_revision = None branch_labels = None depends_on = None @@ -119,7 +119,6 @@ def upgrade(): sa.Column('id', sa.Integer(), nullable=False), sa.Column('process_model_identifier', sa.String(length=255), nullable=False), sa.Column('process_model_display_name', sa.String(length=255), nullable=False), - sa.Column('process_group_identifier', sa.String(length=50), nullable=False), sa.Column('process_initiator_id', sa.Integer(), nullable=False), sa.Column('bpmn_json', sa.JSON(), nullable=True), sa.Column('start_in_seconds', sa.Integer(), nullable=True), @@ -133,7 +132,6 @@ def upgrade(): sa.ForeignKeyConstraint(['process_initiator_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id') ) - op.create_index(op.f('ix_process_instance_process_group_identifier'), 'process_instance', ['process_group_identifier'], unique=False) op.create_index(op.f('ix_process_instance_process_model_display_name'), 'process_instance', ['process_model_display_name'], unique=False) op.create_index(op.f('ix_process_instance_process_model_identifier'), 'process_instance', ['process_model_identifier'], unique=False) op.create_table('process_instance_report', @@ -301,7 +299,6 @@ def downgrade(): op.drop_table('process_instance_report') op.drop_index(op.f('ix_process_instance_process_model_identifier'), table_name='process_instance') op.drop_index(op.f('ix_process_instance_process_model_display_name'), table_name='process_instance') - op.drop_index(op.f('ix_process_instance_process_group_identifier'), table_name='process_instance') op.drop_table('process_instance') op.drop_table('principal') op.drop_index(op.f('ix_message_triggerable_process_model_process_model_identifier'), table_name='message_triggerable_process_model') diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py index 005b5b43..0109e8a0 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance.py @@ -75,7 +75,6 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel): process_model_display_name: str = db.Column( db.String(255), nullable=False, index=True ) - process_group_identifier: str = db.Column(db.String(50), nullable=False, index=True) process_initiator_id: int = db.Column(ForeignKey(UserModel.id), nullable=False) process_initiator = relationship("UserModel") @@ -104,7 +103,7 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel): return { "id": self.id, "process_model_identifier": self.process_model_identifier, - "process_group_identifier": self.process_group_identifier, + "process_model_display_name": self.process_model_display_name, "status": self.status, "start_in_seconds": self.start_in_seconds, "end_in_seconds": self.end_in_seconds, @@ -141,7 +140,7 @@ class ProcessInstanceModelSchema(Schema): fields = [ "id", "process_model_identifier", - "process_group_identifier", + "process_model_display_name", "process_initiator_id", "start_in_seconds", "end_in_seconds", @@ -193,6 +192,7 @@ class ProcessInstanceApiSchema(Schema): "status", "next_task", "process_model_identifier", + "process_model_display_name", "completed_tasks", "updated_at_in_seconds", ] @@ -211,6 +211,7 @@ class ProcessInstanceApiSchema(Schema): "status", "next_task", "process_model_identifier", + "process_model_display_name", "completed_tasks", "updated_at_in_seconds", ] 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 d42b3e8e..4d3fed28 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py @@ -158,12 +158,12 @@ class ProcessModelService(FileSystemService): os.path.join(FileSystemService.root_path(), process_model_id) ) if cls.is_model(model_path): - process_model = self.get_process_model_from_relative_path(process_model_id) - return process_model + return cls.get_process_model_from_relative_path(process_model_id) raise ProcessEntityNotFoundError("process_model_not_found") + @classmethod def get_process_models( - self, + cls, process_group_id: Optional[str] = None, recursive: Optional[bool] = False, filter_runnable_by_user: Optional[bool] = False, @@ -183,7 +183,7 @@ class ProcessModelService(FileSystemService): process_model_relative_path = os.path.relpath( file, start=FileSystemService.root_path() ) - process_model = self.get_process_model_from_relative_path( + process_model = cls.get_process_model_from_relative_path( os.path.dirname(process_model_relative_path) ) process_models.append(process_model) diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/helpers/base_test.py b/spiffworkflow-backend/tests/spiffworkflow_backend/helpers/base_test.py index 0ecbbc96..7f7c3fa4 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/helpers/base_test.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/helpers/base_test.py @@ -252,6 +252,14 @@ class BaseTest: There must be an existing process model to instantiate. """ + if not ProcessModelService.is_model(test_process_model_id): + import pdb; pdb.set_trace() + basename = os.path.basename(test_process_model_id) + load_test_spec( + process_model_id=test_process_model_id, + process_model_source_directory=basename, + bpmn_file_name=basename + ) modified_process_model_id = test_process_model_id.replace("/", ":") response = client.post( f"/v1.0/process-models/{modified_process_model_id}/process-instances", @@ -283,7 +291,7 @@ class BaseTest: status=status, process_initiator=user, process_model_identifier=process_model.id, - process_group_identifier="", + process_model_display_name=process_model.display_name, updated_at_in_seconds=round(time.time()), start_in_seconds=current_time - (3600 * 1), end_in_seconds=current_time - (3600 * 1 - 20),