Method: OpenWFE::Engine#lookup_processes

Defined in:
lib/openwfe/engine/engine.rb

#lookup_processes(var_name, value = nil) ⇒ Object

Returns an array of wfid (workflow instance ids) whose root environment containes the given variable

If there are no matches, an empty array will be returned.

Regular expressions are accepted as values.

If no value is given, all processes with the given variable name set will be returned.



715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
# File 'lib/openwfe/engine/engine.rb', line 715

def lookup_processes (var_name, value=nil)

    # TODO : maybe this would be better in the ExpressionPool

    regexp = if value
        if value.is_a?(Regexp)
            value
        else
            Regexp.compile(value.to_s)
        end
    else
        nil
    end

    envs = get_expression_storage.find_expressions(
        :include_classes => Environment)

    envs = envs.find_all do |env|
        val = env.variables[var_name]
        (val and ((not regexp) or (regexp.match(val))))
    end
    envs.collect do |env|
        env.fei.wfid
    end

    #envs.inject([]) do |r, env|
    #    val = env.variables[var_name]
    #    r << env.fei.wfid      #        if (val and ((not regexp) or (regexp.match(val))))
    #    r
    #end
        #
        # seems slower...
end