Skip to content

Commit 904c886

Browse files
awegrzynBarthelemy
authored andcommitted
Drop TObject2Json in favour of nodejs extenstion (#106)
* Make TObject2Json a library * Drop TObject2Json * Add retrieveJson method to database interface * Update docs
1 parent c44343c commit 904c886

21 files changed

Lines changed: 34 additions & 2106 deletions

Framework/CMakeLists.txt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,8 @@ set(
3535
include/QualityControl/InfrastructureGenerator.h
3636
)
3737

38-
set(
39-
SRCS_TOBJECT2JSON
40-
src/tobject2json/TObject2Json.cxx
41-
src/tobject2json/TObject2JsonServer.cxx
42-
src/tobject2json/TObject2JsonWorker.cxx
43-
src/tobject2json/TObject2JsonBackendFactory.cxx
44-
src/tobject2json/TObject2JsonCcdb.cxx
45-
)
46-
4738
if(ENABLE_MYSQL)
4839
list(APPEND SRCS src/MySqlDatabase.cxx)
49-
list(APPEND SRCS_TOBJECT2JSON src/tobject2json/TObject2JsonMySql.cxx)
5040
endif()
5141

5242
# Produce the final Version.h using template Version.h.in and substituting variables. We don't want to polute our source
@@ -168,10 +158,6 @@ foreach(i RANGE ${count})
168158
target_link_libraries(${name} PRIVATE QualityControl)
169159
endforeach()
170160

171-
# tobject2json
172-
add_executable(tobject2json ${SRCS_TOBJECT2JSON})
173-
target_link_libraries(tobject2json PRIVATE QualityControl ZeroMQ::ZeroMQ $<$<BOOL:${ENABLE_MYSQL}>:MySQL::MySQL>)
174-
175161
# ---- Gui ----
176162

177163
set(DATADUMP "")
@@ -243,7 +229,7 @@ unset(isSystemDir)
243229

244230
# Install library and binaries
245231
install(
246-
TARGETS QualityControl ${EXE_NAMES} tobject2json ${DATADUMP}
232+
TARGETS QualityControl ${EXE_NAMES} ${DATADUMP}
247233
EXPORT QualityControlTargets
248234
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
249235
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}

Framework/include/QualityControl/CcdbDatabase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class CcdbDatabase : public DatabaseInterface
6161
void connect(const std::unordered_map<std::string, std::string>& config) override;
6262
void store(std::shared_ptr<o2::quality_control::core::MonitorObject> mo) override;
6363
core::MonitorObject* retrieve(std::string taskName, std::string objectName) override;
64+
std::string retrieveJson(std::string taskName, std::string objectName) override;
6465
void disconnect() override;
6566
void prepareTaskDataContainer(std::string taskName) override;
6667
std::vector<std::string> getListOfTasksWithPublications() override;

Framework/include/QualityControl/DatabaseInterface.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class DatabaseInterface
6060
* TODO evaluate whether we should have a method to retrieve a list of objects (optimization)
6161
*/
6262
virtual o2::quality_control::core::MonitorObject* retrieve(std::string taskName, std::string objectName) = 0;
63+
64+
/**
65+
* Returns JSON encoded object
66+
*/
67+
virtual std::string retrieveJson(std::string taskName, std::string objectName) = 0;
6368
virtual void disconnect() = 0;
6469
/**
6570
* \brief Prepare the container, such as a table in a relational database, that will contain the MonitorObject's for

Framework/include/QualityControl/MySqlDatabase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class MySqlDatabase : public DatabaseInterface
3434
void connect(const std::unordered_map& config) override;
3535
void store(std::shared_ptr<o2::quality_control::core::MonitorObject> mo) override;
3636
o2::quality_control::core::MonitorObject* retrieve(std::string taskName, std::string objectName) override;
37+
std::string retrieveJson(std::string taskName, std::string objectName) override;
3738
void disconnect() override;
3839
std::vector<std::string> getPublishedObjectNames(std::string taskName) override;
3940
std::vector<std::string> getListOfTasksWithPublications() override;

Framework/src/CcdbDatabase.cxx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <boost/algorithm/string.hpp>
1919
#include <chrono>
2020
#include <sstream>
21+
#include "TBufferJSON.h"
2122

2223
using namespace std::chrono;
2324
using namespace AliceO2::Common;
@@ -82,6 +83,18 @@ core::MonitorObject* CcdbDatabase::retrieve(std::string taskName, std::string ob
8283
return dynamic_cast<core::MonitorObject*>(object);
8384
}
8485

86+
std::string CcdbDatabase::retrieveJson(std::string taskName, std::string objectName)
87+
{
88+
std::unique_ptr<core::MonitorObject> monitor(retrieve(taskName, objectName));
89+
if (monitor == nullptr) {
90+
return std::string();
91+
}
92+
std::unique_ptr<TObject> obj(monitor->getObject());
93+
monitor->setIsOwner(false);
94+
TString json = TBufferJSON::ConvertToJSON(obj.get());
95+
return json.Data();
96+
}
97+
8598
void CcdbDatabase::disconnect()
8699
{
87100
/* we're done with libcurl, so clean it up */

Framework/src/MySqlDatabase.cxx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "TMySQLResult.h"
1111
#include "TMySQLRow.h"
1212
#include "TMySQLStatement.h"
13+
#include "TBufferJSON.h"
1314
// O2
1415
#include "Common/Exceptions.h"
1516
// QC
@@ -207,6 +208,18 @@ o2::quality_control::core::MonitorObject* MySqlDatabase::retrieve(std::string ta
207208
return mo;
208209
}
209210

211+
std::string MySqlDatabase::retrieveJson(std::string taskName, std::string objectName)
212+
{
213+
std::unique_ptr<o2::quality_control::core::MonitorObject> monitor(retrieve(taskName, objectName));
214+
if (monitor == nullptr) {
215+
return std::string();
216+
}
217+
std::unique_ptr<TObject> obj(monitor->getObject());
218+
monitor->setIsOwner(false);
219+
TString json = TBufferJSON::ConvertToJSON(obj.get());
220+
return json.Data();
221+
}
222+
210223
void MySqlDatabase::disconnect()
211224
{
212225
storeQueue();

Framework/src/tobject2json/TObject2Json.cxx

Lines changed: 0 additions & 56 deletions
This file was deleted.

Framework/src/tobject2json/TObject2JsonBackend.h

Lines changed: 0 additions & 47 deletions
This file was deleted.

Framework/src/tobject2json/TObject2JsonBackendFactory.cxx

Lines changed: 0 additions & 72 deletions
This file was deleted.

Framework/src/tobject2json/TObject2JsonBackendFactory.h

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)