Class: Puree::Dataset
Overview
Dataset resource
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#access ⇒ String
Open access permission.
-
#associated ⇒ Array<Hash>
Combines project and publication.
-
#available ⇒ Hash
Date made available.
-
#description ⇒ String
Description.
-
#doi ⇒ String
Digital Object Identifier.
-
#file ⇒ Array<Hash>
Supporting file.
-
#geographical ⇒ Array<String>
Geographical coverage.
-
#initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil) ⇒ Dataset
constructor
A new instance of Dataset.
-
#keyword ⇒ Array<String>
Keyword.
-
#link ⇒ Array<Hash>
Link.
-
#metadata ⇒ Hash
All metadata.
-
#organisation ⇒ Array<Hash>
Organisation.
-
#owner ⇒ Hash
Owner.
-
#person ⇒ Array<Hash>
Person (internal, external, other).
-
#production ⇒ Hash
Date of data production.
-
#project ⇒ Array<Hash>
Project.
-
#publication ⇒ Array<Hash>
Publication.
-
#publisher ⇒ String
Publisher.
-
#temporal ⇒ Hash
Temporal coverage.
-
#title ⇒ String
Title.
Methods inherited from Resource
#content, #created, #get, #modified, #set_content, #uuid
Constructor Details
#initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil) ⇒ Dataset
Returns a new instance of Dataset.
11 12 13 14 15 16 17 |
# File 'lib/puree/dataset.rb', line 11 def initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil) super(api: :dataset, endpoint: endpoint, username: username, password: password, basic_auth: basic_auth) end |
Instance Method Details
#access ⇒ String
Open access permission
215 216 217 218 |
# File 'lib/puree/dataset.rb', line 215 def access path = '/openAccessPermission/term/localizedString' xpath_query_for_single_value path end |
#associated ⇒ Array<Hash>
Combines project and publication
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/puree/dataset.rb', line 60 def associated path = '/associatedContent//relatedContent' xpath_result = xpath_query path data_arr = [] xpath_result.each { |i| data = {} data['type'] = i.xpath('typeClassification').text.strip data['title'] = i.xpath('title').text.strip data['uuid'] = i.attr('uuid').strip data_arr << data } data_arr.uniq end |
#available ⇒ Hash
Date made available
180 181 182 |
# File 'lib/puree/dataset.rb', line 180 def available temporal_start_date 'dateMadeAvailable' end |
#description ⇒ String
Description
116 117 118 119 |
# File 'lib/puree/dataset.rb', line 116 def description path = '/descriptions/classificationDefinedField/value/localizedString' xpath_query_for_single_value path end |
#doi ⇒ String
Digital Object Identifier
257 258 259 260 |
# File 'lib/puree/dataset.rb', line 257 def doi path = '/doi' xpath_query_for_single_value path end |
#file ⇒ Array<Hash>
Supporting file
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/puree/dataset.rb', line 224 def file path = '/documents/document' xpath_result = xpath_query path docs = [] xpath_result.each do |d| doc = {} # doc['id'] = f.xpath('id').text.strip doc['name'] = d.xpath('fileName').text.strip doc['mime'] = d.xpath('mimeType').text.strip doc['size'] = d.xpath('size').text.strip doc['url'] = d.xpath('url').text.strip doc['title'] = d.xpath('title').text.strip # doc['createdDate'] = d.xpath('createdDate').text.strip # doc['visibleOnPortalDate'] = d.xpath('visibleOnPortalDate').text.strip # doc['limitedVisibility'] = d.xpath('limitedVisibility').text.strip license = {} license_name = d.xpath('documentLicense/term/localizedString').text.strip license['name'] = license_name license_url = d.xpath('documentLicense/description/localizedString').text.strip license['url'] = license_url doc['license'] = license docs << doc end docs.uniq end |
#geographical ⇒ Array<String>
Geographical coverage
187 188 189 190 191 192 193 194 195 |
# File 'lib/puree/dataset.rb', line 187 def geographical path = '/geographicalCoverage/localizedString' xpath_result = xpath_query path data = [] xpath_result.each do |i| data << i.text.strip end data end |
#keyword ⇒ Array<String>
Keyword
106 107 108 109 110 111 |
# File 'lib/puree/dataset.rb', line 106 def keyword path = '/keywordGroups/keywordGroup/keyword/userDefinedKeyword/freeKeyword' xpath_result = xpath_query path data_arr = xpath_result.map { |i| i.text.strip } data_arr.uniq end |
#link ⇒ Array<Hash>
Link
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/puree/dataset.rb', line 23 def link path = '/links/link' xpath_result = xpath_query path data = [] xpath_result.each { |i| o = {} o['url'] = i.xpath('url').text.strip o['description'] = i.xpath('description').text.strip data << o } data.uniq end |
#metadata ⇒ Hash
All metadata
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/puree/dataset.rb', line 271 def o = super o['access'] = access o['associated'] = associated o['available'] = available o['description'] = description o['doi'] = doi o['file'] = file o['geographical'] = geographical o['keyword'] = keyword o['link'] = link o['organisation'] = organisation o['owner'] = owner o['person'] = person o['project'] = project o['production'] = production o['publication'] = publication o['publisher'] = publisher o['temporal'] = temporal o['title'] = title o end |
#organisation ⇒ Array<Hash>
Organisation
124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/puree/dataset.rb', line 124 def organisation path = '/organisations/organisation' xpath_result = xpath_query path data = [] xpath_result.each do |i| o = {} o['uuid'] = i.xpath('@uuid').text.strip o['name'] = i.xpath('name/localizedString').text.strip o['type'] = i.xpath('typeClassification/term/localizedString').text.strip data << o end data end |
#owner ⇒ Hash
Owner
39 40 41 42 43 44 45 46 47 |
# File 'lib/puree/dataset.rb', line 39 def owner path = '/managedBy' xpath_result = xpath_query path o = {} o['uuid'] = xpath_result.xpath('@uuid').text.strip o['name'] = xpath_result.xpath('name/localizedString').text.strip o['type'] = xpath_result.xpath('typeClassification/term/localizedString').text.strip o end |
#person ⇒ Array<Hash>
Person (internal, external, other)
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/puree/dataset.rb', line 141 def person data = {} # internal path = '/persons/dataSetPersonAssociation' xpath_result = xpath_query path internal = [] external = [] other = [] xpath_result.each do |i| o = {} name = {} name['first'] = i.xpath('name/firstName').text.strip name['last'] = i.xpath('name/lastName').text.strip o['name'] = name o['role'] = i.xpath('personRole/term/localizedString').text.strip uuid_internal = i.at_xpath('person/@uuid') uuid_external = i.at_xpath('externalPerson/@uuid') if uuid_internal o['uuid'] = uuid_internal internal << o elsif uuid_external o['uuid'] = uuid_external external << o else other << o o['uuid'] = '' end end data['internal'] = internal data['external'] = external data['other'] = other data end |
#production ⇒ Hash
Date of data production
200 201 202 |
# File 'lib/puree/dataset.rb', line 200 def production temporal_range 'dateOfDataProduction', 'endDateOfDataProduction' end |
#project ⇒ Array<Hash>
Project
77 78 79 |
# File 'lib/puree/dataset.rb', line 77 def project associated_type('Research').uniq end |
#publication ⇒ Array<Hash>
Publication
84 85 86 87 88 89 90 91 92 |
# File 'lib/puree/dataset.rb', line 84 def publication data_arr = [] associated.each do |i| if i['type'] != 'Research' data_arr << i end end data_arr.uniq end |
#publisher ⇒ String
Publisher
52 53 54 55 |
# File 'lib/puree/dataset.rb', line 52 def publisher path = '/publisher/name' xpath_query_for_single_value path end |
#temporal ⇒ Hash
Temporal coverage
208 209 210 |
# File 'lib/puree/dataset.rb', line 208 def temporal temporal_range 'temporalCoverageStartDate', 'temporalCoverageEndDate' end |
#title ⇒ String
Title
98 99 100 101 |
# File 'lib/puree/dataset.rb', line 98 def title path = '/title/localizedString' xpath_query_for_single_value path end |