myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2367] branches/biocat/app: similar workflows bas


From: noreply
Subject: [myexperiment-hackers] [2367] branches/biocat/app: similar workflows based on services improved to order on number of wsdl matches
Date: Wed, 31 Mar 2010 08:50:51 -0400 (EDT)

Revision
2367
Author
dgc
Date
2010-03-31 08:50:51 -0400 (Wed, 31 Mar 2010)

Log Message

similar workflows based on services improved to order on number of wsdl matches

Modified Paths

Diff

Modified: branches/biocat/app/controllers/workflows_controller.rb (2366 => 2367)


--- branches/biocat/app/controllers/workflows_controller.rb	2010-03-31 09:57:21 UTC (rev 2366)
+++ branches/biocat/app/controllers/workflows_controller.rb	2010-03-31 12:50:51 UTC (rev 2367)
@@ -235,6 +235,14 @@
       @viewing = Viewing.create(:contribution => @workflow.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'], :accessed_from_site => accessed_from_website?())
     end
 
+    @contributions_with_similar_services = @workflow.workflows_with_similar_services.select do |w|
+      Authorization.is_authorized?('view', nil, w, current_user)
+    end.map do |w|
+      w.contribution
+    end
+
+    @similar_services_limit = 10
+
     respond_to do |format|
       format.html # show.rhtml
     end

Modified: branches/biocat/app/models/workflow.rb (2366 => 2367)


--- branches/biocat/app/models/workflow.rb	2010-03-31 09:57:21 UTC (rev 2366)
+++ branches/biocat/app/models/workflow.rb	2010-03-31 12:50:51 UTC (rev 2367)
@@ -310,4 +310,30 @@
     end
   end
 
+  def workflows_with_similar_services
+
+    # Get the WSDL URIs that this workflow uses
+
+    workflow_wps = WorkflowProcessor.find(:all,
+        :select     => 'DISTINCT workflow_id, wsdl',
+        :conditions => ['workflow_id = ? AND wsdl IS NOT NULL', id])
+
+    return [] if workflow_wps.empty?
+
+    wsdls = workflow_wps.map do |wp| wp.wsdl end
+
+    # Get all the related workflows
+
+    related_wps = WorkflowProcessor.find(:all,
+        :select => 'DISTINCT workflow_id, wsdl',
+        :conditions => ['workflow_id != ? AND (' + ((1..wsdls.length).map do "wsdl = ?" end).join(" OR ") + ')', id] + wsdls)
+
+    related_workflows = related_wps.group_by do |wp| wp.workflow end
+
+    # Sort results based on the number of matching services with the original workflow
+
+    related_workflows = related_workflows.sort do |a, b| b[1].length <=> a[1].length end
+
+    related_workflows.map do |result| result[0] end
+  end
 end

Modified: branches/biocat/app/views/workflows/show.rhtml (2366 => 2367)


--- branches/biocat/app/views/workflows/show.rhtml	2010-03-31 09:57:21 UTC (rev 2366)
+++ branches/biocat/app/views/workflows/show.rhtml	2010-03-31 12:50:51 UTC (rev 2367)
@@ -308,6 +308,20 @@
 
 <div class="clearer">&nbsp;</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/>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]