adiwg-mdtranslator 2.0.0rc9 → 2.0.0rc10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/adiwg-mdtranslator.gemspec +1 -1
- data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +1 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_metadataRepository.rb +46 -33
- data/lib/adiwg/mdtranslator/version.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/html/sections/html_metadataRepository.rb +16 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_browseCategory.rb +3 -4
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_geographicExtent.rb +33 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_hours.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_metadataRepository.rb +44 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_project.rb +5 -3
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_sbJson.rb +4 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_tag.rb +6 -14
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0934464b5cb7ffa7244aa794417a3bb7ff01c082'
|
4
|
+
data.tar.gz: dd47220a7cb46d796d611ea7adc23e9ecb77b976
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b6e2d96171f64e284fb9810bf8e030eafb2c41dc424b743b3aebc22f25cbefb7d5a6d87be8923cdbdf15a8162bdf2af78aaa887af93ce4a6ad3b1457e395802
|
7
|
+
data.tar.gz: de8f49629d78349c068eb6ad4744d3c008ba94600e7d8d953f21dbdd8bf63d865aaf6dcefded23de666a5da9e9d155e57fe2f23863221eea2019e381e8f470d1
|
data/adiwg-mdtranslator.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_runtime_dependency "thor", "~> 0.19"
|
34
34
|
spec.add_runtime_dependency "uuidtools", "~> 2.1"
|
35
35
|
spec.add_runtime_dependency "json-schema", "~> 2.7"
|
36
|
-
spec.add_runtime_dependency "adiwg-mdjson_schemas", ">= 2.
|
36
|
+
spec.add_runtime_dependency "adiwg-mdjson_schemas", ">= 2.2"
|
37
37
|
spec.add_runtime_dependency "adiwg-mdcodes", "~> 2.1"
|
38
38
|
spec.add_runtime_dependency "jbuilder", "~> 2.5"
|
39
39
|
|
@@ -2,52 +2,65 @@
|
|
2
2
|
# Reader - ADIwg JSON to internal data structure
|
3
3
|
|
4
4
|
# History:
|
5
|
+
# Stan Smith 2017-06-06 add citation to repository
|
5
6
|
# Stan Smith 2017-02-09 original script
|
6
7
|
|
8
|
+
require_relative 'module_citation'
|
9
|
+
|
7
10
|
module ADIWG
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
+
module Mdtranslator
|
12
|
+
module Readers
|
13
|
+
module MdJson
|
11
14
|
|
12
|
-
|
15
|
+
module MetadataRepository
|
13
16
|
|
14
|
-
|
17
|
+
def self.unpack(hMdDist, responseObj)
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
# return nil object if input is empty
|
20
|
+
if hMdDist.empty?
|
21
|
+
responseObj[:readerExecutionMessages] << 'Metadata Repository object is empty'
|
22
|
+
responseObj[:readerExecutionPass] = false
|
23
|
+
return nil
|
24
|
+
end
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
# instance classes needed in script
|
27
|
+
intMetadataClass = InternalMetadata.new
|
28
|
+
intMdDist = intMetadataClass.newMetadataRepository
|
26
29
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
# metadata distribution - repository (required)
|
31
|
+
if hMdDist.has_key?('repository')
|
32
|
+
intMdDist[:repository] = hMdDist['repository']
|
33
|
+
end
|
34
|
+
if intMdDist[:repository].nil? || intMdDist[:repository] == ''
|
35
|
+
responseObj[:readerExecutionMessages] << 'Metadata Repository repository is missing'
|
36
|
+
responseObj[:readerExecutionPass] = false
|
37
|
+
return nil
|
38
|
+
end
|
36
39
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
# metadata distribution - citation
|
41
|
+
if hMdDist.has_key?('citation')
|
42
|
+
unless hMdDist['citation'].empty?
|
43
|
+
hReturn = Citation.unpack(hMdDist['citation'], responseObj)
|
44
|
+
unless hReturn.nil?
|
45
|
+
intMdDist[:citation] = hReturn
|
42
46
|
end
|
47
|
+
end
|
48
|
+
end
|
43
49
|
|
44
|
-
|
50
|
+
# metadata distribution - metadata format
|
51
|
+
if hMdDist.has_key?('metadataStandard')
|
52
|
+
if hMdDist['metadataStandard'] != ''
|
53
|
+
intMdDist[:metadataStandard] = hMdDist['metadataStandard']
|
54
|
+
end
|
55
|
+
end
|
45
56
|
|
46
|
-
|
57
|
+
return intMdDist
|
47
58
|
|
48
|
-
|
59
|
+
end
|
49
60
|
|
50
61
|
end
|
51
|
-
|
52
|
-
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
53
66
|
end
|
@@ -2,8 +2,11 @@
|
|
2
2
|
# metadata repository
|
3
3
|
|
4
4
|
# History:
|
5
|
+
# Stan Smith 2017-06-06 added metadata repository citation
|
5
6
|
# Stan Smith 2017-04-05 original script
|
6
7
|
|
8
|
+
require_relative 'html_citation'
|
9
|
+
|
7
10
|
module ADIWG
|
8
11
|
module Mdtranslator
|
9
12
|
module Writers
|
@@ -17,6 +20,9 @@ module ADIWG
|
|
17
20
|
|
18
21
|
def writeHtml(hRepository)
|
19
22
|
|
23
|
+
# classes used
|
24
|
+
citationClass = Html_Citation.new(@html)
|
25
|
+
|
20
26
|
# metadata repository - repository
|
21
27
|
unless hRepository[:repository].nil?
|
22
28
|
@html.em('Repository Name: ')
|
@@ -31,6 +37,16 @@ module ADIWG
|
|
31
37
|
@html.br
|
32
38
|
end
|
33
39
|
|
40
|
+
# metadata repository - citation
|
41
|
+
unless hRepository[:citation].empty?
|
42
|
+
@html.details do
|
43
|
+
@html.summary('Citation', {'class' => 'h5'})
|
44
|
+
@html.section(:class => 'block') do
|
45
|
+
citationClass.writeHtml(hRepository[:citation])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
34
50
|
end # writeHtml
|
35
51
|
end # Html_Repository
|
36
52
|
|
@@ -17,16 +17,15 @@ module ADIWG
|
|
17
17
|
|
18
18
|
aCategories = []
|
19
19
|
|
20
|
+
# always include a 'Data' browse category
|
21
|
+
aCategories << 'Data'
|
22
|
+
|
20
23
|
aTypes.each do |hType|
|
21
24
|
type = hType[:type]
|
22
25
|
sbType = Codelists.codelist_iso_to_sb('iso_sb_scope', :isoCode => type)
|
23
26
|
aCategories << sbType unless sbType.nil?
|
24
27
|
end
|
25
28
|
|
26
|
-
if aCategories.empty?
|
27
|
-
return nil
|
28
|
-
end
|
29
|
-
|
30
29
|
aCategories = aCategories.uniq
|
31
30
|
|
32
31
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# sbJson 1.0 writer geographic extent
|
2
|
+
|
3
|
+
# History:
|
4
|
+
# Stan Smith 2017-06-06 original script
|
5
|
+
|
6
|
+
module ADIWG
|
7
|
+
module Mdtranslator
|
8
|
+
module Writers
|
9
|
+
module SbJson
|
10
|
+
|
11
|
+
module GeographicExtent
|
12
|
+
|
13
|
+
def self.build(aExtents)
|
14
|
+
|
15
|
+
aGeoExtents = []
|
16
|
+
|
17
|
+
# gather geographicExtents geoJson blocks
|
18
|
+
aExtents.each do |hExtent|
|
19
|
+
hExtent[:geographicExtents].each do |hGeoExtent|
|
20
|
+
aGeoExtents << hGeoExtent[:nativeGeoJson]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
aGeoExtents
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# sbJson 1.0 writer metadata repository
|
2
|
+
|
3
|
+
# History:
|
4
|
+
# Stan Smith 2017-06-06 original script
|
5
|
+
|
6
|
+
module ADIWG
|
7
|
+
module Mdtranslator
|
8
|
+
module Writers
|
9
|
+
module SbJson
|
10
|
+
|
11
|
+
module Repository
|
12
|
+
|
13
|
+
def self.build(aRepositories)
|
14
|
+
|
15
|
+
repository = {}
|
16
|
+
|
17
|
+
aRepositories.each do |hRepo|
|
18
|
+
if hRepo[:repository] == 'data.gov'
|
19
|
+
repository[:repository] = hRepo[:repository]
|
20
|
+
repository[:title] = 'Data.gov'
|
21
|
+
unless hRepo[:citation].empty?
|
22
|
+
unless hRepo[:citation][:identifiers].empty?
|
23
|
+
repository[:identifier] = hRepo[:citation][:identifiers][0][:identifier]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
repository[:metadataStandard] = hRepo[:metadataStandard]
|
27
|
+
break
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if repository.empty?
|
32
|
+
return nil
|
33
|
+
end
|
34
|
+
|
35
|
+
repository
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -19,10 +19,12 @@ module ADIWG
|
|
19
19
|
hResource[:resourceTypes].each do |hResourceType|
|
20
20
|
if hResourceType[:type] == 'project'
|
21
21
|
hProject[:className] = 'gov.sciencebase.catalog.item.facet.ProjectFacet'
|
22
|
-
|
23
|
-
status = hResource[:status][0]
|
22
|
+
hResource[:status].each do |status|
|
24
23
|
sbStatus = Codelists.codelist_iso_to_sb('iso_sb_progress', :isoCode => status)
|
25
|
-
|
24
|
+
unless sbStatus.nil?
|
25
|
+
hProject[:projectStatus] = sbStatus
|
26
|
+
break
|
27
|
+
end
|
26
28
|
end
|
27
29
|
unless hResource[:shortAbstract].nil?
|
28
30
|
hProject[:parts] = [
|
@@ -19,6 +19,8 @@ require_relative 'sbJson_tag'
|
|
19
19
|
require_relative 'sbJson_date'
|
20
20
|
require_relative 'sbJson_spatial'
|
21
21
|
require_relative 'sbJson_facet'
|
22
|
+
require_relative 'sbJson_metadataRepository'
|
23
|
+
require_relative 'sbJson_geographicExtent'
|
22
24
|
|
23
25
|
module ADIWG
|
24
26
|
module Mdtranslator
|
@@ -56,6 +58,8 @@ module ADIWG
|
|
56
58
|
json.dates Date.build(hCitation) unless hCitation.empty?
|
57
59
|
json.spatial Spatial.build(resourceInfo[:extents]) unless resourceInfo[:extents].empty?
|
58
60
|
json.facets Facet.build(intObj[:metadata])
|
61
|
+
json.metadataRepository Repository.build(intObj[:metadataRepositories]) unless intObj[:metadataRepositories].empty?
|
62
|
+
json.geographicExtents GeographicExtent.build(resourceInfo[:extents]) unless resourceInfo[:extents].empty?
|
59
63
|
|
60
64
|
end
|
61
65
|
|
@@ -50,20 +50,12 @@ module ADIWG
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
# tags for
|
54
|
-
hResource[:
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
unless sbStatus.nil?
|
60
|
-
hTag = {}
|
61
|
-
hTag[:type] = 'Project Status'
|
62
|
-
hTag[:name] = sbStatus
|
63
|
-
aTags << hTag
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
53
|
+
# tags for status
|
54
|
+
hResource[:status].each do |status|
|
55
|
+
hTag = {}
|
56
|
+
hTag[:type] = 'Status'
|
57
|
+
hTag[:name] = status
|
58
|
+
aTags << hTag
|
67
59
|
end
|
68
60
|
|
69
61
|
if aTags.empty?
|
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.0.
|
4
|
+
version: 2.0.0rc10
|
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-06-
|
12
|
+
date: 2017-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -129,14 +129,14 @@ dependencies:
|
|
129
129
|
requirements:
|
130
130
|
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 2.
|
132
|
+
version: '2.2'
|
133
133
|
type: :runtime
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 2.
|
139
|
+
version: '2.2'
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: adiwg-mdcodes
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -587,10 +587,12 @@ files:
|
|
587
587
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_contact.rb
|
588
588
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_date.rb
|
589
589
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_facet.rb
|
590
|
+
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_geographicExtent.rb
|
590
591
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_hours.rb
|
591
592
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_id.rb
|
592
593
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_identifier.rb
|
593
594
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_materialRequest.rb
|
595
|
+
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_metadataRepository.rb
|
594
596
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_parentId.rb
|
595
597
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_project.rb
|
596
598
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_provenance.rb
|