cmor_transports 0.0.56.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +19 -0
- data/app/assets/config/cmor/transports_manifest.js +1 -0
- data/app/assets/javascripts/cmor/transports/application.js +2 -0
- data/app/assets/javascripts/cmor/transports/application/keep.js +0 -0
- data/app/assets/javascripts/cmor_transports.js +2 -0
- data/app/assets/stylesheets/cmor/transports/application.css +3 -0
- data/app/assets/stylesheets/cmor/transports/application/keep.css +0 -0
- data/app/assets/stylesheets/cmor_transports.css +3 -0
- data/app/concerns/cmor/transports/models/uuid_concern.rb +20 -0
- data/app/concerns/cmor/transports/resources_controller/export_concern.rb +63 -0
- data/app/concerns/cmor/transports/routing/export_resources_concern.rb +30 -0
- data/app/controllers/cmor/transports/api/incoming/create_services_controller.rb +22 -0
- data/app/controllers/cmor/transports/api/incoming/show_services_controller.rb +22 -0
- data/app/controllers/cmor/transports/export_sidebars_controller.rb +11 -0
- data/app/controllers/cmor/transports/exports_controller.rb +24 -0
- data/app/controllers/cmor/transports/home_controller.rb +6 -0
- data/app/controllers/cmor/transports/incomings_controller.rb +16 -0
- data/app/controllers/cmor/transports/outgoings_controller.rb +16 -0
- data/app/controllers/cmor/transports/systems_controller.rb +14 -0
- data/app/models/cmor/transports/export.rb +61 -0
- data/app/models/cmor/transports/import.rb +37 -0
- data/app/models/cmor/transports/incoming.rb +40 -0
- data/app/models/cmor/transports/outgoing.rb +98 -0
- data/app/models/cmor/transports/outgoing_export.rb +8 -0
- data/app/models/cmor/transports/outgoing_target.rb +20 -0
- data/app/models/cmor/transports/system.rb +15 -0
- data/app/services/cmor/transports/api/incoming/create_service.rb +45 -0
- data/app/services/cmor/transports/api/incoming/show_service.rb +22 -0
- data/app/services/cmor/transports/exports/base.rb +74 -0
- data/app/services/cmor/transports/exports/csv_service.rb +32 -0
- data/app/services/cmor/transports/exports/json_service.rb +25 -0
- data/app/services/cmor/transports/exports/yaml_service.rb +25 -0
- data/app/services/cmor/transports/packs/base.rb +19 -0
- data/app/services/cmor/transports/packs/zip_service.rb +28 -0
- data/app/services/cmor/transports/transfers/api/incoming_state_service.rb +39 -0
- data/app/services/cmor/transports/transfers/api/push_service.rb +47 -0
- data/app/view_helpers/cmor/transports/application_view_helper.rb +6 -0
- data/app/view_helpers/cmor/transports/export_view_helper.rb +63 -0
- data/app/views/cmor/core/backend/resources_controller/base/_export_form.html.haml +3 -0
- data/app/views/cmor/core/backend/resources_controller/base/export.html.haml +6 -0
- data/app/views/cmor/transports/export_sidebars/show.html.haml +1 -0
- data/app/views/cmor/transports/exports/_after_show_table.html.haml +9 -0
- data/app/views/cmor/transports/exports/_form.html.haml +6 -0
- data/app/views/cmor/transports/exports/_index_table.html.haml +14 -0
- data/app/views/cmor/transports/exports/_show_table.html.haml +17 -0
- data/app/views/cmor/transports/incomings/_index_table.html.haml +12 -0
- data/app/views/cmor/transports/outgoings/_after_show_table.html.haml +26 -0
- data/app/views/cmor/transports/outgoings/_form.html.haml +2 -0
- data/app/views/cmor/transports/outgoings/_index_table.html.haml +8 -0
- data/app/views/cmor/transports/outgoings/_show_table.html.haml +11 -0
- data/config/initializers/assets.rb +2 -0
- data/config/initializers/cmor.rb +3 -0
- data/config/initializers/include_routing_concerns.rb +1 -0
- data/config/locales/de.yml +43 -0
- data/config/locales/en.yml +41 -0
- data/config/routes.rb +31 -0
- data/db/migrate/20200525095216_create_cmor_transports_exports.rb +20 -0
- data/db/migrate/20200607101713_create_cmor_transports_outgoings.rb +15 -0
- data/db/migrate/20200607102346_create_cmor_transports_outgoing_exports.rb +10 -0
- data/db/migrate/20200607105529_create_cmor_transports_systems.rb +11 -0
- data/db/migrate/20200607105839_create_cmor_transports_outgoing_targets.rb +10 -0
- data/db/migrate/20200607110930_create_cmor_transports_incomings.rb +16 -0
- data/db/migrate/20200607111046_create_cmor_transports_imports.rb +17 -0
- data/lib/cmor/transports/configuration.rb +41 -0
- data/lib/cmor/transports/engine.rb +19 -0
- data/lib/cmor/transports/version.rb +7 -0
- data/lib/cmor_transports.rb +18 -0
- data/lib/generators/cmor/transports/install/install_generator.rb +26 -0
- data/lib/generators/cmor/transports/install/templates/initializer.rb +45 -0
- data/lib/generators/cmor/transports/install/templates/routes.source +4 -0
- data/lib/tasks/cmor/transports_tasks.rake +5 -0
- data/spec/factories/cmor_transports_exports.rb +11 -0
- data/spec/factories/cmor_transports_imports.rb +7 -0
- data/spec/factories/cmor_transports_incomings.rb +7 -0
- data/spec/factories/cmor_transports_outgoing_exports.rb +8 -0
- data/spec/factories/cmor_transports_outgoing_targets.rb +8 -0
- data/spec/factories/cmor_transports_outgoings.rb +6 -0
- data/spec/factories/cmor_transports_systems.rb +9 -0
- data/spec/files/cmor/transports/outgoing/output/example.zip +0 -0
- metadata +601 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d8b589bf7f645e6021a753b9ffd0cd58757c012802707023f465b3d46b0db985
|
4
|
+
data.tar.gz: daebbfc29655455ffdd9c206a516034e0fc7d6942a161e78a84a86c73fe0a7a8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f6664ef8c77dafd879f0c61d7bf2111215bfe0a772dac2e8ebf7ec3bdc6a3ac68fec04981aeb9ec03d3a652ef2c1f10ff1d2db7735e49de27a783278413676ee
|
7
|
+
data.tar.gz: 34deea9c5d49f8b1ee8bca574abb02c059da6a2fc95018f0531cd42f6cb5f45f777c1c7000d49b1a9ae016853c29411f60676c5b548067ac338e1cdb2f02881a
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019 Roberto Vasquez Angel
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Cmor::Transports
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'cmor/transports'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install cmor/transports
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Cmor::Transports'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
Bundler::GemHelper.install_tasks
|
18
|
+
|
19
|
+
require 'rails/dummy/tasks'
|
@@ -0,0 +1 @@
|
|
1
|
+
//= link_directory ../stylesheets/cmor/transports .css
|
File without changes
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmor
|
4
|
+
module Transports
|
5
|
+
module Models
|
6
|
+
module UuidConcern
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
after_initialize :set_uuid, if: :new_record?
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def set_uuid
|
15
|
+
self.uuid ||= SecureRandom.uuid
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmor
|
4
|
+
module Transports
|
5
|
+
module ResourcesController
|
6
|
+
module ExportConcern
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
before_action(only: :export) { initialize_export_for_export }
|
11
|
+
before_action(only: :dump) { initialize_export_for_dump }
|
12
|
+
|
13
|
+
helper_method :dump_path
|
14
|
+
helper_method :export_path
|
15
|
+
end
|
16
|
+
|
17
|
+
def export; end
|
18
|
+
def dump
|
19
|
+
if @resource.aasm.fire!(:enqueue)
|
20
|
+
respond_with(@resource, location: url_for([cmor_transports, @resource]))
|
21
|
+
else
|
22
|
+
render :export
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def attributes_for_export
|
28
|
+
resource_class.attribute_names
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize_export_for_export
|
32
|
+
@resource = Cmor::Transports::Export.new(
|
33
|
+
root_model: self.resource_class.to_s,
|
34
|
+
output_attributes: attributes_for_export
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def initialize_export_for_dump
|
39
|
+
@resource = Cmor::Transports::Export.new(permitted_params_for_dump.except("output_attributes")).tap do |resource|
|
40
|
+
resource.output_attributes = permitted_params_for_dump["output_attributes"].reject { |e| e.empty? }
|
41
|
+
resource.creator = current_user if respond_to?(:current_user)
|
42
|
+
resource.query = load_collection_scope.all.to_sql
|
43
|
+
resource.count_query = load_collection_scope.unscope(:order).select(Arel.star.count).to_sql
|
44
|
+
resource.root_model = self.resource_class.to_s
|
45
|
+
resource
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def dump_path
|
50
|
+
url_for(request.GET.clone.merge(action: :dump, only_path: true))
|
51
|
+
end
|
52
|
+
|
53
|
+
def export_path
|
54
|
+
url_for(request.GET.clone.merge(action: :export))
|
55
|
+
end
|
56
|
+
|
57
|
+
def permitted_params_for_dump
|
58
|
+
params.require(:export).permit(:description, :output_format, output_attributes: [])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmor
|
4
|
+
module Transports
|
5
|
+
module Routing
|
6
|
+
# Example:
|
7
|
+
#
|
8
|
+
# Rails.application.routes.draw do
|
9
|
+
# resources :posts do
|
10
|
+
# export_resources
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# This will give you:
|
15
|
+
#
|
16
|
+
# Prefix Verb URI Pattern
|
17
|
+
# export_posts GET /posts/export(.:format) posts#export
|
18
|
+
# dump_posts POST /posts/dump(.:format) posts#dump
|
19
|
+
#
|
20
|
+
module ExportResourcesConcern
|
21
|
+
extend ActiveSupport::Concern
|
22
|
+
|
23
|
+
def export_resources
|
24
|
+
get :export, on: :collection
|
25
|
+
post :dump, on: :collection
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmor
|
4
|
+
module Transports
|
5
|
+
module Api
|
6
|
+
module Incoming
|
7
|
+
class CreateServicesController < Rao::Api::ServiceController::Base
|
8
|
+
protect_from_forgery with: :null_session
|
9
|
+
|
10
|
+
def self.service_class
|
11
|
+
Cmor::Transports::Api::Incoming::CreateService
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def permitted_params
|
16
|
+
params.require(:create_service).permit(outgoing: [:id, :uuid, :state, :creator_type, :creator_id, :job_id, :service_messages, :service_errors, :description, :created_at, :updated_at, :output_base64])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmor
|
4
|
+
module Transports
|
5
|
+
module Api
|
6
|
+
module Incoming
|
7
|
+
class ShowServicesController < Rao::Api::ServiceController::Base
|
8
|
+
protect_from_forgery with: :null_session
|
9
|
+
|
10
|
+
def self.service_class
|
11
|
+
Cmor::Transports::Api::Incoming::ShowService
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def permitted_params
|
16
|
+
params.require(:show_service).permit(:outgoing_uuid)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmor::Transports
|
4
|
+
class ExportsController < Cmor::Core::Backend::ResourcesController::Base
|
5
|
+
include Rao::ResourcesController::AasmConcern
|
6
|
+
|
7
|
+
def self.resource_class
|
8
|
+
Cmor::Transports::Export
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def permitted_params
|
13
|
+
params.require(:export).permit(:root_model, :query, :count_query, :output_format, :description, output_attributes: [])
|
14
|
+
end
|
15
|
+
|
16
|
+
def after_create_location
|
17
|
+
if last_location.start_with?(url_for)
|
18
|
+
url_for(@resource)
|
19
|
+
else
|
20
|
+
last_location
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmor::Transports
|
4
|
+
class IncomingsController < Cmor::Core::Backend::ResourcesController::Base
|
5
|
+
include Rao::ResourcesController::AasmConcern
|
6
|
+
|
7
|
+
def self.resource_class
|
8
|
+
Cmor::Transports::Incoming
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def permitted_params
|
13
|
+
params.require(:incoming).permit()
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmor::Transports
|
4
|
+
class OutgoingsController < Cmor::Core::Backend::ResourcesController::Base
|
5
|
+
include Rao::ResourcesController::AasmConcern
|
6
|
+
|
7
|
+
def self.resource_class
|
8
|
+
Cmor::Transports::Outgoing
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def permitted_params
|
13
|
+
params.require(:outgoing).permit(export_ids: [], system_ids: [])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmor::Transports
|
4
|
+
class SystemsController < Cmor::Core::Backend::ResourcesController::Base
|
5
|
+
def self.resource_class
|
6
|
+
Cmor::Transports::System
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
def permitted_params
|
11
|
+
params.require(:system).permit(:identifier, :endpoint, :api_key)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmor::Transports
|
4
|
+
class Export < ApplicationRecord
|
5
|
+
include Cmor::Transports::Models::UuidConcern
|
6
|
+
include AASM
|
7
|
+
|
8
|
+
belongs_to :creator, optional: true, polymorphic: true
|
9
|
+
# belongs_to :job, optional: true
|
10
|
+
has_many :outgoing_exports
|
11
|
+
has_one_attached :output
|
12
|
+
|
13
|
+
validates :root_model, presence: true
|
14
|
+
validates :query, presence: true
|
15
|
+
validates :count_query, presence: true
|
16
|
+
validates :output_format, presence: true
|
17
|
+
|
18
|
+
serialize :output_attributes, Array
|
19
|
+
|
20
|
+
def human
|
21
|
+
[root_model, output_format, updated_at, creator].compact.join(" | ")
|
22
|
+
end
|
23
|
+
|
24
|
+
def count
|
25
|
+
root_model.constantize.count_by_sql(count_query)
|
26
|
+
end
|
27
|
+
|
28
|
+
aasm(:default, column: "state") do
|
29
|
+
state :created, initial: true
|
30
|
+
state :enqueued
|
31
|
+
state :processing
|
32
|
+
state :failed
|
33
|
+
state :succeeded
|
34
|
+
|
35
|
+
event :enqueue, after: :enqueue_service_call do
|
36
|
+
transitions from: :created, to: :enqueued
|
37
|
+
end
|
38
|
+
|
39
|
+
event :process do
|
40
|
+
transitions from: [:created, :enqueued], to: :processing
|
41
|
+
end
|
42
|
+
|
43
|
+
event :fail do
|
44
|
+
transitions from: :processing, to: :failed
|
45
|
+
end
|
46
|
+
|
47
|
+
event :succeed do
|
48
|
+
transitions from: :processing, to: :succeeded
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def enqueue_service_call
|
53
|
+
result = export_service_class_name.constantize.call_later!(export: self)
|
54
|
+
self.job_id = result.job_id
|
55
|
+
end
|
56
|
+
|
57
|
+
def export_service_class_name
|
58
|
+
"Cmor::Transports::Exports::#{self.output_format.camelize}Service"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmor::Transports
|
4
|
+
class Import < ApplicationRecord
|
5
|
+
include Cmor::Transports::Models::UuidConcern
|
6
|
+
include AASM
|
7
|
+
|
8
|
+
belongs_to :creator, polymorphic: true, optional: true
|
9
|
+
belongs_to :job, optional: true
|
10
|
+
|
11
|
+
validates :root_model, presence: true
|
12
|
+
|
13
|
+
aasm(:default, column: "state") do
|
14
|
+
state :created, initial: true
|
15
|
+
state :enqueued
|
16
|
+
state :processing
|
17
|
+
state :failed
|
18
|
+
state :succeeded
|
19
|
+
|
20
|
+
event :enqueue, after: :enqueue_service_call do
|
21
|
+
transitions from: :created, to: :enqueued
|
22
|
+
end
|
23
|
+
|
24
|
+
event :process do
|
25
|
+
transitions from: [:created, :enqueued], to: :processing
|
26
|
+
end
|
27
|
+
|
28
|
+
event :fail do
|
29
|
+
transitions from: :processing, to: :failed
|
30
|
+
end
|
31
|
+
|
32
|
+
event :succeed do
|
33
|
+
transitions from: :processing, to: :succeeded
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|