infopark_reactor 1.8.1 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -70,6 +70,15 @@ much more efficient than the traditional method.
70
70
 
71
71
  Permissions are checked also! And your user is automatically set according to `JSESSIONID` cookie.
72
72
 
73
+ Workflow support is provided together with comments (just pass your comment as string to the relevant method):
74
+
75
+ obj.edit!('draft version created')
76
+ obj.forward!('please add your text')
77
+ # as other user
78
+ obj.take!
79
+ obj.release!('text added and released')
80
+
81
+
73
82
  KNOWN BUGS/ISSUES
74
83
  =================
75
84
 
@@ -27,7 +27,7 @@ module Reactor
27
27
  # Wraps around Reactor::Persistence::Base#release! and ensures
28
28
  # that current user has required permissions to release the object
29
29
  # @raise [Reactor::NotPermitted] user lacks neccessary permission
30
- def release!
30
+ def release!(*args)
31
31
  ensure_permission_granted(:release)
32
32
  return super
33
33
  end
@@ -35,7 +35,7 @@ module Reactor
35
35
  # Wraps around Reactor::Persistence::Base#take! and ensures
36
36
  # that current user has required permissions to take the object
37
37
  # @raise [Reactor::NotPermitted] user lacks neccessary permission
38
- def take!
38
+ def take!(*args)
39
39
  ensure_permission_granted(:take)
40
40
  return super
41
41
  end
@@ -43,7 +43,7 @@ module Reactor
43
43
  # Wraps around Reactor::Persistence::Base#revert! and ensures
44
44
  # that current user has required permissions to revert the object
45
45
  # @raise [Reactor::NotPermitted] user lacks neccessary permission
46
- def revert!
46
+ def revert!(*args)
47
47
  ensure_permission_granted(:revert)
48
48
  return super
49
49
  end
@@ -51,7 +51,7 @@ module Reactor
51
51
  # Wraps around Reactor::Persistence::Base#edit! and ensures
52
52
  # that current user has required permissions to edit the object
53
53
  # @raise [Reactor::NotPermitted] user lacks neccessary permission
54
- def edit!
54
+ def edit!(*args)
55
55
  ensure_permission_granted(:edit)
56
56
  return super
57
57
  end
@@ -28,37 +28,41 @@ module Reactor
28
28
  # 2. the object has already been released
29
29
  # 3. object is invalid
30
30
  # 4. other error occoured
31
- def release
32
- return release!
31
+ # @param comment [String] comment to leave for the next user
32
+ def release(comment=nil)
33
+ return release!(comment)
33
34
  rescue Reactor::Cm::XmlRequestError, ActiveRecord::RecordInvalid, Reactor::NotPermitted, Reactor::AlreadyReleased
34
35
  return false
35
36
  end
36
37
 
37
38
  # Removes the working version of the object,
38
39
  # if it exists
40
+ # @param comment [String] comment to leave for the next user
39
41
  # @return [true]
40
- def revert
41
- return revert!
42
+ def revert(comment=nil)
43
+ return revert!(comment)
42
44
  end
43
45
 
44
46
  # Removes the working version of the object,
45
47
  # if it exists
48
+ # @param comment [String] comment to leave for the next user
46
49
  # @return [true]
47
50
  # @note There is no difference between #revert and #revert!
48
- def revert!
49
- crul_obj.revert!
51
+ def revert!(comment=nil)
52
+ crul_obj.revert!(comment)
50
53
  reload
51
54
  return true
52
55
  end
53
56
 
54
57
  # Releases the object. Returns true on succes, can raise exceptions
58
+ # @param comment [String] comment to leave for the next user
55
59
  # @raise [Reactor::AlreadyReleased]
56
60
  # @raise [ActiveRecord::RecordInvalid] validations failed
57
61
  # @raise [Reactor::NotPermitted] current user lacks required permissions
58
- def release!
62
+ def release!(comment=nil)
59
63
  run_callbacks(:release) do
60
64
  raise(Reactor::AlreadyReleased) unless self.really_edited?
61
- crul_obj.release!
65
+ crul_obj.release!(comment)
62
66
  reload
63
67
  end
64
68
  return true
@@ -70,8 +74,9 @@ module Reactor
70
74
  # 1. user lacks the permissions
71
75
  # 2. the object has not beed edited
72
76
  # 3. other error occured
73
- def take
74
- take!
77
+ # @param comment [String] comment to leave for the next user
78
+ def take(comment=nil)
79
+ take!(comment)
75
80
  return true
76
81
  rescue Reactor::Cm::XmlRequestError, Reactor::NotPermitted, Reactor::NoWorkingVersion
77
82
  return false
@@ -79,12 +84,13 @@ module Reactor
79
84
 
80
85
  # Makes the current user the editor of the object. Returns true when
81
86
  # user is already the editor or take succeded. Raises exceptions
87
+ # @param comment [String] comment to leave for the next user
82
88
  # @raise [Reactor::NoWorkingVersion] there is no working version of the object
83
89
  # @raise [Reactor::NotPermitted] current user lacks required permissions
84
- def take!
90
+ def take!(comment=nil)
85
91
  raise(Reactor::NoWorkingVersion) unless self.really_edited?
86
92
  # TODO: refactor the if condition
87
- crul_obj.take! if (crul_obj.editor != Reactor::Configuration::xml_access[:username])
93
+ crul_obj.take!(comment) if (crul_obj.editor != Reactor::Configuration::xml_access[:username])
88
94
  # neccessary to recalculate #editor
89
95
  reload
90
96
  return true
@@ -92,10 +98,11 @@ module Reactor
92
98
 
93
99
  # Creates a working version of the object. Returns true on success or when
94
100
  # the object already has a working version. Returns false when:
101
+ # @param comment [String] comment to leave for the next user
95
102
  # 1. user lacks the permissions
96
103
  # 2. other error occured
97
- def edit
98
- edit!
104
+ def edit(comment=nil)
105
+ edit!(comment)
99
106
  return true
100
107
  rescue Reactor::Cm::XmlRequestError, Reactor::NotPermitted
101
108
  return false
@@ -103,9 +110,10 @@ module Reactor
103
110
 
104
111
  # Creates a working version of the object. Returns true on success or when
105
112
  # the object already has a working version. Raises exceptions
113
+ # @param comment [String] comment to leave for the next user
106
114
  # @raise [Reactor::NotPermitted] current user lacks required permissions
107
- def edit!
108
- crul_obj.edit! unless self.really_edited?
115
+ def edit!(comment=nil)
116
+ crul_obj.edit!(comment) unless self.really_edited?
109
117
  reload
110
118
  return true
111
119
  end
@@ -22,7 +22,7 @@ module Reactor
22
22
  # Wraps around Reactor::Persistence::Base#release! and validates object
23
23
  # in :release context before release. Raises exception when invalid.
24
24
  # @raise [ActiveRecord::RecordInvalid] validations registered for :release failed
25
- def release!
25
+ def release!(*args)
26
26
  raise(ActiveRecord::RecordInvalid.new(self)) unless valid?(:release)
27
27
  return super
28
28
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Reactor
3
- VERSION = "1.8.1"
3
+ VERSION = "1.8.2"
4
4
  end
@@ -15,6 +15,34 @@ module Reactor
15
15
  Empty.new(self)
16
16
  end
17
17
  end
18
+
19
+ def workflow_comments
20
+ Reactor::Cm::LogEntry.where(:objectId => self.id).map {|entry| Comment.new(entry) }
21
+ end
22
+ end
23
+
24
+ class Comment < Struct.new(:time, :text, :type, :object_id, :receiver, :user)
25
+ def initialize(log_entry)
26
+ super(
27
+ parse_time(log_entry['logTime']),
28
+ log_entry['logText'],
29
+ log_entry['logType'],
30
+ log_entry['objectId'],
31
+ log_entry['receiver'],
32
+ log_entry['userLogin']
33
+ )
34
+ end
35
+
36
+ def object
37
+ ::AbstractObj.find(self.object_id)
38
+ end
39
+
40
+ alias obj object
41
+
42
+ protected
43
+ def parse_time(time)
44
+ Time.from_iso(time)
45
+ end
18
46
  end
19
47
  end
20
48
  end
@@ -21,8 +21,8 @@ module Reactor
21
21
  valid_action?(action)
22
22
  end
23
23
 
24
- define_method :"#{action}!" do
25
- @obj.send(:crul_obj).send(:"#{action}!")
24
+ define_method :"#{action}!" do |*args|
25
+ @obj.send(:crul_obj).send(:"#{action}!", *args)
26
26
  end
27
27
  end
28
28
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_reactor
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