Merge branch 'main' of github.com:sartography/spiffworkflow-backend

# Conflicts:
#	bin/save_all_bpmn.py
#	migrations/versions/097f52a3ec5d_.py
#	migrations/versions/8aae66f8bba5_.py
#	migrations/versions/eadaa0914e7a_.py
This commit is contained in:
mike cullerton 2022-09-19 09:03:13 -04:00
commit af6fef156f
3 changed files with 63 additions and 41 deletions

View File

@ -5,6 +5,8 @@ from spiffworkflow_backend import create_app
from spiffworkflow_backend.services.process_model_service import ProcessModelService
from spiffworkflow_backend.services.spec_file_service import SpecFileService
# from lxml.etree import Element as EtreeElement
def main():
"""Main."""
@ -21,41 +23,61 @@ def main():
process_models = ProcessModelService().get_process_models()
for process_model in process_models:
if process_model.primary_file_name:
files = SpecFileService.get_files(
process_model, extension_filter="bpmn"
bpmn_xml_file_contents = SpecFileService.get_data(
process_model, process_model.primary_file_name
)
if len(files) == 1:
# print(f"primary_file_name: {process_model.primary_file_name}")
bpmn_xml_file_contents = SpecFileService.get_data(
process_model, process_model.primary_file_name
)
# bpmn_etree_element: EtreeElement = (
# SpecFileService.get_etree_element_from_binary_data(
# bpmn_xml_file_contents, process_model.primary_file_name
# )
# )
# try:
# attributes_to_update = {
# "primary_process_id": (
# SpecFileService.get_bpmn_process_identifier(
# bpmn_etree_element
# )
# ),
# }
# ProcessModelService().update_spec(
# process_model, attributes_to_update
# )
SpecFileService.update_file(
process_model,
process_model.primary_file_name,
bpmn_xml_file_contents,
)
# except Exception:
# print(process_model.id)
bad_files = [
"B.1.0.bpmn",
"C.1.0.bpmn",
"C.2.0.bpmn",
"C.6.0.bpmn",
"TC-5.1.bpmn",
]
if process_model.primary_file_name in bad_files:
continue
print(f"primary_file_name: {process_model.primary_file_name}")
SpecFileService.update_file(
process_model,
process_model.primary_file_name,
bpmn_xml_file_contents,
)
# files = SpecFileService.get_files(
# process_model, extension_filter="bpmn"
# )
# bpmn_etree_element: EtreeElement = (
# SpecFileService.get_etree_element_from_binary_data(
# bpmn_xml_file_contents, process_model.primary_file_name
# )
# )
# if len(files) == 1:
# try:
# new_bpmn_process_identifier = (
# SpecFileService.get_bpmn_process_identifier(
# bpmn_etree_element
# )
# )
# if (
# process_model.primary_process_id
# != new_bpmn_process_identifier
# ):
# print(
# "primary_process_id: ", process_model.primary_process_id
# )
# # attributes_to_update = {
# # "primary_process_id": new_bpmn_process_identifier
# # }
# # ProcessModelService().update_spec(
# # process_model, attributes_to_update
# # )
# # except Exception as exception:
# except Exception:
# print(f"BAD ONE: {process_model.id}")
# # raise exception
else:
no_primary.append(process_model)
for bpmn in no_primary:
print(bpmn)
# for bpmn in no_primary:
# print(bpmn)
if __name__ == "__main__":

View File

@ -1,8 +1,8 @@
"""empty message
Revision ID: 8aae66f8bba5
Revision ID: 00a59d952198
Revises:
Create Date: 2022-09-16 13:46:31.330999
Create Date: 2022-09-19 09:01:56.805355
"""
from alembic import op
@ -10,7 +10,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8aae66f8bba5'
revision = '00a59d952198'
down_revision = None
branch_labels = None
depends_on = None
@ -208,11 +208,11 @@ def upgrade():
op.create_table('spiff_logging',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('process_instance_id', sa.Integer(), nullable=False),
sa.Column('bpmn_process_identifier', sa.String(length=50), nullable=False),
sa.Column('bpmn_task_identifier', sa.String(length=50), nullable=False),
sa.Column('bpmn_process_identifier', sa.String(length=255), nullable=False),
sa.Column('bpmn_task_identifier', sa.String(length=255), nullable=False),
sa.Column('spiff_task_guid', sa.String(length=50), nullable=False),
sa.Column('timestamp', sa.DECIMAL(precision=17, scale=6), nullable=False),
sa.Column('message', sa.String(length=50), nullable=True),
sa.Column('message', sa.String(length=255), nullable=True),
sa.Column('current_user_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['current_user_id'], ['user.id'], ),
sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ),

View File

@ -17,9 +17,9 @@ class SpiffLoggingModel(SpiffworkflowBaseDBModel):
__tablename__ = "spiff_logging"
id: int = db.Column(db.Integer, primary_key=True)
process_instance_id: int = db.Column(ForeignKey(ProcessInstanceModel.id), nullable=False) # type: ignore
bpmn_process_identifier: str = db.Column(db.String(50), nullable=False)
bpmn_task_identifier: str = db.Column(db.String(50), nullable=False)
bpmn_process_identifier: str = db.Column(db.String(255), nullable=False)
bpmn_task_identifier: str = db.Column(db.String(255), nullable=False)
spiff_task_guid: str = db.Column(db.String(50), nullable=False)
timestamp: float = db.Column(db.DECIMAL(17, 6), nullable=False)
message: Optional[str] = db.Column(db.String(50), nullable=True)
message: Optional[str] = db.Column(db.String(255), nullable=True)
current_user_id: int = db.Column(ForeignKey(UserModel.id), nullable=True)