cpee 1.5.16 → 1.5.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cockpit/js/instance.js +1 -1
- data/cockpit/js/wfadaptor.js +1 -1
- data/cockpit/testsets/BCO.xml +2 -2
- data/cockpit/testsets/BCS.xml +2 -2
- data/cockpit/testsets/Lego Full.xml +142 -0
- data/cockpit/testsets/Lego Liddy.xml +40 -0
- data/cockpit/testsets/Lego_Part_1.xml +85 -0
- data/cockpit/testsets/Linear.xml +2 -2
- data/cockpit/testsets/Syncing P34 1.xml +2 -2
- data/cockpit/testsets/Syncing P34 2.xml +2 -2
- data/cockpit/testsets/Syncing P34 3.xml +2 -2
- data/cockpit/testsets/Syncing P34.xml +2 -2
- data/cockpit/testsets/testsets.xml +3 -1
- data/cockpit/themes/compact/theme.js +73 -45
- data/cockpit/themes/extended/theme.js +73 -45
- data/cockpit/themes/packed/theme.js +73 -45
- data/cockpit/themes/preset/theme.js +73 -45
- data/cpee.gemspec +1 -1
- data/lib/cpee/instantiation.rb +22 -5
- data/lib/instantiation.xml +9 -0
- data/log/azure.rb +10 -0
- data/log/azure_logger.rb +136 -0
- data/server/handlerwrappers/default.rb +8 -8
- data/server/resources/transformation_dslx.xsl +24 -5
- data/server/server.pid +1 -0
- metadata +8 -2
@@ -152,7 +152,7 @@ function WFAdaptorManifestation(adaptor) {
|
|
152
152
|
'params': [null, xml_node]
|
153
153
|
}];
|
154
154
|
}
|
155
|
-
if($('>
|
155
|
+
if($('> code', xml_node).length > 0 && xml_node.get(0).tagName == 'call') {
|
156
156
|
var icon = self.elements.callmanipulate.illustrator.svg.clone();
|
157
157
|
icon.children('.rfill:last').addClass('menu');
|
158
158
|
menu['Delete'].push({
|
@@ -160,7 +160,7 @@ function WFAdaptorManifestation(adaptor) {
|
|
160
160
|
'function_call': self.adaptor.description.remove,
|
161
161
|
'menu_icon': icon,
|
162
162
|
'type': undefined,
|
163
|
-
'params': ['>
|
163
|
+
'params': ['> code', xml_node]
|
164
164
|
});
|
165
165
|
}
|
166
166
|
if (xml_node.get(0).tagName == "call" || xml_node.get(0).tagName == "manipulate" || xml_node.get(0).tagName == "stop") {
|
@@ -253,7 +253,7 @@ function WFAdaptorManifestation(adaptor) {
|
|
253
253
|
},
|
254
254
|
'info': function(node){ return { 'element-endpoint': $(node).attr('endpoint') }; },
|
255
255
|
'resolve_symbol': function(node) {
|
256
|
-
if($('
|
256
|
+
if($('code', node).length > 0) {
|
257
257
|
return 'callmanipulate';
|
258
258
|
} else {
|
259
259
|
return 'call';
|
@@ -263,7 +263,7 @@ function WFAdaptorManifestation(adaptor) {
|
|
263
263
|
},//}}}
|
264
264
|
'description': self.adaptor.theme_dir + 'rngs/call.rng',
|
265
265
|
'permissible_children': function(node,mode) { //{{{
|
266
|
-
if(node.children('
|
266
|
+
if(node.children('code').length < 1)
|
267
267
|
return [
|
268
268
|
{'label': 'Scripts',
|
269
269
|
'function_call': self.adaptor.description.insert_last_into,
|
@@ -538,7 +538,7 @@ function WFAdaptorManifestation(adaptor) {
|
|
538
538
|
var childs = null;
|
539
539
|
if (mode == 'into') { func = self.adaptor.description.insert_first_into }
|
540
540
|
else { func = self.adaptor.description.insert_after }
|
541
|
-
|
541
|
+
var childs = [
|
542
542
|
{'label': 'Service Call with Scripts',
|
543
543
|
'function_call': func,
|
544
544
|
'menu_icon': self.elements.callmanipulate.illustrator.svg.clone(),
|
@@ -578,13 +578,18 @@ function WFAdaptorManifestation(adaptor) {
|
|
578
578
|
'function_call': func,
|
579
579
|
'menu_icon': self.elements.stop.illustrator.svg.clone(),
|
580
580
|
'type': 'stop',
|
581
|
-
'params': [self.adaptor.description.elements.stop, node]}
|
582
|
-
{'label': 'Critical',
|
583
|
-
'function_call': func,
|
584
|
-
'menu_icon': self.elements.critical.illustrator.svg.clone(),
|
585
|
-
'type': 'critical',
|
586
|
-
'params': [self.adaptor.description.elements.critical, node]}
|
581
|
+
'params': [self.adaptor.description.elements.stop, node]}
|
587
582
|
];
|
583
|
+
if(node.parent('parallel_branch').length > 0) {
|
584
|
+
childs.push({
|
585
|
+
'label': 'Critical',
|
586
|
+
'function_call': func,
|
587
|
+
'menu_icon': self.elements.critical.illustrator.svg.clone(),
|
588
|
+
'type': 'critical',
|
589
|
+
'params': [self.adaptor.description.elements.critical, node]
|
590
|
+
});
|
591
|
+
}
|
592
|
+
return childs;
|
588
593
|
}, //}}}
|
589
594
|
'adaptor': {//{{{
|
590
595
|
'mousedown': function (node,e) {
|
@@ -625,7 +630,7 @@ function WFAdaptorManifestation(adaptor) {
|
|
625
630
|
'type': 'parallel_branch',
|
626
631
|
'params': [self.adaptor.description.elements.parallel_branch, node]}];
|
627
632
|
}
|
628
|
-
|
633
|
+
var childs = [
|
629
634
|
{'label': 'Service Call with Scripts',
|
630
635
|
'function_call': func,
|
631
636
|
'menu_icon': self.elements.callmanipulate.illustrator.svg.clone(),
|
@@ -665,13 +670,18 @@ function WFAdaptorManifestation(adaptor) {
|
|
665
670
|
'function_call': func,
|
666
671
|
'menu_icon': self.elements.stop.illustrator.svg.clone(),
|
667
672
|
'type': 'stop',
|
668
|
-
'params': [self.adaptor.description.elements.stop, node]}
|
669
|
-
{'label': 'Critical',
|
670
|
-
'function_call': func,
|
671
|
-
'menu_icon': self.elements.critical.illustrator.svg.clone(),
|
672
|
-
'type': 'critical',
|
673
|
-
'params': [self.adaptor.description.elements.critical, node]}
|
673
|
+
'params': [self.adaptor.description.elements.stop, node]}
|
674
674
|
];
|
675
|
+
if(node.parent('parallel_branch').length > 0) {
|
676
|
+
childs.push({
|
677
|
+
'label': 'Critical',
|
678
|
+
'function_call': func,
|
679
|
+
'menu_icon': self.elements.critical.illustrator.svg.clone(),
|
680
|
+
'type': 'critical',
|
681
|
+
'params': [self.adaptor.description.elements.critical, node]
|
682
|
+
});
|
683
|
+
}
|
684
|
+
return childs;
|
675
685
|
}, //}}}
|
676
686
|
'adaptor': {//{{{
|
677
687
|
'mousedown': function (node,e) {
|
@@ -717,7 +727,7 @@ function WFAdaptorManifestation(adaptor) {
|
|
717
727
|
'menu_icon': self.elements.call.illustrator.svg.clone(),
|
718
728
|
'type': 'call',
|
719
729
|
'params': [self.adaptor.description.elements.call, node]},
|
720
|
-
{'label': '
|
730
|
+
{'label': 'Script',
|
721
731
|
'function_call': func,
|
722
732
|
'menu_icon': self.elements.manipulate.illustrator.svg.clone(),
|
723
733
|
'type': 'manipulate',
|
@@ -741,13 +751,17 @@ function WFAdaptorManifestation(adaptor) {
|
|
741
751
|
'function_call': func,
|
742
752
|
'menu_icon': self.elements.stop.illustrator.svg.clone(),
|
743
753
|
'type': 'stop',
|
744
|
-
'params': [self.adaptor.description.elements.stop, node]}
|
745
|
-
{'label': 'Critical',
|
746
|
-
'function_call': func,
|
747
|
-
'menu_icon': self.elements.critical.illustrator.svg.clone(),
|
748
|
-
'type': 'critical',
|
749
|
-
'params': [self.adaptor.description.elements.critical, node]}
|
754
|
+
'params': [self.adaptor.description.elements.stop, node]}
|
750
755
|
];
|
756
|
+
if(node.parent('parallel_branch').length > 0) {
|
757
|
+
childs.push({
|
758
|
+
'label': 'Critical',
|
759
|
+
'function_call': func,
|
760
|
+
'menu_icon': self.elements.critical.illustrator.svg.clone(),
|
761
|
+
'type': 'critical',
|
762
|
+
'params': [self.adaptor.description.elements.critical, node]
|
763
|
+
});
|
764
|
+
}
|
751
765
|
if(node.parent('parallel').length > node.parent('parallel_branch').length) {
|
752
766
|
childs.push({'label': 'Parallel Branch',
|
753
767
|
'function_call': func,
|
@@ -807,7 +821,7 @@ function WFAdaptorManifestation(adaptor) {
|
|
807
821
|
'menu_icon': self.elements.call.illustrator.svg.clone(),
|
808
822
|
'type': 'call',
|
809
823
|
'params': [self.adaptor.description.elements.call, node]},
|
810
|
-
{'label': '
|
824
|
+
{'label': 'Script',
|
811
825
|
'function_call': func,
|
812
826
|
'menu_icon': self.elements.manipulate.illustrator.svg.clone(),
|
813
827
|
'type': 'manipulate',
|
@@ -826,7 +840,12 @@ function WFAdaptorManifestation(adaptor) {
|
|
826
840
|
'function_call': func,
|
827
841
|
'menu_icon': self.elements.parallel_branch.illustrator.svg.clone(),
|
828
842
|
'type': 'parallel_branch',
|
829
|
-
'params': [self.adaptor.description.elements.parallel_branch, node]}
|
843
|
+
'params': [self.adaptor.description.elements.parallel_branch, node]},
|
844
|
+
{'label': 'Stop',
|
845
|
+
'function_call': func,
|
846
|
+
'menu_icon': self.elements.stop.illustrator.svg.clone(),
|
847
|
+
'type': 'stop',
|
848
|
+
'params': [self.adaptor.description.elements.stop, node]}
|
830
849
|
];
|
831
850
|
if(node.get(0).tagName != 'parallel')
|
832
851
|
childs.push({'label': 'Parallel',
|
@@ -872,10 +891,9 @@ function WFAdaptorManifestation(adaptor) {
|
|
872
891
|
'description': self.adaptor.theme_dir + 'rngs/parallel_branch.rng',
|
873
892
|
'permissible_children': function(node,mode) { //{{{
|
874
893
|
var func = null;
|
875
|
-
var childs = null;
|
876
894
|
if (mode == 'into') { func = self.adaptor.description.insert_first_into }
|
877
895
|
else { func = self.adaptor.description.insert_after }
|
878
|
-
childs =
|
896
|
+
var childs = [
|
879
897
|
{'label': 'Service Call with Scripts',
|
880
898
|
'function_call': func,
|
881
899
|
'menu_icon': self.elements.callmanipulate.illustrator.svg.clone(),
|
@@ -920,7 +938,7 @@ function WFAdaptorManifestation(adaptor) {
|
|
920
938
|
'function_call': func,
|
921
939
|
'menu_icon': self.elements.critical.illustrator.svg.clone(),
|
922
940
|
'type': 'critical',
|
923
|
-
'params': [self.adaptor.description.elements.critical, node]}
|
941
|
+
'params': [self.adaptor.description.elements.critical, node]}
|
924
942
|
];
|
925
943
|
if(node.parents('choose').length > node.parents('alternative, otherwise').length && node.get(0).tagName == 'parallel_branch') {
|
926
944
|
return [{'label': 'Alternative',
|
@@ -965,7 +983,7 @@ function WFAdaptorManifestation(adaptor) {
|
|
965
983
|
var func = null;
|
966
984
|
if (mode == 'into') { func = self.adaptor.description.insert_first_into }
|
967
985
|
else { func = self.adaptor.description.insert_after }
|
968
|
-
|
986
|
+
var childs = [
|
969
987
|
{'label': 'Service Call with Scripts',
|
970
988
|
'function_call': func,
|
971
989
|
'menu_icon': self.elements.callmanipulate.illustrator.svg.clone(),
|
@@ -1005,13 +1023,18 @@ function WFAdaptorManifestation(adaptor) {
|
|
1005
1023
|
'function_call': func,
|
1006
1024
|
'menu_icon': self.elements.stop.illustrator.svg.clone(),
|
1007
1025
|
'type': 'stop',
|
1008
|
-
'params': [self.adaptor.description.elements.stop, node]}
|
1009
|
-
{'label': 'Critical',
|
1010
|
-
'function_call': func,
|
1011
|
-
'menu_icon': self.elements.critical.illustrator.svg.clone(),
|
1012
|
-
'type': 'critical',
|
1013
|
-
'params': [self.adaptor.description.elements.critical, node]},
|
1026
|
+
'params': [self.adaptor.description.elements.stop, node]}
|
1014
1027
|
];
|
1028
|
+
if(node.parent('parallel_branch').length > 0) {
|
1029
|
+
childs.push({
|
1030
|
+
'label': 'Critical',
|
1031
|
+
'function_call': func,
|
1032
|
+
'menu_icon': self.elements.critical.illustrator.svg.clone(),
|
1033
|
+
'type': 'critical',
|
1034
|
+
'params': [self.adaptor.description.elements.critical, node]
|
1035
|
+
});
|
1036
|
+
}
|
1037
|
+
return childs;
|
1015
1038
|
}, //}}}
|
1016
1039
|
'adaptor': {//{{{
|
1017
1040
|
'mousedown': function (node,e) {
|
@@ -1075,7 +1098,7 @@ function WFAdaptorManifestation(adaptor) {
|
|
1075
1098
|
var func = null;
|
1076
1099
|
if (mode == 'into') { func = self.adaptor.description.insert_first_into }
|
1077
1100
|
else { func = self.adaptor.description.insert_after }
|
1078
|
-
|
1101
|
+
var childs = [
|
1079
1102
|
{'label': 'Service Call with Scripts',
|
1080
1103
|
'function_call': func,
|
1081
1104
|
'menu_icon': self.elements.callmanipulate.illustrator.svg.clone(),
|
@@ -1086,7 +1109,7 @@ function WFAdaptorManifestation(adaptor) {
|
|
1086
1109
|
'menu_icon': self.elements.call.illustrator.svg.clone(),
|
1087
1110
|
'type': 'call',
|
1088
1111
|
'params': [self.adaptor.description.elements.call, node]},
|
1089
|
-
{'label': 'Script
|
1112
|
+
{'label': 'Script',
|
1090
1113
|
'function_call': func,
|
1091
1114
|
'menu_icon': self.elements.manipulate.illustrator.svg.clone(),
|
1092
1115
|
'type': 'manipulate',
|
@@ -1115,13 +1138,18 @@ function WFAdaptorManifestation(adaptor) {
|
|
1115
1138
|
'function_call': func,
|
1116
1139
|
'menu_icon': self.elements.stop.illustrator.svg.clone(),
|
1117
1140
|
'type': 'stop',
|
1118
|
-
'params': [self.adaptor.description.elements.stop, node]}
|
1119
|
-
{'label': 'Critical',
|
1120
|
-
'function_call': func,
|
1121
|
-
'menu_icon': self.elements.critical.illustrator.svg.clone(),
|
1122
|
-
'type': 'critical',
|
1123
|
-
'params': [self.adaptor.description.elements.critical, node]}
|
1141
|
+
'params': [self.adaptor.description.elements.stop, node]}
|
1124
1142
|
];
|
1143
|
+
if(node.parent('parallel_branch').length > 0) {
|
1144
|
+
childs.push({
|
1145
|
+
'label': 'Critical',
|
1146
|
+
'function_call': func,
|
1147
|
+
'menu_icon': self.elements.critical.illustrator.svg.clone(),
|
1148
|
+
'type': 'critical',
|
1149
|
+
'params': [self.adaptor.description.elements.critical, node]
|
1150
|
+
});
|
1151
|
+
}
|
1152
|
+
return childs;
|
1125
1153
|
}, //}}}
|
1126
1154
|
'adaptor': {//{{{
|
1127
1155
|
'mousedown': function (node,e) {
|
data/cpee.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cpee"
|
3
|
-
s.version = "1.5.
|
3
|
+
s.version = "1.5.17"
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.license = "LGPL-3.0"
|
6
6
|
s.summary = "Preliminary release of cloud process execution engine (cpee). If you just need workflow execution, without a rest/xmpp service exposing it, then use WEEL"
|
data/lib/cpee/instantiation.rb
CHANGED
@@ -27,7 +27,7 @@ module CPEE
|
|
27
27
|
SERVER = File.expand_path(__dir__ + '/../instantiation.xml')
|
28
28
|
|
29
29
|
module Helpers #{{{
|
30
|
-
def load_testset(tdoc,cpee,name=nil) #{{{
|
30
|
+
def load_testset(tdoc,cpee,name=nil,stream=nil) #{{{
|
31
31
|
ins = -1
|
32
32
|
uuid = nil
|
33
33
|
XML::Smart.string(tdoc) do |doc|
|
@@ -41,6 +41,23 @@ module CPEE
|
|
41
41
|
e.text = name
|
42
42
|
end
|
43
43
|
end
|
44
|
+
if stream && !stream.empty?
|
45
|
+
JSON.parse(stream).each do |e|
|
46
|
+
begin
|
47
|
+
stream = Typhoeus.get e['url']
|
48
|
+
if stream.success?
|
49
|
+
XML::Smart::string(stream.response_body) do |str|
|
50
|
+
doc.find("//desc:call[@id=\"#{e['id']}\"]/desc:parameters/desc:stream").each do |ele|
|
51
|
+
ele.replace_by str.root
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
rescue => e
|
56
|
+
puts e.message
|
57
|
+
puts e.backtrace
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
44
61
|
|
45
62
|
status, response, headers = res.post Riddl::Parameter::Simple.new("info",doc.find("string(/testset/attributes/prop:info)"))
|
46
63
|
|
@@ -160,8 +177,8 @@ module CPEE
|
|
160
177
|
else
|
161
178
|
(@status = 500) && return
|
162
179
|
end
|
163
|
-
|
164
|
-
if (instance, uuid = load_testset(tdoc,cpee)).first == -1
|
180
|
+
stream = @p.find{ |e| e.name == 'stream' }&.value
|
181
|
+
if (instance, uuid = load_testset(tdoc,cpee,nil,stream)).first == -1
|
165
182
|
@status = 500
|
166
183
|
else
|
167
184
|
handle_data cpee, instance, @p[4]&.value if @p[4]&.name == 'init'
|
@@ -198,8 +215,8 @@ module CPEE
|
|
198
215
|
else
|
199
216
|
(@status = 500) && return
|
200
217
|
end
|
201
|
-
|
202
|
-
if (instance, uuid = load_testset(tdoc,cpee,name)).first == -1
|
218
|
+
stream = @p.find{ |e| e.name == 'stream' }&.value
|
219
|
+
if (instance, uuid = load_testset(tdoc,cpee,name,stream)).first == -1
|
203
220
|
@status = 500
|
204
221
|
else
|
205
222
|
handle_data cpee, instance, @p[2]&.value if @p[2]&.name == 'init'
|
data/lib/instantiation.xml
CHANGED
@@ -33,6 +33,9 @@
|
|
33
33
|
<optional>
|
34
34
|
<parameter name="endpoints" type="string"/>
|
35
35
|
</optional>
|
36
|
+
<optional>
|
37
|
+
<parameter name="stream" type="string"/>
|
38
|
+
</optional>
|
36
39
|
</message>
|
37
40
|
<message name="url">
|
38
41
|
<parameter name="behavior" type="string">
|
@@ -50,6 +53,9 @@
|
|
50
53
|
<optional>
|
51
54
|
<parameter name="endpoints" type="string"/>
|
52
55
|
</optional>
|
56
|
+
<optional>
|
57
|
+
<parameter name="stream" type="string"/>
|
58
|
+
</optional>
|
53
59
|
</message>
|
54
60
|
<message name="git">
|
55
61
|
<parameter name="behavior" type="string">
|
@@ -69,6 +75,9 @@
|
|
69
75
|
<optional>
|
70
76
|
<parameter name="endpoints" type="string"/>
|
71
77
|
</optional>
|
78
|
+
<optional>
|
79
|
+
<parameter name="stream" type="string"/>
|
80
|
+
</optional>
|
72
81
|
</message>
|
73
82
|
<message name="instance">
|
74
83
|
<parameter name="behavior" type="string">
|
data/log/azure.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require_relative 'azure_logger'
|
3
|
+
|
4
|
+
Riddl::Server.new(File.join(__dir__,'/log.xml'), :host => 'localhost', :port => 9313) do
|
5
|
+
accessible_description true
|
6
|
+
cross_site_xhr true
|
7
|
+
interface 'events' do
|
8
|
+
run Logging if post 'event'
|
9
|
+
end
|
10
|
+
end.loop!
|
data/log/azure_logger.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'time'
|
3
|
+
require 'digest'
|
4
|
+
|
5
|
+
require 'json'
|
6
|
+
require 'riddl/server'
|
7
|
+
require 'typhoeus'
|
8
|
+
|
9
|
+
EP_ARTEFACTS = "https://api.powerbi.com/beta/7ba47c6d-039d-44e5-8834-ee103ea08c19/datasets/2fb85c30-2e66-42d3-ac16-18c1fe76f501/rows?key=qpnTPKsn4ekXasNFs9he4afwAb%2Bj8DndJ6mGAomCGkkAdKsIDifRDK9hsQd0mk3X94KCzqGrNCYN%2Fs7T7STQjg%3D%3D"
|
10
|
+
EP_INSTANCES = "https://api.powerbi.com/beta/7ba47c6d-039d-44e5-8834-ee103ea08c19/datasets/25c94fa0-f6f3-4547-9815-f772e1abc92f/rows?key=vWSGqHeQp6BQ8IPt4RBMLAbDPhVsyTW2NVcXfqQBCMx17cAZXfVejyAW72MeMGSbEk3fguhhqLoR3nYmopLIow%3D%3D"
|
11
|
+
EP_SPAWNED = "https://api.powerbi.com/beta/7ba47c6d-039d-44e5-8834-ee103ea08c19/datasets/79620e3f-a65c-4e34-b859-5aa43074f086/rows?key=dFS4XmqxI8iauMKucZenHQOi6mNcPhBslYo%2B8NwlzMYgiDYN%2FGDv6hX%2BwHMRIJwvQDyCxgd614KDihPw1Q%2BGSA%3D%3D"
|
12
|
+
EP_SENSORS = "https://api.powerbi.com/beta/7ba47c6d-039d-44e5-8834-ee103ea08c19/datasets/b62aada9-fe26-43e6-9e18-4bd3978e651d/rows?key=QWKNhGe3glUuWMOkCmJPytVQjaCn1Wyf8NboH3RXJTdA2ryiY%2Fk5%2Fz2lXDpgfguAa1xq%2BO%2Fw3lDhuXLYx4CyFA%3D%3D"
|
13
|
+
EP_VALUES = "https://api.powerbi.com/beta/7ba47c6d-039d-44e5-8834-ee103ea08c19/datasets/fc53f106-0299-458d-aa33-a04a00d68571/rows?key=mp9Om5wrPLG5hDA4efGzpfEGG5uHRUTtnUGlzNrfHJ5qaub2fG2FpwS5gq3g4IYRKMWG7mlCK5pgwm48XxtItw%3D%3D"
|
14
|
+
|
15
|
+
class Logging < Riddl::Implementation
|
16
|
+
|
17
|
+
def doc(topic,event_name,instancenr,notification)
|
18
|
+
uuid = notification['instance_uuid']
|
19
|
+
return unless uuid
|
20
|
+
|
21
|
+
uuid = notification.dig('instance_uuid')
|
22
|
+
|
23
|
+
if notification.dig('attributes','artefacts') #{{{
|
24
|
+
artefacts = JSON.parse(notification.dig('attributes','artefacts'))
|
25
|
+
|
26
|
+
artefacts.each do |a|
|
27
|
+
aid = Digest::MD5.hexdigest(a['group'] + '_' + a['name'])
|
28
|
+
iid = Digest::MD5.hexdigest(a['group'] + '_' + a['name'] + '_' + uuid)
|
29
|
+
Typhoeus.post(EP_ARTEFACTS,
|
30
|
+
headers: {'Content-Type'=> "application/json"},
|
31
|
+
body: JSON.generate([a])
|
32
|
+
)
|
33
|
+
Typhoeus.post(EP_INSTANCES,
|
34
|
+
headers: {'Content-Type'=> "application/json"},
|
35
|
+
body: [
|
36
|
+
{
|
37
|
+
'uuid': uuid,
|
38
|
+
'group': a['group'],
|
39
|
+
'name': a['name'],
|
40
|
+
'date': Time.now.iso8601,
|
41
|
+
'info': notification.dig('attributes','info')
|
42
|
+
}
|
43
|
+
]
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end #}}}
|
47
|
+
|
48
|
+
case "#{topic}/#{event_name}"
|
49
|
+
when "dataelements/change", "endpoints/change"
|
50
|
+
sensors = JSON.parse(notification.dig('attributes','sensors') || '[]')
|
51
|
+
sensors.each do |s|
|
52
|
+
sid = Digest::MD5.hexdigest(uuid + '_' + s['name'])
|
53
|
+
Typhoeus.post(EP_SENSORS,
|
54
|
+
headers: {'Content-Type'=> "application/json"},
|
55
|
+
body: [
|
56
|
+
{
|
57
|
+
'uuid': uuid,
|
58
|
+
'sensor': s['name'],
|
59
|
+
'visualizer_url': s['visualizer_url'],
|
60
|
+
'visualizer_params': [s['visualizer_params']]
|
61
|
+
}
|
62
|
+
]
|
63
|
+
)
|
64
|
+
Typhoeus.post(EP_VALUES,
|
65
|
+
headers: {'Content-Type'=> "application/json"},
|
66
|
+
body: [
|
67
|
+
{
|
68
|
+
'uuid': uuid,
|
69
|
+
'sensor': s['name'],
|
70
|
+
'timestamp': notification.dig('timestamp'),
|
71
|
+
'value': s['value']
|
72
|
+
}
|
73
|
+
]
|
74
|
+
)
|
75
|
+
end
|
76
|
+
when "activity/receiving"
|
77
|
+
sensors = JSON.parse(notification.dig('sensors') || '[]')
|
78
|
+
tdoc = notification.dig('received')
|
79
|
+
sensors.each do |s|
|
80
|
+
sid = Digest::MD5.hexdigest(uuid + '_' + s['name'])
|
81
|
+
Typhoeus.post(EP_SENSORS,
|
82
|
+
headers: {'Content-Type'=> "application/json"},
|
83
|
+
body: [
|
84
|
+
{
|
85
|
+
'uuid': uuid,
|
86
|
+
'sensor': s['name'],
|
87
|
+
'task': notification.dig('activity'),
|
88
|
+
'visualizer_url': s['visualizer_url'],
|
89
|
+
'visualizer_params': (s['visualizer_params'].nil? || s['visualizer_params'].empty? ? [] : [s['visualizer_params']])
|
90
|
+
}
|
91
|
+
]
|
92
|
+
)
|
93
|
+
status, result = Riddl::Client.new(s['extractor_url']).post [
|
94
|
+
Riddl::Parameter::Simple.new('data',JSON.pretty_generate(tdoc)),
|
95
|
+
Riddl::Parameter::Simple.new('what',s['extractor_arg'])
|
96
|
+
]
|
97
|
+
if status >= 200 && status < 300
|
98
|
+
ret = JSON::parse(result[0]&.value.read) rescue []
|
99
|
+
ret.each do |v,t|
|
100
|
+
Typhoeus.post(EP_VALUES,
|
101
|
+
headers: {'Content-Type'=> "application/json"},
|
102
|
+
body: [
|
103
|
+
{
|
104
|
+
'uuid': uuid,
|
105
|
+
'sensor': s['name'],
|
106
|
+
'timestamp': t,
|
107
|
+
'value': v
|
108
|
+
}
|
109
|
+
]
|
110
|
+
)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
116
|
+
nil
|
117
|
+
end
|
118
|
+
|
119
|
+
def response #{{{
|
120
|
+
### save events for later replay
|
121
|
+
# a = {
|
122
|
+
# :topic => @p[1].value,
|
123
|
+
# :event_name => @p[2].value,
|
124
|
+
# :instancenr => @h['CPEE_INSTANCE'].split('/').last,
|
125
|
+
# :notification => JSON.parse(@p[3].value)
|
126
|
+
# }.to_yaml
|
127
|
+
# File.open('events.yaml','a') do |f|
|
128
|
+
# f << a
|
129
|
+
# end
|
130
|
+
topic = @p[1].value
|
131
|
+
event_name = @p[2].value
|
132
|
+
instancenr = @h['CPEE_INSTANCE'].split('/').last
|
133
|
+
notification = JSON.parse(@p[3].value)
|
134
|
+
doc topic, event_name, instancenr, notification
|
135
|
+
end #}}}
|
136
|
+
end
|