module ADIWG::Mdtranslator::Readers::MdJson::EntityAttribute
Public Class Methods
unpack(hAttribute, responseObj, inContext = nil)
click to toggle source
# File lib/adiwg/mdtranslator/readers/mdJson/modules/module_entityAttribute.rb, line 27 def self.unpack(hAttribute, responseObj, inContext = nil) @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson # return nil object if input is empty if hAttribute.empty? @MessagePath.issueWarning(240, responseObj, inContext) return nil end # instance classes needed in script intMetadataClass = InternalMetadata.new intAttribute = intMetadataClass.newEntityAttribute outContext = nil # attribute - common name if hAttribute.has_key?('commonName') unless hAttribute['commonName'] == '' intAttribute[:attributeName] = hAttribute['commonName'] end end # attribute - code name (required) if hAttribute.has_key?('codeName') intAttribute[:attributeCode] = hAttribute['codeName'] end if intAttribute[:attributeCode].nil? || intAttribute[:attributeCode] == '' @MessagePath.issueError(241, responseObj, inContext) else if inContext.nil? outContext = 'attribute code name ' + hAttribute['codeName'] else outContext = inContext + ' attribute code name ' + hAttribute['codeName'] end end # attribute - alias [] if hAttribute.has_key?('alias') hAttribute['alias'].each do |item| unless item == '' intAttribute[:attributeAlias] << item end end end # attribute - definition (required) if hAttribute.has_key?('definition') intAttribute[:attributeDefinition] = hAttribute['definition'] end if intAttribute[:attributeDefinition].nil? || intAttribute[:attributeDefinition] == '' @MessagePath.issueError(242, responseObj, outContext) end # attribute - attribute reference if hAttribute.has_key?('attributeReference') hCitation = hAttribute['attributeReference'] unless hCitation.empty? hReturn = Citation.unpack(hCitation, responseObj, outContext) unless hReturn.nil? intAttribute[:attributeReference] = hReturn end end end # attribute - data type (required) if hAttribute.has_key?('dataType') intAttribute[:dataType] = hAttribute['dataType'] end if intAttribute[:dataType].nil? || intAttribute[:dataType] == '' @MessagePath.issueError(243, responseObj, outContext) end # attribute - allow nulls (required) if hAttribute.has_key?('allowNull') if hAttribute['allowNull'] === true intAttribute[:allowNull] = hAttribute['allowNull'] end end # attribute - require value to be unique (required) # ... allowMany deprecated if hAttribute.has_key?('allowMany') if hAttribute['allowMany'] === false intAttribute[:mustBeUnique] = hAttribute['allowMany'] @MessagePath.issueNotice(244, responseObj, outContext) end end if hAttribute.has_key?('mustBeUnique') if hAttribute['mustBeUnique'] === false intAttribute[:mustBeUnique] = hAttribute['mustBeUnique'] end end # attribute - units of measure if hAttribute.has_key?('units') unless hAttribute['units'] == '' intAttribute[:unitOfMeasure] = hAttribute['units'] end end # attribute - units of measure resolution if hAttribute.has_key?('unitsResolution') unless hAttribute['unitsResolution'] == '' intAttribute[:measureResolution] = hAttribute['unitsResolution'] end end # attribute - case sensitive {Boolean} (default = false) if hAttribute.has_key?('isCaseSensitive') unless hAttribute['unitsResolution'] == '' intAttribute[:isCaseSensitive] = hAttribute['isCaseSensitive'] end end # attribute - field width if hAttribute.has_key?('fieldWidth') unless hAttribute['fieldWidth'] == '' intAttribute[:fieldWidth] = hAttribute['fieldWidth'] end end # attribute - missing value if hAttribute.has_key?('missingValue') unless hAttribute['missingValue'] == '' intAttribute[:missingValue] = hAttribute['missingValue'] end end # attribute - domain ID if hAttribute.has_key?('domainId') unless hAttribute['domainId'] == '' intAttribute[:domainId] = hAttribute['domainId'] end end # attribute - minimum value if hAttribute.has_key?('minValue') unless hAttribute['minValue'] == '' intAttribute[:minValue] = hAttribute['minValue'] end end # attribute - maximum value if hAttribute.has_key?('maxValue') unless hAttribute['maxValue'] == '' intAttribute[:maxValue] = hAttribute['maxValue'] end end # attribute - domain range of values [] {valueRange} if hAttribute.has_key?('valueRange') aValueRange = hAttribute['valueRange'] aValueRange.each do |hRange| unless hRange.empty? hReturn = ValueRange.unpack(hRange, responseObj, outContext) unless hReturn.nil? intAttribute[:valueRange] << hReturn end end end end # attribute - time period of values [] {timePeriod} if hAttribute.has_key?('timePeriod') aTimePeriods = hAttribute['timePeriod'] aTimePeriods.each do |hTimePeriod| unless hTimePeriod.empty? hReturn = TimePeriod.unpack(hTimePeriod, responseObj, outContext) unless hReturn.nil? intAttribute[:timePeriod] << hReturn end end end end return intAttribute end