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
154
155
156
157
158
159
160
161
162
163
|
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_constraint.rb', line 23
def self.unpack(hConstraint, responseObj, inContext = nil)
@MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
if hConstraint.empty?
@MessagePath.issueWarning(90, responseObj, inContext)
return nil
end
intMetadataClass = InternalMetadata.new
intConstraint = intMetadataClass.newConstraint
type = nil
if hConstraint.has_key?('type')
unless hConstraint['type'] == ''
type = hConstraint['type']
if %w{ use legal security }.one? {|word| word == type}
intConstraint[:type] = hConstraint['type']
else
@MessagePath.issueError(91, responseObj, inContext)
end
end
end
if intConstraint[:type].nil? || intConstraint[:type] == ''
@MessagePath.issueError(92, responseObj, inContext)
end
outContext = 'constraint'
outContext = intConstraint[:type] + ' constraint' unless intConstraint[:type].nil?
outContext = inContext + ' > ' + outContext unless inContext.nil?
if hConstraint.has_key?('useLimitation')
hConstraint['useLimitation'].each do |item|
unless item == ''
intConstraint[:useLimitation] << item
end
end
end
if hConstraint.has_key?('scope')
hObject = hConstraint['scope']
unless hObject.empty?
hReturn = Scope.unpack(hObject, responseObj, outContext)
unless hReturn.nil?
intConstraint[:scope] = hReturn
end
end
end
if hConstraint.has_key?('graphic')
aGraphic = hConstraint['graphic']
aGraphic.each do |item|
hGraphic = Graphic.unpack(item, responseObj, outContext)
unless hGraphic.nil?
intConstraint[:graphic] << hGraphic
end
end
end
if hConstraint.has_key?('reference')
aReference = hConstraint['reference']
aReference.each do |item|
hReference = Citation.unpack(item, responseObj, outContext)
unless hReference.nil?
intConstraint[:reference] << hReference
end
end
end
if hConstraint.has_key?('releasability')
hObject = hConstraint['releasability']
unless hObject.empty?
hReturn = Releasability.unpack(hObject, responseObj, outContext)
unless hReturn.nil?
intConstraint[:releasability] = hReturn
end
end
end
if hConstraint.has_key?('responsibleParty')
aRParty = hConstraint['responsibleParty']
aRParty.each do |item|
hParty = ResponsibleParty.unpack(item, responseObj, outContext)
unless hParty.nil?
intConstraint[:responsibleParty] << hParty
end
end
end
if type == 'legal'
if hConstraint.has_key?('legal')
hObject = hConstraint['legal']
unless hObject.empty?
hReturn = LegalConstraint.unpack(hObject, responseObj, inContext)
unless hReturn.nil?
intConstraint[:legalConstraint] = hReturn
end
if hReturn.nil?
return nil
end
end
if hObject.empty?
@MessagePath.issueError(93, responseObj, inContext)
end
else
@MessagePath.issueError(93, responseObj, inContext)
end
end
if type == 'security'
if hConstraint.has_key?('security')
hObject = hConstraint['security']
unless hObject.empty?
hReturn = SecurityConstraint.unpack(hObject, responseObj, inContext)
unless hReturn.nil?
intConstraint[:securityConstraint] = hReturn
end
if hReturn.nil?
return nil
end
end
if hObject.empty?
@MessagePath.issueError(94, responseObj, inContext)
end
else
@MessagePath.issueError(94, responseObj, inContext)
end
end
return intConstraint
end
|