| 56 |
* @param debug debug flag. |
* @param debug debug flag. |
| 57 |
* @param tlefilename ascii file with TLE 3 line elements. |
* @param tlefilename ascii file with TLE 3 line elements. |
| 58 |
*/ |
*/ |
| 59 |
PamelaDBOperations::PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug, TString tlefilename, UInt_t dwinput){ |
PamelaDBOperations::PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug, TString tlefilename, UInt_t dwinput, Bool_t staticp){ |
| 60 |
// |
// |
| 61 |
|
STATIC=false; |
| 62 |
|
if ( staticp ) STATIC=true; |
| 63 |
// |
// |
| 64 |
SetConnection(host,user,password); |
SetConnection(host,user,password); |
| 65 |
// |
// |
| 263 |
tlefilename = str; |
tlefilename = str; |
| 264 |
}; |
}; |
| 265 |
|
|
| 266 |
|
TString PamelaDBOperations::GetRawPath(){ |
| 267 |
|
if ( STATIC ){ |
| 268 |
|
return((TString)gSystem->DirName(filerawname.Data())+'/'); |
| 269 |
|
} else { |
| 270 |
|
return((TString)gSystem->ExpandPathName("$PAM_RAW")+'/'); |
| 271 |
|
}; |
| 272 |
|
}; |
| 273 |
|
|
| 274 |
|
TString PamelaDBOperations::GetRootPath(){ |
| 275 |
|
if ( STATIC ){ |
| 276 |
|
return((TString)gSystem->DirName(filerootname.Data())+'/'); |
| 277 |
|
} else { |
| 278 |
|
return((TString)gSystem->ExpandPathName("$PAM_L0")+'/'); |
| 279 |
|
}; |
| 280 |
|
}; |
| 281 |
|
|
| 282 |
/** |
/** |
| 283 |
* Store the olderthan variable |
* Store the olderthan variable |
| 284 |
* @param olderthan |
* @param olderthan |
| 295 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 296 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
| 297 |
oss.str(""); |
oss.str(""); |
| 298 |
oss << "SELECT ID FROM GL_RAW WHERE " |
if ( STATIC ){ |
| 299 |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
oss << "SELECT ID FROM GL_RAW WHERE " |
| 300 |
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
| 301 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
| 302 |
|
} else { |
| 303 |
|
oss << "SELECT ID FROM GL_RAW WHERE " |
| 304 |
|
<< " PATH = '$PAM_RAW' AND " |
| 305 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
| 306 |
|
} |
| 307 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 308 |
if ( result == NULL ) throw -4; |
if ( result == NULL ) throw -4; |
| 309 |
row = result->Next(); |
row = result->Next(); |
| 1003 |
if ( idr ) return(1); |
if ( idr ) return(1); |
| 1004 |
// |
// |
| 1005 |
oss.str(""); |
oss.str(""); |
| 1006 |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
if ( STATIC ){ |
| 1007 |
<< this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
| 1008 |
|
<< this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
| 1009 |
|
} else { |
| 1010 |
|
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << this->GetRawFile().Data() << "')"; |
| 1011 |
|
}; |
| 1012 |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
| 1013 |
// |
// |
| 1014 |
idr = this->SetID_RAW(); |
idr = this->SetID_RAW(); |
| 1289 |
UInt_t idtimesync = 0; |
UInt_t idtimesync = 0; |
| 1290 |
// |
// |
| 1291 |
oss.str(""); |
oss.str(""); |
| 1292 |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
if ( STATIC ){ |
| 1293 |
<< " LEFT JOIN GL_ROOT " |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
| 1294 |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
<< " LEFT JOIN GL_ROOT " |
| 1295 |
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
| 1296 |
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
| 1297 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
| 1298 |
|
} else { |
| 1299 |
|
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
| 1300 |
|
<< " LEFT JOIN GL_ROOT " |
| 1301 |
|
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
| 1302 |
|
<< " WHERE GL_RAW.PATH = '$PAM_RAW' AND " |
| 1303 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
| 1304 |
|
}; |
| 1305 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 1306 |
// |
// |
| 1307 |
if ( !result ) throw -12; |
if ( !result ) throw -12; |
| 1328 |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
| 1329 |
// |
// |
| 1330 |
oss.str(""); |
oss.str(""); |
| 1331 |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
if ( STATIC ){ |
| 1332 |
<< this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')"; |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
| 1333 |
|
<< this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')"; |
| 1334 |
|
} else { |
| 1335 |
|
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
| 1336 |
|
<< this->GetID_RAW() << "', '" << idtimesync << "', '$PAM_L0', '" << this->GetRootFile().Data() << "')"; |
| 1337 |
|
}; |
| 1338 |
// |
// |
| 1339 |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
| 1340 |
// |
// |
| 1361 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 1362 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
| 1363 |
oss.str(""); |
oss.str(""); |
| 1364 |
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
if ( STATIC ){ |
| 1365 |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
| 1366 |
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
| 1367 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
| 1368 |
|
} else { |
| 1369 |
|
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
| 1370 |
|
<< " PATH = '$PAM_RAW' AND " |
| 1371 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
| 1372 |
|
}; |
| 1373 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 1374 |
// |
// |
| 1375 |
if ( !result ) throw -4;; |
if ( !result ) throw -4;; |