Diff
Modified: trunk/Gemfile (3548 => 3549)
--- trunk/Gemfile 2013-05-20 10:25:04 UTC (rev 3548)
+++ trunk/Gemfile 2013-05-20 13:46:27 UTC (rev 3549)
@@ -28,4 +28,4 @@
gem "will_paginate", "~> 2.3.16"
gem "open_id_authentication", "~> 1.1.0"
gem "simple-rss", "~> 1.2.3"
-
+gem "net-http-persistent", "~> 2.8"
Modified: trunk/app/controllers/friendships_controller.rb (3548 => 3549)
--- trunk/app/controllers/friendships_controller.rb 2013-05-20 10:25:04 UTC (rev 3548)
+++ trunk/app/controllers/friendships_controller.rb 2013-05-20 13:46:27 UTC (rev 3549)
@@ -230,7 +230,7 @@
not_auth = true
end
when "destroy" # link - just the friend id, but current user can be "friend" or "user" in the friendship
- unless params[:user_id].to_i == @friendship.friend_id.to_i && (address@hidden, @friendship.friend_id].include? current_user.id)
+ unless address@hidden, @friendship.friend_id].include? current_user.id
not_auth = true
end
else # link - just the current user id, and it should be "friend" in the friendship ("accept" for example)
Modified: trunk/app/controllers/workflows_controller.rb (3548 => 3549)
--- trunk/app/controllers/workflows_controller.rb 2013-05-20 10:25:04 UTC (rev 3548)
+++ trunk/app/controllers/workflows_controller.rb 2013-05-20 13:46:27 UTC (rev 3549)
@@ -366,6 +366,7 @@
begin
@workflow.extract_metadata
rescue
+ raise unless Rails.env == "production"
end
policy_err_msg = update_policy(@workflow, params, current_user)
@@ -470,7 +471,7 @@
if @workflow.valid?
# Save content blob first now and set it on the workflow.
# TODO: wrap this in a transaction!
- @workflow.content_blob = ContentBlob.create(:data ="" file.read)
+ @workflow.content_blob = ContentBlob.new(:data ="" file.read)
@workflow.preview = nil
@workflow[:revision_comments] = params[:new_workflow][:rev_comments]
@@ -991,6 +992,7 @@
rescue Exception => ex
worked = false
err_msg = "ERROR: some processing failed in workflow processor '#{processor_class.to_s}'.\nEXCEPTION: #{ex}"
+ raise unless Rails.env == "production"
logger.error err_msg
end
else
Modified: trunk/app/models/workflow.rb (3548 => 3549)
--- trunk/app/models/workflow.rb 2013-05-20 10:25:04 UTC (rev 3548)
+++ trunk/app/models/workflow.rb 2013-05-20 13:46:27 UTC (rev 3549)
@@ -10,6 +10,7 @@
require 'acts_as_attributable'
require 'acts_as_reviewable'
require 'acts_as_runnable'
+require 'acts_as_rdf_serializable'
require 'previews'
require 'sunspot_rails'
@@ -49,6 +50,11 @@
acts_as_reviewable
+ acts_as_rdf_serializable('application/x-turtle',
+ :generation_error_message => "Failed to generate RDF, please check the given workflow file is valid.") do |workflow|
+ workflow.processor_class.new(workflow.content_blob.data).extract_rdf_structure(workflow)
+ end
+
has_previews
has_versions :workflow_versions,
@@ -373,12 +379,14 @@
begin
processor_class.new(content_blob.data).extract_metadata(self)
rescue
+ raise unless Rails.env == 'production'
end
end
end
def unique_wsdls
- WorkflowProcessor.find(:all, :conditions => ['workflow_id = ? AND wsdl IS NOT NULL', id]).map do |wp| wp.wsdl end.uniq
+ WorkflowProcessor.find(:all,
+ :conditions => ['workflow_id = ? AND wsdl IS NOT NULL', id]).map do |wp| wp.wsdl end.uniq
end
def workflows_with_similar_services
Copied: trunk/config/initializers/triple_store.rb (from rev 3548, branches/component-querying/config/initializers/triple_store.rb) (0 => 3549)
--- trunk/config/initializers/triple_store.rb (rev 0)
+++ trunk/config/initializers/triple_store.rb 2013-05-20 13:46:27 UTC (rev 3549)
@@ -0,0 +1,19 @@
+# myExperiment: config/initializers/triple_store.rb
+#
+# Copyright (c) 2013 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+require 'sesame'
+
+class TripleStore
+
+ if Rails.env == 'test'
+ @instance = DummyTripleStore::Repository.new
+ elsif Conf.enable_triple_store
+ @instance = Sesame::Repository.new(Conf.sesame_repository, 'myexp_sesame')
+ end
+
+ def self.instance
+ @instance
+ end
+end
Copied: trunk/lib/acts_as_rdf_serializable.rb (from rev 3548, branches/component-querying/lib/acts_as_rdf_serializable.rb) (0 => 3549)
--- trunk/lib/acts_as_rdf_serializable.rb (rev 0)
+++ trunk/lib/acts_as_rdf_serializable.rb 2013-05-20 13:46:27 UTC (rev 3549)
@@ -0,0 +1,81 @@
+# myExperiment: lib/acts_as_rdf_serializable.rb
+#
+# Copyright (c) 2013 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+module Finn
+ module Acts #:nodoc:
+ module RDFSerializable #:nodoc:
+
+ def self.included(mod)
+ mod.extend(ClassMethods)
+ end
+
+ module ClassMethods
+
+ ##
+ # Specify an representation of the resource as a string (in the specified :format:)
+ # in the block (to which the resource instance is yielded).
+ # The resource will be stored in TripleStore on save/update, and removed when deleted.
+ def acts_as_rdf_serializable(format, options = {}, &block)
+ cattr_accessor :rdf_generator, :rdf_format, :rdf_serializable_options
+
+ self.rdf_serializable_options = options
+ self.rdf_generator = block
+ self.rdf_format = format
+
+ validate :generate_rdf
+
+ after_save :store_rdf
+ after_destroy :destroy_rdf
+
+ include Finn::Acts::RDFSerializable::InstanceMethods
+ # To generate resource's URI to be used as "context" in the triple store:
+ include ActionController::UrlWriter
+ include ActionController::PolymorphicRoutes
+ end
+ end
+
+ module InstanceMethods
+
+ def to_rdf
+ self.class.rdf_generator.call(self)
+ end
+
+ private
+
+ def resource_uri
+ base_uri = URI(Conf.base_uri)
+ "<#{polymorphic_url(self, :host => "#{base_uri.host}:#{base_uri.port}")}>"
+ end
+
+ def generate_rdf
+ begin
+ @rdf = self.to_rdf
+ rescue
+ errors.add_to_base(self.rdf_serializable_options[:generation_error_message] || "RDF failed to generate")
+ false
+ else
+ true
+ end
+ end
+
+ def store_rdf
+ unless TripleStore.instance.nil? || @rdf.nil?
+ TripleStore.instance.insert(@rdf, resource_uri, self.class.rdf_format)
+ end
+ end
+
+ def destroy_rdf
+ unless TripleStore.instance.nil?
+ TripleStore.instance.delete(:context => resource_uri)
+ end
+ end
+ end
+ end
+ end
+end
+
+ActiveRecord::Base.class_eval do
+ include Finn::Acts::RDFSerializable
+end
Modified: trunk/lib/conf.rb (3548 => 3549)
--- trunk/lib/conf.rb 2013-05-20 10:25:04 UTC (rev 3548)
+++ trunk/lib/conf.rb 2013-05-20 13:46:27 UTC (rev 3549)
@@ -202,6 +202,14 @@
self.fetch_entry('pivot_options', {})
end
+ def self.enable_triple_store
+ self.fetch_entry('enable_triple_store')
+ end
+
+ def self.sesame_repository
+ self.fetch_entry('sesame_repository')
+ end
+
# This method is required to create an administrator in the test fixtures
def self.admins=(value)
Copied: trunk/lib/dummy_triple_store.rb (from rev 3548, branches/component-querying/lib/dummy_triple_store.rb) (0 => 3549)
--- trunk/lib/dummy_triple_store.rb (rev 0)
+++ trunk/lib/dummy_triple_store.rb 2013-05-20 13:46:27 UTC (rev 3549)
@@ -0,0 +1,33 @@
+# myExperiment: lib/dummy_triple_store.rb
+#
+# Copyright (c) 2013 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+# For test purposes
+
+require 'uri'
+
+module DummyTripleStore
+ class Repository
+
+ attr_accessor :repo
+
+ def initialize
+ @repo = {}
+ end
+
+ def insert(rdf, context, content_type = 'application/x-turtle')
+ @repo[context] = rdf
+ end
+
+ alias_method :update, :insert
+
+ def query(query)
+ @repo.keys.map {|key| {:workflow_uri => URI(key[1..-2])}}
+ end
+
+ def delete(parameters = {})
+ @repo.delete(parameters[:context])
+ end
+ end
+end
Modified: trunk/lib/rest.rb (3548 => 3549)
--- trunk/lib/rest.rb 2013-05-20 10:25:04 UTC (rev 3548)
+++ trunk/lib/rest.rb 2013-05-20 13:46:27 UTC (rev 3549)
@@ -2510,44 +2510,55 @@
end
end
-
# Component Querying
def get_components(opts)
- query = opts[:query]
+ return rest_response(404) if TripleStore.instance.nil?
- annotations = query['annotations'] # annotations on workflow itself
- # annotations on workflow features
- inputs = query["input"]
- outputs = query["output"]
- processors = query["processor"]
+ sparql_prefixes = CGI.unescape(opts[:query]["prefixes"] || '')
+ sparql_query = CGI.unescape(opts[:query]["query"] || '')
- # Filter workflow set
- pivot, problem = calculate_pivot(
- :pivot_options => Conf.pivot_options,
- :params => query,
- :user => opts[:user],
- :search_models => [Workflow],
- :no_pagination => true,
- :locked_filters => { 'CATEGORY' => 'Workflow' },
- :active_filters => ["CATEGORY", "TYPE_ID", "TAG_ID", "USER_ID",
- "LICENSE_ID", "GROUP_ID", "WSDL_ENDPOINT",
- "CURATION_EVENT", "SERVICE_PROVIDER",
- "SERVICE_COUNTRY", "SERVICE_STATUS"])
+ # Prevent subversion of SELECT template
+ if sparql_prefixes.downcase.include?("select")
+ return rest_response(400, :reason => "Invalid prefix syntax")
+ end
- workflow_ids = pivot[:results].map {|r| r.is_a?(SearchResult) ? r.result_id : r.contributable_id }
+ template = %(
+ PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
+ PREFIX wfdesc:<http://purl.org/wf4ever/wfdesc#>
+ PREFIX wf4ever:<http://purl.org/wf4ever/wf4ever#>
+ #{sparql_prefixes}
+ SELECT ?workflow_uri WHERE {
+ GRAPH ?workflow_uri {
+ ?w a wfdesc:Workflow .
+ #{sparql_query}
+ }
+ })
+
+ # Perform query
begin
- matches = filter_by_semantic_annotations(workflow_ids, inputs, outputs, processors, annotations)
- rescue RuntimeError => e
- if e.message == "Bad Syntax"
- return rest_response(400)
- else
- raise e
- end
+ sparql_results = TripleStore.instance.query(template)
+ rescue Sesame::QueryException => e
+ return rest_response(400, :reason => "SPARQL Error: #{e.message}")
end
- # Render
- produce_rest_list(opts[:uri], opts[:rules], query, matches, "workflows", [], opts[:user])
+ # Remove results not from this host
+ # TODO: do this in the query?
+ base_uri = URI(Conf.base_uri)
+ results = sparql_results.select do |r|
+ r[:workflow_uri].host == base_uri.host && r[:workflow_uri].port == base_uri.port
+ end
+
+ # Find the workflows in the database
+ results = results.map do |r|
+ Workflow.find_by_id(r[:workflow_uri].request_uri.to_s.sub('/workflows/', '').to_i)
+ end
+
+ # Perform auth on workflow set
+ results = results.select { |r| Authorization.check("view", r, opts[:user]) }
+
+ # Render results
+ produce_rest_list(opts[:uri], opts[:rules], opts[:query], results, "workflows", [], opts[:user])
end
def get_policies(opts)
@@ -2563,82 +2574,3 @@
produce_rest_list(opts[:uri], opts[:rules], opts[:query], policies, "policies", [], opts[:user])
end
-
-
-private
-
-# Here be dragons!
-def filter_by_semantic_annotations(workflow_ids, inputs, outputs, processors, annotations)
-
- # This method returns an array of workflow ids for workflows that possess all of the specified features.
- def get_workflow_feature_matches(workflow_ids, features, model, query_conditions, query_conditions_excluding)
- # "features" is an array of sets of annotations to be queried, in the form [ '"<ann1>","<ann2>"' , '"<ann3>"' ]
- # Where "<ann1>" etc. is in the form "pred1 obj1", where pred1 and obj1 are the predicate and object parts of an RDF triple, respectively..
- # The above example states that the workflow must have a <feature> that has annotations "pred1 obj1" and "pred2 obj2", AND
- # another, different <feature> with "pred3 obj3".
-
- selected = []
- feature_matches = features.collect do |key,set|
- raise "Bad Syntax" unless set =~ /^("[^ ]+ [^"]+")(,"[^ ]+ [^"]+")*$/
-
- feature_annotations = set.split('","').collect {|a| a.gsub('"','')}
- # "<ann1>", "<ann2>" (example)
- matching_features = feature_annotations.collect { |a|
- # Find all <features> with semantic annotation "<predicate> <object>" (example)
- predicate, object = a.split(" ", 2)
- unless selected.empty?
- model.find(:all, :include => :semantic_annotations,
- :conditions => [query_conditions, workflow_ids, predicate, object, selected])
- else
- model.find(:all, :include => :semantic_annotations,
- :conditions => [query_conditions_excluding, workflow_ids, predicate, object])
- end
-
- }.inject {|f, matches| matches & f} # Get the intersection of <features> that have each annotation.
- # ie. the set of <features> that have ALL the required annotations
- selected += matching_features
- matching_features.collect {|wp| wp.workflow_id} # Get the workflows that those features belong to
- end
-
- feature_matches.inject {|matches, matches_all| matches_all & matches}
- end
-
-
- # Filter for workflows that have the required inputs
- if inputs
- workflow_ids = workflow_ids & get_workflow_feature_matches(workflow_ids, inputs, WorkflowPort,
- "workflow_id IN (?) AND semantic_annotations.predicate = ? AND semantic_annotations.object = ? AND port_type = 'input' AND workflow_ports.id NOT IN (?)",
- "workflow_id IN (?) AND semantic_annotations.predicate = ? AND semantic_annotations.object = ? AND port_type = 'input'")
- end
-
- # Filter for workflows that have the required outputs
- if outputs
- workflow_ids = workflow_ids & get_workflow_feature_matches(workflow_ids, outputs, WorkflowPort,
- "workflow_id IN (?) AND semantic_annotations.predicate = ? AND semantic_annotations.object = ? AND port_type = 'output' AND workflow_ports.id NOT IN (?)",
- "workflow_id IN (?) AND semantic_annotations.predicate = ? AND semantic_annotations.object = ? AND port_type = 'output'")
- end
-
- # Filter for workflows that have the required processors
- if processors
- workflow_ids = workflow_ids & get_workflow_feature_matches(workflow_ids, processors, WorkflowProcessor,
- "workflow_id IN (?) AND semantic_annotations.predicate = ? AND semantic_annotations.object = ? AND workflow_processors.id NOT IN (?)",
- "workflow_id IN (?) AND semantic_annotations.predicate = ? AND semantic_annotations.object = ?")
- end
-
- # Filter for workflows that have the required semantic annotations
- unless annotations.blank?
- raise "Bad Syntax" unless annotations =~ /^("[^ ]+ [^"]+")(,"[^ ]+ [^"]+")*$/
-
- annotations = annotations.split('","').collect {|a| a.gsub('"','')}
-
- matches_semantic_annotation_requirements = annotations.collect { |a|
- predicate, object = a.split(" ", 2)
- SemanticAnnotation.find_all_by_predicate_and_object_and_subject_type(predicate, object, "Workflow").map {|a| a.subject_id}
- }
-
- workflow_ids = workflow_ids & matches_semantic_annotation_requirements.inject {|matches, matches_all| matches_all & matches}
- end
-
- # Workflows that match ALL the requirements - the intersection of all the sub arrays.
- Workflow.find_all_by_id(workflow_ids)
-end
Copied: trunk/lib/sesame.rb (from rev 3548, branches/component-querying/lib/sesame.rb) (0 => 3549)
--- trunk/lib/sesame.rb (rev 0)
+++ trunk/lib/sesame.rb 2013-05-20 13:46:27 UTC (rev 3549)
@@ -0,0 +1,90 @@
+# myExperiment: lib/sesame.rb
+#
+# Copyright (c) 2013 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+require 'net/http/persistent'
+
+module Sesame
+ class Repository
+
+ VALID_CONTENT_TYPES = ['application/rdf+xml', 'text/plain', 'application/x-turtle', 'text/rdf+n3', 'application/trix',
+ 'application/x-trig', 'application/x-binary-rdf'].freeze
+
+ def initialize(repo_url, name = 'sesame_connection')
+ @url = "" # http://example.com:8080/openrdf-sesame/repositories/my_repo
+ @connection = Net::HTTP::Persistent.new name
+ end
+
+ def insert(rdf, context, content_type = 'application/x-turtle')
+ raise "Content type not supported: #{content_type}" unless VALID_CONTENT_TYPES.include?(content_type)
+
+ url = ""
+ request = Net::HTTP::Put.new url.request_uri
+ request.body = rdf
+ request.content_type = content_type
+
+ response = @connection.request url, request #Net::HTTP::Persistent::Error if can't connect
+
+ case response.code
+ when '204'
+ true
+ else
+ raise RequestException.new(response.code, response.body)
+ end
+ end
+
+ alias_method :update, :insert
+
+ def query(query)
+ url = ""
+ request = Net::HTTP::Get.new url.request_uri
+ request['accept'] = 'application/sparql-results+xml'
+ response = @connection.request url, request
+
+ case response.code
+ when '200'
+ SPARQLResults.from_xml(response.body)
+ when '400'
+ raise QueryException.new(response.code, response.body)
+ else
+ raise RequestException.new(response.code, response.body)
+ end
+ end
+
+ ##
+ # Valid options for parameters:
+ # :context, :subject, :object, :predicate
+ #
+ # Needs at least one of the above
+ def delete(parameters = {})
+ unless parameters.keys.any? {|k| [:subject, :predicate, :object, :context].include?(k)}
+ raise "At least one of :subject, :predicate, :object, or :context required"
+ end
+
+ url = ""
+ request = Net::HTTP::Delete.new url.request_uri
+ response = @connection.request url, request
+
+ case response.code
+ when '204'
+ true
+ else
+ raise RequestException.new(response.code, response.body)
+ end
+ end
+
+ end
+
+ class RequestException < Exception
+ attr_reader :code
+
+ def initialize(code, message)
+ super(message)
+ @code = code
+ end
+
+ end
+
+ class QueryException < RequestException; end
+end
Copied: trunk/lib/sparql_results.rb (from rev 3548, branches/component-querying/lib/sparql_results.rb) (0 => 3549)
--- trunk/lib/sparql_results.rb (rev 0)
+++ trunk/lib/sparql_results.rb 2013-05-20 13:46:27 UTC (rev 3549)
@@ -0,0 +1,56 @@
+# myExperiment: lib/sparql_results.rb
+#
+# Copyright (c) 2013 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+require 'libxml'
+
+class SPARQLResults
+
+ include Enumerable
+
+ attr_reader :variables
+
+ def self.from_xml(xml)
+ doc = LibXML::XML::Parser.string(xml).parse
+ root = doc.root
+ root.namespaces.default_prefix = "ns"
+
+ variables = []
+ root.find('ns:head/ns:variable').each do |variable_node|
+ variables << variable_node['name'].to_sym
+ end
+
+ results = []
+ root.find('ns:results/ns:result').each do |result_node|
+ result = {}
+ result_node.find('ns:binding').each do |binding_node|
+ content_node = binding_node.find_first('*')
+ case content_node.name
+ when 'uri'
+ content = URI(content_node.content)
+ else
+ content = content_node.content
+ end
+ result[binding_node['name'].to_sym] = content
+ end
+ results << result
+ end
+
+ SPARQLResults.new(variables, results)
+ end
+
+ def initialize(variables, results)
+ @variables = variables
+ @results = results
+ end
+
+ def each(&block)
+ @results.each(&block)
+ end
+
+ def size
+ @results.size
+ end
+
+end
\ No newline at end of file
Modified: trunk/lib/workflow_processors/interface.rb (3548 => 3549)
--- trunk/lib/workflow_processors/interface.rb 2013-05-20 10:25:04 UTC (rev 3548)
+++ trunk/lib/workflow_processors/interface.rb 2013-05-20 13:46:27 UTC (rev 3549)
@@ -120,6 +120,10 @@
def extract_metadata(workflow)
end
+ def extract_rdf_structure(workflow)
+ nil
+ end
+
# End Instance Methods
end
Modified: trunk/lib/workflow_processors/taverna2.rb (3548 => 3549)
--- trunk/lib/workflow_processors/taverna2.rb 2013-05-20 10:25:04 UTC (rev 3548)
+++ trunk/lib/workflow_processors/taverna2.rb 2013-05-20 13:46:27 UTC (rev 3549)
@@ -396,39 +396,113 @@
:name => processor.name,
:wsdl => processor.wsdl,
:wsdl_operation => processor.wsdl)
- create_semantic_annotations(workflow_processor, processor.semantic_annotation) if processor.semantic_annotation
end
@t2flow_model.sources.each do |source|
port = WorkflowPort.create(:workflow => workflow,
:port_type => "input",
:name => source.name)
- create_semantic_annotations(port, source.semantic_annotation) if source.semantic_annotation
end
@t2flow_model.sinks.each do |sink|
port = WorkflowPort.create(:workflow => workflow,
:port_type => "output",
:name => sink.name)
- create_semantic_annotations(port, sink.semantic_annotation) if sink.semantic_annotation
end
- create_semantic_annotations(workflow, @t2flow_model.main.annotations.semantic_annotation) if @t2flow_model.main.annotations.semantic_annotation
end
- def create_semantic_annotations(subject, semantic_annotations)
- if semantic_annotations.type == "text/rdf+n3"
- g = RDF::Graph.new
- g << RDF::Reader.for(:n3).new(semantic_annotations.content)
+ def extract_rdf_structure(workflow)
+ rdf = ''
+ IO.popen("java -jar #{RAILS_ROOT}/vendor/java/scufl2-wfdesc/scufl2-wfdesc-0.3.0-standalone.jar", 'r+') do |converter|
+ converter.puts(workflow.content_blob.data)
+ converter.close_write
+ rdf = converter.read
+ end
- g.each_statement do |statement|
- predicate = statement.predicate.to_s
- object = statement.object.to_s
- SemanticAnnotation.create(:subject => subject, :predicate => predicate, :object => object)
+ raise "Error generating wfdesc" if rdf.blank?
+
+ # TODO: Remove this hack, put in place because the wfdesc tool does not yet merge in semantic annotations
+ # *** Start of hack ***
+ structure = RDF::Graph.new
+ structure.insert(RDF::Reader.for(:turtle).new(StringIO.new(rdf)))
+
+ wfdesc = RDF::Vocabulary.new('http://purl.org/wf4ever/wfdesc#')
+
+ main_workflow = @t2flow_model.dataflows.first
+
+ query = RDF::Query.new do
+ pattern [:uri, RDF.type, wfdesc.Workflow]
+ pattern [:uri, RDF::RDFS.label, main_workflow.name]
+ end
+
+ # Annotations on the workflow
+ base_uri = query.execute(structure).first.uri
+
+ if main_workflow.annotations.semantic_annotation
+ RDF::Reader.for(:n3).new(StringIO.new(main_workflow.annotations.semantic_annotation.content), :base_uri => base_uri.to_s).each_statement do |s|
+ structure << s
end
- else
- raise "Unsupported annotation content type (#{semantic_annotations.type}) for #{subject}."
end
+
+ # Annotations on processors
+ @t2flow_model.processors.each do |processor|
+ query = RDF::Query.new do
+ pattern [base_uri, wfdesc.hasSubProcess, :uri]
+ pattern [:uri, RDF.type, wfdesc.Process]
+ pattern [:uri, RDF::RDFS.label, processor.name]
+ end
+
+ processor_uri = query.execute(structure).first.uri
+
+ if processor.semantic_annotation
+ RDF::Reader.for(:n3).new(StringIO.new(processor.semantic_annotation.content), :base_uri => processor_uri.to_s).each_statement do |s|
+ structure << s
+ end
+ end
+ end
+
+ # Annotations on inputs
+ @t2flow_model.sources.each do |input|
+ query = RDF::Query.new do
+ pattern [base_uri, wfdesc.hasInput, :uri]
+ pattern [:uri, RDF.type, wfdesc.Input]
+ pattern [:uri, RDF::RDFS.label, input.name]
+ end
+
+ input_uri = query.execute(structure).first.uri
+
+ if input.semantic_annotation
+ RDF::Reader.for(:n3).new(StringIO.new(input.semantic_annotation.content), :base_uri => input_uri.to_s).each_statement do |s|
+ structure << s
+ end
+ end
+ end
+
+ # Annotations on outputs
+ @t2flow_model.sinks.each do |output|
+ query = RDF::Query.new do
+ pattern [base_uri, wfdesc.hasOutput, :uri]
+ pattern [:uri, RDF.type, wfdesc.Output]
+ pattern [:uri, RDF::RDFS.label, output.name]
+ end
+
+ output_uri = query.execute(structure).first.uri
+
+ if output.semantic_annotation
+ RDF::Reader.for(:n3).new(StringIO.new(output.semantic_annotation.content), :base_uri => output_uri.to_s).each_statement do |s|
+ structure << s
+ end
+ end
+ end
+
+ RDF::Writer.for(:turtle).buffer do |writer|
+ structure.each_statement do |statement|
+ writer << statement
+ end
+ end
+
+ # *** End of hack ***
end
# End Instance Methods
Copied: trunk/public/component_query_demo.html (from rev 3548, branches/component-querying/public/component_query_demo.html) (0 => 3549)
--- trunk/public/component_query_demo.html (rev 0)
+++ trunk/public/component_query_demo.html 2013-05-20 13:46:27 UTC (rev 3549)
@@ -0,0 +1,36 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <title>myExperiment Component Query Form</title>
+ </head>
+ <body>
+ <h1>myExperiment Component Querying Demo</h1>
+ <div style="float: left; margin-right: 3em">
+ <form action="" method="GET">
+ <h2>SPARQL Prefixes</h2>
+ <textarea rows="5" cols="80" name="prefixes"></textarea><br/>
+ <h2>SPARQL Query Fragment</h2>
+ <textarea rows="20" cols="80" name="query"></textarea><br/>
+ <input type="submit"/>
+ </form>
+ </div>
+ <div style="float:left">
+ <h2>SPARQL Template</h2>
+ PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#><br/>
+ PREFIX wfdesc:<http://purl.org/wf4ever/wfdesc#><br/>
+ <i>{sparql_prefixes}</i><br/><br/>
+ <div>
+ SELECT ?workflow_uri WHERE {
+ <div style="margin-left: 2em;">
+ GRAPH ?workflow_uri {
+ <div style="margin-left: 2em;">
+ ?w a wfdesc:Workflow . <br/>
+ <i>{sparql_query_fragment}</i>
+ </div>
+ }
+ </div>
+ }
+ </div>
+ </div>
+ </body>
+</html>
Modified: trunk/test/fixtures/files/image_to_tiff_migration.t2flow (3548 => 3549)
--- trunk/test/fixtures/files/image_to_tiff_migration.t2flow 2013-05-20 10:25:04 UTC (rev 3548)
+++ trunk/test/fixtures/files/image_to_tiff_migration.t2flow 2013-05-20 13:46:27 UTC (rev 3549)
@@ -1,10 +1,10 @@
-<workflow xmlns="http://taverna.sf.net/2008/xml/t2flow" version="1" producedBy="taverna-2.4.0"><dataflow id="16841f82-e1fe-4527-b7ef-411c4c59493b" role="top"><name>Image_to_tiff_migrat</name><inputPorts><port><name>from_uri</name><depth>0</depth><granularDepth>0</granularDepth><annotations><annotation_chain encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
+<workflow xmlns="http://taverna.sf.net/2008/xml/t2flow" version="1" producedBy="taverna-2.4.0"><dataflow id="8d2f9ef0-09ca-4103-b4fd-0ee0a40d8263" role="top"><name>Imagemagick_convert_</name><inputPorts><port><name>from_uri</name><depth>0</depth><granularDepth>0</granularDepth><annotations><annotation_chain encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
- <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.FreeTextDescription">
- <text>description</text>
+ <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.ExampleValue">
+ <text>in.tiff</text>
</annotationBean>
- <date>2012-11-16 16:22:56.977 UTC</date>
+ <date>2013-03-06 15:58:34.431 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
@@ -12,10 +12,35 @@
</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain><annotation_chain encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
+ <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.FreeTextDescription">
+ <text>URI to the input object</text>
+ </annotationBean>
+ <date>2013-03-06 15:58:35.192 UTC</date>
+ <creators />
+ <curationEventList />
+ </net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
+ </annotationAssertions>
+</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
+ <annotationAssertions>
+ <net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
+ <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.SemanticAnnotation">
+ <mimeType>text/rdf+n3</mimeType>
+ <content><> <http://purl.org/DP/components#portType>
+ <http://purl.org/DP/components#FromURIPort> .
+</content>
+ </annotationBean>
+ <date>2013-03-06 15:36:17.856 UTC</date>
+ <creators />
+ <curationEventList />
+ </net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
+ </annotationAssertions>
+</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain_2_2></annotations></port><port><name>to_uri</name><depth>0</depth><granularDepth>0</granularDepth><annotations><annotation_chain encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
+ <annotationAssertions>
+ <net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
<annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.ExampleValue">
- <text>example</text>
+ <text>out.tiff</text>
</annotationBean>
- <date>2012-11-16 16:22:43.712 UTC</date>
+ <date>2013-03-06 15:58:28.756 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
@@ -25,57 +50,137 @@
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
<annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.SemanticAnnotation">
<mimeType>text/rdf+n3</mimeType>
- <content>[] <http://scape-project.eu/pc/vocab/profiles#hasPortType>
- <http://scape-project.eu/pc/vocab/profiles#FromURIPort> .
+ <content><> <http://purl.org/DP/components#portType>
+ <http://purl.org/DP/components#ToURIPort> .
</content>
</annotationBean>
- <date>2012-11-19 15:53:49.250 UTC</date>
+ <date>2013-03-06 15:36:10.390 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
</annotationAssertions>
-</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain_2_2></annotations></port><port><name>to_uri</name><depth>0</depth><granularDepth>0</granularDepth><annotations><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
+</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain_2_2><annotation_chain encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
+ <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.FreeTextDescription">
+ <text>URI to the input object</text>
+ </annotationBean>
+ <date>2013-03-06 15:58:27.713 UTC</date>
+ <creators />
+ <curationEventList />
+ </net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
+ </annotationAssertions>
+</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain></annotations></port><port><name>compression</name><depth>0</depth><granularDepth>0</granularDepth><annotations><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
+ <annotationAssertions>
+ <net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
<annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.SemanticAnnotation">
<mimeType>text/rdf+n3</mimeType>
- <content>[] <http://scape-project.eu/pc/vocab/profiles#hasPortType>
- <http://scape-project.eu/pc/vocab/profiles#ToURIPort> .
+ <content><> <http://purl.org/DP/components#acceptsPredefinedParameter>
+ [ a <http://purl.org/DP/components#PredefinedParameter> ;
+ <http://purl.org/DP/components#parameterValue>
+ "none" ;
+ <http://purl.org/DP/components#parameterDescription>
+ "no compression"
+ ] .
+
+ <> <http://purl.org/DP/components#acceptsPredefinedParameter>
+ [ a <http://purl.org/DP/components#PredefinedParameter> ;
+ <http://purl.org/DP/components#parameterValue>
+ "Group4" ;
+ <http://purl.org/DP/components#parameterDescription>
+ "CCITT Group 4"
+ ] .
+
+ <> <http://purl.org/DP/components#acceptsPredefinedParameter>
+ [ a <http://purl.org/DP/components#PredefinedParameter> ;
+ <http://purl.org/DP/components#parameterValue>
+ "RLE" ;
+ <http://purl.org/DP/components#parameterDescription>
+ "run length encoding"
+ ] .
</content>
</annotationBean>
- <date>2012-11-20 12:09:41.928 UTC</date>
+ <date>2013-03-06 16:09:38.742 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
</annotationAssertions>
-</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain_2_2></annotations></port></inputPorts><outputPorts /><processors><processor><name>Tool</name><inputPorts><port><name>to_uri</name><depth>0</depth></port><port><name>from_uri</name><depth>0</depth></port></inputPorts><outputPorts /><annotations><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
+</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain_2_2><annotation_chain encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
+ <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.FreeTextDescription">
+ <text>Imagemagick convert compress parameter</text>
+ </annotationBean>
+ <date>2013-03-06 15:57:39.167 UTC</date>
+ <creators />
+ <curationEventList />
+ </net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
+ </annotationAssertions>
+</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain><annotation_chain encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
+ <annotationAssertions>
+ <net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
+ <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.ExampleValue">
+ <text>none</text>
+ </annotationBean>
+ <date>2013-03-06 15:57:42.109 UTC</date>
+ <creators />
+ <curationEventList />
+ </net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
+ </annotationAssertions>
+</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain></annotations></port></inputPorts><outputPorts><port><name>status</name><annotations><annotation_chain encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
+ <annotationAssertions>
+ <net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
+ <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.FreeTextDescription">
+ <text>STDOUT and STDERR of the action</text>
+ </annotationBean>
+ <date>2013-03-06 15:59:16.363 UTC</date>
+ <creators />
+ <curationEventList />
+ </net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
+ </annotationAssertions>
+</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
+ <annotationAssertions>
+ <net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
<annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.SemanticAnnotation">
<mimeType>text/rdf+n3</mimeType>
- <content>[] <http://scape-project.eu/pc/vocab/profiles#hasDependency>
- <http://scape-project.eu/pc/vocab/profiles#imagemagick-image2tiff> .
+ <content><> <http://purl.org/DP/components#portType>
+ <http://purl.org/DP/components#ActionStatusPort> .
</content>
</annotationBean>
- <date>2012-11-20 12:17:37.420 UTC</date>
+ <date>2013-03-06 15:35:48.882 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
</annotationAssertions>
-</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain_2_2></annotations><activities><activity><raven><group>net.sf.taverna.t2.activities</group><artifact>external-tool-activity</artifact><version>1.4</version></raven><class>net.sf.taverna.t2.activities.externaltool.ExternalToolActivity</class><inputMap><map from="to_uri" to="to_uri" /><map from="from_uri" to="from_uri" /></inputMap><outputMap /><configBean encoding="xstream"><net.sf.taverna.t2.activities.externaltool.ExternalToolActivityConfigurationBean xmlns="">
+</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain_2_2></annotations></port></outputPorts><processors><processor><name>convert</name><inputPorts><port><name>from_uri</name><depth>0</depth></port><port><name>to_uri</name><depth>0</depth></port><port><name>compression</name><depth>0</depth></port></inputPorts><outputPorts><port><name>STDOUT</name><depth>0</depth><granularDepth>0</granularDepth></port><port><name>STDERR</name><depth>0</depth><granularDepth>0</granularDepth></port></outputPorts><annotations><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
+ <annotationAssertions>
+ <net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
+ <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.SemanticAnnotation">
+ <mimeType>text/rdf+n3</mimeType>
+ <content><> <http://purl.org/DP/components#hasDependency>
+ <http://scape.keep.pt/vocab/dependencies#digital-preservation-migration-image-imagemagick-image2tiff> .
+</content>
+ </annotationBean>
+ <date>2013-03-06 19:59:47.611 UTC</date>
+ <creators />
+ <curationEventList />
+ </net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
+ </annotationAssertions>
+</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain_2_2></annotations><activities><activity><raven><group>net.sf.taverna.t2.activities</group><artifact>external-tool-activity</artifact><version>1.4</version></raven><class>net.sf.taverna.t2.activities.externaltool.ExternalToolActivity</class><inputMap><map from="to_uri" to="to_uri" /><map from="compression" to="compression" /><map from="from_uri" to="from_uri" /></inputMap><outputMap><map from="STDERR" to="STDERR" /><map from="STDOUT" to="STDOUT" /></outputMap><configBean encoding="xstream"><net.sf.taverna.t2.activities.externaltool.ExternalToolActivityConfigurationBean xmlns="">
<mechanismType>789663B8-DA91-428A-9F7D-B3F3DA185FD4</mechanismType>
<mechanismName>default local</mechanismName>
<mechanismXML><?xml version="1.0" encoding="UTF-8"?>
<localInvocation><shellPrefix>/bin/sh -c</shellPrefix><linkCommand>/bin/ln -s %%PATH_TO_ORIGINAL%% %%TARGET_NAME%%</linkCommand></localInvocation>
</mechanismXML>
- <externaltoolid>1c6b3cec-667d-4364-8a77-315a3b3c71f8</externaltoolid>
+ <externaltoolid>a69089e9-f0e9-4ca8-b151-3aa93621a97b</externaltoolid>
<useCaseDescription>
<usecaseid />
<description />
- <command>convert %%from_uri%% tiff:%%to_uri%%</command>
+ <command>convert -compress "%%compression%%" "%%from_uri%%" tiff:"%%to_uri%%"</command>
<preparingTimeoutInSeconds>1200</preparingTimeoutInSeconds>
<executionTimeoutInSeconds>1800</executionTimeoutInSeconds>
<tags>
+ <string>compression</string>
<string>from_uri</string>
<string>to_uri</string>
</tags>
@@ -91,7 +196,7 @@
<file>false</file>
<tempFile>false</tempFile>
<binary>false</binary>
- <charsetName>MacRoman</charsetName>
+ <charsetName>UTF-8</charsetName>
<forceCopy>false</forceCopy>
<list>false</list>
<concatenate>false</concatenate>
@@ -99,13 +204,27 @@
</de.uni__luebeck.inb.knowarc.usecases.ScriptInputUser>
</entry>
<entry>
+ <string>compression</string>
+ <de.uni__luebeck.inb.knowarc.usecases.ScriptInputUser>
+ <tag>compression</tag>
+ <file>false</file>
+ <tempFile>false</tempFile>
+ <binary>false</binary>
+ <charsetName>UTF-8</charsetName>
+ <forceCopy>false</forceCopy>
+ <list>false</list>
+ <concatenate>false</concatenate>
+ <mime />
+ </de.uni__luebeck.inb.knowarc.usecases.ScriptInputUser>
+ </entry>
+ <entry>
<string>from_uri</string>
<de.uni__luebeck.inb.knowarc.usecases.ScriptInputUser>
<tag>from_uri</tag>
<file>false</file>
<tempFile>false</tempFile>
<binary>false</binary>
- <charsetName>MacRoman</charsetName>
+ <charsetName>UTF-8</charsetName>
<forceCopy>false</forceCopy>
<list>false</list>
<concatenate>false</concatenate>
@@ -129,24 +248,13 @@
<initialDelay>1000</initialDelay>
<maxDelay>5000</maxDelay>
<maxRetries>0</maxRetries>
-</net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.RetryConfig></configBean></dispatchLayer><dispatchLayer><raven><group>net.sf.taverna.t2.core</group><artifact>workflowmodel-impl</artifact><version>1.4</version></raven><class>net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Invoke</class><configBean encoding="xstream"><null xmlns="" /></configBean></dispatchLayer></dispatchStack><iterationStrategyStack><iteration><strategy><cross><port name="to_uri" depth="0" /><port name="from_uri" depth="0" /></cross></strategy></iteration></iterationStrategyStack></processor></processors><conditions /><datalinks><datalink><sink type="processor"><processor>Tool</processor><port>to_uri</port></sink><source type="dataflow"><port>to_uri</port></source></datalink><datalink><sink type="processor"><processor>Tool</processor><port>from_uri</port></sink><source type="dataflow"><port>from_uri</port></source></datalink></datalinks><annotations><annotation_chain encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
+</net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.RetryConfig></configBean></dispatchLayer><dispatchLayer><raven><group>net.sf.taverna.t2.core</group><artifact>workflowmodel-impl</artifact><version>1.4</version></raven><class>net.sf.taverna.t2.workflowmodel.processor.dispatch.layers.Invoke</class><configBean encoding="xstream"><null xmlns="" /></configBean></dispatchLayer></dispatchStack><iterationStrategyStack><iteration><strategy><cross><port name="from_uri" depth="0" /><port name="to_uri" depth="0" /><port name="compression" depth="0" /></cross></strategy></iteration></iterationStrategyStack></processor></processors><conditions /><datalinks><datalink><sink type="processor"><processor>convert</processor><port>from_uri</port></sink><source type="dataflow"><port>from_uri</port></source></datalink><datalink><sink type="processor"><processor>convert</processor><port>to_uri</port></sink><source type="dataflow"><port>to_uri</port></source></datalink><datalink><sink type="processor"><processor>convert</processor><port>compression</port></sink><source type="dataflow"><port>compression</port></source></datalink><datalink><sink type="merge"><port>status</port></sink><source type="processor"><processor>convert</processor><port>STDOUT</port></source></datalink><datalink><sink type="merge"><port>status</port></sink><source type="processor"><processor>convert</processor><port>STDERR</port></source></datalink></datalinks><annotations><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
- <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.FreeTextDescription">
- <text>SCAPE Migration Components that converts any ImageMagick supported image format to TIFF</text>
- </annotationBean>
- <date>2012-11-15 13:07:59.763 UTC</date>
- <creators />
- <curationEventList />
- </net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
- </annotationAssertions>
-</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
- <annotationAssertions>
- <net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
<annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.IdentificationAssertion">
- <identification>fd401dac-c521-4d94-8014-8efeba355d7a</identification>
+ <identification>8d2f9ef0-09ca-4103-b4fd-0ee0a40d8263</identification>
</annotationBean>
- <date>2012-11-19 15:55:14.145 UTC</date>
+ <date>2013-03-06 21:41:51.284 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
@@ -154,32 +262,43 @@
</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
- <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.IdentificationAssertion">
- <identification>22bc577f-9a74-4981-8725-c3b4ac28d88b</identification>
+ <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.SemanticAnnotation">
+ <mimeType>text/rdf+n3</mimeType>
+ <content><> <http://purl.org/DP/components#fits>
+ <http://purl.org/DP/components#MigrationAction> .
+
+<> <http://purl.org/DP/components#migrates>
+ [ a <http://purl.org/DP/components#MigrationPath> ;
+ <http://purl.org/DP/components#fromMimetype>
+ "image/tiff" ;
+ <http://purl.org/DP/components#toMimetype>
+ "image/tiff"
+ ] .
+</content>
</annotationBean>
- <date>2012-11-20 12:10:07.110 UTC</date>
+ <date>2013-03-06 21:41:35.890 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
</annotationAssertions>
-</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
+</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain_2_2><annotation_chain encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
- <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.IdentificationAssertion">
- <identification>052219d1-09ed-4c6b-a5a4-2bad004a10ed</identification>
+ <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.Author">
+ <text>Markus</text>
</annotationBean>
- <date>2012-11-19 16:17:25.295 UTC</date>
+ <date>2013-03-06 15:56:07.430 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
</annotationAssertions>
-</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
+</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
<annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.IdentificationAssertion">
- <identification>5abab48b-a3f0-4f14-9894-e824a2fa5966</identification>
+ <identification>890bb055-628d-42ad-bcee-61077e3e763c</identification>
</annotationBean>
- <date>2012-11-16 16:39:00.691 UTC</date>
+ <date>2013-03-06 16:10:40.753 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
@@ -187,10 +306,10 @@
</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain_2_2><annotation_chain encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
- <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.Author">
- <text>David Withers</text>
+ <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.FreeTextDescription">
+ <text>Converts tiff to tiff using imagemagick convert with the provided compression</text>
</annotationBean>
- <date>2012-11-15 12:25:42.359 UTC</date>
+ <date>2013-03-06 15:56:46.924 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
@@ -199,9 +318,9 @@
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
<annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.IdentificationAssertion">
- <identification>b5361a0e-6abd-4070-8655-5dd7b4237576</identification>
+ <identification>8c741630-ac74-42f2-827a-501fa7e53bd7</identification>
</annotationBean>
- <date>2012-11-15 13:36:38.115 UTC</date>
+ <date>2013-03-06 15:44:03.459 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
@@ -210,9 +329,9 @@
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
<annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.IdentificationAssertion">
- <identification>2bec9695-c132-4728-988c-c3a03ddcc78d</identification>
+ <identification>472b15c2-0b16-4ebd-b865-0c268d5f42b4</identification>
</annotationBean>
- <date>2012-11-15 13:08:31.374 UTC</date>
+ <date>2013-03-06 15:59:49.673 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
@@ -221,9 +340,9 @@
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
<annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.IdentificationAssertion">
- <identification>0d60174b-0d75-481d-8b4d-194c6109bc96</identification>
+ <identification>dfc4edbb-582f-4853-bb47-02b43abd82ee</identification>
</annotationBean>
- <date>2012-11-20 12:17:54.280 UTC</date>
+ <date>2013-03-06 15:49:55.477 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
@@ -231,13 +350,10 @@
</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain_2_2><annotation_chain_2_2 encoding="xstream"><net.sf.taverna.t2.annotation.AnnotationChainImpl xmlns="">
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
- <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.SemanticAnnotation">
- <mimeType>text/rdf+n3</mimeType>
- <content>[] <http://scape-project.eu/pc/vocab/profiles#hasMigrationPath>
- <http://scape-project.eu/pc/vocab/profiles#jpegToTiff> .
-</content>
+ <annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.IdentificationAssertion">
+ <identification>49d15e90-99a8-4970-84b3-5d26d77a1a58</identification>
</annotationBean>
- <date>2012-11-20 12:17:49.904 UTC</date>
+ <date>2013-03-06 19:59:59.809 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
@@ -246,9 +362,9 @@
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
<annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.IdentificationAssertion">
- <identification>16841f82-e1fe-4527-b7ef-411c4c59493b</identification>
+ <identification>6190a4fa-5178-43cf-9b43-dbbc6476ee00</identification>
</annotationBean>
- <date>2012-11-21 11:00:56.248 UTC</date>
+ <date>2013-03-06 15:48:57.814 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
@@ -257,9 +373,9 @@
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
<annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.IdentificationAssertion">
- <identification>a5aee4f0-01d8-4ae3-96f0-c992b8d40af2</identification>
+ <identification>58fc3bb3-9020-4fe5-83db-19fa2e1017e1</identification>
</annotationBean>
- <date>2012-11-15 13:14:14.243 UTC</date>
+ <date>2013-03-06 15:48:25.73 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
@@ -268,11 +384,11 @@
<annotationAssertions>
<net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
<annotationBean class="net.sf.taverna.t2.annotation.annotationbeans.DescriptiveTitle">
- <text>Image to tiff migration action</text>
+ <text>Imagemagick convert - tiff2tiff - compression</text>
</annotationBean>
- <date>2012-11-21 11:00:54.84 UTC</date>
+ <date>2013-03-06 15:56:22.628 UTC</date>
<creators />
<curationEventList />
</net.sf.taverna.t2.annotation.AnnotationAssertionImpl>
</annotationAssertions>
-</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain></annotations></dataflow></workflow>
\ No newline at end of file
+</net.sf.taverna.t2.annotation.AnnotationChainImpl></annotation_chain></annotations></dataflow></workflow>
Deleted: trunk/test/fixtures/semantic_annotations.yml (3548 => 3549)
--- trunk/test/fixtures/semantic_annotations.yml 2013-05-20 10:25:04 UTC (rev 3548)
+++ trunk/test/fixtures/semantic_annotations.yml 2013-05-20 13:46:27 UTC (rev 3549)
@@ -1,36 +0,0 @@
-has_migration_path:
- subject_id: 3
- subject_type: Workflow
- predicate: http://scape-project.eu/pc/vocab/profiles#hasMigrationPath
- object: http://scape-project.eu/pc/vocab/profiles#jpegToTiff
-
-has_dependency:
- subject_id: 1
- subject_type: WorkflowProcessor
- predicate: http://scape-project.eu/pc/vocab/profiles#hasDependency
- object: http://scape-project.eu/pc/vocab/profiles#imagemagick-image2tiff
-
-has_port_type_from:
- subject_id: 1
- subject_type: WorkflowPort
- predicate: http://scape-project.eu/pc/vocab/profiles#hasPortType
- object: http://scape-project.eu/pc/vocab/profiles#FromURIPort
-
-has_port_type_to:
- subject_id: 2
- subject_type: WorkflowPort
- predicate: http://scape-project.eu/pc/vocab/profiles#hasPortType
- object: http://scape-project.eu/pc/vocab/profiles#ToURIPort
-
-has_port_type_from2:
- subject_id: 3
- subject_type: WorkflowPort
- predicate: http://scape-project.eu/pc/vocab/profiles#hasPortType
- object: http://scape-project.eu/pc/vocab/profiles#FromURIPort
-
-second_port_annotation:
- subject_id: 3
- subject_type: WorkflowPort
- predicate: http://scape-project.eu/pc/vocab/profiles#hasFish
- object: http://scape-project.eu/pc/vocab/profiles#CornishSardine
-
Modified: trunk/test/functional/api_controller_test.rb (3548 => 3549)
--- trunk/test/functional/api_controller_test.rb 2013-05-20 10:25:04 UTC (rev 3548)
+++ trunk/test/functional/api_controller_test.rb 2013-05-20 13:46:27 UTC (rev 3549)
@@ -1131,74 +1131,38 @@
assert_response(:not_found)
end
- # component querying
+ # Component querying
- def test_basic_component_query
+ def test_basic_component_query # not a great test, but should pick up any major errors
login_as(:john)
- resp = rest_request(:get, 'components', nil, {"input" => {"0" => '"http://scape-project.eu/pc/vocab/profiles#hasPortType http://scape-project.eu/pc/vocab/profiles#FromURIPort"'}})
-
+ # Check empty
+ resp = rest_request(:get, 'components', nil, {'prefixes' => '', 'query' => ''})
assert_response(:success)
- assert_equal 2, resp.find('//workflow').size
- assert_equal [3,4], resp.find('//workflow').map {|w| w['uri'].split('?id=').last.to_i}
- end
+ assert_equal 0, resp.find('//workflow').size
- def test_two_annotation_component_query
- login_as(:john)
+ # Upload a component workflow
+ license_type = "by-sa"
+ content_type = "application/vnd.taverna.t2flow+xml"
+ content = Base64.encode64(File.read('test/fixtures/files/image_to_tiff_migration.t2flow'))
- anns = '"http://scape-project.eu/pc/vocab/profiles#hasPortType http://scape-project.eu/pc/vocab/profiles#FromURIPort"' +
- ',"http://scape-project.eu/pc/vocab/profiles#hasFish http://scape-project.eu/pc/vocab/profiles#CornishSardine"'
- resp = rest_request(:get, 'components', nil, {"input" => {"0" => anns}})
+ rest_request(:post, 'workflow', "<?xml version='1.0'?>
+ <workflow>
+ <title>Test Component</title>
+ <description>123</description>
+ <license-type>#{license_type}</license-type>
+ <content-type>#{content_type}</content-type>
+ <content>#{content}</content>
+ </workflow>")
assert_response(:success)
- assert_equal 1, resp.find('//workflow').size
- assert_equal 4, resp.find('//workflow').first['uri'].split('?id=').last.to_i
- end
- def test_two_feature_component_query
- login_as(:john)
-
- resp = rest_request(:get, 'components', nil, {'input' => {'0' => '"http://scape-project.eu/pc/vocab/profiles#hasPortType http://scape-project.eu/pc/vocab/profiles#FromURIPort"',
- '1' => '"http://scape-project.eu/pc/vocab/profiles#hasPortType http://scape-project.eu/pc/vocab/profiles#ToURIPort"'}
- })
-
+ # Check result returned
+ resp = rest_request(:get, 'components', nil, {'prefixes' => '', 'query' => ''})
assert_response(:success)
assert_equal 1, resp.find('//workflow').size
- assert_equal 3, resp.find('//workflow').first['uri'].split('?id=').last.to_i
end
- def test_verbose_component_query
- login_as(:john)
-
- resp = rest_request(:get, 'components', nil, {'input' => {'0' => '"http://scape-project.eu/pc/vocab/profiles#hasPortType http://scape-project.eu/pc/vocab/profiles#FromURIPort"',
- '1' => '"http://scape-project.eu/pc/vocab/profiles#hasPortType http://scape-project.eu/pc/vocab/profiles#ToURIPort"'},
- 'processor' => {'0' => '"http://scape-project.eu/pc/vocab/profiles#hasDependency http://scape-project.eu/pc/vocab/profiles#imagemagick-image2tiff"'},
- 'annotations' => '"http://scape-project.eu/pc/vocab/profiles#hasMigrationPath http://scape-project.eu/pc/vocab/profiles#jpegToTiff"'
- })
-
- assert_response(:success)
- assert_equal 1, resp.find('//workflow').size
- assert_equal 3, resp.find('//workflow').first['uri'].split('?id=').last.to_i
- end
-
- def test_component_query_with_filters
- login_as(:john)
-
- resp = rest_request(:get, 'components', nil, {"input" => {"0" => '"http://scape-project.eu/pc/vocab/profiles#hasPortType http://scape-project.eu/pc/vocab/profiles#FromURIPort"'},
- "filter" => 'USER_ID("2")'})
-
- assert_response(:success)
- assert_equal 1, resp.find('//workflow').size
- assert_equal 4, resp.find('//workflow').last['uri'].split('?id=').last.to_i
-
- resp = rest_request(:get, 'components', nil, {"input" => {"0" => '"http://scape-project.eu/pc/vocab/profiles#hasPortType http://scape-project.eu/pc/vocab/profiles#FromURIPort"'},
- "filter" => 'USER_ID("1")'})
-
- assert_response(:success)
- assert_equal 1, resp.find('//workflow').size
- assert_equal 3, resp.find('//workflow').last['uri'].split('?id=').last.to_i
- end
-
private
def rest_request(method, uri, data = "" query = {})
Modified: trunk/test/functional/workflows_controller_test.rb (3548 => 3549)
--- trunk/test/functional/workflows_controller_test.rb 2013-05-20 10:25:04 UTC (rev 3548)
+++ trunk/test/functional/workflows_controller_test.rb 2013-05-20 13:46:27 UTC (rev 3549)
@@ -71,4 +71,31 @@
assert_equal old_count-1, Workflow.count
assert_redirected_to workflows_path
end
+
+ def test_should_store_workflow_rdf
+ login_as(:john)
+
+ # Clear test repo
+ TripleStore.instance.repo = {}
+
+ assert_difference('Workflow.count', 1) do
+ post :create, :workflow => { :file => fixture_file_upload('files/image_to_tiff_migration.t2flow'), :license_id => '1' },
+ :metadata_choice => 'infer',
+ :credits_me => 'false',
+ :credits_users => '',
+ :credits_groups => '',
+ :attributions_workflows => '',
+ :attributions_files => ''
+ end
+
+ # Was it inserted into the triple store on save?
+ assert_equal 1, TripleStore.instance.repo.keys.size
+
+ delete :destroy, :id => assigns(:workflow).id
+
+ # Was it deleted from the triple store on delete?
+ assert_equal 0, TripleStore.instance.repo.keys.size
+
+ TripleStore.instance.repo = {}
+ end
end