summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xapplication.rb34
1 files changed, 22 insertions, 12 deletions
diff --git a/application.rb b/application.rb
index f6dc140..139c867 100755
--- a/application.rb
+++ b/application.rb
@@ -1,5 +1,5 @@
require 'rubygems'
-gem "opentox-ruby-api-wrapper", "= 1.6.5"
+gem "opentox-ruby-api-wrapper", "= 1.6.6"
require 'opentox-ruby-api-wrapper'
class Dataset
@@ -13,15 +13,24 @@ class Dataset
def to_owl
data = YAML.load(yaml)
- owl = OpenTox::Owl.create 'Dataset', uri
- owl.set "title", data.title
- owl.set "creator", data.creator
+ beginning = Time.now
+ owl = OpenTox::OwlSerializer.create 'Dataset', uri
+ owl.annotation_property uri, DC.title, data.title, XSD.string
+ owl.annotation_property uri, DC.creator, data.creator, XSD.string if data.creator
if data.compounds
data.compounds.each do |compound|
- owl.add_data_entries compound,data.data[compound]
+ owl.object_property uri, OT.compound, compound, XSD.anyUri
end
end
- owl.rdf
+ if data.features
+ data.features.each do |feature|
+ owl.object_property uri, OT.feature, feature, XSD.anyUri
+ end
+ end
+ #TODO: add data entries
+ nt = owl.rdf
+ LOGGER.debug "OWL creation took #{Time.now - beginning} seconds"
+ nt
end
end
@@ -61,7 +70,7 @@ def get_dataset( params, request, response, only_metadata=false )
raise e.message + e.backtrace
halt 404, "Dataset #{params[:id]} not found."
end
- halt 404, "Dataset #{params[:id]} not found." if dataset.nil? # not sure how an empty cataset can be returned, but if this happens stale processes keep runing at 100% cpu
+ halt 404, "Dataset #{params[:id]} not found." if dataset.nil? # not sure how an empty dataset can be returned, but if this happens stale processes keep runing at 100% cpu
if only_metadata # remove compounds and feature data from yaml
d = YAML.load(dataset.yaml)
@@ -77,11 +86,12 @@ def get_dataset( params, request, response, only_metadata=false )
if only_metadata
dataset.to_owl
else
- unless dataset.owl # lazy owl creation
- dataset.owl = dataset.to_owl
- dataset.save
- end
- dataset.owl
+ #unless dataset.owl # lazy owl creation
+ #dataset.owl = dataset.to_owl
+ #dataset.save
+ #end
+ #dataset.owl
+ dataset.to_owl
end
when /yaml/
response['Content-Type'] = 'application/x-yaml'