Class: MyExperimentREST::MyExperimentWorkflow

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

Overview

Contains all available information about a workflow: content_uri, title, description,inputs, outputs and uploader_uri.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ MyExperimentWorkflow

Returns a new instance of MyExperimentWorkflow.



59
60
61
62
63
64
65
66
# File 'lib/myexperiment-rest/workflow.rb', line 59

def initialize(attributes)
  @content_uri = attributes[:content_uri]
  @title = attributes[:title]
  @description = attributes[:description]
  @inputs = attributes[:inputs]
  @outputs = attributes[:outputs]
  @uploader_uri = attributes[:uploader_uri]
end

Instance Attribute Details

#content_uriObject (readonly)

Returns the value of attribute content_uri.



57
58
59
# File 'lib/myexperiment-rest/workflow.rb', line 57

def content_uri
  @content_uri
end

#descriptionObject (readonly)

Returns the value of attribute description.



57
58
59
# File 'lib/myexperiment-rest/workflow.rb', line 57

def description
  @description
end

#inputsObject (readonly)

Returns the value of attribute inputs.



57
58
59
# File 'lib/myexperiment-rest/workflow.rb', line 57

def inputs
  @inputs
end

#outputsObject (readonly)

Returns the value of attribute outputs.



57
58
59
# File 'lib/myexperiment-rest/workflow.rb', line 57

def outputs
  @outputs
end

#titleObject (readonly)

Returns the value of attribute title.



57
58
59
# File 'lib/myexperiment-rest/workflow.rb', line 57

def title
  @title
end

#uploader_uriObject (readonly)

Returns the value of attribute uploader_uri.



57
58
59
# File 'lib/myexperiment-rest/workflow.rb', line 57

def uploader_uri
  @uploader_uri
end

Class Method Details

.parse(xml) ⇒ Object

Parse workflow information XML and instantiate a MyExperimentWorkflow object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/myexperiment-rest/workflow.rb', line 69

def self.parse(xml)

  wkf_inputs = []
  wkf_outputs = []

  doc = LibXML::XML::Document.string(xml)

  doc.find("//workflow/components/dataflows/dataflow[@role='top']/sources/source").each do |element|
    wkf_inputs << MyExperimentIOData.from_xml(element)
  end

  doc.find("//workflow/components/dataflows/dataflow[@role='top']/sinks/sink").each do |element|
    wkf_outputs << MyExperimentIOData.from_xml(element)
  end


  new(:content_uri => doc.find_first("/workflow/content-uri").content,
      :title => doc.find_first("/workflow/title").content,
      :description => doc.find_first("/workflow/description").content,
      :inputs => wkf_inputs,
      :outputs => wkf_outputs,
      :uploader_uri => doc.find_first("/workflow/uploader").attributes['uri'])

end