#include <DbiRollbackDates.h>
Public Types | |
| typedef std::map< std::string, std::string > | name_map_t |
Public Member Functions | |
| DbiRollbackDates () | |
| virtual | ~DbiRollbackDates () |
| const std::string & | GetDate (const std::string &tableName) const |
| const std::string & | GetType (const std::string &tableName) const |
| void | Show () const |
| void | Clear () |
| void | Set (Registry ®) |
Private Attributes | |
| name_map_t | fTableToDate |
| Look-up table name -> date string. | |
| name_map_t | fTableToType |
| Look-up table name -> time type (either "INSERTDATE" [default] or "CREATIONDATE"). | |
DatabaseInterface
Contact: n.west1@physics.ox.ac.uk
Definition at line 35 of file DbiRollbackDates.h.
|
|
Definition at line 40 of file DbiRollbackDates.h. |
|
|
Definition at line 31 of file DbiRollbackDates.cxx. 00032 {
00033 //
00034 //
00035 // Purpose: Default constructor
00036 //
00037 // Contact: N. West
00038 //
00039 // Specification:-
00040 // =============
00041 //
00042 // o Create DbiRollbackDates.
00043
00044
00045 // Program Notes:-
00046 // =============
00047
00048 // None.
00049
00050 LEA_CTOR //Leak Checker
00051
00052 MSG("Dbi", Msg::kVerbose) << "Creating DbiRollbackDates" << endl;
00053 }
|
|
|
Definition at line 56 of file DbiRollbackDates.cxx. 00056 {
00057 //
00058 //
00059 // Contact: N. West
00060 //
00061 // Specification:-
00062 // =============
00063 //
00064 // o Destroy DbiRollbackDates.
00065
00066
00067 LEA_DTOR //Leak Checker
00068
00069 MSG("Dbi", Msg::kVerbose) << "Destroying DbiRollbackDates" << endl;
00070
00071 }
|
|
|
Definition at line 54 of file DbiRollbackDates.h. Referenced by DbiTableProxyRegistry::ClearRollbackDates(). 00054 {fTableToDate.clear(); fTableToType.clear();}
|
|
|
Definition at line 74 of file DbiRollbackDates.cxx. References UtilString::cmp_wildcard(), and fTableToDate. Referenced by DbiTableProxyRegistry::ApplySqlCondition(). 00074 {
00075 //
00076 //
00077 // Purpose: Return rollback date associated with named table.
00078 //
00079 // Contact: N. West
00080
00081 // Program Notes:-
00082 // =============
00083
00084 // Search in reverse order so that specific entries are processed
00085 // before generic (i.e. ones that end in wildcard *).
00086
00087 static std::string date;
00088
00089 name_map_t::const_reverse_iterator itr = fTableToDate.rbegin();
00090 name_map_t::const_reverse_iterator itrEnd = fTableToDate.rend();
00091 for (; itr != itrEnd; ++itr)
00092 if ( ! UtilString::cmp_wildcard(tableName,itr->first)
00093 ) return itr->second;
00094 return date;
00095 }
|
|
|
Definition at line 98 of file DbiRollbackDates.cxx. References UtilString::cmp_wildcard(), and fTableToType. Referenced by DbiTableProxyRegistry::ApplySqlCondition(). 00098 {
00099 //
00100 //
00101 // Purpose: Return rollback time type associated with named table.
00102 //
00103 // Contact: N. West
00104
00105 // Program Notes:-
00106 // =============
00107
00108 // Search in reverse order so that specific entries are processed
00109 // before generic (i.e. ones that end in wildcard *).
00110
00111 static std::string type("INSERTDATE"); // The default type
00112
00113 name_map_t::const_reverse_iterator itr = fTableToType.rbegin();
00114 name_map_t::const_reverse_iterator itrEnd = fTableToType.rend();
00115 for (; itr != itrEnd; ++itr)
00116 if ( ! UtilString::cmp_wildcard(tableName,itr->first)
00117 ) return itr->second;
00118 return type;
00119 }
|
|
|
Definition at line 122 of file DbiRollbackDates.cxx. References fTableToDate, fTableToType, Registry::Get(), Dbi::MakeDateTimeString(), MSG, reg, Registry::RemoveKey(), and Show(). Referenced by DbiTableProxyRegistry::Config(). 00122 {
00123 //
00124 //
00125 // Purpose: Extract Rollback dates from Registry.
00126 //
00127 // Arguments:
00128 // reg in Registry containing "Rollback:" and "RollbackType:" keys.
00129 // out Updated Registry with these keys removed.
00130 //
00131 // Contact: N. West
00132 //
00133 // Specification:-
00134 // =============
00135 //
00136 // o Extract Rollback dates from Registry.
00137
00138 Registry::RegistryKey keyItr(®);
00139
00140 Bool_t hasChanged = kFALSE;
00141
00142 const char* key = keyItr();
00143 while ( key ) {
00144
00145 const char* nextKey = keyItr();
00146
00147 // Process Rollback keys
00148
00149 if ( ! strncmp("Rollback:",key,9) ) {
00150 std::string tableName = key+9;
00151 std::string date;
00152 const char* dateChars = 0;
00153 bool ok = reg.Get(key,dateChars);
00154 if ( ok ) {
00155 date = dateChars;
00156 VldTimeStamp ts(Dbi::MakeTimeStamp(date,&ok));
00157 date = Dbi::MakeDateTimeString(ts);
00158 }
00159 if ( ok ) {
00160
00161 // Prune away any trailing spaces - they cause SQL
00162 // to fail expressions involving the date.
00163 int loc = date.size()-1;
00164 while ( loc && date[loc] == ' ' ) date.erase(loc--);
00165
00166 fTableToDate[tableName] = date;
00167 hasChanged = kTRUE;
00168
00169 }
00170 else MSG("Dbi",Msg::kWarning)
00171 << "Illegal Rollback registry item: " << key
00172 << " = " << dateChars << endl;
00173 reg.RemoveKey(key);
00174 }
00175
00176 // Process RollbackType keys
00177
00178 else if ( ! strncmp("RollbackType:",key,13) ) {
00179 std::string tableName = key+13;
00180 TString type;
00181 const char* typeChars = 0;
00182 bool ok = reg.Get(key,typeChars);
00183 if ( ok ) {
00184 // Convert to upper case and remove any leading or trailing spaces
00185 type = typeChars;
00186 type.ToUpper();
00187 type = type.Strip(TString::kBoth);
00188 ok = ! type.CompareTo("INSERTDATE") || ! type.CompareTo("CREATIONDATE");
00189 }
00190 if ( ok ) {
00191 fTableToType[tableName] = type.Data();
00192 hasChanged = kTRUE;
00193 }
00194 else MSG("Dbi",Msg::kWarning)
00195 << "Illegal RollbackType registry item: " << key
00196 << " = " << typeChars << endl;
00197 reg.RemoveKey(key);
00198 }
00199 key = nextKey;
00200 }
00201
00202 if ( hasChanged ) this->Show();
00203 }
|
|
|
Definition at line 206 of file DbiRollbackDates.cxx. References fTableToDate, fTableToType, and MSGSTREAM. Referenced by Set(). 00206 {
00207 //
00208 //
00209 // Purpose: Print out the current Rollback date status.
00210 //
00211 //
00212 // Contact: N. West
00213 //
00214
00215 MsgStream msg = MSGSTREAM("Dbi",Msg::kInfo);
00216 msg << "\n\nRollback Status: ";
00217 if ( fTableToDate.size() == 0 ) msg <<"Not enabled" << endl;
00218 else {
00219 msg << "\n\n Dates:- " << endl;
00220 name_map_t::const_reverse_iterator itr = fTableToDate.rbegin();
00221 name_map_t::const_reverse_iterator itrEnd = fTableToDate.rend();
00222 for (; itr != itrEnd; ++itr) {
00223 std::string name = itr->first;
00224 if ( name.size() < 30 ) name.append(30-name.size(),' ');
00225 msg <<" " << name << " " << itr->second << endl;
00226 }
00227 msg << "\n Rollback Type is 'INSERTDATE'";
00228 if ( fTableToType.size() ) {
00229 msg << " except as follows:- " << endl;
00230 itr = fTableToType.rbegin();
00231 itrEnd = fTableToType.rend();
00232 for (; itr != itrEnd; ++itr) {
00233 std::string name = itr->first;
00234 if ( name.size() < 30 ) name.append(30-name.size(),' ');
00235 msg <<" " << name << " " << itr->second << endl;
00236 }
00237 }
00238 msg << endl;
00239 }
00240 }
|
|
|
Look-up table name -> date string.
Definition at line 62 of file DbiRollbackDates.h. |
|
|
Look-up table name -> time type (either "INSERTDATE" [default] or "CREATIONDATE").
Definition at line 64 of file DbiRollbackDates.h. |
1.3.9.1