// ============================================================================= // ============================================================================= int updatetpc() { // // Update a value for the TPC table. // if (arguments.pSelectTagList.size() == 0) { cerr << "*Error: No tags given!" << endl; return 0; } FERODBFieldPositions *fp = new FERODBFieldPositions(); int32_t pos = fp->TpcTable->getPosition(arguments.pSelectField); if ( pos < 0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in TPC Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } if ( fp->TpcTable->isDate(pos) ) { cerr << "*Error: Update of dates not supported!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; // TEST MODE if ( arguments.pTest == true ) { ofstream *outFile = new ofstream(); outFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlUpdateTpcField(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateString) << ";" << endl; else if ( arguments.pUpdateString.length() == 0 ) *outFile << dbq->getSqlUpdateTpcField(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValueInt) << ";" << endl; } outFile->close(); delete outFile; } else { // DATA BASE access try { Statement st(con); for ( uint32_t iTag=0; iTaggetSqlUpdateTpcField(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateString)); st.Execute(dbq->getSqlUpdateUpdated(arguments.pSelectTagList.at(iTag))); // mark configuration(s) as updated in TPC table } else if ( arguments.pUpdateString.length() == 0 ) { st.Execute(dbq->getSqlUpdateTpcField(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValueInt)); st.Execute(dbq->getSqlUpdateUpdated(arguments.pSelectTagList.at(iTag))); // mark configuration(s) as updated in TPC table } cout << "--------------" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ": " << endl; cout << "*Updated value of " << arguments.pSelectField << endl; } con.Commit(); } catch (exception &ex) { cout << ex.what() << endl; } } return 1; } // ============================================================================= // ============================================================================= int updatepartition() { // // Update one value for an Partition. // if (arguments.pSelectTagList.size() == 0) { cerr << "*Error: No tags given!" << endl; return 0; } if (arguments.pSelectSideList.size() == 0) { cerr << "*Error: No sides given!" << endl; return 0; } if (arguments.pSelectSectorList.size() == 0) { cerr << "*Error: No sectors given!" << endl; return 0; } if (arguments.pSelectPartitionList.size() == 0) { cerr << "*Error: No partitions given!" << endl; return 0; } if ( arguments.pSelectField.compare("ON_PARTITION") != 0 ) { cerr << "*Error: Can update only column ON_PARTITION. Bad column name: " << arguments.pSelectField << endl; return 0; } // TEST MODE if ( arguments.pTest == true ) { ofstream *outFile = new ofstream(); outFile->open("DBQuery.sql"); *outFile << dbq->getSqlUpdatePartitionFieldVectors(arguments.pSelectTagList, arguments.pSelectSideList, arguments.pSelectSectorList, arguments.pSelectPartitionList, arguments.pSelectField, arguments.pUpdateValueInt) << ";" << endl; outFile->close(); delete outFile; } else { try { Statement st(con); st.Execute(dbq->getSqlUpdatePartitionFieldVectors(arguments.pSelectTagList, arguments.pSelectSideList, arguments.pSelectSectorList, arguments.pSelectPartitionList, arguments.pSelectField, arguments.pUpdateValueInt)); cout << "*Updated value of " << arguments.pSelectField << " for list of tags and positions." << endl; st.Execute(dbq->getSqlUpdateUpdated(arguments.pSelectTagList)); // mark configuration(s) as updated in TPC table con.Commit(); } catch(exception &ex) { cout << ex.what() << endl; } } return 1; } // ============================================================================= // ============================================================================= int updateallpartition() { // // Update one value for all Partitions for a given list of configuration tags. // if (arguments.pSelectTagList.size() == 0) { cerr << "*Error: No tags given!" << endl; return 0; } if ( arguments.pSelectField.compare("ON_PARTITION") != 0 ) { cerr << "*Error: Only column ON_PARTITION can be updated. Bad column name: " << arguments.pSelectField << endl; return 0; } // TEST MODE if ( arguments.pTest == true ) { ofstream *outFile = new ofstream(); outFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlUpdateFieldAllPartitions(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValueInt) << ";" << endl; outFile->close(); delete outFile; } else { // DB activity try { Statement st(con); for ( uint32_t iTag=0; iTaggetSqlUpdateFieldAllPartitions(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValueInt)); cout << "Tag " << arguments.pSelectTagList.at(iTag) << ":" << endl; cout << "*Updated all values of " << arguments.pSelectField << endl; // st.Execute(dbq->getSqlUpdateUpdated(arguments.pSelectTagList.at(iTag))); // mark configuration(s) as updated in TPC table } con.Commit(); } catch(exception &ex) { cout << ex.what() << endl; } } return 1; } // ============================================================================= // ============================================================================= int updatecru() { // // Update a value for one CRU. // if (arguments.pSelectTagList.size() == 0) { cerr << "*Error: No tags given!" << endl; return 0; } if (arguments.pSelectSideList.size() == 0) { cerr << "*Error: No sides given!" << endl; return 0; } if (arguments.pSelectSectorList.size() == 0) { cerr << "*Error: No sectors given!" << endl; return 0; } if (arguments.pSelectPartitionList.size() == 0) { cerr << "*Error: No partitions given!" << endl; return 0; } if (arguments.pSelectCruList.size() == 0) { cerr << "*Error: No crus given!" << endl; return 0; } FERODBFieldPositions *fp = new FERODBFieldPositions(); int pos = fp->CruTable->getPosition(arguments.pSelectField); if ( pos < 0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in CRU Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; if ( arguments.pTest == true ) { // TEST MODE ofstream *outFile = new ofstream(); outFile->open("DBQuery.sql"); *outFile << dbq->getSqlUpdateCruFieldVectors(arguments.pSelectTagList, arguments.pSelectSideList, arguments.pSelectSectorList, arguments.pSelectPartitionList, arguments.pSelectCruList, arguments.pSelectField, arguments.pUpdateValueInt, arguments.pUpdateValueFloat) << ";" << endl; outFile->close(); delete outFile; } else { // DB activity try { Statement st(con); st.Execute(dbq->getSqlUpdateCruFieldVectors(arguments.pSelectTagList, arguments.pSelectSideList, arguments.pSelectSectorList, arguments.pSelectPartitionList, arguments.pSelectCruList, arguments.pSelectField, arguments.pUpdateValueInt, arguments.pUpdateValueFloat)); cout << "*Updated value of " << arguments.pSelectField << " for list of tags and positions." << endl; // st.Execute(dbq->getSqlUpdateUpdated(arguments.pSelectTagList)); // mark configuration(s) as updated in TPC table con.Commit(); } catch(exception &ex) { cout << ex.what() << endl; } } return 1; } // ============================================================================= // ============================================================================= int updateallcru() { // // Update a column for all CRUs for a given list of configIDs. // if (arguments.pSelectTagList.size() == 0) { cerr << "*Error: No tags given!" << endl; return 0; } FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( fp->CruTable->getPosition(arguments.pSelectField) <0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in CRU Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; if ( arguments.pTest == true ) { // TEST MODE ofstream *outFile = new ofstream(); outFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlUpdateFieldAllCru(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValueInt, arguments.pUpdateValueFloat) << ";" << endl; outFile->close(); delete outFile; } else { // DB activity try { Statement st(con); for ( uint32_t iTag=0; iTaggetSqlUpdateFieldAllCru(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValueInt, arguments.pUpdateValueFloat)); cout << "Tag " << arguments.pSelectTagList.at(iTag) << ": " << endl; cout << "*Updated all values of " << arguments.pSelectField << endl; st.Execute(dbq->getSqlUpdateUpdated(arguments.pSelectTagList.at(iTag))); // mark configuration(s) as updated in TPC table } con.Commit(); } catch(exception &ex) { cout << ex.what() << endl; } } return 1; } // ============================================================================= // ============================================================================= int updatefec() { // // Update a value for one FEC. // if (arguments.pSelectTagList.size() == 0) { cerr << "*Error: No tags given!" << endl; return 0; } if (arguments.pSelectSideList.size() == 0) { cerr << "*Error: No sides given!" << endl; return 0; } if (arguments.pSelectSectorList.size() == 0) { cerr << "*Error: No sectors given!" << endl; return 0; } if (arguments.pSelectPartitionList.size() == 0) { cerr << "*Error: No partitions given!" << endl; return 0; } if (arguments.pSelectBranchList.size() == 0) { cerr << "*Error: No branches given!" << endl; return 0; } if (arguments.pSelectFecList.size() == 0) { cerr << "*Error: No fecs given!" << endl; return 0; } FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( fp->FecTable->getPosition(arguments.pSelectField) <0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in FEC Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; // TEST MODE if ( arguments.pTest == true ) { ofstream *outFile = new ofstream(); outFile->open("DBQuery.sql"); *outFile << dbq->getSqlUpdateFecFieldVectors(arguments.pSelectTagList, arguments.pSelectSideList, arguments.pSelectSectorList, arguments.pSelectPartitionList, arguments.pSelectBranchList, arguments.pSelectFecList, arguments.pSelectField, arguments.pUpdateValueInt) << ";" << endl; outFile->close(); delete outFile; } else { // DB activity try { Statement st(con); st.Execute(dbq->getSqlUpdateFecFieldVectors(arguments.pSelectTagList, arguments.pSelectSideList, arguments.pSelectSectorList, arguments.pSelectPartitionList, arguments.pSelectBranchList, arguments.pSelectFecList, arguments.pSelectField, arguments.pUpdateValueInt)); cout << "*Updated value of " << arguments.pSelectField << " for list of tags and positions." << endl; st.Execute(dbq->getSqlUpdateUpdated(arguments.pSelectTagList)); // mark configuration(s) as updated in TPC table con.Commit(); } catch(exception &ex) { cout << ex.what() << endl; } } return 1; } // ============================================================================= // ============================================================================= int updateallfec() { // // Update a column for all FECs of a given list of configIDs. // if (arguments.pSelectTagList.size() == 0) { cerr << "*Error: No tags given!" << endl; return 0; } FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( fp->FecTable->getPosition(arguments.pSelectField) <0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in FEC Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; if ( arguments.pTest == true ) { // TEST MODE ofstream *outFile = new ofstream(); outFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlUpdateFieldAllFec(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValueInt) << ";" << endl; } outFile->close(); delete outFile; } else { // DB activity try { Statement st(con); for ( uint32_t iTag=0; iTaggetSqlUpdateFieldAllFec(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValueInt)); cout << "Tag " << arguments.pSelectTagList.at(iTag) << ": " << endl; cout << "*Updated all values of " << arguments.pSelectField << endl; st.Execute(dbq->getSqlUpdateUpdated(arguments.pSelectTagList.at(iTag))); // mark configuration(s) as updated in TPC table } con.Commit(); } catch(exception &ex) { cout << ex.what() << endl; } } return 1; } // ============================================================================= // ============================================================================= int updateUL(string tablename) { // // Update a value in one of the UL registers. // if (arguments.pSelectTagList.size() == 0) { cerr << "*Error: No tags given!" << endl; return 0; } if (arguments.pSelectSideList.size() == 0) { cerr << "*Error: No sides given!" << endl; return 0; } if (arguments.pSelectSectorList.size() == 0) { cerr << "*Error: No sectors given!" << endl; return 0; } if (arguments.pSelectPartitionList.size() == 0) { cerr << "*Error: No partitions given!" << endl; return 0; } if (arguments.pSelectCruList.size() == 0) { cerr << "*Error: No CRUs given!" << endl; return 0; } if (arguments.pSelectFecList.size() == 0) { cerr << "*Error: No fecs given!" << endl; return 0; } FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( fp->UlTable->getPosition(arguments.pSelectField) <0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in table " << tablename << " (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; // TEST MODE if ( arguments.pTest == true ) { ofstream *outFile = new ofstream(); outFile->open("DBQuery.sql"); *outFile << dbq->getSqlUpdateUlFieldVectors(tablename, arguments.pSelectTagList, arguments.pSelectSideList, arguments.pSelectSectorList, arguments.pSelectPartitionList, arguments.pSelectCruList, arguments.pSelectBranchList, arguments.pSelectFecList, arguments.pSelectField, arguments.pUpdateValueInt, arguments.pUpdateValueFloat) << ";" << endl; outFile->close(); delete outFile; } else { // DB activity try { Statement st(con); st.Execute(dbq->getSqlUpdateUlFieldVectors(tablename, arguments.pSelectTagList, arguments.pSelectSideList, arguments.pSelectSectorList, arguments.pSelectPartitionList, arguments.pSelectCruList, arguments.pSelectBranchList, arguments.pSelectFecList, arguments.pSelectField, arguments.pUpdateValueInt, arguments.pUpdateValueFloat)); cout << "*Updated value of " << arguments.pSelectField << " for list of tags and positions." << endl; st.Execute(dbq->getSqlUpdateUpdated(arguments.pSelectTagList)); // mark configuration(s) as updated in TPC table con.Commit(); } catch(exception &ex) { cout << ex.what() << endl; } } return 1; } // ============================================================================= // ============================================================================= int updateallUL(string tablename) { // // Update a column in the given UL table for all links of a given list of configIDs. // if (arguments.pSelectTagList.size() == 0) { cerr << "*Error: No tags given!" << endl; return 0; } FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( fp->UlTable->getPosition(arguments.pSelectField) < 0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in table " << tablename << " (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; if ( arguments.pTest == true ) { // TEST MODE ofstream *outFile = new ofstream(); outFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlUpdateFieldAllUl(tablename, arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValueInt, arguments.pUpdateValueFloat) << ";" << endl; outFile->close(); delete outFile; } else { // DB activity try { Statement st(con); for ( uint32_t iTag=0; iTaggetSqlUpdateFieldAllUl(tablename, arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValueInt, arguments.pUpdateValueFloat)); cout << "Tag " << arguments.pSelectTagList.at(iTag) << ": " << endl; cout << "*Updated all values of " << arguments.pSelectField << endl; st.Execute(dbq->getSqlUpdateUpdated(arguments.pSelectTagList.at(iTag))); // mark configuration(s) as updated in TPC table } con.Commit(); } catch(exception &ex) { cout << ex.what() << endl; } } return 1; }