Module: Adiwg_MetadataInfo

Defined in:
lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_metadataInfo.rb

Class Method Summary collapse

Class Method Details

.unpack(hMetadata) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_metadataInfo.rb', line 20

def self.unpack()

  # instance classes needed in script
  intMetadataClass = .new
  intMetadataInfo = intMetadataClass.newMetadataInfo
  hMetadataInfo = ['metadataInfo']

  # metadata - metadata identifier
  if hMetadataInfo.has_key?('metadataIdentifier')
    hMetadataId = hMetadataInfo['metadataIdentifier']
    unless hMetadataId.empty?
      intMetadataInfo[:metadataId] = Adiwg_ResourceIdentifier.unpack(hMetadataId)
    end
  end

  # metadata - parent metadata identifier
  if hMetadataInfo.has_key?('parentMetadata')
    hParent = hMetadataInfo['parentMetadata']
    unless hParent.empty?
      intMetadataInfo[:parentMetadata] = Adiwg_Citation.unpack(hParent)
    end
  end

  # metadata - metadata contacts, custodians
  if hMetadataInfo.has_key?('metadataContact')
    aCust = hMetadataInfo['metadataContact']
    unless aCust.empty?
      aCust.each do |rParty|
        intMetadataInfo[:metadataCustodians] << Adiwg_ResponsibleParty.unpack(rParty)
      end
    end
  end

  # metadata - creation date
  if hMetadataInfo.has_key?('metadataCreationDate')
    s = hMetadataInfo['metadataCreationDate']
    if s != ''
      hDateTime = Adiwg_DateTime.unpack(s)
      hDateTime[:dateType] = 'publication'
      intMetadataInfo[:metadataCreateDate] = hDateTime
    end
  end

  # metadata - date of last metadata update
  if hMetadataInfo.has_key?('metadataLastUpdate')
    s = hMetadataInfo['metadataLastUpdate']
    if s != ''
      hDateTime = Adiwg_DateTime.unpack(s)
      hDateTime[:dateType] = 'revision'
      intMetadataInfo[:metadataUpdateDate] = hDateTime
    end
  end

  # metadata - metadata URI
  if hMetadataInfo.has_key?('metadataUri')
    s = hMetadataInfo['metadataUri']
    if s != ''
      intMetadataInfo[:metadataURI] = s
    end
  end

  # metadata - status
  if hMetadataInfo.has_key?('metadataStatus')
    s = hMetadataInfo['metadataStatus']
    if s != ''
      intMetadataInfo[:metadataStatus] = s
    end
  end

  # metadata - metadata maintenance info
  if hMetadataInfo.has_key?('metadataMaintenance')
    hMetaMaint = hMetadataInfo['metadataMaintenance']
    unless hMetaMaint.empty?
      intMetadataInfo[:maintInfo] = Adiwg_ResourceMaintenance.unpack(hMetaMaint)
    end
  end

  # metadata - extension info - if biological extension
  if .has_key?('resourceInfo')
  resourceInfo = ['resourceInfo']
    if resourceInfo.has_key?('taxonomy')
      hTaxonomy = resourceInfo['taxonomy']
      unless hTaxonomy.empty?
        intMetadataInfo[:extensions] << Adiwg_MetadataExtension.addExtensionISObio
      end
    end
  end

  return intMetadataInfo

end