00001
00002
00003
00004
00005
00006
00007
00008 #include "BaBar/BaBar.hh"
00009
00010 #include "CdbBdb/CdbBdbObjectFactory.hh"
00011 #include "CdbBdb/CdbBdbObjectCreator.hh"
00012 #include "CdbBdb/CdbBdb.hh"
00013
00014 #include "CdbBase/Cdb.hh"
00015 #include "CdbBase/CdbDatabase.hh"
00016 #include "CdbBase/CdbCondition.hh"
00017 #include "CdbBase/CdbObject.hh"
00018
00019 #include "BdbTime/BdbTime.hh"
00020
00021 #include "ErrLogger/ErrLog.hh"
00022
00023 #include <string>
00024
00025 CdbBdbObjectFactory::CdbBdbObjectFactory( bool verifyFlag ) :
00026 _verifyFlag(verifyFlag)
00027 { }
00028
00029 CdbBdbObjectFactory::~CdbBdbObjectFactory( )
00030 { }
00031
00032 CdbStatus
00033 CdbBdbObjectFactory::create( CdbObjectPtr& thePtr,
00034 const CdbConditionPtr& theConditionPtr,
00035 const BdbTime& theBegin,
00036 const BdbTime& theEnd )
00037 {
00038 CdbStatus status = CdbStatus::Error;
00039
00040 const char* errorStr = "CdbBdbObjectFactory::create() -- ERROR.";
00041
00042
00043
00044
00045
00046 if( theConditionPtr.isNull( )) return CdbStatus::IllegalParameters;
00047
00048
00049
00050
00051 const std::string apiTechnologyName = theConditionPtr->parentDatabase( )->parent( )->technologyName( );
00052
00053 if( apiTechnologyName != CdbBdb::technology( )) {
00054 ErrMsg(error) << errorStr << "\n"
00055 << " The factory is being used in a wrong CDB API context. The condition's technology\n"
00056 << " doesn't match the expected one.\n"
00057 << " CONDITION API OBJECT 'TECHNOLOGY' : \"" << apiTechnologyName << "\"\n"
00058 << " EXPECTED 'TECHNOLOGY' : \"" << CdbBdb::technology( ) << "\"" << endmsg;
00059 return CdbStatus::ConflictOfParameters;
00060 }
00061
00062
00063
00064
00065
00066
00067 BdbRefAny hint;
00068
00069 status = CdbBdbObjectCreator::hint( hint,
00070 theConditionPtr,
00071 theBegin,
00072 theEnd );
00073 if( CdbStatus::Success != status ) return status;
00074
00075
00076
00077 BdbHandle(BdbObject) product;
00078
00079 status = doCreate( product,
00080 hint );
00081 if( CdbStatus::Success != status ) return status;
00082
00083
00084
00085 if( _verifyFlag ) {
00086 status = CdbBdbObjectCreator::verify( hint,
00087 product,
00088 theConditionPtr );
00089 if( CdbStatus::Success != status ) return status;
00090 }
00091
00092
00093
00094
00095
00096
00097
00098 BdbTime insertionTime( BdbTime::now( ));
00099
00100 status = CdbBdbObjectCreator::object( thePtr,
00101 theConditionPtr,
00102 theBegin,
00103 theEnd,
00104 theBegin,
00105 theEnd,
00106 insertionTime,
00107 BdbTime::plusInfinity,
00108 insertionTime,
00109 product );
00110 if( CdbStatus::Success != status ) return status;
00111
00112 return CdbStatus::Success;
00113 }
00114
00115
00116
00117