Method: OpenWFE::Extras::Workitem.from_owfe_workitem

Defined in:
lib/openwfe/extras/participants/activeparticipants.rb

.from_owfe_workitem(wi, store_name = nil) ⇒ Object

Generates a (new) Workitem from an OpenWFEru InFlowWorkItem instance.

This is a ‘static’ method :

awi = OpenWFE::Extras::Workitem.from_owfe_workitem(wi)

(This method saves the ‘ActiveWorkitem’).


177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/openwfe/extras/participants/activeparticipants.rb', line 177

def Workitem.from_owfe_workitem (wi, store_name=nil)

    i = nil

    #MUTEX.synchronize do

    i = Workitem.new
    i.fei = wi.fei.to_s
    i.wfid = wi.fei.wfid
    i.wf_name = wi.fei.workflow_definition_name
    i.wf_revision = wi.fei.workflow_definition_revision
    i.participant_name = wi.participant_name
    i.dispatch_time = wi.dispatch_time
    i.last_modified = nil

    i.store_name = store_name

    i.save!
      # save workitem before adding any field
      # making sure it has an id...


    # This is a field set by the active participant immediately
    # before calling this method.
    # the default behavior is "use field method"

    if wi.attributes["compact_workitems"]

        wi.attributes.delete("compact_workitems")
        i.yattributes = wi.attributes

    else

        i.yattributes = nil

        wi.attributes.each do |k, v|
            i.fields << Field.new_field(k, v)
        end
    end

    i.save!
        # making sure to throw an exception in case of trouble
        #
        # damn, insert then update :(

    #end

    i
end