From 19a3d3b27b3d9c79978420f6cb20496a15288f6c Mon Sep 17 00:00:00 2001 From: burnettk Date: Fri, 16 Sep 2022 18:39:00 -0400 Subject: [PATCH] longer column and update script --- bin/save_all_bpmn.py | 69 ++++++++++--------- .../{6d3ffcc6849e_.py => eadaa0914e7a_.py} | 8 +-- .../models/bpmn_process_id_lookup.py | 2 +- 3 files changed, 41 insertions(+), 38 deletions(-) rename migrations/versions/{6d3ffcc6849e_.py => eadaa0914e7a_.py} (99%) diff --git a/bin/save_all_bpmn.py b/bin/save_all_bpmn.py index 55a0de90..bc3302ae 100644 --- a/bin/save_all_bpmn.py +++ b/bin/save_all_bpmn.py @@ -26,40 +26,43 @@ def main(): files = SpecFileService.get_files( process_model, extension_filter="bpmn" ) - 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_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 ) - bpmn_etree_element: EtreeElement = ( - SpecFileService.get_etree_element_from_binary_data( - bpmn_xml_file_contents, process_model.primary_file_name - ) - ) - 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 - # ) - # SpecFileService.update_file(process_model, process_model.primary_file_name, bpmn_xml_file_contents) - # except Exception as exception: - except Exception: - print(f"BAD ONE: {process_model.id}") - # raise exception + ) + 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) + # 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: diff --git a/migrations/versions/6d3ffcc6849e_.py b/migrations/versions/eadaa0914e7a_.py similarity index 99% rename from migrations/versions/6d3ffcc6849e_.py rename to migrations/versions/eadaa0914e7a_.py index fac466a1..33dd33bc 100644 --- a/migrations/versions/6d3ffcc6849e_.py +++ b/migrations/versions/eadaa0914e7a_.py @@ -1,8 +1,8 @@ """empty message -Revision ID: 6d3ffcc6849e +Revision ID: eadaa0914e7a Revises: -Create Date: 2022-09-16 18:20:43.082949 +Create Date: 2022-09-16 18:32:44.599837 """ from alembic import op @@ -10,7 +10,7 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '6d3ffcc6849e' +revision = 'eadaa0914e7a' down_revision = None branch_labels = None depends_on = None @@ -27,7 +27,7 @@ def upgrade(): ) op.create_table('bpmn_process_id_lookup', sa.Column('id', sa.Integer(), nullable=False), - sa.Column('bpmn_process_identifier', sa.String(length=50), nullable=True), + sa.Column('bpmn_process_identifier', sa.String(length=255), nullable=True), sa.Column('bpmn_file_relative_path', sa.String(length=255), nullable=True), sa.PrimaryKeyConstraint('id') ) diff --git a/src/spiffworkflow_backend/models/bpmn_process_id_lookup.py b/src/spiffworkflow_backend/models/bpmn_process_id_lookup.py index 86b2a0cc..0c71817c 100644 --- a/src/spiffworkflow_backend/models/bpmn_process_id_lookup.py +++ b/src/spiffworkflow_backend/models/bpmn_process_id_lookup.py @@ -9,5 +9,5 @@ class BpmnProcessIdLookup(SpiffworkflowBaseDBModel): __tablename__ = "bpmn_process_id_lookup" id = db.Column(db.Integer, primary_key=True) - bpmn_process_identifier = db.Column(db.String(50), unique=True, index=True) + bpmn_process_identifier = db.Column(db.String(255), unique=True, index=True) bpmn_file_relative_path = db.Column(db.String(255))