def generate_workflow_export(self, workflow_name, testscript, project, client, worksheet, row, column): #The number of rows in the workflow to be returned num_rows = 0 #Find the workflow self.cur.execute('select wf.id, wf.name from workflow wf left join testscript ts on ts.id = wf.testscriptid) left join project p on ts.projectid = p.id) left join client c on p.clientid = c.id where wf.name = %s and ts.name = %s and p.name = %s and c.name = %s order by w.id;' % (workflow_name, testscript, project, client)) flow = self.cur.fetchone() workflow = _Workflow() workflow.name = flow[1] workflow.id = flow[0] #Find the Key Actions for the workflow self.cur.execute('select ka.id, ka.name, ka.description, ka.custom, wfa.expectedresult, wfa.notes from ((workflowaction wfa left join keyaction ka on wfa.keyactionid = ka.id) left join workflow w on wfa.workflowid = w.id) where w.id = %s;' % (workflow[0])) keyactions = self.cur.fetchall() for action in keyactions: keyaction = _KeyAction() keyaction.id = action[0] keyaction.name = action[1] keyaction.description = action[2] if action[3] == 0: keyaction.custom = False else: keyaction.custom = True keyaction.expected_result = action[4] keyaction.notes = action[5] workflow.add_keyaction(keyaction) #Find the Input Parameters for the Key Action self.cur.execute('select ip.id, ip.name, wp.value from ((inputparameter ip left join keyaction ka on ip.keyactionid = ka.id) left join workflowparam wp on wp.inputparamid = ip.id) where ka.id = %s;' % (action[0])) inputparameters = self.cur.fetchall() for param in inputparameters: input_parameter = _InputParameter() input_parameter.id = param[0] input_parameter.name = param[1] input_parameter.value = param[2] keyaction.add_inputparameter(input_parameter) num_rows+=1 #TODO - Write the _Workflow object to the Excel Sheet self.execute_workflow_export(workflow, worksheet, row, column) return num_rows
def generate_workflow_export(self, workflow_id): #The number of rows in the workflow to be returned num_rows = 0 #Find the workflow self.cur.execute("select wf.id from workflow wf where wf.id = %s" % (workflow_id)) # self.cur.execute("select wf.id, wf.name from workflow wf left join testscript ts on ts.id = wf.testscriptid left join project p on ts.projectid = p.id left join client c on p.clientid = c.id where wf.name = '%s' and ts.name = '%s' and p.name = '%s' and c.name = '%s' order by wf.id;" % (workflow_name, testscript, project, client)) flow = self.cur.fetchone() workflow = _Workflow() workflow.name = flow[1] workflow.id = flow[0] print('Workflow %s created with ID %s' % (workflow.name, workflow.id)) #Find the Key Actions for the workflow self.cur.execute("select ka.id, ka.name, ka.description, ka.custom, wfa.expectedresult, wfa.notes from workflowaction wfa left join keyaction ka on wfa.keyactionid = ka.id left join workflow w on wfa.workflowid = w.id where w.id = '%s';" % (workflow.id)) keyactions = self.cur.fetchall() for action in keyactions: keyaction = _KeyAction() keyaction.id = action[0] keyaction.name = action[1] keyaction.description = action[2] if action[3] == 0: keyaction.custom = False else: keyaction.custom = True keyaction.expected_result = action[4] keyaction.notes = action[5] print('Key Action %s created' % (keyaction.name)) print('Description: %s' % (keyaction.description)) print('Custom: %s' % (keyaction.custom)) print('Expected Result: %s' % (keyaction.expected_result)) #Find the Next Actions for the Key Action self.cur.execute("select ka.id, ka.name, ka.description, ka.custom, wfa.expectedresult, wfa.notes from workflowaction wfa left join keyaction ka on wfa.keyactionid = ka.id where ka.id = %s;" % (action.id)) keyactions = self.cur.fetchall() for action in nextactions: ka = _KeyAction() ka.id = action[0] ka.name = action[1] ka.description = action[2] if action[3] == 0: ka.custom = False else: ka.custom = True ka.expected_result = action[4] ka.notes = action[5] print('Key Action %s created' % (ka.name)) print('Description: %s' % (ka.description)) print('Custom: %s' % (ka.custom)) print('Expected Result: %s' % (ka.expected_result)) keyaction.add_nextaction(ka) #Find the Input Parameters for the Key Action self.cur.execute('select ip.id, ip.name, wp.value from ((inputparameter ip left join keyaction ka on ip.keyactionid = ka.id) left join workflowparam wp on wp.inputparamid = ip.id) where ka.id = %s;' % (action[0])) inputparameters = self.cur.fetchall() if len(inputparameters) == 0: num_rows+=1 else: for param in inputparameters: input_parameter = _InputParameter() input_parameter.id = param[0] input_parameter.name = param[1] input_parameter.value = param[2] keyaction.add_inputparameter(input_parameter) print('Input Parameter %s added to keyaction %s' % (input_parameter.name, keyaction.name)) num_rows+=1 workflow.add_keyaction(keyaction) print('Key Action %s added to Workflow %s' % (keyaction.name, workflow.name)) #Write the _Workflow object to the Excel Sheet # self.execute_workflow_export(workflow, worksheet, row, column) return workflow
act.name = "AND" act2.name = "OR" act3.name="a" act4.name="b" act5.name="c" act6.name="d" act.add_nextaction(act2) act2.add_nextaction(act3) act.add_nextaction(act4) act5.add_nextaction(act6) act3.add_nextaction(act5) #Workflow Tests flow = _Workflow() flow.add_keyaction(act) flow.add_keyaction(act2) flow.add_keyaction(act3) flow.add_keyaction(act4) flow.add_keyaction(act5) flow.add_keyaction(act6) flow.build_keyactiontree() for tree in flow.keyactiontreelist: print(tree.root.data.id) for con in tree.root.connections: print(con.data.id) for connection in con.connections: print(connection.data.id) for c in connection.connections: