You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by al...@apache.org on 2015/08/24 13:41:38 UTC

[12/50] [abbrv] incubator-taverna-databundle-viewer git commit: Extract files from datbundle on upload file

Extract files from datbundle on upload file


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/commit/974abbcf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/tree/974abbcf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/diff/974abbcf

Branch: refs/heads/master
Commit: 974abbcf783a8bd65da52480bbc5ec9d4df2e786
Parents: 1af1be7
Author: Denis Karyakin <sa...@gmail.com>
Authored: Mon Aug 10 21:39:28 2015 +0300
Committer: Denis Karyakin <sa...@gmail.com>
Committed: Mon Aug 10 21:39:28 2015 +0300

----------------------------------------------------------------------
 app/controllers/data_bundles_controller.rb | 8 ++++++++
 app/models/data_bundle.rb                  | 3 +++
 2 files changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/blob/974abbcf/app/controllers/data_bundles_controller.rb
----------------------------------------------------------------------
diff --git a/app/controllers/data_bundles_controller.rb b/app/controllers/data_bundles_controller.rb
index 8fca52b..f929c69 100644
--- a/app/controllers/data_bundles_controller.rb
+++ b/app/controllers/data_bundles_controller.rb
@@ -40,6 +40,14 @@ class DataBundlesController < ApplicationController
     @data_bundle = current_user.databundles.new(data_bundle_params)
 
     if @data_bundle.save
+      Archive::Zip.extract(
+          @data_bundle.file.path,
+          "#{@data_bundle.file.root}/#{@data_bundle.file.store_dir}/#{DataBundle::EXTRACTED_PATH}"
+      )
+      Archive::Zip.extract(
+          "#{@data_bundle.file.root}/#{@data_bundle.file.store_dir}/#{DataBundle::EXTRACTED_PATH}/workflow.wfbundle",
+          "#{@data_bundle.file.root}/#{@data_bundle.file.store_dir}/#{DataBundle::EXTRACTED_PATH}/#{DataBundle::EXTRACTED_WORKFLOW_PATH}",
+      )
       redirect_to @data_bundle, notice: 'Data bundle was successfully created.'
     else
       render :edit

http://git-wip-us.apache.org/repos/asf/incubator-taverna-databundle-viewer/blob/974abbcf/app/models/data_bundle.rb
----------------------------------------------------------------------
diff --git a/app/models/data_bundle.rb b/app/models/data_bundle.rb
index 37abbe6..7728a58 100644
--- a/app/models/data_bundle.rb
+++ b/app/models/data_bundle.rb
@@ -23,4 +23,7 @@ class DataBundle < ActiveRecord::Base
   belongs_to :user
 
   validates :user_id, presence: true
+
+  EXTRACTED_PATH = 'extracted_source'
+  EXTRACTED_WORKFLOW_PATH = 'workflow_source'
 end