TDbiRollbackDates.cxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include <cstring>
00007
00008 #include "TString.h"
00009
00010 #include "TDbi.hxx"
00011 #include "TDbiRollbackDates.hxx"
00012 #include <TSK_DBI_Log.hxx>
00013 #include <MsgFormat.h>
00014 using std::endl;
00015 #include "TDbiRegistry.hxx"
00016 #include "UtilString.hxx"
00017 #include "TVldTimeStamp.hxx"
00018
00019 ClassImp(TDbiRollbackDates)
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 TDbiRollbackDates::TDbiRollbackDates()
00032 {
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 SK_DBI_Trace( "Creating TDbiRollbackDates" << " ");
00052 }
00053
00054
00055 TDbiRollbackDates::~TDbiRollbackDates() {
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 SK_DBI_Trace( "Destroying TDbiRollbackDates" << " ");
00068
00069 }
00070
00071
00072 const std::string& TDbiRollbackDates::GetDate(const std::string& tableName) const {
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 static std::string date;
00086
00087 name_map_t::const_reverse_iterator itr = fTableToDate.rbegin();
00088 name_map_t::const_reverse_iterator itrEnd = fTableToDate.rend();
00089 for (; itr != itrEnd; ++itr)
00090 if ( ! UtilString::cmp_wildcard(tableName,itr->first)
00091 ) return itr->second;
00092 return date;
00093 }
00094
00095
00096 const std::string& TDbiRollbackDates::GetType(const std::string& tableName) const {
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 static std::string type("INSERTDATE");
00110
00111 name_map_t::const_reverse_iterator itr = fTableToType.rbegin();
00112 name_map_t::const_reverse_iterator itrEnd = fTableToType.rend();
00113 for (; itr != itrEnd; ++itr)
00114 if ( ! UtilString::cmp_wildcard(tableName,itr->first)
00115 ) return itr->second;
00116 return type;
00117 }
00118
00119
00120 void TDbiRollbackDates::Set(TDbiRegistry& reg) {
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 TDbiRegistry::TDbiRegistryKey keyItr(®);
00137
00138 Bool_t hasChanged = kFALSE;
00139
00140 const char* key = keyItr();
00141 while ( key ) {
00142
00143 const char* nextKey = keyItr();
00144
00145
00146
00147 if ( ! strncmp("Rollback:",key,9) ) {
00148 std::string tableName = key+9;
00149 std::string date;
00150 const char* dateChars = 0;
00151 bool ok = reg.Get(key,dateChars);
00152 if ( ok ) {
00153 date = dateChars;
00154 TVldTimeStamp ts(TDbi::MakeTimeStamp(date,&ok));
00155 date = TDbi::MakeDateTimeString(ts);
00156 }
00157 if ( ok ) {
00158
00159
00160
00161 int loc = date.size()-1;
00162 while ( loc && date[loc] == ' ' ) date.erase(loc--);
00163
00164 fTableToDate[tableName] = date;
00165 hasChanged = kTRUE;
00166
00167 }
00168 else SK_DBI_Warn( "Illegal Rollback registry item: " << key
00169 << " = " << dateChars << " ");
00170 reg.RemoveKey(key);
00171 }
00172
00173
00174
00175 else if ( ! strncmp("RollbackType:",key,13) ) {
00176 std::string tableName = key+13;
00177 TString type;
00178 const char* typeChars = 0;
00179 bool ok = reg.Get(key,typeChars);
00180 if ( ok ) {
00181
00182 type = typeChars;
00183 type.ToUpper();
00184 type = type.Strip(TString::kBoth);
00185 ok = ! type.CompareTo("INSERTDATE") || ! type.CompareTo("CREATIONDATE");
00186 }
00187 if ( ok ) {
00188 fTableToType[tableName] = type.Data();
00189 hasChanged = kTRUE;
00190 }
00191 else SK_DBI_Warn( "Illegal RollbackType registry item: " << key
00192 << " = " << typeChars << " ");
00193 reg.RemoveKey(key);
00194 }
00195 key = nextKey;
00196 }
00197
00198 if ( hasChanged ) this->Show();
00199 }
00200
00201
00202 void TDbiRollbackDates::Show() const {
00203
00204
00205 }
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239