Class: CPEE::ModelManagement::PutItem
- Inherits:
-
Riddl::Implementation
- Object
- Riddl::Implementation
- CPEE::ModelManagement::PutItem
- Defined in:
- lib/cpee-model-management/implementation.rb
Overview
}}}
Instance Method Summary collapse
-
#response ⇒ Object
{{{.
Instance Method Details
#response ⇒ Object
{{{
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 |
# File 'lib/cpee-model-management/implementation.rb', line 576 def response where = @a[0] == :main ? '' : @r[0..-2].map{ |d| Riddl::Protocols::Utils::unescape(d) }.join('/') conns = @a[1] models = @a[2] name = File.basename(@r.last,'.xml') cont = @p[0].value.read dn = CPEE::ModelManagement::get_dn @h['DN'] fname = File.join(models,where,name + '.xml') p fname if File.exist?(fname) = dn['GN'] + ' ' + dn['SN'] attrs = {} XML::Smart.string(cont) do |doc| doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0' doc.find('/p:testset/p:attributes/p:author').each do |ele| ele.text = dn['GN'] + ' ' + dn['SN'] end if doc.find('/p:testset/p:attributes/p:design_stage').empty? doc.find('/p:testset/p:attributes').first.add('p:design_stage','draft') else doc.find('/p:testset/p:attributes/p:design_stage').each do |ele| ele.text = 'draft' if ele.text.strip == '' end end attrs = doc.find('/p:testset/p:attributes/*').map do |e| [e.qname.name,e.text] end.to_h File.write(fname,doc.to_s) end File.write(fname + '.attrs',JSON::pretty_generate(attrs)) CPEE::ModelManagement::op , 'add', models, File.join('.', where, name + '.xml') CPEE::ModelManagement::notify conns, 'put', models, fname else @status = 400 end end |