cpee 1.5.27 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{FEATURES → FEATURES.md} +7 -6
- data/INSTALL.md +1 -0
- data/{README → README.md} +3 -3
- data/Rakefile +1 -0
- data/cockpit/index.html +7 -7
- data/cockpit/js/details.js +13 -14
- data/cockpit/js/instance.js +186 -284
- data/cockpit/js/parameters.js +13 -3
- data/cockpit/js/ui.js +2 -2
- data/cockpit/rngs/attributes.rng +1 -1
- data/cockpit/rngs/dataelements.rng +1 -1
- data/cockpit/rngs/endpoints.rng +1 -1
- data/cockpit/templates.legacy/Async.xml +7 -7
- data/cockpit/templates.legacy/BCO.xml +7 -10
- data/cockpit/templates.legacy/BCS.xml +7 -10
- data/cockpit/templates.legacy/Centurio.xml +6 -6
- data/cockpit/templates.legacy/Concurrent.xml +6 -6
- data/cockpit/templates.legacy/Coopis Testset.xml +6 -6
- data/cockpit/templates.legacy/Endpoints and Data Manipulation.xml +6 -6
- data/cockpit/templates.legacy/ICSOC Testset.xml +6 -6
- data/cockpit/templates.legacy/Infinity.xml +3 -3
- data/cockpit/templates.legacy/Lego Boxer.xml +7 -7
- data/cockpit/templates.legacy/Lego Conveyor.xml +7 -7
- data/cockpit/templates.legacy/Lego Crane.xml +7 -7
- data/cockpit/templates.legacy/Lego Ejector.xml +7 -7
- data/cockpit/templates.legacy/Lego Full.xml +7 -7
- data/cockpit/templates.legacy/Lego Liddy.xml +7 -7
- data/cockpit/templates.legacy/Lego Plate.xml +7 -7
- data/cockpit/templates.legacy/Lego Transporter.xml +7 -7
- data/cockpit/templates.legacy/Lego_Part_1.xml +7 -7
- data/cockpit/templates.legacy/LgLinear.xml +6 -10
- data/cockpit/templates.legacy/Linear.xml +7 -7
- data/cockpit/templates.legacy/Log.xml +7 -7
- data/cockpit/templates.legacy/Mangler 1.xml +6 -6
- data/cockpit/templates.legacy/Mangler 2.xml +6 -6
- data/cockpit/templates.legacy/Manuel Labels.xml +7 -7
- data/cockpit/templates.legacy/Promise.xml +7 -7
- data/cockpit/templates.legacy/SOPROMO Test Sonification.xml +6 -6
- data/cockpit/templates.legacy/Subprocess.xml +56 -0
- data/cockpit/templates.legacy/Syncing P34 1.xml +8 -11
- data/cockpit/templates.legacy/Syncing P34 2.xml +8 -11
- data/cockpit/templates.legacy/Syncing P34 3.xml +8 -11
- data/cockpit/templates.legacy/Syncing P34.xml +8 -11
- data/cockpit/templates.legacy/TEST - Bad Loop.xml +6 -6
- data/cockpit/templates.legacy/TEST - Wrong Positions.xml +6 -6
- data/cockpit/templates.legacy/Take_5.xml +48 -0
- data/cockpit/templates.legacy/Update.xml +7 -7
- data/cockpit/templates.legacy/Worklist Parallel.xml +7 -7
- data/cockpit/templates.legacy/Worklist Test CPEE.xml +7 -7
- data/cockpit/templates.legacy/Worklist Test.xml +7 -7
- data/cockpit/templates.legacy/Worklist Test2.xml +7 -7
- data/cockpit/templates.legacy/convert_cpee2.rb +15 -0
- data/cockpit/templates.legacy/testsets.xml +1 -1
- data/cockpit/templates/BPM 2020 Manual Adjust.xml +18 -71
- data/cockpit/templates/BPM 2020 Solution Baseline.xml +17 -71
- data/cockpit/templates/BPM 2020 Solution NN.xml +25 -71
- data/cockpit/templates/BPM 2020 Solution View.xml +15 -71
- data/cockpit/templates/BPM 2020.xml +17 -6
- data/cockpit/templates/Coopis 2010.xml +16 -7
- data/cockpit/templates/IUPC arXiv:1104.3609 P34 1.xml +8 -11
- data/cockpit/templates/IUPC arXiv:1104.3609 P34 2.xml +8 -11
- data/cockpit/templates/IUPC arXiv:1104.3609 P34 3.xml +8 -11
- data/cockpit/templates/Worklist.xml +7 -7
- data/cockpit/templates/convert_cpee2.rb +15 -0
- data/cockpit/themes/compact/rngs/alternative.rng +25 -0
- data/cockpit/themes/compact/rngs/call.rng +18 -18
- data/cockpit/themes/compact/rngs/callmanipulate.rng +26 -26
- data/cockpit/themes/compact/rngs/choose.rng +14 -0
- data/cockpit/themes/compact/rngs/critical.rng +5 -0
- data/cockpit/themes/compact/rngs/escape.rng +1 -0
- data/cockpit/themes/compact/rngs/group.rng +3 -0
- data/cockpit/themes/compact/rngs/loop.rng +22 -0
- data/cockpit/themes/compact/rngs/manipulate.rng +9 -0
- data/cockpit/themes/compact/rngs/otherwise.rng +22 -0
- data/cockpit/themes/compact/rngs/parallel.rng +21 -0
- data/cockpit/themes/compact/rngs/parallel_branch.rng +8 -0
- data/cockpit/themes/compact/rngs/scripts.rng +10 -11
- data/cockpit/themes/compact/rngs/stop.rng +5 -0
- data/cockpit/themes/compact/rngs/terminate.rng +1 -0
- data/cockpit/themes/convert_cpee2.rb +8 -0
- data/cockpit/themes/default/rngs/alternative.rng +8 -8
- data/cockpit/themes/default/rngs/call.rng +85 -49
- data/cockpit/themes/default/rngs/callmanipulate.rng +103 -64
- data/cockpit/themes/default/rngs/choose.rng +5 -3
- data/cockpit/themes/default/rngs/critical.rng +2 -2
- data/cockpit/themes/default/rngs/escape.rng +1 -1
- data/cockpit/themes/default/rngs/group.rng +3 -3
- data/cockpit/themes/default/rngs/loop.rng +8 -8
- data/cockpit/themes/default/rngs/manipulate.rng +3 -3
- data/cockpit/themes/default/rngs/otherwise.rng +8 -8
- data/cockpit/themes/default/rngs/parallel.rng +14 -6
- data/cockpit/themes/default/rngs/parallel_branch.rng +2 -2
- data/cockpit/themes/default/rngs/scripts.rng +23 -0
- data/cockpit/themes/default/rngs/stop.rng +2 -2
- data/cockpit/themes/default/rngs/terminate.rng +1 -1
- data/cockpit/themes/extended/rngs/alternative.rng +25 -0
- data/cockpit/themes/extended/rngs/call.rng +18 -18
- data/cockpit/themes/extended/rngs/callmanipulate.rng +26 -26
- data/cockpit/themes/extended/rngs/choose.rng +14 -0
- data/cockpit/themes/extended/rngs/critical.rng +5 -0
- data/cockpit/themes/extended/rngs/escape.rng +1 -0
- data/cockpit/themes/extended/rngs/group.rng +3 -0
- data/cockpit/themes/extended/rngs/loop.rng +22 -0
- data/cockpit/themes/extended/rngs/manipulate.rng +9 -0
- data/cockpit/themes/extended/rngs/otherwise.rng +22 -0
- data/cockpit/themes/extended/rngs/parallel.rng +21 -0
- data/cockpit/themes/extended/rngs/parallel_branch.rng +8 -0
- data/cockpit/themes/extended/rngs/scripts.rng +10 -11
- data/cockpit/themes/extended/rngs/stop.rng +5 -0
- data/cockpit/themes/extended/rngs/terminate.rng +1 -0
- data/cockpit/themes/extended/theme.js +7 -6
- data/cockpit/themes/model/rngs/alternative.rng +1 -1
- data/cockpit/themes/model/rngs/call.rng +16 -16
- data/cockpit/themes/model/rngs/callmanipulate.rng +17 -17
- data/cockpit/themes/model/rngs/choose.rng +1 -1
- data/cockpit/themes/model/rngs/critical.rng +1 -1
- data/cockpit/themes/model/rngs/escape.rng +1 -1
- data/cockpit/themes/model/rngs/group.rng +1 -1
- data/cockpit/themes/model/rngs/loop.rng +1 -1
- data/cockpit/themes/model/rngs/manipulate.rng +1 -1
- data/cockpit/themes/model/rngs/otherwise.rng +1 -1
- data/cockpit/themes/model/rngs/parallel.rng +1 -1
- data/cockpit/themes/model/rngs/parallel_branch.rng +1 -1
- data/cockpit/themes/model/rngs/scripts.rng +3 -4
- data/cockpit/themes/model/rngs/stop.rng +1 -1
- data/cockpit/themes/model/rngs/terminate.rng +1 -1
- data/cockpit/themes/model/theme.js +7 -6
- data/cockpit/themes/packed/rngs/alternative.rng +25 -0
- data/cockpit/themes/packed/rngs/call.rng +18 -18
- data/cockpit/themes/packed/rngs/callmanipulate.rng +26 -26
- data/cockpit/themes/packed/rngs/choose.rng +14 -0
- data/cockpit/themes/packed/rngs/critical.rng +5 -0
- data/cockpit/themes/packed/rngs/escape.rng +1 -0
- data/cockpit/themes/packed/rngs/group.rng +3 -0
- data/cockpit/themes/packed/rngs/loop.rng +22 -0
- data/cockpit/themes/packed/rngs/manipulate.rng +9 -0
- data/cockpit/themes/packed/rngs/otherwise.rng +22 -0
- data/cockpit/themes/packed/rngs/parallel.rng +21 -0
- data/cockpit/themes/packed/rngs/parallel_branch.rng +8 -0
- data/cockpit/themes/packed/rngs/scripts.rng +10 -11
- data/cockpit/themes/packed/rngs/stop.rng +5 -0
- data/cockpit/themes/packed/rngs/terminate.rng +1 -0
- data/cockpit/themes/packed/theme.js +7 -6
- data/cockpit/themes/preset/rngs/alternative.rng +25 -0
- data/cockpit/themes/preset/rngs/call.rng +18 -18
- data/cockpit/themes/preset/rngs/callmanipulate.rng +26 -26
- data/cockpit/themes/preset/rngs/choose.rng +14 -0
- data/cockpit/themes/preset/rngs/critical.rng +5 -0
- data/cockpit/themes/preset/rngs/escape.rng +1 -0
- data/cockpit/themes/preset/rngs/group.rng +3 -0
- data/cockpit/themes/preset/rngs/loop.rng +22 -0
- data/cockpit/themes/preset/rngs/manipulate.rng +9 -0
- data/cockpit/themes/preset/rngs/otherwise.rng +22 -0
- data/cockpit/themes/preset/rngs/parallel.rng +21 -0
- data/cockpit/themes/preset/rngs/parallel_branch.rng +8 -0
- data/cockpit/themes/preset/rngs/scripts.rng +10 -11
- data/cockpit/themes/preset/rngs/stop.rng +5 -0
- data/cockpit/themes/preset/rngs/terminate.rng +1 -0
- data/cockpit/themes/preset/theme.js +7 -6
- data/cpee.gemspec +9 -10
- data/{log/topics.xml → lib/callbacks.xml} +16 -6
- data/lib/{engine → callbacks}/callbacks.rng +2 -8
- data/lib/cpee.xml +10 -4
- data/lib/cpee/attributes_helper.rb +27 -0
- data/lib/cpee/controller.rb +113 -596
- data/lib/cpee/implementation.rb +152 -191
- data/lib/cpee/implementation_callbacks.rb +77 -0
- data/lib/cpee/implementation_notifications.rb +189 -0
- data/lib/cpee/implementation_properties.rb +707 -0
- data/lib/cpee/{callback.rb → message.rb} +20 -18
- data/lib/cpee/persistence.rb +135 -0
- data/lib/cpee/statemachine.rb +20 -0
- data/lib/cpee/transform.rb +95 -0
- data/lib/engine.xml +1 -59
- data/lib/properties.xml +236 -0
- data/lib/properties/arbitrary.rng +26 -0
- data/lib/properties/attributes.rng +10 -0
- data/lib/properties/dataelements.rng +10 -0
- data/lib/properties/description.rng +8 -0
- data/lib/properties/dsl.rng +7 -0
- data/lib/properties/dslx.rng +8 -0
- data/lib/properties/endpoints.rng +10 -0
- data/lib/properties/handlerwrapper.rng +9 -0
- data/lib/properties/position.rng +15 -0
- data/lib/properties/positions.rng +10 -0
- data/lib/properties/properties.rng +29 -0
- data/lib/properties/set-properties.rng +25 -0
- data/lib/properties/set-some-properties.rng +45 -0
- data/lib/properties/simple.rng +8 -0
- data/lib/properties/state.rng +33 -0
- data/lib/properties/status.rng +12 -0
- data/lib/properties/t_attributes.rng +7 -0
- data/lib/properties/t_dataelements.rng +7 -0
- data/lib/properties/t_endpoints.rng +7 -0
- data/lib/properties/t_position.rng +7 -0
- data/lib/properties/t_positions.rng +7 -0
- data/lib/properties/t_simple.rng +7 -0
- data/lib/properties/t_status.rng +7 -0
- data/lib/properties/t_transformation.rng +7 -0
- data/lib/properties/transformation.rng +40 -0
- data/server/dev.rb +1 -0
- data/server/handlerwrappers/default.rb +40 -38
- data/server/resources/backend/README.md +17 -0
- data/server/resources/backend/instance.rb +23 -0
- data/server/resources/backend/instance.template +19 -0
- data/server/resources/backend/opts.yaml +6 -0
- data/server/resources/backend/run +29 -0
- data/server/resources/notifications/logging/subscription.xml +19 -0
- data/server/resources/properties.empty +38 -0
- data/server/resources/properties.init +11 -11
- data/server/resources/states.dot +19 -0
- data/server/resources/states.xml +49 -0
- data/server/resources/transformation_dslx.xsl +3 -12
- data/server/routing/end.rb +44 -0
- data/server/routing/forward-events.rb +59 -0
- data/server/routing/forward-votes.rb +108 -0
- data/server/routing/persist.rb +155 -0
- data/server/server.rb +1 -0
- data/tools/cpee +19 -15
- data/tools/instantiation/instantiation +0 -1
- data/tools/server/server.rb +0 -1
- metadata +77 -132
- data/INSTALL +0 -23
- data/cockpit/templates/convert_preset.rb +0 -32
- data/cockpit/templates/testsets.xml +0 -11
- data/cockpit/templates/transformations.xml +0 -4
- data/cockpit/themes/compact/rngs/alternative.rng +0 -1
- data/cockpit/themes/compact/rngs/choose.rng +0 -1
- data/cockpit/themes/compact/rngs/critical.rng +0 -1
- data/cockpit/themes/compact/rngs/escape.rng +0 -1
- data/cockpit/themes/compact/rngs/group.rng +0 -1
- data/cockpit/themes/compact/rngs/loop.rng +0 -1
- data/cockpit/themes/compact/rngs/manipulate.rng +0 -1
- data/cockpit/themes/compact/rngs/otherwise.rng +0 -1
- data/cockpit/themes/compact/rngs/parallel.rng +0 -1
- data/cockpit/themes/compact/rngs/parallel_branch.rng +0 -1
- data/cockpit/themes/compact/rngs/stop.rng +0 -1
- data/cockpit/themes/compact/rngs/terminate.rng +0 -1
- data/cockpit/themes/default/rngs/finalize.rng +0 -6
- data/cockpit/themes/default/rngs/update.rng +0 -6
- data/cockpit/themes/default/theme.js +0 -1286
- data/cockpit/themes/extended/rngs/alternative.rng +0 -1
- data/cockpit/themes/extended/rngs/choose.rng +0 -1
- data/cockpit/themes/extended/rngs/critical.rng +0 -1
- data/cockpit/themes/extended/rngs/escape.rng +0 -1
- data/cockpit/themes/extended/rngs/group.rng +0 -1
- data/cockpit/themes/extended/rngs/loop.rng +0 -1
- data/cockpit/themes/extended/rngs/manipulate.rng +0 -1
- data/cockpit/themes/extended/rngs/otherwise.rng +0 -1
- data/cockpit/themes/extended/rngs/parallel.rng +0 -1
- data/cockpit/themes/extended/rngs/parallel_branch.rng +0 -1
- data/cockpit/themes/extended/rngs/stop.rng +0 -1
- data/cockpit/themes/extended/rngs/terminate.rng +0 -1
- data/cockpit/themes/labels/rngs/alternative.rng +0 -25
- data/cockpit/themes/labels/rngs/call.rng +0 -81
- data/cockpit/themes/labels/rngs/callmanipulate.rng +0 -101
- data/cockpit/themes/labels/rngs/choose.rng +0 -12
- data/cockpit/themes/labels/rngs/critical.rng +0 -5
- data/cockpit/themes/labels/rngs/escape.rng +0 -1
- data/cockpit/themes/labels/rngs/finalize.rng +0 -6
- data/cockpit/themes/labels/rngs/group.rng +0 -3
- data/cockpit/themes/labels/rngs/loop.rng +0 -22
- data/cockpit/themes/labels/rngs/manipulate.rng +0 -9
- data/cockpit/themes/labels/rngs/otherwise.rng +0 -22
- data/cockpit/themes/labels/rngs/parallel.rng +0 -13
- data/cockpit/themes/labels/rngs/parallel_branch.rng +0 -8
- data/cockpit/themes/labels/rngs/stop.rng +0 -5
- data/cockpit/themes/labels/rngs/terminate.rng +0 -1
- data/cockpit/themes/labels/rngs/update.rng +0 -6
- data/cockpit/themes/labels/symbols/alternative.svg +0 -5
- data/cockpit/themes/labels/symbols/arrow.svg +0 -3
- data/cockpit/themes/labels/symbols/call.svg +0 -6
- data/cockpit/themes/labels/symbols/callmanipulate.svg +0 -8
- data/cockpit/themes/labels/symbols/choose.svg +0 -5
- data/cockpit/themes/labels/symbols/choose_exclusive.svg +0 -5
- data/cockpit/themes/labels/symbols/choose_inclusive.svg +0 -4
- data/cockpit/themes/labels/symbols/complex.svg +0 -8
- data/cockpit/themes/labels/symbols/critical.svg +0 -4
- data/cockpit/themes/labels/symbols/end.svg +0 -3
- data/cockpit/themes/labels/symbols/escape.svg +0 -5
- data/cockpit/themes/labels/symbols/event_end.svg +0 -3
- data/cockpit/themes/labels/symbols/loop.svg +0 -5
- data/cockpit/themes/labels/symbols/manipulate.svg +0 -4
- data/cockpit/themes/labels/symbols/otherwise.svg +0 -5
- data/cockpit/themes/labels/symbols/parallel.svg +0 -5
- data/cockpit/themes/labels/symbols/parallel_branch.svg +0 -5
- data/cockpit/themes/labels/symbols/parallel_branch_compact.svg +0 -4
- data/cockpit/themes/labels/symbols/parallel_branch_event.svg +0 -14
- data/cockpit/themes/labels/symbols/parallel_branch_normal.svg +0 -5
- data/cockpit/themes/labels/symbols/scripts.svg +0 -4
- data/cockpit/themes/labels/symbols/start.svg +0 -3
- data/cockpit/themes/labels/symbols/stop.svg +0 -5
- data/cockpit/themes/labels/symbols/terminate.svg +0 -4
- data/cockpit/themes/packed/rngs/alternative.rng +0 -1
- data/cockpit/themes/packed/rngs/choose.rng +0 -1
- data/cockpit/themes/packed/rngs/critical.rng +0 -1
- data/cockpit/themes/packed/rngs/escape.rng +0 -1
- data/cockpit/themes/packed/rngs/group.rng +0 -1
- data/cockpit/themes/packed/rngs/loop.rng +0 -1
- data/cockpit/themes/packed/rngs/manipulate.rng +0 -1
- data/cockpit/themes/packed/rngs/otherwise.rng +0 -1
- data/cockpit/themes/packed/rngs/parallel.rng +0 -1
- data/cockpit/themes/packed/rngs/parallel_branch.rng +0 -1
- data/cockpit/themes/packed/rngs/stop.rng +0 -1
- data/cockpit/themes/packed/rngs/terminate.rng +0 -1
- data/cockpit/themes/preset/rngs/alternative.rng +0 -1
- data/cockpit/themes/preset/rngs/choose.rng +0 -1
- data/cockpit/themes/preset/rngs/critical.rng +0 -1
- data/cockpit/themes/preset/rngs/escape.rng +0 -1
- data/cockpit/themes/preset/rngs/group.rng +0 -1
- data/cockpit/themes/preset/rngs/loop.rng +0 -1
- data/cockpit/themes/preset/rngs/manipulate.rng +0 -1
- data/cockpit/themes/preset/rngs/otherwise.rng +0 -1
- data/cockpit/themes/preset/rngs/parallel.rng +0 -1
- data/cockpit/themes/preset/rngs/parallel_branch.rng +0 -1
- data/cockpit/themes/preset/rngs/stop.rng +0 -1
- data/cockpit/themes/preset/rngs/terminate.rng +0 -1
- data/lib/cpee/empty_workflow.rb +0 -28
- data/lib/cpee/handler_notifications.rb +0 -47
- data/lib/cpee/handler_properties.rb +0 -50
- data/lib/cpee/instantiation.rb +0 -369
- data/lib/cpee/processtransformation/bpel/Repository/booking.bpel +0 -125
- data/lib/cpee/processtransformation/bpel/Repository/booking.wsdl +0 -72
- data/lib/cpee/processtransformation/bpel/Repository/booking/airline.wsdl +0 -71
- data/lib/cpee/processtransformation/bpel/Repository/booking/hotel.wsdl +0 -64
- data/lib/cpee/processtransformation/bpel/Repository/booking/report.wsdl +0 -71
- data/lib/cpee/processtransformation/bpel/bpel2wee.rb +0 -34
- data/lib/cpee/processtransformation/bpel/bpelserver.ru +0 -64
- data/lib/cpee/processtransformation/bpel/bpelserver.xml +0 -70
- data/lib/cpee/processtransformation/bpel/lib/BPEL_Transform.rb +0 -367
- data/lib/cpee/processtransformation/bpmn2.rb +0 -297
- data/lib/cpee/processtransformation/cpee.rb +0 -119
- data/lib/cpee/processtransformation/structures.rb +0 -465
- data/lib/cpee/processtransformation/target.rb +0 -50
- data/log/azure.rb +0 -10
- data/log/azure_logger.rb +0 -136
- data/log/chain.xml +0 -27
- data/log/elasticsearch.rb +0 -15
- data/log/elasticsearch_logging.rb +0 -377
- data/log/legacy/test_es.rb +0 -26
- data/log/legacy/test_split.rb +0 -211
- data/log/log.xml +0 -13
- data/log/non_tamp.rb +0 -156
- data/log/sic.rb +0 -64
- data/log/template.xes_xml +0 -23
- data/log/template.xes_yaml +0 -28
- data/log/trace.yaml +0 -17717
- data/log/trace_sic.yaml +0 -18343
- data/log/xes_xml.rb +0 -121
- data/log/xes_yaml.rb +0 -96
- data/server/handlerwrappers/soap.rb +0 -146
- data/server/resources/properties.schema.active +0 -139
- data/server/resources/properties.schema.finished +0 -139
- data/server/resources/properties.schema.inactive +0 -136
- data/server/transformation_dslx.xsl +0 -790
- data/test/callback.rb +0 -9
data/cpee.gemspec
CHANGED
@@ -1,31 +1,30 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cpee"
|
3
|
-
s.version = "
|
3
|
+
s.version = "2.0"
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.license = "LGPL-3.0"
|
6
|
-
s.summary = "Preliminary release of cloud process execution engine (cpee). If you just need workflow execution, without a rest
|
6
|
+
s.summary = "Preliminary release of cloud process execution engine (cpee.org). If you just need workflow execution, without a rest service exposing it, then use WEEL."
|
7
7
|
|
8
8
|
s.description = "see http://cpee.org"
|
9
9
|
|
10
|
-
s.files = Dir['{example/**/*,server/**/*,tools/**/*,lib/**/*,cockpit/**/*,cockpit/themes/*/*/*,contrib/logo*,contrib/Screen
|
10
|
+
s.files = Dir['{example/**/*,server/**/*,tools/**/*,lib/**/*,cockpit/**/*,cockpit/themes/*/*/*,contrib/logo*,contrib/Screen*}'] - Dir['{server/instances/**/*,cockpit/js_libs/**/*}'] + %w(COPYING FEATURES.md INSTALL.md Rakefile cpee.gemspec README.md AUTHORS)
|
11
11
|
s.require_path = 'lib'
|
12
|
-
s.extra_rdoc_files = ['README']
|
12
|
+
s.extra_rdoc_files = ['README.md']
|
13
13
|
s.bindir = 'tools'
|
14
14
|
s.executables = ['cpee']
|
15
15
|
s.test_files = Dir['{test/*,test/*/tc_*.rb}']
|
16
16
|
|
17
17
|
s.required_ruby_version = '>=2.4.0'
|
18
18
|
|
19
|
-
s.authors = ['Juergen eTM Mangler','Ralph Vigne','Gerhard Stuermer'
|
19
|
+
s.authors = ['Juergen eTM Mangler','Ralph Vigne','Gerhard Stuermer']
|
20
20
|
|
21
21
|
s.email = 'juergen.mangler@gmail.com'
|
22
22
|
s.homepage = 'http://cpee.org/'
|
23
23
|
|
24
|
-
s.add_runtime_dependency 'riddl', '~> 0.
|
25
|
-
s.add_runtime_dependency 'weel', '~> 1.99', '>= 1.99.
|
26
|
-
s.add_runtime_dependency '
|
27
|
-
s.add_runtime_dependency 'xml-smart', '>=0.4.3', '~>0'
|
28
|
-
s.add_runtime_dependency 'highline', '~> 1.6'
|
24
|
+
s.add_runtime_dependency 'riddl', '~> 0.105'
|
25
|
+
s.add_runtime_dependency 'weel', '~> 1.99', '>= 1.99.90'
|
26
|
+
s.add_runtime_dependency 'highline', '~> 2.0'
|
29
27
|
s.add_runtime_dependency 'json', '~>2.1'
|
28
|
+
s.add_runtime_dependency 'redis', '~> 4.1'
|
30
29
|
s.add_runtime_dependency 'rubyzip', '~>1.2'
|
31
30
|
end
|
@@ -14,9 +14,19 @@
|
|
14
14
|
<http://www.gnu.org/licenses/>.
|
15
15
|
-->
|
16
16
|
|
17
|
-
<
|
18
|
-
<
|
19
|
-
<
|
20
|
-
|
21
|
-
|
22
|
-
</
|
17
|
+
<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" xmlns:doc="http://cpee.org/ns/documentation">
|
18
|
+
<message name="callbacks">
|
19
|
+
<parameter name="callbacks" mimetype="text/xml" handler="http://riddl.org/ns/handlers/relaxng">
|
20
|
+
<xi:include href="callbacks/callbacks.rng"/>
|
21
|
+
</parameter>
|
22
|
+
</message>
|
23
|
+
|
24
|
+
<resource>
|
25
|
+
<doc:documentation>xb</doc:documentation>
|
26
|
+
<get in="*" out="callbacks"/>
|
27
|
+
<resource>
|
28
|
+
<put in="*"/>
|
29
|
+
</resource>
|
30
|
+
</resource>
|
31
|
+
|
32
|
+
</description>
|
@@ -17,15 +17,9 @@
|
|
17
17
|
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
18
18
|
<start>
|
19
19
|
<element name="callbacks">
|
20
|
-
<attribute name="details">
|
21
|
-
<choice>
|
22
|
-
<value>debug</value>
|
23
|
-
<value>production</value>
|
24
|
-
</choice>
|
25
|
-
</attribute>
|
26
20
|
<zeroOrMore>
|
27
21
|
<ref name="callback"/>
|
28
|
-
</zeroOrMore>
|
22
|
+
</zeroOrMore>
|
29
23
|
</element>
|
30
24
|
</start>
|
31
25
|
|
@@ -36,6 +30,6 @@
|
|
36
30
|
</attribute>
|
37
31
|
<data type="string"/>
|
38
32
|
</element>
|
39
|
-
</define>
|
33
|
+
</define>
|
40
34
|
|
41
35
|
</grammar>
|
data/lib/cpee.xml
CHANGED
@@ -19,20 +19,26 @@
|
|
19
19
|
<xi:include href="engine.xml"/>
|
20
20
|
</interface>
|
21
21
|
<interface name="properties">
|
22
|
-
<xi:include href="
|
22
|
+
<xi:include href="properties.xml"/>
|
23
|
+
</interface>
|
24
|
+
<interface name="callbacks">
|
25
|
+
<xi:include href="callbacks.xml"/>
|
23
26
|
</interface>
|
24
27
|
<interface name="notifications">
|
25
|
-
<xi:include href="http://www.riddl.org/ns/common-patterns/notifications-producer/
|
28
|
+
<xi:include href="http://www.riddl.org/ns/common-patterns/notifications-producer/2.0/producer.xml"/>
|
26
29
|
</interface>
|
27
30
|
|
28
31
|
<facade>
|
29
32
|
<tile>
|
30
33
|
<layer name="main"/>
|
31
34
|
<layer name="properties">
|
32
|
-
<apply-to
|
35
|
+
<apply-to>/\d+/properties</apply-to>
|
36
|
+
</layer>
|
37
|
+
<layer name="callbacks">
|
38
|
+
<apply-to>/\d+/callbacks</apply-to>
|
33
39
|
</layer>
|
34
40
|
<layer name="notifications">
|
35
|
-
<apply-to
|
41
|
+
<apply-to>/\d+</apply-to>
|
36
42
|
</layer>
|
37
43
|
</tile>
|
38
44
|
</facade>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'weel'
|
2
|
+
|
3
|
+
class AttributesHelper
|
4
|
+
def translate(__attributes__,__dataelements__,__endpoints__)
|
5
|
+
@data = WEEL::ReadHash.new(__dataelements__)
|
6
|
+
@endpoints = WEEL::ReadHash.new(__endpoints__)
|
7
|
+
@attributes = WEEL::ReadHash.new(__attributes__)
|
8
|
+
__attributes__.transform_values do |v|
|
9
|
+
v.gsub(/(!(attributes|data|endpoints)\.[\w_]+)/) do |m|
|
10
|
+
eval(m[1..-1])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def data
|
16
|
+
@data
|
17
|
+
end
|
18
|
+
|
19
|
+
def endpoints
|
20
|
+
@endpoints
|
21
|
+
end
|
22
|
+
|
23
|
+
def attributes
|
24
|
+
@attributes
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
data/lib/cpee/controller.rb
CHANGED
@@ -12,128 +12,51 @@
|
|
12
12
|
# CPEE (file COPYING in the main directory). If not, see
|
13
13
|
# <http://www.gnu.org/licenses/>.
|
14
14
|
|
15
|
+
require 'weel'
|
15
16
|
require 'json'
|
16
|
-
require '
|
17
|
+
require 'redis'
|
17
18
|
require 'securerandom'
|
18
|
-
require
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
require 'riddl/client'
|
20
|
+
require_relative 'value_helper'
|
21
|
+
require_relative 'attributes_helper'
|
22
|
+
require_relative 'message'
|
23
|
+
|
24
|
+
require 'ostruct'
|
25
|
+
class ParaStruct < OpenStruct
|
26
|
+
def to_json(*a)
|
27
|
+
table.to_json
|
28
|
+
end
|
29
|
+
end
|
30
|
+
def →(a); ParaStruct.new(a); end
|
31
|
+
def ⭐(a); ParaStruct.new(a); end
|
23
32
|
|
24
33
|
module CPEE
|
25
34
|
|
26
|
-
class AttributesHelper #{{{
|
27
|
-
def translate(__attributes__,__dataelements__,__endpoints__)
|
28
|
-
@data = WEEL::ReadHash.new(__dataelements__)
|
29
|
-
@endpoints = WEEL::ReadHash.new(__endpoints__)
|
30
|
-
@attributes = WEEL::ReadHash.new(__attributes__)
|
31
|
-
__attributes__.transform_values do |v|
|
32
|
-
v.gsub(/(!(attributes|data|endpoints)\.[\w_]+)/) do |m|
|
33
|
-
eval(m[1..-1])
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def data
|
39
|
-
@data
|
40
|
-
end
|
41
|
-
|
42
|
-
def endpoints
|
43
|
-
@endpoints
|
44
|
-
end
|
45
|
-
|
46
|
-
def attributes
|
47
|
-
@attributes
|
48
|
-
end
|
49
|
-
end #}}}
|
50
|
-
|
51
35
|
class Controller
|
36
|
+
def initialize(id,dir,opts)
|
37
|
+
@redis = Redis.new(path: opts[:redis_path], db: opts[:redis_db])
|
38
|
+
@votes = []
|
52
39
|
|
53
|
-
def initialize(id,opts)
|
54
|
-
@directory = opts[:instances] + "/#{id}/"
|
55
40
|
@id = id
|
56
|
-
|
57
|
-
@votes = {}
|
58
|
-
@votes_results = {}
|
59
|
-
@communication = {}
|
60
|
-
@callbacks = {}
|
61
|
-
@positions = []
|
41
|
+
|
62
42
|
@attributes = {}
|
43
|
+
@redis.keys("instance:#{id}/attributes/*").each do |key|
|
44
|
+
@attributes[File.basename(key)] = @redis.get(key)
|
45
|
+
end
|
46
|
+
|
63
47
|
@attributes_helper = AttributesHelper.new
|
64
48
|
@thread = nil
|
65
|
-
@mutex = Mutex.new
|
66
49
|
@opts = opts
|
67
|
-
|
68
|
-
@
|
69
|
-
{
|
70
|
-
:inactive => opts[:properties_schema_inactive],
|
71
|
-
:active => opts[:properties_schema_active],
|
72
|
-
:finished => opts[:properties_schema_finished]
|
73
|
-
},
|
74
|
-
@directory + '/properties.xml',
|
75
|
-
opts[:properties_init]
|
76
|
-
)
|
77
|
-
@notifications = Riddl::Utils::Notifications::Producer::Backend.new(
|
78
|
-
opts[:topics],
|
79
|
-
@directory + '/notifications/',
|
80
|
-
opts[:notifications_init]
|
81
|
-
)
|
82
|
-
unless ['stopped','ready','finished','abandoned'].include?(@properties.data.find("string(/p:properties/p:state)"))
|
83
|
-
@properties.modify do |doc|
|
84
|
-
doc.find("/p:properties/p:state").first.text = 'stopped'
|
85
|
-
end
|
86
|
-
end
|
87
|
-
@uuid = sync_uuid!
|
88
|
-
if @properties.data.find("string(/p:properties/p:state)") == "finished"
|
89
|
-
@instance = nil
|
90
|
-
else
|
91
|
-
@instance = EmptyWorkflow.new(self)
|
92
|
-
|
93
|
-
@notifications.subscriptions.keys.each do |key|
|
94
|
-
self.unserialize_notifications!(:cre,key)
|
95
|
-
end
|
96
|
-
|
97
|
-
unserialize_handlerwrapper!
|
98
|
-
unserialize_dataelements!
|
99
|
-
unserialize_endpoints!
|
100
|
-
unserialize_dsl!
|
101
|
-
unserialize_positions!
|
102
|
-
unserialize_attributes!
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def help
|
107
|
-
"\033[1m\033[31mpm or public_methods(false)\033[0m\033[0m\n Methods.\n" +
|
108
|
-
"\033[1m\033[31miv or instance_variables\033[0m\033[0m\n Attributes.\n" +
|
109
|
-
"\033[1m\033[31mgc or GC.stat\033[0m\033[0m\n GC stats to look for memleaks. Google for 'GC.stat ruby'.\n"
|
110
|
-
end
|
111
|
-
def pm
|
112
|
-
public_methods(false)
|
113
|
-
end
|
114
|
-
def iv
|
115
|
-
instance_variables
|
116
|
-
end
|
117
|
-
def gc
|
118
|
-
x = GC.stat
|
119
|
-
y = {}
|
120
|
-
y[:heap_live_slots] = x[:heap_live_slots]
|
121
|
-
y[:total_allocated_objects] = x[:total_allocated_objects]
|
122
|
-
y[:total_freed_objects] = x[:total_freed_objects]
|
123
|
-
y
|
50
|
+
@instance = nil
|
51
|
+
@loop_guard = {}
|
124
52
|
end
|
125
53
|
|
126
54
|
attr_reader :id
|
127
|
-
attr_reader :notifications
|
128
|
-
attr_reader :properties
|
129
|
-
attr_reader :callbacks
|
130
|
-
attr_reader :mutex
|
131
55
|
attr_reader :attributes
|
132
|
-
attr_reader :
|
56
|
+
attr_reader :loop_guard
|
133
57
|
|
134
|
-
def
|
135
|
-
|
136
|
-
x.class == String ? x : x.pretty_inspect
|
58
|
+
def uuid
|
59
|
+
@attributes['uuid']
|
137
60
|
end
|
138
61
|
|
139
62
|
def attributes_translated
|
@@ -149,11 +72,14 @@ module CPEE
|
|
149
72
|
def instance_url
|
150
73
|
File.join(@opts[:url].to_s,@id.to_s)
|
151
74
|
end
|
75
|
+
def instance_id
|
76
|
+
@id
|
77
|
+
end
|
152
78
|
def base
|
153
79
|
base_url
|
154
80
|
end
|
155
|
-
def instance
|
156
|
-
|
81
|
+
def instance=(inst)
|
82
|
+
@instance = inst
|
157
83
|
end
|
158
84
|
def endpoints
|
159
85
|
@instance.endpoints
|
@@ -162,515 +88,106 @@ module CPEE
|
|
162
88
|
@instance.data
|
163
89
|
end
|
164
90
|
|
165
|
-
def
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
@thread = @instance.replay
|
173
|
-
end # }}}
|
174
|
-
|
175
|
-
def start # {{{
|
176
|
-
@thread.join if !@thread.nil? && @thread.alive?
|
177
|
-
unless @positions.empty?
|
178
|
-
@instance.search(@positions)
|
91
|
+
def start
|
92
|
+
if vote("state/change")
|
93
|
+
@thread = @instance.start
|
94
|
+
@thread.join
|
95
|
+
else
|
96
|
+
@thread = @instance.stop
|
97
|
+
@thread.join
|
179
98
|
end
|
180
|
-
|
181
|
-
end # }}}
|
99
|
+
end
|
182
100
|
|
183
|
-
def stop
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
c.callback
|
191
|
-
true
|
192
|
-
else
|
193
|
-
false
|
101
|
+
def stop
|
102
|
+
### tell the instance to stop
|
103
|
+
@instance.stop
|
104
|
+
### end all votes or it will not work
|
105
|
+
Thread.new do # doing stuff in trap context is a nono. but in a thread its fine :-)
|
106
|
+
@votes.each do |key|
|
107
|
+
CPEE::Message::send(:'vote-response',key,base,@id,uuid,info,true,@redis)
|
194
108
|
end
|
195
109
|
end
|
196
110
|
@thread.join if !@thread.nil? && @thread.alive?
|
197
|
-
@callback = [] # everything should be empty now
|
198
|
-
end # }}}
|
199
|
-
|
200
|
-
def info
|
201
|
-
@properties.data.find("string(/p:properties/p:attributes/p:info)")
|
202
|
-
end
|
203
|
-
def info=(text)
|
204
|
-
@properties.modify do |doc|
|
205
|
-
node = doc.find("/p:properties/p:attributes/p:info").first
|
206
|
-
node.text = text if node
|
207
|
-
end
|
208
|
-
end
|
209
|
-
def state
|
210
|
-
@properties.data.find("string(/p:properties/p:state)")
|
211
|
-
end
|
212
|
-
def state_changed
|
213
|
-
(str = @properties.data.find("string(/p:properties/p:state/@changed)")).empty? ? Time.at(0).xmlschema : str
|
214
|
-
end
|
215
|
-
def state_change!(state=nil)
|
216
|
-
@properties.modify do |doc|
|
217
|
-
doc.find("/p:properties/p:state").each do |ele|
|
218
|
-
ele.attributes['changed'] = Time.now.xmlschema
|
219
|
-
ele.text = state if state
|
220
|
-
end
|
221
|
-
end
|
222
111
|
end
|
223
112
|
|
224
|
-
def
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
pos = doc.find("/p:properties/p:positions").first
|
260
|
-
pos.children.delete_all!
|
261
|
-
@positions = @instance.positions
|
262
|
-
@instance.positions.each do |p|
|
263
|
-
pos.add("#{p.position}",p.detail,'passthrough' => p.passthrough.to_s.empty? ? nil : p.passthrough)
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end # }}}
|
267
|
-
def serialize_status! #{{{
|
268
|
-
@properties.modify do |doc|
|
269
|
-
node = doc.find("/p:properties/p:status/p:id").first
|
270
|
-
node.text = @instance.status.id
|
271
|
-
node = doc.find("/p:properties/p:status/p:message").first
|
272
|
-
node.text = @instance.status.message
|
273
|
-
end
|
274
|
-
end #}}}
|
275
|
-
|
276
|
-
def unserialize_notifications!(op,key)# {{{
|
277
|
-
case op
|
278
|
-
when :del
|
279
|
-
@notifications.subscriptions[key].delete if @notifications.subscriptions.include?(key)
|
280
|
-
|
281
|
-
@communication[key].io.close_connection if @communication[key].class == Riddl::Utils::Notifications::Producer::WS
|
282
|
-
@communication.delete(key)
|
283
|
-
|
284
|
-
@events.each do |eve,keys|
|
285
|
-
keys.delete_if{|k,v| key == k}
|
286
|
-
end
|
287
|
-
@votes.each do |eve,keys|
|
288
|
-
keys.delete_if do |k,v|
|
289
|
-
if key == k
|
290
|
-
@callbacks.each{|voteid,cb|cb.delete_if!(eve,k)}
|
291
|
-
true
|
292
|
-
end
|
293
|
-
end
|
294
|
-
end
|
295
|
-
when :upd
|
296
|
-
if @notifications.subscriptions.include?(key)
|
297
|
-
url = @communication[key]
|
298
|
-
evs = []
|
299
|
-
vos = []
|
300
|
-
@events.each { |e,v| evs << e }
|
301
|
-
@votes.each { |e,v| vos << e }
|
302
|
-
@notifications.subscriptions[key].read do |doc|
|
303
|
-
turl = doc.find('string(/n:subscription/@url)')
|
304
|
-
url = turl == '' ? url : turl
|
305
|
-
@communication[key] = url
|
306
|
-
doc.find('/n:subscription/n:topic').each do |t|
|
307
|
-
t.find('n:event').each do |e|
|
308
|
-
@events["#{t.attributes['id']}/#{e}"] ||= {}
|
309
|
-
@events["#{t.attributes['id']}/#{e}"][key] = url
|
310
|
-
evs.delete("#{t.attributes['id']}/#{e}")
|
311
|
-
end
|
312
|
-
t.find('n:vote').each do |e|
|
313
|
-
@votes["#{t.attributes['id']}/#{e}"] ||= {}
|
314
|
-
@votes["#{t.attributes['id']}/#{e}"][key] = url
|
315
|
-
vos.delete("#{t.attributes['id']}/#{e}")
|
316
|
-
end
|
317
|
-
end
|
318
|
-
end
|
319
|
-
evs.each { |e| @events[e].delete(key) if @events[e] }
|
320
|
-
vos.each do |e|
|
321
|
-
@callbacks.each{|voteid,cb|cb.delete_if!(e,key)}
|
322
|
-
@votes[e].delete(key) if @votes[e]
|
323
|
-
end
|
324
|
-
end
|
325
|
-
when :cre
|
326
|
-
@notifications.subscriptions[key].read do |doc|
|
327
|
-
turl = doc.find('string(/n:subscription/@url)')
|
328
|
-
url = turl == '' ? nil : turl
|
329
|
-
@communication[key] = url
|
330
|
-
doc.find('/n:subscription/n:topic').each do |t|
|
331
|
-
t.find('n:event').each do |e|
|
332
|
-
@events["#{t.attributes['id']}/#{e}"] ||= {}
|
333
|
-
@events["#{t.attributes['id']}/#{e}"][key] = (url == "" ? nil : url)
|
334
|
-
end
|
335
|
-
t.find('n:vote').each do |e|
|
336
|
-
@votes["#{t.attributes['id']}/#{e}"] ||= {}
|
337
|
-
@votes["#{t.attributes['id']}/#{e}"][key] = url
|
338
|
-
end
|
339
|
-
end
|
340
|
-
end
|
341
|
-
end
|
342
|
-
end # }}}
|
343
|
-
|
344
|
-
def unserialize_attributes! #{{{
|
345
|
-
@attributes = {}
|
346
|
-
@properties.data.find("/p:properties/p:attributes/p:*").map do |ele|
|
347
|
-
@attributes[ele.qname.name.to_sym] = ele.text
|
348
|
-
end
|
349
|
-
uuid = @properties.data.find("/p:properties/p:attributes/p:uuid")
|
350
|
-
if uuid.empty? || uuid.length != 1 || uuid.first.text != @uuid
|
351
|
-
@properties.modify do |doc|
|
352
|
-
attr = doc.find("/p:properties/p:attributes").first
|
353
|
-
attr.find('p:uuid').delete_all!
|
354
|
-
attr.prepend('uuid',@uuid)
|
355
|
-
end
|
356
|
-
end
|
357
|
-
end #}}}
|
358
|
-
def unserialize_dataelements! #{{{
|
359
|
-
@instance.data.clear
|
360
|
-
@properties.data.find("/p:properties/p:dataelements/p:*").each do |e|
|
361
|
-
@instance.data[e.qname.to_sym] = ValueHelper::parse(e.text)
|
362
|
-
end
|
363
|
-
end #}}}
|
364
|
-
def unserialize_endpoints! #{{{
|
365
|
-
@instance.endpoints.clear
|
366
|
-
@properties.data.find("/p:properties/p:endpoints/p:*").each do |e|
|
367
|
-
@instance.endpoints[e.qname.to_sym] = e.text
|
368
|
-
end
|
369
|
-
end #}}}
|
370
|
-
def unserialize_state! #{{{
|
371
|
-
state = 'ready'
|
372
|
-
@properties.modify do |doc|
|
373
|
-
node = doc.find("/p:properties/p:state").first
|
374
|
-
state = node.text
|
375
|
-
end
|
376
|
-
if call_vote("state/change", :instance => @id, :info => info, :state => state, :attributes => attributes_translated)
|
377
|
-
case state
|
378
|
-
when 'stopping'
|
379
|
-
stop
|
380
|
-
when 'running'
|
381
|
-
start
|
382
|
-
when 'simulating'
|
383
|
-
sim
|
384
|
-
when 'replaying'
|
385
|
-
replay
|
386
|
-
when 'ready'
|
387
|
-
@instance.state_signal
|
388
|
-
when 'abandoned'
|
389
|
-
@instance.abandon
|
390
|
-
end
|
391
|
-
else
|
392
|
-
if node = @properties.data.find("/p:properties/p:state").first
|
393
|
-
node.text = @instance.state_signal
|
394
|
-
end
|
395
|
-
end
|
396
|
-
end #}}}
|
397
|
-
def unserialize_handlerwrapper! #{{{
|
398
|
-
hw = nil
|
399
|
-
begin
|
400
|
-
hw = @properties.data.find("string(/p:properties/p:handlerwrapper)")
|
401
|
-
@instance.handlerwrapper = eval(hw)
|
402
|
-
rescue => e
|
403
|
-
@instance.handlerwrapper = DefaultHandlerWrapper
|
404
|
-
end
|
405
|
-
if hw != @instance.handlerwrapper
|
406
|
-
@properties.modify do |doc|
|
407
|
-
node = doc.find("/p:properties/p:handlerwrapper").first
|
408
|
-
node.text = @instance.handlerwrapper.to_s
|
409
|
-
end
|
410
|
-
end
|
411
|
-
end #}}}
|
412
|
-
def unserialize_positions! #{{{
|
413
|
-
@positions = []
|
414
|
-
@properties.data.find("/p:properties/p:positions/p:*").each do |e|
|
415
|
-
val = e.text.split(';')
|
416
|
-
@positions << ::WEEL::Position.new(e.qname.to_s.to_sym,e.text.to_sym,e.attributes['passthrough'])
|
417
|
-
end
|
418
|
-
end #}}}
|
419
|
-
def unserialize_dsl! #{{{
|
420
|
-
@instance.description = @properties.data.find("string(/p:properties/p:dsl)")
|
421
|
-
end #}}}
|
422
|
-
def unserialize_description! #{{{
|
423
|
-
dsl = nil
|
424
|
-
nots = []
|
425
|
-
@properties.modify do |doc|
|
426
|
-
begin
|
427
|
-
dsl = doc.find("/p:properties/p:dsl").first
|
428
|
-
dslx = doc.find("/p:properties/p:dslx").first
|
429
|
-
desc = doc.find("/p:properties/p:description").first
|
430
|
-
tdesc = doc.find("/p:properties/p:transformation/p:description").first
|
431
|
-
tdata = doc.find("/p:properties/p:transformation/p:dataelements").first
|
432
|
-
tendp = doc.find("/p:properties/p:transformation/p:endpoints").first
|
433
|
-
|
434
|
-
tdesctype = tdesc.attributes['type']
|
435
|
-
tdatatype = tdata.attributes['type']
|
436
|
-
tendptype = tendp.attributes['type']
|
437
|
-
|
438
|
-
if desc.children.empty?
|
439
|
-
tdesctype = tdatatype = tendptype = 'clean'
|
440
|
-
end
|
441
|
-
|
442
|
-
### description transformation, including dslx to dsl
|
443
|
-
addit = if tdesctype == 'copy' || tdesc.empty?
|
444
|
-
desc.children.first.to_doc.root
|
445
|
-
elsif tdesctype == 'rest' && !tdesc.empty?
|
446
|
-
srv = Riddl::Client.interface(tdesc.text,@opts[:transformation_service])
|
447
|
-
status, res = srv.post [
|
448
|
-
Riddl::Parameter::Complex.new("description","text/xml",desc.children.first.dump),
|
449
|
-
Riddl::Parameter::Simple.new("type","description")
|
450
|
-
]
|
451
|
-
if status >= 200 && status < 300
|
452
|
-
XML::Smart::string(res[0].value.read).root
|
453
|
-
else
|
454
|
-
raise 'Could not extract dslx'
|
455
|
-
end
|
456
|
-
elsif tdesctype == 'xslt' && !tdesc.empty?
|
457
|
-
trans = XML::Smart::open_unprotected(tdesc.text)
|
458
|
-
desc.children.first.to_doc.transform_with(trans).root
|
459
|
-
elsif tdesctype == 'clean'
|
460
|
-
XML::Smart::open_unprotected(@opts[:empty_dslx]).root
|
461
|
-
else
|
462
|
-
nil
|
463
|
-
end
|
464
|
-
unless addit.nil?
|
465
|
-
dslx.children.delete_all!
|
466
|
-
dslx.add addit
|
467
|
-
trans = XML::Smart::open_unprotected(@opts[:transformation_dslx])
|
468
|
-
dsl.text = dslx.to_doc.transform_with(trans)
|
469
|
-
@instance.description = dsl.text
|
470
|
-
end
|
471
|
-
|
472
|
-
### dataelements extraction
|
473
|
-
addit = if tdatatype == 'rest' && !tdata.empty?
|
474
|
-
srv = Riddl::Client.interface(tdata.text,@opts[:transformation_service])
|
475
|
-
status, res = srv.post [
|
476
|
-
Riddl::Parameter::Complex.new("description","text/xml",desc.children.first.dump),
|
477
|
-
Riddl::Parameter::Simple.new("type","dataelements")
|
478
|
-
]
|
479
|
-
if status >= 200 && status < 300
|
480
|
-
res
|
481
|
-
else
|
482
|
-
raise 'Could not extract dataelements'
|
483
|
-
end
|
484
|
-
elsif tdatatype == 'xslt' && !tdata.empty?
|
485
|
-
trans = XML::Smart::open_unprotected(tdata.text)
|
486
|
-
desc.children.first.to_doc.transform_with(trans)
|
487
|
-
elsif tdatatype == 'clean'
|
488
|
-
[]
|
489
|
-
else
|
490
|
-
nil
|
491
|
-
end
|
492
|
-
unless addit.nil?
|
493
|
-
node = doc.find("/p:properties/p:dataelements").first
|
494
|
-
node.children.delete_all!
|
495
|
-
@instance.data.clear
|
496
|
-
addit.each_slice(2).each do |k,v|
|
497
|
-
@instance.data[k.value.to_sym] = ValueHelper::parse(v.value)
|
498
|
-
node.add(k.value,ValueHelper::generate(v.value))
|
499
|
-
end
|
500
|
-
nots << ["dataelements/change", {:instance => instance, :changed => JSON::generate(@instance.data)}]
|
501
|
-
end
|
502
|
-
|
503
|
-
### endpoints extraction
|
504
|
-
addit = if tendptype == 'rest' && !tdata.empty?
|
505
|
-
srv = Riddl::Client.interface(tendp.text,@opts[:transformation_service])
|
506
|
-
status, res = srv.post [
|
507
|
-
Riddl::Parameter::Complex.new("description","text/xml",desc.children.first.dump),
|
508
|
-
Riddl::Parameter::Simple.new("type","endpoints")
|
509
|
-
]
|
510
|
-
if status >= 200 && status < 300
|
511
|
-
res
|
512
|
-
else
|
513
|
-
raise 'Could not extract endpoints'
|
514
|
-
end
|
515
|
-
elsif tendptype == 'xslt' && !tdata.empty?
|
516
|
-
trans = XML::Smart::open_unprotected(tendp.text)
|
517
|
-
desc.children.first.to_doc.transform_with(trans)
|
518
|
-
elsif tendptype == 'clean'
|
519
|
-
[]
|
520
|
-
else
|
521
|
-
nil
|
522
|
-
end
|
523
|
-
unless addit.nil?
|
524
|
-
node = doc.find("/p:properties/p:endpoints").first
|
525
|
-
node.children.delete_all!
|
526
|
-
@instance.endpoints.clear
|
527
|
-
addit.each_slice(2).each do |k,v|
|
528
|
-
@instance.endpoints[k.value.to_sym] = ValueHelper::parse(v.value)
|
529
|
-
node.add(k.value,ValueHelper::generate(v.value))
|
113
|
+
def info
|
114
|
+
@attributes['info']
|
115
|
+
end
|
116
|
+
|
117
|
+
def notify(what,content={})
|
118
|
+
content[:attributes] = attributes_translated
|
119
|
+
CPEE::Message::send(:event,what,base,@id,uuid,info,content,@redis)
|
120
|
+
end
|
121
|
+
|
122
|
+
def vote(what,content={})
|
123
|
+
topic, name = what.split('/')
|
124
|
+
handler = File.join(topic,'vote',name)
|
125
|
+
votes = []
|
126
|
+
@redis.smembers("instance:#{id}/handlers/#{handler}").each do |client|
|
127
|
+
voteid = Digest::MD5.hexdigest(Kernel::rand().to_s)
|
128
|
+
content[:key] = voteid
|
129
|
+
content[:subscription] = client
|
130
|
+
votes << voteid
|
131
|
+
CPEE::Message::send(:vote,what,base,@id,uuid,info,content,@redis)
|
132
|
+
end
|
133
|
+
|
134
|
+
if votes.length > 0
|
135
|
+
@votes += votes
|
136
|
+
psredis = Redis.new(path: @opts[:redis_path], db: @opts[:redis_db])
|
137
|
+
collect = []
|
138
|
+
psredis.subscribe(votes.map{|e| ['vote-response:' + e.to_s, 'vote-end:' + e.to_s] }.flatten) do |on|
|
139
|
+
on.message do |what, message|
|
140
|
+
index = message.index(' ')
|
141
|
+
mess = message[index+1..-1]
|
142
|
+
m = JSON.parse(mess)
|
143
|
+
collect << (m['content'] == 'true' || false)
|
144
|
+
@votes.delete m['name']
|
145
|
+
cancel_callback m['name']
|
146
|
+
if collect.length >= votes.length
|
147
|
+
psredis.unsubscribe
|
530
148
|
end
|
531
|
-
nots << ["endpoints/change", {:instance => instance, :changed => JSON::generate(@instance.endpoints)}]
|
532
149
|
end
|
533
|
-
nots << ["description/change", { :instance => instance }]
|
534
|
-
rescue => err
|
535
|
-
nots << ["description/error", { :instance => instance, :message => err.message }]
|
536
150
|
end
|
537
|
-
|
538
|
-
nots
|
539
|
-
end #}}}
|
540
|
-
|
541
|
-
def sync_uuid! #{{{
|
542
|
-
val = SecureRandom.uuid
|
543
|
-
uuid = @properties.data.find("/p:properties/p:attributes/p:uuid")
|
544
|
-
if uuid.empty?
|
545
|
-
@properties.modify { |doc| doc.find("/p:properties/p:attributes").first.prepend('p:uuid',val) }
|
546
|
-
val
|
151
|
+
!collect.include?(false)
|
547
152
|
else
|
548
|
-
|
549
|
-
end
|
550
|
-
end #}}}
|
551
|
-
|
552
|
-
def notify(what,content={})# {{{
|
553
|
-
item = @events[what]
|
554
|
-
|
555
|
-
if item
|
556
|
-
item.each do |ke,ur|
|
557
|
-
Thread.new(ke,ur) do |key,url|
|
558
|
-
notf = build_notification(key,what,content,'event')
|
559
|
-
if url.class == String
|
560
|
-
client = Riddl::Client.new(url,'http://riddl.org/ns/common-patterns/notifications-consumer/1.0/consumer.xml')
|
561
|
-
params = notf.map{|ke,va|Riddl::Parameter::Simple.new(ke,va)}
|
562
|
-
params << Riddl::Header.new("CPEE-BASE",self.base)
|
563
|
-
params << Riddl::Header.new("CPEE-INSTANCE",self.instance)
|
564
|
-
params << Riddl::Header.new("CPEE-INSTANCE-URL",self.instance_url)
|
565
|
-
params << Riddl::Header.new("CPEE-INSTANCE-UUID",self.uuid)
|
566
|
-
client.post params
|
567
|
-
elsif url.class == Riddl::Utils::Notifications::Producer::WS
|
568
|
-
e = XML::Smart::string("<event/>")
|
569
|
-
notf.each do |k,v|
|
570
|
-
e.root.add(k,v)
|
571
|
-
end
|
572
|
-
url.send(e.to_s) rescue nil
|
573
|
-
end
|
574
|
-
end
|
575
|
-
end
|
153
|
+
true
|
576
154
|
end
|
577
|
-
end
|
578
|
-
|
579
|
-
def call_vote(what,content={})# {{{
|
580
|
-
voteid = Digest::MD5.hexdigest(Kernel::rand().to_s)
|
581
|
-
item = @votes[what]
|
582
|
-
if item && item.length > 0
|
583
|
-
continue = WEEL::Continue.new
|
584
|
-
@votes_results[voteid] = []
|
585
|
-
inum = 0
|
586
|
-
item.each do |key,url|
|
587
|
-
if url.class == String
|
588
|
-
inum += 1
|
589
|
-
elsif url.class == Riddl::Utils::Notifications::Producer::WS
|
590
|
-
inum += 1 unless url.closed?
|
591
|
-
end
|
592
|
-
end
|
593
|
-
|
594
|
-
item.each do |key,url|
|
155
|
+
end
|
595
156
|
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
157
|
+
def callback(hw,key,content)
|
158
|
+
CPEE::Message::send(:callback,'activity/content',base,@id,uuid,info,content.merge(:key => key),@redis)
|
159
|
+
|
160
|
+
psredis = Redis.new(path: @opts[:redis_path], db: @opts[:redis_db])
|
161
|
+
response = nil
|
162
|
+
Thread.new do
|
163
|
+
psredis.subscribe('callback-response:' + key, 'callback-end:' + key) do |on|
|
164
|
+
on.message do |what, message|
|
165
|
+
if what == 'callback-response:' + key
|
166
|
+
index = message.index(' ')
|
167
|
+
mess = message[index+1..-1]
|
168
|
+
instance = message[0...index]
|
169
|
+
m = JSON.parse(mess)
|
170
|
+
resp = []
|
171
|
+
m['content']['values'].each do |e|
|
172
|
+
if e[1][0] == 'simple'
|
173
|
+
resp << Riddl::Parameter::Simple.new(e[0],e[1][1])
|
174
|
+
elsif e[1][0] == 'complex'
|
175
|
+
resp << Riddl::Parameter::Complex.new(e[0],e[1][1],File.open(e[1][2]))
|
614
176
|
end
|
615
177
|
end
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
e.root.add(ke,va)
|
621
|
-
end
|
622
|
-
u.send(e.to_s)
|
178
|
+
hw.send(:callback,resp,m['content']['headers'])
|
179
|
+
end
|
180
|
+
if what == 'callback-end:' + key
|
181
|
+
psredis.unsubscribe
|
623
182
|
end
|
624
183
|
end
|
625
|
-
|
626
184
|
end
|
627
|
-
continue.wait
|
628
|
-
|
629
|
-
!@votes_results.delete(voteid).include?(false)
|
630
|
-
else
|
631
|
-
true
|
632
185
|
end
|
633
|
-
end
|
634
|
-
|
635
|
-
def vote_callback(result,options,continue,voteid,callback,num)# {{{
|
636
|
-
@callbacks.delete(callback)
|
637
|
-
if result == :DELETE
|
638
|
-
@votes_results[voteid] << true
|
639
|
-
else
|
640
|
-
@votes_results[voteid] << (result && result[0] && result[0].value == 'true')
|
641
|
-
end
|
642
|
-
if (num == @votes_results[voteid].length)
|
643
|
-
continue.continue
|
644
|
-
end
|
645
|
-
end # }}}
|
646
|
-
|
647
|
-
def add_websocket(key,socket)# {{{
|
648
|
-
@communication[key] = socket
|
649
|
-
@events.each do |a|
|
650
|
-
if a[1].has_key?(key)
|
651
|
-
a[1][key] = socket
|
652
|
-
end
|
653
|
-
end
|
654
|
-
@votes.each do |a|
|
655
|
-
if a[1].has_key?(key)
|
656
|
-
a[1][key] = socket
|
657
|
-
end
|
658
|
-
end
|
659
|
-
end # }}}
|
660
|
-
|
661
|
-
private
|
662
|
-
|
663
|
-
def build_notification(key,what,content,type,callback=nil)# {{{
|
664
|
-
res = []
|
665
|
-
res << ['key' , key]
|
666
|
-
res << ['topic' , ::File::dirname(what)]
|
667
|
-
res << [type , ::File::basename(what)]
|
668
|
-
res << ['notification' , ValueHelper::generate(content)]
|
669
|
-
res << ['callback' , callback] unless callback.nil?
|
670
|
-
res << ['fingerprint-with-consumer-secret', Digest::MD5.hexdigest(res.join(''))]
|
671
|
-
# TODO add secret to fp
|
672
|
-
end # }}}
|
186
|
+
end
|
673
187
|
|
188
|
+
def cancel_callback(key)
|
189
|
+
CPEE::Message::send(:'callback-end',key,base,@id,uuid,info,{},@redis)
|
190
|
+
end
|
674
191
|
end
|
675
192
|
|
676
193
|
end
|