TransformationCDPP3DView.cpp 21.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664
#include "TransformationCDPP3DView.h"

#include <vector>
#include <iterator>
// 9639
#include <algorithm>

#include "../../CDPP3DViewSOAPClient/cdppBinder.nsmap"

#include "../Common/Toolbox.h"
#include "../DataRetriever/DataRetriever.h"
#include "../File/FileLoaderManager.h"
#include "../TimeManager/TimeManager.h"

using namespace TREPS::Common;
using namespace TREPS::DataRetriever;
using namespace TREPS::File;
using namespace TREPS::TimeManager;

namespace TREPS
{
	namespace Transformation
	{
		TransformationCDPP3DViewClass::TransformationCDPP3DViewClass(RequestAbstractClass *trepsRequest):TransformationAbstractClass(trepsRequest),
						client(NULL)
		{
			//init SOAP client for 3DView Web Service
			this->client = new cdppBinderProxy(SOAP_IO_KEEPALIVE);
			soap_ssl_init();
			if (soap_ssl_client_context(this->client,
				SOAP_SSL_NO_AUTHENTICATION,
				NULL, // keyfile: required only when client must authenticate to server
				NULL, // password to read the key file (not used with GNUTLS)
				NULL, // cacert file to store trusted certificates
				NULL, // capath to directory with trusted certificates
				NULL  // if randfile!=NULL: use a file with random data to seed randomness
			)) {
				this->errorMsg = "Error during the SOAP SSL init: ";
				if (this->client->soap_fault_string() != NULL)
				{
					this->errorMsg += this->client->soap_fault_string();
				}
				LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
			}
			//
			this->availableFrames.clear();
		}

		TransformationCDPP3DViewClass::~TransformationCDPP3DViewClass(void)
		{
			if (this->client != NULL)
			{
				delete this->client;
				this->client = NULL;
			}
		}

		bool TransformationCDPP3DViewClass::run(const char *workingDir)
		{
			this->errorMsg = "";

			//when source frame == destination frame => no frame transformation to do
			bool noTrans = (this->request->getSrcFrame().compare(this->request->getDstFrame()) == 0);

			//FOr a frame transformation, we need a source vectors list
			if (!noTrans && this->request->getSrcVectors()->empty())
			{
				this->errorMsg = "Empty source vector list";
				LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
				return false;
			}

			int nbSrcVectors = this->request->getSrcVectors()->size();

			if (noTrans)
			{
				if (nbSrcVectors == 0)
				{
					string status = "Clone source data";
                                	this->trepsRequest->setStatus(status.c_str());
					//if no fame transformation and no vector , content of result file == content of source file, except for the time field
					
					// 9639 if « pattern - TF_PATTERN - user defined pattern » and no transformation
					//this->result->clone(this->request->getSrcFields(), this->request->getSrcDataRecordList(),
					// 			this->request->getTimeFieldId().c_str());
					string startingIdxToCopy = "";
					if(this->request->getTimeFormat()==TF_PATTERN){
						// in case "t_TimeFormat pattern 1"
						// count how many time field []
						string lPattern = this->request->getTimePattern();
						int lCnt = std::count(lPattern.begin(), lPattern.end(), ']') - 1;
						startingIdxToCopy = intToStr(lCnt);

					}else{
						startingIdxToCopy = this->request->getTimeFieldId().c_str();
					}
					this->result->clone(this->request->getSrcFields(), this->request->getSrcDataRecordList(),
							startingIdxToCopy.c_str());

				}
				else
				{
					//no frame transformation, add selected source vectors in result file
					for (t_VectorList::iterator it=this->request->getSrcVectors()->begin(); it != this->request->getSrcVectors()->end(); ++it)
					{
						int crtIndex = distance(this->request->getSrcVectors()->begin(),it);
						string status = "Copy source vector ";
						status += intToStr(crtIndex + 1);
						status += " / ";
						status += intToStr(nbSrcVectors);
						this->trepsRequest->setStatus(status.c_str());

						string fieldId = (*it).id;
						if (!this->result->addFieldVector(fieldId.c_str(), this->request->getSrcDataRecordList(),
									(*it).fieldId[0].c_str(), (*it).fieldId[1].c_str(), (*it).fieldId[2].c_str(),
									this->request->getSrcFrame().c_str()))
						{
							this->errorMsg = "Cannot add vector";
							LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
							return false;
						}
					}
				}
				return true;
			}

			//for each vector
			for (t_VectorList::iterator it=this->request->getSrcVectors()->begin(); it != this->request->getSrcVectors()->end(); ++it)
			{
				//Init current transformation
				int crtIndex = distance(this->request->getSrcVectors()->begin(),it);

				string vectorStatus = "Current vector : ";
				vectorStatus += intToStr(crtIndex + 1);
				vectorStatus += " / ";
				vectorStatus += intToStr(nbSrcVectors);
				
				//if RTN/RTP, get files
				vector<ns4__TimeFile*> timeFiles;
				//get time manager instance
				TimeManagerClass *timeMgr = TimeManagerClass::getInstance();
				time_t lStart = timeMgr->to_TIMESTAMP(request->getStartTime());
				time_t lStop = timeMgr->to_TIMESTAMP(request->getStopTime());

				LOG4CXX_INFO(this->app->getLog()->getPtr(),"Search for RTN/RTP " << request->getSrcFrame().c_str()<< "/"<<request->getDstFrame().c_str());


				if(request->getSrcFrame().compare("RTN")==0||request->getSrcFrame().compare("RTP")==0){
					LOG4CXX_INFO(this->app->getLog()->getPtr(),"Search for src timeFile for RTN/RTP "<<request->getSrcCenter().c_str());
					istringstream iss(request->getSrcCenter());
					vector<string> splitStr((istream_iterator<string>(iss)),istream_iterator<string>());

					// 11165 : transfo RTN - update parameter checking                
					//if(splitStr.size()!=4) {
         			if(splitStr.size()<4) {                        
						this->errorMsg = "Source frame center should be 4 elements: ";
						this->errorMsg += request->getSrcCenter().c_str();
						LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
						return false;
					}
					LOG4CXX_INFO(this->app->getLog()->getPtr(),"Found src sc: "<<splitStr.at(2).c_str());
					timeFiles.push_back(callListFilesRequest(atoi(splitStr.at(2).c_str()),lStart,lStop ));
				}
				if(request->getDstFrame().compare("RTN")==0||request->getDstFrame().compare("RTP")==0){
					LOG4CXX_INFO(this->app->getLog()->getPtr(),"Search for dst timeFile for RTN/RTP "<<request->getDstCenter().c_str());
					istringstream iss(request->getDstCenter());
					vector<string> splitStr((istream_iterator<string>(iss)),istream_iterator<string>());
                             
          			// 11165 : transfo RTN - update parameter checking               
					//if(splitStr.size()!=4) {
			        if(splitStr.size()<4) {
						this->errorMsg = "Dest frame center should be 4 elements: ";
						this->errorMsg += request->getDstCenter().c_str();
						LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
						return false;
					}
					LOG4CXX_INFO(this->app->getLog()->getPtr(),"Found dst sc: "<<splitStr.at(2).c_str());
					timeFiles.push_back(callListFilesRequest(atoi(splitStr.at(2).c_str()),lStart,lStop ));
				}
				
				

				#ifdef WITH_GETORBURL
				//call getOrbUrl to generate a VOTable
				string generalStatus = vectorStatus;
				generalStatus += " - Running step : Send data for transformation";
				this->trepsRequest->setStatus(generalStatus.c_str());
				string url = this->callGetOrbUrlRequest(&(*it));

				if (url.compare("") == 0)
					return false;

				LOG4CXX_INFO(this->app->getLog()->getPtr(),"getOrbUrl result : " << url);

				//call transformation request
				generalStatus = vectorStatus;
                                generalStatus += " - Running step : Compute transformation";
                                this->trepsRequest->setStatus(generalStatus.c_str());
				url = this->callNewFrameRequest(&(*it), url.c_str(),timeFiles);

				#else
				string generalStatus = vectorStatus;
				generalStatus += " - Running step : Compute transformation";
				this->trepsRequest->setStatus(generalStatus.c_str());
				string url = this->callNewFrameRequest(&(*it),timeFiles);
				#endif


				if (url.compare("") == 0)
					return false;

				LOG4CXX_INFO(this->app->getLog()->getPtr(),"listNewFrame result : " << url);

				//copy result VOTable in op workspace
				generalStatus = vectorStatus;
                                generalStatus += " - Running step : Save transformation result";
				this->trepsRequest->setStatus(generalStatus.c_str());
				string filePath = this->copyFileInWorkingDir(url.c_str(),workingDir);

				if (filePath.compare("") == 0)
					return false;

				//add result
				generalStatus = vectorStatus;
                                generalStatus += " - Running step : Merge results";
				this->trepsRequest->setStatus(generalStatus.c_str());
				if (!this->addResultFileInResultVec(filePath.c_str(), &(*it)))
					return false;
			}

			return true;
		}

		t_VectorTuple3d TransformationCDPP3DViewClass::createVectorTuple3d(const t_Vector *vector)
		{
			t_VectorTuple3d vT;

			DataRecordClass *crtRecord = this->request->getSrcDataRecordList()->getFirstRecord();

			while (crtRecord != NULL)
			{
				ns4__Tuple3d *tup = new ns4__Tuple3d();
				tup->x = crtRecord->getDoubleValue(vector->fieldId[0].c_str())*vector->scale;
				tup->y = crtRecord->getDoubleValue(vector->fieldId[1].c_str())*vector->scale;
				tup->z = crtRecord->getDoubleValue(vector->fieldId[2].c_str())*vector->scale;

				vT.push_back(tup);
				crtRecord = crtRecord->getNextRecord();
			}

			return vT;
		}

		void TransformationCDPP3DViewClass::deleteVectorTuple3d(t_VectorTuple3d &vT)
		{
			for (t_VectorTuple3d::iterator it=vT.begin(); it != vT.end(); ++it)
			{
				ns4__Tuple3d *tup = (*it);
				delete tup;
			}
			vT.clear();
		}

		t_VectorTime TransformationCDPP3DViewClass::createTimeList(void)
		{
			t_VectorTime vT;
			vT.clear();

			//get time manager instance
			TimeManagerClass *timeMgr = TimeManagerClass::getInstance();

			t_Time t;
			time_t tt;

			DataRecordClass *crtRecord = this->request->getSrcDataRecordList()->getFirstRecord();

			while (crtRecord != NULL)
			{
				if (this->request->getTimeFormat() == TF_NONE)
					tt = 0;
				else
				{
					t = crtRecord->getTime();
					tt = timeMgr->to_TIMESTAMP(t);
				}
				vT.push_back(tt);
				crtRecord = crtRecord->getNextRecord();
			}

			return vT;
		}

		void TransformationCDPP3DViewClass::deleteTimeList(t_VectorTime &vT)
		{
			vT.clear();
		}

		bool TransformationCDPP3DViewClass::checkFrame(const char *frame)
		{
			this->errorMsg = "";

			if (!this->updateAvailableFrameList())
				return false;

			for (t_StringList::iterator it = this->availableFrames.begin(); it != this->availableFrames.end(); ++it)
			{
				if ((*it).compare(frame) == 0)
					return true;
			}

			this->errorMsg = "Frame not available in 3DView Web Service : ";
			this->errorMsg += frame;
			LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);

			return false;
		}

		t_StringList TransformationCDPP3DViewClass::getAvailableFrameList(void)
		{
			this->updateAvailableFrameList();
			return this->availableFrames;
		}

		bool TransformationCDPP3DViewClass::updateAvailableFrameList(void)
		{
			this->errorMsg = "";

			if (this->availableFrames.empty())
			{
				//get frames list
				_ns3__listFrames2 listFrames2Request;

				_ns3__listFrames2Response listFrames2Response;

        //compilAndInstall.sh pb compilation Ubuntu
        // error: no matching function for call to ‘cdppBinderProxy::listFrames2(_ns3__listFrames2*, _ns3__listFrames2Response*)
        bool res = (this->client->listFrames2(&listFrames2Request,&listFrames2Response) == SOAP_OK);
		//bool res = (this->client->listFrames2(&listFrames2Request,listFrames2Response) == SOAP_OK);

				if (!res)
				{
					this->errorMsg = "Error during the call of listFrames2 of 3DView Web Service";
					LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
					return false;
				}

				for (std::vector<ns4__Frame*>::iterator it=listFrames2Response.return_.begin(); it!=listFrames2Response.return_.end(); ++it)
				{
					this->availableFrames.push_back((*it)->name);
				}
				//add dynamic frames
				this->availableFrames.push_back("RTN");
				this->availableFrames.push_back("RTP");
			}

			return true;
		}

		ns4__TimeFile* TransformationCDPP3DViewClass::callListFilesRequest(int bodyId, time_t startTime, time_t stopTime)
		{
			bool res = false;
			
			
			string method = "listFiles";

			//Init 3DView listBodies request
			_ns3__listFiles listFilesRequest;
			//_ns3__listNewFrameOrb listNewFrameOrbRequest;
			//listNewFrameOrbRequest.pUrlInput = NULL;
			//listNewFrameOrbRequest.pDateTimeInput  = this->createTimeList();
			//listNewFrameOrbRequest.pInFrame  = this->request->getSrcFrame();
			//listNewFrameOrbRequest.pOutFrame  = this->request->getDstFrame();
			ns4__TimeFileType type = ns4__TimeFileType__ORBIT;
			listFilesRequest.type = &type;
			listFilesRequest.pBodyId = bodyId;
			listFilesRequest.pStartTime = startTime;
			listFilesRequest.pStopTime = stopTime;

			//run listNewFrameOrb to perform transformation (rotation + translation)
			//_ns3__listNewFrameOrbResponse listNewFrameOrbResponse;
			ns4__TimeFileArray listFilesResponse;
      
      //compilAndInstall.sh pb compilation Ubuntu
      // error: no matching function for call to ‘cdppBinderProxy::listFrames2(_ns3__listFrames2*, _ns3__listFrames2Response*)
			res = (this->client->listFiles(&listFilesRequest,&listFilesResponse) == SOAP_OK);
      		//res = (this->client->listFiles(&listFilesRequest,listFilesResponse) == SOAP_OK);      
      
      
			LOG4CXX_INFO(this->app->getLog()->getPtr(),"found timefiles" << listFilesResponse.timeFile.size());
			if(res && listFilesResponse.timeFile.size()>0) {
				return listFilesResponse.timeFile.at(0);
			} else {
				res = false;
			}
			

			if (!res)
			{
				this->errorMsg = "Error during the call of ";
				this->errorMsg += method;
				this->errorMsg += " of 3DView Web Service";
				if (this->client->soap_fault_string() != NULL)
				{
					this->errorMsg += " (";
                                        this->errorMsg += this->client->soap_fault_string();
                                        this->errorMsg += ")";
				}
				LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
				
			}

			return NULL;
		}





		#ifdef WITH_GETORBURL
		string TransformationCDPP3DViewClass::callGetOrbUrlRequest(const t_Vector *crtSrcVec)
		{
			//Init 3DView getOrbUrl request
			_ns3__getOrbUrl getOrbUrlRequest;

			//make Tuple3D list
			getOrbUrlRequest.pDataInput = this->createVectorTuple3d(crtSrcVec);

			if (getOrbUrlRequest.pDataInput.empty())
				return "";

                        //make time list
                        getOrbUrlRequest.pDateTimeInput = this->createTimeList();

			//run getOrbUrl to build a VOTable than contains current vector datas
			_ns3__getOrbUrlResponse getOrbUrlResponse;

			bool res = (this->client->getOrbUrl(&getOrbUrlRequest,&getOrbUrlResponse) == SOAP_OK);

			this->deleteTimeList(getOrbUrlRequest.pDateTimeInput);
			this->deleteVectorTuple3d(getOrbUrlRequest.pDataInput);

			if (!res)
			{
				this->errorMsg = "Error during the call of getOrbUrl of 3DView Web Service";
				if (this->client->soap_fault_string() != NULL)
				{
					this->errorMsg += " (";
					this->errorMsg += this->client->soap_fault_string();
					this->errorMsg += ")";
				}
				LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
				return "";
			}

			return this->getURLResponse(getOrbUrlResponse.return_.c_str());
		}
		#endif

		#ifdef WITH_GETORBURL
		string TransformationCDPP3DViewClass::callNewFrameRequest(const t_Vector *crtSrcVec, const char *dataURL, vector<ns4__TimeFile*> timeFiles)
		#else
		string TransformationCDPP3DViewClass::callNewFrameRequest(const t_Vector *crtSrcVec, vector<ns4__TimeFile*> timeFiles)
		#endif
		{
			bool res = false;
			string response = "";

			string method = "";

			if (crtSrcVec->ispos)
			{
				method = "listNewFrameOrb";
				//Init 3DView listNewFrameOrb request
				_ns3__listNewFrameOrb listNewFrameOrbRequest;
				#ifdef WITH_GETORBURL
				string url = dataURL;
				listNewFrameOrbRequest.pUrlInput = &url;
				#else
				listNewFrameOrbRequest.pUrlInput = NULL;
				listNewFrameOrbRequest.pDataInput = this->createVectorTuple3d(crtSrcVec);

				if (listNewFrameOrbRequest.pDataInput.empty())
					return "";

				listNewFrameOrbRequest.pDateTimeInput  = this->createTimeList();
				#endif
				listNewFrameOrbRequest.pInFrame  = this->request->getSrcFrame();
				listNewFrameOrbRequest.pOutFrame  = this->request->getDstFrame();
				//for RTN/RTP
				listNewFrameOrbRequest.pInCenter  = this->request->getSrcCenter();
				listNewFrameOrbRequest.pOutCenter  = this->request->getDstCenter();
				listNewFrameOrbRequest.pTimeFiles  = timeFiles;

				//run listNewFrameOrb to perform transformation (rotation + translation)
				_ns3__listNewFrameOrbResponse listNewFrameOrbResponse;


        //compilAndInstall.sh pb compilation ubuntu
        // error: no matching function for call 
			  	res = (this->client->listNewFrameOrb(&listNewFrameOrbRequest,&listNewFrameOrbResponse) == SOAP_OK);
        		//res = (this->client->listNewFrameOrb(&listNewFrameOrbRequest,listNewFrameOrbResponse) == SOAP_OK);


				#ifndef WITH_GETORBURL
				this->deleteTimeList(listNewFrameOrbRequest.pDateTimeInput);
				this->deleteVectorTuple3d(listNewFrameOrbRequest.pDataInput);
				#endif

				response = listNewFrameOrbResponse.return_;
			}
			else
			{
				method = "listNewFrameAtt";
				//Init 3DView listNewFrameAtt request
				_ns3__listNewFrameAtt listNewFrameAttRequest;
				#ifdef WITH_GETORBURL
				string url = dataURL;
				listNewFrameAttRequest.pUrlInput = &url;
				#else
				listNewFrameAttRequest.pUrlInput = NULL;
				listNewFrameAttRequest.pDataInput = this->createVectorTuple3d(crtSrcVec);

				if (listNewFrameAttRequest.pDataInput.empty())
					return "";

				listNewFrameAttRequest.pDateTimeInput  = this->createTimeList();
				#endif
				listNewFrameAttRequest.pInFrame  = this->request->getSrcFrame();
				listNewFrameAttRequest.pOutFrame  = this->request->getDstFrame();
				//for RTN/RTP
				listNewFrameAttRequest.pInCenter  = this->request->getSrcCenter();
				listNewFrameAttRequest.pOutCenter  = this->request->getDstCenter();
				listNewFrameAttRequest.pTimeFiles  = timeFiles;

				//run listNewFrameAtt to perform transformation (rotation)
				_ns3__listNewFrameAttResponse listNewFrameAttResponse;



        //compilAndInstall.sh pb compilation ubuntu
        // error: no matching function for call 
				res = (this->client->listNewFrameAtt(&listNewFrameAttRequest,&listNewFrameAttResponse) == SOAP_OK);
        		//res = (this->client->listNewFrameAtt(&listNewFrameAttRequest,listNewFrameAttResponse) == SOAP_OK);


				#ifndef WITH_GETORBURL
				this->deleteTimeList(listNewFrameAttRequest.pDateTimeInput);
				this->deleteVectorTuple3d(listNewFrameAttRequest.pDataInput);
				#endif

				response = listNewFrameAttResponse.return_;
			}

			if (!res)
			{
				this->errorMsg = "Error during the call of ";
				this->errorMsg += method;
				this->errorMsg += " of 3DView Web Service";
				if (this->client->soap_fault_string() != NULL)
				{
					this->errorMsg += " (";
                                        this->errorMsg += this->client->soap_fault_string();
                                        this->errorMsg += ")";
				}
				LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
				return "";
			}

			return this->getURLResponse(response.c_str());	
		}

		string TransformationCDPP3DViewClass::getURLResponse(const char *response)
		{
			string res = response;

			if (res.compare("Error No file generated.") == 0)
			{
				this->errorMsg = "3DView Web Service return an error";
				LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
				return "";
			}

			//make full URL
			string fullURL = this->app->getConf()->get3DViewWSBaseURL();
			fullURL += response;

			return fullURL;
		}

		string TransformationCDPP3DViewClass::copyFileInWorkingDir(const char *fullURL, const char *workingDir)
		{
			//Init data retriever
			DataRetrieverClass *dataRet = new DataRetrieverClass();

			//extract file name
			string fileName = getFileNameStr(fullURL);

			bool res = dataRet->copyWebFile(fullURL,workingDir,fileName.c_str());

			if (!res)
			{
				this->errorMsg = "Cannot copy result file in workind dir";
				LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
				return "";
			}

			delete dataRet;

			string filePath = getPathCorrection(workingDir);
			filePath += fileName;

			return filePath;
		}

		bool TransformationCDPP3DViewClass::addResultFileInResultVec(const char *resultFile, const t_Vector *crtSrcVec)
		{
			//Init file loader manager
			FileLoaderManagerClass *fileLoaderMgr = new FileLoaderManagerClass();

			bool res = false;

			//Get result data
			DataRecordListClass crtResData;
			crtResData.clear();

			if (fileLoaderMgr->init(resultFile))
			{
				int crtTotal = 0;
				res = fileLoaderMgr->getData(0,0,&crtResData,crtTotal);
			}

			delete fileLoaderMgr;

			if (!res)
			{
				crtResData.clear();
				this->errorMsg = "Cannot open result file";
				LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
				return false;
			}

			if (this->request->getTimeFormat() != TF_NONE)
			{
				//update time in result data
				if (!crtResData.loadTimes(CDPP3DVIEW_TIME_ID,TF_PATTERN,CDPP3DVIEW_TIME_PATTERN))
				{
					crtResData.clear();

					this->errorMsg = "Cannot load times in result file";

					LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
					return false;
				}
			}

			//make a unique field id
			string fieldId = crtSrcVec->id;

			return this->result->addFieldVector(fieldId.c_str(), &crtResData,
								CDPP3DVIEW_COMP1_ID, CDPP3DVIEW_COMP2_ID, CDPP3DVIEW_COMP3_ID,
								this->request->getDstFrame().c_str());
		}
	}
}