cpee-logging-xes-yaml 1.1.1 → 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: d956eefad6c946b59eb9fabc244d9349844f4b502cea3c04f49b8deb0ec50751
4
- data.tar.gz: 393afba26427d6cf6ad65154c6d8fa485d4c09baef23d13d526fbfdc9b0ee968
3
+ metadata.gz: 8c9febaecfc6e2f6f3adf2775e105c36b38c3683f7cd2c32fbf728f5e20a5469
4
+ data.tar.gz: 28e13027adfe3bb13d59e1bbe963024ee93053fdd12c62f4203f771d489c8d81
5
5
  SHA512:
6
- metadata.gz: 95046ec653cbeffb1122109f9acec7e71387efd94c732235790bb28cc824f74ec0e4a6d6b03ad7a03d268b303b98c0dc71697a627ef250631a75b7d0a89bc7f9
7
- data.tar.gz: eefc314f27a41321e204d28c535ce27572ed58b4dc1b157bedda3c3169f133b45d5a1e3d0273c9db77130b20fb6babed433a9ad2e9647c64794245c5a4908bac
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.1"
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,19 +24,43 @@ 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'
30
52
  doc.find('//d:call').each do |c|
31
- c.find('d:annotations/d:_context_data_analysis/d:probes').each do |p|
53
+ File.unlink(where + '_' + c.attributes['id'] + '.probe') rescue nil
54
+ c.find('d:annotations/d:_context_data_analysis/d:probes[d:probe]').each do |p|
32
55
  File.write(where + '_' + c.attributes['id'] + '.probe', p.dump)
33
56
  end
34
57
  end
35
58
  end
36
59
  end
37
60
 
38
- def self::extract_sensor(rs,code,result)
39
- result.map! do |res|
61
+ def self::extract_result(result)
62
+ p result
63
+ ret = result.map do |res|
40
64
  if res['mimetype'].nil?
41
65
  res['value']
42
66
  elsif res['mimetype'] == 'application/json'
@@ -63,7 +87,10 @@ module CPEE
63
87
  res['data']
64
88
  end
65
89
  end
66
- 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)
67
94
  rs.instance_eval(code)
68
95
  end
69
96
 
@@ -134,6 +161,21 @@ module CPEE
134
161
  event["data"] = content['values'].map do |k,v|
135
162
  { 'name' => k, 'value' => v }
136
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
137
179
  end
138
180
  if receiving && !receiving.empty?
139
181
  fname = File.join(log_dir,instance + '_' + event["id:id"] + '.probe')
@@ -141,35 +183,24 @@ module CPEE
141
183
 
142
184
  if File.exists?(fname)
143
185
  te = event.dup
144
- te['stream:sensorstream'] = []
145
186
 
146
187
  rs = WEEL::ReadStructure.new(File.exists?(dname) ? JSON::load(File::open(dname)) : {},{},{})
147
188
  XML::Smart::open_unprotected(fname) do |doc|
148
189
  doc.register_namespace 'd', 'http://cpee.org/ns/description/1.0'
149
- doc.find('//d:probe').each do |p|
150
- tid = p.find('string(d:id)')
151
- tso = p.find('string(d:source)')
152
- if p.find('d:extractor_type[.="extrinsic"]')
153
- val = CPEE::Logging::extract_sensor(rs,p.find('string(d:extractor_code)'),receiving) rescue nil
154
- if val.is_a? Array
155
- val.each do |e|
156
- if e.is_a? StreamPoint
157
- e.source ||= tso
158
- te['stream:sensorstream'] << e.to_h(tid)
159
- end
160
- end
161
- else
162
- tp = StreamPoint.new
163
- tp.source = tso
164
- tp.value = val
165
- te['stream:sensorstream'] << tp.to_h(tid)
166
- 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)'))
167
196
  end
168
197
  end
169
198
  end
170
- te["cpee:lifecycle:transition"] = "sensor/stream"
171
- File.open(File.join(log_dir,instance+'.xes.yaml'),'a') do |f|
172
- 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
173
204
  end
174
205
  end
175
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.1
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler