77 ATH_MSG_INFO (
"Finalize: preparing to write conditions objects ");
82 return( StatusCode::FAILURE);
95 std::vector<obj_t> objs;
97 for (
unsigned int iobj = 0; iobj <
m_objectList.size(); ++iobj) {
99 obj_t& objt=objs.emplace_back();
106 auto hashSplit = std::ranges::views::split(objStr,std::string_view(
"#"));
107 for (
const auto [iHash,
ss] : std::views::enumerate(hashSplit)) {
110 objt.type=std::string_view(
ss);
113 objt.key=std::string_view(
ss);
116 objt.folder=std::string_view(
ss);
120 ATH_MSG_ERROR(
"Expect format typename#key#folder (where key and folder are optional)");
121 return StatusCode::FAILURE;
127 if (objt.key.empty()) {
129 objt.proxy =
detStore()->proxy(clid);
131 ATH_MSG_ERROR(
"Could not get default proxy for CLID {}, typename {}",clid,objt.type);
132 return StatusCode::FAILURE;
134 objt.key = objt.proxy->name();
137 objt.proxy =
detStore()->proxy(clid, objt.key);
139 ATH_MSG_ERROR(
"Could not get proxy for CLID {}, typename {}, key {}",clid,objt.type,objt.key);
140 return StatusCode::FAILURE;
145 if (objt.folder.empty()) {
146 objt.folder=objt.key;
152 const size_t nObjects = objs.size();
154 ATH_MSG_INFO(
"Identified a total of " << nObjects <<
" objects to write out:");
157 return StatusCode::SUCCESS;
159 for (
unsigned i=1;
const obj_t& objt : objs) {
160 typeKeys.emplace_back(std::make_pair(objt.type, objt.key));
161 ATH_MSG_INFO(
"{}: {}#{}#{}",i++,objt.type,objt.key,objt.folder);
167 if (
sc.isFailure()) {
169 return StatusCode::FAILURE;
173 if (
sc.isFailure()) {
175 return StatusCode::FAILURE;
177 ATH_MSG_INFO(
"Written {} objects to output stream",nObjects);
183 msg() << MSG::INFO <<
"Register objects in IOV database, interval of validity ";
190 for (
const obj_t& objt : objs) {
191 ATH_MSG_INFO(
"Register object {}#{} in IOV database folder {} {}", objt.type, objt.key, objt.folder,
192 objt.tag.size() ?
"with tag " + objt.tag :
"without tagging");
198 if (
sc == StatusCode::SUCCESS) {
204 ATH_MSG_INFO(
"Registered " << nreg <<
" objects in COOL IOV database");
211 const std::string globalTagName =
"GlobalTestTag";
212 chai::GlobalTagPtr gt;
213 std::vector<std::string> existingGlobalTags;
215 existingGlobalTags = db.findGlobalTags(globalTagName);
217 catch (std::exception& e) {
220 if (existingGlobalTags.empty()) {
221 gt = db.createGlobalTag(
"GlobalTestTag",
"test",
"test");
224 gt = db.getGlobalTag(globalTagName);
229 std::string address_data;
231 for (
const obj_t& objt : objs) {
232 chai::TagIovType iovType;
235 iovType = chai::Tag::IovType::Time;
238 iovType = chai::Tag::IovType::RunNumberLumiBlock;
241 const CLID clid = objt.proxy->clID();
244 ATH_MSG_INFO(
"Working on object clid {}, type {}, folder {}",clid, objt.type, objt.folder);
247 if (clid == 40774348 || clid == 1238547719) {
249 description = chai::Tag::buildNodeDescription(iovType, objt.type, clid);
252 IOpaqueAddress* addr = objt.proxy->address();
254 ATH_MSG_ERROR(
"No IOpaqueAddress from Type/Key [{}/{}]",objt.type,objt.key);
255 return StatusCode::FAILURE;
260 std::string address_header;
262 if (
splitAddress(saddr, address_header, address_data).isFailure()) {
263 ATH_MSG_ERROR(
"Could not split address: {}\n hdr: {}\n data: {}",saddr,address_header,address_data);
264 return StatusCode::FAILURE;
266 ATH_MSG_DEBUG(
"split address: {}\n hdr: {}\n data: {}",saddr,address_header,address_data);
284 std::string symLinkTypes;
285 for (
const CLID& c : objt.proxy->transientID()) {
289 if (!symLinkTypes.empty())
291 symLinkTypes.append(symType);
294 if (!symLinkTypes.empty()) {
299 if (iovType == chai::Tag::IovType::Time) {
309 if (objt.key != objt.folder) {
313 static const std::string crestObjTypeStr{
"crest-json-single-iov"};
314 chai::Tag::Metadata chaiMD{.iovType = iovType,
315 .objectType = crestObjTypeStr,
316 .synchronization = chai::Tag::Synchronization::All,
317 .status = chai::Tag::Status::Unlocked,
323 IOpaqueAddress* addr = objt.proxy->address();
332 ATH_MSG_INFO(
"Created chai container with " << chaiCont.numChannels() <<
" channels.");
333 const chai::PayloadSpec& chaiSpec=chaiCont.payloadSpec();
334 auto chaiTag=db.createTag(objt.tag, objt.tagDescr, chaiSpec,chaiMD);
335 chaiTag->addPayload(chaiCont,since);
338 }
else if (clid == 40774348) {
345 const chai::PayloadSpec& chaiSpec=chaiCont.payloadSpec();
346 auto chaiTag=db.createTag(objt.tag, objt.tagDescr, chaiSpec,chaiMD);
347 gt->addTag(objt.folder,objt.tag);
348 chaiTag->addPayload(chaiCont,since);
352 chai::PayloadSpec spec(chai::FieldSpec({{
"PoolRef", chai::Type::String}}), chai::ChannelSpec({{0,
""}}));
353 auto tag = db.createTag(objt.tag, objt.tagDescr, spec,chaiMD);
354 gt->addTag(objt.folder, objt.tag);
355 chai::Container container = tag->buildContainer();
356 container[0].push(address_data);
359 tag->addPayload(container, since);
363 ATH_MSG_INFO(
"Registered " << objs.size() <<
" objects in CREST IOV database");
369 return StatusCode::SUCCESS;