lib/gooddata/models/process.rb in gooddata-0.6.6 vs lib/gooddata/models/process.rb in gooddata-0.6.7

- old
+ new

@@ -4,10 +4,14 @@ module GoodData class Process attr_reader :data + alias_method :raw_data, :data + alias_method :json, :data + alias_method :to_hash, :data + class << self def [](id, options = {}) if id == :all uri = "/gdc/projects/#{GoodData.project.pid}/dataload/processes" data = GoodData.get(uri) @@ -25,11 +29,11 @@ end # TODO: Check the params. def with_deploy(dir, options = {}, &block) # verbose = options[:verbose] || false - GoodData.with_project(options[:project_id]) do |project| + GoodData.with_project(options[:project_id] || options[:project]) do |project| params = options[:params].nil? ? [] : [options[:params]] if block begin res = GoodData::Process.deploy(dir, options.merge(:files_to_exclude => params)) block.call(res) @@ -69,11 +73,10 @@ # Deploy a new process or redeploy existing one. # # @param path [String] Path to ZIP archive or to a directory containing files that should be ZIPed # @option options [String] :files_to_exclude - # @option options [String] :process_id ('nobody') From address # @option options [String] :type ('GRAPH') Type of process - GRAPH or RUBY # @option options [String] :name Readable name of the process # @option options [String] :process_id ID of a process to be redeployed (do not set if you want to create a new process) # @option options [Boolean] :verbose (false) Switch on verbose mode for detailed logging def deploy(path, options = {}) @@ -162,34 +165,27 @@ def executables process['executables'] end def schedules - res = [] + GoodData::Schedule[:all].select { |schedule| schedule.process_id == obj_id } + end - scheds = GoodData::Schedule[:all] - scheds['schedules']['items'].each do |item| - if item['schedule']['params']['PROCESS_ID'] == obj_id - res << GoodData::Schedule.new(item) - end - end - - res + def create_schedule(cron, executable, options = {}) + GoodData::Schedule.create(process_id, cron, executable, options) end - alias_method :raw_data, :data - def execute(executable, options = {}) params = options[:params] || {} hidden_params = options[:hidden_params] || {} result = GoodData.post(executions_link, :execution => { :graph => executable.to_s, :params => params, :hiddenParams => hidden_params }) begin - GoodData.poll(result, 'executionTask') + GoodData.poll_on_code(result['executionTask']['links']['poll']) rescue RestClient::RequestFailed => e raise(e) ensure result = GoodData.get(result['executionTask']['links']['detail']) if result['executionDetail']['status'] == 'ERROR'