equal
deleted
inserted
replaced
47 Configuration configuration; |
47 Configuration configuration; |
48 RelationConfiguration* currentRelationConfiguration = nullptr; |
48 RelationConfiguration* currentRelationConfiguration = nullptr; |
49 std::vector<relpipe::reader::handlers::AttributeMetadata> currentReaderMetadata; |
49 std::vector<relpipe::reader::handlers::AttributeMetadata> currentReaderMetadata; |
50 std::vector<relpipe::writer::AttributeMetadata> currentWriterMetadata; |
50 std::vector<relpipe::writer::AttributeMetadata> currentWriterMetadata; |
51 size_t currentAttributeIndex = 0; |
51 size_t currentAttributeIndex = 0; |
|
52 size_t currentRecordNumber = 1; |
52 |
53 |
53 |
54 |
54 xmlpp::DomParser dom; |
55 xmlpp::DomParser dom; |
55 xmlpp::Element* recordElement = nullptr; |
56 xmlpp::Element* recordElement = nullptr; |
56 relpipe::in::xmltable::XMLNameCodec xmlNameCodec; // TODO: move to a common library |
57 relpipe::in::xmltable::XMLNameCodec xmlNameCodec; // TODO: move to a common library |
115 } |
116 } |
116 } |
117 } |
117 |
118 |
118 currentReaderMetadata = attributes; |
119 currentReaderMetadata = attributes; |
119 currentWriterMetadata.clear(); |
120 currentWriterMetadata.clear(); |
|
121 currentRecordNumber = 1; |
|
122 recordElement = nullptr; |
120 |
123 |
121 if (currentRelationConfiguration == nullptr) { |
124 if (currentRelationConfiguration == nullptr) { |
122 copyInputAttributesToOutput(); |
125 copyInputAttributesToOutput(); |
123 } else { |
126 } else { |
124 if (isPrependingInputAttributes()) copyInputAttributesToOutput(); |
127 if (isPrependingInputAttributes()) copyInputAttributesToOutput(); |
140 xmlpp::Element* attributeElement = recordElement->add_child(xmlNameCodec.encode(s2x(attributeMetadata.getAttributeName()))); |
143 xmlpp::Element* attributeElement = recordElement->add_child(xmlNameCodec.encode(s2x(attributeMetadata.getAttributeName()))); |
141 attributeElement->set_attribute("name", s2x(attributeMetadata.getAttributeName())); |
144 attributeElement->set_attribute("name", s2x(attributeMetadata.getAttributeName())); |
142 attributeElement->set_attribute("type", s2x(attributeMetadata.getTypeName())); |
145 attributeElement->set_attribute("type", s2x(attributeMetadata.getTypeName())); |
143 attributeElement->add_child_text(s2x(value)); |
146 attributeElement->add_child_text(s2x(value)); |
144 |
147 |
|
148 if (currentAttributeIndex == 0) { |
|
149 recordElement->set_attribute("number", std::to_string(currentRecordNumber)); |
|
150 } |
|
151 |
145 currentAttributeIndex++; |
152 currentAttributeIndex++; |
146 |
153 |
147 if (currentAttributeIndex == currentReaderMetadata.size()) { |
154 if (currentAttributeIndex == currentReaderMetadata.size()) { |
148 if (currentRelationConfiguration->where.empty() || recordElement->eval_to_boolean(s2x(currentRelationConfiguration->where))) { |
155 if (currentRelationConfiguration->where.empty() || recordElement->eval_to_boolean(s2x(currentRelationConfiguration->where))) { |
149 if (isPrependingInputAttributes()) writeInputAttributes(); |
156 if (isPrependingInputAttributes()) writeInputAttributes(); |
151 if (isAppendingInputAttributes()) writeInputAttributes(); |
158 if (isAppendingInputAttributes()) writeInputAttributes(); |
152 } |
159 } |
153 |
160 |
154 resetRecordElement(); |
161 resetRecordElement(); |
155 currentAttributeIndex = 0; |
162 currentAttributeIndex = 0; |
|
163 currentRecordNumber++; |
156 } |
164 } |
157 } else { |
165 } else { |
158 relationalWriter->writeAttribute(value); |
166 relationalWriter->writeAttribute(value); |
159 } |
167 } |
160 } |
168 } |