start adding display name and removing garbage

This commit is contained in:
burnettk 2022-11-24 11:51:31 -05:00
parent 1270ea4fb0
commit f8e78d352d
13 changed files with 19 additions and 116 deletions

View File

@ -1,3 +1,5 @@
from __future__ import with_statement
import logging
from logging.config import fileConfig

View File

@ -1,8 +1,8 @@
"""empty message
Revision ID: 70223f5c7b98
Revision ID: 37079935891c
Revises:
Create Date: 2022-11-20 19:54:45.061376
Create Date: 2022-11-24 11:44:47.149204
"""
from alembic import op
@ -10,7 +10,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '70223f5c7b98'
revision = '37079935891c'
down_revision = None
branch_labels = None
depends_on = None
@ -97,14 +97,12 @@ def upgrade():
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('message_model_id', sa.Integer(), nullable=False),
sa.Column('process_model_identifier', sa.String(length=50), nullable=False),
sa.Column('process_group_identifier', sa.String(length=50), nullable=False),
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['message_model_id'], ['message_model.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('message_model_id')
)
op.create_index(op.f('ix_message_triggerable_process_model_process_group_identifier'), 'message_triggerable_process_model', ['process_group_identifier'], unique=False)
op.create_index(op.f('ix_message_triggerable_process_model_process_model_identifier'), 'message_triggerable_process_model', ['process_model_identifier'], unique=False)
op.create_table('principal',
sa.Column('id', sa.Integer(), nullable=False),
@ -120,6 +118,7 @@ def upgrade():
op.create_table('process_instance',
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),
@ -135,6 +134,7 @@ def upgrade():
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',
sa.Column('id', sa.Integer(), nullable=False),
@ -300,11 +300,11 @@ def downgrade():
op.drop_index(op.f('ix_process_instance_report_created_by_id'), table_name='process_instance_report')
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')
op.drop_index(op.f('ix_message_triggerable_process_model_process_group_identifier'), table_name='message_triggerable_process_model')
op.drop_table('message_triggerable_process_model')
op.drop_index(op.f('ix_message_correlation_property_identifier'), table_name='message_correlation_property')
op.drop_table('message_correlation_property')

View File

@ -1665,10 +1665,6 @@ components:
type: integer
x-nullable: true
example: 12
study_id:
type: integer
x-nullable: true
example: 42
user_id:
type: string
x-nullable: true
@ -1793,8 +1789,6 @@ components:
type: integer
num_tasks_incomplete:
type: integer
study_id:
type: integer
example:
id: 291234
@ -1929,9 +1923,6 @@ components:
workflow_id:
example: 42
type: integer
study_id:
example: 187
type: integer
user_uid:
example: "dhf8r"
type: string

View File

@ -16,8 +16,6 @@ class MessageTriggerableProcessModel(SpiffworkflowBaseDBModel):
ForeignKey(MessageModel.id), nullable=False, unique=True
)
process_model_identifier: str = db.Column(db.String(50), nullable=False, index=True)
# fixme: Maybe we don't need this anymore?
process_group_identifier: str = db.Column(db.String(50), nullable=False, index=True)
updated_at_in_seconds: int = db.Column(db.Integer)
created_at_in_seconds: int = db.Column(db.Integer)

View File

@ -74,6 +74,9 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel):
process_model_identifier: str = db.Column(
db.String(255), nullable=False, index=True
)
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")
@ -166,23 +169,18 @@ class ProcessInstanceApi:
status: ProcessInstanceStatus,
next_task: Task | None,
process_model_identifier: str,
process_group_identifier: str,
process_model_display_name: str,
completed_tasks: int,
updated_at_in_seconds: int,
is_review: bool,
title: str,
) -> None:
"""__init__."""
self.id = id
self.status = status
self.next_task = next_task # The next task that requires user input.
# self.navigation = navigation fixme: would be a hotness.
self.process_model_identifier = process_model_identifier
self.process_group_identifier = process_group_identifier
self.process_model_display_name = process_model_display_name
self.completed_tasks = completed_tasks
self.updated_at_in_seconds = updated_at_in_seconds
self.title = title
self.is_review = is_review
class ProcessInstanceApiSchema(Schema):
@ -196,24 +194,14 @@ class ProcessInstanceApiSchema(Schema):
"id",
"status",
"next_task",
"navigation",
"process_model_identifier",
"process_group_identifier",
"completed_tasks",
"updated_at_in_seconds",
"is_review",
"title",
"study_id",
"state",
]
unknown = INCLUDE
status = EnumField(ProcessInstanceStatus)
next_task = marshmallow.fields.Nested(TaskSchema, dump_only=True, required=False)
navigation = marshmallow.fields.List(
marshmallow.fields.Nested(NavigationItemSchema, dump_only=True)
)
state = marshmallow.fields.String(allow_none=True)
@marshmallow.post_load
def make_process_instance(
@ -224,73 +212,10 @@ class ProcessInstanceApiSchema(Schema):
"id",
"status",
"next_task",
"navigation",
"process_model_identifier",
"process_group_identifier",
"completed_tasks",
"updated_at_in_seconds",
"is_review",
"title",
"study_id",
"state",
]
filtered_fields = {key: data[key] for key in keys}
filtered_fields["next_task"] = TaskSchema().make_task(data["next_task"])
return ProcessInstanceApi(**filtered_fields)
@dataclass
class ProcessInstanceMetadata:
"""ProcessInstanceMetadata."""
id: int
display_name: str | None = None
description: str | None = None
spec_version: str | None = None
state: str | None = None
status: str | None = None
completed_tasks: int | None = None
is_review: bool | None = None
state_message: str | None = None
process_model_identifier: str | None = None
process_group_id: str | None = None
@classmethod
def from_process_instance(
cls, process_instance: ProcessInstanceModel, process_model: ProcessModelInfo
) -> ProcessInstanceMetadata:
"""From_process_instance."""
instance = cls(
id=process_instance.id,
display_name=process_model.display_name,
description=process_model.description,
process_group_id=process_model.process_group,
state_message=process_instance.state_message,
status=process_instance.status,
completed_tasks=process_instance.completed_tasks,
is_review=process_model.is_review,
process_model_identifier=process_instance.process_model_identifier,
)
return instance
class ProcessInstanceMetadataSchema(Schema):
"""ProcessInstanceMetadataSchema."""
status = EnumField(ProcessInstanceStatus)
class Meta:
"""Meta."""
model = ProcessInstanceMetadata
additional = [
"id",
"display_name",
"description",
"state",
"completed_tasks",
"process_group_id",
"is_review",
"state_message",
]
unknown = INCLUDE

View File

@ -34,7 +34,6 @@ class ProcessModelInfo:
primary_file_name: str | None = None
primary_process_id: str | None = None
display_order: int | None = 0
is_review: bool = False
files: list[File] | None = field(default_factory=list[File])
fault_or_suspend_on_exception: str = NotificationType.fault.value
exception_notification_addresses: list[str] = field(default_factory=list)
@ -72,7 +71,6 @@ class ProcessModelInfoSchema(Schema):
display_order = marshmallow.fields.Integer(allow_none=True)
primary_file_name = marshmallow.fields.String(allow_none=True)
primary_process_id = marshmallow.fields.String(allow_none=True)
is_review = marshmallow.fields.Boolean(allow_none=True)
files = marshmallow.fields.List(marshmallow.fields.Nested("FileSchema"))
fault_or_suspend_on_exception = marshmallow.fields.String()
exception_notification_addresses = marshmallow.fields.List(

View File

@ -349,7 +349,7 @@ class ProcessInstanceProcessor:
check_sub_specs(test_spec, 5)
self.process_model_identifier = process_instance_model.process_model_identifier
# self.process_group_identifier = process_instance_model.process_group_identifier
self.process_model_display_name = process_instance_model.process_model_display_name
try:
self.bpmn_process_instance = self.__get_bpmn_process_instance(

View File

@ -12,6 +12,7 @@ from spiffworkflow_backend.models.active_task import ActiveTaskModel
from spiffworkflow_backend.models.process_instance import ProcessInstanceApi
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus
from spiffworkflow_backend.models.process_model import ProcessModelInfo
from spiffworkflow_backend.models.task import MultiInstanceType
from spiffworkflow_backend.models.task import Task
from spiffworkflow_backend.models.user import UserModel
@ -30,7 +31,7 @@ class ProcessInstanceService:
@staticmethod
def create_process_instance(
process_model_identifier: str,
process_model: ProcessModelInfo,
user: UserModel,
) -> ProcessInstanceModel:
"""Get_process_instance_from_spec."""
@ -38,8 +39,8 @@ class ProcessInstanceService:
process_instance_model = ProcessInstanceModel(
status=ProcessInstanceStatus.not_started.value,
process_initiator=user,
process_model_identifier=process_model_identifier,
process_group_identifier="",
process_model_identifier=process_model.id,
process_model_display_name=process_model.display_name,
start_in_seconds=round(time.time()),
bpmn_version_control_type="git",
bpmn_version_control_identifier=current_git_revision,
@ -88,20 +89,15 @@ class ProcessInstanceService:
process_model = process_model_service.get_process_model(
processor.process_model_identifier
)
is_review_value = process_model.is_review if process_model else False
title_value = process_model.display_name if process_model else ""
process_instance_api = ProcessInstanceApi(
id=processor.get_process_instance_id(),
status=processor.get_status(),
next_task=None,
# navigation=navigation,
process_model_identifier=processor.process_model_identifier,
process_group_identifier="",
# total_tasks=len(navigation),
process_model_display_name=processor.process_model_display_name,
completed_tasks=processor.process_instance_model.completed_tasks,
updated_at_in_seconds=processor.process_instance_model.updated_at_in_seconds,
is_review=is_review_value,
title=title_value,
)
next_task_trying_again = next_task

View File

@ -429,7 +429,6 @@ class ProcessModelService(FileSystemService):
display_name=name,
description="",
display_order=0,
is_review=False,
)
self.write_json_file(
json_file_path, self.PROCESS_MODEL_SCHEMA.dump(process_model_info)

View File

@ -176,7 +176,6 @@ class SpecFileService(FileSystemService):
{
"primary_process_id": ref.identifier,
"primary_file_name": file_name,
"is_review": ref.has_lanes,
},
)
SpecFileService.update_caches(ref)

View File

@ -149,7 +149,6 @@ class BaseTest:
id=process_model_id,
display_name=process_model_display_name,
description=process_model_description,
is_review=False,
primary_process_id=primary_process_id,
primary_file_name=primary_file_name,
fault_or_suspend_on_exception=fault_or_suspend_on_exception,

View File

@ -36,7 +36,6 @@ class ExampleDataLoader:
display_name=display_name,
description=description,
display_order=display_order,
is_review=False,
)
workflow_spec_service = ProcessModelService()
workflow_spec_service.add_process_model(spec)

View File

@ -332,14 +332,12 @@ class TestProcessApi(BaseTest):
)
assert process_model.id == process_model_identifier
assert process_model.display_name == "Cooooookies"
assert process_model.is_review is False
assert process_model.primary_file_name is None
assert process_model.primary_process_id is None
process_model.display_name = "Updated Display Name"
process_model.primary_file_name = "superduper.bpmn"
process_model.primary_process_id = "superduper"
process_model.is_review = True # not in the include list, so get ignored
modified_process_model_identifier = process_model_identifier.replace("/", ":")
response = client.put(
@ -353,7 +351,6 @@ class TestProcessApi(BaseTest):
assert response.json["display_name"] == "Updated Display Name"
assert response.json["primary_file_name"] == "superduper.bpmn"
assert response.json["primary_process_id"] == "superduper"
assert response.json["is_review"] is False
def test_process_model_list_all(
self,