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/mdJson/modules/module_timePeriod.rb', line 22
def self.unpack(hTimePeriod, responseObj, inContext = nil)
@MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
if hTimePeriod.empty?
@MessagePath.issueWarning(870, responseObj, inContext)
return nil
end
intMetadataClass = InternalMetadata.new
intTimePer = intMetadataClass.newTimePeriod
outContext = 'time period'
outContext = inContext + ' > ' + outContext unless inContext.nil?
haveTime = false
if hTimePeriod.has_key?('id')
unless hTimePeriod['id'] == ''
intTimePer[:timeId] = hTimePeriod['id']
end
end
if hTimePeriod.has_key?('description')
unless hTimePeriod['description'] == ''
intTimePer[:description] = hTimePeriod['description']
end
end
if hTimePeriod.has_key?('identifier')
unless hTimePeriod['identifier'].empty?
hReturn = Identifier.unpack(hTimePeriod['identifier'], responseObj, outContext)
unless hReturn.nil?
intTimePer[:identifier] = hReturn
end
end
end
if hTimePeriod.has_key?('periodName')
hTimePeriod['periodName'].each do |item|
unless item == ''
intTimePer[:periodNames] << item
end
end
end
if hTimePeriod.has_key?('startDateTime')
unless hTimePeriod['startDateTime'] == ''
hReturn = DateTime.unpack(hTimePeriod['startDateTime'], responseObj, outContext)
unless hReturn.nil?
intTimePer[:startDateTime] = hReturn
haveTime = true
end
end
end
if hTimePeriod.has_key?('endDateTime')
unless hTimePeriod['endDateTime'] == ''
hReturn = DateTime.unpack(hTimePeriod['endDateTime'], responseObj, outContext)
unless hReturn.nil?
intTimePer[:endDateTime] = hReturn
haveTime = true
end
end
end
if hTimePeriod.has_key?('startGeologicAge')
unless hTimePeriod['startGeologicAge'].empty?
hReturn = GeologicAge.unpack(hTimePeriod['startGeologicAge'], responseObj, outContext)
unless hReturn.nil?
intTimePer[:startGeologicAge] = hReturn
haveTime = true
end
end
end
if hTimePeriod.has_key?('endGeologicAge')
unless hTimePeriod['endGeologicAge'].empty?
hReturn = GeologicAge.unpack(hTimePeriod['endGeologicAge'], responseObj, outContext)
unless hReturn.nil?
intTimePer[:endGeologicAge] = hReturn
haveTime = true
end
end
end
unless haveTime
@MessagePath.issueError(871, responseObj, inContext)
end
if hTimePeriod.has_key?('timeInterval')
unless hTimePeriod['timeInterval'].empty?
hReturn = TimeInterval.unpack(hTimePeriod['timeInterval'], responseObj, outContext)
unless hReturn.nil?
intTimePer[:timeInterval] = hReturn
end
if intTimePer[:startDateTime].empty? && intTimePer[:endDateTime].empty?
@MessagePath.issueError(872, responseObj, inContext)
end
end
end
if hTimePeriod.has_key?('duration')
unless hTimePeriod['duration'].empty?
hReturn = Duration.unpack(hTimePeriod['duration'], responseObj, outContext)
unless hReturn.nil?
intTimePer[:duration] = hReturn
end
if intTimePer[:startDateTime].empty? && intTimePer[:endDateTime].empty?
@MessagePath.issueError(873, responseObj, inContext)
end
end
end
return intTimePer
end
|