Module: ADIWG::Mdtranslator::Readers::Fgdc::MetadataInformation

Defined in:
lib/adiwg/mdtranslator/readers/fgdc/modules/module_metadataInfo.rb

Class Method Summary collapse

Class Method Details

.unpack(xMetaInfo, hResponseObj) ⇒ 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/adiwg/mdtranslator/readers/fgdc/modules/module_metadataInfo.rb', line 20

def self.unpack(xMetaInfo, hResponseObj)

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   hMetadataInfo = intMetadataClass.newMetadataInfo
   hLegal = intMetadataClass.newLegalConstraint

   # metadata information 7.1 (metd) - metadata date (required)
   # -> metadataInfo.metadataDates.date{type=creation}
   date = xMetaInfo.xpath('./metd').text
   unless date.empty?
      hDate = Date.unpack(date, '', 'creation', hResponseObj)
      unless hDate.nil?
         hMetadataInfo[:metadataDates] << hDate
      end
   end
   if date.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: metadata creation date is missing'
   end

   # metadata information 7.2 (metrd) - metadata review date
   # -> metadataInfo.metadataDates.date{type=review}
   date = xMetaInfo.xpath('./metrd').text
   unless date.empty?
      hDate = Date.unpack(date, '', 'review', hResponseObj)
      unless hDate.nil?
         hMetadataInfo[:metadataDates] << hDate
      end
   end

   # metadata information 7.3 (metfrd) - metadata future review date
   # -> metadataInfo.metadataDates.date{type=nextReview}
   date = xMetaInfo.xpath('./metfrd').text
   unless date.empty?
      hDate = Date.unpack(date, '', 'nextReview', hResponseObj)
      unless hDate.nil?
         hMetadataInfo[:metadataDates] << hDate
      end
   end

   # metadata information 7.4 (metc) - metadata contact (required)
   # -> metadataInfo.metadataContacts.responsibility{roleType=pointOfContact}
   xContact = xMetaInfo.xpath('./metc')
   unless xContact.empty?
      hResponsibility = Contact.unpack(xContact, hResponseObj)
      unless hResponsibility.nil?
         hResponsibility[:roleName] = 'pointOfContact'
         hMetadataInfo[:metadataContacts] << hResponsibility
      end
   end
   if xContact.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: metadata point of contact is missing'
   end

   # metadata information 7.5 (metstdn) - metadata standard name (required)
   # -> set by writer

   # metadata information 7.6 (metstdv) - metadata standard version (required)
   # -> set by writer

   # metadata information 7.7 (mettc) - metadata time convention
   # -> read by date/time modules

   # metadata information 7.8 (metac) - metadata access constraint
   # -> resourceInfo.constraints.legalConstraint.accessCodes
   accessCode = xMetaInfo.xpath('metac').text
   unless accessCode.empty?
      hLegal[:accessCodes] << accessCode
   end

   # metadata information 7.9 (metuc) - metadata use constraint
   # -> resourceInfo.constraints.legalConstraint.useCodes
   useCode = xMetaInfo.xpath('metuc').text
   unless useCode.empty?
      hLegal[:useCodes] << useCode
   end

   legal = accessCode + useCode
   if legal != ''
      hConstraint = intMetadataClass.newConstraint
      hConstraint[:type] = 'legal'
      hConstraint[:legalConstraint] = hLegal
      hMetadataInfo[:metadataConstraints] << hConstraint
   end

   # metadata information 7.10 (metsi) - metadata security information
   xSecurity = xMetaInfo.xpath('./metsi')
   unless xSecurity.empty?

      hSecurity = intMetadataClass.newSecurityConstraint

      # metadata information 7.10.1 (metscs) - metadata security classification system
      # -> resourceInfo.constraints.securityConstraint.classificationSystem
      system = xSecurity.xpath('./metscs').text
      unless system.empty?
         hSecurity[:classSystem] = system
      end

      # metadata information 7.10.2 (metsc) - metadata security classification
      # -> resourceInfo.constraints.securityConstraint.classification
      classCode = xSecurity.xpath('./metsc').text
      unless classCode.empty?
         hSecurity[:classCode] = classCode
      end

      # metadata information 7.10.3 (metshd) - metadata security handling description
      # -> resourceInfo.constraints.securityConstraint.handlingDescription
      handling = xSecurity.xpath('./metshd').text
      unless handling.empty?
         hSecurity[:handling] = handling
      end

      security = system + classCode + handling
      if security != ''
         hConstraint = intMetadataClass.newConstraint
         hConstraint[:type] = 'security'
         hConstraint[:securityConstraint] = hSecurity
         hMetadataInfo[:metadataConstraints] << hConstraint
      end

   end

   # metadata information 7.11 (metextns) - metadata extension []

   # metadata information 7.11.1 (onlink) - online linkage []
   # -> set by writer, reader assumes NBII biological extension is present

   # metadata information 7.11.2 (metprof) - profile name
   # -> set by writer, reader assumes NBII biological extension is present

   return hMetadataInfo

end