Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions Framework/src/CcdbDatabase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include <unordered_set>

#include <boost/algorithm/string.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/foreach.hpp>

using namespace std::chrono;
using namespace AliceO2::Common;
Expand Down Expand Up @@ -184,6 +187,9 @@ std::shared_ptr<core::MonitorObject> CcdbDatabase::retrieveMO(std::string taskNa
map<string, string> metadata;
TObject* obj = retrieveTObject(path, metadata, when, &headers);
Version objectVersion(headers["qc_version"]); // retrieve headers to determine the version of the QC framework
// ILOG(Debug) << "Version of object is " << objectVersion << ENDM;
// ILOG(Debug) << "objectVersion == Version(\"0.0.0\") : " << (objectVersion == Version("0.0.0")) << ENDM;
// ILOG(Debug) << "objectVersion < Version(\"0.25\") : " << (objectVersion < Version("0.25")) << ENDM

std::shared_ptr<MonitorObject> mo;
if (objectVersion == Version("0.0.0") || objectVersion < Version("0.25")) {
Expand Down Expand Up @@ -315,21 +321,18 @@ std::vector<std::string> CcdbDatabase::getListing(std::string subpath)
std::vector<std::string> CcdbDatabase::getPublishedObjectNames(std::string taskName)
{
std::vector<string> result;

string listing = ccdbApi.list(taskName + "/.*", true, "Application/JSON");

// Split the string we received, by line. Also trim it and remove empty lines. Select the lines starting with "path".
std::stringstream ss(listing);
std::string line;
std::string taskNameEscaped = boost::replace_all_copy(taskName, "/", "\\/");
while (std::getline(ss, line, '\n')) {
ltrim(line);
rtrim(line);
if (line.length() > 0 && line.find("\"path\"") == 0) {
unsigned long objNameStart = 9 + taskNameEscaped.length();
string path = line.substr(objNameStart, line.length() - 2 /*final 2 char*/ - objNameStart);
result.push_back(path);
}
boost::property_tree::ptree pt;
stringstream ss;
ss << listing;
boost::property_tree::read_json(ss, pt);

BOOST_FOREACH (boost::property_tree::ptree::value_type& v, pt.get_child("objects")) {
assert(v.first.empty()); // array elements have no names
string data = v.second.get_child("path").data();
string path = data.substr(taskName.size());
result.push_back(path);
}

return result;
Expand Down
6 changes: 3 additions & 3 deletions Framework/test/testDbFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
///

#include "QualityControl/DatabaseFactory.h"
#include "QualityControl/QcInfoLogger.h"

#ifdef _WITH_MYSQL

#include "QualityControl/MySqlDatabase.h"

#endif

#define BOOST_TEST_MODULE DbFactory test
#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK
Expand Down Expand Up @@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE(db_ccdb_listing)
// }
BOOST_CHECK(std::find(objectNames.begin(), objectNames.end(), "/object1") != objectNames.end());
BOOST_CHECK(std::find(objectNames.begin(), objectNames.end(), "/object2") != objectNames.end());
BOOST_CHECK(std::find(objectNames.begin(), objectNames.end(), "/path\\/to\\/object3") != objectNames.end());
BOOST_CHECK(std::find(objectNames.begin(), objectNames.end(), "/path/to/object3") != objectNames.end());

// store list of streamer infos
// ccdb->storeStreamerInfosToFile("streamerinfos.root");
Expand Down