Class: CPEE::Properties::Put

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

Overview

}}}

Instance Method Summary collapse

Instance Method Details

#responseObject

{{{



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/cpee/implementation_properties.rb', line 187

def response
  id = @a[0]
  opts = @a[1]
  if opts[:statemachine].readonly? id
    @status = 400
  else
    doc = XML::Smart::string(@p[0].value.read)
    doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
    if (node = doc.find('/p:properties/p:status')).any?
      CPEE::Properties::PutStatus::set id, opts, node.first.dump
    end
    if (node = doc.find('/p:properties/p:executionhandler')).any?
      CPEE::Properties::PutExecutionHandler::set id, opts, node.first.text
    end

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

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

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

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