Class: OpenWFE::RawExpression

Inherits:
FlowExpression show all
Defined in:
lib/openwfe/expressions/raw.rb

Overview

A class storing bits (trees) of process definitions just parsed. Upon application (apply()) these raw expressions get turned into real expressions.

Defined Under Namespace

Classes: Parameter, Tag

Instance Attribute Summary

Attributes inherited from FlowExpression

#apply_time, #attributes, #children, #environment_id, #fei, #parent_id, #raw_representation

Attributes included from Contextual

#application_context

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FlowExpression

#cancel, #clean_children, #delete_variable, #dup_environment, #fetch_environment, #fetch_text_content, #get_binding, #get_environment, #get_parent, #get_root_environment, #has_attribute, #initialize, is_definition, is_definition?, #lookup_attribute, #lookup_attributes, #lookup_boolean_attribute, #lookup_comma_list_attribute, #lookup_downcase_attribute, #lookup_ref, #lookup_string_attribute, #lookup_sym_attribute, #lookup_value, #lookup_variable, #lookup_vf_attribute, names, #new_environment, new_exp, #owns_its_environment?, #paused?, #remove_child, #reply, #reply_to_parent, #set_variable, #store_itself, #synchronize, #to_s, #to_yaml_properties

Methods included from Contextual

#get_work_directory, #init_service, #lookup

Methods included from Logging

#ldebug, #ldebug_callstack, #lerror, #lfatal, #linfo, #llog, #lunknown, #lwarn

Methods included from OwfeServiceLocator

#get_engine, #get_error_journal, #get_expool, #get_expression_map, #get_expression_pool, #get_expression_storage, #get_expression_storages, #get_journal, #get_participant_map, #get_scheduler, #get_wfid_generator

Methods inherited from ObjectWithMeta

#class_def, meta_def, meta_eval, metaclass

Constructor Details

This class inherits a constructor from OpenWFE::FlowExpression

Class Method Details

.new_raw(fei, parent_id, env_id, app_context, raw_representation) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/openwfe/expressions/raw.rb', line 55

def self.new_raw (
    fei, parent_id, env_id, app_context, raw_representation)

    re = self.new

    re.fei = fei
    re.parent_id = parent_id
    re.environment_id = env_id
    re.application_context = app_context
    re.attributes = nil
    re.children = []
    re.apply_time = nil

    re.raw_representation = raw_representation
    re
end

Instance Method Details

#apply(workitem) ⇒ Object

When a raw expression is applied, it gets turned into the real expression which then gets applied.



127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/openwfe/expressions/raw.rb', line 127

def apply (workitem)

    exp_name, exp_class, attributes = determine_real_expression

    expression = instantiate_real_expression(
        workitem, exp_name, exp_class, attributes)

    expression.apply_time = Time.now
    expression.store_itself

    expression.apply workitem
end

#check_parameters(workitem) ⇒ Object

This method is called by the expression pool when it is about to launch a process, it will interpret the ‘parameter’ statements in the process definition and raise an exception if the requirements are not met.



146
147
148
149
150
151
# File 'lib/openwfe/expressions/raw.rb', line 146

def check_parameters (workitem)

    extract_parameters.each do |param|
        param.check(workitem)
    end
end

#definition_nameObject



169
170
171
172
# File 'lib/openwfe/expressions/raw.rb', line 169

def definition_name

    raw_representation[1]['name'].to_s
end

#expression_classObject



164
165
166
167
# File 'lib/openwfe/expressions/raw.rb', line 164

def expression_class

    get_expression_map.get_class(expression_name())
end

#expression_nameObject



174
175
176
177
# File 'lib/openwfe/expressions/raw.rb', line 174

def expression_name

    raw_representation.first
end

#extract_attributesObject

This method has been made public in order to have quick look at the attributes of an expression before it’s really ‘instantiated’.



194
195
196
197
# File 'lib/openwfe/expressions/raw.rb', line 194

def extract_attributes

    raw_representation[1]
end

#instantiate_real_expression(workitem, exp_name = nil, exp_class = nil, attributes = nil) ⇒ Object

– a duplication method that duplicates everything, except the application context

def dup

self.class.new_raw(
    @fei.dup,
    @parent_id ? @parent_id.dup : nil,
    @environment_id ? @environment_id.dup : nil,
    @application_context,
    raw_representation)

end alias :fulldup :dup ++



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/openwfe/expressions/raw.rb', line 87

def instantiate_real_expression (
    workitem, exp_name=nil, exp_class=nil, attributes=nil)

    exp_name ||= expression_name
    exp_class ||= expression_class

    raise "unknown expression '#{exp_name}'" \
        unless exp_class

    #ldebug do 
    #    "instantiate_real_expression() exp_class is #{exp_class}"
    #end

    attributes ||= raw_representation[1]

    exp = exp_class.new
    exp.fei = @fei 
    exp.parent_id = @parent_id
    exp.environment_id = @environment_id
    exp.application_context = @application_context
    exp.attributes = attributes

    exp.raw_representation = raw_representation
        #
        # keeping track of how the expression look at apply / 
        # instantiation time

    consider_tag workitem, exp
    
    handle_descriptions

    exp.children = extract_children

    exp
end

#is_definition?Boolean

– def reply (workitem) no implementation necessary end ++

Returns:

  • (Boolean)


159
160
161
162
# File 'lib/openwfe/expressions/raw.rb', line 159

def is_definition?

    get_expression_map.is_definition?(expression_name())
end

#load_attributesObject

Forces the raw expression to load the attributes and set them in its @attributes instance variable. Currently only used by FilterDefinitionExpression.



184
185
186
187
# File 'lib/openwfe/expressions/raw.rb', line 184

def load_attributes

    @attributes = raw_representation[1]
end