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

{{{



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/cpee/implementation_properties.rb', line 161

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:handlerwrapper')).any?
      CPEE::Properties::PutHandlerWrapper::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