Module: OpenTox
- Included in:
- Algorithm, AlgorithmComparisonReport, Compound, Crossvalidation, CrossvalidationReport, Dataset, Feature, Model, QMRFReport, Task, Validation, ValidationReport
- Defined in:
- lib/task.rb,
lib/error.rb,
lib/model.rb,
lib/utils.rb,
lib/parser.rb,
lib/policy.rb,
lib/r-util.rb,
lib/dataset.rb,
lib/feature.rb,
lib/opentox.rb,
lib/to-html.rb,
lib/compound.rb,
lib/ontology.rb,
lib/algorithm.rb,
lib/transform.rb,
lib/serializer.rb,
lib/validation.rb,
lib/authorization.rb,
lib/rest_client_wrapper.rb
Defined Under Namespace
Modules: Algorithm, Authorization, Model, Ontology, Parser, Serializer, Transform Classes: AlgorithmComparisonReport, BadRequestError, Compound, Crossvalidation, CrossvalidationReport, Dataset, ErrorReport, FakeSubTask, Feature, LazarPrediction, NotAuthorizedError, NotFoundError, Policies, Policy, PostAttribute, PostCommand, QMRFReport, RUtil, RestCallError, RestClientWrapper, ServiceUnavailableError, SubTask, Task, Validation, ValidationReport, WrapperResult
Instance Attribute Summary collapse
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#uri ⇒ Object
Returns the value of attribute uri.
Class Method Summary collapse
-
.all(uri, subjectid = nil) ⇒ Array
Get all objects from a service.
- .sign_in(msg = nil) ⇒ Object
-
.text_to_html(text, subjectid = nil, related_links = nil, description = nil, post_command = nil) ⇒ String
produces a html page for making web services browser friendly format of text (=string params) is preserved (e.g. line breaks) urls are marked as links.
Instance Method Summary collapse
- #add_metadata(metadata) ⇒ Object
-
#delete(subjectid = nil) ⇒ Object
deletes the resource, deletion should have worked when no RestCallError raised.
-
#initialize(uri = nil) ⇒ Object
Initialize OpenTox object with optional uri.
-
#load_metadata(subjectid = nil) ⇒ Hash
Load (and return) metadata from object URI.
-
#to_rdfxml ⇒ application/rdf+xml
Get OWL-DL representation in RDF/XML format.
Instance Attribute Details
#metadata ⇒ Object
Returns the value of attribute metadata.
4 5 6 |
# File 'lib/opentox.rb', line 4 def @metadata end |
#uri ⇒ Object
Returns the value of attribute uri.
3 4 5 |
# File 'lib/opentox.rb', line 3 def uri @uri end |
Class Method Details
.all(uri, subjectid = nil) ⇒ Array
Get all objects from a service
22 23 24 |
# File 'lib/opentox.rb', line 22 def self.all(uri, subjectid=nil) RestClientWrapper.get(uri,:accept => "text/uri-list", :subjectid => subjectid).to_s.split(/\n/) end |
.sign_in(msg = nil) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/to-html.rb', line 59 def self.sign_in( msg=nil ) html = "<html><title>Login</title><img src="+OT_LOGO+"><body>" html += "<form method='POST' action='"+$url_provider.url_for("/sign_in",:full)+"'>" html += "<pre><p style=\"padding:15px; border:10px solid \#5D308A\">" html += msg+"\n\n" if msg html += "Please sign in to "+$url_provider.request.host.to_s+"\n\n" html += "<table border=0>" html += "<tr><td>user:</td><td><input type='text' name='user' size='15' /></td></tr>"+ "<tr><td>password:</td><td><input type='password' name='password' size='15' /></td></tr>"+ #"<input type=hidden name=back_to value="+back_to.to_s+">"+ "<tr><td><input type='submit' value='Sign in' /></td></tr>" html += "</table></p></pre></form></body></html>" html end |
.text_to_html(text, subjectid = nil, related_links = nil, description = nil, post_command = nil) ⇒ String
produces a html page for making web services browser friendly format of text (=string params) is preserved (e.g. line breaks) urls are marked as links
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/to-html.rb', line 24 def self.text_to_html( text, subjectid=nil, =nil, description=nil, post_command=nil ) # TODO add title as parameter title = nil #$sinatra.url_for($sinatra.request.env['PATH_INFO'], :full) if $sinatra html = "<html>" html += "<title>"+title+"</title>" if title html += "<img src=\""+OT_LOGO+"\"><\/img><body>" if AA_SERVER user = OpenTox::Authorization.get_user(subjectid) if subjectid html += "<pre><p align=\"right\">" unless user html += "You are currently not signed in to "+$url_provider.request.host.to_s+ ", <a href="+$url_provider.url_for("/sign_in",:full)+">sign in</a>" else html += "You are signed in as '#{user}' to "+$url_provider.request.host.to_s+ ", <a href="+$url_provider.url_for("/sign_out",:full)+">sign out</a>" end html += " </p></pre>" end html += "<h3>Description</h3><pre><p>"+description.link_urls+"</p></pre>" if description html += "<h3>Related links</h3><pre><p>"+.link_urls+"</p></pre>" if if post_command raise "not a post command" unless post_command.is_a?(OpenTox::PostCommand) html += "<h3>POST command</h3>" html += post_command.to_html end html += "<h3>Content</h3>" if description || || post_command html += "<pre><p style=\"padding:15px; border:10px solid \#5D308A\">" html += text.link_urls html += "</p></pre></body></html>" html end |
Instance Method Details
#add_metadata(metadata) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/opentox.rb', line 33 def () if !.nil? .each do |k,v| if v.is_a? Array @metadata[k] = [] unless @metadata[k] @metadata[k] << v else @metadata[k] = v end end end end |
#delete(subjectid = nil) ⇒ Object
deletes the resource, deletion should have worked when no RestCallError raised
55 56 57 |
# File 'lib/opentox.rb', line 55 def delete(subjectid=nil) RestClientWrapper.delete(uri,:subjectid => subjectid) end |
#initialize(uri = nil) ⇒ Object
Initialize OpenTox object with optional uri
8 9 10 11 |
# File 'lib/opentox.rb', line 8 def initialize(uri=nil) @metadata = {} self.uri = uri if uri end |
#load_metadata(subjectid = nil) ⇒ Hash
Load (and return) metadata from object URI
28 29 30 31 |
# File 'lib/opentox.rb', line 28 def (subjectid=nil) @metadata = Parser::Owl::Generic.new(@uri).(subjectid) @metadata end |
#to_rdfxml ⇒ application/rdf+xml
Get OWL-DL representation in RDF/XML format
48 49 50 51 52 53 54 55 |
# File 'lib/feature.rb', line 48 def to_rdfxml s = Serializer::Owl.new s.add_feature(@uri,@metadata) @metadata.values.grep(/model\/\d+$/).each{ |m| s.add_uri(m,OT.Model)} @metadata.values.grep(/feature/).each{ |f| s.add_uri(f,OT.Feature)} #s.add_parameters(@uri,@parameters) if @parameters s.to_rdfxml end |