00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "CondTools/DT/plugins/DTConfigDBCopy.h"
00014
00015
00016
00017
00018 #include "CondTools/DT/interface/DTConfigHandler.h"
00019 #include "CondTools/DT/interface/DTDBSession.h"
00020 #include "FWCore/Framework/interface/MakerMacros.h"
00021
00022
00023
00024
00025 #include <iostream>
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 DTConfigDBCopy::DTConfigDBCopy( const edm::ParameterSet& ps ):
00036 sourceContact( ps.getParameter<std::string> ( "sourceContact" ) ),
00037 sourceCatalog( ps.getParameter<std::string> ( "sourceCatalog" ) ),
00038 sourceToken( ps.getParameter<std::string> ( "sourceToken" ) ),
00039 sourceAuthPath( ps.getParameter<std::string> ( "sourceAuthPath" ) ),
00040 targetContact( ps.getParameter<std::string> ( "targetContact" ) ),
00041 targetCatalog( ps.getParameter<std::string> ( "targetCatalog" ) ),
00042 targetToken( ps.getParameter<std::string> ( "targetToken" ) ),
00043 targetAuthPath( ps.getParameter<std::string> ( "targetAuthPath" ) ) {
00044 }
00045
00046
00047
00048
00049 DTConfigDBCopy::~DTConfigDBCopy() {
00050 }
00051
00052
00053
00054
00055 void DTConfigDBCopy::beginJob( edm::EventSetup const& c ) {
00056
00057 DTDBSession* sourceSession = new DTDBSession( sourceContact,
00058 sourceCatalog,
00059 sourceAuthPath );
00060 DTDBSession* targetSession = new DTDBSession( targetContact,
00061 targetCatalog,
00062 targetAuthPath );
00063 sourceSession->connect( false );
00064 targetSession->connect( false );
00065
00066 const DTConfigList* confList = 0;
00067
00068 DTConfigHandler* confHandler =
00069 DTConfigHandler::create( sourceSession, sourceToken );
00070 confList = confHandler->getContainer();
00071
00072 std::string cloneToken;
00073 if ( confHandler != 0 ) {
00074 if ( targetToken.length() ) {
00075 cloneToken = confHandler->clone( targetSession, targetToken,
00076 "DTConfigList", "DTConfigData" );
00077 if ( cloneToken.length() ) std::cout << "unvalid target token, new "
00078 << "configuration list created"
00079 << std::endl;
00080 else std::cout << "existing "
00081 << "configuration list updated"
00082 << std::endl;
00083 }
00084 else {
00085 cloneToken = confHandler->clone( targetSession, "",
00086 "DTConfigList", "DTConfigData" );
00087 }
00088 }
00089 if ( cloneToken.length() )
00090 std::cout << "configuration list copied with token: " << cloneToken
00091 << std::endl;
00092 else
00093 std::cout << "configuration list updated"
00094 << std::endl;
00095
00096 DTConfigHandler::remove( sourceSession );
00097 sourceSession->disconnect();
00098 targetSession->disconnect();
00099 delete sourceSession;
00100 delete targetSession;
00101
00102 return;
00103
00104 }
00105
00106
00107 void DTConfigDBCopy::analyze( const edm::Event& e,
00108 const edm::EventSetup& c ) {
00109 return;
00110 }
00111
00112 DEFINE_FWK_MODULE(DTConfigDBCopy);
00113