cpee-logging-xes-yaml 1.3.21 → 1.3.23

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: 781e1920d2f1c740b9266c8b6c16e8f6deb515abd8496bc2e235b3f0016790b6
4
- data.tar.gz: e17203546cdc764602584353ae8bffdf66b85040e0928a18b8467571b0c10475
3
+ metadata.gz: '0826aa750d298fd8ec36f2e650295d8584d5861b9db5f9043ce7aa4bdd211f95'
4
+ data.tar.gz: 949622e3a7b0c311d6f3c959c7cf3e702c010d09730801b60436cbd9f3840e60
5
5
  SHA512:
6
- metadata.gz: e94e0a10e89ea868f533fa5186596bab4ba448bea86e6efeb5fa33f08df4fcff5f94aafbb5d95eb850c803b696f4c21222e1a1fefd69151d2488bfd1573faa68
7
- data.tar.gz: 3578abef72c8f7eef3b3874a31bf1f70b89429beeab58509b10f8a8b66bc35bf954d086b2fbe89d09fbeb67ad0efb8ce134e01394f07baea428ee603f0c1dbe0
6
+ metadata.gz: e193a45610da57a8384a4e7efc9611b68e6f5280f7ffdbf03f2a0e4ea726f261c7ba5cc8d291b49a4e80e783e1f3e9a8805b9288e368fcd6d47861de1ec4fc0f
7
+ data.tar.gz: e9e0a9b52b398c87872f4a692ae42440e6eea1c265603c5d48f5776288a13a0af4148fa5dbf01d8cc7be6a557846045c0333e00fa163ce83d6a27b9ed741487a
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-logging-xes-yaml"
3
- s.version = "1.3.21"
3
+ s.version = "1.3.23"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0-or-later"
6
6
  s.summary = "Logging for the cloud process execution engine (cpee.org)"
@@ -76,6 +76,7 @@ end
76
76
  module CPEE
77
77
  module Logging
78
78
 
79
+ # Forward event to subscriptions
79
80
  def self::notify(opts,topic,event_name,payload)
80
81
  opts[:subscriptions].each do |e,urls|
81
82
  if e == topic + '/' + event_name
@@ -92,7 +93,7 @@ module CPEE
92
93
  end
93
94
  end
94
95
 
95
- def self::val_merge(target,val,tid,tso)
96
+ def self::merge_val(target,val,tid,tso)
96
97
  if val.is_a? Stream
97
98
  val.source = tso if val.source.nil?
98
99
  target.push *val.to_list
@@ -114,7 +115,7 @@ module CPEE
114
115
  def self::extract_probes(where,xml)
115
116
  XML::Smart::string(xml) do |doc|
116
117
  doc.register_namespace 'd', 'http://cpee.org/ns/description/1.0'
117
- doc.find('//d:call').each do |c|
118
+ doc.find('//d:call | //d:manipulate').each do |c|
118
119
  File.unlink(where + '_' + c.attributes['id'] + '.probe') rescue nil
119
120
  c.find('d:annotations/d:_context_data_analysis/d:probes[d:probe]').each do |p|
120
121
  File.write(where + '_' + c.attributes['id'] + '.probe', p.dump)
@@ -122,14 +123,15 @@ module CPEE
122
123
  end
123
124
  end
124
125
  end
126
+
125
127
  def self::extract_annotations(where,xml)
126
128
  ret = {}
127
129
  XML::Smart::string(xml) do |doc|
128
130
  doc.register_namespace 'd', 'http://cpee.org/ns/description/1.0'
129
- doc.find('/d:description | //d:call').each do |c|
130
- tid = c.attributes['id'] || 'start'
131
+ doc.find('/d:description | //d:call | //d:manipulate').each do |c|
132
+ tid = c.attributes['id'] || 'complex'
131
133
  fname = where + '_' + tid + '.anno'
132
- nset = if tid == 'start'
134
+ nset = if tid == 'complex'
133
135
  c.find('d:*[starts-with(name(),"_")]')
134
136
  else
135
137
  c.find('d:annotations')
@@ -143,7 +145,7 @@ module CPEE
143
145
  if ret[tid].length > 1
144
146
  ret[tid] = "<annotations xmlns=\"http://cpee.org/ns/description/1.0\">\n" +
145
147
  ret[tid].join("\n") + "\n" +
146
- "</annotations>"
148
+ '</annotations>'
147
149
  else
148
150
  ret[tid] = ret[tid][0]
149
151
  end
@@ -169,7 +171,7 @@ module CPEE
169
171
  YAML::load(res['data']) rescue nil
170
172
  elsif res['mimetype'] == 'text/plain'
171
173
  t = res['data']
172
- if t.start_with?("<?xml version=")
174
+ if t.start_with?('<?xml version=')
173
175
  t = XML::Smart::string(t)
174
176
  else
175
177
  t = t.to_f if t == t.to_f.to_s
@@ -188,7 +190,7 @@ module CPEE
188
190
  ret.length == 1 ? ret[0] : ret
189
191
  end
190
192
 
191
- def self::extract_sensor(rs,code,pid,result)
193
+ def self::extract_val(rs,code,pid,result)
192
194
  rs.instance_eval(code,'probe',1)
193
195
  rescue => e
194
196
  e.backtrace[0].gsub(/(\w+):(\d+):in.*/,'Probe ' + pid + ' Line \2: ') + e.message
@@ -257,60 +259,68 @@ module CPEE
257
259
  end
258
260
 
259
261
  event = {}
260
- event["concept:instance"] = instancenr
261
- event["concept:name"] = content["label"] if content["label"]
262
- if content["endpoint"]
263
- event["concept:endpoint"] = content["endpoint"]
262
+ event['concept:instance'] = instancenr
263
+ event['concept:name'] = content['label'] if content['label']
264
+ if content['endpoint']
265
+ event['concept:endpoint'] = content['endpoint']
264
266
  end
265
- event["id:id"] = (activity.nil? || activity == "") ? 'external' : activity
266
- event["cpee:activity"] = event["id:id"]
267
- event["cpee:activity_uuid"] = content['activity-uuid'] if content['activity-uuid']
268
- event["cpee:instance"] = instance
267
+ event['id:id'] = (activity.nil? || activity == '') ? 'external' : activity
268
+ event['cpee:activity'] = event['id:id']
269
+ event['cpee:activity_uuid'] = content['activity-uuid'] if content['activity-uuid']
270
+ event['cpee:instance'] = instance
269
271
  case event_name
270
272
  when 'calling'
271
- event["lifecycle:transition"] = "start"
273
+ event['lifecycle:transition'] = 'start'
272
274
  when 'done'
273
- event["lifecycle:transition"] = "complete"
275
+ event['lifecycle:transition'] = 'complete'
274
276
  else
275
- event["lifecycle:transition"] = "unknown"
277
+ event['lifecycle:transition'] = 'unknown'
276
278
  end
277
- event["cpee:lifecycle:transition"] = "#{topic}/#{event_name}"
278
- event["cpee:state"] = content['state'] if content['state']
279
- event["cpee:description"] = content['dslx'] if content['dslx']
280
- event["cpee:change_uuid"] = content['change_uuid'] if content['change_uuid']
281
- event["cpee:exposition"] = content['exposition'] if content['exposition']
282
- unless parameters["arguments"]&.nil?
283
- event["data"] = parameters["arguments"]
279
+ event['cpee:lifecycle:transition'] = "#{topic}/#{event_name}"
280
+ event['cpee:state'] = content['state'] if content['state']
281
+ event['cpee:description'] = content['dslx'] if content['dslx']
282
+ event['cpee:change_uuid'] = content['change_uuid'] if content['change_uuid']
283
+ event['cpee:exposition'] = content['exposition'] if content['exposition']
284
+ unless parameters['arguments']&.nil?
285
+ event['data'] = parameters['arguments']
284
286
  end if parameters
285
287
  if content['changed']&.any?
286
- event["data"] = content['values'].map do |k,v|
288
+ event['data'] = content['values'].map do |k,v|
287
289
  { 'name' => k, 'value' => v }
288
290
  end
289
291
 
290
- fname = File.join(log_dir,instance + '_' + event["id:id"] + '.probe')
292
+ fname = File.join(log_dir,instance + '_' + event['id:id'] + '.probe')
291
293
  dname = File.join(log_dir,instance + '.data.json')
292
294
 
295
+ # Handle intrinsic data probes
293
296
  if File.exist?(fname)
294
297
  rs = WEEL::ReadStructure.new(File.exist?(dname) ? JSON::load(File::open(dname)) : {},{},{},{})
295
298
  XML::Smart::open_unprotected(fname) do |doc|
296
299
  doc.register_namespace 'd', 'http://cpee.org/ns/description/1.0'
297
300
  doc.find('//d:probe[d:extractor_type="intrinsic"]').each do |p|
298
- pid = p.find('string(d:id)')
301
+ pid = p.find('string(d:id)')
302
+ source = p.find('string(d:source)')
303
+ val = CPEE::Logging::extract_val(rs,p.find('string(d:extractor_code)'),pid,nil) rescue nil
299
304
  event['stream:datastream'] ||= []
300
- val = CPEE::Logging::extract_sensor(rs,p.find('string(d:extractor_code)'),pid,nil) rescue nil
301
- CPEE::Logging::val_merge(event['stream:datastream'],val,pid,p.find('string(d:source)'))
305
+ # Do not add datastream entries if the dataprobes return nil
306
+ if val != nil
307
+ CPEE::Logging::merge_val(event['stream:datastream'],val,pid,source)
308
+ end
302
309
  end
303
310
  end
304
- notification['datastream'] = event['stream:datastream']
305
- EM.defer do
306
- notification['topic'] = 'stream'
307
- notification['name'] = 'extraction'
308
- self::notify(opts,'stream','extraction',notification.to_json)
311
+ if event['stream:datastream'] && event['stream:datastream'].any?
312
+ notification['datastream'] = event['stream:datastream']
313
+ EM.defer do
314
+ notification['topic'] = 'stream'
315
+ notification['name'] = 'extraction'
316
+ self::notify(opts,'stream','extraction',notification.to_json)
317
+ end
309
318
  end
310
319
  end
311
320
  end
321
+ # Handle extrinsic data probes
312
322
  if topic == 'activity' && event_name == 'receiving' && receiving && !receiving.empty?
313
- fname = File.join(log_dir,instance + '_' + event["id:id"] + '.probe')
323
+ fname = File.join(log_dir,instance + '_' + event['id:id'] + '.probe')
314
324
  dname = File.join(log_dir,instance + '.data.json')
315
325
 
316
326
  if File.exist?(fname)
@@ -324,13 +334,16 @@ module CPEE
324
334
  doc.find('//d:probe[d:extractor_type="extrinsic"]').each do |p|
325
335
  pid = p.find('string(d:id)')
326
336
  te['stream:datastream'] ||= []
327
- val = CPEE::Logging::extract_sensor(rs,p.find('string(d:extractor_code)'),pid,rc) rescue nil
328
- CPEE::Logging::val_merge(te['stream:datastream'],val,pid,p.find('string(d:source)'))
337
+ val = CPEE::Logging::extract_val(rs,p.find('string(d:extractor_code)'),pid,rc) rescue nil
338
+ if not val.nil?
339
+ # Do not add datastream entries if the dataprobes return nil
340
+ CPEE::Logging::merge_val(te['stream:datastream'],val,pid,p.find('string(d:source)'))
341
+ end
329
342
  end
330
343
  end
331
344
  end
332
- if te['stream:datastream']
333
- te["cpee:lifecycle:transition"] = "stream/data"
345
+ if te['stream:datastream'] && te['stream:datastream'].any?
346
+ te['cpee:lifecycle:transition'] = 'stream/data'
334
347
  File.open(File.join(log_dir,instance+'.xes.yaml'),'a') do |f|
335
348
  f << {'event' => te}.to_yaml
336
349
  end
@@ -344,9 +357,12 @@ module CPEE
344
357
  end
345
358
  end
346
359
  if receiving && !receiving.empty?
347
- event["data"] = receiving
360
+ event['data'] = receiving
361
+ end
362
+ if content['data'] && !content['data'].empty?
363
+ event['data'] = content['data']
348
364
  end
349
- event["time:timestamp"]= notification['timestamp'] || Time.now.xmlschema(4)
365
+ event['time:timestamp']= notification['timestamp'] || Time.now.xmlschema(4)
350
366
  File.open(File.join(log_dir,instance+'.xes.yaml'),'a') do |f|
351
367
  f << {'event' => event}.to_yaml
352
368
  end
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.3.21
4
+ version: 1.3.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler