Class: RDFObject::Store
- Inherits:
-
Pho::Store
- Object
- Pho::Store
- RDFObject::Store
- Defined in:
- lib/rdf_objects/pho/store.rb
Instance Method Summary collapse
- #augment(data) ⇒ Object
- #describe(uri, format = "text/plain", etags = nil, if_match = false) ⇒ Object
- #get_field_predicate_map(output = ::Pho::ACCEPT_JSON) ⇒ Object
- #get_indexes ⇒ Object
- #get_job(uri) ⇒ Object
- #get_jobs ⇒ Object
- #get_query_profile(output = ::Pho::ACCEPT_JSON) ⇒ Object
- #put_field_predicate_map(fpmap) ⇒ Object
- #put_query_profile(qp) ⇒ Object
- #search(query, params = nil) ⇒ Object
- #set_indexes(index_set) ⇒ Object
- #sparql_construct(query, format = "application/rdf+xml", multisparql = false) ⇒ Object
- #sparql_describe(query, format = "application/rdf+xml", multisparql = false) ⇒ Object
- #store_object(rdf_object, depth = 0, graph_name = nil) ⇒ Object
- #submit_changeset(rdf, versioned = false, graph_name = nil) ⇒ Object
Instance Method Details
#augment(data) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rdf_objects/pho/store.rb', line 15 def augment(data) d = case data.class.name when "String" then data when "RDFObject::Resource" then data.to_rss when "RDFObject::Collection" then data.to_rss else raise ArgumentError, "Argument 'data' must be an RSS 1.0 formatted string, RDFObject::Resource or RDFObject::Collection" end response = super(d) response.extend ::RDFObject::StoreResponse search_resource = response.collection.find_by_predicate_and_object("http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://purl.org/rss/1.0/channel") search_resource.keys.each do |uri| if uri =~ /http:\/\/api\.talis\.com\/stores/ response.resource = search_resource[uri] end end return response end |
#describe(uri, format = "text/plain", etags = nil, if_match = false) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/rdf_objects/pho/store.rb', line 33 def describe(uri, format="text/plain", =nil, if_match=false) response = super(uri, format, , if_match) response.extend ::RDFObject::StoreResponse response.resource = response.collection[uri] return response end |
#get_field_predicate_map(output = ::Pho::ACCEPT_JSON) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/rdf_objects/pho/store.rb', line 40 def get_field_predicate_map(output=::Pho::ACCEPT_JSON) u = build_uri("/config/fpmaps/1") response = super(output) response.extend ::RDFObject::StoreResponse response.resource = response.collection[u] return response end |
#get_indexes ⇒ Object
48 49 50 51 52 |
# File 'lib/rdf_objects/pho/store.rb', line 48 def get_indexes fp_map_resp = get_field_predicate_map qp_resp = get_query_profile RDFObject::IndexSet.new_from_response(fp_map_resp.resource, qp_resp.resource) end |
#get_job(uri) ⇒ Object
61 62 63 64 65 |
# File 'lib/rdf_objects/pho/store.rb', line 61 def get_job(uri) response = super(uri) response.extend ::RDFObject::StoreResponse response.resource = response.collection[uri] end |
#get_jobs ⇒ Object
67 68 69 70 71 |
# File 'lib/rdf_objects/pho/store.rb', line 67 def get_jobs response = super response.extend ::RDFObject::StoreResponse response end |
#get_query_profile(output = ::Pho::ACCEPT_JSON) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/rdf_objects/pho/store.rb', line 73 def get_query_profile(output=::Pho::ACCEPT_JSON) u = build_uri("/config/queryprofiles/1") response = super(output) response.extend ::RDFObject::StoreResponse response.resource = response.collection[u] response end |
#put_field_predicate_map(fpmap) ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rdf_objects/pho/store.rb', line 81 def put_field_predicate_map(fpmap) if fpmap.is_a?(RDFObject::Resource) rdf = fpmap.to_xml(4) elsif fpmap.is_a?(String) rdf = fpmap end u = build_uri("/config/fpmaps/1") headers = {"Content-Type" => "application/rdf+xml"} return @client.put(u, rdf, headers) end |
#put_query_profile(qp) ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/rdf_objects/pho/store.rb', line 92 def put_query_profile(qp) if qp.is_a?(RDFObject::Resource) rdf = qp.to_xml(4) elsif qp.is_a?(String) rdf = qp end u = build_uri("/config/queryprofiles/1") headers = {"Content-Type" => "application/rdf+xml"} return @client.put(u, rdf, headers) end |
#search(query, params = nil) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/rdf_objects/pho/store.rb', line 103 def search(query, params=nil) response = super(query, params) response.extend ::RDFObject::StoreResponse search_resource = response.collection.find_by_predicate_and_object("http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://purl.org/rss/1.0/channel") search_resource.keys.each do |uri| if uri =~ /http:\/\/api\.talis\.com\/stores/ response.resource = search_resource[uri] end end return response end |
#set_indexes(index_set) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/rdf_objects/pho/store.rb', line 54 def set_indexes(index_set) index_set.set_store(@storeuri) put_field_predicate_map(index_set.to_fpmap) put_query_profile(index_set.to_qp) get_indexes end |
#sparql_construct(query, format = "application/rdf+xml", multisparql = false) ⇒ Object
115 116 117 118 119 |
# File 'lib/rdf_objects/pho/store.rb', line 115 def sparql_construct(query, format="application/rdf+xml", multisparql=false) response = super(query, format, multisparql) response.extend ::RDFObject::StoreResponse response end |
#sparql_describe(query, format = "application/rdf+xml", multisparql = false) ⇒ Object
121 122 123 124 125 |
# File 'lib/rdf_objects/pho/store.rb', line 121 def sparql_describe(query, format="application/rdf+xml", multisparql=false) response = super(query, format, multisparql) response.extend ::RDFObject::StoreResponse response end |
#store_object(rdf_object, depth = 0, graph_name = nil) ⇒ Object
127 128 129 130 131 132 |
# File 'lib/rdf_objects/pho/store.rb', line 127 def store_object(rdf_object, depth=0, graph_name=nil) unless rdf_object.is_a?(RDFObject::Node) || rdf_object.is_a?(RDFObject::Collection) raise ArgumentError, "Argument must be a RDFObject::Node or RDFObject::Collection" end store_data(rdf_object.to_xml(depth), graph_name) end |
#submit_changeset(rdf, versioned = false, graph_name = nil) ⇒ Object
134 135 136 137 138 139 140 141 142 143 |
# File 'lib/rdf_objects/pho/store.rb', line 134 def submit_changeset(rdf, versioned=false, graph_name=nil) unless rdf.is_a?(String) or rdf.is_a?(RDFObject::ChangeSet) raise ArgumentError, "Argument 'rdf' must be a String or RDFObject::ChangeSet" end data = case rdf.class.name when "String" then rdf else rdf.to_xml end super(data, versioned, graph_name) end |