Module containing the main parsing code.

Design notes for the parsing of a procedure map with logic gates are here.

 3 module PARSE

Method to parse a route.

We pass in the ID of the route to be parsed.

 7   def parse_route_with_id( route_id )

A route being parsed as one of the set of routes originating from a start step may have already been parsed, because a route subsequent to one of the routes from that start step may have that start step as its target. We want to parse a route only if it has not already been parsed.

Unless this route has been parsed ...

 11     unless route_parsed_attribute( route_id ) == true

... we increment the parse pass count for this route, ...

 14       parse_pass_count = route_parse_pass_count_attribute( route_id ) + 1

... we update the route hash with that count ...

 17       update_route_hash( route_id, nil, nil, nil, nil, parse_pass_count )

... and increment the total parse pass count.

 20       @parse_pass_count += 1

The route and its attributes are logged.

 23       @parse_log << "Parsing route from #{route_source_step_name( route_id )} (#{route_source_step_type( route_id )}) to #{route_target_step_name( route_id )} (#{route_target_step_type( route_id )}) [#{@parse_pass_count}/#{@route_count}]."

We parse the route according to the type of the source step.

For each parse method we pass the ID of the route to be parsed.

 27       case route_source_step_type( route_id )
 28       when "Business step"
 29         parse_route_from_business_step( route_id )
 30       when "Decision"
 31         parse_route_from_decision_step( route_id )
 32       when "NOT"
 33         parse_route_from_not_step( route_id )
 34       when "AND"
 35         parse_route_from_and_step( route_id )
 36       when "OR"
 37         parse_route_from_or_step( route_id )
 38       when "SUM"
 39         parse_route_from_sum_step( route_id )
 40       when "INCREMENT"
 41         parse_route_from_increment_step( route_id )
 42       when "EQUALS"
 43         parse_route_from_equals_step( route_id )
 44       when "SUMMATION"
 45         parse_route_from_summation_step( route_id )
 46       end

We check the currency of the route.

Regardless of the type of the source step of the route we know that some routes are not current.

 50       parse_route_currency( route_id )

We assign the potential state of any target business step.

 53       assign_potential_business_step_state( route_id )

We continue to traverse the graph by following outbound routes from the target step of this route.

This forces a depth first traversal of the procedure.

If the target step of the route we're parsing has outbound routes ...

 58       if step_outbound_routes( route_target_step_id( route_id ) )

... for each outbound route from the target step of the route ...

 61         step_outbound_routes( route_target_step_id( route_id ) ).each do |outbound_route_id|

... unless that route has already been parsed ...

 64           unless route_parsed_attribute( outbound_route_id ) == true

... we parse the route.

 67             parse_route_with_id( outbound_route_id )
 68           end
 69         end
 70       end
 71     end
 72   end
 73 end