Module: CPEE

Defined in:
lib/cpee/callback.rb,
lib/cpee/controller.rb,
lib/cpee/implementation.rb,
lib/cpee/processtransformation/cpee.rb,
lib/cpee/processtransformation/bpmn2.rb,
lib/cpee/processtransformation/structures.rb

Overview

This file is part of CPEE.

Apache License, Version 2.0

Copyright © 2013 Juergen Mangler

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Modules: ProcessTransformation Classes: Callback, Callbacks, Controller, DeleteInstance, ExCallback, Info, Instances, NewInstance, ValueHelper

Constant Summary collapse

SERVER =
File.expand_path(File.dirname(__FILE__) + '/../cpee.xml')

Class Method Summary collapse

Class Method Details

.implementation(opts) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/cpee/implementation.rb', line 26

def self::implementation(opts)
  opts[:instances]                  ||= File.expand_path(File.dirname(__FILE__) + '/../../server/instances')
  opts[:handlerwrappers]            ||= File.expand_path(File.dirname(__FILE__) + '/../../server/handlerwrappers')
  opts[:topics]                     ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/topics.xml')
  opts[:properties_init]            ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/properties.init')
  opts[:properties_schema_active]   ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/properties.schema.active')
  opts[:properties_schema_finished] ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/properties.schema.finished')
  opts[:properties_schema_inactive] ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/properties.schema.inactive')
  opts[:transformation_dslx]        ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/transformation_dslx.xsl')
  opts[:transformation_service]     ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/transformation.xml')
  opts[:empty_dslx]                 ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/empty_dslx.xml')

  Proc.new do
    Dir[opts[:handlerwrappers] + "/*.rb"].each do |h|
      require h
    end

    controller = {}
    Dir[opts[:instances] + '/*/properties.xml'].map{|e|::File::basename(::File::dirname(e))}.each do |id|
      controller[id.to_i] = Controller.new(id,opts)
    end

    interface 'properties' do |r|
      id = r[:h]['RIDDL_DECLARATION_PATH'].split('/')[1].to_i
      use Riddl::Utils::Properties::implementation(controller[id].properties, PropertiesHandler.new(controller[id]), opts[:mode]) if controller[id]
    end  

    interface 'main' do
      run CPEE::Instances, controller if get '*'
      run CPEE::NewInstance, controller, opts if post 'instance-new'
      on resource do |r|
        run CPEE::Info, controller if get
        run CPEE::DeleteInstance, controller, opts if delete
        on resource 'callbacks' do
          run CPEE::Callbacks, controller, opts if get
          on resource do
            run CPEE::ExCallback, controller if get || put || post || delete
          end  
        end  
      end  
    end

    interface 'notifications' do |r|
      id = r[:h]['RIDDL_DECLARATION_PATH'].split('/')[1].to_i
      use Riddl::Utils::Notifications::Producer::implementation(controller[id].notifications, NotificationsHandler.new(controller[id]), opts[:mode]) if controller[id]
    end
  end  
end