From 9119cb4f3fbcedb5c233b0a1f3fe1398fcc0e193 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 28 Jun 2012 12:24:52 +0000 Subject: modified assignment operator --- lib/opentox.rb | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'lib/opentox.rb') 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 -- cgit v1.2.3