8 namespace persistency {
34 std::vector<std::tuple<cond::Time_t, cond::Hash, boost::posix_time::ptime> >
iovBuffer;
53 m_data->payloadType = payloadObjectType;
57 m_data->metadataChange =
true;
74 m_data->synchronizationType,
76 m_data->lastValidatedTime)) {
98 m_data->changes.insert(
"SynchronizationType");
108 m_data->changes.insert(
"EndOfValidity");
117 m_data->metadataChange =
true;
118 m_data->changes.insert(
"Description");
130 m_data->changes.insert(
"LastValidatedTime");
136 m_data->validationMode =
true;
140 boost::posix_time::ptime
now = boost::posix_time::microsec_clock::universal_time();
146 const boost::posix_time::ptime& insertionTime,
150 m_data->iovBuffer.push_back(std::tie(
since, payloadHash, insertionTime));
156 m_data->deleteBuffer.push_back(std::tie(
since, payloadHash));
160 bool iovSorter(
const std::tuple<cond::Time_t, cond::Hash, boost::posix_time::ptime>&
f,
161 const std::tuple<cond::Time_t, cond::Hash, boost::posix_time::ptime>&
s) {
162 return std::get<0>(
f) < std::get<0>(
s);
166 const boost::posix_time::ptime& operationTime,
167 bool forceInsertion) {
174 if (
m_data->metadataChange &&
m_data->description.empty())
175 throwException(
"A non-empty description string is mandatory.",
"IOVEditor::flush");
176 if (
m_data->validationMode)
177 m_session->iovSchema().tagTable().setValidationMode();
180 if (
m_data->creationTime.is_not_a_date_time())
181 m_data->creationTime = operationTime;
185 m_data->synchronizationType,
188 m_data->lastValidatedTime,
190 if (
m_session->iovSchema().tagLogTable().exists())
203 m_data->synchronizationType,
205 m_data->lastValidatedTime,
208 if (
m_data->metadataChange) {
211 if (
m_session->iovSchema().tagLogTable().exists()) {
214 for (
const auto&
c :
m_data->changes) {
216 if (
i == (
m_data->changes.size() - 1))
222 m_session->iovSchema().tagLogTable().insert(
223 m_data->tag, operationTime, cond::getUserName(), cond::getHostName(), cond::getCommand(),
action, lt);
229 if (!
m_data->iovBuffer.empty()) {
241 boost::posix_time::ptime no_time;
245 std::stringstream
msg;
246 msg <<
"Can't insert iov since " <<
l <<
" on the tag " <<
m_data->tag <<
": last since is " <<
last
252 for (
auto& iov :
m_data->iovBuffer) {
253 boost::posix_time::ptime& insertionTime = std::get<2>(iov);
254 if (insertionTime.is_not_a_date_time())
255 insertionTime = operationTime;
261 if (!
m_data->deleteBuffer.empty()) {
266 if (
m_session->iovSchema().tagLogTable().exists()) {
267 std::stringstream
msg;
268 if (!
m_data->iovBuffer.empty())
269 msg <<
m_data->iovBuffer.size() <<
" iov(s) inserted";
270 if (!
msg.str().empty())
274 if (!
m_data->deleteBuffer.empty())
275 msg <<
m_data->deleteBuffer.size() <<
" iov(s) deleted.";
277 m_session->iovSchema().tagLogTable().insert(
278 m_data->tag, operationTime, cond::getUserName(), cond::getHostName(), cond::getCommand(),
msg.str(), lt);
281 m_data->iovBuffer.clear();
282 m_data->deleteBuffer.clear();
288 return flush(logText, boost::posix_time::microsec_clock::universal_time(),
false);
296 return flush(
std::string(
"-"), boost::posix_time::microsec_clock::universal_time(),
false);
300 return flush(logText, boost::posix_time::microsec_clock::universal_time(), forceInsertion);
306 if (!
m_session->isTransactionActive(
false))