Class: CPEE::Properties::Get

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

Overview

{{{

Instance Method Summary collapse

Instance Method Details

#responseObject



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/cpee/implementation_properties.rb', line 103

def response
  id = @a[0]
  opts = @a[1]
  doc = XML::Smart::open_unprotected(opts[:properties_empty])
  doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
  doc.find('/p:properties/p:state').first.text = CPEE::Persistence::extract_item(id,opts,'state')
  doc.find('/p:properties/p:state/@changed').first.value = CPEE::Persistence::extract_item(id,opts,'state/@changed')
  doc.find('/p:properties/p:status/p:id').first.text = CPEE::Persistence::extract_item(id,opts,'status/id')
  doc.find('/p:properties/p:status/p:message').first.text = CPEE::Persistence::extract_item(id,opts,'status/message')
  doc.find('/p:properties/p:executionhandler').first.text = CPEE::Persistence::extract_item(id,opts,'executionhandler')
  %w{dataelements endpoints attributes}.each do |item|
    des = doc.find("/p:properties/p:#{item}").first
    CPEE::Persistence::extract_list(id,opts,item).each{ |de| des.add(*de) }
  end
  des = doc.find("/p:properties/p:positions").first
  CPEE::Persistence::extract_set(id,opts,'positions').each do |de|
    node = des.add(*de)
    if pt = CPEE::Persistence::extract_item(id,opts,File.join('positions',de[0],'@passthrough'))
      node.attributes['passthrough'] = pt
    end
  end
  doc.find('/p:properties/p:dsl').first.text = CPEE::Persistence::extract_item(id,opts,'dsl')
  if val = CPEE::Persistence::extract_item(id,opts,'dslx') #{{{
    doc.find('/p:properties/p:dslx').first.add XML::Smart::string(val).root rescue nil
  end #}}}
  if val = CPEE::Persistence::extract_item(id,opts,'description') #{{{
    d = XML::Smart::string(val).root rescue nil
    if d.nil?
      doc.find('/p:properties/p:description').first.text = val
    else
      doc.find('/p:properties/p:description').first.add d
    end
  end #}}}
  doc.find('/p:properties/p:transformation/p:description').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/description')
  doc.find('/p:properties/p:transformation/p:dataelements').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/dataelements')
  doc.find('/p:properties/p:transformation/p:endpoints').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/endpoints')
  doc.find('/p:properties/p:transformation/p:description/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/description/@type')
  doc.find('/p:properties/p:transformation/p:dataelements/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/dataelements/@type')
  doc.find('/p:properties/p:transformation/p:endpoints/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/endpoints/@type')
  Riddl::Parameter::Complex.new('properties','application/xml',doc.to_s)
end