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

{{{



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/cpee/implementation_properties.rb', line 120

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