>>> ar.activity['m2'] = MergeNode() >>> ar.activity['12'].target = ar.activity['m2'] >>> ar.activity['13'].target = ar.activity['d2'] >>> ar.activity['14'] = ActivityEdge(\ ... source=ar.activity['m2'],\ ... target=ar.activity['normal therapy']) >>> ar.activity['15'] = ActivityEdge(\ ... source=ar.activity['d2'],\ ... target=ar.activity['m2'],\ ... guard="patient.health < 90") >>> ar.activity['16'] = ActivityEdge( ... source=ar.activity['d2'],\ ... target=ar.activity['end'],\ ... guard="patient.health >= 90") >>> from activities.metamodel.elements import validate >>> validate(ar.activity) Our token state didn't change >>> ar.ts() 13: ... Going back to MergeNode "m2" >>> ar.next() >>> ar.ts() 15: ... >>> ar.next() >>> ar.ts() 14: ...
Import handler to register them. >>> from activities.transform.xmi import handler >>> import os >>> sourcepath = os.path.join(\ ... os.path.dirname(__file__),\ ... 'data', 'activities-testmodel.uml') >>> xml = transform.source(sourcepath) >>> xml <XMLNode object ...> >>> from agx.core import Processor >>> processor = Processor('xmi2act') >>> pkg = processor(xml, transform.target()) >>> from activities.metamodel.elements import validate >>> validate(pkg) >>> act = pkg.activities[0] >>> act <Activity...> >>> act.actions [<... 'action1' ... 'action2' ... 'action3' ...>] >>> act.nodes [<... 'action1' ... 'action2' ... 'action3' ... 'initial node' ... 'activity final node' ... 'flow final node' ... 'fork node' ... 'merge node' ... 'join node' ... 'decision node' ...>] >>> act.edges [<...'1' ...'2' ...'3' ...'7' ...'5' ...'10' ...'11' ...'6' ...'9' ...'8' ...'4' ...>]