Class: CPEE::Properties::Patch

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

Overview

}}}

Instance Method Summary collapse

Instance Method Details

#responseObject

{{{



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/cpee/implementation_properties.rb', line 146

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::PatchItems::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::PatchPositions::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