# #-- # Copyright (c) 2006-2007, Nicolas Modryzk and John Mettraux, OpenWFE.org # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # . Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # # . Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # . Neither the name of the "OpenWFE" nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. #++ # # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $ # # # "made in Japan" # # Nicolas Modrzyk at openwfe.org # John Mettraux at openwfe.org # #require 'find' require 'openwfe/utils' require 'openwfe/rudefinitions' require 'openwfe/storage/yamlfilestorage' require 'openwfe/expressions/flowexpression' require 'openwfe/expressions/raw_xml' # # making sure classes in those files are loaded # before their yaml persistence is tuned # (else the reopening of the class is interpreted as # a definition of the class...) module OpenWFE # # reopening some classes in order to facilitate their # yaml serialization # # opening for tuning yaml persistence # class FlowExpression def to_yaml_properties l = super() l.delete("@application_context") return l end end # opening for tuning yaml persistence # class XmlRawExpression def to_yaml_properties l = super() l.delete("@raw_representation") return l end end # # yaml expression storage # class YamlFileExpressionStorage < YamlFileStorage include OwfeServiceLocator def initialize (service_name, application_context) path = if (@application_context) @application_context[:file_expression_storage_path] else DEFAULT_FILE_STORAGE_PATH end super(service_name, application_context, path + "/expool") end # # Iterates on each expression that is of the given kind. # Used for example by the expression pool when rescheduling. # def each_of_kind (kind, &block) return unless block exp_names = get_expression_map.get_expression_names(kind) #require 'pp' #pp exp_names each_object_path do |path| #ldebug { "each_of_kind() path is #{path}" } next unless matches(path, exp_names) expression = load_object(path) expression.application_context = @application_context block.call expression end end def to_s s = "\n\n==== #{self.class} ====" s << "\n" each_expression_path do |path| s << path s << "\n" end s << "==== . ====\n" return s end protected def compute_file_path (fei) return @basepath + "/engine_environment.yaml" \ if fei.workflow_instance_id == "0" wfid = fei.parent_workflow_instance_id @basepath + "/" + wfid[-1, 1] + "/" + wfid[-2, 1] + "/" + wfid + "/" + fei.workflow_instance_id + "__" + fei.expression_id + "_" + fei.expression_name + ".yaml" end def matches (path, exp_names) exp_names.each do |exp_name| return true \ if OpenWFE::ends_with(path, "_#{exp_name}.yaml") end return false end end end