Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor bug fixes #182

Merged
merged 7 commits into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ def newDistribution
{
description: nil,
liabilityStatement: nil,
technicalPrerequisite: nil,
distributor: []
}
end
Expand Down Expand Up @@ -565,7 +564,8 @@ def newResourceFormat
{
formatSpecification: {},
amendmentNumber: nil,
compressionMethod: nil
compressionMethod: nil,
technicalPrerequisite: nil
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Fgdc

module DigitalForm

def self.unpack(xDigiForm, hResponseObj)
def self.unpack(xDigiForm, techPre, hResponseObj)

# instance classes needed in script
intMetadataClass = InternalMetadata.new
Expand All @@ -27,7 +27,7 @@ def self.unpack(xDigiForm, hResponseObj)
# distribution 6.4.2.1 (digtinfo) - digital transfer information
xTranInfo = xDigiForm.xpath('./digtinfo')
unless xTranInfo.empty?
TransferInfo.unpack(xTranInfo, hTransfer, hResponseObj)
TransferInfo.unpack(xTranInfo, hTransfer, techPre, hResponseObj)
end

# distribution 6.4.2.2 (digtopt) - digital transfer option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,16 @@ def self.unpack(xDistribution, hResponseObj)
hDistribution[:liabilityStatement] = liability
end

# distribution 6.6 (techpreq) - technical prerequisites
# -> distribution.distributor[all].transferOption[all].distributionFormat[all].technicalPrerequisite
# pass it down the line
techPre = xDistribution.xpath('./techpreq').text

# distribution 6.4 (stdorder) - standard order process []
axOrders = xDistribution.xpath('./stdorder')
unless axOrders.empty?
axOrders.each do |xOrder|
OrderProcess.unpack(xOrder, hDistributor, hResponseObj)
OrderProcess.unpack(xOrder, hDistributor, techPre, hResponseObj)
end
end

Expand All @@ -67,13 +72,6 @@ def self.unpack(xDistribution, hResponseObj)
hDistributor[:orderProcess] << hOrder
end

# distribution 6.6 (techpreq) - technical prerequisites
# -> distribution.technicalPrerequisite
techPre = xDistribution.xpath('./techpreq').text
unless techPre.empty?
hDistribution[:technicalPrerequisite] = techPre
end

# distribution 6.7 (availabl) - available time period {time period}
# -> distribution.distributor.orderProcess.plannedAvailability
xTimePeriod = xDistribution.xpath('./availabl')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Fgdc

module OrderProcess

def self.unpack(xOrder, hDistributor, hResponseObj)
def self.unpack(xOrder, hDistributor, techPre, hResponseObj)

# instance classes needed in script
intMetadataClass = InternalMetadata.new
Expand All @@ -37,7 +37,7 @@ def self.unpack(xOrder, hDistributor, hResponseObj)
axDigital = xOrder.xpath('./digform')
unless axDigital.empty?
axDigital.each do |xDigiForm|
hReturn = DigitalForm.unpack(xDigiForm, hResponseObj)
hReturn = DigitalForm.unpack(xDigiForm, techPre, hResponseObj)
unless hReturn.nil?
hDistributor[:transferOptions] << hReturn
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Fgdc

module TransferInfo

def self.unpack(xTranInfo, hTransfer, hResponseObj)
def self.unpack(xTranInfo, hTransfer, techPre, hResponseObj)

# instance classes needed in script
intMetadataClass = InternalMetadata.new
Expand All @@ -26,6 +26,11 @@ def self.unpack(xTranInfo, hTransfer, hResponseObj)
hFormat[:formatSpecification] = hSpecification
hTransfer[:distributionFormats] << hFormat

# add technical prerequisite to resourceFormat
unless techPre.empty?
hFormat[:technicalPrerequisite] = techPre
end

# distribution 6.4.2.1.1 (formname) - format name
# -> transferOption.distributionFormat.formatSpecification.title
# -> transferOption.distributionFormat.formatSpecification.identifier[].identifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Reader - ADIwg JSON to internal data structure

# History:
# Stan Smith 2018-01-30 add technicalPrerequisite
# Stan Smith 2018-01-29 add liabilityStatement
# Stan Smith 2016-10-21 original script

Expand Down Expand Up @@ -42,13 +41,6 @@ def self.unpack(hDistribution, responseObj)
end
end

# distribution - technical prerequisite
if hDistribution.has_key?('technicalPrerequisite')
if hDistribution['technicalPrerequisite'] != ''
intDistribution[:technicalPrerequisite] = hDistribution['technicalPrerequisite']
end
end

# distribution - distributor [distributor]
if hDistribution.has_key?('distributor')
aItems = hDistribution['distributor']
Expand Down
98 changes: 53 additions & 45 deletions lib/adiwg/mdtranslator/readers/mdJson/modules/module_format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,75 @@
# Reader - ADIwg JSON to internal data structure

# History:
# Stan Smith 2018-02-05 add 'technicalPrerequisite'
# Stan Smith 2016-10-20 original script

require_relative 'module_citation'

module ADIWG
module Mdtranslator
module Readers
module MdJson
module Mdtranslator
module Readers
module MdJson

module Format
module Format

def self.unpack(hFormat, responseObj)
def self.unpack(hFormat, responseObj)

# return nil object if input is empty
if hFormat.empty?
responseObj[:readerExecutionMessages] << 'Format object is empty'
responseObj[:readerExecutionPass] = false
return nil
end
# return nil object if input is empty
if hFormat.empty?
responseObj[:readerExecutionMessages] << 'Format object is empty'
responseObj[:readerExecutionPass] = false
return nil
end

# instance classes needed in script
intMetadataClass = InternalMetadata.new
intFormat = intMetadataClass.newResourceFormat
# instance classes needed in script
intMetadataClass = InternalMetadata.new
intFormat = intMetadataClass.newResourceFormat

# format - format specification {citation} (required)
if hFormat.has_key?('formatSpecification')
hObject = hFormat['formatSpecification']
unless hObject.empty?
hReturn = Citation.unpack(hObject, responseObj)
unless hReturn.nil?
intFormat[:formatSpecification] = hReturn
end
end
end
if intFormat[:formatSpecification].empty?
responseObj[:readerExecutionMessages] << 'Format is missing formatSpecification'
responseObj[:readerExecutionPass] = false
return nil
# format - format specification {citation} (required)
if hFormat.has_key?('formatSpecification')
hObject = hFormat['formatSpecification']
unless hObject.empty?
hReturn = Citation.unpack(hObject, responseObj)
unless hReturn.nil?
intFormat[:formatSpecification] = hReturn
end
end
end
if intFormat[:formatSpecification].empty?
responseObj[:readerExecutionMessages] << 'Format is missing formatSpecification'
responseObj[:readerExecutionPass] = false
return nil
end

# format - amendment number
if hFormat.has_key?('amendmentNumber')
if hFormat['amendmentNumber'] != ''
intFormat[:amendmentNumber] = hFormat['amendmentNumber']
end
end
# format - amendment number
if hFormat.has_key?('amendmentNumber')
if hFormat['amendmentNumber'] != ''
intFormat[:amendmentNumber] = hFormat['amendmentNumber']
end
end

# format - compression method
if hFormat.has_key?('compressionMethod')
if hFormat['compressionMethod'] != ''
intFormat[:compressionMethod] = hFormat['compressionMethod']
end
end
# format - compression method
if hFormat.has_key?('compressionMethod')
if hFormat['compressionMethod'] != ''
intFormat[:compressionMethod] = hFormat['compressionMethod']
end
end

return intFormat
# format - compression method
if hFormat.has_key?('technicalPrerequisite')
if hFormat['technicalPrerequisite'] != ''
intFormat[:technicalPrerequisite] = hFormat['technicalPrerequisite']
end
end

end
return intFormat

end
end

end
end
end

end
end
end
end
4 changes: 3 additions & 1 deletion lib/adiwg/mdtranslator/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# adiwg mdTranslator

# version 2 history
# 2.9.1 2018-02-05 move 'technicalPrerequisite' to 'resourceFormat'
# 2.9.1 2018-02-05 fix variable name in fgdc spatial domain writer
# 2.9.0 2018-02-01 added fgdc writer distribution information section
# 2.9.0 2018-01-26 deprecate dictionaryFormat in favor of dictionaryFunctionalLanguage
# 2.9.0 2018-01-25 added fgdc writer entity and attribute section
Expand Down Expand Up @@ -61,7 +63,7 @@
module ADIWG
module Mdtranslator
# current mdtranslator version
VERSION = "2.9.0"
VERSION = "2.9.1"
end
end

Expand Down
25 changes: 21 additions & 4 deletions lib/adiwg/mdtranslator/writers/fgdc/classes/class_distribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,28 @@ def writeXML(hDistribution)
end

# distribution 6.6 (techpreq) - technical prerequisites
# <- distribution.technicalPrerequisite
unless hDistribution[:technicalPrerequisite].nil?
@xml.tag!('techpreq', hDistribution[:technicalPrerequisite])
# -> distribution.distributor[all].transferOption[all].distributionFormat[all].technicalPrerequisite
# collect these and string unique together
techPre = ''
aTechPre = []
unless hDistributor.empty?
hDistributor[:transferOptions].each do |hTransOpt|
hTransOpt[:distributionFormats].each do |hFormat|
unless hFormat[:technicalPrerequisite].nil?
aTechPre << hFormat[:technicalPrerequisite]
end
end
end
end
aTechPre = aTechPre.uniq
aTechPre.each do |prereq|
techPre += prereq + '; '
end
techPre.chomp!('; ')
unless techPre == ''
@xml.tag!('techpreq', techPre)
end
if hDistribution[:technicalPrerequisite].nil?
if techPre == ''
@xml.tag!('techpreq')
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# FGDC CSDGM writer output in XML

# History:
# Stan Smith 2017-11-25 original script
# Stan Smith 2018-02-05 fixed typo in variable name 'aBPoly'
# Stan Smith 2017-11-25 original script

module ADIWG
module Mdtranslator
Expand All @@ -18,7 +19,7 @@ def initialize(xml, hResponseObj)

def writeXML(aExtents)

# spatial domain section is no required under bio extension rules
# spatial domain section is not required under biological extension rules

# look for geographic description - take first
# <- geographicExtent[:description]
Expand Down Expand Up @@ -54,7 +55,7 @@ def writeXML(aExtents)

# look for bounding polygon
# <- geographicExtent[:geographicElements]
# polygon must be in FeatureCollection with properties description of 'FGDC bounding polygon'
# polygon must be in a FeatureCollection with properties description of 'FGDC bounding polygon'
aBPoly = []
aExtents.each do |hExtent|
unless hExtent.empty?
Expand All @@ -81,7 +82,7 @@ def writeXML(aExtents)
end

# spatial domain 1.5 (spdom)
unless geoDescription.empty? && hBBox.empty? && hBPoly.empty?
unless geoDescription.empty? && hBBox.empty? && aBPoly.empty?
@xml.tag!('spdom') do

# spatial domain bio (descgeog) - geographic description (required)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ def writeXML(hTransOpt)
# transfer information 6.4.2.1.1 (formname) - format name (required)
# <- formatSpecification.identifier.identifier
# FGDC requires a format name for digital options (online and offline)
# the format name is saved in the format specification of the first distribution format
# the format name is saved in the identifier of the format specification
# of the first distribution format
# as backup, allow specification title to serve as format name
haveId = false
unless hSpec.empty?
unless hSpec[:identifiers].empty?
if hSpec[:identifiers].empty?
@xml.tag!('formname', hSpec[:title])
haveId = true
else
unless hSpec[:identifiers][0][:identifier].nil?
@xml.tag!('formname', hSpec[:identifiers][0][:identifier])
haveId = true
Expand All @@ -42,7 +47,7 @@ def writeXML(hTransOpt)
end
unless haveId
@hResponseObj[:writerPass] = false
@hResponseObj[:writerMessages] << 'Distribution Format is mission format name'
@hResponseObj[:writerMessages] << 'Distribution Format is missing format name'
end

# transfer information 6.4.2.1.2 (formvern) - format version number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# distribution

# History:
# Stan Smith 2018-01-30 add technicalPrerequisite
# Stan Smith 2018-01-29 add liabilityStatement
# Stan Smith 2017-04-04 original script

Expand Down Expand Up @@ -40,14 +39,6 @@ def writeHtml(hDistribution)
end
end

# distribution - technical prerequisite
unless hDistribution[:technicalPrerequisite].nil?
@html.em('Technical Prerequisite:')
@html.section(:class => 'block') do
@html.text!(hDistribution[:technicalPrerequisite])
end
end

# distribution - distributor [] {distributor}
hDistribution[:distributor].each do |hDistributor|
@html.details do
Expand Down
Loading