infopark_reactor 1.25.2 → 1.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/rails_connector/job.rb +14 -0
- data/lib/reactor/cm/job.rb +79 -0
- data/lib/reactor/migration.rb +7 -1
- data/lib/reactor/plans/common_job.rb +32 -0
- data/lib/reactor/plans/create_job.rb +23 -0
- data/lib/reactor/plans/delete_channel.rb +4 -1
- data/lib/reactor/plans/delete_job.rb +25 -0
- data/lib/reactor/plans/update_job.rb +31 -0
- data/lib/reactor/tools/response_handler/xml_attribute.rb +16 -0
- data/lib/reactor/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e8434b8daf081b380a95c8e1dc9cd4862c7e735
|
4
|
+
data.tar.gz: a24b736884d52b6b011a7bfbc1169dc6c04a28cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7869cd7e683b8a1adb5e446a9400a654759949defe5d709db195d0f50bbae186ca1b4b628ed16b3a30a7341d9b037d8910ff0667f6e8cd750dd5019689433a22
|
7
|
+
data.tar.gz: e4c5fb4d5f3be48c69c913615ef159266c39cad7d348b0322d45109fb4670358efba11ddb8e6a319a64d995a7634aa3447f8f02f0ad624d2e8c6ce59bf74e20e
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module RailsConnector
|
3
|
+
|
4
|
+
# This class allows us to read out basic information about jobs
|
5
|
+
class Job < RailsConnector::AbstractModel
|
6
|
+
|
7
|
+
self.primary_key = "job_id"
|
8
|
+
|
9
|
+
def self.table_name
|
10
|
+
"#{table_name_prefix}" "jobs"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
require 'reactor/cm/object_base'
|
4
|
+
|
5
|
+
module Reactor
|
6
|
+
module Cm
|
7
|
+
class Job < ObjectBase
|
8
|
+
attribute :name, :except => [:set]
|
9
|
+
attribute :title
|
10
|
+
attribute :is_active, :name => :isActive
|
11
|
+
attribute :comment
|
12
|
+
attribute :exec_login, :name => :execLogin
|
13
|
+
attribute :exec_perm, :name => :execPerm
|
14
|
+
# This attribute has the following format:
|
15
|
+
# [{:years => ['2001', '2002']}, {:years => ['2002', '2003'], :minutes => ['11', '12']}]
|
16
|
+
attribute :schedule, :type => :schedule
|
17
|
+
attribute :script
|
18
|
+
|
19
|
+
primary_key :name
|
20
|
+
|
21
|
+
def self.serialize_attribute_to_xml(xml, xml_attribute, value)
|
22
|
+
if xml_attribute.type.to_sym == :schedule
|
23
|
+
xml.tag!('schedule') do
|
24
|
+
(value || []).each do |schedule_entry|
|
25
|
+
xml.tag!('listitem') do
|
26
|
+
schedule_entry.each do |dim, values|
|
27
|
+
xml.tag!('dictitem') do
|
28
|
+
xml.tag!('key') do
|
29
|
+
xml.text!(dim.to_s)
|
30
|
+
end
|
31
|
+
xml.tag!('value') do
|
32
|
+
values.each do |val|
|
33
|
+
xml.tag!('listitem', val)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
else
|
42
|
+
super(xml, xml_attribute, value)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.create(pk_value, attributes={})
|
47
|
+
request = XmlRequest.prepare do |xml|
|
48
|
+
xml.create_tag!(base_name) do
|
49
|
+
attributes.merge(:name => pk_value).each do |attr_name, attr_value|
|
50
|
+
self.serialize_attribute_to_xml(xml, self.xml_attribute(attr_name), attr_value)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
response = request.execute!
|
56
|
+
|
57
|
+
return get(pk_value)
|
58
|
+
end
|
59
|
+
|
60
|
+
def exec
|
61
|
+
simple_commnad('exec')
|
62
|
+
end
|
63
|
+
|
64
|
+
def cancel
|
65
|
+
simple_command('cancel')
|
66
|
+
end
|
67
|
+
|
68
|
+
protected
|
69
|
+
def simple_command(cmd_name)
|
70
|
+
request = XmlRequest.prepare do |xml|
|
71
|
+
xml.where_key_tag!(self.base_name, 'name', self.name)
|
72
|
+
xml.tag!("#{self.base_name}-#{cmd_name}")
|
73
|
+
end
|
74
|
+
response = request.execute!
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
data/lib/reactor/migration.rb
CHANGED
@@ -18,6 +18,9 @@ require 'reactor/plans/delete_group'
|
|
18
18
|
require 'reactor/plans/rename_group'
|
19
19
|
require 'reactor/plans/create_channel'
|
20
20
|
require 'reactor/plans/delete_channel'
|
21
|
+
require 'reactor/plans/create_job'
|
22
|
+
require 'reactor/plans/update_job'
|
23
|
+
require 'reactor/plans/delete_job'
|
21
24
|
|
22
25
|
module Reactor
|
23
26
|
class Migration
|
@@ -40,7 +43,10 @@ module Reactor
|
|
40
43
|
:update_group => Plans::UpdateGroup,
|
41
44
|
:rename_group => Plans::RenameGroup,
|
42
45
|
:create_channel => Plans::CreateChannel,
|
43
|
-
:delete_channel => Plans::DeleteChannel
|
46
|
+
:delete_channel => Plans::DeleteChannel,
|
47
|
+
:create_job => Plans::CreateJob,
|
48
|
+
:delete_job => Plans::DeleteJob,
|
49
|
+
:update_job => Plans::UpdateJob
|
44
50
|
}
|
45
51
|
|
46
52
|
def self.method_missing(name, *args, &block)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Reactor
|
3
|
+
module Plans
|
4
|
+
class CommonJob
|
5
|
+
include Prepared
|
6
|
+
|
7
|
+
ALLOWED_PARAMS = [:title, :is_active, :comment, :exec_login, :exec_perm, :schedule, :script]
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@params = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def set(key,value)
|
14
|
+
@params[key.to_sym] = value
|
15
|
+
end
|
16
|
+
|
17
|
+
def migrate!
|
18
|
+
raise "#{self.class.name} did not implement migrate!"
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
def prepare_params!(job=nil)
|
23
|
+
@params.keys.each{|k| error("unknown parameter: #{k}") unless ALLOWED_PARAMS.include? k}
|
24
|
+
end
|
25
|
+
|
26
|
+
def migrate_params!(job)
|
27
|
+
@params.each{|k,v|job.send(:"#{k}=",v)}
|
28
|
+
job.save!
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'reactor/cm/job'
|
3
|
+
require 'reactor/plans/common_job'
|
4
|
+
|
5
|
+
module Reactor
|
6
|
+
module Plans
|
7
|
+
class CreateJob < CommonJob
|
8
|
+
def initialize(*args)
|
9
|
+
super()
|
10
|
+
(name, x), options = separate_arguments(*args)
|
11
|
+
@name = name || options[:name]
|
12
|
+
end
|
13
|
+
|
14
|
+
def prepare!
|
15
|
+
error("name is nil") if @name.nil?
|
16
|
+
end
|
17
|
+
|
18
|
+
def migrate!
|
19
|
+
job = Reactor::Cm::Job.create(@name, @params)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
+
require 'reactor/cm/channel'
|
3
|
+
require 'reactor/plans/common_channel'
|
2
4
|
module Reactor
|
5
|
+
|
3
6
|
module Plans
|
4
|
-
class DeleteChannel <
|
7
|
+
class DeleteChannel < CommonChannel
|
5
8
|
def initialize(*args)
|
6
9
|
super()
|
7
10
|
(name, x), options = separate_arguments(*args)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'reactor/cm/job'
|
3
|
+
require 'reactor/plans/common_job'
|
4
|
+
|
5
|
+
module Reactor
|
6
|
+
module Plans
|
7
|
+
class DeleteJob < CommonJob
|
8
|
+
def initialize(*args)
|
9
|
+
super()
|
10
|
+
(name, x), options = separate_arguments(*args)
|
11
|
+
@name = name || options[:name]
|
12
|
+
end
|
13
|
+
|
14
|
+
def prepare!
|
15
|
+
error("name is nil") if @name.nil?
|
16
|
+
error("job #{@name} does not exist") if not Reactor::Cm::Job.exists?(@name)
|
17
|
+
end
|
18
|
+
|
19
|
+
def migrate!
|
20
|
+
Reactor::Cm::Job.delete!(@name)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'reactor/cm/job'
|
3
|
+
require 'reactor/plans/common_job'
|
4
|
+
|
5
|
+
module Reactor
|
6
|
+
module Plans
|
7
|
+
class UpdateJob < CommonJob
|
8
|
+
def initialize(*args)
|
9
|
+
super()
|
10
|
+
|
11
|
+
(name, _), options = separate_arguments(*args)
|
12
|
+
@name = name || options[:name]
|
13
|
+
end
|
14
|
+
|
15
|
+
def prepapre!
|
16
|
+
error('name is nil') if @name.nil?
|
17
|
+
error("job #{@name} not found") unless Reactor::Cm::Job.exists?(@name)
|
18
|
+
|
19
|
+
prepare_params!(nil)
|
20
|
+
end
|
21
|
+
|
22
|
+
def migrate!
|
23
|
+
job = Reactor::Cm::Job.get(@name)
|
24
|
+
migrate_params!(job)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -75,6 +75,22 @@ module Reactor
|
|
75
75
|
Reactor::XPathExtractor.new(self.node).match(expr)
|
76
76
|
end
|
77
77
|
|
78
|
+
def extract_schedule(name)
|
79
|
+
schedule_entries = []
|
80
|
+
self.response.xpath("//#{name}/listitem").each do |potential_schedule|
|
81
|
+
entry = {}
|
82
|
+
potential_schedule.children.find_all {|c| c.name == "dictitem" }.each do |item|
|
83
|
+
key = item.children.find {|c| c.name == "key" }.text
|
84
|
+
values_item = item.children.find {|c| c.name == "value" }
|
85
|
+
values = values_item.children.find_all { |c| c.name == "listitem" }.map {|i| i.text.to_s }
|
86
|
+
entry[key.to_sym] = values
|
87
|
+
end
|
88
|
+
schedule_entries << entry
|
89
|
+
end
|
90
|
+
|
91
|
+
schedule_entries
|
92
|
+
end
|
93
|
+
|
78
94
|
end
|
79
95
|
|
80
96
|
end
|
data/lib/reactor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infopark_reactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomasz Przedmojski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- app/models/rails_connector/blob_mapping.rb
|
91
91
|
- app/models/rails_connector/channel.rb
|
92
92
|
- app/models/rails_connector/content.rb
|
93
|
+
- app/models/rails_connector/job.rb
|
93
94
|
- app/models/rails_connector/obj_class.rb
|
94
95
|
- app/models/rails_connector/obj_class_attr.rb
|
95
96
|
- app/models/rails_connector/object_with_meta_data.rb
|
@@ -117,6 +118,7 @@ files:
|
|
117
118
|
- lib/reactor/cm/channel.rb
|
118
119
|
- lib/reactor/cm/editorial_group.rb
|
119
120
|
- lib/reactor/cm/group.rb
|
121
|
+
- lib/reactor/cm/job.rb
|
120
122
|
- lib/reactor/cm/language.rb
|
121
123
|
- lib/reactor/cm/link.rb
|
122
124
|
- lib/reactor/cm/live_group.rb
|
@@ -152,17 +154,20 @@ files:
|
|
152
154
|
- lib/reactor/plans/common_attribute_group.rb
|
153
155
|
- lib/reactor/plans/common_channel.rb
|
154
156
|
- lib/reactor/plans/common_group.rb
|
157
|
+
- lib/reactor/plans/common_job.rb
|
155
158
|
- lib/reactor/plans/common_obj_class.rb
|
156
159
|
- lib/reactor/plans/create_attribute.rb
|
157
160
|
- lib/reactor/plans/create_attribute_group.rb
|
158
161
|
- lib/reactor/plans/create_channel.rb
|
159
162
|
- lib/reactor/plans/create_group.rb
|
163
|
+
- lib/reactor/plans/create_job.rb
|
160
164
|
- lib/reactor/plans/create_obj.rb
|
161
165
|
- lib/reactor/plans/create_obj_class.rb
|
162
166
|
- lib/reactor/plans/delete_attribute.rb
|
163
167
|
- lib/reactor/plans/delete_attribute_group.rb
|
164
168
|
- lib/reactor/plans/delete_channel.rb
|
165
169
|
- lib/reactor/plans/delete_group.rb
|
170
|
+
- lib/reactor/plans/delete_job.rb
|
166
171
|
- lib/reactor/plans/delete_obj.rb
|
167
172
|
- lib/reactor/plans/delete_obj_class.rb
|
168
173
|
- lib/reactor/plans/prepared.rb
|
@@ -171,6 +176,7 @@ files:
|
|
171
176
|
- lib/reactor/plans/update_attribute.rb
|
172
177
|
- lib/reactor/plans/update_attribute_group.rb
|
173
178
|
- lib/reactor/plans/update_group.rb
|
179
|
+
- lib/reactor/plans/update_job.rb
|
174
180
|
- lib/reactor/plans/update_obj.rb
|
175
181
|
- lib/reactor/plans/update_obj_class.rb
|
176
182
|
- lib/reactor/rails_connector_meta.rb
|