Class: MyExperimentREST::Workflow

Inherits:
Object
  • Object
show all
Defined in:
lib/myexperiment-rest/workflow.rb

Overview

Connects to myExperiment REST API and creates a MyExperimentWorkflow object.

Class Method Summary collapse

Class Method Details

.from_id_and_version(id, version = '', session_cookie = {}) ⇒ Object

Returns a MyExperimentWorkflow object given a myExperiment id and version for that workflow.



38
39
40
41
42
43
44
# File 'lib/myexperiment-rest/workflow.rb', line 38

def self.from_id_and_version(id, version='', session_cookie={})

  # Get workflow resource information
  xml = MyExperimentREST.get_myexperiment_data(Urls::WORKFLOW_URL, :id => id, :version => version, :session_cookie => session_cookie)

  MyExperimentWorkflow.parse(xml)
end

.from_uri(uri, session_cookie = {}) ⇒ Object

Returns a MyExperimentWorkflow object given a URI of the workflow in the repository as a String.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/myexperiment-rest/workflow.rb', line 11

def self.from_uri(uri, session_cookie={})

  workflow_id = ''
  workflow_version = ''

  # Get workflow id - will match both workflow/74 and workflows.xml?id=74
  uri_id = uri.match(/workflow.*[\/?](id=)?(\d+)/)
  if uri_id != nil
    workflow_id = uri_id[2]
  else
    raise "Could not match workflow id."
  end

  # Get workflow version if it exists
  uri_version = uri.match(/version=(\d+)/)
  if uri_version != nil
    workflow_version = uri_version[1]
  end

  # Get workflow resource information 
  xml = MyExperimentREST.get_myexperiment_data(Urls::WORKFLOW_URL, :id => workflow_id, :version => workflow_version, :session_cookie => session_cookie)
  
  MyExperimentWorkflow.parse(xml)
end