Diff
Modified: svn:ignore
+ index
.project
Modified: trunk/Rakefile (2657 => 2658)
--- trunk/Rakefile 2011-07-30 13:56:59 UTC (rev 2657)
+++ trunk/Rakefile 2011-08-01 15:57:13 UTC (rev 2658)
@@ -17,6 +17,7 @@
User.rebuild_solr_index
Network.rebuild_solr_index
Pack.rebuild_solr_index
+ Service.rebuild_solr_index
end
desc 'Refresh contribution caches'
@@ -97,3 +98,14 @@
end
end
+desc 'Import data from BioCatalogue'
+task "myexp:import:biocat" do
+ require File.dirname(__FILE__) + '/config/environment'
+
+ Contribution.delete_all("contributable_type = 'Service'")
+
+ conn = ActiveRecord::Base.connection
+
+ BioCatalogueImport.import_biocatalogue
+end
+
Modified: trunk/app/controllers/application.rb (2657 => 2658)
--- trunk/app/controllers/application.rb 2011-07-30 13:56:59 UTC (rev 2657)
+++ trunk/app/controllers/application.rb 2011-08-01 15:57:13 UTC (rev 2658)
@@ -975,7 +975,7 @@
if params["query"]
drop_search_results_table
- create_search_results_table(params["query"], [Workflow, Blob, Pack, User, Network])
+ create_search_results_table(params["query"], [Workflow, Blob, Pack, User, Network, Service])
joins.push(:search) unless opts[:arbitrary_models]
end
Copied: trunk/app/controllers/services_controller.rb (from rev 2657, branches/biocat/app/controllers/services_controller.rb) (0 => 2658)
--- trunk/app/controllers/services_controller.rb (rev 0)
+++ trunk/app/controllers/services_controller.rb 2011-08-01 15:57:13 UTC (rev 2658)
@@ -0,0 +1,100 @@
+# myExperiment: app/controllers/services_controller.rb
+#
+# Copyright (c) 2010 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class ServicesController < ApplicationController
+
+ include ApplicationHelper
+
+# before_filter :find_service, : [:show]
+ before_filter :find_services, : [:all]
+
+ # GET /algorithms;search
+ def search
+# @query = params[:query] || ''
+# @query.strip!
+#
+# @contributables = (Conf.solr_enable && address@hidden) ? Algorithm.find_by_solr(@query, :limit => 100).results : []
+# @total_count = (Conf.solr_enable && address@hidden) ? Algorithm.count_by_solr(@query) : 0
+#
+# respond_to do |format|
+# format.html # search.rhtml
+# end
+ end
+
+ # GET /services
+ def index
+ respond_to do |format|
+ format.html {
+ @pivot_options = pivot_options
+
+ begin
+ expr = parse_filter_expression(params["filter"]) if params["filter"]
+ rescue Exception => ex
+ puts "ex = #{ex.inspect}"
+ flash.now[:error] = "Problem with query _expression_: #{ex}"
+ expr = nil
+ end
+
+ @pivot = contributions_list(Contribution, params, current_user,
+ :lock_filter => { 'CATEGORY' => 'Service' },
+ :filters => expr)
+
+ # index.rhtml
+ }
+ end
+ end
+
+ # GET /services/all
+ def all
+ respond_to do |format|
+ format.html # all.rhtml
+ end
+ end
+
+ # GET /service/1
+ def show
+ raise ActionController::UnknownAction.new
+ end
+
+ protected
+
+ def find_services
+ @contributables = Service.find(:all,
+ :order => "created_at DESC",
+ :page => { :size => 20,
+ :current => params[:page] })
+ end
+
+ def find_service
+# begin
+# service = Service.find(params[:id])
+#
+# @contributable = service
+#
+# @contributable_entry_url = url_for : false,
+# :host => base_host,
+# :id => @contributable.id
+#
+# @contributable_label = @contributable.name
+# @contributable_path = service_path(@contributable)
+#
+# rescue ActiveRecord::RecordNotFound
+# error("Service not found", "is invalid")
+# return false
+# end
+ end
+
+ private
+
+ def error(notice, message, attr=:id)
+ flash[:error] = notice
+ (err = Service.new.errors).add(attr, message)
+
+ respond_to do |format|
+ format.html { redirect_to services_url }
+ end
+ end
+end
+
Modified: trunk/app/helpers/application_helper.rb (2657 => 2658)
--- trunk/app/helpers/application_helper.rb 2011-07-30 13:56:59 UTC (rev 2657)
+++ trunk/app/helpers/application_helper.rb 2011-08-01 15:57:13 UTC (rev 2658)
@@ -349,6 +349,8 @@
return nil unless network
return title(network)
+ elsif contributortype.to_s == "FederationSource"
+ link_to "The BioCatalogue", "http://www.biocatalogue.org"
else
return nil
end
@@ -365,6 +367,8 @@
return nil unless network
return h(network.title)
+ elsif contributortype.to_s == "FederationSource"
+ "The BioCatalogue"
else
return nil
end
@@ -424,6 +428,13 @@
else
return nil
end
+ when "Service"
+ if s = Service.find(:first, :conditions => ["id = ?", contributableid])
+ name = h(s.name)
+ return link ? link_to(name, service_url(s)) : name
+ else
+ return nil
+ end
end
end
@@ -774,6 +785,8 @@
return "famfamfam_silk/award_star_add.png"
when "remove_group_admin"
return "famfamfam_silk/award_star_delete.png"
+ when "service"
+ return "biocat_icon.png"
else
return Conf.label_icons[method.to_s] if Conf.label_icons[method.to_s]
end
Copied: trunk/app/models/federation_source.rb (from rev 2657, branches/biocat/app/models/federation_source.rb) (0 => 2658)
--- trunk/app/models/federation_source.rb (rev 0)
+++ trunk/app/models/federation_source.rb 2011-08-01 15:57:13 UTC (rev 2658)
@@ -0,0 +1,14 @@
+# myExperiment: app/models/federation_source.rb
+#
+# Copyright (c) 2007 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+require 'lib/acts_as_site_entity'
+require 'lib/acts_as_contributor'
+
+class FederationSource < ActiveRecord::Base
+ acts_as_site_entity
+ acts_as_contributor
+ acts_as_structured_data
+end
+
Copied: trunk/app/models/service.rb (from rev 2657, branches/biocat/app/models/service.rb) (0 => 2658)
--- trunk/app/models/service.rb (rev 0)
+++ trunk/app/models/service.rb 2011-08-01 15:57:13 UTC (rev 2658)
@@ -0,0 +1,22 @@
+# myExperiment: app/models/service.rb
+#
+# Copyright (c) 2007 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+require 'lib/acts_as_site_entity'
+require 'lib/acts_as_contributable'
+
+class Service < ActiveRecord::Base
+ acts_as_site_entity
+ acts_as_contributable
+ acts_as_structured_data
+
+ acts_as_solr(:fields => [ :submitter_label, :name, :provider_label, :endpoint,
+ :wsdl, :city, :country, :description, :extra_search_terms ]) if Conf.solr_enable
+
+ def extra_search_terms
+ service_categories.map do |category| category.label end +
+ service_tags.map do |tag| tag.label end +
+ service_types.map do |types| types.label end
+ end
+end
Modified: trunk/app/views/content/_index.rhtml (2657 => 2658)
--- trunk/app/views/content/_index.rhtml 2011-07-30 13:56:59 UTC (rev 2657)
+++ trunk/app/views/content/_index.rhtml 2011-08-01 15:57:13 UTC (rev 2658)
@@ -1,48 +1,52 @@
<div class="pivot">
<div class="left">
- <div class="category">Search filter terms</div>
- <div class="search_filters">
- <form action="" url_for(request.query_parameters) -%>" method="GET">
- <div class="filter_search_box">
- <input class="query" name="filter_query" value="<%= params[:filter_query] -%>" />
- <% @pivot[:filter_query_url].each do |key, value| %>
- <input name="<%= key -%>" type="hidden" value="<%= value.gsub('"', '"') -%>" />
- <% end %>
+ <% if @pivot[:filters].length > 0 %>
+ <div class="category">Search filter terms</div>
+ <div class="search_filters">
+ <form action="" url_for(request.query_parameters) -%>" method="GET">
+ <div class="filter_search_box">
+ <input class="query" name="filter_query" value="<%= params[:filter_query] -%>" />
+ <% @pivot[:filter_query_url].each do |key, value| %>
+ <input name="<%= key -%>" type="hidden" value="<%= value.gsub('"', '"') -%>" />
+ <% end %>
+ <% if @pivot[:cancel_filter_query_url] %>
+ <%= link_to('<img src="" />',
+ @pivot[:cancel_filter_query_url]) -%>
+ <% else %>
+ <input class="submit" type="image" src="" name="submit" />
+ <% end %>
+ </div>
+ </form>
+ </div>
+ <div class="filters">
+ <% @pivot[:filters].each do |filter| %>
+ <% query_name = "#{filter[:query_option]}_query" %>
<% if @pivot[:cancel_filter_query_url] %>
- <%= link_to('<img src="" />',
- @pivot[:cancel_filter_query_url]) -%>
+ <div class="category"><%= filter[:title].capitalize -%> results</div>
<% else %>
- <input class="submit" type="image" src="" name="submit" />
+ <div class="category">Filter by <%= filter[:title] -%></div>
<% end %>
- </div>
- </form>
- </div>
- <div class="filters">
- <% @pivot[:filters].each do |filter| %>
- <% query_name = "#{filter[:query_option]}_query" %>
- <% if @pivot[:cancel_filter_query_url] %>
- <div class="category"><%= filter[:title].capitalize -%> results</div>
- <% else %>
- <div class="category">Filter by <%= filter[:title] -%></div>
+ <div id="<%= query_name -%>" style="display: <%= @pivot[:cancel_filter_query_url] ? "block" : "none" -%>">
+ </div>
+ <div class="filter">
+ <div class="options">
+ <% filter[:objects].each do |object| %>
+ <div title='<%= h(object[:plain_label]) -%>'<%= object[:selected] ? ' class="selected"' : '' -%>>
+ <input class='checkbox' type='checkbox' <% if object[:selected] %> checked='checked' <% end %> />
+ <%= link_to("<div class='count'>#{object[:count]}</div> <div class='label'><span class='truncate'>#{object[:label]}</span></div>", object[:label_uri]) -%>
+ </div>
+ <% end %>
+ </div>
+ </div>
<% end %>
- <div id="<%= query_name -%>" style="display: <%= @pivot[:cancel_filter_query_url] ? "block" : "none" -%>">
+ </div>
+ <% if @pivot[:cancel_filter_query_url] && @pivot[:filters].empty? %>
+ <div class="no-filter-query-results">
+ Your search did not match any filter terms.
</div>
- <div class="filter">
- <div class="options">
- <% filter[:objects].each do |object| %>
- <div title='<%= h(object[:plain_label]) -%>'<%= object[:selected] ? ' class="selected"' : '' -%>>
- <input class='checkbox' type='checkbox' <% if object[:selected] %> checked='checked' <% end %> />
- <%= link_to("<div class='count'>#{object[:count]}</div> <div class='label'><span class='truncate'>#{object[:label]}</span></div>", object[:label_uri]) -%>
- </div>
- <% end %>
- </div>
- </div>
<% end %>
- </div>
- <% if @pivot[:cancel_filter_query_url] && @pivot[:filters].empty? %>
- <div class="no-filter-query-results">
- Your search did not match any filter terms.
- </div>
+ <% else %>
+ <div class="category">No search filters available.</div>
<% end %>
</div>
<div class="main">
Modified: trunk/app/views/contributions/_list.rhtml (2657 => 2658)
--- trunk/app/views/contributions/_list.rhtml 2011-07-30 13:56:59 UTC (rev 2657)
+++ trunk/app/views/contributions/_list.rhtml 2011-08-01 15:57:13 UTC (rev 2658)
@@ -10,9 +10,9 @@
<% end %>
<% if table %>
- <%= render :partial => "#{klass.pluralize.downcase}/table", :locals => { :collection => contributables } %>
+ <%= render :partial => "#{klass.pluralize.underscore}/table", :locals => { :collection => contributables } %>
<% else %>
- <%= render :partial => "#{klass.pluralize.downcase}/#{klass.downcase}", :collection => contributables, :spacer_template => "contributions/list_spacer" %>
+ <%= render :partial => "#{klass.pluralize.underscore}/#{klass.downcase}", :collection => contributables, :spacer_template => "contributions/list_spacer" %>
<% end %>
-<% end %>
\ No newline at end of file
+<% end %>
Modified: trunk/app/views/workflows/show.rhtml (2657 => 2658)
--- trunk/app/views/workflows/show.rhtml 2011-07-30 13:56:59 UTC (rev 2657)
+++ trunk/app/views/workflows/show.rhtml 2011-08-01 15:57:13 UTC (rev 2658)
@@ -331,6 +331,20 @@
<div class="clearer"> </div>
+<!-- Other workflows that use a service this workflow users -->
+
+<h2>Other workflows that use services that this workflow uses</h2>
+
+<% if @contributions_with_similar_services.length > @similar_services_limit %>
+ <p><i>Only the first <%= @similar_services_limit %> workflows that use similar services are shown.</i></p>
+<% end %>
+
+<% if @contributions_with_similar_services.length > 0 %>
+ <%= render :partial => "contributions/list", :locals => { :collection => @address@hidden - 1], :table => true } %>
+<% else %>
+ <p>There are no workflows in <%= Conf.sitename %> that use similar services to this Workflow.</p>
+<% end %>
+
<!-- BEGIN tabs -->
<br/>
Modified: trunk/app/views/workflows/taverna2/_internals.rhtml (2657 => 2658)
--- trunk/app/views/workflows/taverna2/_internals.rhtml 2011-07-30 13:56:59 UTC (rev 2657)
+++ trunk/app/views/workflows/taverna2/_internals.rhtml 2011-08-01 15:57:13 UTC (rev 2658)
@@ -120,7 +120,14 @@
<tr>
<td><b><%= h p.name -%></b></td>
<td><%= h p.type -%></td>
- <td><%= h p.description -%></td>
+ <td><%= h p.description -%>
+ <% if p.wsdl %>
+ <% if service = Service.find_by_wsdl(p.wsdl) %>
+ <br /><p>See the <%= link_to('Service entry', service.uri) %>
+ for this web service.</p>
+ <% end %>
+ <% end %>
+ </td>
</tr>
<% end %>
</table>
Modified: trunk/app/views/workflows/taverna_scufl/_internals.rhtml (2657 => 2658)
--- trunk/app/views/workflows/taverna_scufl/_internals.rhtml 2011-07-30 13:56:59 UTC (rev 2657)
+++ trunk/app/views/workflows/taverna_scufl/_internals.rhtml 2011-08-01 15:57:13 UTC (rev 2658)
@@ -48,7 +48,14 @@
<tr>
<td><b><%= h p.name -%></b></td>
<td><%= h p.type -%></td>
- <td><%= h p.description -%></td>
+ <td><%= h p.description -%>
+ <% if p.wsdl %>
+ <% if service = Service.find_by_wsdl(p.wsdl) %>
+ <br /><p>See the <%= link_to('Service entry', service.uri) %>
+ for this web service.</p>
+ <% end %>
+ <% end %>
+ </td>
</tr>
<% end %>
</table>
Property changes: trunk/config
Added: svn:ignore
settings.yml
captcha.yml
Modified: trunk/config/default_settings.yml (2657 => 2658)
--- trunk/config/default_settings.yml 2011-07-30 13:56:59 UTC (rev 2657)
+++ trunk/config/default_settings.yml 2011-08-01 15:57:13 UTC (rev 2658)
@@ -231,7 +231,7 @@
# search_categories - These are the search categories shown in the search bar
# just under the main tabs.
-search_categories: [all, users, groups, workflows, files, packs]
+search_categories: [all, users, groups, workflows, services, files, packs]
# default_search_size - The default number of items shown in each search result
# page.
Modified: trunk/config/routes.rb (2657 => 2658)
--- trunk/config/routes.rb 2011-07-30 13:56:59 UTC (rev 2657)
+++ trunk/config/routes.rb 2011-08-01 15:57:13 UTC (rev 2658)
@@ -169,6 +169,9 @@
# blogs have nested posts
blog.resources :blog_posts
end
+
+ # services
+ map.resources :services, :collection => { :search => :get }
# content_types
map.resources :content_types
Copied: trunk/config/schema.d/federation.xml (from rev 2657, branches/biocat/config/schema.d/federation.xml) (0 => 2658)
--- trunk/config/schema.d/federation.xml (rev 0)
+++ trunk/config/schema.d/federation.xml 2011-08-01 15:57:13 UTC (rev 2658)
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<schema>
+
+ <table name="federation_sources">
+
+ <column type="string" name="name"/>
+
+ </table>
+
+</schema>
+
Copied: trunk/config/schema.d/services.xml (from rev 2657, branches/biocat/config/schema.d/services.xml) (0 => 2658)
--- trunk/config/schema.d/services.xml (rev 0)
+++ trunk/config/schema.d/services.xml 2011-08-01 15:57:13 UTC (rev 2658)
@@ -0,0 +1,146 @@
+<?xml version="1.0"?>
+<schema>
+
+ <!-- BioCatalogue services -->
+
+ <table name="services">
+
+ <column type="integer" name="contributor_id"/>
+ <column type="string" name="contributor_type"/>
+
+ <column type="datetime" name="created_at"/>
+ <column type="datetime" name="updated_at"/>
+ <column type="datetime" name="retrieved_at"/>
+
+ <!-- from the service index listing -->
+
+ <column type="string" name="uri"/>
+ <column type="string" name="submitter_label"/>
+ <column type="datetime" name="created"/>
+ <column type="string" name="submitter_uri"/>
+
+ <!-- service summary -->
+
+ <column type="string" name="name"/>
+ <column type="string" name="provider_uri"/>
+ <column type="string" name="provider_label"/>
+ <column type="string" name="endpoint"/>
+ <column type="string" name="wsdl"/>
+ <column type="string" name="city"/>
+ <column type="string" name="country"/>
+ <column type="string" name="iso3166_country_code"/>
+ <column type="string" name="flag_url"/>
+ <column type="string" name="documentation_uri"/>
+ <column type="text" name="description"/>
+
+ <!-- service monitoring -->
+
+ <column type="string" name="monitor_label"/>
+ <column type="text" name="monitor_message"/>
+ <column type="string" name="monitor_symbol_url"/>
+ <column type="string" name="monitor_small_symbol_url"/>
+ <column type="datetime" name="monitor_last_checked"/>
+
+ <has-many target="service_categories"/>
+ <has-many target="service_types"/>
+ <has-many target="service_tags"/>
+ <has-many target="service_deployments"/>
+
+ </table>
+
+ <!-- BioCatalogue service categories -->
+
+ <table name="service_categories">
+
+ <column type="datetime" name="created_at"/>
+ <column type="datetime" name="updated_at"/>
+ <column type="datetime" name="retrieved_at"/>
+
+ <column type="integer" name="service_id"/>
+ <column type="string" name="uri"/>
+ <column type="string" name="label"/>
+
+ <belongs-to target="service"/>
+
+ </table>
+
+ <!-- BioCatalogue service types -->
+
+ <table name="service_types">
+
+ <column type="datetime" name="created_at"/>
+ <column type="datetime" name="updated_at"/>
+ <column type="datetime" name="retrieved_at"/>
+
+ <column type="integer" name="service_id"/>
+ <column type="string" name="label"/>
+
+ <belongs-to target="service"/>
+
+ </table>
+
+ <!-- BioCatalogue service tags -->
+
+ <table name="service_tags">
+
+ <column type="datetime" name="created_at"/>
+ <column type="datetime" name="updated_at"/>
+ <column type="datetime" name="retrieved_at"/>
+
+ <column type="integer" name="service_id"/>
+ <column type="string" name="uri"/>
+ <column type="string" name="label"/>
+
+ <belongs-to target="service"/>
+
+ </table>
+
+ <!-- BioCatalogue service deployments -->
+
+ <table name="service_deployments">
+
+ <column type="datetime" name="created_at"/>
+ <column type="datetime" name="updated_at"/>
+ <column type="datetime" name="retrieved_at"/>
+
+ <column type="string" name="uri"/>
+ <column type="string" name="endpoint"/>
+
+ <column type="string" name="city"/>
+ <column type="string" name="country"/>
+ <column type="string" name="iso3166_country_code"/>
+ <column type="string" name="flag_url"/>
+
+ <column type="string" name="submitter_label"/>
+ <column type="string" name="submitter_uri"/>
+
+ <column type="datetime" name="created"/>
+
+ <column type="integer" name="service_id"/>
+ <column type="integer" name="service_provider_id"/>
+
+ <belongs-to target="service_provider"/>
+ <belongs-to target="service"/>
+
+ </table>
+
+ <!-- BioCatalogue service providers -->
+
+ <table name="service_providers">
+
+ <column type="datetime" name="created_at"/>
+ <column type="datetime" name="updated_at"/>
+ <column type="datetime" name="retrieved_at"/>
+
+ <column type="string" name="uri"/>
+ <column type="string" name="name"/>
+ <column type="text" name="description"/>
+
+ <column type="datetime" name="created"/>
+
+ <has-many target="service_deployments" foreign_key="service_provider_id"/>
+
+ </table>
+
+</schema>
+
Copied: trunk/lib/bio_catalogue_import.rb (from rev 2657, branches/biocat/lib/bio_catalogue_import.rb) (0 => 2658)
--- trunk/lib/bio_catalogue_import.rb (rev 0)
+++ trunk/lib/bio_catalogue_import.rb 2011-08-01 15:57:13 UTC (rev 2658)
@@ -0,0 +1,328 @@
+# myExperiment: lib/biocatalog_import.rb
+#
+# Copyright (c) 2010 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class BioCatalogueImport
+
+ require 'xml/libxml'
+ require 'open-uri'
+
+ @@biocat_base_uri = 'http://www.biocatalogue.org/'
+ @@biocat_ns = { "bc" => "http://www.biocatalogue.org/2009/xml/rest" }
+ @@biocat_wait_in_seconds = 10
+
+ def self.fetch_uri(uri)
+
+ if @documents.nil?
+ if File.exists?(@@biocat_document_cache)
+ @documents = YAML::load_file(@@biocat_document_cache)
+ else
+ @documents = { :retrieved_at => { } }
+ end
+ end
+
+ return @documents[uri] if @documents[uri]
+
+ rest_uri = URI.parse(uri)
+ rest_uri.path = rest_uri.path + ".xml"
+
+ puts "Fetching URI: #{rest_uri}"
+
+ @documents[uri] = open(rest_uri.to_s).read.to_s
+ @documents[:retrieved_at][uri] = Time.now
+
+ Kernel.sleep(@@biocat_wait_in_seconds)
+
+ @documents[uri]
+ end
+
+ def self.uri_retrieved_at(uri)
+ @documents[:retrieved_at][uri]
+ end
+
+ def self.save_document_cache
+ file = File.open(@@biocat_document_cache, "w+") do |file|
+ file.rewind
+ file.puts(@documents.to_yaml)
+ end
+ end
+
+ def self.get_text(element, query)
+ response = element.find(query, @@biocat_ns)
+ response[0].to_s unless response.length.zero?
+ end
+
+ def self.get_attr(element, query)
+ response = element.find(query, @@biocat_ns)
+ response[0].value unless response.length.zero?
+ end
+
+ def self.get_link(element, query)
+ response = element.find(query, @@biocat_ns)
+ (URI.parse(@@biocat_base_uri) + response[0].value).to_s unless response.length.zero?
+ end
+
+ def self.import_service(service_element, index_uri)
+
+ summary_element = service_element.find('bc:summary', @@biocat_ns)[0]
+
+ # Service
+
+ service_uri = get_link(service_element, '@xlink:href')
+
+#return service_uri unless service_uri.ends_with?("/2")
+ service = Service.find_by_uri(service_uri)
+
+ service = Service.new if service.nil?
+
+ service.attributes = {
+
+ :contributor => @federation_source,
+
+ :uri => service_uri,
+ :name => get_text(service_element, 'bc:name/text()'),
+ :submitter_label => get_attr(service_element, 'bc:originalSubmitter/@resourceName'),
+ :created => get_text(service_element, 'dcterms:created/text()'),
+ :submitter_uri => get_attr(service_element, 'bc:originalSubmitter/@xlink:href'),
+
+ :provider_uri => get_link(summary_element, 'bc:provider/@xlink:href'),
+ :provider_label => get_text(summary_element, 'bc:provider/bc:name/text()'),
+ :endpoint => get_text(summary_element, 'bc:endpoint/text()'),
+ :wsdl => get_text(summary_element, 'bc:wsdl/text()'),
+ :city => get_text(summary_element, 'bc:location/bc:city/text()'),
+ :country => get_text(summary_element, 'bc:location/bc:country/text()'),
+ :iso3166_country_code => get_text(summary_element, 'bc:location/bc:iso3166CountryCode/text()'),
+ :flag_url => get_link(summary_element, 'bc:location/bc:flag/@xlink:href'),
+ :documentation_uri => get_text(summary_element, 'bc:documentationUrl/text()'),
+ :description => get_text(summary_element, 'dc:description/text()'),
+
+ :monitor_label => get_text(service_element, 'bc:latestMonitoringStatus/bc:label/text()'),
+ :monitor_message => get_text(service_element, 'bc:latestMonitoringStatus/bc:message/text()'),
+ :monitor_symbol_url => get_link(service_element, 'bc:latestMonitoringStatus/bc:symbol/@xlink:href'),
+ :monitor_small_symbol_url => get_link(service_element, 'bc:latestMonitoringStatus/bc:smallSymbol/@xlink:href'),
+ :monitor_last_checked => get_text(service_element, 'bc:latestMonitoringStatus/bc:lastChecked/text()')
+ }
+
+ service.save if service.changed?
+
+ if service.contribution.nil?
+ service.contribution = Contribution.create(:contributor => @federation_source)
+ service.contribution.policy = create_default_policy(@federation_source)
+ service.contribution.policy.share_mode = 0 # Make public
+ service.contribution.policy.save
+ service.contribution.save
+ end
+
+ # Service categories
+
+ existing_service_categories = ServiceCategory.find_all_by_service_id(service.id)
+
+ current_service_category_uris = []
+
+ summary_element.find('bc:category', @@biocat_ns).each do |category_element|
+
+ service_category_uri = get_link(category_element, '@xlink:href')
+
+ service_category = ServiceCategory.find_by_service_id_and_uri(service.id, service_category_uri)
+
+ service_category = ServiceCategory.new if service_category.nil?
+
+ service_category.attributes = {
+ :service => service,
+ :retrieved_at => uri_retrieved_at(index_uri),
+ :uri => service_category_uri,
+ :label => get_text(category_element, 'text()')
+ }
+
+ service_category.save if service_category.changed?
+
+ current_service_category_uris << service_category_uri
+ end
+
+ existing_service_categories.each do |service_category|
+ next if current_service_category_uris.include?(service_category.uri)
+ service_category.destroy
+ end
+
+ # Service technology types
+
+ existing_service_types = ServiceType.find_all_by_service_id(service.id)
+
+ current_types = []
+
+ service_element.find('bc:serviceTechnologyTypes/bc:type', @@biocat_ns).each do |type_element|
+
+ type_text = get_text(type_element, 'text()')
+
+ service_type = ServiceType.find_by_service_id_and_label(service.id, type_text)
+
+ service_type = ServiceType.new if service_type.nil?
+
+ service_type.attributes = {
+ :service => service,
+ :retrieved_at => uri_retrieved_at(index_uri),
+ :label => type_text
+ }
+
+ service_type.save if service_type.changed?
+
+ current_types << type_text
+ end
+
+ existing_service_types.each do |service_type|
+ next if current_types.include?(service_type.label)
+ service_type.destroy
+ end
+
+ # Service tags
+
+ existing_service_tags = ServiceTag.find_all_by_service_id(service.id)
+
+ current_service_tag_uris = []
+
+ summary_element.find('bc:tag', @@biocat_ns).each do |tag_element|
+
+ service_tag_uri = get_link(tag_element, '@xlink:href')
+ service_tag_label = get_text(tag_element, 'text()')
+
+ service_tag = ServiceTag.find_by_service_id_and_uri(service.id, service_tag_uri)
+
+ service_tag = ServiceTag.new if service_tag.nil?
+
+ service_tag.attributes = {
+ :service => service,
+ :retrieved_at => uri_retrieved_at(index_uri),
+ :uri => service_tag_uri,
+ :label => service_tag_label
+ }
+
+ service_tag.save if service_tag.changed?
+
+ current_service_tag_uris << service_tag_uri
+ end
+
+ existing_service_tags.each do |service_tag|
+ next if current_service_tag_uris.include?(service_tag.uri)
+ service_tag.destroy
+ end
+
+ # deployments and providers
+
+ existing_service_providers = ServiceProvider.find(:all)
+ existing_service_deployments = ServiceDeployment.find_all_by_service_id(service.id)
+
+ current_service_deployments = []
+
+ service_element.find('bc:deployments/bc:serviceDeployment', @@biocat_ns).each do |deployment_element|
+
+ # provider
+
+ provider_uri = get_link(deployment_element, 'bc:serviceProvider/@xlink:href')
+ deployment_uri = get_link(deployment_element, '@xlink:href')
+
+
+ service_provider = ServiceProvider.find_by_uri(provider_uri)
+
+ service_provider = ServiceProvider.new if service_provider.nil?
+
+ service_provider.attributes = {
+ :uri => provider_uri,
+ :retrieved_at => uri_retrieved_at(index_uri),
+ :name => get_text(deployment_element, 'bc:serviceProvider/bc:name/text()'),
+ :description => get_text(deployment_element, 'bc:serviceProvider/dc:description/text()'),
+ :created => get_text(deployment_element, 'bc:serviceProvider/dcterms:created/text()')
+ }
+
+ service_provider.save if service_provider.changed?
+
+ # deployment
+
+ service_deployment = ServiceDeployment.find_by_service_id_and_uri(service.id, deployment_uri)
+
+ service_deployment = ServiceDeployment.new if service_deployment.nil?
+
+ service_deployment.attributes = {
+ :service => service,
+ :service_provider => service_provider,
+ :retrieved_at => uri_retrieved_at(index_uri),
+ :uri => get_link(deployment_element, '@xlink:href'),
+ :endpoint => get_text(deployment_element, 'bc:endpoint/text()'),
+ :city => get_text(deployment_element, 'bc:location/bc:city/text()'),
+ :country => get_text(deployment_element, 'bc:location/bc:country/text()'),
+ :iso3166_country_code => get_text(deployment_element, 'bc:location/bc:iso3166CountryCode/text()'),
+ :flag_url => get_link(deployment_element, 'bc:location/bc:flag/@xlink:href'),
+ :submitter_label => get_attr(deployment_element, 'bc:submitter/@resourceName'),
+ :submitter_uri => get_attr(deployment_element, 'bc:submitter/@xlink:href'),
+ :created => get_text(deployment_element, 'dcterms:created/text()')
+ }
+
+ service_deployment.save if service_deployment.changed?
+
+ current_service_deployments << deployment_uri
+ end
+
+ existing_service_deployments.each do |service_deployment|
+ next if current_service_deployments.include?(service_deployment.uri)
+ service_deployment.destroy
+ end
+
+ # update the retrieved_at attribute
+
+ ActiveRecord::Base.record_timestamps = false
+ service.update_attribute(:retrieved_at, uri_retrieved_at(index_uri))
+ ActiveRecord::Base.record_timestamps = true
+
+ service_uri
+ end
+
+ def self.import_biocatalogue_services(uri)
+
+ current_service_uris = []
+
+ while true
+ doc = LibXML::XML::Parser.string(fetch_uri(uri)).parse.root
+
+ doc.find("/bc:services/bc:results/bc:service", @@biocat_ns).each do |service_element|
+ current_service_uris << import_service(service_element, uri)
+ end
+
+ next_doc = doc.find("/bc:services/bc:related/bc:next/@xlink:href", @@biocat_ns)
+
+ break if next_doc.length.zero?
+
+ uri = next_doc[0].value
+ end
+
+ Service.find(:all).each do |service|
+
+ next if current_service_uris.include?(service.uri)
+
+ service.destroy
+ end
+
+ # destroy unused service providers
+
+ current_service_providers = ServiceDeployment.find(:all).map do |sd| sd.service_provider end.uniq
+
+ (ServiceProvider.find(:all) - current_service_providers).each do |service_provider|
+ service_provider.destroy
+ end
+
+ save_document_cache
+ end
+
+ def self.import_biocatalogue
+
+ if FederationSource.find_by_name("BioCatalogue").nil?
+ FederationSource.create(:name => "BioCatalogue")
+ end
+
+ @@biocat_document_cache = ENV['FILE'] ? ENV['FILE'] : "tmp/biocatalogue.yml"
+
+ @federation_source = FederationSource.find_by_name("BioCatalogue")
+
+ import_biocatalogue_services("http://www.biocatalogue.org/services?include=summary,deployments&sort_order=asc")
+ end
+end
+
Copied: trunk/public/images/biocat_icon.png (from rev 2657, branches/biocat/public/images/biocat_icon.png)
(Binary files differ)
Copied: trunk/public/images/biocat_logo.png (from rev 2657, branches/biocat/public/images/biocat_logo.png)
(Binary files differ)
Modified: trunk/public/stylesheets/styles.css (2657 => 2658)
--- trunk/public/stylesheets/styles.css 2011-07-30 13:56:59 UTC (rev 2657)
+++ trunk/public/stylesheets/styles.css 2011-08-01 15:57:13 UTC (rev 2658)
@@ -838,6 +838,7 @@
margin-bottom: 0.5em;
padding: 1em 0.5em;
vertical-align: top;
+ width: 737px;
}
table.alt_table tr.odd_row td {
Property changes: trunk/tmp
Added: svn:ignore
Property changes: trunk/vendor/plugins/acts_as_solr/solr/solr
Added: svn:ignore
Modified: trunk/vendor/plugins/structured_data/lib/auto_migrate.rb (2657 => 2658)
--- trunk/vendor/plugins/structured_data/lib/auto_migrate.rb 2011-07-30 13:56:59 UTC (rev 2657)
+++ trunk/vendor/plugins/structured_data/lib/auto_migrate.rb 2011-08-01 15:57:13 UTC (rev 2658)
@@ -1,4 +1,4 @@
-# myExperiment: vendor/plugins/structured_data/lib/auto_migrate.rb)
+# myExperiment: vendor/plugins/structured_data/lib/auto_migrate.rb
#
# Copyright (c) 2009 University of Manchester and the University of Southampton.
# See license.txt for details.
@@ -7,9 +7,9 @@
class AutoMigrate
- AUTO_TABLE_NAME = "auto_tables"
- SCHEMA = "config/base_schema.xml"
- SCHEMA_D = "config/schema.d"
+ AUTO_TABLE_NAME = "auto_tables"
+ SCHEMA = "config/base_schema.xml"
+ SCHEMA_D = "config/schema.d"
COLUMN_ATTRIBUTES = ['name', 'type', 'default', 'limit']
BELONGS_TO_ATTRIBUTES = ['polymorphic', 'class_name', 'foreign_key']
HAS_MANY_ATTRIBUTES = ['target', 'through', 'foreign_key', 'source', 'dependent', 'conditions', 'class_name', 'as']