diff options
author | Christoph Helma <helma@in-silico.ch> | 2012-03-14 10:15:36 +0000 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2012-03-14 10:15:36 +0000 |
commit | d657955ef09c69ce66e2eda3a03dbf4b87461915 (patch) | |
tree | d935d03e532a8a4e37c2fe4edade635d02639bd4 /lib | |
parent | 625c88673e90053f898423dfc96bda1d6c0fa8eb (diff) |
Fallback for OpenTox class if URI is ambiguous
Diffstat (limited to 'lib')
-rw-r--r-- | lib/opentox-client.rb | 2 | ||||
-rw-r--r-- | lib/opentox.rb | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/opentox-client.rb b/lib/opentox-client.rb index 7d9329d..e68fd7f 100644 --- a/lib/opentox-client.rb +++ b/lib/opentox-client.rb @@ -14,7 +14,7 @@ RDF::OT1 = RDF::Vocabulary.new 'http://www.opentox.org/api/1.1#' RDF::OTA = RDF::Vocabulary.new 'http://www.opentox.org/algorithmTypes.owl#' #CLASSES = ["Compound", "Feature", "Dataset", "Algorithm", "Model", "Validation", "Task", "ErrorReport", "Investigation"] -CLASSES = ["Compound", "Feature", "Dataset", "Algorithm", "Model", "Validation", "Task", "Investigation"] +CLASSES = ["Generic", "Compound", "Feature", "Dataset", "Algorithm", "Model", "Validation", "Task", "Investigation"] RDF_FORMATS = [:rdfxml,:ntriples,:turtle] $default_rdf = "application/rdf+xml" diff --git a/lib/opentox.rb b/lib/opentox.rb index 342b04e..944eda5 100644 --- a/lib/opentox.rb +++ b/lib/opentox.rb @@ -125,8 +125,12 @@ module OpenTox # guess class from uri, this is potentially unsafe, but polling metadata from large uri lists is way too slow (and not all service provide RDF.type in their metadata) result = CLASSES.collect{|s| s if uri =~ /#{s.downcase}/}.compact - internal_server_error "Cannot determine class from URI: '#{uri}.\nCandidate classes are #{result.inspect}" unless result.size == 1 - klass = result.first + if result.size == 1 + klass = result.first + else + klass = OpenTox::Generic.new(uri)[RDF.type] + internal_server_error "Cannot determine class from URI '#{uri} (Candidate classes are #{result.inspect}) or matadata." unless klass + end # initialize with/without subjectid subjectid ? eval("#{self}.new(\"#{uri}\", #{subjectid})") : eval("#{self}.new(\"#{uri}\")") end |