00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 void table_reupload(const char* fDbName = 0, const char* fTableName = 0, const char* fFlavorName = "ofl",
00018 const char* fRequestTimestamp = "2011-01-01 00:00:00",
00019 const char* fStoreTimestamp = "2012-01-01 00:00:00" ) {
00020
00021
00022
00023
00024
00025
00026
00027
00028 if (!fDbName || !fTableName || !fFlavorName || !fRequestTimestamp || ! fStoreTimestamp) {
00029 std::cerr << "ERROR: Missing initialization data, please check input parameters!\n";
00030 return;
00031 }
00032
00033 gSystem->Setenv("DB_ACCESS_MODE", "write");
00034
00035
00036 gROOT->Reset();
00037
00038
00039 gSystem->Load("St_base.so");
00040 gSystem->Load("libStDb_Tables.so");
00041 gSystem->Load("StDbLib.so");
00042
00043
00044
00045 StDbManager* mgr = StDbManager::Instance();
00046 StDbConfigNode* node = mgr->initConfig(fDbName);
00047 StDbTable* dbtable = node->addDbTable(fTableName);
00048
00049
00050
00051 mgr->setRequestTime(fRequestTimestamp);
00052 mgr->fetchDbTable(dbtable);
00053
00054
00055 std::cout << "READ CHECK: " << dbtable->printCstructName() << " has data: " << (dbtable->hasData() ? "yes" : "no") << " (" << dbtable->GetNRows() << " rows)" << std::endl;
00056
00057 if (!dbtable->hasData()) {
00058 std::cout << "ERROR: This table has no data to reupload. Please try some other timestamp!";
00059 return;
00060 }
00061
00062 char confirm[255];
00063 std::string test_cnf;
00064 std::cout << "ATTENTION: please confirm that you want to reupload " << fDbName << " / " << fTableName << ", " << fRequestTimestamp << " data with " << fStoreTimestamp << " timestamp.\n Type YES to proceed: ";
00065 std::cin.getline(confirm,256);
00066 test_cnf = confirm;
00067 if (test_cnf != "YES") {
00068 std::cout << "since you've typed \"" << test_cnf << "\" and not \"YES\", data won't be reuploaded." << std::endl;
00069 return;
00070 }
00071
00072
00073 if (dbtable->hasData()) {
00074 mgr->setStoreTime(fStoreTimestamp);
00075 if (mgr->storeDbTable(dbtable)) {
00076 std::cout << "SUCCESS: Data reupload complete for " << fDbName << " / " << fTableName << " [ flavor : " << fFlavorName << " ]"
00077 << "\n" << "Data copied FROM " << fRequestTimestamp << " TO " << fStoreTimestamp << std::endl << std::endl;
00078 } else {
00079 std::cerr << "ERROR: Something went wrong. Please send error message text to DB Admin!" << std::endl;
00080 }
00081 }
00082 }