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
164
165
|
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_entity.rb', line 27
def self.unpack(hEntity, responseObj)
@MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
if hEntity.empty?
@MessagePath.issueWarning(230, responseObj)
return nil
end
intMetadataClass = InternalMetadata.new
intEntity = intMetadataClass.newEntity
outContext = nil
if hEntity.has_key?('entityId')
s = hEntity['entityId']
unless s == ''
intEntity[:entityId] = s
end
end
if hEntity.has_key?('commonName')
unless hEntity['commonName'] == ''
intEntity[:entityName] = hEntity['commonName']
end
end
if hEntity.has_key?('codeName')
intEntity[:entityCode] = hEntity['codeName']
end
if intEntity[:entityCode].nil? || intEntity[:entityCode] == ''
@MessagePath.issueError(231, responseObj)
else
outContext = 'entity code name ' + hEntity['codeName']
end
if hEntity.has_key?('alias')
hEntity['alias'].each do |item|
unless item == ''
intEntity[:entityAlias] << item
end
end
end
if hEntity.has_key?('definition')
intEntity[:entityDefinition] = hEntity['definition']
end
if intEntity[:entityDefinition].nil? || intEntity[:entityDefinition] == ''
@MessagePath.issueError(232, responseObj, outContext)
end
if hEntity.has_key?('entityReference')
hEntity['entityReference'].each do |hCitation|
unless hCitation.empty?
hReturn = Citation.unpack(hCitation, responseObj, outContext)
unless hReturn.nil?
intEntity[:entityReferences] << hReturn
end
end
end
end
if hEntity.has_key?('primaryKeyAttributeCodeName')
hEntity['primaryKeyAttributeCodeName'].each do |item|
unless item == ''
intEntity[:primaryKey] << item
end
end
end
if hEntity.has_key?('index')
hEntity['index'].each do |hIndex|
unless hIndex.empty?
index = EntityIndex.unpack(hIndex, responseObj, outContext)
unless index.nil?
intEntity[:indexes] << index
end
end
end
end
if hEntity.has_key?('attribute')
hEntity['attribute'].each do |hAttribute|
unless hAttribute.empty?
attribute = EntityAttribute.unpack(hAttribute, responseObj, outContext)
unless attribute.nil?
intEntity[:attributes] << attribute
end
end
end
end
if hEntity.has_key?('foreignKey')
hEntity['foreignKey'].each do |hFKey|
unless hFKey.empty?
fKey = EntityForeignKey.unpack(hFKey, responseObj, outContext)
unless fKey.nil?
intEntity[:foreignKeys] << fKey
end
end
end
end
if hEntity.has_key?('fieldSeparatorCharacter')
unless hEntity['fieldSeparatorCharacter'] == ''
intEntity[:fieldSeparatorCharacter] = hEntity['fieldSeparatorCharacter']
end
end
if hEntity.has_key?('numberOfHeaderLines')
unless hEntity['numberOfHeaderLines'] == ''
intEntity[:numberOfHeaderLines] = hEntity['numberOfHeaderLines'].to_i
end
end
if hEntity.has_key?('quoteCharacter')
unless hEntity['quoteCharacter'] == ''
intEntity[:quoteCharacter] = hEntity['quoteCharacter']
end
end
return intEntity
end
|