linked_research_metadata 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7c1a8e70e56d0e27192ea504c47611805d45d4b9
4
+ data.tar.gz: 496d1fb8a316cc68e05ee2a310bd94a83b9a600e
5
+ SHA512:
6
+ metadata.gz: d907f9dd473fe7ea2248c2e28bddd92f66be1fce737da20ae75f5a9a11facc108d9c3ed203ec78b7c11ff0544973398ac6f5ed2c11d705e8f95835b529c8202e
7
+ data.tar.gz: b71ef79fbe3cfcf6355991948669119b886b6ab896a60258a86b1d7c3981d7aa6b79e5b2f778e3484d05f5f55626fd313594b9e11077ee1c8b0f978926e465ae
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semver.org/).
4
+
5
+ ## Unreleased
6
+
7
+ ## 0.1.0 - 2017-06-30
8
+ ### Added
9
+ - Working product supports datasets.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in linked_research_metadata.gemspec
4
+ gemspec
data/MODEL.md ADDED
@@ -0,0 +1,69 @@
1
+ # Data Model
2
+ Version 0.1.0
3
+
4
+ ## Prefixes
5
+ Prefix | URI
6
+ --- | ---
7
+ dcterms | http://purl.org/dc/terms/
8
+ foaf | http://xmlns.com/foaf/0.1/
9
+ mads | http://www.loc.gov/mads/rdf/v1#
10
+ owl | http://www.w3.org/2002/07/owl#
11
+ premis | http://www.loc.gov/premis/rdf/v1#
12
+ rdf | http://www.w3.org/1999/02/22-rdf-syntax-ns#
13
+ swpo | http://sw-portal.deri.org/ontologies/swportal#
14
+ vivo | http://vivoweb.org/ontology/core#
15
+ xsd | http://www.w3.org/2001/XMLSchema#
16
+
17
+ ## Resources
18
+
19
+ ### Dataset
20
+ Property | Value | Cardinality
21
+ --- | --- | ---
22
+ dcterms:available | xsd:date | 1
23
+ dcterms:created | xsd:date | 1
24
+ dcterms:creator | URI | 1..n
25
+ dcterms:contributor | URI | 0..n
26
+ dcterms:description | Literal (String) | 0..1
27
+ dcterms:hasPart | URI | 0..n
28
+ dcterms:identifier | URI. DOI. | 0..1
29
+ dcterms:relation | URI | 0..n
30
+ dcterms:spatial | Literal (String) | 0..n
31
+ dcterms:subject | Literal (String) | 0..n
32
+ dcterms:temporal | Literal (String). RKMS‐ISO8601 form. | 0..1
33
+ dcterms:title | Literal (String) | 1
34
+ rdf:type | vivo:Dataset | 1
35
+
36
+ ### File
37
+ Property | Value | Cardinality
38
+ --- | --- | ---
39
+ dcterms:extent | Literal (Integer) | 1
40
+ dcterms:format | Literal (String) | 1
41
+ dcterms:license | URI | 0..1
42
+ dcterms:title | Literal (String) | 1
43
+ rdf:type | premis:File | 1
44
+
45
+ ### Organisation
46
+ Property | Value | Cardinality
47
+ --- | --- | ---
48
+ dcterms:title | Literal (String) | 1
49
+ rdf:type | foaf:Organization | 1
50
+
51
+ ### Person
52
+ Property | Value | Cardinality
53
+ --- | --- | ---
54
+ foaf:name | Literal (String) | 1
55
+ mads:hasAffiliation | URI | 0..n
56
+ rdf:type | foaf:Person | 1
57
+ vivo:OrcidId | URI | 0..1
58
+
59
+ ### Project
60
+ Property | Value | Cardinality
61
+ --- | --- | ---
62
+ dcterms:title | Literal (String) | 1
63
+ rdf:type | vivo:Project | 1
64
+
65
+ ### Publication
66
+ Property | Value | Cardinality
67
+ --- | --- | ---
68
+ dcterms:title | Literal (String) | 1
69
+ rdf:type | swpo:Publication | 1
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # LinkedResearchMetadata
2
+
3
+ Metadata extraction from the Pure Research Information System and transformation of the metadata into RDF.
4
+
5
+ ## Status
6
+
7
+ [![Gem Version](https://badge.fury.io/rb/linked_research_metadata.svg)](https://badge.fury.io/rb/linked_research_metadata)
8
+ [![Build Status](https://semaphoreci.com/api/v1/aalbinclark/linked_research_metadata/branches/master/badge.svg)](https://semaphoreci.com/aalbinclark/linked_research_metadata)
9
+ [![Code Climate](https://codeclimate.com/github/lulibrary/linked_research_metadata/badges/gpa.svg)](https://codeclimate.com/github/lulibrary/linked_research_metadata)
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'linked_research_metadata'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install linked_research_metadata
24
+
25
+ ## Usage
26
+
27
+ ### Configuration
28
+
29
+ Create a hash for passing to a transformer.
30
+
31
+ ```ruby
32
+ # Pure host with authentication.
33
+ config = {
34
+ url: ENV['PURE_URL'],
35
+ username: ENV['PURE_USERNAME'],
36
+ password: ENV['PURE_PASSWORD'],
37
+ minting_uri: 'http://data.example.com'
38
+ }
39
+ ```
40
+
41
+ ```ruby
42
+ # Pure host without authentication.
43
+ config = {
44
+ url: ENV['PURE_URL'],
45
+ minting_uri: 'http://data.example.com'
46
+ }
47
+ ```
48
+
49
+ ### Transformation
50
+
51
+ Create a metadata transformer for a Pure dataset.
52
+
53
+ ```ruby
54
+ transformer = LinkedResearchMetadata::Transformer::Dataset.new config
55
+ ```
56
+
57
+ Give it a Pure identifier...
58
+
59
+ ```ruby
60
+ graph = transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
61
+ ```
62
+
63
+ ...and get an RDF graph.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,44 @@
1
+ module LinkedResearchMetadata
2
+ module Transformer
3
+
4
+ # Base transformer
5
+ #
6
+ class Base
7
+
8
+ # @param config [Hash]
9
+ # @option config [String] :url The URL of the Pure host.
10
+ # @option config [String] :username The username of the Pure host account.
11
+ # @option config [String] :password The password of the Pure host account.
12
+ # @option config [String] :minting_uri The URI at which to mint a resource.
13
+ def initialize(config)
14
+ @config = config
15
+ raise 'Minting URI missing' if @config[:minting_uri].empty?
16
+ @graph = RDF::Graph.new
17
+ end
18
+
19
+ private
20
+
21
+ def vocab(v)
22
+ vocabulary_map =
23
+ {
24
+ swpo: 'http://sw-portal.deri.org/ontologies/swportal#',
25
+ vivo: 'http://vivoweb.org/ontology/core#'
26
+ }
27
+ RDF::Vocabulary.new vocabulary_map[v]
28
+ end
29
+
30
+ def mint_uri(uuid, resource)
31
+ uri_resource_map = {
32
+ dataset: 'datasets',
33
+ file: 'files',
34
+ organisation: 'organisations',
35
+ person: 'people',
36
+ project: 'projects',
37
+ publication: 'publications'
38
+ }
39
+ File.join @config[:minting_uri], uri_resource_map[resource], uuid
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,223 @@
1
+ module LinkedResearchMetadata
2
+ module Transformer
3
+
4
+ # Dataset transformer
5
+ #
6
+ class Dataset < Base
7
+
8
+ # @param config [Hash]
9
+ # @option config [String] :url The URL of the Pure host.
10
+ # @option config [String] :username The username of the Pure host account.
11
+ # @option config [String] :password The password of the Pure host account.
12
+ # @option config [String] :minting_uri The URI at which to mint a resource.
13
+ def initialize(config)
14
+ super
15
+ end
16
+
17
+ # Dataset transformation
18
+ #
19
+ # @param uuid [String]
20
+ # @return [RDF::Graph]
21
+ def transform(uuid:)
22
+ dataset_extractor = Puree::Extractor::Dataset.new @config
23
+ @resource = dataset_extractor.find uuid: uuid
24
+ raise 'No metadata for ' + uuid if !@resource
25
+ dataset_uri = mint_uri uuid, :dataset
26
+ @resource_uri = RDF::URI.new dataset_uri
27
+ build_graph
28
+ @graph
29
+ end
30
+
31
+ private
32
+
33
+ def meta
34
+ @graph << [ @resource_uri, RDF.type, "#{vocab(:vivo)}Dataset" ]
35
+ end
36
+
37
+ def available
38
+ object = @resource.available
39
+ if object
40
+ object_literal = RDF::Literal.new(object.strftime("%F"), datatype: RDF::XSD.date)
41
+ @graph << [ @resource_uri, RDF::Vocab::DC.available, object_literal ]
42
+ end
43
+ end
44
+
45
+ def created
46
+ object = @resource.created
47
+ if object
48
+ object_literal = RDF::Literal.new(object.strftime("%F"), datatype: RDF::XSD.date)
49
+ @graph << [ @resource_uri, RDF::Vocab::DC.created, object_literal ]
50
+ end
51
+ end
52
+
53
+ def doi
54
+ if @resource.doi
55
+ doi_uri = RDF::URI.new @resource.doi
56
+ doi_predicate_uri = RDF::Vocab::DC.identifier
57
+ @graph << [ @resource_uri, doi_predicate_uri, doi_uri ]
58
+ end
59
+ end
60
+
61
+ def description
62
+ object = @resource.description
63
+ if object
64
+ @graph << [ @resource_uri, RDF::Vocab::DC.description, object ]
65
+ end
66
+ end
67
+
68
+ def files
69
+ @resource.files.each do |i|
70
+ file_uri = RDF::URI.new mint_uri(SecureRandom.uuid, :file)
71
+
72
+ @graph << [ @resource_uri, RDF::Vocab::DC.hasPart, file_uri ]
73
+
74
+ # license
75
+ if i.license && i.license.url
76
+ uri = RDF::URI.new i.license.url
77
+ @graph << [ file_uri, RDF::Vocab::DC.license, uri ]
78
+ end
79
+
80
+ # mime
81
+ @graph << [ file_uri, RDF::Vocab::DC.format, i.mime ]
82
+
83
+ # size
84
+ size_predicate = RDF::Vocab::DC.extent
85
+ @graph << [ file_uri, size_predicate, i.size ]
86
+
87
+ #name
88
+ @graph << [ file_uri, RDF::Vocab::DC.title, i.name ]
89
+
90
+ #type
91
+ @graph << [ file_uri, RDF.type, RDF::Vocab::PREMIS.File ]
92
+ end
93
+ end
94
+
95
+ def keywords
96
+ @resource.keywords.each do |i|
97
+ @graph << [ @resource_uri, RDF::Vocab::DC.subject, i ]
98
+ end
99
+ end
100
+
101
+ def person(person_uri, uuid, name)
102
+ @graph << [ person_uri, RDF.type, RDF::Vocab::FOAF.Person ]
103
+ @graph << [ person_uri, RDF::Vocab::FOAF.name, name ]
104
+ person_extractor = Puree::Extractor::Person.new @config
105
+ person = person_extractor.find uuid: uuid
106
+ if person
107
+ person.affiliations.each do |i|
108
+ organisation_uri = RDF::URI.new mint_uri(i.uuid, :organisation)
109
+ @graph << [ person_uri, RDF::Vocab::MADS.hasAffiliation, organisation_uri ]
110
+ @graph << [ organisation_uri, RDF::Vocab::DC.title, i.name ]
111
+ @graph << [ organisation_uri, RDF.type, RDF::Vocab::FOAF.Organization ]
112
+ end
113
+ if person.orcid
114
+ orcid_uri = RDF::URI.new "http://orcid.org/#{person.orcid}"
115
+ orcid_predicate_uri = RDF::URI.new "#{vocab(:vivo)}OrcidId"
116
+ @graph << [ person_uri, orcid_predicate_uri, orcid_uri ]
117
+ end
118
+ end
119
+ end
120
+
121
+ def projects
122
+ @resource.projects.each do |i|
123
+ project_uri = RDF::URI.new mint_uri(i.uuid, :project)
124
+ @graph << [ @resource_uri, RDF::Vocab::DC.relation, project_uri ]
125
+ @graph << [ project_uri, RDF::Vocab::DC.title, i.title ]
126
+ @graph << [ project_uri, RDF.type, "#{vocab(:vivo)}Project" ]
127
+ end
128
+ end
129
+
130
+ def publications
131
+ @resource.publications.each do |i|
132
+ if i.type == 'Dataset'
133
+ publication_uri = RDF::URI.new mint_uri(i.uuid, :dataset)
134
+ @graph << [ publication_uri, RDF.type, "#{vocab(:vivo)}Dataset" ]
135
+ else
136
+ publication_uri = RDF::URI.new mint_uri(i.uuid, :publication)
137
+ @graph << [ publication_uri, RDF.type, "#{vocab(:swpo)}Publication" ]
138
+ end
139
+ @graph << [ @resource_uri, RDF::Vocab::DC.relation, publication_uri ]
140
+ @graph << [ publication_uri, RDF::Vocab::DC.title, i.title ]
141
+ end
142
+ end
143
+
144
+ def publisher
145
+ # should be URI
146
+ end
147
+
148
+ def roles
149
+ all_persons = []
150
+ all_persons << @resource.persons_internal
151
+ all_persons << @resource.persons_external
152
+ all_persons << @resource.persons_other
153
+ all_persons.each do |person_type|
154
+ person_type.each do |i|
155
+ name = i.name.first_last
156
+ if i.uuid
157
+ uuid = i.uuid
158
+ else
159
+ uuid = SecureRandom.uuid
160
+ end
161
+ person_uri = RDF::URI.new mint_uri(uuid, :person)
162
+ if i.role == 'Creator'
163
+ @graph << [ @resource_uri, RDF::Vocab::DC.creator, person_uri ]
164
+ person person_uri, uuid, name
165
+ end
166
+ if i.role == 'Contributor'
167
+ @graph << [ @resource_uri, RDF::Vocab::DC.contributor, person_uri ]
168
+ person person_uri, uuid, name
169
+ end
170
+ end
171
+ end
172
+
173
+ end
174
+
175
+ def spatial
176
+ @resource.spatial_places.each do |i|
177
+ @graph << [ @resource_uri, RDF::Vocab::DC.spatial, i ]
178
+ end
179
+ end
180
+
181
+ def temporal
182
+ t = @resource.temporal
183
+ temporal_range = ''
184
+ if t
185
+ if t.start
186
+ temporal_range << t.start.strftime("%F")
187
+ if t.end
188
+ temporal_range << '/'
189
+ temporal_range << t.end.strftime("%F")
190
+ end
191
+ object = temporal_range
192
+ @graph << [ @resource_uri, RDF::Vocab::DC.temporal, object ]
193
+ end
194
+ end
195
+ end
196
+
197
+ def title
198
+ object = @resource.title
199
+ if object
200
+ @graph << [ @resource_uri, RDF::Vocab::DC.title, object ]
201
+ end
202
+ end
203
+
204
+ def build_graph
205
+ meta
206
+ available
207
+ created
208
+ description
209
+ doi
210
+ files
211
+ keywords
212
+ projects
213
+ publications
214
+ # publisher
215
+ roles
216
+ spatial
217
+ temporal
218
+ title
219
+ end
220
+
221
+ end
222
+ end
223
+ end
@@ -0,0 +1,10 @@
1
+ module LinkedResearchMetadata
2
+
3
+ # Extracts metadata from the Pure Research Information System and
4
+ # converts it into RDF.
5
+ #
6
+ module Transformer
7
+
8
+ end
9
+
10
+ end
@@ -0,0 +1,5 @@
1
+ module LinkedResearchMetadata
2
+ # Semantic version number
3
+ #
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,12 @@
1
+ require 'puree'
2
+ require 'linkeddata'
3
+ require 'linked_research_metadata/transformer/base'
4
+ require 'linked_research_metadata/transformer/dataset'
5
+ require 'linked_research_metadata/version'
6
+
7
+ # Metadata extraction from the Pure Research Information System and
8
+ # transformation of the metadata into RDF.
9
+ #
10
+ module LinkedResearchMetadata
11
+
12
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "linked_research_metadata/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "linked_research_metadata"
8
+ spec.version = LinkedResearchMetadata::VERSION
9
+ spec.authors = ["Adrian Albin-Clark"]
10
+ spec.email = ["a.albin-clark@lancaster.ac.uk"]
11
+
12
+ spec.summary = %q{Metadata extraction from the Pure Research Information System and transformation of the metadata into RDF.}
13
+ spec.homepage = "https://github.com/lulibrary/linked_research_metadata"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.required_ruby_version = '~> 2.3'
23
+
24
+ spec.add_runtime_dependency "puree", "~> 1.3"
25
+ spec.add_runtime_dependency "linkeddata", "~> 2.2"
26
+
27
+ spec.add_development_dependency "minitest-reporters", "~> 1.1"
28
+
29
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: linked_research_metadata
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Adrian Albin-Clark
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: puree
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: linkeddata
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest-reporters
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ description:
56
+ email:
57
+ - a.albin-clark@lancaster.ac.uk
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - CHANGELOG.md
64
+ - Gemfile
65
+ - MODEL.md
66
+ - README.md
67
+ - Rakefile
68
+ - lib/linked_research_metadata.rb
69
+ - lib/linked_research_metadata/transformer/base.rb
70
+ - lib/linked_research_metadata/transformer/dataset.rb
71
+ - lib/linked_research_metadata/transformer/transformer.rb
72
+ - lib/linked_research_metadata/version.rb
73
+ - linked_research_metadata.gemspec
74
+ homepage: https://github.com/lulibrary/linked_research_metadata
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '2.3'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.5.1
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Metadata extraction from the Pure Research Information System and transformation
98
+ of the metadata into RDF.
99
+ test_files: []
100
+ has_rdoc: