cpee 1.5.25 → 2.0.2

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 (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
@@ -0,0 +1,189 @@
1
+ require 'json'
2
+
3
+ module CPEE
4
+ module Notifications
5
+
6
+ def self::implementation(id,opts)
7
+ Proc.new do
8
+ on resource "notifications" do
9
+ run CPEE::Notifications::Overview if get
10
+ on resource "topics" do
11
+ run CPEE::Notifications::Topics, opts if get
12
+ end
13
+ on resource "subscriptions" do
14
+ run CPEE::Notifications::Subscriptions, id, opts if get
15
+ run CPEE::Notifications::CreateSubscription, id, opts if post 'subscribe'
16
+ on resource do
17
+ run CPEE::Notifications::Subscription, id, opts if get
18
+ run CPEE::Notifications::UpdateSubscription, id, opts if put 'subscribe'
19
+ run CPEE::Notifications::DeleteSubscription, id, opts if delete
20
+ on resource 'sse' do
21
+ run CPEE::Notifications::SSE, id, opts if sse
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ class Overview < Riddl::Implementation #{{{
30
+ def response
31
+ Riddl::Parameter::Complex.new("overview","text/xml") do
32
+ <<-END
33
+ <overview xmlns='http://riddl.org/ns/common-patterns/notifications-producer/2.0'>
34
+ <topics/>
35
+ <subscriptions/>
36
+ </overview>
37
+ END
38
+ end
39
+
40
+ end
41
+ end #}}}
42
+
43
+ class Topics < Riddl::Implementation #{{{
44
+ def response
45
+ opts = @a[0]
46
+ Riddl::Parameter::Complex.new("overview","text/xml") do
47
+ File.read(opts[:topics])
48
+ end
49
+ end
50
+ end #}}}
51
+
52
+ class Subscriptions < Riddl::Implementation #{{{
53
+ def response
54
+ id = @a[0]
55
+ opts = @a[1]
56
+ Riddl::Parameter::Complex.new("subscriptions","text/xml") do
57
+ ret = XML::Smart::string <<-END
58
+ <subscriptions xmlns='http://riddl.org/ns/common-patterns/notifications-producer/2.0'/>
59
+ END
60
+ CPEE::Persistence::extract_handlers(id,opts).each do |de|
61
+ ret.root.add('subscription').tap do |n|
62
+ n.attributes['id'] = de[0]
63
+ n.attributes['url'] = de[1] if de[1] && !de[1].empty?
64
+ end
65
+ end
66
+ ret.to_s
67
+ end
68
+ end
69
+ end #}}}
70
+
71
+ class Subscription < Riddl::Implementation #{{{
72
+ def response
73
+ id = @a[0]
74
+ opts = @a[1]
75
+ key = @r[-1]
76
+ Riddl::Parameter::Complex.new("subscriptions","text/xml") do
77
+ ret = XML::Smart::string <<-END
78
+ <subscription xmlns='http://riddl.org/ns/common-patterns/notifications-producer/2.0'/>
79
+ END
80
+ url = CPEE::Persistence::extract_item(id,opts,File.join('handler',key,'url'))
81
+ ret.root.attributes['url'] = url if url && !url.empty?
82
+ items = {}
83
+ CPEE::Persistence::extract_handler(id,opts,key).each do |h|
84
+ t, i, v = h.split('/')
85
+ items[t] ||= []
86
+ items[t] << [i,v]
87
+ end
88
+ items.each do |k,v|
89
+ ret.root.add('topic').tap do |n|
90
+ n.attributes['id'] = k
91
+ v.each do |e|
92
+ n.add *e
93
+ end
94
+ end
95
+ end
96
+ ret.to_s
97
+ end
98
+ end
99
+ end #}}}
100
+
101
+ class CreateSubscription < Riddl::Implementation #{{{
102
+ def response
103
+ id = @a[0]
104
+ opts = @a[1]
105
+ key = Digest::MD5.hexdigest(Kernel::rand().to_s)
106
+
107
+ url = @p[0].name == 'url' ? @p.shift.value : nil
108
+ values = []
109
+ while @p.length > 0
110
+ topic = @p.shift.value
111
+ base = @p.shift
112
+ type = base.name
113
+ values += base.value.split(',').map { |i| File.join(topic,type[0..-2],i) }
114
+ end
115
+ @header = CPEE::Persistence::set_handler(id,opts,key,url,values)
116
+
117
+ Riddl::Parameter::Simple.new('key',key)
118
+ end
119
+ end #}}}
120
+
121
+ class UpdateSubscription < Riddl::Implementation #{{{
122
+ def response
123
+ id = @a[0]
124
+ opts = @a[1]
125
+ key = @r.last
126
+
127
+ url = @p[0].name == 'url' ? @p.shift.value : nil
128
+ values = []
129
+ while @p.length > 0
130
+ topic = @p.shift.value
131
+ base = @p.shift
132
+ type = base.name
133
+ values += base.value.split(',').map { |i| File.join(topic,type[0..-2],i) }
134
+ end
135
+ @header = CPEE::Persistence::set_handler(id,opts,key,url,values,true)
136
+ end
137
+ end #}}}
138
+
139
+ class DeleteSubscription < Riddl::Implementation #{{{
140
+ def self::set(id,opts,key)
141
+ CPEE::Persistence::set_handler(id,opts,key,"",[],true)
142
+ end
143
+
144
+ def response
145
+ id = @a[0]
146
+ opts = @a[1]
147
+ key = @r.last
148
+
149
+ DeleteSubscription::set(id,opts,key)
150
+ nil
151
+ end
152
+ end #}}}
153
+
154
+ class SSE < Riddl::SSEImplementation #{{{
155
+ def onopen
156
+ @id = @a[0]
157
+ @opts = @a[1]
158
+ @key = @r[-2]
159
+ @conn = Redis.new(path: @opts[:redis_path], db: @opts[:redis_db])
160
+ EM.defer do
161
+ @conn.subscribe("forward:#{@id}/#{@key}", "forward-end:#{@id}/#{@key}") do |on|
162
+ on.message do |what, message|
163
+ if what == "forward-end:#{@id}/#{@key}"
164
+ @conn.unsubscribe
165
+ else
166
+ send message
167
+ end
168
+ end
169
+ end
170
+ @conn.close
171
+ end
172
+ EM.defer do
173
+ until closed?
174
+ send_with_id 'hearbeat', '42'
175
+ sleep 10
176
+ end
177
+ end
178
+ end
179
+
180
+ def onclose
181
+ tredis = Redis.new(path: @opts[:redis_path], db: @opts[:redis_db])
182
+ tredis.publish("forward-end:#{@id}/#{@key}",true)
183
+ tredis.close
184
+ DeleteSubscription::set(@id,@opts,@key)
185
+ end
186
+ end #}}}
187
+
188
+ end
189
+ end
@@ -0,0 +1,714 @@
1
+ require_relative 'attributes_helper'
2
+ require_relative 'value_helper'
3
+ require_relative 'transform'
4
+ require 'json'
5
+ require 'erb'
6
+ require 'yaml'
7
+
8
+ module CPEE
9
+ module Properties
10
+
11
+ def self::implementation(id,opts)
12
+ Proc.new do
13
+ run CPEE::Properties::Get, id, opts if get
14
+ run CPEE::Properties::Patch, id, opts if patch 'set-some-properties'
15
+ run CPEE::Properties::Put, id, opts if put 'set-some-properties'
16
+ on resource 'state' do
17
+ run CPEE::Properties::GetStateMachine, id, opts if get 'machine'
18
+ run CPEE::Properties::GetState, id, opts if get
19
+ run CPEE::Properties::PutState, id, opts if put 'state'
20
+ on resource '@changed' do
21
+ run CPEE::Properties::GetStateChanged, id, opts if get
22
+ end
23
+ end
24
+ on resource 'status' do
25
+ run CPEE::Properties::GetStatus, id, opts if get
26
+ run CPEE::Properties::PutStatus, id, opts if put 'status'
27
+ on resource 'id' do
28
+ run CPEE::Properties::GetStatusID, id, opts if get
29
+ end
30
+ on resource 'message' do
31
+ run CPEE::Properties::GetStatusMessage, id, opts if get
32
+ end
33
+ end
34
+ on resource 'handlerwrapper' do
35
+ run CPEE::Properties::GetHandlerWrapper, id, opts if get
36
+ run CPEE::Properties::PutHandlerWrapper, id, opts if put 'handlerwrapper'
37
+ end
38
+ on resource 'positions' do
39
+ run CPEE::Properties::GetPositions, id, opts if get
40
+ run CPEE::Properties::PatchPositions, id, opts if patch 'positions'
41
+ run CPEE::Properties::PutPositions, id, opts if put 'positions'
42
+ run CPEE::Properties::PostPositions, id, opts if post 'position'
43
+ on resource do
44
+ run CPEE::Properties::GetDetail, 'positions', id, opts if get
45
+ run CPEE::Properties::SetDetail, id, opts if put 'detail'
46
+ run CPEE::Properties::DelDetail, id, opts if delete
47
+ on resource '@passthrough' do
48
+ run CPEE::Properties::GetPt, id, opts if get
49
+ end
50
+ end
51
+ end
52
+ %w{dataelements endpoints attributes}.each do |ele|
53
+ on resource ele do
54
+ run CPEE::Properties::GetItems, ele, id, opts if get
55
+ run CPEE::Properties::PatchItems, ele, id, opts if patch ele
56
+ run CPEE::Properties::PutItems, ele, id, opts if put ele
57
+ run CPEE::Properties::PostItem, ele, id, opts if post ele[0..-2]
58
+ on resource do
59
+ run CPEE::Properties::GetItem, ele, id, opts if get
60
+ run CPEE::Properties::SetItem, ele, id, opts if put 'string'
61
+ run CPEE::Properties::DelItem, ele, id, opts if delete
62
+ end
63
+ end
64
+ end
65
+ on resource 'dsl' do
66
+ run CPEE::Properties::GetComplex, 'dsl', 'text/plain', id, opts if get
67
+ end
68
+ on resource 'dslx' do
69
+ run CPEE::Properties::GetComplex, 'dslx', 'text/xml', id, opts if get
70
+ end
71
+ on resource 'description' do
72
+ run CPEE::Properties::GetComplex, 'description', 'text/xml', id, opts if get
73
+ run CPEE::Properties::PutDescription, id, opts if put 'description'
74
+ end
75
+ on resource 'transformation' do
76
+ run CPEE::Properties::GetTransformation, id, opts if get
77
+ run CPEE::Properties::PutTransformation, id, opts if put 'transformation'
78
+ end
79
+ end
80
+ end
81
+
82
+ class Get < Riddl::Implementation #{{{
83
+ def response
84
+ id = @a[0]
85
+ opts = @a[1]
86
+ doc = XML::Smart::open_unprotected(opts[:properties_empty])
87
+ doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
88
+ doc.find('/p:properties/p:state').first.text = CPEE::Persistence::extract_item(id,opts,'state')
89
+ doc.find('/p:properties/p:state/@changed').first.value = CPEE::Persistence::extract_item(id,opts,'state/@changed')
90
+ doc.find('/p:properties/p:status/p:id').first.text = CPEE::Persistence::extract_item(id,opts,'status/id')
91
+ doc.find('/p:properties/p:status/p:message').first.text = CPEE::Persistence::extract_item(id,opts,'status/message')
92
+ %w{dataelements endpoints attributes}.each do |item|
93
+ des = doc.find("/p:properties/p:#{item}").first
94
+ CPEE::Persistence::extract_list(id,opts,item).each{ |de| des.add(*de) }
95
+ end
96
+ des = doc.find("/p:properties/p:positions").first
97
+ CPEE::Persistence::extract_set(id,opts,'positions').each do |de|
98
+ node = des.add(*de)
99
+ if pt = CPEE::Persistence::extract_item(id,opts,File.join('positions',de[0],'@passthrough'))
100
+ node.attributes['passthrough'] = pt
101
+ end
102
+ end
103
+ doc.find('/p:properties/p:dsl').first.text = CPEE::Persistence::extract_item(id,opts,'dsl')
104
+ if val = CPEE::Persistence::extract_item(id,opts,'dslx') #{{{
105
+ doc.find('/p:properties/p:dslx').first.add XML::Smart::string(val).root rescue nil
106
+ end #}}}
107
+ if val = CPEE::Persistence::extract_item(id,opts,'description') #{{{
108
+ doc.find('/p:properties/p:description').first.add XML::Smart::string(val).root rescue nil
109
+ end #}}}
110
+ doc.find('/p:properties/p:transformation/p:description').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/description')
111
+ doc.find('/p:properties/p:transformation/p:dataelements').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/dataelements')
112
+ doc.find('/p:properties/p:transformation/p:endpoints').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/endpoints')
113
+ doc.find('/p:properties/p:transformation/p:description/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/description/@type')
114
+ doc.find('/p:properties/p:transformation/p:dataelements/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/dataelements/@type')
115
+ doc.find('/p:properties/p:transformation/p:endpoints/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/endpoints/@type')
116
+ Riddl::Parameter::Complex.new('properties','application/xml',doc.to_s)
117
+ end
118
+ end #}}}
119
+ class Patch < Riddl::Implementation #{{{
120
+ def response
121
+ id = @a[0]
122
+ opts = @a[1]
123
+ if opts[:statemachine].readonly? id
124
+ @status = 400
125
+ else
126
+ doc = XML::Smart::string(@p[0].value.read)
127
+ doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
128
+ if (node = doc.find('/p:properties/p:status')).any?
129
+ CPEE::Properties::PutStatus::set id, opts, node.first.dump
130
+ end
131
+ if (node = doc.find('/p:properties/p:handlerwrapper')).any?
132
+ CPEE::Properties::PutHandlerWrapper::set id, opts, node.first.text
133
+ end
134
+
135
+ %w{dataelements endpoints attributes}.each do |item|
136
+ if (node = doc.find('/p:properties/p:' + item)).any?
137
+ CPEE::Properties::PatchItems::set item, id, opts, node.first.dump
138
+ end
139
+ end
140
+
141
+ if (node = doc.find('/p:properties/p:transformation')).any?
142
+ CPEE::Properties::PutTransformation::set id, opts, node.first.dump
143
+ end
144
+ if (node = doc.find('/p:properties/p:description/*')).any?
145
+ CPEE::Properties::PutDescription::set id, opts, node.first.dump
146
+ end
147
+
148
+ if (node = doc.find('/p:properties/p:positions')).any?
149
+ if node.first.find('p:*').any?
150
+ CPEE::Properties::PatchPositions::set id, opts, node.first.dump
151
+ end
152
+ end
153
+
154
+ if (node = doc.find('/p:properties/p:state')).any?
155
+ CPEE::Properties::PutState::run id, opts, node.first.text
156
+ end
157
+ end
158
+ end
159
+ end #}}}
160
+ class Put < Riddl::Implementation #{{{
161
+ def response
162
+ id = @a[0]
163
+ opts = @a[1]
164
+ if opts[:statemachine].readonly? id
165
+ @status = 400
166
+ else
167
+ doc = XML::Smart::string(@p[0].value.read)
168
+ doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
169
+ if (node = doc.find('/p:properties/p:status')).any?
170
+ CPEE::Properties::PutStatus::set id, opts, node.first.dump
171
+ end
172
+ if (node = doc.find('/p:properties/p:handlerwrapper')).any?
173
+ CPEE::Properties::PutHandlerWrapper::set id, opts, node.first.text
174
+ end
175
+
176
+ %w{dataelements endpoints attributes}.each do |item|
177
+ if (node = doc.find('/p:properties/p:' + item)).any?
178
+ CPEE::Properties::PutItems::set item, id, opts, node.first.dump
179
+ end
180
+ end
181
+
182
+ if (node = doc.find('/p:properties/p:transformation')).any?
183
+ CPEE::Properties::PutTransformation::set id, opts, node.first.dump
184
+ end
185
+ if (node = doc.find('/p:properties/p:description/*')).any?
186
+ CPEE::Properties::PutDescription::set id, opts, node.first.dump
187
+ end
188
+
189
+ if (node = doc.find('/p:properties/p:positions')).any?
190
+ if node.first.find('p:*').any?
191
+ CPEE::Properties::PutPositions::set id, opts, node.first.dump
192
+ end
193
+ end
194
+
195
+ if (node = doc.find('/p:properties/p:state')).any?
196
+ CPEE::Properties::PutState::run id, opts, node.first.text
197
+ end
198
+ end
199
+ end
200
+ end #}}}
201
+ class GetState < Riddl::Implementation #{{{
202
+ def response
203
+ id = @a[0]
204
+ opts = @a[1]
205
+ Riddl::Parameter::Simple.new('value',CPEE::Persistence::extract_item(id,opts,'state'))
206
+ end
207
+ end #}}}
208
+ class PutState < Riddl::Implementation #{{{
209
+ def self::set(id,opts,state)
210
+ CPEE::Persistence::set_item(id,opts,'state',:state => state, :timestamp => Time.now.xmlschema(3))
211
+ end
212
+
213
+ def self::run(id,opts,state)
214
+ exe = File.join(opts[:instances],id.to_s,File.basename(opts[:backend_run]))
215
+ case state
216
+ when 'running'
217
+ CPEE::Persistence::write_instance id, opts
218
+ pid = Kernel.spawn(exe , :out => exe + '.out', :err => exe + '.err')
219
+ File.write(exe + '.pid',pid)
220
+ Process.detach pid
221
+ when 'stopping'
222
+ pid = File.read(exe + '.pid') rescue nil
223
+ if pid && (Process.kill(0, pid) rescue false)
224
+ Process.kill('HUP', pid.to_i) rescue nil
225
+ else
226
+ File.unlink(exe + '.pid') rescue nil
227
+ PutState::set id, opts, 'stopped'
228
+ end
229
+ else
230
+ ### Most probably this is never needed. Lets see.
231
+ PutState::set id, opts, state
232
+ end
233
+ end
234
+
235
+ def response
236
+ id = @a[0]
237
+ opts = @a[1]
238
+ state = @p[0].value
239
+ if opts[:statemachine].setable? id, state
240
+ PutState::run id, opts, state
241
+ else
242
+ @status = 422
243
+ end
244
+ nil
245
+ end
246
+ end #}}}
247
+ class GetStateMachine < Riddl::Implementation #{{{
248
+ def response
249
+ id = @a[0]
250
+ opts = @a[1]
251
+ Riddl::Parameter::Complex.new('statemachine','text/xml',File.read(opts[:states]))
252
+ end
253
+ end #}}}
254
+ class GetStateChanged < Riddl::Implementation #{{{
255
+ def response
256
+ id = @a[0]
257
+ opts = @a[1]
258
+ Riddl::Parameter::Simple.new('state',CPEE::Persistence::extract_item(id,opts,'state/@changed'))
259
+ end
260
+ end #}}}
261
+ class GetStatus < Riddl::Implementation #{{{
262
+ def response
263
+ id = @a[0]
264
+ opts = @a[1]
265
+ doc = XML::Smart::open_unprotected(opts[:properties_empty])
266
+ doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
267
+ des = doc.find('/p:properties/p:status').first
268
+ des.find('p:id').first.text = CPEE::Persistence::extract_item(id,opts,'status/id')
269
+ des.find('p:message').first.text = CPEE::Persistence::extract_item(id,opts,'status/message')
270
+ Riddl::Parameter::Complex.new('status','text/xml',des.to_doc.to_s)
271
+ end
272
+ end #}}}
273
+ class PutStatus < Riddl::Implementation #{{{
274
+ def self::set(id,opts,xml)
275
+ doc = XML::Smart::string(xml)
276
+ doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
277
+ CPEE::Persistence::set_item(id,opts,'status',:id => doc.find('string(/p:status/p:id)').to_i, :message => doc.find('string(/p:status/p:message)'))
278
+ end
279
+
280
+ def response
281
+ id = @a[0]
282
+ opts = @a[1]
283
+ if opts[:statemachine].readonly? id
284
+ @status = 422 # semantic error
285
+ else
286
+ PutStatus::set id, opts, @p[0].value.read
287
+ end
288
+ nil
289
+ end
290
+ end #}}}
291
+ class GetStatusID < Riddl::Implementation #{{{
292
+ def response
293
+ id = @a[0]
294
+ opts = @a[1]
295
+ Riddl::Parameter::Simple.new('value',CPEE::Persistence::extract_item(id,opts,'status/id'))
296
+ end
297
+ end #}}}
298
+ class GetStatusMessage < Riddl::Implementation #{{{
299
+ def response
300
+ id = @a[0]
301
+ opts = @a[1]
302
+ Riddl::Parameter::Simple.new('value',CPEE::Persistence::extract_item(id,opts,'status/message'))
303
+ end
304
+ end #}}}
305
+ class GetHandlerWrapper < Riddl::Implementation #{{{
306
+ def response
307
+ id = @a[0]
308
+ opts = @a[1]
309
+ Riddl::Parameter::Simple.new('value',CPEE::Persistence::extract_item(id,opts,'handlerwrapper'))
310
+ end
311
+ end #}}}
312
+ class PutHandlerWrapper < Riddl::Implementation #{{{
313
+ def self::set(id,opts,hw)
314
+ CPEE::Persistence::set_item(id,opts,'handlerwrapper',:handlerwrapper => hw)
315
+ end
316
+ def response
317
+ id = @a[0]
318
+ opts = @a[1]
319
+ if opts[:statemachine].readonly? id
320
+ @status = 423
321
+ else
322
+ PutHandlerWrapper::set(id,opts,@p[0].value)
323
+ end
324
+ nil
325
+ end
326
+ end #}}}
327
+ class GetItems < Riddl::Implementation #{{{
328
+ def response
329
+ item = @a[0]
330
+ id = @a[1]
331
+ opts = @a[2]
332
+ doc = XML::Smart::open_unprotected(opts[:properties_empty])
333
+ doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
334
+ des = doc.find("/p:properties/p:#{item}").first
335
+ CPEE::Persistence::extract_list(id,opts,item).each{ |de| des.add(*de) }
336
+ Riddl::Parameter::Complex.new(item,'text/xml',des.to_doc.to_s)
337
+ end
338
+ end #}}}
339
+ class PatchItems < Riddl::Implementation #{{{
340
+ def self::set_hash(item, id, opts, val)
341
+ CPEE::Persistence::set_list(id,opts,item,val)
342
+ end
343
+ def self::set(item, id, opts, xml)
344
+ doc = XML::Smart::string(xml)
345
+ val = doc.find("/*/*").map do |ele|
346
+ [ele.qname.name, ele.text]
347
+ end.to_h
348
+ CPEE::Persistence::set_list(id,opts,item,val)
349
+ end
350
+
351
+ def response
352
+ item = @a[0]
353
+ id = @a[1]
354
+ opts = @a[2]
355
+ if opts[:statemachine].readonly? id
356
+ @status = 423
357
+ else
358
+ begin
359
+ PatchItems::set(item,id,opts,@p[0].value.read)
360
+ rescue
361
+ @status = 400
362
+ end
363
+ end
364
+ nil
365
+ end
366
+ end #}}}
367
+ class PutItems < Riddl::Implementation #{{{
368
+ def self::set(item,id,opts,xml)
369
+ doc = XML::Smart::string(xml)
370
+ val = {}
371
+ doc.find("/*/*").each do |ele|
372
+ val[ele.qname.name] = ele.text unless val.has_key?(ele.qname.name)
373
+ end
374
+ oldkeys = CPEE::Persistence::extract_list(id,opts,item).to_h.keys
375
+ newkeys = val.keys
376
+ del = oldkeys - newkeys
377
+ CPEE::Persistence::set_list(id,opts,item,val,del)
378
+ end
379
+
380
+ def response
381
+ item = @a[0]
382
+ id = @a[1]
383
+ opts = @a[2]
384
+ if opts[:statemachine].readonly? id
385
+ @status = 423
386
+ else
387
+ begin
388
+ PutItems::set(item,id,opts,@p[0].value.read)
389
+ rescue
390
+ @status = 400
391
+ end
392
+ end
393
+ nil
394
+ end
395
+ end #}}}
396
+ class PostItem < Riddl::Implementation #{{{
397
+ def response
398
+ item = @a[0]
399
+ id = @a[1]
400
+ opts = @a[2]
401
+ if opts[:statemachine].readonly? id
402
+ @status = 423
403
+ else
404
+ begin
405
+ doc = XML::Smart::string(@p[0].value.read)
406
+ val = doc.find("/*").map do |ele|
407
+ [ele.qname.name, ele.text]
408
+ end.to_h
409
+ if not CPEE::Persistence::extract_item(id,opts,File.join(@r.first,val.keys.first))
410
+ CPEE::Persistence::set_list(id,opts,item,val)
411
+ Riddl::Parameter::Simple.new('id',val.keys.first)
412
+ else
413
+ @status= 409
414
+ end
415
+ rescue => e
416
+ @status = 400
417
+ end
418
+ end
419
+ nil
420
+ end
421
+ end #}}}
422
+ class GetItem < Riddl::Implementation #{{{
423
+ def response
424
+ item = @a[0]
425
+ id = @a[1]
426
+ opts = @a[2]
427
+ if val = CPEE::Persistence::extract_item(id,opts,@r.join('/'))
428
+ Riddl::Parameter::Simple.new('value',val)
429
+ else
430
+ @status = 404
431
+ end
432
+ end
433
+ end #}}}
434
+ class SetItem < Riddl::Implementation #{{{
435
+ def response
436
+ item = @a[0]
437
+ id = @a[1]
438
+ opts = @a[2]
439
+ val = { @r.last => @p[0].value }
440
+ if CPEE::Persistence::extract_item(id,opts,@r.join('/'))
441
+ CPEE::Persistence::set_list(id,opts,item,val)
442
+ else
443
+ @status = 404
444
+ end
445
+ nil
446
+ end
447
+ end #}}}
448
+ class DelItem < Riddl::Implementation #{{{
449
+ def response
450
+ item = @a[0]
451
+ id = @a[1]
452
+ opts = @a[2]
453
+ val = { @r.last => nil }
454
+ if opts[:statemachine].readonly? id
455
+ @status = 423
456
+ else
457
+ if CPEE::Persistence::extract_item(id,opts,@r.join('/'))
458
+ CPEE::Persistence::set_list(id,opts,item,val,val.keys)
459
+ else
460
+ @status = 404
461
+ end
462
+ end
463
+ nil
464
+ end
465
+ end #}}}
466
+
467
+ class GetComplex < Riddl::Implementation #{{{
468
+ def response
469
+ item = @a[0]
470
+ mime = @a[1]
471
+ id = @a[2]
472
+ opts = @a[3]
473
+ if val = CPEE::Persistence::extract_item(id,opts,@r.join('/'))
474
+ Riddl::Parameter::Complex.new(item,mime,val)
475
+ else
476
+ @status = 404
477
+ end
478
+ end
479
+ end #}}}
480
+
481
+ class GetPositions < Riddl::Implementation #{{{
482
+ def response
483
+ id = @a[0]
484
+ opts = @a[1]
485
+ doc = XML::Smart::open_unprotected(opts[:properties_empty])
486
+ doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
487
+ des = doc.find("/p:properties/p:positions").first
488
+ CPEE::Persistence::extract_set(id,opts,'positions').each do |de|
489
+ node = des.add(*de)
490
+ if pt = CPEE::Persistence::extract_item(id,opts,File.join('positions',de[0],'@passthrough'))
491
+ node.attributes['passthrough'] = pt
492
+ end
493
+ end
494
+ Riddl::Parameter::Complex.new('positions','text/xml',des.to_doc.to_s)
495
+ end
496
+ end #}}}
497
+ class PatchPositions < Riddl::Implementation #{{{
498
+ def self::set(id,opts,xml)
499
+ doc = XML::Smart::string(xml)
500
+ content = {}
501
+ doc.find("/*/*").map do |ele|
502
+ val = { 'position' => ele.qname.name }
503
+ val['passthrough'] = ele.attributes['passthrough'] if ele.attributes['passthrough']
504
+ content[ele.text] ||= []
505
+ content[ele.text] << val
506
+ end
507
+ CPEE::Persistence::set_item(id,opts,'position',content)
508
+ end
509
+
510
+ def response
511
+ id = @a[0]
512
+ opts = @a[1]
513
+ if opts[:statemachine].readonly? id
514
+ @status = 423
515
+ else
516
+ begin
517
+ PatchPositions::set(id,opts,@p[0].value.read)
518
+ rescue => e
519
+ @status = 400
520
+ end
521
+ end
522
+ nil
523
+ end
524
+ end #}}}
525
+ class PutPositions < Riddl::Implementation #{{{
526
+ def PutPositions::set(id,opts,xml)
527
+ doc = XML::Smart::string(xml)
528
+ content = {}
529
+ newkeys = []
530
+ doc.find("/*/*").map do |ele|
531
+ val = { 'position' => ele.qname.name }
532
+ val['passthrough'] = ele.attributes['passthrough'] if ele.attributes['passthrough']
533
+ content[ele.text] ||= []
534
+ content[ele.text] << val
535
+ newkeys << ele.qname.name
536
+ end
537
+ oldkeys = CPEE::Persistence::extract_set(id,opts,'positions').to_h.keys
538
+ del = oldkeys - newkeys
539
+ del.each do |key|
540
+ val = { 'position' => key }
541
+ content['unmark'] ||= []
542
+ content['unmark'] << val
543
+ end
544
+ CPEE::Persistence::set_item(id,opts,'position',content)
545
+ end
546
+
547
+ def response
548
+ id = @a[0]
549
+ opts = @a[1]
550
+ if opts[:statemachine].readonly? id
551
+ @status = 423
552
+ else
553
+ begin
554
+ PutPositions::set(id,opts,@p[0].value.read)
555
+ rescue => e
556
+ @status = 400
557
+ end
558
+ end
559
+ nil
560
+ end
561
+ end #}}}
562
+ class PostPositions < Riddl::Implementation #{{{
563
+ def response
564
+ id = @a[0]
565
+ opts = @a[1]
566
+ if opts[:statemachine].readonly? id
567
+ @status = 423
568
+ else
569
+ begin
570
+ doc = XML::Smart::string(@p[0].value.read)
571
+ if not CPEE::Persistence::extract_item(id,opts,File.join('positions',doc.root.qname.name))
572
+ content = {}
573
+ content[doc.root.text] = [{ 'position' => doc.root.qname.name }]
574
+ content[doc.root.text][0]['passthrough'] = doc.root.attributes['passthrough'] if doc.root.attributes['passthrough']
575
+ CPEE::Persistence::set_item(id,opts,'position',content)
576
+ else
577
+ @status= 409
578
+ end
579
+ Riddl::Parameter::Simple.new('id',doc.root.qname.name)
580
+ rescue => e
581
+ @status = 400
582
+ end
583
+ end
584
+ nil
585
+ end
586
+ end #}}}
587
+ class GetDetail < Riddl::Implementation #{{{
588
+ def response
589
+ item = @a[0]
590
+ id = @a[1]
591
+ opts = @a[2]
592
+ if val = CPEE::Persistence::extract_item(id,opts,@r.join('/'))
593
+ Riddl::Parameter::Simple.new('value',val)
594
+ else
595
+ @status = 404
596
+ end
597
+ end
598
+ end #}}}
599
+ class SetDetail < Riddl::Implementation #{{{
600
+ def response
601
+ id = @a[0]
602
+ opts = @a[1]
603
+ if CPEE::Persistence::extract_item(id,opts,@r.join('/'))
604
+ CPEE::Persistence::set_item(id,opts,'position',@p[0].value => [ { 'position' => @r.last } ])
605
+ else
606
+ @status = 404
607
+ end
608
+ nil
609
+ end
610
+ end #}}}
611
+ class DelDetail < Riddl::Implementation #{{{
612
+ def response
613
+ id = @a[0]
614
+ opts = @a[1]
615
+ if CPEE::Persistence::extract_item(id,opts,@r.join('/'))
616
+ CPEE::Persistence::set_position(id,opts,'position','unmark' => [ { 'position' => @r.last } ])
617
+ else
618
+ @status = 404
619
+ end
620
+ nil
621
+ end
622
+ end #}}}
623
+ class GetPt < Riddl::Implementation #{{{
624
+ def response
625
+ id = @a[0]
626
+ opts = @a[1]
627
+ if val = CPEE::Persistence::extract_item(id,opts,@r.join('/'))
628
+ Riddl::Parameter::Simple.new('value',val)
629
+ else
630
+ @status = 404
631
+ end
632
+ end
633
+ end #}}}
634
+
635
+ class PutDescription < Riddl::Implementation #{{{
636
+ def self::set(id,opts,xml)
637
+ dslx, dsl, de, ep = transform(
638
+ xml,
639
+ CPEE::Persistence::extract_item(id,opts,'transformation/description'),
640
+ CPEE::Persistence::extract_item(id,opts,'transformation/description/@type'),
641
+ CPEE::Persistence::extract_item(id,opts,'transformation/dataelements'),
642
+ CPEE::Persistence::extract_item(id,opts,'transformation/dataelements/@type'),
643
+ CPEE::Persistence::extract_item(id,opts,'transformation/endpoints'),
644
+ CPEE::Persistence::extract_item(id,opts,'transformation/endpoints/@type'),
645
+ opts
646
+ )
647
+ CPEE::Persistence::set_item(id,opts,'description',
648
+ :description => xml,
649
+ :dslx => dslx,
650
+ :dsl => dsl
651
+ )
652
+ PatchItems::set_hash('dataelements',id,opts,de) unless de.empty?
653
+ PatchItems::set_hash('dataelements',id,opts,ep) unless ep.empty?
654
+ end
655
+
656
+ def response
657
+ id = @a[0]
658
+ opts = @a[1]
659
+ if opts[:statemachine].readonly? id
660
+ @status = 422 # semantic error
661
+ else
662
+ begin
663
+ PutDescription::set(id,opts,@p[0].value.read)
664
+ rescue
665
+ @status = 400
666
+ end
667
+ end
668
+ nil
669
+ end
670
+ end #}}}
671
+
672
+ class GetTransformation < Riddl::Implementation #{{{
673
+ def response
674
+ id = @a[0]
675
+ opts = @a[1]
676
+ doc = XML::Smart::open_unprotected(opts[:properties_empty])
677
+ doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
678
+ des = doc.find('/p:properties/p:transformation').first
679
+ des.find('p:description').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/description')
680
+ des.find('p:dataelements').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/dataelements')
681
+ des.find('p:endpoints').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/endpoints')
682
+ des.find('p:description/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/description/@type')
683
+ des.find('p:dataelements/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/dataelements/@type')
684
+ des.find('p:endpoints/@type').first.text = CPEE::Persistence::extract_item(id,opts,'transformation/endpoints/@type')
685
+ Riddl::Parameter::Complex.new('status','text/xml',des.to_doc.to_s)
686
+ end
687
+ end #}}}
688
+ class PutTransformation < Riddl::Implementation #{{{
689
+ def self::set(id,opts,xml)
690
+ doc = XML::Smart::string(xml)
691
+ doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
692
+ CPEE::Persistence::set_item(id,opts,'transformation',
693
+ :description => doc.find('string(/p:transformation/p:description)'),
694
+ :description_type => doc.find('string(/p:transformation/p:description/@type)'),
695
+ :dataelements =>doc.find('string(/p:transformation/p:dataelements)'),
696
+ :dataelements_type => doc.find('string(/p:transformation/p:dataelements/@type)'),
697
+ :endpoints =>doc.find('string(/p:transformation/p:endpoints)'),
698
+ :endpoints_type => doc.find('string(/p:transformation/p:endpoints/@type)')
699
+ )
700
+ end
701
+ def response
702
+ id = @a[0]
703
+ opts = @a[1]
704
+ if opts[:statemachine].readonly? id
705
+ @status = 422 # semantic error
706
+ else
707
+ PutTransformation::set(id,opts,@p[0].value.read)
708
+ end
709
+ nil
710
+ end
711
+ end #}}}
712
+
713
+ end
714
+ end