Exemplo n.º 1
0
    def __init__(self):
        super(ASmallWorkflow, self).__init__(name="asmallworkflow")

        multichoice = MultiChoice(self, 'multi_choice_1')
        self.start.connect(multichoice)

        a1 = Simple(self, 'task_a1')
        multichoice.connect(a1)

        a2 = Simple(self, 'task_a2')
        cond = Equal(Attrib('test_attribute1'), Attrib('test_attribute2'))
        multichoice.connect_if(cond, a2)

        syncmerge = Join(self, 'struct_synch_merge_1', 'multi_choice_1')
        a1.connect(syncmerge)
        a2.connect(syncmerge)

        end = Simple(self, 'End')
        syncmerge.connect(end)
    def __init__(self):
        super(ASmallWorkflow, self).__init__(name="asmallworkflow")

        multichoice = MultiChoice(self, 'multi_choice_1')
        self.start.connect(multichoice)

        a1 = Simple(self, 'task_a1')
        multichoice.connect(a1)

        a2 = Simple(self, 'task_a2')
        cond = Equal(Attrib('test_attribute1'), PathAttrib('test/attribute2'))
        multichoice.connect_if(cond, a2)

        syncmerge = Join(self, 'struct_synch_merge_1', 'multi_choice_1')
        a1.connect(syncmerge)
        a2.connect(syncmerge)

        end = Simple(self, 'End')
        syncmerge.connect(end)
    def _createWorkflowSpec(self):
        wf_spec = WorkflowSpec()
        # Build one branch.
        a1 = Simple(wf_spec, 'task_a1')
        wf_spec.start.connect(a1)

        a2 = Simple(wf_spec, 'task_a2')
        a1.connect(a2)

        # Build another branch.
        b1 = Simple(wf_spec, 'task_b1')
        wf_spec.start.connect(b1)

        b2 = Simple(wf_spec, 'task_b2')
        b1.connect(b2)

        # Merge both branches (synchronized).
        synch_1 = Join(wf_spec, 'synch_1')
        a2.connect(synch_1)
        b2.connect(synch_1)

        # If-condition that does not match.
        excl_choice_1 = ExclusiveChoice(wf_spec, 'excl_choice_1')
        synch_1.connect(excl_choice_1)

        c1 = Simple(wf_spec, 'task_c1')
        excl_choice_1.connect(c1)

        c2 = Simple(wf_spec, 'task_c2')
        cond = Equal(Attrib('test_attribute1'), Attrib('test_attribute2'))
        excl_choice_1.connect_if(cond, c2)

        c3 = Simple(wf_spec, 'task_c3')
        excl_choice_1.connect_if(cond, c3)

        # If-condition that matches.
        excl_choice_2 = ExclusiveChoice(wf_spec, 'excl_choice_2')
        c1.connect(excl_choice_2)
        c2.connect(excl_choice_2)
        c3.connect(excl_choice_2)

        d1 = Simple(wf_spec, 'task_d1')
        excl_choice_2.connect(d1)

        d2 = Simple(wf_spec, 'task_d2')
        excl_choice_2.connect_if(cond, d2)

        d3 = Simple(wf_spec, 'task_d3')
        cond = Equal(Attrib('test_attribute1'), Attrib('test_attribute1'))
        excl_choice_2.connect_if(cond, d3)

        # If-condition that does not match.
        multichoice = MultiChoice(wf_spec, 'multi_choice_1')
        d1.connect(multichoice)
        d2.connect(multichoice)
        d3.connect(multichoice)

        e1 = Simple(wf_spec, 'task_e1')
        multichoice.connect_if(cond, e1)

        e2 = Simple(wf_spec, 'task_e2')
        cond = Equal(Attrib('test_attribute1'), Attrib('test_attribute2'))
        multichoice.connect_if(cond, e2)

        e3 = Simple(wf_spec, 'task_e3')
        cond = Equal(Attrib('test_attribute2'), Attrib('test_attribute2'))
        multichoice.connect_if(cond, e3)

        # StructuredSynchronizingMerge
        syncmerge = Join(wf_spec, 'struct_synch_merge_1', 'multi_choice_1')
        e1.connect(syncmerge)
        e2.connect(syncmerge)
        e3.connect(syncmerge)

        # Implicit parallel split.
        f1 = Simple(wf_spec, 'task_f1')
        syncmerge.connect(f1)

        f2 = Simple(wf_spec, 'task_f2')
        syncmerge.connect(f2)

        f3 = Simple(wf_spec, 'task_f3')
        syncmerge.connect(f3)

        # Discriminator
        discrim_1 = Join(wf_spec,
                         'struct_discriminator_1',
                         'struct_synch_merge_1',
                         threshold = 1)
        f1.connect(discrim_1)
        f2.connect(discrim_1)
        f3.connect(discrim_1)

        # Loop back to the first exclusive choice.
        excl_choice_3 = ExclusiveChoice(wf_spec, 'excl_choice_3')
        discrim_1.connect(excl_choice_3)
        cond = NotEqual(Attrib('excl_choice_3_reached'), Attrib('two'))
        excl_choice_3.connect_if(cond, excl_choice_1)

        # Split into 3 branches, and implicitly split twice in addition.
        multi_instance_1 = MultiInstance(wf_spec, 'multi_instance_1', times = 3)
        excl_choice_3.connect(multi_instance_1)

        # Parallel tasks.
        g1 = Simple(wf_spec, 'task_g1')
        g2 = Simple(wf_spec, 'task_g2')
        multi_instance_1.connect(g1)
        multi_instance_1.connect(g2)

        # StructuredSynchronizingMerge
        syncmerge2 = Join(wf_spec, 'struct_synch_merge_2', 'multi_instance_1')
        g1.connect(syncmerge2)
        g2.connect(syncmerge2)

        # Add a final task.
        last = Simple(wf_spec, 'last')
        syncmerge2.connect(last)

        # Add another final task :-).
        end = Simple(wf_spec, 'End')
        last.connect(end)
        return wf_spec
Exemplo n.º 4
0
    def _createWorkflowSpec(self):
        wf_spec = WorkflowSpec()
        # Build one branch.
        a1 = Simple(wf_spec, 'task_a1')
        wf_spec.start.connect(a1)

        a2 = Simple(wf_spec, 'task_a2')
        a1.connect(a2)

        # Build another branch.
        b1 = Simple(wf_spec, 'task_b1')
        wf_spec.start.connect(b1)

        b2 = Simple(wf_spec, 'task_b2')
        b1.connect(b2)

        # Merge both branches (synchronized).
        synch_1 = Join(wf_spec, 'synch_1')
        a2.connect(synch_1)
        b2.connect(synch_1)

        # If-condition that does not match.
        excl_choice_1 = ExclusiveChoice(wf_spec, 'excl_choice_1')
        synch_1.connect(excl_choice_1)

        c1 = Simple(wf_spec, 'task_c1')
        excl_choice_1.connect(c1)

        c2 = Simple(wf_spec, 'task_c2')
        cond = Equal(Attrib('test_attribute1'), Attrib('test_attribute2'))
        excl_choice_1.connect_if(cond, c2)

        c3 = Simple(wf_spec, 'task_c3')
        excl_choice_1.connect_if(cond, c3)

        # If-condition that matches.
        excl_choice_2 = ExclusiveChoice(wf_spec, 'excl_choice_2')
        c1.connect(excl_choice_2)
        c2.connect(excl_choice_2)
        c3.connect(excl_choice_2)

        d1 = Simple(wf_spec, 'task_d1')
        excl_choice_2.connect(d1)

        d2 = Simple(wf_spec, 'task_d2')
        excl_choice_2.connect_if(cond, d2)

        d3 = Simple(wf_spec, 'task_d3')
        cond = Equal(Attrib('test_attribute1'), Attrib('test_attribute1'))
        excl_choice_2.connect_if(cond, d3)

        # If-condition that does not match.
        multichoice = MultiChoice(wf_spec, 'multi_choice_1')
        d1.connect(multichoice)
        d2.connect(multichoice)
        d3.connect(multichoice)

        e1 = Simple(wf_spec, 'task_e1')
        multichoice.connect_if(cond, e1)

        e2 = Simple(wf_spec, 'task_e2')
        cond = Equal(Attrib('test_attribute1'), Attrib('test_attribute2'))
        multichoice.connect_if(cond, e2)

        e3 = Simple(wf_spec, 'task_e3')
        cond = Equal(Attrib('test_attribute2'), Attrib('test_attribute2'))
        multichoice.connect_if(cond, e3)

        # StructuredSynchronizingMerge
        syncmerge = Join(wf_spec, 'struct_synch_merge_1', 'multi_choice_1')
        e1.connect(syncmerge)
        e2.connect(syncmerge)
        e3.connect(syncmerge)

        # Implicit parallel split.
        f1 = Simple(wf_spec, 'task_f1')
        syncmerge.connect(f1)

        f2 = Simple(wf_spec, 'task_f2')
        syncmerge.connect(f2)

        f3 = Simple(wf_spec, 'task_f3')
        syncmerge.connect(f3)

        # Discriminator
        discrim_1 = Join(wf_spec,
                         'struct_discriminator_1',
                         'struct_synch_merge_1',
                         threshold=1)
        f1.connect(discrim_1)
        f2.connect(discrim_1)
        f3.connect(discrim_1)

        # Loop back to the first exclusive choice.
        excl_choice_3 = ExclusiveChoice(wf_spec, 'excl_choice_3')
        discrim_1.connect(excl_choice_3)
        cond = NotEqual(Attrib('excl_choice_3_reached'), Attrib('two'))
        excl_choice_3.connect_if(cond, excl_choice_1)

        # Split into 3 branches, and implicitly split twice in addition.
        multi_instance_1 = MultiInstance(wf_spec, 'multi_instance_1', times=3)
        excl_choice_3.connect(multi_instance_1)

        # Parallel tasks.
        g1 = Simple(wf_spec, 'task_g1')
        g2 = Simple(wf_spec, 'task_g2')
        multi_instance_1.connect(g1)
        multi_instance_1.connect(g2)

        # StructuredSynchronizingMerge
        syncmerge2 = Join(wf_spec, 'struct_synch_merge_2', 'multi_instance_1')
        g1.connect(syncmerge2)
        g2.connect(syncmerge2)

        # Add a final task.
        last = Simple(wf_spec, 'last')
        syncmerge2.connect(last)

        # Add another final task :-).
        end = Simple(wf_spec, 'End')
        last.connect(end)
        return wf_spec