cpee-logging-xes-yaml 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 186da10687e64dcb1463bb2499bb2f7cacee45c687e2f086758ab847193e8fc4
4
- data.tar.gz: ff3062ea2289e0d47845c60666d7413ad7253b63d1115ff6a7f410dc3aea75f6
3
+ metadata.gz: 8c9febaecfc6e2f6f3adf2775e105c36b38c3683f7cd2c32fbf728f5e20a5469
4
+ data.tar.gz: 28e13027adfe3bb13d59e1bbe963024ee93053fdd12c62f4203f771d489c8d81
5
5
  SHA512:
6
- metadata.gz: 35c9e6a02d694d1909f0773321dfff7b61ed6324a8146712c35caa23fc79303ee6403dab6bb3e6182046efece09cffddec420b9acee75864ed606198ba3ba861
7
- data.tar.gz: 23c70dba7ff36da95cbb0532f8f9fca8c6f7334e8689665c0cc864a2b16f9a72f815708dd5427dc13c46fb2c2786c57876cbcf3cfbbdc4a441922896f7440597
6
+ metadata.gz: 0a9171b0b8129ffd5b3e84b6d9abce475b0a8df9eb72c0e0d4788b659a4a14be2487b57d5126592265bb8feeebf5aa29832eb4567ece5f30d2852c35a7d98123
7
+ data.tar.gz: cd6bf42243214309f338a993b74dd20065eeef9c982f266d7549303f624cc3de134812672406f736a1f19b2c11c6b941c6ab7b5d1bba7b319fb39370ca660fb3
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-logging-xes-yaml"
3
- s.version = "1.1.2"
3
+ s.version = "1.1.3"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
6
  s.summary = "Logging for the cloud process execution engine (cpee.org)"
@@ -24,6 +24,28 @@ end
24
24
  module CPEE
25
25
  module Logging
26
26
 
27
+ def self::val_merge(target,val,tid,tso)
28
+ if val.is_a? Array
29
+ val.each do |e|
30
+ if e.is_a? StreamPoint
31
+ e.source ||= tso
32
+ target << e.to_h(tid)
33
+ end
34
+ end
35
+ else
36
+ tp = nil
37
+ if val.is_a? StreamPoint
38
+ tp = val
39
+ tp.source = tso if tp.source.nil?
40
+ else
41
+ tp = StreamPoint.new
42
+ tp.source = tso
43
+ tp.value = val
44
+ end
45
+ target << tp.to_h(tid)
46
+ end
47
+ end
48
+
27
49
  def self::extract_probes(where,xml)
28
50
  XML::Smart::string(xml) do |doc|
29
51
  doc.register_namespace 'd', 'http://cpee.org/ns/description/1.0'
@@ -36,8 +58,9 @@ module CPEE
36
58
  end
37
59
  end
38
60
 
39
- def self::extract_sensor(rs,code,result)
40
- result.map! do |res|
61
+ def self::extract_result(result)
62
+ p result
63
+ ret = result.map do |res|
41
64
  if res['mimetype'].nil?
42
65
  res['value']
43
66
  elsif res['mimetype'] == 'application/json'
@@ -64,7 +87,10 @@ module CPEE
64
87
  res['data']
65
88
  end
66
89
  end
67
- result = result[0] if result.length == 1
90
+ ret.length == 1 ? ret[0] : ret
91
+ end
92
+
93
+ def self::extract_sensor(rs,code,result)
68
94
  rs.instance_eval(code)
69
95
  end
70
96
 
@@ -135,6 +161,21 @@ module CPEE
135
161
  event["data"] = content['values'].map do |k,v|
136
162
  { 'name' => k, 'value' => v }
137
163
  end
164
+
165
+ fname = File.join(log_dir,instance + '_' + event["id:id"] + '.probe')
166
+ dname = File.join(log_dir,instance + '.data.json')
167
+
168
+ if File.exists?(fname)
169
+ rs = WEEL::ReadStructure.new(File.exists?(dname) ? JSON::load(File::open(dname)) : {},{},{})
170
+ XML::Smart::open_unprotected(fname) do |doc|
171
+ doc.register_namespace 'd', 'http://cpee.org/ns/description/1.0'
172
+ doc.find('//d:probe[d:extractor_type="intrinsic"]').each do |p|
173
+ event['stream:sensorstream'] ||= []
174
+ val = CPEE::Logging::extract_sensor(rs,p.find('string(d:extractor_code)'),nil) rescue nil
175
+ CPEE::Logging::val_merge(event['stream:sensorstream'],val,p.find('string(d:id)'),p.find('string(d:source)'))
176
+ end
177
+ end
178
+ end
138
179
  end
139
180
  if receiving && !receiving.empty?
140
181
  fname = File.join(log_dir,instance + '_' + event["id:id"] + '.probe')
@@ -142,35 +183,24 @@ module CPEE
142
183
 
143
184
  if File.exists?(fname)
144
185
  te = event.dup
145
- te['stream:sensorstream'] = []
146
186
 
147
187
  rs = WEEL::ReadStructure.new(File.exists?(dname) ? JSON::load(File::open(dname)) : {},{},{})
148
188
  XML::Smart::open_unprotected(fname) do |doc|
149
189
  doc.register_namespace 'd', 'http://cpee.org/ns/description/1.0'
150
- doc.find('//d:probe').each do |p|
151
- tid = p.find('string(d:id)')
152
- tso = p.find('string(d:source)')
153
- if p.find('d:extractor_type[.="extrinsic"]')
154
- val = CPEE::Logging::extract_sensor(rs,p.find('string(d:extractor_code)'),receiving) rescue nil
155
- if val.is_a? Array
156
- val.each do |e|
157
- if e.is_a? StreamPoint
158
- e.source ||= tso
159
- te['stream:sensorstream'] << e.to_h(tid)
160
- end
161
- end
162
- else
163
- tp = StreamPoint.new
164
- tp.source = tso
165
- tp.value = val
166
- te['stream:sensorstream'] << tp.to_h(tid)
167
- end
190
+ if doc.find('//d:probe/d:extractor_type[.="extrinsic"]').any?
191
+ rc = CPEE::Logging::extract_result(receiving)
192
+ doc.find('//d:probe[d:extractor_type="extrinsic"]').each do |p|
193
+ te['stream:sensorstream'] ||= []
194
+ val = CPEE::Logging::extract_sensor(rs,p.find('string(d:extractor_code)'),rc) rescue nil
195
+ CPEE::Logging::val_merge(te['stream:sensorstream'],val,p.find('string(d:id)'),p.find('string(d:source)'))
168
196
  end
169
197
  end
170
198
  end
171
- te["cpee:lifecycle:transition"] = "sensor/stream"
172
- File.open(File.join(log_dir,instance+'.xes.yaml'),'a') do |f|
173
- f << {'event' => te}.to_yaml
199
+ if te['stream:sensorstream']
200
+ te["cpee:lifecycle:transition"] = "sensor/stream"
201
+ File.open(File.join(log_dir,instance+'.xes.yaml'),'a') do |f|
202
+ f << {'event' => te}.to_yaml
203
+ end
174
204
  end
175
205
  end
176
206
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpee-logging-xes-yaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler