cpee 1.5.25 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (357) hide show
  1. checksums.yaml +4 -4
  2. data/{FEATURES → FEATURES.md} +7 -6
  3. data/INSTALL.md +1 -0
  4. data/{README → README.md} +3 -3
  5. data/Rakefile +1 -0
  6. data/cockpit/index.html +7 -7
  7. data/cockpit/js/details.js +13 -14
  8. data/cockpit/js/instance.js +191 -284
  9. data/cockpit/js/parameters.js +13 -3
  10. data/cockpit/js/ui.js +2 -2
  11. data/cockpit/model.html +1 -0
  12. data/cockpit/rngs/attributes.rng +1 -1
  13. data/cockpit/rngs/dataelements.rng +1 -1
  14. data/cockpit/rngs/endpoints.rng +1 -1
  15. data/cockpit/templates.legacy/Async.xml +7 -7
  16. data/cockpit/templates.legacy/BCO.xml +7 -10
  17. data/cockpit/templates.legacy/BCS.xml +7 -10
  18. data/cockpit/templates.legacy/Centurio.xml +6 -6
  19. data/cockpit/templates.legacy/Concurrent.xml +6 -6
  20. data/cockpit/templates.legacy/Coopis Testset.xml +6 -6
  21. data/cockpit/templates.legacy/Endpoints and Data Manipulation.xml +6 -6
  22. data/cockpit/templates.legacy/ICSOC Testset.xml +6 -6
  23. data/cockpit/templates.legacy/Infinity.xml +3 -3
  24. data/cockpit/templates.legacy/Lego Boxer.xml +7 -7
  25. data/cockpit/templates.legacy/Lego Conveyor.xml +7 -7
  26. data/cockpit/templates.legacy/Lego Crane.xml +7 -7
  27. data/cockpit/templates.legacy/Lego Ejector.xml +7 -7
  28. data/cockpit/templates.legacy/Lego Full.xml +7 -7
  29. data/cockpit/templates.legacy/Lego Liddy.xml +7 -7
  30. data/cockpit/templates.legacy/Lego Plate.xml +7 -7
  31. data/cockpit/templates.legacy/Lego Transporter.xml +7 -7
  32. data/cockpit/templates.legacy/Lego_Part_1.xml +7 -7
  33. data/cockpit/templates.legacy/LgLinear.xml +6 -10
  34. data/cockpit/templates.legacy/Linear.xml +7 -7
  35. data/cockpit/templates.legacy/Log.xml +7 -7
  36. data/cockpit/templates.legacy/Mangler 1.xml +6 -6
  37. data/cockpit/templates.legacy/Mangler 2.xml +6 -6
  38. data/cockpit/templates.legacy/Manuel Labels.xml +7 -7
  39. data/cockpit/templates.legacy/Promise.xml +7 -7
  40. data/cockpit/templates.legacy/SOPROMO Test Sonification.xml +6 -6
  41. data/cockpit/templates.legacy/Subprocess.xml +56 -0
  42. data/cockpit/templates.legacy/Syncing P34 1.xml +8 -11
  43. data/cockpit/templates.legacy/Syncing P34 2.xml +8 -11
  44. data/cockpit/templates.legacy/Syncing P34 3.xml +8 -11
  45. data/cockpit/templates.legacy/Syncing P34.xml +8 -11
  46. data/cockpit/templates.legacy/TEST - Bad Loop.xml +6 -6
  47. data/cockpit/templates.legacy/TEST - Wrong Positions.xml +6 -6
  48. data/cockpit/templates.legacy/Take_5.xml +48 -0
  49. data/cockpit/templates.legacy/Update.xml +7 -7
  50. data/cockpit/templates.legacy/Worklist Parallel.xml +7 -7
  51. data/cockpit/templates.legacy/Worklist Test CPEE.xml +7 -7
  52. data/cockpit/templates.legacy/Worklist Test.xml +7 -7
  53. data/cockpit/templates.legacy/Worklist Test2.xml +7 -7
  54. data/cockpit/templates.legacy/convert_cpee2.rb +15 -0
  55. data/cockpit/templates.legacy/testsets.xml +1 -1
  56. data/cockpit/templates/BPM 2020 Manual Adjust.xml +18 -71
  57. data/cockpit/templates/BPM 2020 Solution Baseline.xml +17 -71
  58. data/cockpit/templates/BPM 2020 Solution NN.xml +25 -71
  59. data/cockpit/templates/BPM 2020 Solution View.xml +15 -71
  60. data/cockpit/templates/BPM 2020.xml +17 -6
  61. data/cockpit/templates/Coopis 2010.xml +7 -7
  62. data/cockpit/templates/IUPC arXiv:1104.3609 P34 1.xml +7 -10
  63. data/cockpit/templates/IUPC arXiv:1104.3609 P34 2.xml +7 -10
  64. data/cockpit/templates/IUPC arXiv:1104.3609 P34 3.xml +7 -10
  65. data/cockpit/templates/Worklist.xml +7 -7
  66. data/cockpit/templates/convert_cpee2.rb +15 -0
  67. data/cockpit/themes/compact/rngs/alternative.rng +25 -0
  68. data/cockpit/themes/compact/rngs/call.rng +17 -17
  69. data/cockpit/themes/compact/rngs/callmanipulate.rng +26 -26
  70. data/cockpit/themes/compact/rngs/choose.rng +14 -0
  71. data/cockpit/themes/compact/rngs/critical.rng +5 -0
  72. data/cockpit/themes/compact/rngs/escape.rng +1 -0
  73. data/cockpit/themes/compact/rngs/group.rng +3 -0
  74. data/cockpit/themes/compact/rngs/loop.rng +22 -0
  75. data/cockpit/themes/compact/rngs/manipulate.rng +9 -0
  76. data/cockpit/themes/compact/rngs/otherwise.rng +22 -0
  77. data/cockpit/themes/compact/rngs/parallel.rng +21 -0
  78. data/cockpit/themes/compact/rngs/parallel_branch.rng +8 -0
  79. data/cockpit/themes/compact/rngs/scripts.rng +10 -11
  80. data/cockpit/themes/compact/rngs/stop.rng +5 -0
  81. data/cockpit/themes/compact/rngs/terminate.rng +1 -0
  82. data/cockpit/themes/convert_cpee2.rb +8 -0
  83. data/cockpit/themes/default/rngs/alternative.rng +8 -8
  84. data/cockpit/themes/default/rngs/call.rng +84 -48
  85. data/cockpit/themes/default/rngs/callmanipulate.rng +103 -64
  86. data/cockpit/themes/default/rngs/choose.rng +5 -3
  87. data/cockpit/themes/default/rngs/critical.rng +2 -2
  88. data/cockpit/themes/default/rngs/escape.rng +1 -1
  89. data/cockpit/themes/default/rngs/group.rng +3 -3
  90. data/cockpit/themes/default/rngs/loop.rng +8 -8
  91. data/cockpit/themes/default/rngs/manipulate.rng +3 -3
  92. data/cockpit/themes/default/rngs/otherwise.rng +8 -8
  93. data/cockpit/themes/default/rngs/parallel.rng +14 -6
  94. data/cockpit/themes/default/rngs/parallel_branch.rng +2 -2
  95. data/cockpit/themes/default/rngs/scripts.rng +23 -0
  96. data/cockpit/themes/default/rngs/stop.rng +2 -2
  97. data/cockpit/themes/default/rngs/terminate.rng +1 -1
  98. data/cockpit/themes/extended/rngs/alternative.rng +25 -0
  99. data/cockpit/themes/extended/rngs/call.rng +17 -17
  100. data/cockpit/themes/extended/rngs/callmanipulate.rng +26 -26
  101. data/cockpit/themes/extended/rngs/choose.rng +14 -0
  102. data/cockpit/themes/extended/rngs/critical.rng +5 -0
  103. data/cockpit/themes/extended/rngs/escape.rng +1 -0
  104. data/cockpit/themes/extended/rngs/group.rng +3 -0
  105. data/cockpit/themes/extended/rngs/loop.rng +22 -0
  106. data/cockpit/themes/extended/rngs/manipulate.rng +9 -0
  107. data/cockpit/themes/extended/rngs/otherwise.rng +22 -0
  108. data/cockpit/themes/extended/rngs/parallel.rng +21 -0
  109. data/cockpit/themes/extended/rngs/parallel_branch.rng +8 -0
  110. data/cockpit/themes/extended/rngs/scripts.rng +10 -11
  111. data/cockpit/themes/extended/rngs/stop.rng +5 -0
  112. data/cockpit/themes/extended/rngs/terminate.rng +1 -0
  113. data/cockpit/themes/extended/theme.js +7 -6
  114. data/cockpit/themes/model/rngs/alternative.rng +1 -1
  115. data/cockpit/themes/model/rngs/call.rng +16 -16
  116. data/cockpit/themes/model/rngs/callmanipulate.rng +17 -17
  117. data/cockpit/themes/model/rngs/choose.rng +1 -1
  118. data/cockpit/themes/model/rngs/critical.rng +1 -1
  119. data/cockpit/themes/model/rngs/escape.rng +1 -1
  120. data/cockpit/themes/model/rngs/group.rng +1 -1
  121. data/cockpit/themes/model/rngs/loop.rng +1 -1
  122. data/cockpit/themes/model/rngs/manipulate.rng +1 -1
  123. data/cockpit/themes/model/rngs/otherwise.rng +1 -1
  124. data/cockpit/themes/model/rngs/parallel.rng +1 -1
  125. data/cockpit/themes/model/rngs/parallel_branch.rng +1 -1
  126. data/cockpit/themes/model/rngs/scripts.rng +3 -4
  127. data/cockpit/themes/model/rngs/stop.rng +1 -1
  128. data/cockpit/themes/model/rngs/terminate.rng +1 -1
  129. data/cockpit/themes/model/theme.js +7 -6
  130. data/cockpit/themes/packed/rngs/alternative.rng +25 -0
  131. data/cockpit/themes/packed/rngs/call.rng +17 -17
  132. data/cockpit/themes/packed/rngs/callmanipulate.rng +26 -26
  133. data/cockpit/themes/packed/rngs/choose.rng +14 -0
  134. data/cockpit/themes/packed/rngs/critical.rng +5 -0
  135. data/cockpit/themes/packed/rngs/escape.rng +1 -0
  136. data/cockpit/themes/packed/rngs/group.rng +3 -0
  137. data/cockpit/themes/packed/rngs/loop.rng +22 -0
  138. data/cockpit/themes/packed/rngs/manipulate.rng +9 -0
  139. data/cockpit/themes/packed/rngs/otherwise.rng +22 -0
  140. data/cockpit/themes/packed/rngs/parallel.rng +21 -0
  141. data/cockpit/themes/packed/rngs/parallel_branch.rng +8 -0
  142. data/cockpit/themes/packed/rngs/scripts.rng +10 -11
  143. data/cockpit/themes/packed/rngs/stop.rng +5 -0
  144. data/cockpit/themes/packed/rngs/terminate.rng +1 -0
  145. data/cockpit/themes/packed/theme.js +7 -6
  146. data/cockpit/themes/preset/rngs/alternative.rng +25 -0
  147. data/cockpit/themes/preset/rngs/call.rng +17 -17
  148. data/cockpit/themes/preset/rngs/callmanipulate.rng +26 -26
  149. data/cockpit/themes/preset/rngs/choose.rng +14 -0
  150. data/cockpit/themes/preset/rngs/critical.rng +5 -0
  151. data/cockpit/themes/preset/rngs/escape.rng +1 -0
  152. data/cockpit/themes/preset/rngs/group.rng +3 -0
  153. data/cockpit/themes/preset/rngs/loop.rng +22 -0
  154. data/cockpit/themes/preset/rngs/manipulate.rng +9 -0
  155. data/cockpit/themes/preset/rngs/otherwise.rng +22 -0
  156. data/cockpit/themes/preset/rngs/parallel.rng +21 -0
  157. data/cockpit/themes/preset/rngs/parallel_branch.rng +8 -0
  158. data/cockpit/themes/preset/rngs/scripts.rng +10 -11
  159. data/cockpit/themes/preset/rngs/stop.rng +5 -0
  160. data/cockpit/themes/preset/rngs/terminate.rng +1 -0
  161. data/cockpit/themes/preset/theme.js +7 -6
  162. data/cpee.gemspec +10 -11
  163. data/{log/topics.xml → lib/callbacks.xml} +16 -6
  164. data/lib/{engine → callbacks}/callbacks.rng +2 -8
  165. data/lib/cpee.xml +10 -4
  166. data/lib/cpee/attributes_helper.rb +27 -0
  167. data/lib/cpee/controller.rb +113 -596
  168. data/lib/cpee/implementation.rb +167 -191
  169. data/lib/cpee/implementation_callbacks.rb +77 -0
  170. data/lib/cpee/implementation_notifications.rb +189 -0
  171. data/lib/cpee/implementation_properties.rb +714 -0
  172. data/lib/cpee/{callback.rb → message.rb} +20 -18
  173. data/lib/cpee/persistence.rb +135 -0
  174. data/lib/cpee/statemachine.rb +20 -0
  175. data/lib/cpee/transform.rb +95 -0
  176. data/lib/engine.xml +1 -59
  177. data/lib/properties.xml +236 -0
  178. data/lib/properties/arbitrary.rng +26 -0
  179. data/lib/properties/attributes.rng +10 -0
  180. data/lib/properties/dataelements.rng +10 -0
  181. data/lib/properties/description.rng +8 -0
  182. data/lib/properties/dsl.rng +7 -0
  183. data/lib/properties/dslx.rng +8 -0
  184. data/lib/properties/endpoints.rng +10 -0
  185. data/lib/properties/handlerwrapper.rng +9 -0
  186. data/lib/properties/position.rng +15 -0
  187. data/lib/properties/positions.rng +10 -0
  188. data/lib/properties/properties.rng +29 -0
  189. data/lib/properties/set-properties.rng +25 -0
  190. data/lib/properties/set-some-properties.rng +45 -0
  191. data/lib/properties/simple.rng +8 -0
  192. data/lib/properties/state.rng +33 -0
  193. data/lib/properties/status.rng +12 -0
  194. data/lib/properties/t_attributes.rng +7 -0
  195. data/lib/properties/t_dataelements.rng +7 -0
  196. data/lib/properties/t_endpoints.rng +7 -0
  197. data/lib/properties/t_position.rng +7 -0
  198. data/lib/properties/t_positions.rng +7 -0
  199. data/lib/properties/t_simple.rng +7 -0
  200. data/lib/properties/t_status.rng +7 -0
  201. data/lib/properties/t_transformation.rng +7 -0
  202. data/lib/properties/transformation.rng +40 -0
  203. data/server/dev.rb +1 -0
  204. data/server/handlerwrappers/default.rb +40 -38
  205. data/server/resources/backend/README.md +17 -0
  206. data/server/resources/backend/instance.rb +23 -0
  207. data/server/resources/backend/instance.template +19 -0
  208. data/server/resources/backend/opts.yaml +6 -0
  209. data/server/resources/backend/run +33 -0
  210. data/server/resources/notifications/logging/subscription.xml +19 -0
  211. data/server/resources/properties.empty +38 -0
  212. data/server/resources/properties.init +11 -11
  213. data/server/resources/states.dot +19 -0
  214. data/server/resources/states.xml +49 -0
  215. data/server/resources/transformation_dslx.xsl +12 -3
  216. data/server/routing/end.rb +44 -0
  217. data/server/routing/forward-events.rb +59 -0
  218. data/server/routing/forward-votes.rb +108 -0
  219. data/server/routing/persist.rb +155 -0
  220. data/server/server.rb +1 -0
  221. data/tools/cpee +46 -15
  222. data/tools/instantiation/instantiation +0 -1
  223. data/tools/server/server.rb +0 -1
  224. metadata +78 -132
  225. data/INSTALL +0 -23
  226. data/cockpit/templates/convert_preset.rb +0 -32
  227. data/cockpit/templates/testsets.xml +0 -11
  228. data/cockpit/templates/transformations.xml +0 -4
  229. data/cockpit/themes/compact/rngs/alternative.rng +0 -1
  230. data/cockpit/themes/compact/rngs/choose.rng +0 -1
  231. data/cockpit/themes/compact/rngs/critical.rng +0 -1
  232. data/cockpit/themes/compact/rngs/escape.rng +0 -1
  233. data/cockpit/themes/compact/rngs/group.rng +0 -1
  234. data/cockpit/themes/compact/rngs/loop.rng +0 -1
  235. data/cockpit/themes/compact/rngs/manipulate.rng +0 -1
  236. data/cockpit/themes/compact/rngs/otherwise.rng +0 -1
  237. data/cockpit/themes/compact/rngs/parallel.rng +0 -1
  238. data/cockpit/themes/compact/rngs/parallel_branch.rng +0 -1
  239. data/cockpit/themes/compact/rngs/stop.rng +0 -1
  240. data/cockpit/themes/compact/rngs/terminate.rng +0 -1
  241. data/cockpit/themes/default/rngs/finalize.rng +0 -6
  242. data/cockpit/themes/default/rngs/update.rng +0 -6
  243. data/cockpit/themes/default/theme.js +0 -1286
  244. data/cockpit/themes/extended/rngs/alternative.rng +0 -1
  245. data/cockpit/themes/extended/rngs/choose.rng +0 -1
  246. data/cockpit/themes/extended/rngs/critical.rng +0 -1
  247. data/cockpit/themes/extended/rngs/escape.rng +0 -1
  248. data/cockpit/themes/extended/rngs/group.rng +0 -1
  249. data/cockpit/themes/extended/rngs/loop.rng +0 -1
  250. data/cockpit/themes/extended/rngs/manipulate.rng +0 -1
  251. data/cockpit/themes/extended/rngs/otherwise.rng +0 -1
  252. data/cockpit/themes/extended/rngs/parallel.rng +0 -1
  253. data/cockpit/themes/extended/rngs/parallel_branch.rng +0 -1
  254. data/cockpit/themes/extended/rngs/stop.rng +0 -1
  255. data/cockpit/themes/extended/rngs/terminate.rng +0 -1
  256. data/cockpit/themes/labels/rngs/alternative.rng +0 -25
  257. data/cockpit/themes/labels/rngs/call.rng +0 -81
  258. data/cockpit/themes/labels/rngs/callmanipulate.rng +0 -101
  259. data/cockpit/themes/labels/rngs/choose.rng +0 -12
  260. data/cockpit/themes/labels/rngs/critical.rng +0 -5
  261. data/cockpit/themes/labels/rngs/escape.rng +0 -1
  262. data/cockpit/themes/labels/rngs/finalize.rng +0 -6
  263. data/cockpit/themes/labels/rngs/group.rng +0 -3
  264. data/cockpit/themes/labels/rngs/loop.rng +0 -22
  265. data/cockpit/themes/labels/rngs/manipulate.rng +0 -9
  266. data/cockpit/themes/labels/rngs/otherwise.rng +0 -22
  267. data/cockpit/themes/labels/rngs/parallel.rng +0 -13
  268. data/cockpit/themes/labels/rngs/parallel_branch.rng +0 -8
  269. data/cockpit/themes/labels/rngs/stop.rng +0 -5
  270. data/cockpit/themes/labels/rngs/terminate.rng +0 -1
  271. data/cockpit/themes/labels/rngs/update.rng +0 -6
  272. data/cockpit/themes/labels/symbols/alternative.svg +0 -5
  273. data/cockpit/themes/labels/symbols/arrow.svg +0 -3
  274. data/cockpit/themes/labels/symbols/call.svg +0 -6
  275. data/cockpit/themes/labels/symbols/callmanipulate.svg +0 -8
  276. data/cockpit/themes/labels/symbols/choose.svg +0 -5
  277. data/cockpit/themes/labels/symbols/choose_exclusive.svg +0 -5
  278. data/cockpit/themes/labels/symbols/choose_inclusive.svg +0 -4
  279. data/cockpit/themes/labels/symbols/complex.svg +0 -8
  280. data/cockpit/themes/labels/symbols/critical.svg +0 -4
  281. data/cockpit/themes/labels/symbols/end.svg +0 -3
  282. data/cockpit/themes/labels/symbols/escape.svg +0 -5
  283. data/cockpit/themes/labels/symbols/event_end.svg +0 -3
  284. data/cockpit/themes/labels/symbols/loop.svg +0 -5
  285. data/cockpit/themes/labels/symbols/manipulate.svg +0 -4
  286. data/cockpit/themes/labels/symbols/otherwise.svg +0 -5
  287. data/cockpit/themes/labels/symbols/parallel.svg +0 -5
  288. data/cockpit/themes/labels/symbols/parallel_branch.svg +0 -5
  289. data/cockpit/themes/labels/symbols/parallel_branch_compact.svg +0 -4
  290. data/cockpit/themes/labels/symbols/parallel_branch_event.svg +0 -14
  291. data/cockpit/themes/labels/symbols/parallel_branch_normal.svg +0 -5
  292. data/cockpit/themes/labels/symbols/scripts.svg +0 -4
  293. data/cockpit/themes/labels/symbols/start.svg +0 -3
  294. data/cockpit/themes/labels/symbols/stop.svg +0 -5
  295. data/cockpit/themes/labels/symbols/terminate.svg +0 -4
  296. data/cockpit/themes/packed/rngs/alternative.rng +0 -1
  297. data/cockpit/themes/packed/rngs/choose.rng +0 -1
  298. data/cockpit/themes/packed/rngs/critical.rng +0 -1
  299. data/cockpit/themes/packed/rngs/escape.rng +0 -1
  300. data/cockpit/themes/packed/rngs/group.rng +0 -1
  301. data/cockpit/themes/packed/rngs/loop.rng +0 -1
  302. data/cockpit/themes/packed/rngs/manipulate.rng +0 -1
  303. data/cockpit/themes/packed/rngs/otherwise.rng +0 -1
  304. data/cockpit/themes/packed/rngs/parallel.rng +0 -1
  305. data/cockpit/themes/packed/rngs/parallel_branch.rng +0 -1
  306. data/cockpit/themes/packed/rngs/stop.rng +0 -1
  307. data/cockpit/themes/packed/rngs/terminate.rng +0 -1
  308. data/cockpit/themes/preset/rngs/alternative.rng +0 -1
  309. data/cockpit/themes/preset/rngs/choose.rng +0 -1
  310. data/cockpit/themes/preset/rngs/critical.rng +0 -1
  311. data/cockpit/themes/preset/rngs/escape.rng +0 -1
  312. data/cockpit/themes/preset/rngs/group.rng +0 -1
  313. data/cockpit/themes/preset/rngs/loop.rng +0 -1
  314. data/cockpit/themes/preset/rngs/manipulate.rng +0 -1
  315. data/cockpit/themes/preset/rngs/otherwise.rng +0 -1
  316. data/cockpit/themes/preset/rngs/parallel.rng +0 -1
  317. data/cockpit/themes/preset/rngs/parallel_branch.rng +0 -1
  318. data/cockpit/themes/preset/rngs/stop.rng +0 -1
  319. data/cockpit/themes/preset/rngs/terminate.rng +0 -1
  320. data/lib/cpee/empty_workflow.rb +0 -28
  321. data/lib/cpee/handler_notifications.rb +0 -47
  322. data/lib/cpee/handler_properties.rb +0 -50
  323. data/lib/cpee/instantiation.rb +0 -369
  324. data/lib/cpee/processtransformation/bpel/Repository/booking.bpel +0 -125
  325. data/lib/cpee/processtransformation/bpel/Repository/booking.wsdl +0 -72
  326. data/lib/cpee/processtransformation/bpel/Repository/booking/airline.wsdl +0 -71
  327. data/lib/cpee/processtransformation/bpel/Repository/booking/hotel.wsdl +0 -64
  328. data/lib/cpee/processtransformation/bpel/Repository/booking/report.wsdl +0 -71
  329. data/lib/cpee/processtransformation/bpel/bpel2wee.rb +0 -34
  330. data/lib/cpee/processtransformation/bpel/bpelserver.ru +0 -64
  331. data/lib/cpee/processtransformation/bpel/bpelserver.xml +0 -70
  332. data/lib/cpee/processtransformation/bpel/lib/BPEL_Transform.rb +0 -367
  333. data/lib/cpee/processtransformation/bpmn2.rb +0 -297
  334. data/lib/cpee/processtransformation/cpee.rb +0 -119
  335. data/lib/cpee/processtransformation/structures.rb +0 -465
  336. data/lib/cpee/processtransformation/target.rb +0 -50
  337. data/log/azure.rb +0 -10
  338. data/log/azure_logger.rb +0 -136
  339. data/log/chain.xml +0 -27
  340. data/log/elasticsearch.rb +0 -15
  341. data/log/elasticsearch_logging.rb +0 -377
  342. data/log/legacy/test_es.rb +0 -26
  343. data/log/legacy/test_split.rb +0 -211
  344. data/log/log.xml +0 -13
  345. data/log/non_tamp.rb +0 -156
  346. data/log/sic.rb +0 -64
  347. data/log/template.xes_xml +0 -23
  348. data/log/template.xes_yaml +0 -28
  349. data/log/trace.yaml +0 -17717
  350. data/log/trace_sic.yaml +0 -18343
  351. data/log/xes_xml.rb +0 -121
  352. data/log/xes_yaml.rb +0 -96
  353. data/server/handlerwrappers/soap.rb +0 -146
  354. data/server/resources/properties.schema.active +0 -139
  355. data/server/resources/properties.schema.finished +0 -139
  356. data/server/resources/properties.schema.inactive +0 -136
  357. data/test/callback.rb +0 -9
@@ -14,9 +14,19 @@
14
14
  <http://www.gnu.org/licenses/>.
15
15
  -->
16
16
 
17
- <topics xmlns='http://riddl.org/ns/common-patterns/notifications-producer/1.0'>
18
- <topic id='activity'>
19
- <event>calling</event>
20
- <event>done</event>
21
- </topic>
22
- </topics>
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>
@@ -19,20 +19,26 @@
19
19
  <xi:include href="engine.xml"/>
20
20
  </interface>
21
21
  <interface name="properties">
22
- <xi:include href="http://www.riddl.org/ns/common-patterns/properties/1.0/properties.xml"/>
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/1.0/producer.xml"/>
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>/{}/properties</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>/{}</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
+
@@ -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 'pp'
17
+ require 'redis'
17
18
  require 'securerandom'
18
- require ::File.dirname(__FILE__) + '/handler_properties'
19
- require ::File.dirname(__FILE__) + '/handler_notifications'
20
- require ::File.dirname(__FILE__) + '/callback'
21
- require ::File.dirname(__FILE__) + '/empty_workflow'
22
- require ::File.dirname(__FILE__) + '/value_helper'
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
- @events = {}
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
- @properties = Riddl::Utils::Properties::Backend.new(
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 :uuid
56
+ attr_reader :loop_guard
133
57
 
134
- def console(cmd)
135
- x = eval(cmd)
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
- instance_url
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 sim # {{{
166
- @thread.join if !@thread.nil? && @thread.alive?
167
- @thread = @instance.sim
168
- end # }}}
169
-
170
- def replay # {{{
171
- @thread.join if !@thread.nil? && @thread.alive?
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
- @thread = @instance.start
181
- end # }}}
99
+ end
182
100
 
183
- def stop # {{{
184
- t = @instance.stop
185
- t.run
186
- @callbacks.delete_if do |k,c|
187
- # only remove vote_callbacks, the other stuff is removed by
188
- # the instance stopping cleanup
189
- if c.method == :vote_callback
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 finalize_if_finished
225
- if @instance.state == :finished
226
- # TODO unlink engine, be careful race condition
227
- # @instance = nil
228
- end
229
- end
230
-
231
- def serialize_dataelements! #{{{
232
- @properties.modify do |doc|
233
- node = doc.find("/p:properties/p:dataelements").first
234
- node.children.delete_all!
235
- @instance.data.each do |k,v|
236
- node.add(k.to_s,ValueHelper::generate(v))
237
- end
238
- end
239
- end #}}}
240
- def serialize_endpoints! #{{{
241
- @properties.modify do |doc|
242
- node = doc.find("/p:properties/p:endpoints").first
243
- node.children.delete_all!
244
- @instance.endpoints.each do |k,v|
245
- node.add(k.to_s,v)
246
- end
247
- end
248
- end #}}}
249
- def serialize_state! # {{{
250
- @properties.activate_schema(:finished) if @instance.state == :finished || @instance.state == :abandoned
251
- @properties.activate_schema(:inactive) if @instance.state == :stopped || @instance.state == :ready
252
- @properties.activate_schema(:active) if @instance.state == :running || @instance.state == :simulating || @instance.state == :replaying
253
- if [:finished, :stopped, :ready, :abandoned].include?(@instance.state)
254
- state_change! @instance.state
255
- end
256
- end # }}}
257
- def serialize_positions! # {{{
258
- @properties.modify do |doc|
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
- end
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
- uuid.first.text
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
- Thread.new(key,url,content.dup) do |k,u,c|
597
- callback = Digest::MD5.hexdigest(Kernel::rand().to_s)
598
- c['callback'] = callback
599
- notf = build_notification(k,what,c,'vote',callback)
600
- if u.class == String
601
- client = Riddl::Client.new(u,'http://riddl.org/ns/common-patterns/notifications-consumer/1.0/consumer.xml')
602
- params = notf.map{|ke,va|Riddl::Parameter::Simple.new(ke,va)}
603
- params << Riddl::Header.new("CPEE-BASE",self.base_url)
604
- params << Riddl::Header.new("CPEE-INSTANCE",self.instance)
605
- params << Riddl::Header.new("CPEE-INSTANCE-URL",self.instance_url)
606
- params << Riddl::Header.new("CPEE-INSTANCE-UUID",self.uuid)
607
- params << Riddl::Header.new("CPEE-CALLBACK",self.instance_url + '/callbacks/' + callback)
608
- @mutex.synchronize do
609
- status, result, headers = client.post params
610
- if headers["CPEE_CALLBACK"] && headers["CPEE_CALLBACK"] == 'true'
611
- @callbacks[callback] = Callback.new("vote #{notf.find{|a,b| a == 'notification'}[1]}", self, :vote_callback, what, k, :http, continue, voteid, callback, inum)
612
- else
613
- vote_callback(result,nil,continue,voteid,callback,inum)
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
- elsif u.class == Riddl::Utils::Notifications::Producer::WS
617
- @callbacks[callback] = Callback.new("vote #{notf.find{|a,b| a == 'notification'}[1]}", self, :vote_callback, what, k, :ws, continue, voteid, callback, inum)
618
- e = XML::Smart::string("<vote/>")
619
- notf.each do |ke,va|
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