152 lines
6.2 KiB
XML
152 lines
6.2 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_96f6665" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
|
|
<bpmn:process id="Process_sartography_admin_import_tickets_import_tickets_bd2e724" isExecutable="true">
|
|
<bpmn:startEvent id="StartEvent_1">
|
|
<bpmn:outgoing>Flow_0pvp5mz</bpmn:outgoing>
|
|
</bpmn:startEvent>
|
|
<bpmn:endEvent id="Event_0kj51tx">
|
|
<bpmn:incoming>Flow_04qc4ur</bpmn:incoming>
|
|
</bpmn:endEvent>
|
|
<bpmn:sequenceFlow id="Flow_0pvp5mz" sourceRef="StartEvent_1" targetRef="Activity_17wwliq" />
|
|
<bpmn:sequenceFlow id="Flow_04qc4ur" sourceRef="Activity_17wwliq" targetRef="Event_0kj51tx" />
|
|
<bpmn:scriptTask id="Activity_17wwliq" name="Import tickets from csv inside backend" scriptFormat="python">
|
|
<bpmn:incoming>Flow_0pvp5mz</bpmn:incoming>
|
|
<bpmn:outgoing>Flow_04qc4ur</bpmn:outgoing>
|
|
<bpmn:script>"""Import tickets, for use in script task."""
|
|
|
|
|
|
def main():
|
|
"""Use main to avoid global namespace."""
|
|
import csv
|
|
|
|
from flask_bpmn.models.db import db
|
|
|
|
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
|
from spiffworkflow_backend.models.user import UserModel
|
|
from spiffworkflow_backend.services.process_instance_processor import (
|
|
ProcessInstanceProcessor,
|
|
)
|
|
from spiffworkflow_backend.services.process_instance_service import (
|
|
ProcessInstanceService,
|
|
)
|
|
from spiffworkflow_backend.models.process_instance_report import ProcessInstanceReportModel
|
|
|
|
process_model_identifier_ticket = "ticket"
|
|
db.session.query(ProcessInstanceModel).filter(
|
|
ProcessInstanceModel.process_model_identifier == process_model_identifier_ticket
|
|
).delete()
|
|
db.session.commit()
|
|
|
|
"""Print process instance count."""
|
|
process_instances = ProcessInstanceModel.query.filter_by(
|
|
process_model_identifier=process_model_identifier_ticket
|
|
).all()
|
|
process_instance_count = len(process_instances)
|
|
print(f"process_instance_count: {process_instance_count}")
|
|
|
|
columns_to_data_key_mappings = {
|
|
"Month": "month",
|
|
"MS": "milestone",
|
|
"Done?": "done",
|
|
"#": "notion_id",
|
|
"ID": "req_id",
|
|
"Dev Days": "dev_days",
|
|
"Feature": "feature",
|
|
"Feature description": "feature_description",
|
|
"Priority": "priority",
|
|
}
|
|
columns_to_header_index_mappings = {}
|
|
|
|
user = UserModel.query.first()
|
|
|
|
with open("tests/files/tickets.csv") as infile:
|
|
reader = csv.reader(infile, delimiter=",")
|
|
|
|
# first row is garbage
|
|
next(reader)
|
|
|
|
header = next(reader)
|
|
for column_name in columns_to_data_key_mappings:
|
|
columns_to_header_index_mappings[column_name] = header.index(column_name)
|
|
id_index = header.index("ID")
|
|
priority_index = header.index("Priority")
|
|
month_index = header.index("Month")
|
|
print(f"header: {header}")
|
|
for row in reader:
|
|
ticket_identifier = row[id_index]
|
|
priority = row[priority_index]
|
|
month = row[month_index]
|
|
print(f"ticket_identifier: {ticket_identifier}")
|
|
print(f"priority: {priority}")
|
|
# if there is no month, who cares about it.
|
|
if month:
|
|
process_instance = ProcessInstanceService.create_process_instance(
|
|
process_model_identifier=process_model_identifier_ticket,
|
|
user=user,
|
|
process_group_identifier="sartography-admin",
|
|
)
|
|
processor = ProcessInstanceProcessor(process_instance)
|
|
|
|
processor.do_engine_steps()
|
|
# processor.save()
|
|
|
|
for (
|
|
column_name,
|
|
desired_data_key,
|
|
) in columns_to_data_key_mappings.items():
|
|
appropriate_index = columns_to_header_index_mappings[column_name]
|
|
print(f"appropriate_index: {appropriate_index}")
|
|
processor.bpmn_process_instance.data[desired_data_key] = row[
|
|
appropriate_index
|
|
]
|
|
|
|
# you at least need a month, or else this row in the csv is considered garbage
|
|
month_value = processor.bpmn_process_instance.data["month"]
|
|
if month_value == "" or month_value is None:
|
|
db.delete(process_instance)
|
|
db.session.commit()
|
|
continue
|
|
|
|
processor.save()
|
|
|
|
process_instance_data = processor.get_data()
|
|
print(f"process_instance_data: {process_instance_data}")
|
|
|
|
ProcessInstanceReportModel.add_fixtures()
|
|
print("added report fixtures")
|
|
|
|
|
|
main()
|
|
|
|
# to avoid serialization issues
|
|
del main
|
|
</bpmn:script>
|
|
</bpmn:scriptTask>
|
|
</bpmn:process>
|
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_sartography_admin_import_tickets_import_tickets_bd2e724">
|
|
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
|
<dc:Bounds x="179" y="159" width="36" height="36" />
|
|
</bpmndi:BPMNShape>
|
|
<bpmndi:BPMNShape id="Event_0kj51tx_di" bpmnElement="Event_0kj51tx">
|
|
<dc:Bounds x="462" y="159" width="36" height="36" />
|
|
</bpmndi:BPMNShape>
|
|
<bpmndi:BPMNShape id="Activity_0lu5tuc_di" bpmnElement="Activity_17wwliq">
|
|
<dc:Bounds x="290" y="125" width="100" height="80" />
|
|
</bpmndi:BPMNShape>
|
|
<bpmndi:BPMNEdge id="Flow_0pvp5mz_di" bpmnElement="Flow_0pvp5mz">
|
|
<di:waypoint x="215" y="177" />
|
|
<di:waypoint x="253" y="177" />
|
|
<di:waypoint x="253" y="165" />
|
|
<di:waypoint x="290" y="165" />
|
|
</bpmndi:BPMNEdge>
|
|
<bpmndi:BPMNEdge id="Flow_04qc4ur_di" bpmnElement="Flow_04qc4ur">
|
|
<di:waypoint x="390" y="165" />
|
|
<di:waypoint x="426" y="165" />
|
|
<di:waypoint x="426" y="177" />
|
|
<di:waypoint x="462" y="177" />
|
|
</bpmndi:BPMNEdge>
|
|
</bpmndi:BPMNPlane>
|
|
</bpmndi:BPMNDiagram>
|
|
</bpmn:definitions>
|