int cond::ListIOVUtilities::execute(){ initializePluginManager(); bool listAll = hasOptionValue("all"); cond::DbSession session = openDbSession( "connect", true ); if( listAll ){ cond::MetaData metadata_svc(session); std::vector<std::string> alltags; cond::DbScopedTransaction transaction(session); transaction.start(true); metadata_svc.listAllTags(alltags); transaction.commit(); std::copy (alltags.begin(), alltags.end(), std::ostream_iterator<std::string>(std::cout,"\n") ); }else{ std::string tag = getOptionValue<std::string>("tag"); cond::MetaData metadata_svc(session); std::string token; cond::DbScopedTransaction transaction(session); transaction.start(true); token=metadata_svc.getToken(tag); transaction.commit(); { bool verbose = hasOptionValue("verbose"); bool details = hasOptionValue("summary"); TFile * xml=0; if (details) { xml = TFile::Open(std::string(tag+".xml").c_str(),"recreate"); } cond::IOVProxy iov( session, token, !details, details); unsigned int counter=0; std::string payloadContainer=iov.payloadContainerName(); std::cout<<"Tag "<<tag; if (verbose) std::cout << "\nStamp: " << iov.iov().comment() << "; time " << cond::time::to_boost(iov.iov().timestamp()) << "; revision " << iov.iov().revision(); std::cout <<"\nTimeType " << cond::timeTypeSpecs[iov.timetype()].name <<"\nPayloadContainerName "<<payloadContainer<<"\n" <<"since \t till \t payloadToken"<<std::endl; for (cond::IOVProxy::const_iterator ioviterator=iov.begin(); ioviterator!=iov.end(); ioviterator++) { std::cout<<ioviterator->since() << " \t "<<ioviterator->till() <<" \t "<<ioviterator->wrapperToken(); if (details) { ora::Object obj = session.getObject(ioviterator->wrapperToken()); std::ostringstream ss; ss << tag << '_' << ioviterator->since(); xml->WriteObjectAny(obj.address(),obj.typeName().c_str(), ss.str().c_str()); obj.destruct(); } std::cout<<std::endl; ++counter; } if (xml) xml->Close(); std::cout<<"Total # of payload objects: "<<counter<<std::endl; } } return 0; }
std::string getToken(cond::DbSession & s, std::string & tag) { s = openDbSession("connect", true); cond::MetaData metadata_svc(s); cond::DbScopedTransaction transaction(s); transaction.start(true); std::string token = metadata_svc.getToken(tag); transaction.commit(); std::cout << "Source iov token: " << token << "\n"; return token; }