Class: CPEE::Worklist::TaskDel

Inherits:
Riddl::Implementation
  • Object
show all
Defined in:
lib/cpee-worklist/implementation.rb

Overview

}}}

Instance Method Summary collapse

Instance Method Details

#responseObject

{{{



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/cpee-worklist/implementation.rb', line 145

def response
  index = @a[0].activities.index{ |e| e["id"] == @r.last }
  if index
    activity = @a[0].activities[index]
    if activity['collected'] && (activity['collected'] + 1) < activity['collect_max']
      activity['collected'] += 1
      activity['restrictions'] << { "restriction" => { "mode" => "prohibit", "id" => @r[-3] } }
      @a[0].activities.serialize
      @a[0].notify('user/finish', :callback_id => activity['id'], :user => @r[-3], :role => activity['role'],:instance_uuid => activity['uuid'], :cpee_callback => activity['url'], :cpee_instance => activity['cpee_instance'], :cpee_base => activity['cpee_base'], :cpee_label => activity['label'], :cpee_activity => activity['cpee_activity_id'], :orgmodel => activity['orgmodel'])
    else
      activity = @a[0].activities.delete_at(index)
      @a[0].activities.serialize
      if @r.length == 3
        @a[0].notify('task/delete', :callback_id => activity['id'],                                             :instance_uuid => activity['uuid'], :cpee_callback => activity['url'], :cpee_instance => activity['cpee_instance'], :cpee_base => activity['cpee_base'], :cpee_label => activity['label'], :cpee_activity => activity['cpee_activity_id'], :orgmodel => activity['orgmodel'])
        Riddl::Client.new(activity['url']).put
      else
        info = CPEE::Worklist::User::info(@a[0].opts,activity,@r[-3])
        @a[0].notify('user/finish', :callback_id => activity['id'], :user => @r[-3], :role => activity['role'],:instance_uuid => activity['uuid'], :cpee_callback => activity['url'], :cpee_instance => activity['cpee_instance'], :cpee_base => activity['cpee_base'], :cpee_label => activity['label'], :cpee_activity => activity['cpee_activity_id'], :orgmodel => activity['orgmodel'])
      end
    end
  else
    @status = 404
  end
end