Class: CPEE::Properties::Put

Inherits:
Riddl::Implementation
  • Object
show all
Defined in:
lib/cpee/implementation_properties.rb

Overview

}}}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.change_first(id, opts, doc) ⇒ Object

{{{



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
# File 'lib/cpee/implementation_properties.rb', line 191

def self::change_first(id,opts,doc)
  if (node = doc.find('/*/p:status')).any?
    CPEE::Properties::PutStatus::set id, opts, node.first.dump
  end
  if (node = doc.find('/*/p:executionhandler')).any?
    CPEE::Properties::PutExecutionHandler::set id, opts, node.first.text, false
  end

  %w{dataelements endpoints attributes}.each do |item|
    if (node = doc.find('/*/p:' + item)).any?
      CPEE::Properties::PutItems::set item, id, opts, node.first.dump
    end
  end

  if (node = doc.find('/*/p:transformation')).any?
    CPEE::Properties::PutTransformation::set id, opts, node.first.dump
  end
  if (node = doc.find('/*/p:description/*')).any?
    CPEE::Properties::PutDescription::set id, opts, node.first.dump
  end

  if (node = doc.find('/*/p:positions')).any?
    if node.first.find('p:*').any?
      CPEE::Properties::PutPositions::set id, opts, node.first.dump
    end
  end
  CPEE::Persistence::wait(opts)
end

.change_last(id, opts, doc) ⇒ Object



220
221
222
223
224
# File 'lib/cpee/implementation_properties.rb', line 220

def self::change_last(id,opts,doc)
  if (node = doc.find('/*/p:state')).any?
    CPEE::Properties::PutState::run id, opts, node.first.text
  end
end

Instance Method Details

#responseObject



226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/cpee/implementation_properties.rb', line 226

def response
  id = @a[0]
  opts = @a[1]
  if opts[:statemachine].readonly? id
    @status = 423
  elsif opts[:statemachine].final? id
    @status = 410
  else
    doc = XML::Smart::string(@p[0].value.read)
    doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
    CPEE::Properties::Put::change_first(id,opts,doc)
    CPEE::Properties::Put::change_last(id,opts,doc)
  end
end