adiwg-mdtranslator 2.3.1 → 2.3.2

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: c76bab7a13d123b87ccc5b186b838330dd5dcd08
4
- data.tar.gz: 83e0218e6a5ea373d2b9283ca61d72a32a840dd5
3
+ metadata.gz: 6d8f9dcd1aef3c375a17c1695eed301fb9f80fdf
4
+ data.tar.gz: e560fadd2c76252c9967ddc7fb2efcbdf0c3c471
5
5
  SHA512:
6
- metadata.gz: 666c6243ff33753bd0d73f29097d707464d5cf0ffe04f2ac4c7b64a9dde97e5c523d22755a5a79aa04d17f960c034104bff16e2761e965540144edcc763072e4
7
- data.tar.gz: 5b88078e37e97f0f6ed0327e6c71be0f90fbf0a56c3c777e99b0b337ee0a5d83a4e1c988bead13d0f599b257aef32be0f2035450b3d5253f97819255a828d2d0
6
+ metadata.gz: ebc60b53f0aefadcabf3288413bd761d79af4553e151581ba0f238b3d09a28b74f774474cae89dfbdf5ca1e750efebeae3e583740d5a5f1f1909fb51c17105a9
7
+ data.tar.gz: da2f0bc3ac197cfffdb664b9d192a842df407bf103ec5bc28c3c49a4204cefbf400ee2ef2bac0637fc65cafda3d8266150b1476f3e531f03e11651815a5009f1
@@ -151,15 +151,26 @@ module ADIWG
151
151
  {sb: 'Proposed', adiwg: 'proposed'}
152
152
  ]
153
153
 
154
- @association_sb2adiwg = [
155
- {sb: 'alternate', adiwg: 'alternate', reverse: 'alternate'},
156
- {sb: 'constituentOf', adiwg: 'isComposedOf', reverse: 'constituent'},
157
- {sb: 'copiedFrom', adiwg: nil, reverse: 'copiedInto'},
158
- {sb: 'derivativeOf', adiwg: 'derivativeProduct', reverse: 'derived'},
159
- {sb: 'precededBy', adiwg: nil, reverse: 'succeededBy'},
160
- {sb: 'productOf', adiwg: 'parentProject', reverse: 'produced'},
161
- {sb: 'related', adiwg: 'crossReference', reverse: 'related'},
162
- {sb: 'subprojectOf', adiwg: 'subProject', reverse: 'mainprojectOf'}
154
+ @association_sb2adiwg_forward = [
155
+ {sb: 'alternate', adiwg: 'alternate'},
156
+ {sb: 'constituentOf', adiwg: 'isComposedOf'},
157
+ {sb: 'copiedFrom', adiwg: 'copiedFrom'},
158
+ {sb: 'derivativeOf', adiwg: 'derivativeProduct'},
159
+ {sb: 'precededBy', adiwg: 'precededBy'},
160
+ {sb: 'productOf', adiwg: 'product'},
161
+ {sb: 'related', adiwg: 'crossReference'},
162
+ {sb: 'subprojectOf', adiwg: 'subProject'}
163
+ ]
164
+
165
+ @association_sb2adiwg_reverse = [
166
+ {sb: 'alternate', adiwg: 'alternate'},
167
+ {sb: 'constituent', adiwg: 'isComposedOf'},
168
+ {sb: 'copiedInto', adiwg: 'copiedFrom'},
169
+ {sb: 'derived', adiwg: 'derivativeProduct'},
170
+ {sb: 'succeededBy', adiwg: 'precededBy'},
171
+ {sb: 'produced', adiwg: 'product'},
172
+ {sb: 'related', adiwg: 'crossReference'},
173
+ {sb: 'mainprojectOf', adiwg: 'subProject'}
163
174
  ]
164
175
 
165
176
  # translate iso/adiwg code to sb
@@ -7,6 +7,7 @@
7
7
 
8
8
  require 'uuidtools'
9
9
  require 'adiwg/mdtranslator/internal/internal_metadata_obj'
10
+ require_relative 'module_codelists'
10
11
 
11
12
  module ADIWG
12
13
  module Mdtranslator
@@ -53,7 +54,26 @@ module ADIWG
53
54
 
54
55
  end
55
56
 
56
- def self.unpack(hSbJson, aContacts, hResponseObj)
57
+ # find the array pointer and type for a contact
58
+ def self.findContact(contactId, aContacts)
59
+
60
+ contactIndex = nil
61
+ contactType = nil
62
+ aContacts.each_with_index do |contact, i|
63
+ if contact[:contactId] == contactId
64
+ contactIndex = i
65
+ if contact[:isOrganization]
66
+ contactType = 'organization'
67
+ else
68
+ contactType = 'individual'
69
+ end
70
+ end
71
+ end
72
+ return contactIndex, contactType
73
+
74
+ end
75
+
76
+ def self.unpack(hSbJson, aContacts, hCitation, hResponseObj)
57
77
 
58
78
  # instance classes needed in script
59
79
  intMetadataClass = InternalMetadata.new
@@ -234,6 +254,19 @@ module ADIWG
234
254
  aContacts << hContact
235
255
  aContacts << hContactOrg unless hContactOrg.empty?
236
256
 
257
+ # add contact to resource citation
258
+ hResponsibility = intMetadataClass.newResponsibility
259
+ roleType = Codelists.codelist_sb2adiwg('role_sb2adiwg', hContact[:contactType])
260
+ roleType = hContact[:contactType] if roleType.nil?
261
+ hResponsibility[:roleName] = roleType
262
+ hParty = intMetadataClass.newParty
263
+ aReturn = findContact(hContact[:contactId], aContacts)
264
+ hParty[:contactId] = hContact[:contactId]
265
+ hParty[:contactIndex] = aReturn[0]
266
+ hParty[:contactType] = aReturn[1]
267
+ hResponsibility[:parties] << hParty
268
+ hCitation[:responsibleParties] << hResponsibility
269
+
237
270
  end
238
271
 
239
272
  end
@@ -2,7 +2,8 @@
2
2
  # Reader - ScienceBase JSON to internal data structure
3
3
 
4
4
  # History:
5
- # Stan Smith 2016-08-03 original script
5
+ # Stan Smith 2017-09-14 remove all identifiers except relatedItemId
6
+ # Stan Smith 2017-08-03 original script
6
7
 
7
8
  require 'json'
8
9
  require 'open-uri'
@@ -110,6 +111,27 @@ module ADIWG
110
111
  # add resource types
111
112
  BrowseCategory.unpack(hRelatedItem, hResource[:resourceTypes], hResponseObj)
112
113
 
114
+ # add association type
115
+ if hItem.has_key?('type')
116
+ sbAssocType = hItem['type']
117
+ unless sbAssocType.nil? || sbAssocType == ''
118
+ assocType = nil
119
+ if forward
120
+ assocType = Codelists.codelist_sb2adiwg('association_sb2adiwg_forward', sbAssocType)
121
+ else
122
+ assocType = Codelists.codelist_sb2adiwg('association_sb2adiwg_reverse', sbAssocType)
123
+ end
124
+ if assocType.nil?
125
+ hResource[:associationType] = sbAssocType
126
+ else
127
+ hResource[:associationType] = assocType
128
+ end
129
+ end
130
+ end
131
+ if hResource[:associationType].nil?
132
+ hResource[:associationType] = 'missing'
133
+ end
134
+
113
135
  # fill in associated resource citation
114
136
  hCitation = intMetadataClass.newCitation
115
137
  citationTitle = nil
@@ -121,35 +143,13 @@ module ADIWG
121
143
  end
122
144
  hCitation[:title] = citationTitle
123
145
 
124
- # create an identifier for each related item id
125
- if hItem.has_key?('id')
126
- hIdentifier = intMetadataClass.newIdentifier
127
- hIdentifier[:identifier] = hItem['id']
128
- hIdentifier[:namespace] = 'gov.sciencebase.catalog'
129
- hIdentifier[:description] = 'id'
130
- hCitation[:identifiers] << hIdentifier
131
- end
132
- if hItem.has_key?('itemId')
133
- hIdentifier = intMetadataClass.newIdentifier
134
- hIdentifier[:identifier] = hItem['itemId']
135
- hIdentifier[:namespace] = 'gov.sciencebase.catalog'
136
- hIdentifier[:description] = 'itemId'
137
- hCitation[:identifiers] << hIdentifier
138
- end
139
- if hItem.has_key?('relatedItemId')
140
- hIdentifier = intMetadataClass.newIdentifier
141
- hIdentifier[:identifier] = hItem['relatedItemId']
142
- hIdentifier[:namespace] = 'gov.sciencebase.catalog'
143
- hIdentifier[:description] = 'relatedItemId'
144
- hCitation[:identifiers] << hIdentifier
145
- end
146
- if hItem.has_key?('itemLinkTypeId')
147
- hIdentifier = intMetadataClass.newIdentifier
148
- hIdentifier[:identifier] = hItem['itemLinkTypeId']
149
- hIdentifier[:namespace] = 'gov.sciencebase.catalog'
150
- hIdentifier[:description] = 'itemLinkTypeId'
151
- hCitation[:identifiers] << hIdentifier
152
- end
146
+ # create an identifier for the related item
147
+ # use resourceId computed above
148
+ hIdentifier = intMetadataClass.newIdentifier
149
+ hIdentifier[:identifier] = resourceId
150
+ hIdentifier[:namespace] = 'gov.sciencebase.catalog'
151
+ hIdentifier[:description] = 'relatedItemId'
152
+ hCitation[:identifiers] << hIdentifier
153
153
 
154
154
  hResource[:resourceCitation] = hCitation
155
155
  hMetadata[:associatedResources] << hResource
@@ -50,6 +50,7 @@ module ADIWG
50
50
  hResourceInfo = intMetadataClass.newResourceInfo
51
51
  hCitation = intMetadataClass.newCitation
52
52
  hSchema = intMetadataClass.newSchema
53
+ @contacts = intObj[:contacts]
53
54
 
54
55
  # schema
55
56
  hSchema[:name] = 'sbJson'
@@ -96,7 +97,7 @@ module ADIWG
96
97
  hMetadataInfo[:parentMetadata] = hReturn unless hReturn.nil?
97
98
 
98
99
  # contacts
99
- Contact.unpack(hSbJson, intObj[:contacts], hResponseObj)
100
+ Contact.unpack(hSbJson, intObj[:contacts], hCitation, hResponseObj)
100
101
 
101
102
  # web links
102
103
  aReturn = WebLinkDocument.unpack(hSbJson, hResponseObj)
@@ -158,36 +159,11 @@ module ADIWG
158
159
  hMetadata[:resourceInfo] = hResourceInfo
159
160
  intObj[:schema] = hSchema
160
161
  intObj[:metadata] = hMetadata
161
- @contacts = intObj[:contacts]
162
162
 
163
163
  return intObj
164
164
 
165
165
  end
166
166
 
167
- # find the array pointer and type for a contact
168
- def self.findContact(contactId)
169
-
170
- contactIndex = nil
171
- contactType = nil
172
- @contacts.each_with_index do |contact, i|
173
- if contact[:contactId] == contactId
174
- contactIndex = i
175
- if contact[:isOrganization]
176
- contactType = 'organization'
177
- else
178
- contactType = 'individual'
179
- end
180
- end
181
- end
182
- return contactIndex, contactType
183
-
184
- end
185
-
186
- # set contacts array for reader test modules
187
- def self.setContacts(contacts)
188
- @contacts = contacts
189
- end
190
-
191
167
  end
192
168
 
193
169
  end
@@ -1,6 +1,8 @@
1
1
  # adiwg mdTranslator
2
2
 
3
3
  # version 2 history
4
+ # 2.3.2 2017-09-14 add associationType to sbJson relatedItems
5
+ # 2.3.2 2017-09-14 add contacts to resource citation
4
6
  # 2.3.1 2017-09-13 fixed fgdc reader: removed conversion of hash to json
5
7
  # 2.3.0 2017-09-11 add fgdc 1998 CSDGM reader
6
8
  # 2.2.0 2017-08-31 refactor for schema changes to Lineage and Funding
@@ -26,7 +28,7 @@
26
28
  module ADIWG
27
29
  module Mdtranslator
28
30
  # current mdtranslator version
29
- VERSION = "2.3.1"
31
+ VERSION = "2.3.2"
30
32
  end
31
33
  end
32
34
 
@@ -172,11 +172,11 @@ module ADIWG
172
172
  {adiwg: 'subProject', sb: 'subprojectOf'},
173
173
  {adiwg: 'supplementalResource', sb: nil},
174
174
 
175
- {adiwg: 'mainprojectOf', sb: 'subprojectOf', deprecated: true},
175
+ {adiwg: 'mainProjectOf', sb: 'subprojectOf', deprecated: true},
176
176
  {adiwg: 'produced', sb: 'productOf', deprecated: true},
177
177
  {adiwg: 'productOf', sb: 'productOf', deprecated: true},
178
178
  {adiwg: 'projectProduct', sb: 'productOf', deprecated: true},
179
- {adiwg: 'subprojectOf', sb: 'subprojectOf', deprecated: true}
179
+ {adiwg: 'subProjectOf', sb: 'subprojectOf', deprecated: true}
180
180
  ]
181
181
 
182
182
  # translate iso/adiwg code to sb
@@ -61,16 +61,14 @@ module ADIWG
61
61
 
62
62
  # tags from repositories
63
63
  intObj[:metadataRepositories].each do |hRepo|
64
- if hRepo[:repository] == 'data.gov'
65
- unless hRepo[:citation].empty?
66
- tagName = nil
67
- tagName = hRepo[:citation][:title] unless hRepo[:citation][:title].nil?
68
- unless tagName.nil?
69
- hTag = {}
70
- hTag[:type] = 'Harvest Set'
71
- hTag[:name] = tagName
72
- aTags << hTag
73
- end
64
+ unless hRepo[:citation].empty?
65
+ tagName = nil
66
+ tagName = hRepo[:citation][:title] unless hRepo[:citation][:title].nil?
67
+ unless tagName.nil?
68
+ hTag = {}
69
+ hTag[:type] = 'Harvest Set'
70
+ hTag[:name] = tagName + ' - ' + hRepo[:repository]
71
+ aTags << hTag
74
72
  end
75
73
  end
76
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adiwg-mdtranslator
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stan Smith
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-09-14 00:00:00.000000000 Z
12
+ date: 2017-09-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler