cpee-logging-xes-yaml 1.1.2 → 1.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 186da10687e64dcb1463bb2499bb2f7cacee45c687e2f086758ab847193e8fc4
4
- data.tar.gz: ff3062ea2289e0d47845c60666d7413ad7253b63d1115ff6a7f410dc3aea75f6
3
+ metadata.gz: 8a28cb07da1a9501ae42be2daed564edbe2e9c8f19d9b935beae41eb92d9e858
4
+ data.tar.gz: c0608403c7d0ed382f31bc268c5d6091ab3de1ac27b3be45dab7b7b3474cfbf1
5
5
  SHA512:
6
- metadata.gz: 35c9e6a02d694d1909f0773321dfff7b61ed6324a8146712c35caa23fc79303ee6403dab6bb3e6182046efece09cffddec420b9acee75864ed606198ba3ba861
7
- data.tar.gz: 23c70dba7ff36da95cbb0532f8f9fca8c6f7334e8689665c0cc864a2b16f9a72f815708dd5427dc13c46fb2c2786c57876cbcf3cfbbdc4a441922896f7440597
6
+ metadata.gz: d8c0ec086213534780c96fd7ca2da9cc9f4621985876db32c47e061566ded16e3c530e6c28156f1ff49f0955136816ca09b24c0c125218c256c1179db42a8a9b
7
+ data.tar.gz: a14a71277ee317c3214bda9310cded04c9367d5363a75b8669a1ee67417ec539846e5908e570637c493a01e78b5a53c503c83b20a231e111b23cab665c5e5898
@@ -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.4"
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,8 @@ 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
+ ret = result.map do |res|
41
63
  if res['mimetype'].nil?
42
64
  res['value']
43
65
  elsif res['mimetype'] == 'application/json'
@@ -64,7 +86,10 @@ module CPEE
64
86
  res['data']
65
87
  end
66
88
  end
67
- result = result[0] if result.length == 1
89
+ ret.length == 1 ? ret[0] : ret
90
+ end
91
+
92
+ def self::extract_sensor(rs,code,result)
68
93
  rs.instance_eval(code)
69
94
  end
70
95
 
@@ -135,6 +160,21 @@ module CPEE
135
160
  event["data"] = content['values'].map do |k,v|
136
161
  { 'name' => k, 'value' => v }
137
162
  end
163
+
164
+ fname = File.join(log_dir,instance + '_' + event["id:id"] + '.probe')
165
+ dname = File.join(log_dir,instance + '.data.json')
166
+
167
+ if File.exists?(fname)
168
+ rs = WEEL::ReadStructure.new(File.exists?(dname) ? JSON::load(File::open(dname)) : {},{},{})
169
+ XML::Smart::open_unprotected(fname) do |doc|
170
+ doc.register_namespace 'd', 'http://cpee.org/ns/description/1.0'
171
+ doc.find('//d:probe[d:extractor_type="intrinsic"]').each do |p|
172
+ event['stream:sensorstream'] ||= []
173
+ val = CPEE::Logging::extract_sensor(rs,p.find('string(d:extractor_code)'),nil) rescue nil
174
+ CPEE::Logging::val_merge(event['stream:sensorstream'],val,p.find('string(d:id)'),p.find('string(d:source)'))
175
+ end
176
+ end
177
+ end
138
178
  end
139
179
  if receiving && !receiving.empty?
140
180
  fname = File.join(log_dir,instance + '_' + event["id:id"] + '.probe')
@@ -142,35 +182,24 @@ module CPEE
142
182
 
143
183
  if File.exists?(fname)
144
184
  te = event.dup
145
- te['stream:sensorstream'] = []
146
185
 
147
186
  rs = WEEL::ReadStructure.new(File.exists?(dname) ? JSON::load(File::open(dname)) : {},{},{})
148
187
  XML::Smart::open_unprotected(fname) do |doc|
149
188
  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
189
+ if doc.find('//d:probe/d:extractor_type[.="extrinsic"]').any?
190
+ rc = CPEE::Logging::extract_result(receiving)
191
+ doc.find('//d:probe[d:extractor_type="extrinsic"]').each do |p|
192
+ te['stream:sensorstream'] ||= []
193
+ val = CPEE::Logging::extract_sensor(rs,p.find('string(d:extractor_code)'),rc) rescue nil
194
+ CPEE::Logging::val_merge(te['stream:sensorstream'],val,p.find('string(d:id)'),p.find('string(d:source)'))
168
195
  end
169
196
  end
170
197
  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
198
+ if te['stream:sensorstream']
199
+ te["cpee:lifecycle:transition"] = "sensor/stream"
200
+ File.open(File.join(log_dir,instance+'.xes.yaml'),'a') do |f|
201
+ f << {'event' => te}.to_yaml
202
+ end
174
203
  end
175
204
  end
176
205
 
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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler