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 +4 -4
- data/cpee-logging-xes-yaml.gemspec +1 -1
- data/lib/cpee-logging-xes-yaml/tools.rb +57 -26
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c9febaecfc6e2f6f3adf2775e105c36b38c3683f7cd2c32fbf728f5e20a5469
|
4
|
+
data.tar.gz: 28e13027adfe3bb13d59e1bbe963024ee93053fdd12c62f4203f771d489c8d81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a9171b0b8129ffd5b3e84b6d9abce475b0a8df9eb72c0e0d4788b659a4a14be2487b57d5126592265bb8feeebf5aa29832eb4567ece5f30d2852c35a7d98123
|
7
|
+
data.tar.gz: cd6bf42243214309f338a993b74dd20065eeef9c982f266d7549303f624cc3de134812672406f736a1f19b2c11c6b941c6ab7b5d1bba7b319fb39370ca660fb3
|
@@ -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
|
-
|
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::
|
39
|
-
result
|
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
|
-
|
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').
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
val = CPEE::Logging::extract_sensor(rs,p.find('string(d:extractor_code)'),
|
154
|
-
|
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[
|
171
|
-
|
172
|
-
|
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
|
|