infopark_reactor_migrations 1.8.1 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,6 +18,7 @@ require 'reactor/cm/group'
18
18
  require 'reactor/cm/editorial_group'
19
19
  require 'reactor/cm/live_group'
20
20
  require 'reactor/cm/workflow'
21
+ require 'reactor/cm/log_entry'
21
22
  require 'reactor/cm/channel'
22
23
 
23
24
  # require main class
@@ -0,0 +1,62 @@
1
+ module Reactor
2
+ module Cm
3
+ class LogEntry
4
+ class << self
5
+ def where(conditions = {})
6
+ request = XmlRequest.prepare do |xml|
7
+ where_part(xml, conditions)
8
+ xml.tag!('logEntry-get') do
9
+ xml.tag!('logTime')
10
+ xml.tag!('logText')
11
+ xml.tag!('logType')
12
+ xml.tag!('objectId')
13
+ xml.tag!('receiver')
14
+ xml.tag!('userLogin')
15
+ end
16
+ end
17
+ response = request.execute!
18
+
19
+ result = []
20
+ response.xpath('//logEntry').each do |log_entry_node|
21
+ dict = {}
22
+ log_entry_node.each_element do |value_node|
23
+ if value_node.name == 'logTime'
24
+ dict[value_node.name] = value_node.elements['isoDateTime'].text.to_s
25
+ else
26
+ dict[value_node.name] = value_node.text.to_s
27
+ end
28
+ end
29
+
30
+ result << dict
31
+ end
32
+
33
+ return result
34
+ rescue Reactor::Cm::XmlRequestError => e
35
+ if e.message =~ /#{Regexp.escape('[060001] Es wurde kein Eintrag gefunden.')}/
36
+ return []
37
+ else
38
+ raise e
39
+ end
40
+ end
41
+
42
+ def delete(conditions)
43
+ request = XmlRequest.prepare do |xml|
44
+ where_part(xml, conditions)
45
+ xml.tag!('logEntry-delete')
46
+ end
47
+ response = request.execute!
48
+ result = response.xpath('//deleteLogEntriesCount').map {|x| x.text.to_s }.first
49
+ end
50
+
51
+ protected
52
+ def where_part(xml, conditions)
53
+ xml.tag!('logEntry-where') do
54
+ conditions.each do |key, value|
55
+ xml.tag!(key.to_s, value.to_s)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -186,36 +186,36 @@ module Reactor
186
186
  end
187
187
 
188
188
 
189
- def release!
190
- simple_command("release")
189
+ def release!(msg=nil)
190
+ simple_command("release",msg)
191
191
  end
192
192
 
193
- def edit!
194
- simple_command("edit")
193
+ def edit!(msg=nil)
194
+ simple_command("edit",msg)
195
195
  end
196
196
 
197
- def take!
198
- simple_command("take")
197
+ def take!(msg=nil)
198
+ simple_command("take",msg)
199
199
  end
200
200
 
201
- def forward!
202
- simple_command("forward")
201
+ def forward!(msg=nil)
202
+ simple_command("forward",msg)
203
203
  end
204
204
 
205
- def commit!
206
- simple_command("commit")
205
+ def commit!(msg=nil)
206
+ simple_command("commit",msg)
207
207
  end
208
208
 
209
- def reject!
210
- simple_command("reject")
209
+ def reject!(msg=nil)
210
+ simple_command("reject",msg)
211
211
  end
212
212
 
213
- def revert!
214
- simple_command("revert")
213
+ def revert!(msg=nil)
214
+ simple_command("revert",msg)
215
215
  end
216
216
 
217
- def sign!
218
- simple_command("sign")
217
+ def sign!(msg=nil)
218
+ simple_command("sign",msg)
219
219
  end
220
220
 
221
221
  def valid_actions
@@ -292,6 +292,18 @@ module Reactor
292
292
  result.kind_of?(Array) ? result.map(&:text).map(&:to_s) : [result.to_s]
293
293
  end
294
294
 
295
+ def workflow_comment
296
+ request = XmlRequest.prepare do |xml|
297
+ xml.tag!('content-where') do
298
+ xml.tag!('objectId', @obj_id)
299
+ xml.tag!('state', 'released')
300
+ end
301
+ xml.get_key_tag!('content', 'workflowComment')
302
+ end
303
+ response = request.execute!
304
+ result = response.xpath('//workflowComment/*').map {|x| x.text.to_s}.first
305
+ end
306
+
295
307
  def editor
296
308
  request = XmlRequest.prepare do |xml|
297
309
  xml.tag!('content-where') do
@@ -314,10 +326,16 @@ module Reactor
314
326
  end
315
327
 
316
328
  protected
317
- def simple_command(cmd_name)
329
+ def simple_command(cmd_name, comment=nil)
318
330
  @request = XmlRequest.prepare do |xml|
319
331
  xml.where_key_tag!(base_name, 'id', @obj_id)
320
- xml.tag!("#{base_name}-#{cmd_name}")
332
+ if comment
333
+ xml.tag!("#{base_name}-#{cmd_name}") do
334
+ xml.tag!('comment', comment)
335
+ end
336
+ else
337
+ xml.tag!("#{base_name}-#{cmd_name}")
338
+ end
321
339
  end
322
340
  response = @request.execute!
323
341
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Reactor
3
3
  module Migrations
4
- VERSION = "1.8.1"
4
+ VERSION = "1.8.2"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_reactor_migrations
3
3
  version: !ruby/object:Gem::Version
4
- hash: 53
4
+ hash: 51
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 8
9
- - 1
10
- version: 1.8.1
9
+ - 2
10
+ version: 1.8.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tomasz Przedmojski
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-06-19 00:00:00 +02:00
18
+ date: 2013-07-10 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -111,6 +111,7 @@ files:
111
111
  - lib/reactor/cm/language.rb
112
112
  - lib/reactor/cm/link.rb
113
113
  - lib/reactor/cm/live_group.rb
114
+ - lib/reactor/cm/log_entry.rb
114
115
  - lib/reactor/cm/missing_credentials.rb
115
116
  - lib/reactor/cm/obj.rb
116
117
  - lib/reactor/cm/obj_class.rb