cpee-logging-xes-yaml 1.3.5 → 1.3.6

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: ddf89052e93d9c38c178377595703e815e14bc16a05b2c57cbf9ff73f65f12ad
4
- data.tar.gz: c1fc949892594dd764c55338ddbe9d0eb74aa84a49799503c4a2cc5764f0f2c5
3
+ metadata.gz: 899e0d2f04869dfa68eb7c7922222c825f87a1bd90d3b73f0cbb528bd95779d3
4
+ data.tar.gz: 64ef69bebaad740bb8ef4944fb2a5fa3a37d26ab1e0156bf58b75392c9fe8d39
5
5
  SHA512:
6
- metadata.gz: afa34dc21a86f7112a81958620b49d9dfb0457dbaba778d876b4cb24a9e8f31685168111e610848a73c5d26ca4efe38b1c509d2fd4065acec49ea8c6daec64e3
7
- data.tar.gz: 1da376713380410325754f2dd18e8d70653ce0f0026b56c347ae1062ca8aeba7e7660568031df9fe0efa150a51239e98ce739329adafcf52fd7fd27fbff7fcfa
6
+ metadata.gz: 0b0f53c72122468d2f3c4e6a17cd69a7bb7ca0c9088bb843e82ebe3700cb0e6b78a20b453d761648acba181afcb3f9122eb4e4a65c0da166f07249c7b3b48341
7
+ data.tar.gz: 0557b1e7f8cb2e1538b4984238530d713db7b7927b6ccba5abc949c1b2f180d307370c9d2d6781f689cfce156f1b19339e624dab2eae1a8dfc0478706329ed61
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-logging-xes-yaml"
3
- s.version = "1.3.5"
3
+ s.version = "1.3.6"
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)"
@@ -48,6 +48,74 @@ def wrap(s, width=78, indent=19, extra_indent=2)
48
48
  return lines.join "\n"
49
49
  end
50
50
 
51
+ TEMPLATE_XES_XML = <<-END
52
+ <log xmlns="http://www.xes-standard.org/" xes.version="2.0" xes.features="nested-attributes">
53
+ <string key="creator" value="cpee.org"/>
54
+ <extension name="Time" prefix="time" uri="http://www.xes-standard.org/time.xesext"/>
55
+ <extension name="Concept" prefix="concept" uri="http://www.xes-standard.org/concept.xesext"/>
56
+ <extension name="ID" prefix="id" uri="http://www.xes-standard.org/identity.xesext"/>
57
+ <extension name="Lifecycle" prefix="lifecycle" uri="http://www.xes-standard.org/lifecycle.xesext"/>
58
+ <extension name="CPEE" prefix="cpee" uri="http://cpee.org/cpee.xesext"/>
59
+ <extension name="stream" prefix="stream" uri="https://cpee.org/datastream/datastream.xesext"/>
60
+ <global scope="trace">
61
+ <string key="concept:name" value="__INVALID__"/>
62
+ <string key="cpee:name" value="__INVALID__"/>
63
+ </global>
64
+ <global scope="event">
65
+ <string key="concept:name" value="__INVALID__"/>
66
+ <string key="concept:instance" value="-1"/>
67
+ <string key="concept:endpoint" value=""/>
68
+ <string key="id:id" value=""/>
69
+ <string key="lifecycle:transition" value="complete" />
70
+ <string key="cpee:lifecycle:transition" value="activity/calling"/>
71
+ <date key="time:timestamp" value=""/>
72
+ </global>
73
+ <trace/>
74
+ </log>
75
+ END
76
+
77
+ def rec_type(it)
78
+ if (Time.parse(it) rescue nil)
79
+ 'x:date'
80
+ elsif it.is_a? Float
81
+ 'x:float'
82
+ elsif it.is_a? Integer
83
+ 'x:int'
84
+ elsif it.is_a? String
85
+ 'x:string'
86
+ end
87
+ end
88
+
89
+ def rec_a_insert(event,node,level=0)
90
+ event.each do |i|
91
+ tnode = node
92
+ # tnode = node.add('x:string', 'key' => 'item')
93
+ case i
94
+ when Hash
95
+ rec_insert(i,tnode,level+1)
96
+ when Array
97
+ rec_a_insert(i,tnode,level+1)
98
+ when String
99
+ node.add(rec_type(i), 'key' => i, 'value' => i)
100
+ end
101
+ end
102
+ end
103
+
104
+ def rec_insert(event,node,level=0)
105
+ event.each do |k,v|
106
+ case v
107
+ when String
108
+ node.add(rec_type(v), 'key' => k, 'value' => v)
109
+ when Array
110
+ tnode = node.add('x:list', 'key' => k)
111
+ rec_a_insert(v,tnode,level+1)
112
+ when Hash
113
+ tnode = node.add('x:string', 'key' => k)
114
+ rec_insert(v,tnode)
115
+ end
116
+ end
117
+ end
118
+
51
119
  def follow(fname,io,copy,deep=0,index=nil)
52
120
  tname = if fname =~ /\.xes\.shift\.yaml/
53
121
  File.basename(fname,'.xes.shift.yaml')
@@ -175,9 +243,11 @@ ARGV.options { |opt|
175
243
  opt.on("")
176
244
  opt.on(wrap("extract-all [LOG] extract cpee testset from cpee xes-yaml log. Works for local and remote logs. Write logs to files in folder named like the instance uuid contained in the log. Examples: \n#{exname} extract https://cpee.org/log/123.xes.yaml\n#{exname} extract ~/log/logs/456.xes.yaml"))
177
245
  opt.on("")
178
- opt.on(wrap("extract-last [LOG] extract cpee testset from cpee xes-yaml log. Works for local and remote logs. Write last revision of the model to stdout. When called with out [LOG], models for all log files in the current directory are extracted. Examples:\n#{exname} extract https://cpee.org/log/123.xes.yaml\n#{exname} extract ~/log/logs/456.xes.yaml"))
246
+ opt.on(wrap("extract-last [LOG] extract cpee testset from cpee xes-yaml log. Works for local and remote logs. When called with out [LOG], models for all log files in the current directory are extracted. Examples:\n#{exname} extract https://cpee.org/log/123.xes.yaml\n#{exname} extract ~/log/logs/456.xes.yaml"))
179
247
  opt.on("")
180
248
  opt.on(wrap("index [LOG] creates an index for a log file, for more efficient parsing. When called without [LOG], indexes all log files in the current directory. Examples:\n#{exname} index https://cpee.org/log/123.xes.yaml\n#{exname} index ~/log/logs/456.xes.yaml"))
249
+ opt.on("")
250
+ opt.on(wrap("to-xes-xml [LOG] convert cpee xes-yaml to xes-xml. Works for local and remote logs. When called with out [LOG], all log files in the current directory are converted. Examples:\n#{exname} to-xes-xml https://cpee.org/log/123.xes.yaml\n#{exname} to-xes-xml ~/log/logs/456.xes.yaml"))
181
251
  opt.parse!
182
252
  }
183
253
 
@@ -187,7 +257,7 @@ if (ARGV.length < 1 || ARGV.length > 2)
187
257
  elsif ARGV.length == 2
188
258
  command = ARGV[0]
189
259
  path = ARGV[1]
190
- elsif ARGV.length == 1 && %w{index extract-last}.include?(ARGV[0])
260
+ elsif ARGV.length == 1 && %w{index extract-last to-xes-xml}.include?(ARGV[0])
191
261
  command = ARGV[0]
192
262
  end
193
263
 
@@ -300,6 +370,35 @@ elsif command == 'index'
300
370
 
301
371
  File.write(f + '.index', MessagePack.pack(nindex))
302
372
  end
373
+ elsif command == 'to-xes-xml'
374
+ path = if path
375
+ [path]
376
+ else
377
+ Dir.glob('*.xes.yaml')
378
+ end
379
+
380
+ path.each do |f|
381
+ xml = XML::Smart.string(TEMPLATE_XES_XML)
382
+ xml.register_namespace 'x', 'http://www.xes-standard.org/'
383
+
384
+ io = File.open(f)
385
+ YAML.load_stream(io) do |e|
386
+ if trace = e.dig('log','trace')
387
+ trace.each do |t,tv|
388
+ xml.find('//x:trace').each do |ele|
389
+ ele.add('x:string', 'key' => t, 'value' => tv)
390
+ end
391
+ end
392
+ end
393
+ if e.dig('event')
394
+ xml.find('//x:trace').each do |node|
395
+ rec_insert(e.dig('event'),node.add('x:event'))
396
+ end
397
+ end
398
+ end
399
+
400
+ File.write(File.basename(f,'.xes.yaml') + '.xes.xml', xml.to_s)
401
+ end
303
402
  else
304
403
  puts ARGV.options
305
404
  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.5
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: tools
11
11
  cert_chain: []
12
- date: 2024-01-24 00:00:00.000000000 Z
12
+ date: 2024-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: riddl