RequestBodiesGet.cpp
4.26 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
#include "RequestBodiesGet.h"
#include "../Bodies/BodiesCDPP3DView.h"
#include "../Common/Toolbox.h"
#include "../TimeManager/TimeManager.h"
using namespace TREPS::Common;
using namespace TREPS::Bodies;
using namespace TREPS::TimeManager;
namespace TREPS
{
namespace RequestManager
{
RequestBodiesGetClass::RequestBodiesGetClass(void):RequestAbstractClass(), startTime(), stopTime()
{
this->outputType = OUTPUT_XMLFILE;
}
RequestBodiesGetClass::~RequestBodiesGetClass(void)
{
}
string RequestBodiesGetClass::getRequestId(void)
{
return "bodies_get";
}
bool RequestBodiesGetClass::load(RequestLoaderClass *loader)
{
//init request and lock workind dir where we will generate result file
if (!this->initOpId(loader,true))
{
LOG4CXX_ERROR(this->app->getLog()->getPtr(),"Cannot get op Id");
return false;
}
//get isSc
string isSc = loader->getArgStrByName("issc");
if(isSc.compare("true")==0) {
this->isSc = true;
} else {
this->isSc = false;
}
LOG4CXX_INFO(this->app->getLog()->getPtr(),"RequestBodiesGetClass found isSc "<<isSc.c_str()<<" / "<<this->isSc);
//get start time
string startTime = loader->getArgStrByName("starttime");
//get end time
string stopTime = loader->getArgStrByName("stoptime");
//get time manager instance
TimeManagerClass *timeMgr = TimeManagerClass::getInstance();
string pattern = timeMgr->detectPattern(startTime.c_str());
timeMgr->setCurrentPattern(pattern.c_str());
timeMgr->from_PATTERN(startTime.c_str(),this->startTime,false);
timeMgr->from_PATTERN(stopTime.c_str(),this->stopTime,false);
LOG4CXX_INFO(this->app->getLog()->getPtr(),"RequestBodiesGetClass converted start and stop "<<startTime.c_str()<<" / "<<stopTime.c_str());
/*
t_FieldType type;
t_TimeFormat timeformat;
string timepattern;
if (pattern.compare("") != 0)
{
//a time pattern has been detected
timeformat = TF_PATTERN;
timepattern = pattern;
type = FT_TIME;
}
*/
return true;
}
bool RequestBodiesGetClass::run(void)
{
//init getBodies manager
BodiesCDPP3DViewClass *getBodies = new BodiesCDPP3DViewClass(this);
TimeManagerClass *timeMgr = TimeManagerClass::getInstance();
string isoPattern = timeMgr->getPatternFromTimeId("iso-mls-z");
timeMgr->setCurrentPattern(isoPattern.c_str());
//LOG4CXX_INFO(this->app->getLog()->getPtr(),"RequestBodiesGet init getBodies");
if (!getBodies->init(this->isSc, &(this->startTime),&(this->stopTime)))
{
this->lastMsg = getBodies->getLastError();
LOG4CXX_ERROR(this->app->getLog()->getPtr(),"Error to init transformation request");
return false;
}
//get bodies
bool res = getBodies->run();
if (!res)
{
this->lastMsg = getBodies->getLastError();
LOG4CXX_ERROR(this->app->getLog()->getPtr(),"Error during get Bodies between "<<timeMgr->to_PATTERN(this->startTime).c_str()<<" and "<<timeMgr->to_PATTERN(this->stopTime).c_str());
} else {
//get working dir
string dirPath = this->dirMgr->createNewDir(false);
if (dirPath.compare("") == 0)
{
LOG4CXX_ERROR(this->app->getLog()->getPtr(),"Error create dir path");
return false;
}
//LOG4CXX_INFO(this->app->getLog()->getPtr(),"Got dirPath: "<<dirPath.c_str());
this->filePath += getPathCorrection(this->app->getConf()->getWorkingDirPath().c_str());
this->filePath += getPathCorrection(dirPath.c_str());
this->filePath += "bodiesList.xml";
//LOG4CXX_INFO(this->app->getLog()->getPtr(),"*** RequestBodiesGet writer to file "<<this->filePath.c_str());
if (this->filePath.compare("") == 0)
{
LOG4CXX_ERROR(this->app->getLog()->getPtr(),"Error to get bodies result file path");
return false;
}
getBodies->writeResult(this->filePath.c_str());
}
//this->success = res;
delete getBodies;
return res;
}
void RequestBodiesGetClass::writeResult(ResultWriterClass *writer)
{
//No result file for this request
}
string RequestBodiesGetClass::getResultFileSuffix(void)
{
return "";
}
string RequestBodiesGetClass::getXMLFilePath(void)
{
return this->filePath;
}
string RequestBodiesGetClass::getStringResult(void)
{
return "";
}
}
}