Changeset 151

Show
Ignore:
Timestamp:
19-09-11 12:59:23 (3 years ago)
Author:
kostas.karasavvas@…
Message:

Added workflow creator's (user) information to TavernaWorkflow? object

Location:
myexperiment-rest/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • myexperiment-rest/trunk/bin/get_workflow_data.rb

    r139 r151  
    2828end 
    2929 
     30puts wkf.user.name 
     31puts wkf.user.description 
     32puts wkf.user.email 
     33puts wkf.user.avatar 
     34puts wkf.user.website 
     35puts wkf.user.created_at 
     36 
  • myexperiment-rest/trunk/CHANGES

    r139 r151  
    11= Changes log for the MyExperiment via REST Gem 
     2 
     3== Version 0.2.8 
     4* Added user information for workflow 
    25 
    36== Version 0.2.7 
  • myexperiment-rest/trunk/lib/myexperiment-rest/myexperiment_rest.rb

    r139 r151  
    11require 'rubygems' 
    22require 'rest_client' 
     3require 'open-uri' 
    34require 'libxml' 
    45 
     
    3940      response = RestClient.get('http://www.myexperiment.org/workflow.xml', {:params => {'id' => "#{workflow_id}",  
    4041                                                                                         'version' => "#{workflow_version}", 
    41                                                                                          'elements' => 'title,description,content-uri,components'} } ) 
     42                                                                                         'elements' => 'title,description,content-uri,components,uploader'} } ) 
    4243 
    4344      populate_workflow(response) 
     
    4849 
    4950    # Acquire data from XML response and instantiate a _Taverna_Workflow_ object 
     51    #-- 
     52    # TODO: refactor so that each (logical) workflow element is an object with 
     53    # its own read from_xml method... 
    5054    def populate_workflow(response) 
    5155      doc = XML::Document.string(response) 
     
    5559      wkf_inputs = get_IOData(doc, "source") 
    5660      wkf_outputs = get_IOData(doc, "sink") 
     61      wkf_user = get_user(doc.find_first("/workflow/uploader").attributes['uri']) 
    5762 
    58       TavernaWorkflow.new(TavernaWorkflow::MY_EXPERIMENT, wkf_xml_uri, wkf_title, wkf_descr, wkf_inputs, wkf_outputs) 
     63      TavernaWorkflow.new(TavernaWorkflow::MY_EXPERIMENT, wkf_xml_uri, wkf_title, wkf_descr, wkf_inputs, wkf_outputs, wkf_user) 
    5964 
    6065    end 
     
    6267 
    6368    # 
    64     # Populate _Taverna_IOData_ objects for specified type: value +source+'+ is for inputs 
     69    # Populate _TavernaIOData_ objects for specified type: value +source+'+ is for inputs 
    6570    # and +sink+ for outputs 
    6671    # 
     
    95100 
    96101 
     102    # 
     103    # Populate _TavernaUser_ object for specified user resource 
     104    # 
     105    def get_user(user_uri) 
     106      doc = XML::Document.file(user_uri) 
     107      user = TavernaUser.new(doc.find_first("/user/name").content, 
     108                             doc.find_first("/user/description").content, 
     109                             doc.find_first("/user/email").content, 
     110                             doc.find_first("/user/avatar").attributes['uri'], 
     111                             doc.find_first("/user/website").content, 
     112                             doc.find_first("/user/created-at").content) 
     113      user 
     114    end 
     115 
     116 
     117 
    97118  end 
    98119 
    99120 
     121 
    100122  # 
    101   # Contains all available information about a workflow: _input_type_, _xml_uri_, _title_, _description_, 
    102   # _inputs_ and _outputs_. The _xml_uri_ specifies the XML description on myExperiment and 
    103   # not the XML of the workflow itself. _input_type_ specifies the kind of input. Currently, 
    104   # either "myexperiment" (myExperiment's xml uri) or "t2flow" (filename) 
     123  # Contains all available information about a workflow: _input_type_, _xml_uri_, 
     124  # _title_, _description_,_inputs_, _outputs_ and _user_. The _xml_uri_ specifies 
     125  # the XML description on myExperiment and not the XML of the workflow itself. 
     126  # _input_type_ specifies the kind of input. Currently, either "myexperiment" 
     127  # (myExperiment's xml uri) or "t2flow" (filename) 
    105128  # 
    106129  class TavernaWorkflow 
     
    110133    T2_FLOW = 't2flow' 
    111134 
    112     attr_reader(:input_type, :xml_uri, :title, :description, :inputs, :outputs) 
     135    attr_reader(:input_type, :xml_uri, :title, :description, :inputs, :outputs, :user) 
    113136 
    114     def initialize(input_type, xml_uri, title, description, inputs, outputs) 
     137    def initialize(input_type, xml_uri, title, description, inputs, outputs, user) 
    115138      @input_type = input_type 
    116139      @xml_uri = xml_uri 
     
    119142      @inputs = inputs 
    120143      @outputs = outputs 
     144      @user = user 
    121145    end 
    122146 
     
    143167 
    144168 
     169  # 
     170  # Contains all available information about an input or output: name, descriptions 
     171  # and examples. The last two are lists. 
     172  # 
     173  class TavernaUser 
     174    attr_reader(:name, :description, :email, :avatar, :website, :created_at) 
     175 
     176    def initialize(name, description, email, avatar, website, created_at) 
     177      @name = name 
     178      @description = description 
     179      @email = email 
     180      @avatar = avatar 
     181      @website = website 
     182      @created_at = created_at 
     183    end 
     184 
     185  end 
     186 
     187 
     188 
    145189end 
    146190 
  • myexperiment-rest/trunk/Rakefile

    r139 r151  
    1313spec = Gem::Specification.new do |s| 
    1414  s.name = 'myexperiment-rest' 
    15   s.version = '0.2.7' 
     15  s.version = '0.2.8' 
    1616  s.extra_rdoc_files = ['README', 'LICENSE', 'CHANGES'] 
    1717  s.summary = 'This is a simple library to access data on myExperiment via its REST API. Currently supports a subset of the workflow information available.' 
     
    2323  s.require_path = "lib" 
    2424  s.bindir = "bin" 
    25   s.add_dependency 'rest-client', '>= 1.6.3' 
    26   s.add_dependency 'libxml-ruby', '>= 2.0.5' 
     25  s.add_dependency 'rest-client', '~> 1.6.3' 
     26  s.add_dependency 'libxml-ruby', '~> 2.0.5' 
    2727end 
    2828 
  • myexperiment-rest/trunk/README

    r139 r151  
    22 
    33Authors::     Konstantinos Karasavvas 
    4 Gem Version:: 0.2.7 
     4Gem Version:: 0.2.8 
    55Contact::     mailto:kostas.karasavvas@nbic.nl 
    66Licence::     MIT (See LICENCE or http://www.opensource.org/licenses/mit-license)