cpee-logging-xes-yaml 1.5.1 → 1.5.3
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 +4 -4
- data/README.md +1 -1
- data/cpee-logging-xes-yaml.gemspec +1 -1
- data/lib/cpee-logging-xes-yaml/implementation.rb +25 -13
- data/lib/cpee-logging-xes-yaml/tools.rb +12 -14
- 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: c843ee81786240dd8ba23829343e8509e81221311583f57ecf3fa651d0f0b7f5
|
|
4
|
+
data.tar.gz: fc6fa531c34788c79db9b1e7bbf834ca76e8ca6d74297a49550424223cf3dd38
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 80750e8f5fb3b423bf9122ae8bd616d491888905cbb8bd6402473bdd52182d8960280585e780f7687d502213490824d9c9b46a223ebc9ed075a4d1d02a7f6a3b
|
|
7
|
+
data.tar.gz: 2f4f600233e40c07e2caa8aca3c1355ce015642c0ef6c5417b88d0706e103bc315cc23aa48e005a19cc216c7fbc2a9ce9a7291479298432db8e25340f075ee45
|
data/README.md
CHANGED
|
@@ -27,6 +27,7 @@ module CPEE
|
|
|
27
27
|
|
|
28
28
|
SERVER = File.expand_path(File.join(__dir__,'implementation.xml'))
|
|
29
29
|
|
|
30
|
+
### Pieces for writing XML{{{
|
|
30
31
|
TEMPLATE_XES_XML_START = <<-END
|
|
31
32
|
<log xmlns="http://www.xes-standard.org/" xes.version="2.0" xes.features="nested-attributes">
|
|
32
33
|
<string key="creator" value="cpee.org"/>
|
|
@@ -59,10 +60,13 @@ module CPEE
|
|
|
59
60
|
TEMPLATE_XES_XML_MID = <<-END
|
|
60
61
|
<trace>
|
|
61
62
|
END
|
|
62
|
-
|
|
63
|
+
TEMPLATE_XES_XML_MID_END = <<-END
|
|
63
64
|
</trace>
|
|
65
|
+
END
|
|
66
|
+
TEMPLATE_XES_XML_END = <<-END
|
|
64
67
|
</log>
|
|
65
68
|
END
|
|
69
|
+
#}}}
|
|
66
70
|
|
|
67
71
|
class HeaderAndFile #{{{
|
|
68
72
|
def initialize(header, io)
|
|
@@ -114,7 +118,7 @@ module CPEE
|
|
|
114
118
|
private :append_to_outbuf
|
|
115
119
|
end #}}}
|
|
116
120
|
|
|
117
|
-
class DownloadYAML < Riddl::Implementation
|
|
121
|
+
class DownloadYAML < Riddl::Implementation #{{{
|
|
118
122
|
def response
|
|
119
123
|
opts = @a[0]
|
|
120
124
|
fname = File.join(opts[:log_dir],@r[-1])
|
|
@@ -126,7 +130,7 @@ module CPEE
|
|
|
126
130
|
@status = 404
|
|
127
131
|
end
|
|
128
132
|
end
|
|
129
|
-
end
|
|
133
|
+
end #}}}
|
|
130
134
|
|
|
131
135
|
class DownloadXML < Riddl::Implementation
|
|
132
136
|
def self::rec_type(it) #{{{
|
|
@@ -188,24 +192,31 @@ module CPEE
|
|
|
188
192
|
def response
|
|
189
193
|
opts = @a[0]
|
|
190
194
|
fname = File.join(opts[:log_dir],@r[-1]).sub(/xml$/,'yaml')
|
|
195
|
+
hname = File.join(opts[:log_dir],@r[-1]).sub(/xml$/,'header')
|
|
191
196
|
if File.exist?(fname)
|
|
192
197
|
body = StringIO.new
|
|
193
198
|
|
|
194
199
|
body.write(TEMPLATE_XES_XML_START)
|
|
195
200
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
if File.exist?(hname)
|
|
202
|
+
hio = File.open(hname)
|
|
203
|
+
YAML.load_stream(hio) do |e|
|
|
204
|
+
if trace = e.dig('log','trace')
|
|
205
|
+
xml = XML::Smart.string(TEMPLATE_XES_XML_TRC)
|
|
206
|
+
xml.register_namespace 'x', 'http://www.xes-standard.org/'
|
|
207
|
+
trace.each do |t,tv|
|
|
208
|
+
xml.find('//x:trace').each do |ele|
|
|
209
|
+
ele.add('x:string', 'key' => t, 'value' => tv)
|
|
210
|
+
end
|
|
204
211
|
end
|
|
212
|
+
body.write(' ' + xml.root.dump.gsub(/\n/,"\n ") + "\n")
|
|
205
213
|
end
|
|
206
|
-
body.write(' ' + xml.root.dump.gsub(/\n/,"\n ") + "\n")
|
|
207
|
-
body.write(TEMPLATE_XES_XML_MID)
|
|
208
214
|
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
io = File.open(fname)
|
|
218
|
+
body.write(TEMPLATE_XES_XML_MID)
|
|
219
|
+
YAML.load_stream(io) do |e|
|
|
209
220
|
if e.dig('event')
|
|
210
221
|
xml = XML::Smart.string(TEMPLATE_XES_XML_EVT)
|
|
211
222
|
xml.register_namespace 'x', 'http://www.xes-standard.org/'
|
|
@@ -213,6 +224,7 @@ module CPEE
|
|
|
213
224
|
body.write(' ' + xml.root.dump.gsub(/\n/,"\n ") + "\n")
|
|
214
225
|
end
|
|
215
226
|
end
|
|
227
|
+
body.write(TEMPLATE_XES_XML_MID_END)
|
|
216
228
|
body.write(TEMPLATE_XES_XML_END)
|
|
217
229
|
body.rewind
|
|
218
230
|
|
|
@@ -210,10 +210,12 @@ module CPEE
|
|
|
210
210
|
end
|
|
211
211
|
end
|
|
212
212
|
|
|
213
|
+
event['time:timestamp'] = notification['timestamp'] || Time.now.xmlschema(4)
|
|
214
|
+
|
|
213
215
|
if topic == 'task' && event_name == 'probe'
|
|
214
216
|
rs = WEEL::ReadStructure.new(content['data'],{},{},{})
|
|
215
217
|
rc = CPEE::Logging::extract_result(receiving) if receiving && !receiving.empty?
|
|
216
|
-
te = event
|
|
218
|
+
te = event
|
|
217
219
|
|
|
218
220
|
content['probes'].each do |p|
|
|
219
221
|
|
|
@@ -254,9 +256,6 @@ module CPEE
|
|
|
254
256
|
end
|
|
255
257
|
if te['stream:datastream'] && te['stream:datastream'].any?
|
|
256
258
|
te['cpee:lifecycle:transition'] = 'stream/data'
|
|
257
|
-
File.open(File.join(log_dir,instance+'.xes.yaml'),'a') do |f|
|
|
258
|
-
f << {'event' => te}.to_yaml
|
|
259
|
-
end
|
|
260
259
|
EM.defer do
|
|
261
260
|
self::notify(
|
|
262
261
|
opts,
|
|
@@ -274,19 +273,18 @@ module CPEE
|
|
|
274
273
|
end
|
|
275
274
|
|
|
276
275
|
end
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
276
|
+
event = nil if !event['stream:datastream']
|
|
277
|
+
else
|
|
278
|
+
if receiving && !receiving.empty?
|
|
279
|
+
event['data'] = receiving
|
|
280
|
+
end
|
|
281
|
+
if content['data'] && !content['data'].empty?
|
|
282
|
+
event['data'] = content['data']
|
|
283
|
+
end
|
|
285
284
|
end
|
|
286
|
-
event['time:timestamp']= notification['timestamp'] || Time.now.xmlschema(4)
|
|
287
285
|
File.open(File.join(log_dir,instance+'.xes.yaml'),'a') do |f|
|
|
288
286
|
f << {'event' => event}.to_yaml
|
|
289
|
-
end
|
|
287
|
+
end unless event.nil? # :-) for task/probes
|
|
290
288
|
end
|
|
291
289
|
|
|
292
290
|
end
|