9 namespace persistency {
35 std::vector<std::tuple<cond::Time_t, cond::Hash, boost::posix_time::ptime> >
iovBuffer;
54 m_data->payloadType = payloadObjectType;
58 m_data->metadataChange =
true;
77 m_data->synchronizationType,
83 if (
m_data->protectionCode) {
85 bool writeAllowed =
m_session->iovSchema().tagAccessPermissionTable().getAccessPermission(
92 "Tag \"" +
tag +
"\" can't be accessed for update by db-user \"" +
m_session->principalName +
"\".",
96 bool mylock =
m_session->iovSchema().tagAccessPermissionTable().getAccessPermission(
100 "Tag \"" +
tag +
"\" can't be accessed for update, because it has been locked by an other session.",
123 m_data->changes.insert(
"SynchronizationType");
133 m_data->changes.insert(
"EndOfValidity");
142 m_data->metadataChange =
true;
143 m_data->changes.insert(
"Description");
155 m_data->changes.insert(
"LastValidatedTime");
160 boost::posix_time::ptime
now = boost::posix_time::microsec_clock::universal_time();
166 const boost::posix_time::ptime& insertionTime,
170 m_data->iovBuffer.push_back(std::tie(
since, payloadHash, insertionTime));
176 m_data->deleteBuffer.push_back(std::tie(
since, payloadHash));
180 bool iovSorter(
const std::tuple<cond::Time_t, cond::Hash, boost::posix_time::ptime>&
f,
181 const std::tuple<cond::Time_t, cond::Hash, boost::posix_time::ptime>&
s) {
182 return std::get<0>(
f) < std::get<0>(
s);
186 const boost::posix_time::ptime& operationTime,
187 bool forceInsertion) {
194 if (
m_data->metadataChange &&
m_data->description.empty())
195 throwException(
"A non-empty description string is mandatory.",
"IOVEditor::flush");
200 if (
m_data->creationTime.is_not_a_date_time())
201 m_data->creationTime = operationTime;
205 m_data->synchronizationType,
208 m_data->lastValidatedTime,
210 if (
m_session->iovSchema().tagLogTable().exists())
223 m_data->synchronizationType,
225 m_data->lastValidatedTime,
228 if (
m_data->metadataChange) {
231 if (
m_session->iovSchema().tagLogTable().exists()) {
234 for (
const auto&
c :
m_data->changes) {
236 if (
i == (
m_data->changes.size() - 1))
242 m_session->iovSchema().tagLogTable().insert(
243 m_data->tag, operationTime, cond::getUserName(), cond::getHostName(), cond::getCommand(),
action, lt);
249 if (!
m_data->iovBuffer.empty()) {
261 boost::posix_time::ptime no_time;
265 std::stringstream
msg;
266 msg <<
"Can't insert iov since " <<
l <<
" on the tag " <<
m_data->tag <<
": last since is " <<
last 272 for (
auto& iov :
m_data->iovBuffer) {
273 boost::posix_time::ptime& insertionTime = std::get<2>(iov);
274 if (insertionTime.is_not_a_date_time())
275 insertionTime = operationTime;
281 if (!
m_data->deleteBuffer.empty()) {
286 if (
m_session->iovSchema().tagLogTable().exists()) {
287 std::stringstream
msg;
288 if (!
m_data->iovBuffer.empty())
289 msg <<
m_data->iovBuffer.size() <<
" iov(s) inserted";
290 if (!
msg.str().empty())
294 if (!
m_data->deleteBuffer.empty())
295 msg <<
m_data->deleteBuffer.size() <<
" iov(s) deleted.";
297 m_session->iovSchema().tagLogTable().insert(
298 m_data->tag, operationTime, cond::getUserName(), cond::getHostName(), cond::getCommand(),
msg.str(), lt);
301 m_data->iovBuffer.clear();
302 m_data->deleteBuffer.clear();
308 return flush(logText, boost::posix_time::microsec_clock::universal_time(),
false);
316 return flush(
std::string(
"-"), boost::posix_time::microsec_clock::universal_time(),
false);
320 return flush(logText, boost::posix_time::microsec_clock::universal_time(), forceInsertion);
329 m_session->iovSchema().tagAccessPermissionTable().setAccessPermission(
m_data->tag,
340 boost::posix_time::microsec_clock::universal_time(),
352 m_session->iovSchema().tagAccessPermissionTable().removeAccessPermission(
361 boost::posix_time::microsec_clock::universal_time(),
372 if (!
m_session->isTransactionActive(
false))
std::string payloadType() const
std::string synchronizationTypeNames(SynchronizationType type)
ret
prodAgent to be discontinued
cond::Time_t lastValidatedTime() const
void checkTransaction(const std::string &ctx)
cond::Time_t lastValidatedTime
static constexpr int COND_DBTAG_WRITE_ACCESS_CODE
void load(const std::string &tag)
void setDescription(const std::string &description)
std::set< std::string > changes
void setLastValidatedTime(cond::Time_t time)
std::shared_ptr< SessionImpl > m_session
void throwException(const std::string &message, const std::string &methodName)
unsigned long long Time_t
cond::Time_t endOfValidity() const
IOVEditor & operator=(const IOVEditor &rhs)
static constexpr int COND_DBTAG_LOCK_ACCESS_CODE
std::vector< std::tuple< cond::Time_t, cond::Hash, boost::posix_time::ptime > > iovBuffer
void erase(cond::Time_t since, const cond::Hash &payloadHash)
void insert(cond::Time_t since, const cond::Hash &payloadHash, bool checkType=false)
static constexpr int COND_DBKEY_CREDENTIAL_CODE
cond::Time_t endOfValidity
std::shared_ptr< IOVEditorData > m_data
bool iovSorter(const std::tuple< cond::Time_t, cond::Hash, boost::posix_time::ptime > &f, const std::tuple< cond::Time_t, cond::Hash, boost::posix_time::ptime > &s)
std::string description() const
boost::posix_time::ptime creationTime
cond::SynchronizationType synchronizationType
cond::TimeType timeType() const
void setEndOfValidity(cond::Time_t validity)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void setSynchronizationType(cond::SynchronizationType synchronizationType)
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
void throwException(const std::string &message, const std::string &methodName)
static constexpr int COND_SESSION_HASH_CODE
std::vector< std::tuple< cond::Time_t, cond::Hash > > deleteBuffer
cond::SynchronizationType synchronizationType() const