class CPEE::Properties::Patch

Public Instance Methods

response() click to toggle source
# File lib/cpee/implementation_properties.rb, line 140
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