Commit a3eb6f22998bd220e185f2599334674a78af33e4

Authored by Hacene SI HADJ MOHAND
1 parent 93bba7b7

clen up

src/Info/ParamTable.cc
... ... @@ -308,11 +308,7 @@ namespace AMDA {
308 308 infoKey << VARIABLE_PARAMETER_TABLE << tableParam.first << "[" << i << "]";
309 309 PUSHINFO(tableInfo, infoKey.str(), tableParam.second);
310 310 AMDA::Parameters::ParameterSPtr variableTableParam = parameterManager->getParameter(tableParam.second);
311   - bool semiVariable = addSemiVariableTableInfo(parameterManager, dim, tableParam.second, tableParam.first, tableInfo);
312   - if (!semiVariable) {
313   - this->_fullVariable = true;
314   - variableTableParam->setIsTableIndexParam(true);
315   - }
  311 + addSemiVariableTableInfo(parameterManager, dim, tableParam.second, tableParam.first, tableInfo);
316 312 i++;
317 313 }
318 314 }
... ...
src/ParamOutputImpl/Download/DownloadOutput.cc
... ... @@ -90,11 +90,11 @@ namespace AMDA {
90 90 AMDA::Parameters::ParameterSPtr tableParam = _parameterManager.getParameter(tableParamId.second);
91 91 tableParam ->openConnection(this);
92 92 AMDA::Info::ParamInfoSPtr tableInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(tableParamId.second);
93   - }
94 93 }
95 94 }
96 95 }
97 96 }
  97 + }
98 98 } catch (...) {
99 99 LOG4CXX_ERROR(_logger, "DownloadOutput::establishConnection - It's impossible to open connection for " << paramProperties->getOutputId());
100 100 std::string filePath = getFilePath(_fileWriter->getExtension());
... ... @@ -105,25 +105,25 @@ namespace AMDA {
105 105 }
106 106 }
107 107 }
108   -
109   - void DownloadOutput::addAditionalDownloadParams(std::string paramId, bool isFullVariable){
  108 +
  109 + void DownloadOutput::addAditionalDownloadParams(std::string paramId, bool isFullVariable) {
110 110 AMDA::Parameters::ParameterSPtr pParam = _parameterManager.getParameter(paramId);
111   - if( pParam == NULL)
112   - return;
113   - AMDA::Info::ParamInfoSPtr processInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(paramId);
114   - if( isFullVariable || (pParam->isTableIndexParam() && processInfo->getProcessInfo().empty())){
115   - pParam->openConnection(this);
116   - ParamProperties* paramProperties = new ParamProperties();
117   - paramProperties->setOriginalId(paramId);
118   - paramProperties->setOutputId(paramId);
119   - _downloadProperties.addParamProperties(paramProperties);
120   - pParam->init(this, _timeIntervalList);
121   -
122   - }
123   - AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(paramId);
124   - const std::vector<std::string>& paramLinkedParams = paramInfo->getLinkedParamList();
125   - for(auto pId:paramLinkedParams)
126   - addAditionalDownloadParams(pId, false);
  111 + if (pParam == NULL)
  112 + return;
  113 + AMDA::Info::ParamInfoSPtr processInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(paramId);
  114 + if (isFullVariable || (pParam->isTableIndexParam() && processInfo->getProcessInfo().empty())) {
  115 + pParam->openConnection(this);
  116 + ParamProperties* paramProperties = new ParamProperties();
  117 + paramProperties->setOriginalId(paramId);
  118 + paramProperties->setOutputId(paramId);
  119 + _downloadProperties.addParamProperties(paramProperties);
  120 + pParam->init(this, _timeIntervalList);
  121 +
  122 + }
  123 + AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(paramId);
  124 + const std::vector<std::string>& paramLinkedParams = paramInfo->getLinkedParamList();
  125 + for (auto pId : paramLinkedParams)
  126 + addAditionalDownloadParams(pId, false);
127 127 }
128 128  
129 129 /**
... ... @@ -149,7 +149,7 @@ namespace AMDA {
149 149 _tooSmallIntervalProcessMap[paramProperties->getOriginalId()].reset(process);
150 150 }
151 151 }
152   -
  152 +
153 153 //init all needed parameters
154 154 for (auto paramProperties : _downloadProperties.getParamPropertiesList()) {
155 155 try {
... ... @@ -157,33 +157,33 @@ namespace AMDA {
157 157 LOG4CXX_DEBUG(gLogger, "DownloadOutput::init - " << paramProperties->getOutputId());
158 158 _parameterManager.getParameter(paramProperties->getOutputId())->init(this, _timeIntervalList);
159 159  
160   - AMDA::Parameters::ParameterSPtr param = _parameterManager.getParameter(paramProperties->getOriginalId());
  160 + AMDA::Parameters::ParameterSPtr param = _parameterManager.getParameter(paramProperties->getOriginalId());
161 161  
162 162 AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(paramProperties->getOriginalId());
163   -
  163 +
164 164 // adding tableParams
165 165 std::map<int, boost::shared_ptr < AMDA::Info::ParamTable>> tables = paramInfo->getTables();
166 166 if (!tables.empty()) {
167 167 _tableParamsList.push_back(paramProperties->getOriginalId());
168 168 for (auto table : tables) {
169 169 if (table.second != nullptr && table.second->isVariable(&_parameterManager)) {
170   - std::map<std::string, std::string> tableParamIds = table.second->getTableParams(&_parameterManager);
171   - if (!tableParamIds.empty())
172   - for (auto tableParamId : tableParamIds) {
173   - AMDA::Parameters::ParameterSPtr tableParam = _parameterManager.getParameter(tableParamId.second);
174   - if( tableParam == NULL)
175   - continue;
176   - tableParam -> init(this, _timeIntervalList);
177   - if(table.second->isFullVariable(&_parameterManager)){
178   - addAditionalDownloadParams(tableParamId.second, true);
179   - }else{
180   - _tableParamsList.push_back( tableParamId.second);
181   - }
182   - AMDA::Info::ParamInfoSPtr tableInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(tableParamId.second);
183   - for(auto linkedParamId : tableInfo->getLinkedParamList()){
184   - addAditionalDownloadParams(linkedParamId, false);
185   - }
186   - }
  170 + std::map<std::string, std::string> tableParamIds = table.second->getTableParams(&_parameterManager);
  171 + if (!tableParamIds.empty())
  172 + for (auto tableParamId : tableParamIds) {
  173 + AMDA::Parameters::ParameterSPtr tableParam = _parameterManager.getParameter(tableParamId.second);
  174 + if (tableParam == NULL)
  175 + continue;
  176 + tableParam -> init(this, _timeIntervalList);
  177 + if (table.second->isFullVariable(&_parameterManager)) {
  178 + addAditionalDownloadParams(tableParamId.second, true);
  179 + } else {
  180 + _tableParamsList.push_back(tableParamId.second);
  181 + }
  182 + AMDA::Info::ParamInfoSPtr tableInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(tableParamId.second);
  183 + for (auto linkedParamId : tableInfo->getLinkedParamList()) {
  184 + addAditionalDownloadParams(linkedParamId, false);
  185 + }
  186 + }
187 187 }
188 188 }
189 189 }
... ... @@ -258,17 +258,17 @@ namespace AMDA {
258 258 //build too small interval file if needed
259 259 if (isNeedToGenerateTooSmallIntervalFile())
260 260 buildTooSmallIntervalCatalog();
261   - if( !_tableParamsList.empty()){
  261 + if (!_tableParamsList.empty()) {
262 262 std::string filePath = getTableInfoFilePath(_fileWriter->getExtension());
263 263 if (!_fileWriter->createNewFile(filePath)) {
264 264 LOG4CXX_ERROR(_logger, "DownloadOutput::apply : Cannot create table info file " << filePath);
265 265 BOOST_THROW_EXCEPTION(AMDA::Parameters::ParamOutput_exception());
266 266 }
267 267 _files.push_back(filePath);
268   - //write info
  268 + //write info
269 269 writeAMDAInfo();
270   - _fileWriter->writeTableParamsInfo(_tableParamsList,0);
271   - _fileWriter->finalize(true);
  270 + _fileWriter->writeTableParamsInfo(_tableParamsList, 0);
  271 + _fileWriter->finalize(true);
272 272 }
273 273  
274 274 } catch (...) {
... ... @@ -311,6 +311,7 @@ namespace AMDA {
311 311 }
312 312 }
313 313 }
  314 +
314 315 /*
315 316 * @brief Apply structure for "one-file-per-interval"
316 317 */
... ... @@ -456,7 +457,8 @@ namespace AMDA {
456 457  
457 458 void DownloadOutput::writeParamInfo() {
458 459 _fileWriter->writeParamsInfo(_downloadProperties.getParamPropertiesList(),
459   - _downloadProperties.getOutputStructure(), _currentParamId);;
  460 + _downloadProperties.getOutputStructure(), _currentParamId);
  461 + ;
460 462 }
461 463  
462 464 bool DownloadOutput::isNeedToGenerateTooSmallIntervalFile() {
... ... @@ -836,20 +838,19 @@ namespace AMDA {
836 838 std::string DownloadOutput::getInfoFilePath(std::string extension) {
837 839 return getFilePath(extension, true);
838 840 }
839   -
840   - /*
  841 +
  842 + /*
841 843 * @brief Get file info path in relation with the sequence step (only used if info is written is separate file)
842 844 */
843 845 std::string DownloadOutput::getTableInfoFilePath(std::string extension) {
844   - std::string suffix ="_table" ;
  846 + std::string suffix = "_table";
845 847 std::string path = getInfoFilePath(extension);
846   - int pos = path.size()-extension.size()-1;
847   - pos = std::max(pos,0);
848   - path.insert(pos, suffix);
  848 + int pos = path.size() - extension.size() - 1;
  849 + pos = std::max(pos, 0);
  850 + path.insert(pos, suffix);
849 851 return path;
850 852 }
851 853  
852   -
853 854 void DownloadOutput::getParameterDataFromServer(std::string paramId) {
854 855 try {
855 856 _currentParamId = paramId;
... ...