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
153
|
# File 'lib/adiwg/mdtranslator/readers/fgdc/modules/module_attribute.rb', line 22
def self.unpack(xAttribute, hDictionary, hResponseObj)
intMetadataClass = InternalMetadata.new
hAttribute = intMetadataClass.newEntityAttribute
code = xAttribute.xpath('./attrlabl').text
unless code.empty?
hAttribute[:attributeName] = code
hAttribute[:attributeCode] = code
end
if code.empty?
hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: attribute label is missing'
end
definition = xAttribute.xpath('./attrdef').text
unless definition.empty?
hAttribute[:attributeDefinition] = definition
end
if definition.empty?
hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: attribute definition is missing'
end
reference = xAttribute.xpath('./attrdefs').text
unless reference.empty?
hCitation = intMetadataClass.newCitation
hCitation[:title] = reference
hAttribute[:attributeReference] = hCitation
end
if reference.empty?
hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: attribute reference source is missing'
end
domainLength = hDictionary[:domains].length
axDomain = xAttribute.xpath('./attrdomv')
unless axDomain.empty?
unless axDomain.empty?
hDomain = Enumerated.unpack(axDomain, code, hResponseObj)
unless hDomain.nil?
hDictionary[:domains] << hDomain
end
end
unless axDomain.empty?
Range.unpack(axDomain, hAttribute, hResponseObj)
end
unless axDomain.empty?
aDomains = CodeSet.unpack(axDomain, code, hResponseObj)
hDictionary[:domains].concat aDomains
end
axUnRep = axDomain.xpath('./udom')
axUnRep.each do |xUnRep|
unRep = xUnRep.text
unless unRep.empty?
hDomain = intMetadataClass.newDictionaryDomain
hDomain[:domainId] = UUIDTools::UUID.random_create.to_s
hDomain[:domainName] = code
hDomain[:domainCode] = code
hDomain[:domainDescription] = unRep
hDictionary[:domains] << hDomain
end
end
end
if axDomain.empty?
hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: attribute domain is missing'
end
unless hDictionary[:domains].empty?
if hDictionary[:domains].length > domainLength
hAttribute[:domainId] = hDictionary[:domains][domainLength][:domainId]
end
end
axBegin = xAttribute.xpath('./begdatea')
axBegin.each_with_index do |xBegin, index|
beginDate = xBegin.text
unless beginDate.empty?
hTimePeriod = intMetadataClass.newTimePeriod
hDateTime = DateTime.unpack(beginDate, nil, hResponseObj)
unless hDateTime.nil?
hTimePeriod[:startDateTime] = hDateTime
end
endDate = xAttribute.xpath("./enddatea[#{index+1}]").text
hDateTime = DateTime.unpack(endDate, nil, hResponseObj)
unless hDateTime.nil?
hTimePeriod[:endDateTime] = hDateTime
end
hTimePeriod[:description] = 'attribute date range'
hAttribute[:timePeriod] << hTimePeriod
end
end
hAttribute
end
|