kalibro_entities 0.0.1.rc1
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 +7 -0
- data/.gitignore +19 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +21 -0
- data/AUTHORS +4 -0
- data/COPYING +674 -0
- data/COPYING.LESSER +165 -0
- data/Gemfile +4 -0
- data/README.md +77 -0
- data/Rakefile +6 -0
- data/cucumber.yml +1 -0
- data/features/base_tool/all_names.feature +8 -0
- data/features/base_tool/find_by_name.feature +12 -0
- data/features/configuration/all.feature +10 -0
- data/features/metric_configuration/find.feature +18 -0
- data/features/metric_configuration/metric_configurations_of.feature +18 -0
- data/features/metric_result/descendant_results.feature +19 -0
- data/features/metric_result/history_of.feature +20 -0
- data/features/metric_result/metric_results_of.feature +19 -0
- data/features/module_result/children.feature +18 -0
- data/features/module_result/find.feature +15 -0
- data/features/module_result/history_of.feature +11 -0
- data/features/processing/first_processing_after.feature +18 -0
- data/features/processing/first_processing_of.feature +18 -0
- data/features/processing/has_processing.feature +18 -0
- data/features/processing/has_processing_after.feature +18 -0
- data/features/processing/has_processing_before.feature +18 -0
- data/features/processing/has_ready_processing.feature +18 -0
- data/features/processing/last_processing_before.feature +18 -0
- data/features/processing/last_processing_of.feature +18 -0
- data/features/processing/last_processing_state_of.feature +18 -0
- data/features/processing/last_ready_processing_of.feature +18 -0
- data/features/processing/processing_of.feature +32 -0
- data/features/processing/processing_with_date_of.feature +32 -0
- data/features/project/all.feature +10 -0
- data/features/project/creation.feature +9 -0
- data/features/project/destroy.feature +10 -0
- data/features/project/exists.feature +9 -0
- data/features/project/find.feature +10 -0
- data/features/range/ranges_of.feature +22 -0
- data/features/range/save.feature +32 -0
- data/features/reading/find.feature +11 -0
- data/features/reading/readings_of.feature +11 -0
- data/features/reading_group/all.feature +10 -0
- data/features/repository/all.feature +14 -0
- data/features/repository/cancel_processing.feature +14 -0
- data/features/repository/find.feature +14 -0
- data/features/repository/of.feature +15 -0
- data/features/repository/process.feature +16 -0
- data/features/repository/types.feature +9 -0
- data/features/step_definitions/base_tool_steps.rb +28 -0
- data/features/step_definitions/configuration_steps.rb +11 -0
- data/features/step_definitions/metric_configuration_steps.rb +52 -0
- data/features/step_definitions/metric_result_steps.rb +29 -0
- data/features/step_definitions/metric_steps.rb +3 -0
- data/features/step_definitions/module_result_steps.rb +30 -0
- data/features/step_definitions/processing_steps.rb +91 -0
- data/features/step_definitions/project_steps.rb +48 -0
- data/features/step_definitions/range_steps.rb +41 -0
- data/features/step_definitions/reading_group_steps.rb +19 -0
- data/features/step_definitions/reading_steps.rb +20 -0
- data/features/step_definitions/repository_steps.rb +57 -0
- data/features/support/env.rb +25 -0
- data/features/support/kalibro_cucumber_helpers.yml.sample +10 -0
- data/kalibro_entities.gemspec +48 -0
- data/lib/kalibro_entities.rb +61 -0
- data/lib/kalibro_entities/entities.rb +37 -0
- data/lib/kalibro_entities/entities/base_tool.rb +54 -0
- data/lib/kalibro_entities/entities/configuration.rb +33 -0
- data/lib/kalibro_entities/entities/date_metric_result.rb +39 -0
- data/lib/kalibro_entities/entities/date_module_result.rb +39 -0
- data/lib/kalibro_entities/entities/metric.rb +21 -0
- data/lib/kalibro_entities/entities/metric_configuration.rb +70 -0
- data/lib/kalibro_entities/entities/metric_configuration_snapshot.rb +57 -0
- data/lib/kalibro_entities/entities/metric_result.rb +63 -0
- data/lib/kalibro_entities/entities/model.rb +162 -0
- data/lib/kalibro_entities/entities/module.rb +27 -0
- data/lib/kalibro_entities/entities/module_result.rb +69 -0
- data/lib/kalibro_entities/entities/process_time.rb +31 -0
- data/lib/kalibro_entities/entities/processing.rb +113 -0
- data/lib/kalibro_entities/entities/project.rb +34 -0
- data/lib/kalibro_entities/entities/range.rb +75 -0
- data/lib/kalibro_entities/entities/range_snapshot.rb +37 -0
- data/lib/kalibro_entities/entities/reading.rb +51 -0
- data/lib/kalibro_entities/entities/reading_group.rb +43 -0
- data/lib/kalibro_entities/entities/repository.rb +78 -0
- data/lib/kalibro_entities/entities/repository_observer.rb +50 -0
- data/lib/kalibro_entities/entities/stack_trace_element.rb +31 -0
- data/lib/kalibro_entities/entities/throwable.rb +42 -0
- data/lib/kalibro_entities/errors.rb +18 -0
- data/lib/kalibro_entities/errors/record_not_found.rb +22 -0
- data/lib/kalibro_entities/errors/standard.rb +24 -0
- data/lib/kalibro_entities/helpers/aggregation_options.rb +25 -0
- data/lib/kalibro_entities/helpers/hash_converters.rb +48 -0
- data/lib/kalibro_entities/helpers/request_methods.rb +47 -0
- data/lib/kalibro_entities/helpers/xml_converters.rb +20 -0
- data/lib/kalibro_entities/kalibro_cucumber_helpers.rb +40 -0
- data/lib/kalibro_entities/kalibro_cucumber_helpers/configuration.rb +39 -0
- data/lib/kalibro_entities/kalibro_cucumber_helpers/hooks.rb +50 -0
- data/lib/kalibro_entities/kalibro_cucumber_helpers/scripts/delete_all_kalibro_entries.sh +23 -0
- data/lib/kalibro_entities/kalibro_cucumber_helpers/scripts/prepare_kalibro_query_file.sh +38 -0
- data/lib/kalibro_entities/kalibro_cucumber_helpers/scripts/put_kalibro_on_test_mode.sh +35 -0
- data/lib/kalibro_entities/kalibro_cucumber_helpers/scripts/return_kalibro_from_test_mode.sh +26 -0
- data/lib/kalibro_entities/version.rb +19 -0
- data/lib/rake/test_task.rb +57 -0
- data/spec/entities/base_tool_spec.rb +168 -0
- data/spec/entities/configuration_spec.rb +61 -0
- data/spec/entities/date_metric_result_spec.rb +62 -0
- data/spec/entities/date_module_result_spec.rb +61 -0
- data/spec/entities/metric_configuration_snapshot_spec.rb +107 -0
- data/spec/entities/metric_configuration_spec.rb +149 -0
- data/spec/entities/metric_result_spec.rb +193 -0
- data/spec/entities/metric_spec.rb +47 -0
- data/spec/entities/model_spec.rb +275 -0
- data/spec/entities/module_result_spec.rb +135 -0
- data/spec/entities/process_time_spec.rb +33 -0
- data/spec/entities/processing_spec.rb +334 -0
- data/spec/entities/project_spec.rb +68 -0
- data/spec/entities/range_snapshot_spec.rb +50 -0
- data/spec/entities/range_spec.rb +181 -0
- data/spec/entities/reading_group_spec.rb +90 -0
- data/spec/entities/reading_spec.rb +106 -0
- data/spec/entities/repository_observer_spec.rb +123 -0
- data/spec/entities/repository_spec.rb +167 -0
- data/spec/entities/stack_trace_element_spec.rb +26 -0
- data/spec/entities/throwable_spec.rb +51 -0
- data/spec/factories/base_tools.rb +31 -0
- data/spec/factories/configurations.rb +29 -0
- data/spec/factories/date_metric_results.rb +28 -0
- data/spec/factories/date_module_results.rb +22 -0
- data/spec/factories/metric_configurations.rb +28 -0
- data/spec/factories/metric_configurations_snapshot.rb +26 -0
- data/spec/factories/metric_results.rb +24 -0
- data/spec/factories/metrics.rb +35 -0
- data/spec/factories/models.rb +20 -0
- data/spec/factories/module_results.rb +33 -0
- data/spec/factories/modules.rb +22 -0
- data/spec/factories/process_times.rb +27 -0
- data/spec/factories/processings.rb +25 -0
- data/spec/factories/projects.rb +29 -0
- data/spec/factories/ranges.rb +30 -0
- data/spec/factories/ranges_snapshot.rb +26 -0
- data/spec/factories/reading_groups.rb +23 -0
- data/spec/factories/readings.rb +25 -0
- data/spec/factories/repositories.rb +34 -0
- data/spec/factories/repository_observers.rb +24 -0
- data/spec/factories/stack_trace_elements.rb +24 -0
- data/spec/factories/throwables.rb +23 -0
- data/spec/helpers/aggregation_options_spec.rb +31 -0
- data/spec/helpers/hash_converters_spec.rb +111 -0
- data/spec/helpers/xml_converters_spec.rb +64 -0
- data/spec/kalibro_entities_spec.rb +108 -0
- data/spec/savon/fixtures/config.yml +1 -0
- data/spec/savon/fixtures/invalid_config.yml +2 -0
- data/spec/savon/fixtures/project/does_not_exists.xml +1 -0
- data/spec/savon/savon_test_helper.rb +14 -0
- data/spec/spec_helper.rb +60 -0
- metadata +461 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
# This file is part of KalibroEntities
|
2
|
+
# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require "kalibro_entities/entities/model"
|
18
|
+
|
19
|
+
module KalibroEntities
|
20
|
+
module Entities
|
21
|
+
class MetricConfigurationSnapshot < Model
|
22
|
+
attr_accessor :code, :weight, :aggregation_form, :metric, :base_tool_name, :range
|
23
|
+
|
24
|
+
def weight=(value)
|
25
|
+
@weight = value.to_f
|
26
|
+
end
|
27
|
+
|
28
|
+
def metric=(value)
|
29
|
+
if value.kind_of?(Hash)
|
30
|
+
@metric = KalibroEntities::Entities::Metric.to_object(value)
|
31
|
+
else
|
32
|
+
@metric = value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def range=(value)
|
37
|
+
value = [value] unless value.kind_of?(Array)
|
38
|
+
@range = []
|
39
|
+
|
40
|
+
value.each do |range_snapshot|
|
41
|
+
@range << KalibroEntities::Entities::RangeSnapshot.to_object(range_snapshot)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def range_snapshot
|
46
|
+
range
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_hash
|
50
|
+
hash = super
|
51
|
+
hash[:attributes!][:range] = {'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
|
52
|
+
'xsi:type' => 'kalibro:rangeSnapshotXml' }
|
53
|
+
hash
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# This file is part of KalibroEntities
|
2
|
+
# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require "kalibro_entities/entities/model"
|
18
|
+
|
19
|
+
module KalibroEntities
|
20
|
+
module Entities
|
21
|
+
class MetricResult < Model
|
22
|
+
|
23
|
+
attr_accessor :id, :configuration, :value, :aggregated_value
|
24
|
+
|
25
|
+
def id=(value)
|
26
|
+
@id = value.to_i
|
27
|
+
end
|
28
|
+
|
29
|
+
def configuration=(value)
|
30
|
+
@configuration = KalibroEntities::Entities::MetricConfigurationSnapshot.to_object value
|
31
|
+
end
|
32
|
+
|
33
|
+
def metric_configuration_snapshot
|
34
|
+
@configuration
|
35
|
+
end
|
36
|
+
|
37
|
+
def value=(value)
|
38
|
+
@value = value.to_f
|
39
|
+
end
|
40
|
+
|
41
|
+
def aggregated_value=(value)
|
42
|
+
@aggregated_value = value.to_i
|
43
|
+
end
|
44
|
+
|
45
|
+
def descendant_results
|
46
|
+
response = self.class.request(:descendant_results_of, {:metric_result_id => id})[:descendant_result]
|
47
|
+
response = [] if response.nil?
|
48
|
+
response = [response] if response.is_a?(String)
|
49
|
+
response.map {|descendant_result| descendant_result.to_f}
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.metric_results_of(module_result_id)
|
53
|
+
create_objects_array_from_hash self.request(:metric_results_of, {:module_result_id => module_result_id})[:metric_result]
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.history_of(metric_name, module_result_id)
|
57
|
+
response = self.request(:history_of_metric, {:metric_name => metric_name,
|
58
|
+
:module_result_id => module_result_id})[:date_metric_result]
|
59
|
+
create_array_from_hash(response).map { |date_metric_result| KalibroEntities::Entities::DateMetricResult.new date_metric_result }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
# This file is part of KalibroEntities
|
2
|
+
# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require 'savon'
|
18
|
+
require 'kalibro_entities/helpers/hash_converters'
|
19
|
+
require 'kalibro_entities/helpers/request_methods'
|
20
|
+
|
21
|
+
module KalibroEntities
|
22
|
+
module Entities
|
23
|
+
class Model
|
24
|
+
attr_accessor :kalibro_errors
|
25
|
+
|
26
|
+
def initialize(attributes={})
|
27
|
+
attributes.each { |field, value| send("#{field}=", value) if self.class.is_valid?(field) }
|
28
|
+
@kalibro_errors = []
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_hash(options={})
|
32
|
+
hash = Hash.new
|
33
|
+
excepts = options[:except].nil? ? [] : options[:except]
|
34
|
+
excepts << :kalibro_errors
|
35
|
+
fields.each do |field|
|
36
|
+
hash = field_to_hash(field).merge(hash) if !excepts.include?(field)
|
37
|
+
end
|
38
|
+
hash
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.request(action, request_body = nil)
|
42
|
+
response = client(endpoint).call(action, message: request_body )
|
43
|
+
response.to_hash["#{action}_response".to_sym] # response is a Savon::SOAP::Response, and to_hash is a Savon::SOAP::Response method
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.to_object value
|
47
|
+
value.kind_of?(Hash) ? new(value) : value
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.to_objects_array value
|
51
|
+
array = value.kind_of?(Array) ? value : [value]
|
52
|
+
array.each.map { |element| to_object(element) }
|
53
|
+
end
|
54
|
+
|
55
|
+
def save
|
56
|
+
begin
|
57
|
+
self.id = self.class.request(save_action, save_params)["#{instance_class_name.underscore}_id".to_sym]
|
58
|
+
true
|
59
|
+
rescue Exception => exception
|
60
|
+
add_error exception
|
61
|
+
false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def save!
|
66
|
+
save
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.create(attributes={})
|
70
|
+
new_model = new attributes
|
71
|
+
new_model.save
|
72
|
+
new_model
|
73
|
+
end
|
74
|
+
|
75
|
+
def ==(another)
|
76
|
+
unless self.class == another.class then
|
77
|
+
return false
|
78
|
+
end
|
79
|
+
self.variable_names.each {
|
80
|
+
|name|
|
81
|
+
unless self.send("#{name}") == another.send("#{name}") then
|
82
|
+
return false
|
83
|
+
end
|
84
|
+
}
|
85
|
+
true
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.exists?(id)
|
89
|
+
request(exists_action, id_params(id))[:exists]
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.find(id)
|
93
|
+
if(exists?(id))
|
94
|
+
new request(find_action, id_params(id))["#{class_name.underscore}".to_sym]
|
95
|
+
else
|
96
|
+
raise KalibroEntities::Errors::RecordNotFound
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def destroy
|
101
|
+
begin
|
102
|
+
self.class.request(destroy_action, destroy_params)
|
103
|
+
rescue Exception => exception
|
104
|
+
add_error exception
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.create_objects_array_from_hash (response)
|
109
|
+
create_array_from_hash(response).map { |hash| new hash }
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.create_array_from_hash (response)
|
113
|
+
response = [] if response.nil?
|
114
|
+
response = [response] if response.is_a?(Hash)
|
115
|
+
response
|
116
|
+
end
|
117
|
+
|
118
|
+
protected
|
119
|
+
|
120
|
+
def instance_variable_names
|
121
|
+
instance_variables.map { |var| var.to_s }
|
122
|
+
end
|
123
|
+
|
124
|
+
def fields
|
125
|
+
instance_variable_names.each.collect { |variable| variable.to_s.sub(/@/, '').to_sym }
|
126
|
+
end
|
127
|
+
|
128
|
+
def variable_names
|
129
|
+
instance_variable_names.each.collect { |variable| variable.to_s.sub(/@/, '') }
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.client(endpoint)
|
133
|
+
Savon.client({log: false, wsdl: "#{KalibroEntities.config[:address]}#{endpoint}Endpoint/?wsdl"})
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.is_valid?(field)
|
137
|
+
field.to_s[0] != '@' and field != :attributes! and (field.to_s =~ /xsi/).nil?
|
138
|
+
end
|
139
|
+
|
140
|
+
def instance_class_name
|
141
|
+
self.class.name.gsub(/KalibroEntities::Entities::/,"")
|
142
|
+
end
|
143
|
+
|
144
|
+
include RequestMethods
|
145
|
+
extend RequestMethods::ClassMethods
|
146
|
+
|
147
|
+
def add_error(exception)
|
148
|
+
@kalibro_errors << exception
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.endpoint
|
152
|
+
class_name
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.class_name
|
156
|
+
self.name.gsub(/KalibroEntities::Entities::/,"")
|
157
|
+
end
|
158
|
+
|
159
|
+
include HashConverters
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# This file is part of KalibroEntities
|
2
|
+
# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require "kalibro_entities/entities/model"
|
18
|
+
|
19
|
+
module KalibroEntities
|
20
|
+
module Entities
|
21
|
+
class Module < Model
|
22
|
+
|
23
|
+
attr_accessor :name, :granularity
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# This file is part of KalibroEntities
|
2
|
+
# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require "kalibro_entities/entities/model"
|
18
|
+
|
19
|
+
module KalibroEntities
|
20
|
+
module Entities
|
21
|
+
class ModuleResult < Model
|
22
|
+
|
23
|
+
attr_accessor :id, :module, :grade, :parent_id, :height
|
24
|
+
|
25
|
+
def self.find(id)
|
26
|
+
begin
|
27
|
+
new request(:get_module_result, { :module_result_id => id })[:module_result]
|
28
|
+
rescue Savon::SOAPFault
|
29
|
+
raise KalibroEntities::Errors::RecordNotFound
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def children
|
34
|
+
response = self.class.request(:children_of, {:module_result_id => id})[:module_result]
|
35
|
+
self.class.create_objects_array_from_hash(response)
|
36
|
+
end
|
37
|
+
|
38
|
+
def parents
|
39
|
+
if parent_id == 0
|
40
|
+
[]
|
41
|
+
else
|
42
|
+
parent = self.class.find(parent_id)
|
43
|
+
parent.parents << parent
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def id=(value)
|
48
|
+
@id = value.to_i
|
49
|
+
end
|
50
|
+
|
51
|
+
def module=(value)
|
52
|
+
@module = KalibroEntities::Entities::Module.to_object value
|
53
|
+
end
|
54
|
+
|
55
|
+
def grade=(value)
|
56
|
+
@grade = value.to_f
|
57
|
+
end
|
58
|
+
|
59
|
+
def parent_id=(value)
|
60
|
+
@parent_id = value.to_i
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.history_of(module_result_id)
|
64
|
+
response = self.create_array_from_hash self.request(:history_of_module, {:module_result_id => module_result_id})[:date_module_result]
|
65
|
+
response.map {|date_module_result| KalibroEntities::Entities::DateModuleResult.new date_module_result}
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# This file is part of KalibroEntities
|
2
|
+
# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require "kalibro_entities/entities/model"
|
18
|
+
|
19
|
+
module KalibroEntities
|
20
|
+
module Entities
|
21
|
+
class ProcessTime < Model
|
22
|
+
|
23
|
+
attr_accessor :state, :time
|
24
|
+
|
25
|
+
def time=(time)
|
26
|
+
@time = time.to_i
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# This file is part of KalibroEntities
|
2
|
+
# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
require "kalibro_entities/entities/model"
|
18
|
+
|
19
|
+
module KalibroEntities
|
20
|
+
module Entities
|
21
|
+
class Processing < Model
|
22
|
+
|
23
|
+
attr_accessor :id, :date, :state, :error, :process_time, :results_root_id
|
24
|
+
|
25
|
+
def id=(value)
|
26
|
+
@id = value.to_i
|
27
|
+
end
|
28
|
+
|
29
|
+
def date=(value)
|
30
|
+
@date = value.is_a?(String) ? DateTime.parse(value) : value
|
31
|
+
end
|
32
|
+
|
33
|
+
def process_times=(value)
|
34
|
+
@process_time = value
|
35
|
+
end
|
36
|
+
|
37
|
+
def process_time=(value)
|
38
|
+
@process_time = KalibroEntities::Entities::ProcessTime.to_objects_array value
|
39
|
+
end
|
40
|
+
|
41
|
+
def process_times
|
42
|
+
@process_time
|
43
|
+
end
|
44
|
+
|
45
|
+
def error=(value)
|
46
|
+
@error = KalibroEntities::Entities::Throwable.to_object value
|
47
|
+
end
|
48
|
+
|
49
|
+
def results_root_id=(value)
|
50
|
+
@results_root_id = value.to_i
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.processing_of(repository_id)
|
54
|
+
if has_ready_processing(repository_id)
|
55
|
+
last_ready_processing_of(repository_id)
|
56
|
+
else
|
57
|
+
last_processing_of(repository_id)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.processing_with_date_of(repository_id, date)
|
62
|
+
date = date.is_a?(String) ? DateTime.parse(date) : date
|
63
|
+
if has_processing_after(repository_id, date)
|
64
|
+
first_processing_after(repository_id, date)
|
65
|
+
elsif has_processing_before(repository_id, date)
|
66
|
+
last_processing_before(repository_id, date)
|
67
|
+
else
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.has_processing(repository_id)
|
73
|
+
request(:has_processing, {:repository_id => repository_id})[:exists]
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.has_ready_processing(repository_id)
|
77
|
+
request(:has_ready_processing, {:repository_id => repository_id})[:exists]
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.has_processing_after(repository_id, date)
|
81
|
+
request(:has_processing_after, {:repository_id => repository_id, :date => date})[:exists]
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.has_processing_before(repository_id, date)
|
85
|
+
request(:has_processing_before, {:repository_id => repository_id, :date => date})[:exists]
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.last_processing_state_of(repository_id)
|
89
|
+
request(:last_processing_state, {:repository_id => repository_id})[:process_state]
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.last_ready_processing_of(repository_id)
|
93
|
+
new request(:last_ready_processing, {:repository_id => repository_id})[:processing]
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.first_processing_of(repository_id)
|
97
|
+
new request(:first_processing, {:repository_id => repository_id})[:processing]
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.last_processing_of(repository_id)
|
101
|
+
new request(:last_processing, {:repository_id => repository_id})[:processing]
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.first_processing_after(repository_id, date)
|
105
|
+
new request(:first_processing_after, {:repository_id => repository_id, :date => date})[:processing]
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.last_processing_before(repository_id, date)
|
109
|
+
new request(:last_processing_before, {:repository_id => repository_id, :date => date})[:processing]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|