cpee 1.5.20 → 2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (360) 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 +8 -8
  7. data/cockpit/js/details.js +13 -14
  8. data/cockpit/js/instance.js +192 -290
  9. data/cockpit/js/parameters.js +13 -3
  10. data/cockpit/js/ui.js +2 -2
  11. data/cockpit/rngs/attributes.rng +3 -3
  12. data/cockpit/rngs/dataelements.rng +3 -3
  13. data/cockpit/rngs/endpoints.rng +3 -3
  14. data/cockpit/{testsets → templates.legacy}/Async.xml +7 -7
  15. data/cockpit/{testsets → templates.legacy}/BCO.xml +7 -10
  16. data/cockpit/{testsets → templates.legacy}/BCS.xml +7 -10
  17. data/cockpit/{testsets → templates.legacy}/Centurio.xml +6 -6
  18. data/cockpit/{testsets → templates.legacy}/Concurrent.xml +6 -6
  19. data/cockpit/{testsets → templates.legacy}/Coopis Testset.xml +6 -6
  20. data/cockpit/{testsets → templates.legacy}/Endpoints and Data Manipulation.xml +6 -6
  21. data/cockpit/{testsets → templates.legacy}/ICSOC Testset.xml +6 -6
  22. data/cockpit/{testsets → templates.legacy}/Infinity.xml +3 -3
  23. data/cockpit/{testsets → templates.legacy}/Lego Boxer.xml +7 -7
  24. data/cockpit/{testsets → templates.legacy}/Lego Conveyor.xml +7 -7
  25. data/cockpit/{testsets → templates.legacy}/Lego Crane.xml +7 -7
  26. data/cockpit/{testsets → templates.legacy}/Lego Ejector.xml +7 -7
  27. data/cockpit/{testsets → templates.legacy}/Lego Full.xml +7 -7
  28. data/cockpit/{testsets → templates.legacy}/Lego Liddy.xml +7 -7
  29. data/cockpit/{testsets → templates.legacy}/Lego Plate.xml +7 -7
  30. data/cockpit/{testsets → templates.legacy}/Lego Transporter.xml +7 -7
  31. data/cockpit/{testsets → templates.legacy}/Lego_Part_1.xml +7 -7
  32. data/cockpit/{testsets → templates.legacy}/LgLinear.xml +6 -10
  33. data/cockpit/{testsets → templates.legacy}/Linear.xml +7 -7
  34. data/cockpit/{testsets → templates.legacy}/Log.xml +7 -7
  35. data/cockpit/{testsets → templates.legacy}/Mangler 1.xml +6 -6
  36. data/cockpit/{testsets → templates.legacy}/Mangler 2.xml +6 -6
  37. data/cockpit/{testsets → templates.legacy}/Manuel Labels.xml +7 -7
  38. data/cockpit/{testsets → templates.legacy}/Promise.xml +7 -7
  39. data/cockpit/{testsets → templates.legacy}/SOPROMO Test Sonification.xml +6 -6
  40. data/cockpit/{testsets → templates.legacy}/Subprocess.xml +7 -7
  41. data/cockpit/{testsets → templates.legacy}/Syncing P34 1.xml +8 -11
  42. data/cockpit/{testsets → templates.legacy}/Syncing P34 2.xml +8 -11
  43. data/cockpit/{testsets → templates.legacy}/Syncing P34 3.xml +8 -11
  44. data/cockpit/{testsets → templates.legacy}/Syncing P34.xml +8 -11
  45. data/cockpit/{testsets → templates.legacy}/TEST - Bad Loop.xml +6 -6
  46. data/cockpit/{testsets → templates.legacy}/TEST - Wrong Positions.xml +6 -6
  47. data/cockpit/{testsets → templates.legacy}/Take_5.xml +7 -7
  48. data/cockpit/{testsets → templates.legacy}/Update.xml +7 -7
  49. data/cockpit/{testsets → templates.legacy}/Worklist Parallel.xml +7 -7
  50. data/cockpit/{testsets → templates.legacy}/Worklist Test CPEE.xml +7 -7
  51. data/cockpit/{testsets → templates.legacy}/Worklist Test.xml +7 -7
  52. data/cockpit/{testsets → templates.legacy}/Worklist Test2.xml +7 -7
  53. data/cockpit/templates.legacy/convert_cpee2.rb +15 -0
  54. data/cockpit/{testsets → templates.legacy}/convert_preset.rb +0 -0
  55. data/cockpit/{testsets → templates.legacy}/testsets.xml +1 -1
  56. data/cockpit/{testsets → templates.legacy}/transformations.xml +0 -0
  57. data/cockpit/templates/BPM 2020 Manual Adjust.xml +182 -0
  58. data/cockpit/templates/BPM 2020 Solution Baseline.xml +196 -0
  59. data/cockpit/templates/BPM 2020 Solution NN.xml +197 -0
  60. data/cockpit/templates/BPM 2020 Solution View.xml +144 -0
  61. data/cockpit/templates/BPM 2020.xml +26 -0
  62. data/cockpit/templates/Coopis 2010.xml +85 -0
  63. data/cockpit/templates/IUPC arXiv:1104.3609 P34 1.xml +77 -0
  64. data/cockpit/templates/IUPC arXiv:1104.3609 P34 2.xml +77 -0
  65. data/cockpit/templates/IUPC arXiv:1104.3609 P34 3.xml +77 -0
  66. data/cockpit/templates/Worklist.xml +42 -0
  67. data/cockpit/templates/convert_cpee2.rb +15 -0
  68. data/cockpit/themes/compact/rngs/alternative.rng +25 -0
  69. data/cockpit/themes/compact/rngs/call.rng +20 -14
  70. data/cockpit/themes/compact/rngs/callmanipulate.rng +28 -22
  71. data/cockpit/themes/compact/rngs/choose.rng +14 -0
  72. data/cockpit/themes/compact/rngs/critical.rng +5 -0
  73. data/cockpit/themes/compact/rngs/escape.rng +1 -0
  74. data/cockpit/themes/compact/rngs/group.rng +3 -0
  75. data/cockpit/themes/compact/rngs/loop.rng +22 -0
  76. data/cockpit/themes/compact/rngs/manipulate.rng +9 -0
  77. data/cockpit/themes/compact/rngs/otherwise.rng +22 -0
  78. data/cockpit/themes/compact/rngs/parallel.rng +21 -0
  79. data/cockpit/themes/compact/rngs/parallel_branch.rng +8 -0
  80. data/cockpit/themes/compact/rngs/scripts.rng +10 -11
  81. data/cockpit/themes/compact/rngs/stop.rng +5 -0
  82. data/cockpit/themes/compact/rngs/terminate.rng +1 -0
  83. data/cockpit/themes/compact/theme.js +1 -1
  84. data/cockpit/themes/convert_cpee2.rb +8 -0
  85. data/cockpit/themes/default/rngs/alternative.rng +8 -8
  86. data/cockpit/themes/default/rngs/call.rng +85 -49
  87. data/cockpit/themes/default/rngs/callmanipulate.rng +103 -64
  88. data/cockpit/themes/default/rngs/choose.rng +5 -3
  89. data/cockpit/themes/default/rngs/critical.rng +2 -2
  90. data/cockpit/themes/default/rngs/escape.rng +1 -1
  91. data/cockpit/themes/default/rngs/group.rng +3 -3
  92. data/cockpit/themes/default/rngs/loop.rng +8 -8
  93. data/cockpit/themes/default/rngs/manipulate.rng +3 -3
  94. data/cockpit/themes/default/rngs/otherwise.rng +8 -8
  95. data/cockpit/themes/default/rngs/parallel.rng +14 -6
  96. data/cockpit/themes/default/rngs/parallel_branch.rng +2 -2
  97. data/cockpit/themes/default/rngs/scripts.rng +23 -0
  98. data/cockpit/themes/default/rngs/stop.rng +2 -2
  99. data/cockpit/themes/default/rngs/terminate.rng +1 -1
  100. data/cockpit/themes/extended/rngs/alternative.rng +25 -0
  101. data/cockpit/themes/extended/rngs/call.rng +20 -14
  102. data/cockpit/themes/extended/rngs/callmanipulate.rng +28 -22
  103. data/cockpit/themes/extended/rngs/choose.rng +14 -0
  104. data/cockpit/themes/extended/rngs/critical.rng +5 -0
  105. data/cockpit/themes/extended/rngs/escape.rng +1 -0
  106. data/cockpit/themes/extended/rngs/group.rng +3 -0
  107. data/cockpit/themes/extended/rngs/loop.rng +22 -0
  108. data/cockpit/themes/extended/rngs/manipulate.rng +9 -0
  109. data/cockpit/themes/extended/rngs/otherwise.rng +22 -0
  110. data/cockpit/themes/extended/rngs/parallel.rng +21 -0
  111. data/cockpit/themes/extended/rngs/parallel_branch.rng +8 -0
  112. data/cockpit/themes/extended/rngs/scripts.rng +10 -11
  113. data/cockpit/themes/extended/rngs/stop.rng +5 -0
  114. data/cockpit/themes/extended/rngs/terminate.rng +1 -0
  115. data/cockpit/themes/extended/theme.js +14 -28
  116. data/cockpit/themes/model/rngs/alternative.rng +1 -1
  117. data/cockpit/themes/model/rngs/call.rng +16 -16
  118. data/cockpit/themes/model/rngs/callmanipulate.rng +17 -17
  119. data/cockpit/themes/model/rngs/choose.rng +1 -1
  120. data/cockpit/themes/model/rngs/critical.rng +1 -1
  121. data/cockpit/themes/model/rngs/escape.rng +1 -1
  122. data/cockpit/themes/model/rngs/group.rng +1 -1
  123. data/cockpit/themes/model/rngs/loop.rng +1 -1
  124. data/cockpit/themes/model/rngs/manipulate.rng +1 -1
  125. data/cockpit/themes/model/rngs/otherwise.rng +1 -1
  126. data/cockpit/themes/model/rngs/parallel.rng +1 -1
  127. data/cockpit/themes/model/rngs/parallel_branch.rng +1 -1
  128. data/cockpit/themes/model/rngs/scripts.rng +3 -4
  129. data/cockpit/themes/model/rngs/stop.rng +1 -1
  130. data/cockpit/themes/model/rngs/terminate.rng +1 -1
  131. data/cockpit/themes/model/theme.js +8 -7
  132. data/cockpit/themes/packed/rngs/alternative.rng +25 -0
  133. data/cockpit/themes/packed/rngs/call.rng +20 -14
  134. data/cockpit/themes/packed/rngs/callmanipulate.rng +28 -22
  135. data/cockpit/themes/packed/rngs/choose.rng +14 -0
  136. data/cockpit/themes/packed/rngs/critical.rng +5 -0
  137. data/cockpit/themes/packed/rngs/escape.rng +1 -0
  138. data/cockpit/themes/packed/rngs/group.rng +3 -0
  139. data/cockpit/themes/packed/rngs/loop.rng +22 -0
  140. data/cockpit/themes/packed/rngs/manipulate.rng +9 -0
  141. data/cockpit/themes/packed/rngs/otherwise.rng +22 -0
  142. data/cockpit/themes/packed/rngs/parallel.rng +21 -0
  143. data/cockpit/themes/packed/rngs/parallel_branch.rng +8 -0
  144. data/cockpit/themes/packed/rngs/scripts.rng +10 -11
  145. data/cockpit/themes/packed/rngs/stop.rng +5 -0
  146. data/cockpit/themes/packed/rngs/terminate.rng +1 -0
  147. data/cockpit/themes/packed/theme.js +8 -7
  148. data/cockpit/themes/preset/rngs/alternative.rng +25 -0
  149. data/cockpit/themes/preset/rngs/call.rng +20 -14
  150. data/cockpit/themes/preset/rngs/callmanipulate.rng +28 -22
  151. data/cockpit/themes/preset/rngs/choose.rng +14 -0
  152. data/cockpit/themes/preset/rngs/critical.rng +5 -0
  153. data/cockpit/themes/preset/rngs/escape.rng +1 -0
  154. data/cockpit/themes/preset/rngs/group.rng +3 -0
  155. data/cockpit/themes/preset/rngs/loop.rng +22 -0
  156. data/cockpit/themes/preset/rngs/manipulate.rng +9 -0
  157. data/cockpit/themes/preset/rngs/otherwise.rng +22 -0
  158. data/cockpit/themes/preset/rngs/parallel.rng +21 -0
  159. data/cockpit/themes/preset/rngs/parallel_branch.rng +8 -0
  160. data/cockpit/themes/preset/rngs/scripts.rng +10 -11
  161. data/cockpit/themes/preset/rngs/stop.rng +5 -0
  162. data/cockpit/themes/preset/rngs/terminate.rng +1 -0
  163. data/cockpit/themes/preset/theme.js +8 -7
  164. data/cpee.gemspec +9 -9
  165. data/{log/topics.xml → lib/callbacks.xml} +16 -6
  166. data/lib/{engine → callbacks}/callbacks.rng +2 -8
  167. data/lib/cpee.xml +10 -4
  168. data/lib/cpee/attributes_helper.rb +27 -0
  169. data/lib/cpee/controller.rb +113 -596
  170. data/lib/cpee/implementation.rb +152 -191
  171. data/lib/cpee/implementation_callbacks.rb +77 -0
  172. data/lib/cpee/implementation_notifications.rb +189 -0
  173. data/lib/cpee/implementation_properties.rb +707 -0
  174. data/lib/cpee/{callback.rb → message.rb} +20 -18
  175. data/lib/cpee/persistence.rb +135 -0
  176. data/lib/cpee/statemachine.rb +20 -0
  177. data/lib/cpee/transform.rb +95 -0
  178. data/lib/engine.xml +1 -59
  179. data/lib/properties.xml +236 -0
  180. data/lib/properties/arbitrary.rng +26 -0
  181. data/lib/properties/attributes.rng +10 -0
  182. data/lib/properties/dataelements.rng +10 -0
  183. data/lib/properties/description.rng +8 -0
  184. data/lib/properties/dsl.rng +7 -0
  185. data/lib/properties/dslx.rng +8 -0
  186. data/lib/properties/endpoints.rng +10 -0
  187. data/lib/properties/handlerwrapper.rng +9 -0
  188. data/lib/properties/position.rng +15 -0
  189. data/lib/properties/positions.rng +10 -0
  190. data/lib/properties/properties.rng +29 -0
  191. data/lib/properties/set-properties.rng +25 -0
  192. data/lib/properties/set-some-properties.rng +45 -0
  193. data/lib/properties/simple.rng +8 -0
  194. data/lib/properties/state.rng +33 -0
  195. data/lib/properties/status.rng +12 -0
  196. data/lib/properties/t_attributes.rng +7 -0
  197. data/lib/properties/t_dataelements.rng +7 -0
  198. data/lib/properties/t_endpoints.rng +7 -0
  199. data/lib/properties/t_position.rng +7 -0
  200. data/lib/properties/t_positions.rng +7 -0
  201. data/lib/properties/t_simple.rng +7 -0
  202. data/lib/properties/t_status.rng +7 -0
  203. data/lib/properties/t_transformation.rng +7 -0
  204. data/lib/properties/transformation.rng +40 -0
  205. data/server/dev.rb +1 -0
  206. data/server/handlerwrappers/default.rb +40 -34
  207. data/server/resources/backend/README.md +17 -0
  208. data/server/resources/backend/instance.rb +23 -0
  209. data/server/resources/backend/instance.template +19 -0
  210. data/server/resources/backend/opts.yaml +6 -0
  211. data/server/resources/backend/run +29 -0
  212. data/server/resources/notifications/logging/subscription.xml +1 -1
  213. data/server/resources/properties.empty +38 -0
  214. data/server/resources/properties.init +11 -11
  215. data/server/resources/states.dot +19 -0
  216. data/server/resources/states.xml +49 -0
  217. data/server/resources/transformation_dslx.xsl +3 -0
  218. data/server/routing/end.rb +44 -0
  219. data/server/routing/forward-events.rb +59 -0
  220. data/server/routing/forward-votes.rb +108 -0
  221. data/server/routing/persist.rb +155 -0
  222. data/server/server.rb +1 -0
  223. data/tools/cpee +19 -15
  224. metadata +126 -156
  225. data/INSTALL +0 -23
  226. data/cockpit/test.html +0 -40
  227. data/cockpit/themes/compact/rngs/alternative.rng +0 -1
  228. data/cockpit/themes/compact/rngs/choose.rng +0 -1
  229. data/cockpit/themes/compact/rngs/critical.rng +0 -1
  230. data/cockpit/themes/compact/rngs/escape.rng +0 -1
  231. data/cockpit/themes/compact/rngs/group.rng +0 -1
  232. data/cockpit/themes/compact/rngs/loop.rng +0 -1
  233. data/cockpit/themes/compact/rngs/manipulate.rng +0 -1
  234. data/cockpit/themes/compact/rngs/otherwise.rng +0 -1
  235. data/cockpit/themes/compact/rngs/parallel.rng +0 -1
  236. data/cockpit/themes/compact/rngs/parallel_branch.rng +0 -1
  237. data/cockpit/themes/compact/rngs/stop.rng +0 -1
  238. data/cockpit/themes/compact/rngs/terminate.rng +0 -1
  239. data/cockpit/themes/default/rngs/finalize.rng +0 -6
  240. data/cockpit/themes/default/rngs/update.rng +0 -6
  241. data/cockpit/themes/default/theme.js +0 -1286
  242. data/cockpit/themes/extended/rngs/alternative.rng +0 -1
  243. data/cockpit/themes/extended/rngs/choose.rng +0 -1
  244. data/cockpit/themes/extended/rngs/critical.rng +0 -1
  245. data/cockpit/themes/extended/rngs/escape.rng +0 -1
  246. data/cockpit/themes/extended/rngs/group.rng +0 -1
  247. data/cockpit/themes/extended/rngs/loop.rng +0 -1
  248. data/cockpit/themes/extended/rngs/manipulate.rng +0 -1
  249. data/cockpit/themes/extended/rngs/otherwise.rng +0 -1
  250. data/cockpit/themes/extended/rngs/parallel.rng +0 -1
  251. data/cockpit/themes/extended/rngs/parallel_branch.rng +0 -1
  252. data/cockpit/themes/extended/rngs/stop.rng +0 -1
  253. data/cockpit/themes/extended/rngs/terminate.rng +0 -1
  254. data/cockpit/themes/labels/rngs/alternative.rng +0 -25
  255. data/cockpit/themes/labels/rngs/call.rng +0 -81
  256. data/cockpit/themes/labels/rngs/callmanipulate.rng +0 -101
  257. data/cockpit/themes/labels/rngs/choose.rng +0 -12
  258. data/cockpit/themes/labels/rngs/critical.rng +0 -5
  259. data/cockpit/themes/labels/rngs/escape.rng +0 -1
  260. data/cockpit/themes/labels/rngs/finalize.rng +0 -6
  261. data/cockpit/themes/labels/rngs/group.rng +0 -3
  262. data/cockpit/themes/labels/rngs/loop.rng +0 -22
  263. data/cockpit/themes/labels/rngs/manipulate.rng +0 -9
  264. data/cockpit/themes/labels/rngs/otherwise.rng +0 -22
  265. data/cockpit/themes/labels/rngs/parallel.rng +0 -13
  266. data/cockpit/themes/labels/rngs/parallel_branch.rng +0 -8
  267. data/cockpit/themes/labels/rngs/stop.rng +0 -5
  268. data/cockpit/themes/labels/rngs/terminate.rng +0 -1
  269. data/cockpit/themes/labels/rngs/update.rng +0 -6
  270. data/cockpit/themes/labels/symbols/alternative.svg +0 -5
  271. data/cockpit/themes/labels/symbols/arrow.svg +0 -3
  272. data/cockpit/themes/labels/symbols/call.svg +0 -6
  273. data/cockpit/themes/labels/symbols/callmanipulate.svg +0 -8
  274. data/cockpit/themes/labels/symbols/choose.svg +0 -5
  275. data/cockpit/themes/labels/symbols/choose_exclusive.svg +0 -5
  276. data/cockpit/themes/labels/symbols/choose_inclusive.svg +0 -4
  277. data/cockpit/themes/labels/symbols/complex.svg +0 -8
  278. data/cockpit/themes/labels/symbols/critical.svg +0 -4
  279. data/cockpit/themes/labels/symbols/end.svg +0 -3
  280. data/cockpit/themes/labels/symbols/escape.svg +0 -5
  281. data/cockpit/themes/labels/symbols/event_end.svg +0 -3
  282. data/cockpit/themes/labels/symbols/loop.svg +0 -5
  283. data/cockpit/themes/labels/symbols/manipulate.svg +0 -4
  284. data/cockpit/themes/labels/symbols/otherwise.svg +0 -5
  285. data/cockpit/themes/labels/symbols/parallel.svg +0 -5
  286. data/cockpit/themes/labels/symbols/parallel_branch.svg +0 -5
  287. data/cockpit/themes/labels/symbols/parallel_branch_compact.svg +0 -4
  288. data/cockpit/themes/labels/symbols/parallel_branch_event.svg +0 -14
  289. data/cockpit/themes/labels/symbols/parallel_branch_normal.svg +0 -5
  290. data/cockpit/themes/labels/symbols/scripts.svg +0 -4
  291. data/cockpit/themes/labels/symbols/start.svg +0 -3
  292. data/cockpit/themes/labels/symbols/stop.svg +0 -5
  293. data/cockpit/themes/labels/symbols/terminate.svg +0 -4
  294. data/cockpit/themes/packed/rngs/alternative.rng +0 -1
  295. data/cockpit/themes/packed/rngs/choose.rng +0 -1
  296. data/cockpit/themes/packed/rngs/critical.rng +0 -1
  297. data/cockpit/themes/packed/rngs/escape.rng +0 -1
  298. data/cockpit/themes/packed/rngs/group.rng +0 -1
  299. data/cockpit/themes/packed/rngs/loop.rng +0 -1
  300. data/cockpit/themes/packed/rngs/manipulate.rng +0 -1
  301. data/cockpit/themes/packed/rngs/otherwise.rng +0 -1
  302. data/cockpit/themes/packed/rngs/parallel.rng +0 -1
  303. data/cockpit/themes/packed/rngs/parallel_branch.rng +0 -1
  304. data/cockpit/themes/packed/rngs/stop.rng +0 -1
  305. data/cockpit/themes/packed/rngs/terminate.rng +0 -1
  306. data/cockpit/themes/preset/rngs/alternative.rng +0 -1
  307. data/cockpit/themes/preset/rngs/choose.rng +0 -1
  308. data/cockpit/themes/preset/rngs/critical.rng +0 -1
  309. data/cockpit/themes/preset/rngs/escape.rng +0 -1
  310. data/cockpit/themes/preset/rngs/group.rng +0 -1
  311. data/cockpit/themes/preset/rngs/loop.rng +0 -1
  312. data/cockpit/themes/preset/rngs/manipulate.rng +0 -1
  313. data/cockpit/themes/preset/rngs/otherwise.rng +0 -1
  314. data/cockpit/themes/preset/rngs/parallel.rng +0 -1
  315. data/cockpit/themes/preset/rngs/parallel_branch.rng +0 -1
  316. data/cockpit/themes/preset/rngs/stop.rng +0 -1
  317. data/cockpit/themes/preset/rngs/terminate.rng +0 -1
  318. data/lib/cpee/empty_workflow.rb +0 -28
  319. data/lib/cpee/handler_notifications.rb +0 -47
  320. data/lib/cpee/handler_properties.rb +0 -50
  321. data/lib/cpee/instantiation.rb +0 -368
  322. data/lib/cpee/processtransformation/bpel/Repository/booking.bpel +0 -125
  323. data/lib/cpee/processtransformation/bpel/Repository/booking.wsdl +0 -72
  324. data/lib/cpee/processtransformation/bpel/Repository/booking/airline.wsdl +0 -71
  325. data/lib/cpee/processtransformation/bpel/Repository/booking/hotel.wsdl +0 -64
  326. data/lib/cpee/processtransformation/bpel/Repository/booking/report.wsdl +0 -71
  327. data/lib/cpee/processtransformation/bpel/bpel2wee.rb +0 -34
  328. data/lib/cpee/processtransformation/bpel/bpelserver.ru +0 -64
  329. data/lib/cpee/processtransformation/bpel/bpelserver.xml +0 -70
  330. data/lib/cpee/processtransformation/bpel/lib/BPEL_Transform.rb +0 -367
  331. data/lib/cpee/processtransformation/bpmn2.rb +0 -297
  332. data/lib/cpee/processtransformation/cpee.rb +0 -119
  333. data/lib/cpee/processtransformation/structures.rb +0 -465
  334. data/lib/cpee/processtransformation/target.rb +0 -50
  335. data/log/azure.rb +0 -10
  336. data/log/azure_logger.rb +0 -136
  337. data/log/chain.xml +0 -27
  338. data/log/elasticsearch.rb +0 -15
  339. data/log/elasticsearch_logging.rb +0 -377
  340. data/log/legacy/test_es.rb +0 -26
  341. data/log/legacy/test_split.rb +0 -211
  342. data/log/log.xml +0 -13
  343. data/log/non_tamp.rb +0 -156
  344. data/log/sic.rb +0 -63
  345. data/log/template.xes_xml +0 -23
  346. data/log/template.xes_yaml +0 -28
  347. data/log/trace.yaml +0 -17717
  348. data/log/trace_sic.yaml +0 -18343
  349. data/log/xes_xml.rb +0 -121
  350. data/log/xes_yaml.rb +0 -96
  351. data/server/handlerwrappers/soap.rb +0 -146
  352. data/server/resources/notifications/logging/consumer-secret +0 -1
  353. data/server/resources/notifications/logging/producer-secret +0 -1
  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/server/resources/test1.xml +0 -58
  358. data/server/resources/test2.xml +0 -60
  359. data/server/resources/test3.xml +0 -217
  360. data/test/callback.rb +0 -9
@@ -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)
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