cpee 1.3.129 → 1.3.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/cpee.gemspec +1 -1
- data/lib/cpee/processtransformation/bpel/Repository/booking.bpel +125 -0
- data/lib/cpee/processtransformation/bpel/Repository/booking.wsdl +72 -0
- data/lib/cpee/processtransformation/bpel/Repository/booking/airline.wsdl +71 -0
- data/lib/cpee/processtransformation/bpel/Repository/booking/hotel.wsdl +64 -0
- data/lib/cpee/processtransformation/bpel/Repository/booking/report.wsdl +71 -0
- data/lib/cpee/processtransformation/bpel/bpel2wee.rb +34 -0
- data/lib/cpee/processtransformation/bpel/bpelserver.ru +64 -0
- data/lib/cpee/processtransformation/bpel/bpelserver.xml +70 -0
- data/lib/cpee/processtransformation/bpel/lib/BPEL_Transform.rb +367 -0
- data/lib/cpee/processtransformation/bpmn2.rb +273 -0
- data/lib/cpee/processtransformation/cpee.rb +118 -0
- data/lib/cpee/processtransformation/structures.rb +426 -0
- data/server/instances/1/properties.xml +101 -69
- data/server/instances/10/properties.xml +109 -0
- data/server/instances/11/properties.xml +109 -0
- data/server/instances/2/properties.xml +44 -191
- data/server/instances/3/properties.xml +44 -70
- data/server/instances/4/properties.xml +68 -28
- data/server/instances/5/properties.xml +70 -10
- data/server/instances/6/properties.xml +55 -175
- data/server/instances/7/properties.xml +83 -0
- data/server/instances/8/properties.xml +83 -0
- data/server/instances/9/properties.xml +77 -0
- metadata +111 -111
- data/server/instances/1/notifications/d12eff1ac812661c05d7090ce7394cf9/consumer-secret +0 -1
- data/server/instances/1/notifications/d12eff1ac812661c05d7090ce7394cf9/producer-secret +0 -1
- data/server/instances/1/notifications/d12eff1ac812661c05d7090ce7394cf9/subscription.xml +0 -27
- data/server/instances/6/notifications/5c8c36c3dfcec8e36c3b25859a71778c/consumer-secret +0 -1
- data/server/instances/6/notifications/5c8c36c3dfcec8e36c3b25859a71778c/producer-secret +0 -1
- data/server/instances/6/notifications/5c8c36c3dfcec8e36c3b25859a71778c/subscription.xml +0 -27
- data/server/server.pid +0 -1
| @@ -0,0 +1,64 @@ | |
| 1 | 
            +
            #\ -p 9298
         | 
| 2 | 
            +
            $url  = 'http://localhost:9298'
         | 
| 3 | 
            +
            $mode = :debug # :production
         | 
| 4 | 
            +
            $0 = "cpee"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            use Rack::ShowStatus
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            require 'pp'
         | 
| 9 | 
            +
            require 'fileutils'
         | 
| 10 | 
            +
            require '../../../riddl/lib/ruby/server'
         | 
| 11 | 
            +
            require '../../../riddl/lib/ruby/client'
         | 
| 12 | 
            +
            require '../../../riddl/lib/ruby/utils/notifications_producer'
         | 
| 13 | 
            +
            require '../../../riddl/lib/ruby/utils/properties'
         | 
| 14 | 
            +
            require '../../../riddl/lib/ruby/utils/fileserve'
         | 
| 15 | 
            +
            require '../../../riddl/lib/ruby/utils/declaration'
         | 
| 16 | 
            +
            require './engine/implementation'
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            run Riddl::Server.new(::File.dirname(__FILE__) + '/declaration.xml') {
         | 
| 19 | 
            +
              accessible_description true
         | 
| 20 | 
            +
              cross_site_xhr true
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              a_schema, a_strans = Riddl::Utils::Properties::schema(::File.dirname(__FILE__) + '/instances/properties.schema.active')
         | 
| 23 | 
            +
              i_schema, i_strans = Riddl::Utils::Properties::schema(::File.dirname(__FILE__) + '/instances/properties.schema.inactive')
         | 
| 24 | 
            +
              f_schema, f_strans = Riddl::Utils::Properties::schema(::File.dirname(__FILE__) + '/instances/properties.schema.finished')
         | 
| 25 | 
            +
              xsls = {
         | 
| 26 | 
            +
                :overview => '/xsls/overview.xsl',
         | 
| 27 | 
            +
                :subscriptions => '/xsls/subscriptions.xsl'
         | 
| 28 | 
            +
              }
         | 
| 29 | 
            +
              
         | 
| 30 | 
            +
              on resource do
         | 
| 31 | 
            +
                run Riddl::Utils::Declaration::Description, description_string if get 'riddl-description-request'
         | 
| 32 | 
            +
                run Instances if get '*'
         | 
| 33 | 
            +
                run NewInstance, $url if post 'instance-name'
         | 
| 34 | 
            +
                on resource do
         | 
| 35 | 
            +
                  run Info if get
         | 
| 36 | 
            +
                  run DeleteInstance if delete
         | 
| 37 | 
            +
                  on resource 'properties' do |r|
         | 
| 38 | 
            +
                    instance       = ::File.dirname(__FILE__) + '/instances/' + r[:r][0] + '/'
         | 
| 39 | 
            +
                    properties     = Riddl::Utils::Properties::file(instance + 'properties.xml')
         | 
| 40 | 
            +
                    schema, strans = case $controller[r[:r][0].to_i].state
         | 
| 41 | 
            +
                      when :ready, :stopped; [i_schema,i_strans]
         | 
| 42 | 
            +
                      when :running, :stopping; [a_schema,a_strans]
         | 
| 43 | 
            +
                      when :finished; [f_schema,f_strans]
         | 
| 44 | 
            +
                    end
         | 
| 45 | 
            +
                    use Riddl::Utils::Properties::implementation(properties, schema, strans, PropertiesHandler, r[:match].count, $mode)
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
                  on resource 'notifications' do |r|
         | 
| 48 | 
            +
                    ndir = ::File.dirname(__FILE__) + '/instances/' + r[:r][0] + '/notifications/'
         | 
| 49 | 
            +
                    use Riddl::Utils::Notifications::Producer::implementation(ndir,xsls, NotificationsHandler, $mode)
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
                  on resource 'callbacks' do
         | 
| 52 | 
            +
                    run Callbacks, $mode if get
         | 
| 53 | 
            +
                    on resource do
         | 
| 54 | 
            +
                      run ExCallback if get || put || post || delete
         | 
| 55 | 
            +
                    end  
         | 
| 56 | 
            +
                  end  
         | 
| 57 | 
            +
                end  
         | 
| 58 | 
            +
                on resource 'xsls' do
         | 
| 59 | 
            +
                  on resource do
         | 
| 60 | 
            +
                    run Riddl::Utils::FileServe, "xsls" if get
         | 
| 61 | 
            +
                  end  
         | 
| 62 | 
            +
                end  
         | 
| 63 | 
            +
              end
         | 
| 64 | 
            +
            }
         | 
| @@ -0,0 +1,70 @@ | |
| 1 | 
            +
            <description datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" xmlns="http://riddl.org/ns/description/1.0" xmlns:xi="http://www.w3.org/2001/XInclude">
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              <message name="list-of-workflow-instances">
         | 
| 4 | 
            +
                <parameter name="wis" mimetype="text/xml" handler="http://riddl.org/ns/handlers/relaxng">
         | 
| 5 | 
            +
                  <xi:include href="rngs/instances.rng"/>
         | 
| 6 | 
            +
                </parameter>
         | 
| 7 | 
            +
              </message>
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              <message name="instance-id">
         | 
| 10 | 
            +
                <parameter name="id" type="integer"/>
         | 
| 11 | 
            +
              </message>
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              <message name="instance-name">
         | 
| 14 | 
            +
                <parameter name="name" type="string"/>
         | 
| 15 | 
            +
              </message>
         | 
| 16 | 
            +
              
         | 
| 17 | 
            +
              <message name="instance-info">
         | 
| 18 | 
            +
                <parameter name="info" mimetype="text/xml" handler="http://riddl.org/ns/handlers/relaxng">
         | 
| 19 | 
            +
                  <xi:include href="rngs/instance-info.rng"/>
         | 
| 20 | 
            +
                </parameter>
         | 
| 21 | 
            +
              </message>
         | 
| 22 | 
            +
              <message name="callbacks">
         | 
| 23 | 
            +
                <parameter name="info" mimetype="text/xml" handler="http://riddl.org/ns/handlers/relaxng">
         | 
| 24 | 
            +
                  <xi:include href="rngs/callbacks.rng"/>
         | 
| 25 | 
            +
                </parameter>
         | 
| 26 | 
            +
              </message>
         | 
| 27 | 
            +
              <message name="xsl">
         | 
| 28 | 
            +
                <parameter name="xsl" mimetype="application/xml"/>
         | 
| 29 | 
            +
              </message>
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              <message name="message">
         | 
| 32 | 
            +
                <parameter name="type" type="integer"/>
         | 
| 33 | 
            +
                <parameter name="message" type="string"/>
         | 
| 34 | 
            +
                <optional>
         | 
| 35 | 
            +
                  <parameter name="details" mimetype="text/xml"/>
         | 
| 36 | 
            +
                  <parameter name="details" mimetype="text/yaml"/>
         | 
| 37 | 
            +
                </optional>  
         | 
| 38 | 
            +
              </message>
         | 
| 39 | 
            +
             | 
| 40 | 
            +
              <resource>
         | 
| 41 | 
            +
                <get in="*" out="list-of-bpel-schemas"/>
         | 
| 42 | 
            +
                <resource relative='xsls'>
         | 
| 43 | 
            +
                  <resource>
         | 
| 44 | 
            +
                    <get in="*" out="xsl"/>
         | 
| 45 | 
            +
                  </resource>  
         | 
| 46 | 
            +
                </resource>
         | 
| 47 | 
            +
                <resource relative="cpee">
         | 
| 48 | 
            +
                  <get in="*" out="cpee-base"/>
         | 
| 49 | 
            +
                </resource>
         | 
| 50 | 
            +
                <resource>
         | 
| 51 | 
            +
                  <get in="*" out="schema-info"/>
         | 
| 52 | 
            +
                  <resource relative="instances">
         | 
| 53 | 
            +
                    <get in="*" out="instances"/>
         | 
| 54 | 
            +
                  </resource>
         | 
| 55 | 
            +
                  <resource relative="dsl">
         | 
| 56 | 
            +
                    <get in="*" out="dsl"/>
         | 
| 57 | 
            +
                  </resource>
         | 
| 58 | 
            +
                  <resource relative="dataelements">
         | 
| 59 | 
            +
                    <get in="*" out="dataelements"/>
         | 
| 60 | 
            +
                  </resource>
         | 
| 61 | 
            +
                  <resource relative="endpoints">
         | 
| 62 | 
            +
                    <get in="*" out="endpoints"/>
         | 
| 63 | 
            +
                  </resource>
         | 
| 64 | 
            +
                  <resource relative="invocation">
         | 
| 65 | 
            +
                    <get in="*" out="invocation"/>
         | 
| 66 | 
            +
                  </resource>
         | 
| 67 | 
            +
                  <post in="*"/>
         | 
| 68 | 
            +
                  <put in="*"/>
         | 
| 69 | 
            +
              </resource>
         | 
| 70 | 
            +
            </description>
         | 
| @@ -0,0 +1,367 @@ | |
| 1 | 
            +
            #!/usr/bin/ruby 
         | 
| 2 | 
            +
            require 'rubygems'
         | 
| 3 | 
            +
            require 'xml/smart'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class BPEL_Transform 
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              def initialize(fname)
         | 
| 8 | 
            +
                @base = ::File.dirname(fname)
         | 
| 9 | 
            +
                @doc = XML::Smart.open(fname)
         | 
| 10 | 
            +
                @doc.namespaces = {
         | 
| 11 | 
            +
                  'bpel' => 'http://docs.oasis-open.org/wsbpel/2.0/process/executable',
         | 
| 12 | 
            +
                  'bpws' => 'http://schemas.xmlsoap.org/ws/2003/03/business-process/',
         | 
| 13 | 
            +
                  'ext'  => 'http://www.activebpel.org/2006/09/bpel/extension/query_handling',
         | 
| 14 | 
            +
                  'xsd'  => 'http://www.w3.org/2001/XMLSchema'
         | 
| 15 | 
            +
                }
         | 
| 16 | 
            +
                @acounter = 0
         | 
| 17 | 
            +
                @MULTI = 2
         | 
| 18 | 
            +
                @vars = {}
         | 
| 19 | 
            +
              end  
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              def transform_dsl # {{{
         | 
| 22 | 
            +
                @acounter = 0
         | 
| 23 | 
            +
                @vars = {}
         | 
| 24 | 
            +
                extract_vars
         | 
| 25 | 
            +
                spaces = 0
         | 
| 26 | 
            +
                result = ''
         | 
| 27 | 
            +
                @doc.find("/bpel:process/bpel:sequence").each do |e|
         | 
| 28 | 
            +
                  result << print_elements(e,spaces)
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
                result
         | 
| 31 | 
            +
              end # }}}
         | 
| 32 | 
            +
              def extract_vars # {{{
         | 
| 33 | 
            +
                @doc.find("//bpel:variables/bpel:variable").each do |v|
         | 
| 34 | 
            +
                  @vars[v.attributes['name']] = extract_ns_plus v.attributes['messageType']
         | 
| 35 | 
            +
                end  
         | 
| 36 | 
            +
              end # }}}
         | 
| 37 | 
            +
              def transform_data # {{{
         | 
| 38 | 
            +
                result = "<dataelements>\n"
         | 
| 39 | 
            +
                @doc.find("//bpel:variables/bpel:variable").each do |v|
         | 
| 40 | 
            +
                  result << print_spaces(@MULTI)
         | 
| 41 | 
            +
                  result << "<" + v.attributes['name'] + "/>\n"
         | 
| 42 | 
            +
                end  
         | 
| 43 | 
            +
                result << '</dataelements>'
         | 
| 44 | 
            +
                result
         | 
| 45 | 
            +
              end # }}}
         | 
| 46 | 
            +
              def transform_endpoints # {{{
         | 
| 47 | 
            +
                result = XML::Smart.string('<endpoints/>')
         | 
| 48 | 
            +
                result.namespaces = {
         | 
| 49 | 
            +
                  'xsd'  => 'http://www.w3.org/2001/XMLSchema',
         | 
| 50 | 
            +
                }
         | 
| 51 | 
            +
                @doc.find("//bpel:invoke").each do |e|
         | 
| 52 | 
            +
                  op = e.attributes['operation']
         | 
| 53 | 
            +
                  plnk_name = e.attributes['partnerLink']
         | 
| 54 | 
            +
                  @doc.find("/bpel:process/bpel:partnerLinks/bpel:partnerLink[@name=\"#{plnk_name}\"]").each do |f|
         | 
| 55 | 
            +
                    plnk_role = f.attributes['partnerRole'] 
         | 
| 56 | 
            +
                    plnk_type = remove_ns f.attributes['partnerLinkType']
         | 
| 57 | 
            +
                    @doc.find("/bpel:process/bpel:import[@importType=\"http://www.w3.org/ns/wsdl\"]").each do |g|
         | 
| 58 | 
            +
                      XML::Smart.open(@base + "/" + g.attributes['location']) do |w|
         | 
| 59 | 
            +
                        w.namespaces = {
         | 
| 60 | 
            +
                          'wsdl' => 'http://www.w3.org/ns/wsdl',
         | 
| 61 | 
            +
                          'plnk' => 'http://schemas.xmlsoap.org/ws/2003/05/partner-link/',
         | 
| 62 | 
            +
                          'std'  => g.attributes['namespace'],
         | 
| 63 | 
            +
                          'xsd'  => 'http://www.w3.org/2001/XMLSchema',
         | 
| 64 | 
            +
                          'whttp' => 'http://www.w3.org/ns/wsdl/http'
         | 
| 65 | 
            +
                        }
         | 
| 66 | 
            +
                        w.find("/wsdl:description/plnk:partnerLinkType[@name='#{plnk_type}']/plnk:role[@name='#{plnk_role}']").each do |h|
         | 
| 67 | 
            +
                          interface = remove_ns h.attributes['portType']
         | 
| 68 | 
            +
                          method = w.find("string(/wsdl:description/wsdl:binding[@interface='#{interface}']/wsdl:operation[@ref='#{op}']/@whttp:method)")
         | 
| 69 | 
            +
                          method = method == '' ? 'SOAP' : method
         | 
| 70 | 
            +
                          n1 = result.root.add("#{plnk_name}.#{op}")
         | 
| 71 | 
            +
                          w.find("/wsdl:description/wsdl:interface[@name='#{interface}']/wsdl:operation[@name='#{op}']/wsdl:*").each do |i|
         | 
| 72 | 
            +
                            schema_nsn = extract_ns i.attributes['element'] 
         | 
| 73 | 
            +
                            schema_root = remove_ns i.attributes['element']
         | 
| 74 | 
            +
                            schema_ns = w.root.namespaces[schema_nsn]
         | 
| 75 | 
            +
                            w.find("/wsdl:description/wsdl:types/xsd:schema[@targetNamespace='#{schema_ns}']").each do |s|
         | 
| 76 | 
            +
                              n2 = n1.add(i.name.to_s, 'method' => method, 'targetNamespace' => w.root.attributes['targetNamespace'])
         | 
| 77 | 
            +
                              n2.add(s)
         | 
| 78 | 
            +
                              n2.find("xsd:schema/xsd:element[@name!='#{schema_root}']").delete_all!
         | 
| 79 | 
            +
                            end
         | 
| 80 | 
            +
                          end
         | 
| 81 | 
            +
                        end
         | 
| 82 | 
            +
                      end  
         | 
| 83 | 
            +
                    end
         | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
                end
         | 
| 86 | 
            +
                result.to_s
         | 
| 87 | 
            +
              end # }}}
         | 
| 88 | 
            +
              def transform_invocation # {{{
         | 
| 89 | 
            +
                result = XML::Smart.string('<invocations/>')
         | 
| 90 | 
            +
                @doc.find("/bpel:process/bpel:sequence/bpel:receive[@createInstance='yes']").each do |e|
         | 
| 91 | 
            +
                  op = e.attributes['operation']
         | 
| 92 | 
            +
                  plnk_name = e.attributes['partnerLink']
         | 
| 93 | 
            +
                  @doc.find("/bpel:process/bpel:partnerLinks/bpel:partnerLink[@name=\"#{plnk_name}\"]").each do |f|
         | 
| 94 | 
            +
                    plnk_role = f.attributes['myRole'] 
         | 
| 95 | 
            +
                    plnk_type = remove_ns f.attributes['partnerLinkType']
         | 
| 96 | 
            +
                    @doc.find("/bpel:process/bpel:import[@importType=\"http://www.w3.org/ns/wsdl\"]").each do |g|
         | 
| 97 | 
            +
                      XML::Smart.open(@base + "/" + g.attributes['location']) do |w|
         | 
| 98 | 
            +
                        w.namespaces = {
         | 
| 99 | 
            +
                          'wsdl' => 'http://www.w3.org/ns/wsdl',
         | 
| 100 | 
            +
                          'plnk' => 'http://schemas.xmlsoap.org/ws/2003/05/partner-link/',
         | 
| 101 | 
            +
                          'std'  => g.attributes['namespace'],
         | 
| 102 | 
            +
                          'xsd'  => 'http://www.w3.org/2001/XMLSchema',
         | 
| 103 | 
            +
                          'whttp' => 'http://www.w3.org/ns/wsdl/http'
         | 
| 104 | 
            +
                        }
         | 
| 105 | 
            +
                        w.find("/wsdl:description/plnk:partnerLinkType[@name='#{plnk_type}']/plnk:role[@name='#{plnk_role}']").each do |h|
         | 
| 106 | 
            +
                          interface = remove_ns h.attributes['portType']
         | 
| 107 | 
            +
                          method = w.find("string(/wsdl:description/wsdl:binding[@interface='#{interface}']/wsdl:operation[@ref='#{op}']/@whttp:method)")
         | 
| 108 | 
            +
                          method = method == '' ? 'SOAP' : method
         | 
| 109 | 
            +
                          w.find("/wsdl:description/wsdl:interface[@name='#{interface}']/wsdl:operation[@name='#{op}']/wsdl:input").each do |i|
         | 
| 110 | 
            +
                            schema_nsn = extract_ns i.attributes['element'] 
         | 
| 111 | 
            +
                            schema_root = remove_ns i.attributes['element']
         | 
| 112 | 
            +
                            schema_ns = w.root.namespaces[schema_nsn]
         | 
| 113 | 
            +
                            w.find("/wsdl:description/wsdl:types/xsd:schema[@targetNamespace='#{schema_ns}']/xsd:element[@name!='#{schema_root}']").delete_all!
         | 
| 114 | 
            +
                            w.find("/wsdl:description/wsdl:types/xsd:schema[@targetNamespace='#{schema_ns}']").each do |s|
         | 
| 115 | 
            +
                              node = result.root.add('invocation', 'plnk_name' => plnk_name, 'plnk_role' => plnk_role, 'plnk_type' => plnk_type, 'interface' => interface, 'method' => method, 'targetNamespace' => w.root.attributes['targetNamespace'])
         | 
| 116 | 
            +
                              node.add(s)
         | 
| 117 | 
            +
                            end
         | 
| 118 | 
            +
                          end
         | 
| 119 | 
            +
                        end
         | 
| 120 | 
            +
                      end  
         | 
| 121 | 
            +
                    end
         | 
| 122 | 
            +
                  end
         | 
| 123 | 
            +
                end
         | 
| 124 | 
            +
                result.to_s
         | 
| 125 | 
            +
              end # }}}
         | 
| 126 | 
            +
             | 
| 127 | 
            +
              def print_elements(e,spaces) # {{{
         | 
| 128 | 
            +
                result = ''
         | 
| 129 | 
            +
                e.find("*[not(@createInstance) or @createInstance='no']").each do |e|
         | 
| 130 | 
            +
                  result << print_element(e,spaces)
         | 
| 131 | 
            +
                end  
         | 
| 132 | 
            +
                result
         | 
| 133 | 
            +
              end # }}}
         | 
| 134 | 
            +
              def print_element(e,spaces) # {{{
         | 
| 135 | 
            +
                result = ''
         | 
| 136 | 
            +
                case e.name.name
         | 
| 137 | 
            +
                  when 'invoke'
         | 
| 138 | 
            +
                    result << print_activity_plain(spaces)
         | 
| 139 | 
            +
                    result << print_activity_call(e,spaces)
         | 
| 140 | 
            +
                  when 'receive'
         | 
| 141 | 
            +
                    result << print_activity_plain(spaces)
         | 
| 142 | 
            +
                    result << print_activity_call(e)
         | 
| 143 | 
            +
                    result << print_activity_end(spaces)
         | 
| 144 | 
            +
                  when 'reply'
         | 
| 145 | 
            +
                    result << print_reply(e,spaces)
         | 
| 146 | 
            +
                  when 'forEach'
         | 
| 147 | 
            +
                    result << print_foreach(e,spaces)
         | 
| 148 | 
            +
                  when 'pick'
         | 
| 149 | 
            +
                  when 'sequence'
         | 
| 150 | 
            +
                    result << print_elements(e,spaces)
         | 
| 151 | 
            +
                  when 'pick'
         | 
| 152 | 
            +
                  when 'scope'
         | 
| 153 | 
            +
                  when 'wait'
         | 
| 154 | 
            +
                  when 'assign'
         | 
| 155 | 
            +
                    result << print_activity_plain(spaces)
         | 
| 156 | 
            +
                    result << print_activity_manipulate(e)
         | 
| 157 | 
            +
                    result << print_activity_assign(e,spaces+@MULTI)
         | 
| 158 | 
            +
                    result << print_activity_end(spaces)
         | 
| 159 | 
            +
                  when 'if'
         | 
| 160 | 
            +
                    result << print_choose(e,spaces)
         | 
| 161 | 
            +
                  when 'while'
         | 
| 162 | 
            +
                    result << print_while(e,spaces)
         | 
| 163 | 
            +
                  when 'flow'
         | 
| 164 | 
            +
                    result << print_parallel(e,spaces) 
         | 
| 165 | 
            +
                end
         | 
| 166 | 
            +
                result
         | 
| 167 | 
            +
              end # }}}
         | 
| 168 | 
            +
             | 
| 169 | 
            +
              def print_activity_plain(spaces) # {{{
         | 
| 170 | 
            +
                @acounter += 1
         | 
| 171 | 
            +
                result = print_spaces(spaces)
         | 
| 172 | 
            +
                result << 'activity :a'
         | 
| 173 | 
            +
                result << @acounter.to_s
         | 
| 174 | 
            +
              end    # }}}
         | 
| 175 | 
            +
              def print_activity_manipulate(e) # {{{
         | 
| 176 | 
            +
                result = ", :manipulate do\n"
         | 
| 177 | 
            +
              end    # }}}
         | 
| 178 | 
            +
              def print_activity_assign(e,spaces) # {{{
         | 
| 179 | 
            +
                result = ''
         | 
| 180 | 
            +
                e.find('bpel:copy').each do |c|
         | 
| 181 | 
            +
                  result << print_spaces(spaces)
         | 
| 182 | 
            +
                  result << bpel_copy_x(c,'bpel:to','set')
         | 
| 183 | 
            +
                  result << ' = '
         | 
| 184 | 
            +
                  result << bpel_copy_x(c,'bpel:from','evaluate')
         | 
| 185 | 
            +
                  result << "\n"
         | 
| 186 | 
            +
                end
         | 
| 187 | 
            +
                result
         | 
| 188 | 
            +
              end # }}}
         | 
| 189 | 
            +
              def print_activity_end(spaces) # {{{
         | 
| 190 | 
            +
                result = print_spaces(spaces)
         | 
| 191 | 
            +
                result << "end\n"
         | 
| 192 | 
            +
              end # }}}
         | 
| 193 | 
            +
              def bpel_copy_x(c,what,op) # {{{
         | 
| 194 | 
            +
                result = ''
         | 
| 195 | 
            +
                c.find(what).each do |to|
         | 
| 196 | 
            +
                  text = if to.attributes['variable']
         | 
| 197 | 
            +
                    if to.attributes['part']
         | 
| 198 | 
            +
                      temp = "$#{to.attributes['variable']}"
         | 
| 199 | 
            +
                      temp << '/' + @vars[to.attributes['variable']].to_s + to.attributes['part']
         | 
| 200 | 
            +
                      result << transform_bpel_xpath(temp,op)
         | 
| 201 | 
            +
                    else
         | 
| 202 | 
            +
                      result << "data.#{to.attributes['variable']}"
         | 
| 203 | 
            +
                    end
         | 
| 204 | 
            +
                    temp
         | 
| 205 | 
            +
                  else
         | 
| 206 | 
            +
                    result << transform_bpel_xpath(to.text,op)
         | 
| 207 | 
            +
                  end
         | 
| 208 | 
            +
                end
         | 
| 209 | 
            +
                result
         | 
| 210 | 
            +
              end # }}}
         | 
| 211 | 
            +
             | 
| 212 | 
            +
              def print_choose(e,spaces) # {{{
         | 
| 213 | 
            +
                result = ''
         | 
| 214 | 
            +
                result << print_spaces(spaces) << "choose do\n"
         | 
| 215 | 
            +
                result << print_alternative(e,'alternative',spaces+@MULTI)
         | 
| 216 | 
            +
                e.find('bpel:elseif').each do |ei|
         | 
| 217 | 
            +
                  result << print_alternative(ei,'alternative',spaces+@MULTI)
         | 
| 218 | 
            +
                end
         | 
| 219 | 
            +
                e.find('bpel:else').each do |ei|
         | 
| 220 | 
            +
                  result << print_alternative(ei,'otherwise',spaces+@MULTI)
         | 
| 221 | 
            +
                end
         | 
| 222 | 
            +
                result << print_spaces(spaces) << "end\n"
         | 
| 223 | 
            +
                result
         | 
| 224 | 
            +
              end # }}}
         | 
| 225 | 
            +
              def print_alternative(e,word,spaces) # {{{
         | 
| 226 | 
            +
                result = ''
         | 
| 227 | 
            +
                result << print_spaces(spaces) 
         | 
| 228 | 
            +
                case word 
         | 
| 229 | 
            +
                  when 'alternative'
         | 
| 230 | 
            +
                    result << word + " " 
         | 
| 231 | 
            +
                    result << transform_bpel_xpath(e.find('string(bpel:condition)'),'evaluate')
         | 
| 232 | 
            +
                  when 'otherwise'
         | 
| 233 | 
            +
                    result << word
         | 
| 234 | 
            +
                end    
         | 
| 235 | 
            +
                result << " do\n"
         | 
| 236 | 
            +
                result << print_elements(e,spaces+@MULTI)
         | 
| 237 | 
            +
                result << print_spaces(spaces) << "end\n"
         | 
| 238 | 
            +
                result
         | 
| 239 | 
            +
              end # }}}
         | 
| 240 | 
            +
             | 
| 241 | 
            +
              def print_while(e,spaces) # {{{
         | 
| 242 | 
            +
                result = ''
         | 
| 243 | 
            +
                result << print_spaces(spaces) 
         | 
| 244 | 
            +
                result << "loop pre_test{" 
         | 
| 245 | 
            +
                result << transform_bpel_xpath(e.find('string(bpel:condition)'),'evaluate')
         | 
| 246 | 
            +
                result << "} do\n"
         | 
| 247 | 
            +
                result << print_elements(e,spaces+@MULTI)
         | 
| 248 | 
            +
                result << print_spaces(spaces) << "end\n"
         | 
| 249 | 
            +
                result
         | 
| 250 | 
            +
              end # }}}
         | 
| 251 | 
            +
              
         | 
| 252 | 
            +
              def print_foreach(e,spaces) # {{{
         | 
| 253 | 
            +
                result = ''
         | 
| 254 | 
            +
                cname = e.find('string(@counterName)')
         | 
| 255 | 
            +
                parallel = e.find('boolean(@parallel[.="yes"])')
         | 
| 256 | 
            +
                sps = spaces
         | 
| 257 | 
            +
             | 
| 258 | 
            +
                if parallel
         | 
| 259 | 
            +
                  result << print_spaces(sps) << "parallel(:wait) do\n"
         | 
| 260 | 
            +
                  sps += @MULTI
         | 
| 261 | 
            +
                end  
         | 
| 262 | 
            +
             | 
| 263 | 
            +
                result << print_spaces(sps) << "#{cname} = " << e.find('string(bpel:startCounterValue)') << "\n"
         | 
| 264 | 
            +
                result << print_spaces(sps) << "loop pre_test{" 
         | 
| 265 | 
            +
                result << "#{cname} <= " << transform_bpel_xpath(e.find('string(bpel:finalCounterValue)'),'evaluate')
         | 
| 266 | 
            +
                result << "} do\n"
         | 
| 267 | 
            +
                if parallel
         | 
| 268 | 
            +
                  sps += @MULTI
         | 
| 269 | 
            +
                  result << print_spaces(sps) << "parallel_branch(#{cname}) do |#{cname}|\n"
         | 
| 270 | 
            +
                end  
         | 
| 271 | 
            +
                e.find("*[name()='bpel:scope']").each do |f|
         | 
| 272 | 
            +
                  result << print_elements(f,sps+@MULTI)
         | 
| 273 | 
            +
                end  
         | 
| 274 | 
            +
                if parallel
         | 
| 275 | 
            +
                  result << print_spaces(sps) << "end\n"
         | 
| 276 | 
            +
                  sps -= @MULTI
         | 
| 277 | 
            +
                end  
         | 
| 278 | 
            +
                result << print_spaces(sps+@MULTI) << "#{cname} += 1\n"
         | 
| 279 | 
            +
                result << print_spaces(sps) << "end\n"
         | 
| 280 | 
            +
             | 
| 281 | 
            +
                if parallel
         | 
| 282 | 
            +
                  result << print_spaces(spaces) << "end\n"
         | 
| 283 | 
            +
                end  
         | 
| 284 | 
            +
                result
         | 
| 285 | 
            +
              end # }}}
         | 
| 286 | 
            +
              
         | 
| 287 | 
            +
              def print_reply(e,spaces) # {{{
         | 
| 288 | 
            +
                result = ''
         | 
| 289 | 
            +
                result << print_spaces(spaces) 
         | 
| 290 | 
            +
                result << "status.update(1,\"#{e.attributes['partnerLink']}.#{e.attributes['operation']};#{e.attributes['variable']}\")"
         | 
| 291 | 
            +
                result
         | 
| 292 | 
            +
              end # }}}
         | 
| 293 | 
            +
             | 
| 294 | 
            +
              def print_parallel(e,spaces) # {{{
         | 
| 295 | 
            +
                result = ''
         | 
| 296 | 
            +
                result << print_spaces(spaces) 
         | 
| 297 | 
            +
                result << "parallel do\n" 
         | 
| 298 | 
            +
             | 
| 299 | 
            +
                result << print_spaces(spaces+@MULTI) 
         | 
| 300 | 
            +
                result << "links = {}\n"
         | 
| 301 | 
            +
             | 
| 302 | 
            +
                e.find("*[name()!='bpel:links']").each do |e|
         | 
| 303 | 
            +
                  result << print_spaces(spaces+@MULTI) 
         | 
| 304 | 
            +
                  result << "parallel_branch do\n"
         | 
| 305 | 
            +
             | 
| 306 | 
            +
                  e.find('bpel:targets/bpel:target').each do |l|
         | 
| 307 | 
            +
                    result << print_spaces(spaces+@MULTI+@MULTI)
         | 
| 308 | 
            +
                    result << "links[\"" + l.attributes['linkName'] + "\"] = Thread.current\n"
         | 
| 309 | 
            +
                    result << print_spaces(spaces+@MULTI+@MULTI)
         | 
| 310 | 
            +
                    result << "Thread.current.stop\n"
         | 
| 311 | 
            +
                  end
         | 
| 312 | 
            +
             | 
| 313 | 
            +
                  result << print_element(e,spaces+@MULTI+@MULTI)
         | 
| 314 | 
            +
             | 
| 315 | 
            +
                  e.find('bpel:sources/bpel:source').each do |s|
         | 
| 316 | 
            +
                    result << print_spaces(spaces+@MULTI+@MULTI)
         | 
| 317 | 
            +
                    result << "until links.include?(\"" + s.attributes["linkName"] + "\") && links[\"" + s.attributes["linkName"] + "\"].stop?\n"
         | 
| 318 | 
            +
                    result << print_spaces(spaces+@MULTI+@MULTI+@MULTI)
         | 
| 319 | 
            +
                    result << "Thread.current.pass\n"
         | 
| 320 | 
            +
                    result << print_spaces(spaces+@MULTI+@MULTI) << "end\n"
         | 
| 321 | 
            +
                    result << print_spaces(spaces+@MULTI+@MULTI)
         | 
| 322 | 
            +
                    result << "links[\"" + s.attributes["linkName"] + "\"].run\n"
         | 
| 323 | 
            +
                  end
         | 
| 324 | 
            +
             | 
| 325 | 
            +
                  result << print_spaces(spaces+@MULTI) << "end\n"
         | 
| 326 | 
            +
                end
         | 
| 327 | 
            +
             | 
| 328 | 
            +
                result << print_spaces(spaces) << "end\n"
         | 
| 329 | 
            +
                result
         | 
| 330 | 
            +
              end  # }}}
         | 
| 331 | 
            +
             | 
| 332 | 
            +
              def print_activity_call(e,spaces) # {{{
         | 
| 333 | 
            +
                result = ", :call, :\"#{e.attributes['partnerLink']}.#{e.attributes['operation']}\", data.#{e.attributes['inputVariable']}"
         | 
| 334 | 
            +
                if e.attributes['outputVariable']
         | 
| 335 | 
            +
                  result << " do |result|\n"
         | 
| 336 | 
            +
                  result << print_spaces(spaces+@MULTI)
         | 
| 337 | 
            +
                  result << "data.#{e.attributes['outputVariable']} = result\n"
         | 
| 338 | 
            +
                  result << print_activity_end(spaces)
         | 
| 339 | 
            +
                else  
         | 
| 340 | 
            +
                  result << "\n"
         | 
| 341 | 
            +
                end  
         | 
| 342 | 
            +
              end    # }}}
         | 
| 343 | 
            +
             | 
| 344 | 
            +
              def print_spaces(spaces) # {{{
         | 
| 345 | 
            +
                ' ' * spaces
         | 
| 346 | 
            +
              end  # }}}
         | 
| 347 | 
            +
              def transform_bpel_xpath(text,op) # {{{
         | 
| 348 | 
            +
                text.gsub!(/\$([a-z][a-zA-Z0-9]+)\.Document/,'/helper/\1')
         | 
| 349 | 
            +
                text.gsub!(/\$([a-z][a-zA-Z0-9]+)\.([a-z][a-zA-Z0-9]+)/) do
         | 
| 350 | 
            +
                  t1,t2 = $1,$2
         | 
| 351 | 
            +
                  "/helper/#{t1}/" + @vars[t1] + t2
         | 
| 352 | 
            +
                end 
         | 
| 353 | 
            +
                text.gsub!(/\$([a-z][a-zA-Z0-9]+)/,'/helper/\1')
         | 
| 354 | 
            +
                "XPATHHelper.#{op}(\"" + text.strip + "\")"
         | 
| 355 | 
            +
              end  # }}}
         | 
| 356 | 
            +
             | 
| 357 | 
            +
            private
         | 
| 358 | 
            +
              def remove_ns(str) # {{{
         | 
| 359 | 
            +
                str.gsub(/[a-zA_Z][a-zA_Z0-9]*:/,'')
         | 
| 360 | 
            +
              end # }}}
         | 
| 361 | 
            +
              def extract_ns(str) # {{{
         | 
| 362 | 
            +
                str.nil? ? '' : str.match(/^([a-zA_Z][a-zA_Z0-9]*):/)[1].to_s
         | 
| 363 | 
            +
              end # }}}
         | 
| 364 | 
            +
              def extract_ns_plus(str) # {{{
         | 
| 365 | 
            +
                str.nil? ? '' : str.match(/^[a-zA_Z][a-zA_Z0-9]*:/).to_s
         | 
| 366 | 
            +
              end # }}}
         | 
| 367 | 
            +
            end
         |