Commit 20ea693713098ceedafb0ee5221608935e5b0524

Authored by Laurent BEIGBEDER
1 parent 52e36442
Exists in master

9639 : bug with format without separator

server/kernel/src/Export/ExportManager.cpp
... ... @@ -10,6 +10,9 @@
10 10 #include "../Transformation/TransformationResult.h"
11 11 #include "../TimeManager/TimeManager.h"
12 12  
  13 +//9639
  14 +#include <algorithm>
  15 +
13 16 using namespace TREPS::Common;
14 17 using namespace TREPS::File;
15 18 using namespace TREPS::Transformation;
... ... @@ -102,6 +105,9 @@ namespace TREPS
102 105 //load information about transformation request
103 106 TransformationRequestClass *transRequest = new TransformationRequestClass();
104 107  
  108 + // 9639
  109 + this->transformationRequest = transRequest;
  110 +
105 111 if (!transRequest->loadFromFile(requestPath))
106 112 {
107 113 delete transRequest;
... ... @@ -290,11 +296,37 @@ namespace TREPS
290 296 //copy source data in export data
291 297 this->srcData.clone(&this->expData);
292 298  
  299 +
  300 +
  301 + // 9639 if « pattern - TF_PATTERN - user defined pattern »
  302 + // update starting index copy, escape all time fields
  303 + string startingIdxToCopy = "";
  304 +
  305 + if(this->transformationRequest->getTimeFormat()==TF_PATTERN){
  306 + // in case "t_TimeFormat pattern 1"
  307 + // count how many time field []
  308 + string lPattern = this->transformationRequest->getTimePattern();
  309 + int lCnt = std::count(lPattern.begin(), lPattern.end(), ']') - 1;
  310 +
  311 + std::ostringstream ostr; //output string stream
  312 + ostr << lCnt;
  313 +
  314 + // startingIdxToCopy = std::to_string(lCnt); C++11
  315 + startingIdxToCopy = ostr.str(); //C++03
  316 +
  317 + srcTimeFieldId = startingIdxToCopy.c_str();
  318 + }
  319 +
  320 +
  321 +
293 322 //copy source fields in export data (except source time field)
294 323 this->expFields.clear();
295 324 for (t_FieldList::const_iterator srcField = srcFields->begin(); srcField != srcFields->end(); ++srcField)
296 325 {
297   - if (/*((*srcField).type == FT_TIME) &&*/ ((*srcField).id.compare(srcTimeFieldId) == 0))
  326 + // 9639 update starting index copy, escape all time fields
  327 + //if (/*((*srcField).type == FT_TIME) &&*/ ((*srcField).id.compare(srcTimeFieldId) == 0))
  328 + //if (/*((*srcField).type == FT_TIME) &&*/ ( stoi((*srcField).id) <= stoi(srcTimeFieldId) )) //C++11
  329 + if (/*((*srcField).type == FT_TIME) &&*/ ( atoi((*srcField).id.c_str()) <= atoi(srcTimeFieldId) )) //C++03
298 330 continue;
299 331 this->expFields.push_back((*srcField));
300 332 }
... ...
server/kernel/src/Export/ExportManager.h
... ... @@ -5,6 +5,9 @@
5 5 #include "../XMLManager/XMLManager.h"
6 6 #include "../DataRecord/DataRecordList.h"
7 7  
  8 +// 9639
  9 +#include "../Transformation/TransformationRequest.h"
  10 +
8 11 //xml validation
9 12 #define TREPS_EXPORTS_XSD "exports.xsd"
10 13  
... ... @@ -28,6 +31,9 @@ using namespace TREPS::Application;
28 31 using namespace TREPS::XMLManager;
29 32 using namespace TREPS::DataRecord;
30 33  
  34 +// 9639
  35 +using namespace TREPS::Transformation;
  36 +
31 37 namespace TREPS
32 38 {
33 39 namespace Export
... ... @@ -78,6 +84,9 @@ namespace TREPS
78 84 //Exported fields
79 85 t_FieldList expFields;
80 86  
  87 + // 9639
  88 + TransformationRequestClass *transformationRequest;
  89 +
81 90 //load info and data of a file
82 91 bool loadFileData(const char *filePath, t_FileInfo &fileInfo, DataRecordListClass *fileData);
83 92  
... ...