linked_research_metadata 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09fb2c4a097df4a9c607c75f7ec3dcfbb3f74108
4
- data.tar.gz: 0b4632b0da51c220b5a11f74055966fb1cd282dd
3
+ metadata.gz: 0756b8fabccdd04a3d47bf9e95c91e8afcbc4653
4
+ data.tar.gz: a7a3ddc08fc37192ab82d7e35ecb0f7f81bb83d2
5
5
  SHA512:
6
- metadata.gz: e5fca99bc0c6beaf8a33aba4f426c2975245eb9a4a53708052bf1903fb6343eda2142e4399db8be84c876c411ca2f8ffa4c3651971b2cadc2fd9e8d5c24e65af
7
- data.tar.gz: ec48b1aa65477f340487a9739d2da7fae4c59766f337f4fe3b62774dd3cef4be34e07ab89845a5a6fa9374666b88672f696ba454f2f8e70c356ba0fa14828dce
6
+ metadata.gz: 0d44d4a273c9227937cebeeb54a6f4455cdc779c6ddec5b4a2ec87339ab5dcdc3da1db816d4f757a5b4008e5c0a8fa51c69793b8c19fc10bea44bb4777961c4e
7
+ data.tar.gz: f8bd6f8ebc22885210044810e796ce0becff7ebe25f61ecd4abb2d896587e9b6eecf4389d39bb6b6cf773d949b6eecb424d02093b752b540e5e82de40fca2bb2
data/CHANGELOG.md CHANGED
@@ -4,9 +4,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 0.2.0 - 2017-07-28
8
+ ### Added
9
+ - Granularity control for associated resource URIs.
10
+ - Identifiers available as a hash of sets.
11
+
7
12
  ## 0.1.1 - 2017-07-03
8
13
  ### Fixed
9
- - Strings become URIs for rdf::type.
14
+ - Strings become URIs for rdf:type.
10
15
 
11
16
  ## 0.1.0 - 2017-06-30
12
17
  ### Added
data/MODEL.md CHANGED
@@ -1,18 +1,18 @@
1
1
  # Data Model
2
- Version 0.1.0
2
+ Version 0.2.0
3
3
 
4
4
  ## Prefixes
5
5
  Prefix | URI
6
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#
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
16
 
17
17
  ## Resources
18
18
 
@@ -21,12 +21,12 @@ Property | Value | Cardinality
21
21
  --- | --- | ---
22
22
  dcterms:available | xsd:date | 1
23
23
  dcterms:created | xsd:date | 1
24
- dcterms:creator | URI | 1..n
25
- dcterms:contributor | URI | 0..n
24
+ dcterms:creator | Person URI | 1..n
25
+ dcterms:contributor | Person URI | 0..n
26
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
27
+ dcterms:hasPart | File URI | 0..n
28
+ dcterms:identifier | DOI URI | 0..1
29
+ dcterms:relation | Dataset, Publication URI | 0..n
30
30
  dcterms:spatial | Literal (String) | 0..n
31
31
  dcterms:subject | Literal (String) | 0..n
32
32
  dcterms:temporal | Literal (String). RKMS‐ISO8601 form. | 0..1
@@ -52,7 +52,7 @@ rdf:type | foaf:Organization | 1
52
52
  Property | Value | Cardinality
53
53
  --- | --- | ---
54
54
  foaf:name | Literal (String) | 1
55
- mads:hasAffiliation | URI | 0..n
55
+ mads:hasAffiliation | Organisation URI | 0..n
56
56
  rdf:type | foaf:Person | 1
57
57
  vivo:OrcidId | URI | 0..1
58
58
 
@@ -60,7 +60,10 @@ vivo:OrcidId | URI | 0..1
60
60
  Property | Value | Cardinality
61
61
  --- | --- | ---
62
62
  dcterms:title | Literal (String) | 1
63
+ foaf:homepage | URI | 0..1
63
64
  rdf:type | vivo:Project | 1
65
+ vivo:PrincipalInvestigatorRole | Literal (String) | 0..1
66
+ vivo:CoPrincipalInvestigatorRole | Literal (String) | 0..n
64
67
 
65
68
  ### Publication
66
69
  Property | Value | Cardinality
data/README.md CHANGED
@@ -34,7 +34,8 @@ config = {
34
34
  url: ENV['PURE_URL'],
35
35
  username: ENV['PURE_USERNAME'],
36
36
  password: ENV['PURE_PASSWORD'],
37
- minting_uri: 'http://data.example.com'
37
+ minting_uri: 'http://data.example.com',
38
+ granularity: 1
38
39
  }
39
40
  ```
40
41
 
@@ -42,10 +43,32 @@ config = {
42
43
  # Pure host without authentication.
43
44
  config = {
44
45
  url: ENV['PURE_URL'],
45
- minting_uri: 'http://data.example.com'
46
+ minting_uri: 'http://data.example.com',
47
+ granularity: 2
46
48
  }
47
49
  ```
48
50
 
51
+ #### Parameters
52
+
53
+ **minting_uri**
54
+
55
+ Prefix for URIs minted e.g.
56
+
57
+ ```
58
+ http://data.example.com/datasets/c11d50c1-ade2-493a-ab42-ca54ef233b78
59
+ ```
60
+
61
+ UUIDs used are system identifiers wherever possible.
62
+
63
+
64
+ **granularity**
65
+
66
+ Control how much metadata is put into the graph for associated resources.
67
+
68
+ + 0 - gives resource URI only. Omitting the parameter has the same effect.
69
+ + 1 - gives resource URI plus type and title/name from the model metadata.
70
+ + 2 - gives resource URI plus all the model metadata for a resource.
71
+
49
72
  ### Transformation
50
73
 
51
74
  Create a metadata transformer for a Pure dataset.
@@ -61,3 +84,23 @@ graph = transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
61
84
  ```
62
85
 
63
86
  ...and get an RDF graph.
87
+
88
+ ### Some possible publishing strategies
89
+
90
+ Associated identifiers (UUIDs) are available after transformation in a hash of
91
+ sets for :dataset, :organisation, :person, :project, and :publication.
92
+ Organisation is only available if the granularity parameter is set to 2.
93
+
94
+ + Transform a single resource, setting granularity to 0, 1 or 2.
95
+
96
+ + Transform a single dataset resource, setting granularity to 0. Transform
97
+ other resources using UUIDs from the identifiers hash later, setting
98
+ granularity to 2.
99
+
100
+ + Transform a single dataset resource, setting granularity to 0. Repeat,
101
+ combining statements together from subsequent graphs and merging subsequent sets
102
+ of identifiers. Transform other resources using UUIDs from the identifiers hash
103
+ later, setting granularity to 2.
104
+
105
+ + Transform a single dataset resource, setting granularity to 2.
106
+ Repeat, combining statements from subsequent graphs into a larger graph.
@@ -1,7 +1,11 @@
1
1
  require 'puree'
2
2
  require 'linkeddata'
3
+ require 'linked_research_metadata/transformer/shared'
3
4
  require 'linked_research_metadata/transformer/base'
4
5
  require 'linked_research_metadata/transformer/dataset'
6
+ require 'linked_research_metadata/transformer/organisation'
7
+ require 'linked_research_metadata/transformer/person'
8
+ require 'linked_research_metadata/transformer/project'
5
9
  require 'linked_research_metadata/version'
6
10
 
7
11
  # Metadata extraction from the Pure Research Information System and
@@ -10,14 +10,60 @@ module LinkedResearchMetadata
10
10
  # @option config [String] :username The username of the Pure host account.
11
11
  # @option config [String] :password The password of the Pure host account.
12
12
  # @option config [String] :minting_uri The URI at which to mint a resource.
13
+ # @option config [Fixnum] :granularity Expand associated resource URIs with varying amounts of metadata.
14
+
13
15
  def initialize(config)
14
16
  @config = config
17
+ @config[:granularity] = 0 if !@config[:granularity]
15
18
  raise 'Minting URI missing' if @config[:minting_uri].empty?
16
19
  @graph = RDF::Graph.new
20
+ @identifiers = {
21
+ dataset: Set.new,
22
+ organisation: Set.new,
23
+ person: Set.new,
24
+ project: Set.new,
25
+ publication: Set.new
26
+ }
27
+ end
28
+
29
+ # Pure UUIDs available after transformation for :dataset, :organisation,
30
+ # :person, :project, :publication.
31
+ #
32
+ # @return [Hash{Symbol => Set<String>}]
33
+ def identifiers
34
+ @identifiers
17
35
  end
18
36
 
19
37
  private
20
38
 
39
+ def make_transformer(resource)
40
+ resource_class = "LinkedResearchMetadata::Transformer::#{resource.to_s.capitalize}"
41
+ Object.const_get(resource_class).new @config
42
+ end
43
+
44
+ # @param uuid [String]
45
+ # @param resource [Symbol]
46
+ # @return [RDF::Graph]
47
+ def transform(uuid:, resource:)
48
+ resource_class = "Puree::Extractor::#{resource.to_s.capitalize}"
49
+ resource_extractor = Object.const_get(resource_class).new @config
50
+ @resource = resource_extractor.find uuid: uuid
51
+ if @resource
52
+ resource_uri = mint_uri uuid, resource
53
+ @resource_uri = RDF::URI.new(resource_uri)
54
+ build_graph
55
+ end
56
+ @graph
57
+ end
58
+
59
+ def merge_graph(graph)
60
+ graph.each { |i| @graph << i }
61
+ end
62
+
63
+ def merge_identifiers(identifiers)
64
+ @identifiers.each { |k,v| v.merge identifiers[k] }
65
+ end
66
+
21
67
  def add_triple(subject, predicate, object)
22
68
  @graph << [ subject, predicate, object ]
23
69
  end
@@ -43,6 +89,18 @@ module LinkedResearchMetadata
43
89
  File.join @config[:minting_uri], uri_resource_map[resource], uuid
44
90
  end
45
91
 
92
+ def identifiers_to_graph(resource)
93
+ graph = RDF::Graph.new
94
+ @identifiers[resource].each do |i|
95
+ identifiers_graph = RDF::Graph.new
96
+ transformer = make_transformer resource
97
+ graph = transformer.transform uuid: i
98
+ identifiers_graph.each { |i| graph << i }
99
+ end
100
+ graph
101
+ end
102
+
103
+
46
104
  end
47
105
  end
48
106
  end
@@ -4,12 +4,14 @@ module LinkedResearchMetadata
4
4
  # Dataset transformer
5
5
  #
6
6
  class Dataset < Base
7
+ include LinkedResearchMetadata::Transformer::Shared
7
8
 
8
9
  # @param config [Hash]
9
10
  # @option config [String] :url The URL of the Pure host.
10
11
  # @option config [String] :username The username of the Pure host account.
11
12
  # @option config [String] :password The password of the Pure host account.
12
13
  # @option config [String] :minting_uri The URI at which to mint a resource.
14
+ # @option config [Fixnum] :granularity Expand associated resource URIs with varying amounts of metadata.
13
15
  def initialize(config)
14
16
  super
15
17
  end
@@ -19,21 +21,11 @@ module LinkedResearchMetadata
19
21
  # @param uuid [String]
20
22
  # @return [RDF::Graph]
21
23
  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
24
+ super uuid: uuid, resource: :dataset
29
25
  end
30
26
 
31
27
  private
32
28
 
33
- def meta
34
- add_triple @resource_uri, RDF.type, RDF::URI.new("#{vocab(:vivo)}Dataset")
35
- end
36
-
37
29
  def available
38
30
  object = @resource.available
39
31
  if object
@@ -72,24 +64,24 @@ module LinkedResearchMetadata
72
64
 
73
65
  add_triple @resource_uri, RDF::Vocab::DC.hasPart, file_uri
74
66
 
75
- # license
76
- if i.license && i.license.url
67
+ minimal_file file_uri, i if @config[:granularity] > 0
68
+
69
+ if @config[:granularity] > 1
70
+
71
+ # license
72
+ if i.license && i.license.url
77
73
  uri = RDF::URI.new(i.license.url)
78
74
  add_triple file_uri, RDF::Vocab::DC.license, uri
79
- end
80
-
81
- # mime
82
- add_triple file_uri, RDF::Vocab::DC.format, i.mime
75
+ end
83
76
 
84
- # size
85
- size_predicate = RDF::Vocab::DC.extent
86
- add_triple file_uri, size_predicate, i.size
77
+ # mime
78
+ add_triple file_uri, RDF::Vocab::DC.format, i.mime
87
79
 
88
- #name
89
- add_triple file_uri, RDF::Vocab::DC.title, i.name
80
+ # size
81
+ size_predicate = RDF::Vocab::DC.extent
82
+ add_triple file_uri, size_predicate, i.size
83
+ end
90
84
 
91
- #type
92
- add_triple file_uri, RDF.type, RDF::Vocab::PREMIS.File
93
85
  end
94
86
  end
95
87
 
@@ -99,46 +91,31 @@ module LinkedResearchMetadata
99
91
  end
100
92
  end
101
93
 
102
- def person(person_uri, uuid, name)
103
- add_triple person_uri, RDF.type, RDF::Vocab::FOAF.Person
104
- add_triple person_uri, RDF::Vocab::FOAF.name, name
105
- person_extractor = Puree::Extractor::Person.new @config
106
- person = person_extractor.find uuid: uuid
107
- if person
108
- person.affiliations.each do |i|
109
- organisation_uri = RDF::URI.new(mint_uri(i.uuid, :organisation))
110
- add_triple person_uri, RDF::Vocab::MADS.hasAffiliation, organisation_uri
111
- add_triple organisation_uri, RDF::Vocab::DC.title, i.name
112
- add_triple organisation_uri, RDF.type, RDF::Vocab::FOAF.Organization
113
- end
114
- if person.orcid
115
- orcid_uri = RDF::URI.new("http://orcid.org/#{person.orcid}")
116
- orcid_predicate_uri = RDF::URI.new("#{vocab(:vivo)}OrcidId")
117
- add_triple person_uri, orcid_predicate_uri, orcid_uri
118
- end
119
- end
120
- end
121
-
122
94
  def projects
123
95
  @resource.projects.each do |i|
96
+ @identifiers[:project] << i.uuid
124
97
  project_uri = RDF::URI.new(mint_uri(i.uuid, :project))
125
98
  add_triple @resource_uri, RDF::Vocab::DC.relation, project_uri
126
- add_triple project_uri, RDF::Vocab::DC.title, i.title
127
- add_triple project_uri, RDF.type, RDF::URI.new("#{vocab(:vivo)}Project")
99
+ minimal_project project_uri, i if @config[:granularity] > 0
100
+ if @config[:granularity] > 1
101
+ transformer = make_transformer :project
102
+ graph = transformer.transform uuid: i.uuid
103
+ merge_graph graph if graph
104
+ end
128
105
  end
129
106
  end
130
107
 
131
108
  def publications
132
109
  @resource.publications.each do |i|
133
110
  if i.type == 'Dataset'
111
+ @identifiers[:dataset] << i.uuid
134
112
  publication_uri = RDF::URI.new(mint_uri(i.uuid, :dataset))
135
- add_triple publication_uri, RDF.type, RDF::URI.new("#{vocab(:vivo)}Dataset")
136
113
  else
114
+ @identifiers[:publication] << i.uuid
137
115
  publication_uri = RDF::URI.new(mint_uri(i.uuid, :publication))
138
- add_triple publication_uri, RDF.type, RDF::URI.new("#{vocab(:swpo)}Publication")
139
116
  end
140
117
  add_triple @resource_uri, RDF::Vocab::DC.relation, publication_uri
141
- add_triple publication_uri, RDF::Vocab::DC.title, i.title
118
+ minimal_publication publication_uri, i if @config[:granularity] > 0
142
119
  end
143
120
  end
144
121
 
@@ -153,24 +130,30 @@ module LinkedResearchMetadata
153
130
  all_persons << @resource.persons_other
154
131
  all_persons.each do |person_type|
155
132
  person_type.each do |i|
156
- name = i.name.first_last
157
133
  if i.uuid
158
134
  uuid = i.uuid
135
+ @identifiers[:person] << i.uuid
159
136
  else
160
137
  uuid = SecureRandom.uuid
161
138
  end
162
- person_uri = RDF::URI.new(mint_uri(uuid, :person))
163
- if i.role == 'Creator'
164
- add_triple @resource_uri, RDF::Vocab::DC.creator, person_uri
165
- person person_uri, uuid, name
166
- end
167
- if i.role == 'Contributor'
168
- add_triple @resource_uri, RDF::Vocab::DC.contributor, person_uri
169
- person person_uri, uuid, name
139
+ if i.name
140
+ person_uri = RDF::URI.new(mint_uri(uuid, :person))
141
+ if i.role == 'Creator'
142
+ add_triple @resource_uri, RDF::Vocab::DC.creator, person_uri
143
+ end
144
+ if i.role == 'Contributor'
145
+ add_triple @resource_uri, RDF::Vocab::DC.contributor, person_uri
146
+ end
147
+ minimal_person(person_uri, i) if @config[:granularity] > 0
148
+ if i.uuid && @config[:granularity] > 1
149
+ transformer = make_transformer :person
150
+ graph = transformer.transform uuid: uuid
151
+ merge_graph graph if graph
152
+ merge_identifiers transformer.identifiers
153
+ end
170
154
  end
171
155
  end
172
156
  end
173
-
174
157
  end
175
158
 
176
159
  def spatial
@@ -202,8 +185,11 @@ module LinkedResearchMetadata
202
185
  end
203
186
  end
204
187
 
188
+ def type
189
+ add_triple @resource_uri, RDF.type, RDF::URI.new("#{vocab(:vivo)}Dataset")
190
+ end
191
+
205
192
  def build_graph
206
- meta
207
193
  available
208
194
  created
209
195
  description
@@ -217,6 +203,7 @@ module LinkedResearchMetadata
217
203
  spatial
218
204
  temporal
219
205
  title
206
+ type
220
207
  end
221
208
 
222
209
  end
@@ -0,0 +1,43 @@
1
+ module LinkedResearchMetadata
2
+ module Transformer
3
+
4
+ # Organisation transformer
5
+ #
6
+ class Organisation < 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
+ # @option config [Fixnum] :granularity Expand associated resource URIs with varying amounts of metadata.
14
+ def initialize(config)
15
+ super
16
+ end
17
+
18
+ # Organisation transformation
19
+ #
20
+ # @param uuid [String]
21
+ # @return [RDF::Graph]
22
+ def transform(uuid:)
23
+ super uuid: uuid, resource: :organisation
24
+ end
25
+
26
+ private
27
+
28
+ def name
29
+ add_triple @resource_uri, RDF::Vocab::DC.title, @resource.name
30
+ end
31
+
32
+ def type
33
+ add_triple @resource_uri, RDF.type, RDF::Vocab::FOAF.Organization
34
+ end
35
+
36
+ def build_graph
37
+ name
38
+ type
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,68 @@
1
+ module LinkedResearchMetadata
2
+ module Transformer
3
+
4
+ # Person transformer
5
+ #
6
+ class Person < Base
7
+ include LinkedResearchMetadata::Transformer::Shared
8
+
9
+ # @param config [Hash]
10
+ # @option config [String] :url The URL of the Pure host.
11
+ # @option config [String] :username The username of the Pure host account.
12
+ # @option config [String] :password The password of the Pure host account.
13
+ # @option config [String] :minting_uri The URI at which to mint a resource.
14
+ # @option config [Fixnum] :granularity Expand associated resource URIs with varying amounts of metadata.
15
+ def initialize(config)
16
+ super
17
+ end
18
+
19
+ # Person transformation
20
+ #
21
+ # @param uuid [String]
22
+ # @return [RDF::Graph]
23
+ def transform(uuid:)
24
+ super uuid: uuid, resource: :person
25
+ end
26
+
27
+ private
28
+
29
+ def affiliations
30
+ @resource.affiliations.each do |i|
31
+ @identifiers[:organisation] << i.uuid
32
+ organisation_uri = RDF::URI.new(mint_uri(i.uuid, :organisation))
33
+ add_triple @resource_uri, RDF::Vocab::MADS.hasAffiliation, organisation_uri
34
+ minimal_organisation organisation_uri, i if @config[:granularity] > 0
35
+ if @config[:granularity] > 1
36
+ transformer = make_transformer :organisation
37
+ graph = transformer.transform uuid: i.uuid
38
+ merge_graph graph if graph
39
+ end
40
+ end
41
+ end
42
+
43
+ def name
44
+ add_triple @resource_uri, RDF::Vocab::FOAF.name, @resource.name.first_last
45
+ end
46
+
47
+ def orcid
48
+ if @resource.orcid
49
+ orcid_uri = RDF::URI.new("http://orcid.org/#{@resource.orcid}")
50
+ orcid_predicate_uri = RDF::URI.new("#{vocab(:vivo)}OrcidId")
51
+ add_triple @resource_uri, orcid_predicate_uri, orcid_uri
52
+ end
53
+ end
54
+
55
+ def type
56
+ add_triple @resource_uri, RDF.type, RDF::Vocab::FOAF.Person
57
+ end
58
+
59
+ def build_graph
60
+ affiliations
61
+ name
62
+ orcid
63
+ type
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,90 @@
1
+ module LinkedResearchMetadata
2
+ module Transformer
3
+
4
+ # Project transformer
5
+ #
6
+ class Project < Base
7
+ include LinkedResearchMetadata::Transformer::Shared
8
+
9
+ # @param config [Hash]
10
+ # @option config [String] :url The URL of the Pure host.
11
+ # @option config [String] :username The username of the Pure host account.
12
+ # @option config [String] :password The password of the Pure host account.
13
+ # @option config [String] :minting_uri The URI at which to mint a resource.
14
+ # @option config [Fixnum] :granularity Expand associated resource URIs with varying amounts of metadata.
15
+ def initialize(config)
16
+ super
17
+ end
18
+
19
+ # Project transformation
20
+ #
21
+ # @param uuid [String]
22
+ # @return [RDF::Graph]
23
+ def transform(uuid:)
24
+ super uuid: uuid, resource: :project
25
+ end
26
+
27
+ private
28
+
29
+ def roles
30
+ all_persons = []
31
+ all_persons << @resource.persons_internal
32
+ all_persons << @resource.persons_external
33
+ all_persons << @resource.persons_other
34
+ all_persons.each do |person_type|
35
+ person_type.each do |i|
36
+ name = i.name.first_last if i.name
37
+ if i.uuid
38
+ uuid = i.uuid
39
+ else
40
+ uuid = SecureRandom.uuid
41
+ end
42
+ if name
43
+ person_uri = RDF::URI.new(mint_uri(uuid, :person))
44
+ if i.role == 'Principal Investigator'
45
+ role_uri = RDF::URI.new("#{vocab(:vivo)}PrincipalInvestigatorRole")
46
+ add_triple @resource_uri, role_uri, person_uri
47
+ end
48
+ if i.role == 'Co-investigator'
49
+ role_uri = RDF::URI.new("#{vocab(:vivo)}CoPrincipalInvestigatorRole")
50
+ add_triple @resource_uri, role_uri, person_uri
51
+ end
52
+ minimal_person(person_uri, i) if @config[:granularity] > 0
53
+ end
54
+ # Phd Student
55
+ # RA
56
+ # Researcher
57
+ # Research Associate
58
+ # Team Member
59
+ end
60
+ end
61
+ end
62
+
63
+ def title
64
+ object = @resource.title
65
+ if object
66
+ add_triple @resource_uri, RDF::Vocab::DC.title, object
67
+ end
68
+ end
69
+
70
+ def type
71
+ add_triple @resource_uri, RDF.type, RDF::URI.new("#{vocab(:vivo)}Project")
72
+ end
73
+
74
+ def url
75
+ object = @resource.url
76
+ if object
77
+ add_triple @resource_uri, RDF::Vocab::FOAF.homepage, RDF::URI.new(object)
78
+ end
79
+ end
80
+
81
+ def build_graph
82
+ roles
83
+ title
84
+ type
85
+ url
86
+ end
87
+
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,45 @@
1
+ module LinkedResearchMetadata
2
+ module Transformer
3
+
4
+ # Shared
5
+ #
6
+ module Shared
7
+
8
+ private
9
+
10
+ def minimal_file(uri, file)
11
+ #name
12
+ add_triple uri, RDF::Vocab::DC.title, file.name
13
+
14
+ #type
15
+ add_triple uri, RDF.type, RDF::Vocab::PREMIS.File
16
+ end
17
+
18
+ def minimal_organisation(uri, organisation_header)
19
+ add_triple uri, RDF.type, RDF::Vocab::FOAF.Organization
20
+ add_triple uri, RDF::Vocab::DC.title, organisation_header.name
21
+ end
22
+
23
+ def minimal_person(uri, person)
24
+ add_triple uri, RDF.type, RDF::Vocab::FOAF.Person
25
+ add_triple uri, RDF::Vocab::FOAF.name, person.name.first_last
26
+ end
27
+
28
+ def minimal_project(uri, related_content_header)
29
+ add_triple uri, RDF.type, RDF::URI.new("#{vocab(:vivo)}Project")
30
+ add_triple uri, RDF::Vocab::DC.title, related_content_header.title
31
+ end
32
+
33
+ def minimal_publication(uri, related_content_header)
34
+ if related_content_header.type == 'Dataset'
35
+ add_triple uri, RDF.type, RDF::URI.new("#{vocab(:vivo)}Dataset")
36
+ else
37
+ add_triple uri, RDF.type, RDF::URI.new("#{vocab(:swpo)}Publication")
38
+ end
39
+ add_triple uri, RDF::Vocab::DC.title, related_content_header.title
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
@@ -1,5 +1,5 @@
1
1
  module LinkedResearchMetadata
2
2
  # Semantic version number
3
3
  #
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linked_research_metadata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Albin-Clark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-03 00:00:00.000000000 Z
11
+ date: 2017-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puree
@@ -68,6 +68,10 @@ files:
68
68
  - lib/linked_research_metadata.rb
69
69
  - lib/linked_research_metadata/transformer/base.rb
70
70
  - lib/linked_research_metadata/transformer/dataset.rb
71
+ - lib/linked_research_metadata/transformer/organisation.rb
72
+ - lib/linked_research_metadata/transformer/person.rb
73
+ - lib/linked_research_metadata/transformer/project.rb
74
+ - lib/linked_research_metadata/transformer/shared.rb
71
75
  - lib/linked_research_metadata/transformer/transformer.rb
72
76
  - lib/linked_research_metadata/version.rb
73
77
  - linked_research_metadata.gemspec