summaryrefslogtreecommitdiff
path: root/lib/opentox.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2012-06-28 12:24:52 +0000
committerChristoph Helma <helma@in-silico.ch>2012-06-28 12:24:52 +0000
commit9119cb4f3fbcedb5c233b0a1f3fe1398fcc0e193 (patch)
treed94ab6e2629454d17d0605439ac23665444c98cb /lib/opentox.rb
parent5f61cefdefc51a728147478820ffe04c5ec127d5 (diff)
modified assignment operator
Diffstat (limited to 'lib/opentox.rb')
-rw-r--r--lib/opentox.rb24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/opentox.rb b/lib/opentox.rb
index f79b51b..6df16fa 100644
--- a/lib/opentox.rb
+++ b/lib/opentox.rb
@@ -46,11 +46,22 @@ module OpenTox
result
end
+ def []=(key,value)
+ uri = RDF::URI.new(@uri)
+ #@rdf.delete [uri,key,nil]
+ #result = @rdf.query([RDF::URI.new(@uri),key,nil]).collect{|statement| statement.object}
+ @rdf << [uri, key, value]
+ end
+
+ #def []<<(key,value)
+ #@rdf << [RDF::URI.new(@uri), key, value]
+ #end
+
# Save object at service
def save
put self.to_ntriples, { :content_type => "text/plain"}
- rescue # fall back to rdfxml
- put self.to_rdfxml, { :content_type => "application/rdf+xml"}
+ #rescue # fall back to rdfxml
+ #put self.to_rdfxml, { :content_type => "application/rdf+xml"}
end
RDF_FORMATS.each do |format|
@@ -113,8 +124,15 @@ module OpenTox
end
def create service_uri, subjectid=nil
+ bnode = RDF::Node.new
+ klass = "RDF::OT."+self.class.to_s.split('::').last
+ #puts self.class
+ #puts klass
+ #object = eval "#{~
+ @rdf << [bnode, RDF.type, klass]
#uri = File.join(service_uri,SecureRandom.uuid)
- uri = RestClientWrapper.post(service_uri, {}, {:accept => 'text/uri-list', :subjectid => subjectid})
+ uri = RestClientWrapper.post(service_uri, self.to_ntriples, {:content_type => 'text/plain', :accept => 'text/uri-list', :subjectid => subjectid})
+ #uri = RestClientWrapper.put(uri, {}, {:accept => 'text/uri-list', :subjectid => subjectid})
URI.task?(service_uri) ? from_uri(uri, subjectid, false) : from_uri(uri, subjectid)
end