summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2011-01-24 19:35:36 +0100
committermguetlein <martin.guetlein@gmail.com>2011-01-24 19:35:36 +0100
commit8cfe8ad608e59d3536cd5403a70743a51cb901ee (patch)
tree67b16a5f6e2faf8866fd4cd0d2d8290a555c724b /lib
parent59dba52a30de35da0122cd6c25777573faa5ffc3 (diff)
fix task to rdf
Diffstat (limited to 'lib')
-rw-r--r--lib/error.rb18
-rw-r--r--lib/overwrite.rb2
-rw-r--r--lib/serializer.rb11
-rw-r--r--lib/task.rb7
4 files changed, 32 insertions, 6 deletions
diff --git a/lib/error.rb b/lib/error.rb
index 8a57bd0..d3fd19b 100644
--- a/lib/error.rb
+++ b/lib/error.rb
@@ -40,13 +40,27 @@ module OpenTox
@errorCause = error.errorCause if error.errorCause
@rest_params = error.rest_params if error.is_a?(OpenTox::RestCallError) and error.rest_params
end
+
+ def rdf_content()
+ c = {
+ RDF.type => OT.ErrorReport,
+ OT.statusCode => @http_code,
+ OT.message => @message,
+ OT.actor => @actor,
+ OT.errorCode => @errorType,
+ }
+ c[OT.errorCause] = @errorCause.rdf_content if @errorCause
+ c
+ end
def self.from_rdf(rdf)
raise "not yet implemented"
end
- def self.to_rdf
- raise "not yet implemented"
+ def to_rdfxml
+ s = Serializer::Owl.new
+ s.add_resource(CONFIG[:services]["opentox-task"]+"/tmpId/ErrorReport/tmpId", OT.errorReport, rdf_content)
+ s.to_rdfxml
end
end
end \ No newline at end of file
diff --git a/lib/overwrite.rb b/lib/overwrite.rb
index 4fa0829..e52618c 100644
--- a/lib/overwrite.rb
+++ b/lib/overwrite.rb
@@ -27,7 +27,7 @@ error Exception do
case request.env['HTTP_ACCEPT']
when /rdf/
content_type 'application/rdf+xml'
- halt error.http_code,rep.to_xml
+ halt error.http_code,rep.to_rdfxml
when /html/
content_type 'text/html'
halt error.http_code,(OpenTox.text_to_html rep.to_yaml)
diff --git a/lib/serializer.rb b/lib/serializer.rb
index 03c2639..44b4414 100644
--- a/lib/serializer.rb
+++ b/lib/serializer.rb
@@ -14,7 +14,7 @@ module OpenTox
def initialize
@object = {
- # this should come from opntox.owl
+ # this should come from opentox.owl
OT.Compound => { RDF["type"] => [{ "type" => "uri", "value" => OWL['Class'] }] } ,
OT.Feature => { RDF["type"] => [{ "type" => "uri", "value" => OWL['Class'] }] } ,
OT.NominalFeature => { RDF["type"] => [{ "type" => "uri", "value" => OWL['Class'] }] } ,
@@ -35,6 +35,7 @@ module OpenTox
OT.RegressionStatistics => { RDF["type"] => [{ "type" => "uri", "value" => OWL['Class'] }] } ,
OT.Crossvalidation => { RDF["type"] => [{ "type" => "uri", "value" => OWL['Class'] }] } ,
OT.CrossvalidationInfo => { RDF["type"] => [{ "type" => "uri", "value" => OWL['Class'] }] } ,
+ OT.ErrorReport => { RDF["type"] => [{ "type" => "uri", "value" => OWL['Class'] }] } ,
OT.compound => { RDF["type"] => [{ "type" => "uri", "value" => OWL.ObjectProperty }] } ,
OT.feature => { RDF["type"] => [{ "type" => "uri", "value" => OWL.ObjectProperty }] } ,
@@ -113,6 +114,10 @@ module OpenTox
OT.numFolds => { RDF["type"] => [{ "type" => "uri", "value" => OWL.AnnotationProperty }] } ,
OT.randomSeed => { RDF["type"] => [{ "type" => "uri", "value" => OWL.AnnotationProperty }] } ,
OT.reportType => { RDF["type"] => [{ "type" => "uri", "value" => OWL.AnnotationProperty }] } ,
+ OT.message => { RDF["type"] => [{ "type" => "uri", "value" => OWL.AnnotationProperty }] } ,
+ OT.statusCode => { RDF["type"] => [{ "type" => "uri", "value" => OWL.AnnotationProperty }] } ,
+ OT.actor => { RDF["type"] => [{ "type" => "uri", "value" => OWL.AnnotationProperty }] } ,
+ OT.errorCode => { RDF["type"] => [{ "type" => "uri", "value" => OWL.AnnotationProperty }] } ,
OT.hasSource => { RDF["type"] => [{ "type" => "uri", "value" => OWL.DatatypeProperty }] } ,
OT.value => { RDF["type"] => [{ "type" => "uri", "value" => OWL.DatatypeProperty }] } ,
@@ -229,10 +234,10 @@ module OpenTox
@object[uri] = {} unless @object[uri]
@object[uri][u] = [{ "type" => "bnode", "value" => genid }]
# add content to new class
- add_hash(genid,v)
+ add_content(genid,v)
elsif v.is_a? Array
# value is an array, i.e. a list of values with property is added
- v.each{ |vv| add_hash( uri, { u => vv } ) }
+ v.each{ |vv| add_content( uri, { u => vv } ) }
else # v.is_a? String
# simple string value
@object[uri] = {} unless @object[uri]
diff --git a/lib/task.rb b/lib/task.rb
index 06d290f..4d1ee90 100644
--- a/lib/task.rb
+++ b/lib/task.rb
@@ -102,7 +102,9 @@ module OpenTox
def to_rdfxml
s = Serializer::Owl.new
+ @metadata[OT.errorReport] = @uri+"/ErrorReport/tmpId" if @error_report
s.add_task(@uri,@metadata)
+ s.add_resource(@uri+"/ErrorReport/tmpId", OT.errorReport, @error_report.rdf_content) if @error_report
s.to_rdfxml
end
@@ -138,6 +140,11 @@ module OpenTox
load_metadata
end
+ # not stored just for to_rdf
+ def add_error_report( error_report )
+ @error_report = error_report
+ end
+
def pid=(pid)
RestClientWrapper.put(File.join(@uri,'pid'), {:pid => pid})
end