// ============================================================================= // ============================================================================= 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(); if ( fp->TpcTable->getPosition(arguments.pSelectField) < 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(fp->TpcTable->getPosition(arguments.pSelectField)) ) { cerr << "*Error: Update of dates not supported!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlUpdateTpcField(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateString) << ";" << endl; else if ( arguments.pUpdateString.length() == 0 ) *seperateOutFile << dbq->getSqlUpdateTpcField(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValue) << ";" << endl; } seperateOutFile->close(); delete seperateOutFile; return 1; } try { for ( uint32_t iTag=0; iTagexecuteUpdate(dbq->getSqlUpdateTpcField(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateString)); // mark configuration(s) as updated in TPC table db->executeUpdate(dbq->getSqlUpdateUpdated(arguments.pSelectTagList.at(iTag))); } else if ( arguments.pUpdateString.length() == 0 ) { db->executeUpdate(dbq->getSqlUpdateTpcField(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValue)); // mark configuration(s) as updated in TPC table db->executeUpdate(dbq->getSqlUpdateUpdated(arguments.pSelectTagList.at(iTag))); } cout << "--------------" << endl; cout << "Tag " << arguments.pSelectTagList.at(iTag) << ": " << endl; cout << "*Updated value of " << arguments.pSelectField << endl; cout << "--------------" << endl; } } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } return 1; } // ============================================================================= // ============================================================================= int updatercu() { // // Update one value for an Rcu. // 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.pSelectRcuList.size() == 0) { cerr << "*Error: No rcus given!" << endl; return 0; } FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( fp->RcuTable->getPosition(arguments.pSelectField) <0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in RCU Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); *seperateOutFile << dbq->getSqlUpdateRcuFields(arguments.pSelectTagList, arguments.pSelectSideList, arguments.pSelectSectorList, arguments.pSelectRcuList, arguments.pSelectField, arguments.pUpdateValue) << ";" << endl; seperateOutFile->close(); delete seperateOutFile; return 1; } try { db->executeUpdate(dbq->getSqlUpdateRcuFields(arguments.pSelectTagList, arguments.pSelectSideList, arguments.pSelectSectorList, arguments.pSelectRcuList, arguments.pSelectField, arguments.pUpdateValue)); cout << "*Updated value of " << arguments.pSelectField << " for list of tags and positions." << endl; // mark configuration(s) as updated in TPC table if ( arguments.pTest == false ) db->executeUpdate(dbq->getSqlUpdateUpdated(arguments.pSelectTagList)); } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } return 1; } // ============================================================================= // ============================================================================= int updateallrcu() { // // Update one value for all Rcus in a given list of configurations. // if (arguments.pSelectTagList.size() == 0) { cerr << "*Error: No tags given!" << endl; return 0; } FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( fp->RcuTable->getPosition(arguments.pSelectField) <0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in RCU Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; for ( uint32_t iTag=0; iTagopen("DBQuery.sql"); *seperateOutFile << dbq->getSqlUpdateFieldAllRcu(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValue) << ";" << endl; seperateOutFile->close(); delete seperateOutFile; return 1; } cout << "--------------" << endl; db->executeUpdate(dbq->getSqlUpdateFieldAllRcu(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValue)); cout << "Tag " << arguments.pSelectTagList.at(iTag) << ":" << endl; cout << "*Updated all values of " << arguments.pSelectField << endl; cout << "--------------" << endl; // mark configuration(s) as updated in TPC table if ( arguments.pTest == false ) db->executeUpdate(dbq->getSqlUpdateUpdated(arguments.pSelectTagList.at(iTag))); } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } 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.pSelectRcuList.size() == 0) { cerr << "*Error: No rcus 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; if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); *seperateOutFile << dbq->getSqlUpdateFecFields(arguments.pSelectTagList, arguments.pSelectSideList, arguments.pSelectSectorList, arguments.pSelectRcuList, arguments.pSelectBranchList, arguments.pSelectFecList, arguments.pSelectField, arguments.pUpdateValue) << ";" << endl; seperateOutFile->close(); delete seperateOutFile; return 1; } try { db->executeUpdate(dbq->getSqlUpdateFecFields(arguments.pSelectTagList, arguments.pSelectSideList, arguments.pSelectSectorList, arguments.pSelectRcuList, arguments.pSelectBranchList, arguments.pSelectFecList, arguments.pSelectField, arguments.pUpdateValue)); cout << "*Updated value of " << arguments.pSelectField << " for list of tags and positions." << endl; // mark configuration(s) as updated in TPC table db->executeUpdate(dbq->getSqlUpdateUpdated(arguments.pSelectTagList)); } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } 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 ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlUpdateFieldAllFec(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValue) << ";" << endl; } seperateOutFile->close(); delete seperateOutFile; return 1; } for ( uint32_t iTag=0; iTagexecuteUpdate(dbq->getSqlUpdateFieldAllFec(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValue)); cout << "Tag " << arguments.pSelectTagList.at(iTag) << ": " << endl; cout << "*Updated all values of " << arguments.pSelectField << endl; cout << "--------------" << endl; // mark configuration(s) as updated in TPC table db->executeUpdate(dbq->getSqlUpdateUpdated(arguments.pSelectTagList.at(iTag))); } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } return 1; } // ============================================================================= // ============================================================================= int updatealtro() { // // Update a value for one Altro. // 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.pSelectRcuList.size() == 0) { cerr << "*Error: No rcus 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; } if (arguments.pSelectAltroList.size() == 0) { cerr << "*Error: No altros given!" << endl; return 0; } FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( fp->AltroTable->getPosition(arguments.pSelectField) < 0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in ALTRO Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); *seperateOutFile << dbq->getSqlUpdateAltroFields(arguments.pSelectTagList, arguments.pSelectSideList, arguments.pSelectSectorList, arguments.pSelectRcuList, arguments.pSelectBranchList, arguments.pSelectFecList, arguments.pSelectAltroList, arguments.pSelectField, arguments.pUpdateValue) << ";" << endl; seperateOutFile->close(); delete seperateOutFile; return 1; } try { db->executeUpdate(dbq->getSqlUpdateAltroFields(arguments.pSelectTagList, arguments.pSelectSideList, arguments.pSelectSectorList, arguments.pSelectRcuList, arguments.pSelectBranchList, arguments.pSelectFecList, arguments.pSelectAltroList, arguments.pSelectField, arguments.pUpdateValue)); cout << "*Updated value of " << arguments.pSelectField << " for list of tags and positions." << endl; // mark configuration(s) as updated in TPC table db->executeUpdate(dbq->getSqlUpdateUpdated(arguments.pSelectTagList)); } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } return 1; } // ============================================================================= // ============================================================================= int updateallaltro() { // // Update all value for all Altro in a given list of configurations. // if (arguments.pSelectTagList.size() == 0) { cerr << "*Error: No tags given!" << endl; return 0; } FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( fp->AltroTable->getPosition(arguments.pSelectField) < 0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in ALTRO Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("DBQuery.sql"); for ( uint32_t iTag=0; iTaggetSqlUpdateFieldAllAltro(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValue) << ";" << endl; seperateOutFile->close(); delete seperateOutFile; return 1; } for ( uint32_t iTag=0; iTagexecuteUpdate(dbq->getSqlUpdateFieldAllAltro(arguments.pSelectTagList.at(iTag), arguments.pSelectField, arguments.pUpdateValue)); cout << "Tag " << arguments.pSelectTagList.at(iTag) << ": " << endl; cout << "*Updated all values of " << arguments.pSelectField << endl; cout << "--------------" << endl; // mark configuration(s) as updated in TPC table db->executeUpdate(dbq->getSqlUpdateUpdated(arguments.pSelectTagList.at(iTag))); } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } return 1; }