blob: c76e21a2f06fa24d492f16693f4c2a812a2cc788 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
58
59
|
module OpenTox
attr_reader :uri
attr_accessor :metadata
# Initialize OpenTox object with optional uri
# @param [optional, String] URI
def initialize(uri=nil)
@metadata = {}
self.uri = uri if uri
end
# Set URI
# @param [String] URI
def uri=(uri)
@uri = uri
@metadata[XSD.anyURI] = uri
end
# Get all objects from a service
# @return [Array] List of available URIs
def self.all(uri, subjectid=nil)
RestClientWrapper.get(uri,:accept => "text/uri-list", :subjectid => subjectid).to_s.split(/\n/)
end
# Load (and return) metadata from object URI
# @return [Hash] Metadata
def load_metadata(subjectid=nil)
@metadata = Parser::Owl::Generic.new(@uri).load_metadata(subjectid)
@metadata
end
def add_metadata(metadata)
metadata.each do |k,v|
if v.is_a? Array
@metadata[k] = [] unless @metadata[k]
@metadata[k] << v
else
@metadata[k] = v
end
end
end
# Get OWL-DL representation in RDF/XML format
# @return [application/rdf+xml] RDF/XML representation
def to_rdfxml
s = Serializer::Owl.new
s.add_metadata(@uri,@metadata)
#s.add_parameters(@uri,@parameters) if @parameters
s.to_rdfxml
end
# deletes the resource, deletion should have worked when no RestCallError raised
def delete(subjectid=nil)
RestClientWrapper.delete(uri,:subjectid => subjectid)
end
end
|