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

Fix test cases. internal object and changes for bugfixes to mdJson re… #380

Closed
Closed
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
2 changes: 1 addition & 1 deletion adiwg-mdtranslator.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "thor", "~> 0.19"
spec.add_runtime_dependency "uuidtools", "~> 2.1"
spec.add_runtime_dependency "json-schema", "~> 2.7"
spec.add_runtime_dependency "adiwg-mdjson_schemas", "2.9.2"
spec.add_runtime_dependency "adiwg-mdjson_schemas", "2.10.0.pre.beta.0"
spec.add_runtime_dependency "adiwg-mdcodes", "2.9.3"
spec.add_runtime_dependency "jbuilder", "~> 2.5"
spec.add_runtime_dependency "kramdown", ">= 1.13", "< 3.0"
Expand Down
11 changes: 6 additions & 5 deletions lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ def newInstrument
identifier: {},
instrumentType: nil,
description: nil,
mountedOn: nil,
mountedOn: {},
histories: [],
hostId: {}
}
end

def newInstrumentationEvent
{
citation: {},
citations: [],
description: nil,
extent: {},
eventType: nil,
Expand All @@ -223,7 +223,7 @@ def newInstrumentationEvent

def newInstrumentationEventList
{
citations: [],
citation: {},
description: nil,
locale: {},
constraints: [],
Expand Down Expand Up @@ -268,14 +268,15 @@ def newPlan
def newOperation
{
operationId: nil,
description: nil,
citation: {},
identifier: {},
status: nil,
operationType: nil,
objectives: [],
parentOperations: nil,
parentOperation: {},
childOperations: [],
plan: nil,
plan: {},
platforms: [],
significantEvents: []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ def self.unpack(hInstrumentationEvent, responseObj, inContext = nil)
]

if hInstrumentationEvent.has_key?('citation')
intInstrumentationEvent[:citation] = Citation.unpack(hInstrumentationEvent['citation'], responseObj, outContext)
hInstrumentationEvent['citation'].each do |citation|
hReturn = Citation.unpack(citation, responseObj, outContext)
unless hReturn.nil?
intInstrumentationEvent[:citations] << hReturn
end
end
end

if hInstrumentationEvent.has_key?('description')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,28 @@ def self.unpack(hInstrumentationEventList, responseObj, inContext = nil)
intMetadataClass = InternalMetadata.new
intInstrumentationEventList = intMetadataClass.newInstrumentationEventList

outContext = 'instrumentation event list'
outContext = inContext + ' > ' + outContext unless inContext.nil?

if hInstrumentationEventList.has_key?('citation')
citations = hInstrumentationEventList['citation']
citations.each do |citation|
hReturn = Citation.unpack(hInstrumentationEventList['citation'], responseObj, inContext)
unless hReturn.nil?
intInstrumentationEventList[:citations] << hReturn
end
end
intInstrumentationEventList[:citation] = Citation.unpack(hInstrumentationEventList['citation'], responseObj, outContext)
end

if hInstrumentationEventList.has_key?('description')
intInstrumentationEventList[:description] = hInstrumentationEventList['description']
else
@MessagePath.issueWarning(40, responseObj, inContext, 'instrumentation event description')
@MessagePath.issueWarning(40, responseObj, outContext, 'instrumentation event description')
end

if hInstrumentationEventList.has_key?('locale')
hReturn = Locale.unpack(hInstrumentationEventList['locale'], responseObj, inContext)
hReturn = Locale.unpack(hInstrumentationEventList['locale'], responseObj, outContext)

end

if hInstrumentationEventList.has_key?('constraint')
constraints = hInstrumentationEventList['constraint']
constraints.each do |constraint|
hReturn = Constraint.unpack(hInstrumentationEventList['constraint'], responseObj, inContext)
hReturn = Constraint.unpack(hInstrumentationEventList['constraint'], responseObj, outContext)
unless hReturn.nil?
intInstrumentationEventList[:constraints] << hReturn
end
Expand All @@ -48,7 +45,7 @@ def self.unpack(hInstrumentationEventList, responseObj, inContext = nil)

if hInstrumentationEventList.has_key?('instrumentationEvent')
hInstrumentationEventList['instrumentationEvent'].each do |item|
hReturn = InstrumentationEvent.unpack(item, responseObj, inContext)
hReturn = InstrumentationEvent.unpack(item, responseObj, outContext)
unless hReturn.nil?
intInstrumentationEventList[:instrumentationEvents] << hReturn
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def self.unpack(hOperation, responseObj, inContext = nil)
hOperation['objective'].each do |item|
hReturn = Objective.unpack(item, responseObj, outContext)
unless hReturn.nil?
intOperation[:objective] << hReturn
intOperation[:objectives] << hReturn
end
end
end
Expand All @@ -78,7 +78,7 @@ def self.unpack(hOperation, responseObj, inContext = nil)
hOperation['childOperation'].each do |item|
hReturn = Operation.unpack(item, responseObj, outContext)
unless hReturn.nil?
intOperation[:childOperation] << hReturn
intOperation[:childOperations] << hReturn
end
end
end
Expand All @@ -94,7 +94,7 @@ def self.unpack(hOperation, responseObj, inContext = nil)
hOperation['platform'].each do |item|
hReturn = Platform.unpack(item, responseObj, outContext)
unless hReturn.nil?
intOperation[:platform] << hReturn
intOperation[:platforms] << hReturn
end
end
end
Expand All @@ -103,7 +103,7 @@ def self.unpack(hOperation, responseObj, inContext = nil)
hOperation['significantEvent'].each do |item|
hReturn = Event.unpack(item, responseObj, outContext)
unless hReturn.nil?
intOperation[:significantEvent] << hReturn
intOperation[:significantEvents] << hReturn
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def self.unpack(hPlatform, responseObj, inContext = nil)

if hPlatform.has_key?('instrument')
hPlatform['instrument'].each do |instrument|
hReturn = AcqInstrument.unpack(instrument, responseObj, outContext)
hReturn = Instrument.unpack(instrument, responseObj, outContext)
unless hReturn.nil?
intPlatform[:instruments] = hReturn
intPlatform[:instruments] << hReturn
else
@MessagePath.issueError(461, responseObj, outContext)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require_relative 'module_identifier'
require_relative 'module_requestedDate'
require_relative 'module_plan'
require_relative 'module_responsibleParty'

module ADIWG
module Mdtranslator
Expand Down Expand Up @@ -43,15 +44,21 @@ def self.unpack(hRequirement, responseObj, inContext = nil)
end
end

if hRequirement.has_key?('requestors')
hRequirement['requestors'].each do |requestor|
intRequirement[:requestors] << requestor
if hRequirement.has_key?('requestor')
hRequirement['requestor'].each do |requestor|
hReturn = ResponsibleParty.unpack(requestor, responseObj, outContext)
unless hReturn.nil?
intRequirement[:requestors] << hReturn
end
end
end

if hRequirement.has_key?('recipients')
hRequirement['recipients'].each do |recipient|
intRequirement[:recipients] << recipient
if hRequirement.has_key?('recipient')
hRequirement['recipient'].each do |recipient|
hReturn = ResponsibleParty.unpack(recipient, responseObj, outContext)
unless hReturn.nil?
intRequirement[:recipients] << hReturn
end
end
end

Expand All @@ -70,8 +77,8 @@ def self.unpack(hRequirement, responseObj, inContext = nil)
intRequirement[:expiryDate] = hRequirement['expiryDate']
end

if hRequirement.has_key?('satisfiedPlans')
aItems = hRequirement['satisfiedPlans']
if hRequirement.has_key?('satisfiedPlan')
aItems = hRequirement['satisfiedPlan']
aItems.each do |item|
hReturn = Plan.unpack(item, responseObj, outContext)
unless hReturn.nil?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require_relative 'mdJson_objective'
require_relative 'mdJson_platform'
require_relative 'mdJson_instrument'
# require_relative 'mdJson_operation'
require_relative 'mdJson_operation'
require_relative 'mdJson_event'
require_relative 'mdJson_pass'
require_relative 'mdJson_environment'
Expand All @@ -28,7 +28,7 @@ def self.build(hAcquisition)
json.objective @Namespace.json_map(hAcquisition[:objectives], Objective)
json.platform @Namespace.json_map(hAcquisition[:platforms], Platform)
json.instrument @Namespace.json_map(hAcquisition[:instruments], Instrument)
# json.operation @Namespace.json_map(hAcquisition[:operations], Operation)
json.operation @Namespace.json_map(hAcquisition[:operations], Operation)
json.event @Namespace.json_map(hAcquisition[:events], Event)
json.pass @Namespace.json_map(hAcquisition[:passes], Pass)
json.environment Environment.build(hAcquisition[:environment])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'jbuilder'
require_relative 'mdJson_citation'
require_relative 'mdJson_identifier'
# require_relative 'mdJson_platform'
require_relative 'mdJson_platform'
require_relative 'mdJson_instrumentationEventList'

module ADIWG
Expand All @@ -21,7 +21,7 @@ def self.build(hInstrument)
json.identifier Identifier.build(hInstrument[:identifier])
json.instrumentType hInstrument[:instrumentType]
json.description hInstrument[:description] unless hInstrument[:description].nil?
# json.mountedOn Platform.build(hInstrument[:mountedOn]) unless hInstrument[:mountedOn].empty?
json.mountedOn Platform.build(hInstrument[:mountedOn]) unless hInstrument[:mountedOn].empty?
json.history @Namespace.json_map(hInstrument[:histories], InstrumentationEventList) unless hInstrument[:histories].empty?
json.hostId Identifier.build(hInstrument[:hostId]) unless hInstrument[:hostId].empty?
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module InstrumentationEvent
def self.build(hInstrumentationEvent)
# "required": ["description","eventType"],
Jbuilder.new do |json|
json.citation Citation.build(hInstrumentationEvent[:citation]) unless hInstrumentationEvent[:citation].empty?
json.citation @Namespace.json_map(hInstrumentationEvent[:citations], Citation) unless hInstrumentationEvent[:citations].empty?
json.description hInstrumentationEvent[:description]
json.extent hInstrumentationEvent[:extent] unless hInstrumentationEvent[:extent].empty?
json.eventType hInstrumentationEvent[:eventType]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module InstrumentationEventList
def self.build(hInstrumentationEventList)

Jbuilder.new do |json|
json.citation @Namespace.json_map(hInstrumentationEventList[:citations], Citation) unless hInstrumentationEventList[:citations].empty?
json.citation Citation.build(hInstrumentationEventList[:citation]) unless hInstrumentationEventList[:citation].empty?
json.description hInstrumentationEventList[:description]
json.locale Locale.build(hInstrumentationEventList[:locale]) unless hInstrumentationEventList[:locale].empty?
json.constraints @Namespace.json_map(hInstrumentationEventList[:constraints], Constraint) unless hInstrumentationEventList[:constraints].empty?
Expand Down
34 changes: 34 additions & 0 deletions lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_operation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require 'jbuilder'

module ADIWG
module Mdtranslator
module Writers
module MdJson

module Operation

@Namespace = ADIWG::Mdtranslator::Writers::MdJson

def self.build(hOperation)

Jbuilder.new do |json|
json.operationId hOperation[:operationId]
json.description hOperation[:description] unless hOperation[:description].nil?
json.citation Citation.build(hOperation[:citation]) unless hOperation[:citation].empty?
json.identifier Identifier.build(hOperation[:identifier])
json.status hOperation[:status]
json.operationType hOperation[:operationType] unless hOperation[:operationType].nil?
json.objective @Namespace.json_map(hOperation[:objectives], Objective) unless hOperation[:objectives].empty?
json.parentOperation Operation.build(hOperation[:parentOperation]) unless hOperation[:parentOperation].empty?
json.childOperation @Namespace.json_map(hOperation[:childOperations], Operation) unless hOperation[:childOperations].empty?
json.plan Plan.build(hOperation[:plan]) unless hOperation[:plan].empty?
json.platform @Namespace.json_map(hOperation[:platforms], Platform) unless hOperation[:platforms].empty?
json.significantEvent @Namespace.json_map(hOperation[:significantEvents], Event) unless hOperation[:significantEvents].empty?
end

end
end # Operation
end
end
end
end
4 changes: 2 additions & 2 deletions lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_plan.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'jbuilder'
require_relative 'mdJson_citation'
# require_relative 'mdJson_operation'
require_relative 'mdJson_operation'
require_relative 'mdJson_requirement'

module ADIWG
Expand All @@ -19,7 +19,7 @@ def self.build(hPlan)
json.planType hPlan[:planType] unless hPlan[:planType].nil?
json.status hPlan[:status]
json.citation Citation.build(hPlan[:citation])
# json.planOperation @Namespace.json_map(hPlan[:operations], Operation)
json.planOperation @Namespace.json_map(hPlan[:operations], Operation)
json.satisfiedRequirement @Namespace.json_map(hPlan[:satisfiedRequirements], Requirement)

end
Expand Down
8 changes: 7 additions & 1 deletion test/helpers/mdJson_hash_functions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

class MdJsonHashWriter

def build_acquisition
hAcquisition = acquisition
return hAcquisition
end

def build_additionalDocumentation
hDoc = additionalDocumentation
return hDoc
Expand Down Expand Up @@ -72,7 +77,7 @@ def build_dataQuality

hDataQuality[:report] = [
{
type: 'AbsolutePositionalAccuracy',
type: 'AbsoluteExternalPositionalAccuracy',
standaloneQualityReportDetails: "standalone quality report details 1",
qualityMeasure: {
identifier: {
Expand Down Expand Up @@ -473,6 +478,7 @@ def build_metadata_full
hMetadata[:funding] << build_funding
hMetadata[:funding] << build_funding
hMetadata[:dataQuality] << build_dataQuality
hMetadata[:acquisition] << build_acquisition
removeEmptyObjects(hMetadata)
return hMetadata
end
Expand Down
Loading
Loading