app/models/wf/workflow.rb
# TODO: can from start place to end place
# todo: remove color hex to const.
can from start place to end place
todo: remove color hex to const.
can from start place to end place todo : remove color hex to const .
def do_validate!
      msgs = []
      start_place = places.start.first
      end_place   = places.end.first
      msgs << "must have start place" if start_place.blank?
      msgs << "must have only one start place" if places.start.count > 1
      msgs << "must have end place" if end_place.blank?
      msgs << "must have only one end place" if places.end.count > 1
      msgs << "must not have discrete transition" if transitions.any? { |t| !t.arcs.in.exists? }
      if start_place && end_place
        rgl = to_rgl
        places.each do |p|
          msgs << "start place can not reach #{p.name}" unless rgl.path?(start_place.to_gid.to_s, p.to_gid.to_s)
          msgs << "#{p.name} can not reach end_place" unless rgl.path?(p.to_gid.to_s, end_place.to_gid.to_s)
        end
        transitions.each do |t|
          msgs << "start place can not reach #{t.name}" unless rgl.path?(start_place.to_gid.to_s, t.to_gid.to_s)
          msgs << "#{t.name} can not reach end_place" unless rgl.path?(t.to_gid.to_s, end_place.to_gid.to_s)
        end
      end
      if Wf.use_lola
        msgs << "has deadlock" if to_lola.deadlock?
        msgs << "has dead transition" unless to_lola.quasiliveness?
        msgs << "can not reach to the end place" unless to_lola.reachability_of_final_marking?
      end
      if msgs.present?
        update_columns(is_valid: false, error_msg: msgs.join("\n"))
      else
        update_columns(is_valid: true, error_msg: "")
      end
    end
def do_validate! msgs = [ ] start_place = places . start . first end_place = places . end . first msgs << "must have start place" if start_place . blank? msgs << "must have only one start place" if places . start . count > 1 msgs << "must have end place" if end_place . blank? msgs << "must have only one end place" if places . end . count > 1 msgs << "must not have discrete transition" if transitions . any? { | t | ! t . arcs . in . exists? } if start_place && end_place rgl = to_rgl places . each do | p | msgs << "start place can not reach #{p.name}" unless rgl . path? ( start_place . to_gid . to_s , p . to_gid . to_s ) msgs << "#{p.name} can not reach end_place" unless rgl . path? ( p . to_gid . to_s , end_place . to_gid . to_s ) end transitions . each do | t | msgs << "start place can not reach #{t.name}" unless rgl . path? ( start_place . to_gid . to_s , t . to_gid . to_s ) msgs << "#{t.name} can not reach end_place" unless rgl . path? ( t . to_gid . to_s , end_place . to_gid . to_s ) end end if Wf . use_lola msgs << "has deadlock" if to_lola . deadlock? msgs << "has dead transition" unless to_lola . quasiliveness? msgs << "can not reach to the end place" unless to_lola . reachability_of_final_marking? end if msgs . present? update_columns ( is_valid : false , error_msg : msgs . join ( "\n" ) ) else update_columns ( is_valid : true , error_msg : "" ) end end
TODO: can from start place to end place
todo: remove color hex to const.
TODO : can from start place to end place todo : remove color hex to const .