Book a Demo

Author Topic: Generating code from a state machine  (Read 2019 times)

luga

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Generating code from a state machine
« on: September 22, 2007, 10:41:48 pm »
Hi.
I intend to generate code from the state machine associated to a class.
Indeed I need to transform the state transition diagram representing a workflow process into an xml file for JBPM that would look like this:
<?xml version="1.0" encoding="UTF-8"?>
<process-definition name='depot'>
   <start-state>
     <transition to='examensommaire' />
    </start-state>
   
   <state name='examensommaire'>
      <transition name='accepte' to='acceptedepot'  />
      <transition name='refuse'  to='refusdepot' />      
    </state>
   
    <state name='acceptedepot'>
       <transition to='findepot' />
    </state>
   
    <state name='refusdepot'>
          <transition to='findepot' />
    </state>
   
    <end-state name='findepot' />
</process-definition>

OPTION A: I started this through creation of a new language JPDL and try to hook the element with element type equal to State or StateNode. Either they are not browsed within the main loop of the language code generator either i missed wher e I can tackle state and connectors linking them.

OPTION B: I checked the mysql repository and build a SQL Query that collate proper information.

         select distinct
CASE tob.nType when 3 then 1 when 4 then 3 else 2 end as 'Index'
       ,CASE tob.nType when 3 then "1 start-state" when 4 then '3 end-state' else "2 state" end as 'NodeType'
, tob.object_ID as 'from'
, tob.name as source
               , tco.Name   as transition
               , tco.end_object_id as 'to'
, tib.name as destination
       from
t_object tob,
t_connector tco,
t_object tib
 where
(tob.Object_Type="StateNode" or tob.Object_Type="State")
and tco.End_Object_ID=tib.Object_ID
order by NODETYPE, 'from' asc;
My intention is then to call a stored procedure that will use a cursor based on that query and build proper piece of code. In this B option is there any way to call from tools the mysql command ans pass as parameter the StateMachine containing nodes and transitions?

Any help appreciated.
Regards.