Skip to content

Commit

Permalink
Drop TObject2Json in favour of nodejs extenstion (#106)
Browse files Browse the repository at this point in the history
* Make TObject2Json a library

* Drop TObject2Json

* Add retrieveJson method to database interface

* Update docs
  • Loading branch information
awegrzyn authored and Barthelemy committed Jan 8, 2019
1 parent c44343c commit 904c886
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 2,106 deletions.
16 changes: 1 addition & 15 deletions Framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,8 @@ set(
include/QualityControl/InfrastructureGenerator.h
)

set(
SRCS_TOBJECT2JSON
src/tobject2json/TObject2Json.cxx
src/tobject2json/TObject2JsonServer.cxx
src/tobject2json/TObject2JsonWorker.cxx
src/tobject2json/TObject2JsonBackendFactory.cxx
src/tobject2json/TObject2JsonCcdb.cxx
)

if(ENABLE_MYSQL)
list(APPEND SRCS src/MySqlDatabase.cxx)
list(APPEND SRCS_TOBJECT2JSON src/tobject2json/TObject2JsonMySql.cxx)
endif()

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

# tobject2json
add_executable(tobject2json ${SRCS_TOBJECT2JSON})
target_link_libraries(tobject2json PRIVATE QualityControl ZeroMQ::ZeroMQ $<$<BOOL:${ENABLE_MYSQL}>:MySQL::MySQL>)

# ---- Gui ----

set(DATADUMP "")
Expand Down Expand Up @@ -243,7 +229,7 @@ unset(isSystemDir)

# Install library and binaries
install(
TARGETS QualityControl ${EXE_NAMES} tobject2json ${DATADUMP}
TARGETS QualityControl ${EXE_NAMES} ${DATADUMP}
EXPORT QualityControlTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down
1 change: 1 addition & 0 deletions Framework/include/QualityControl/CcdbDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class CcdbDatabase : public DatabaseInterface
void connect(const std::unordered_map<std::string, std::string>& config) override;
void store(std::shared_ptr<o2::quality_control::core::MonitorObject> mo) override;
core::MonitorObject* retrieve(std::string taskName, std::string objectName) override;
std::string retrieveJson(std::string taskName, std::string objectName) override;
void disconnect() override;
void prepareTaskDataContainer(std::string taskName) override;
std::vector<std::string> getListOfTasksWithPublications() override;
Expand Down
5 changes: 5 additions & 0 deletions Framework/include/QualityControl/DatabaseInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ class DatabaseInterface
* TODO evaluate whether we should have a method to retrieve a list of objects (optimization)
*/
virtual o2::quality_control::core::MonitorObject* retrieve(std::string taskName, std::string objectName) = 0;

/**
* Returns JSON encoded object
*/
virtual std::string retrieveJson(std::string taskName, std::string objectName) = 0;
virtual void disconnect() = 0;
/**
* \brief Prepare the container, such as a table in a relational database, that will contain the MonitorObject's for
Expand Down
1 change: 1 addition & 0 deletions Framework/include/QualityControl/MySqlDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class MySqlDatabase : public DatabaseInterface
void connect(const std::unordered_map& config) override;
void store(std::shared_ptr<o2::quality_control::core::MonitorObject> mo) override;
o2::quality_control::core::MonitorObject* retrieve(std::string taskName, std::string objectName) override;
std::string retrieveJson(std::string taskName, std::string objectName) override;
void disconnect() override;
std::vector<std::string> getPublishedObjectNames(std::string taskName) override;
std::vector<std::string> getListOfTasksWithPublications() override;
Expand Down
13 changes: 13 additions & 0 deletions Framework/src/CcdbDatabase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <boost/algorithm/string.hpp>
#include <chrono>
#include <sstream>
#include "TBufferJSON.h"

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

std::string CcdbDatabase::retrieveJson(std::string taskName, std::string objectName)
{
std::unique_ptr<core::MonitorObject> monitor(retrieve(taskName, objectName));
if (monitor == nullptr) {
return std::string();
}
std::unique_ptr<TObject> obj(monitor->getObject());
monitor->setIsOwner(false);
TString json = TBufferJSON::ConvertToJSON(obj.get());
return json.Data();
}

void CcdbDatabase::disconnect()
{
/* we're done with libcurl, so clean it up */
Expand Down
13 changes: 13 additions & 0 deletions Framework/src/MySqlDatabase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "TMySQLResult.h"
#include "TMySQLRow.h"
#include "TMySQLStatement.h"
#include "TBufferJSON.h"
// O2
#include "Common/Exceptions.h"
// QC
Expand Down Expand Up @@ -207,6 +208,18 @@ o2::quality_control::core::MonitorObject* MySqlDatabase::retrieve(std::string ta
return mo;
}

std::string MySqlDatabase::retrieveJson(std::string taskName, std::string objectName)
{
std::unique_ptr<o2::quality_control::core::MonitorObject> monitor(retrieve(taskName, objectName));
if (monitor == nullptr) {
return std::string();
}
std::unique_ptr<TObject> obj(monitor->getObject());
monitor->setIsOwner(false);
TString json = TBufferJSON::ConvertToJSON(obj.get());
return json.Data();
}

void MySqlDatabase::disconnect()
{
storeQueue();
Expand Down
56 changes: 0 additions & 56 deletions Framework/src/tobject2json/TObject2Json.cxx

This file was deleted.

47 changes: 0 additions & 47 deletions Framework/src/tobject2json/TObject2JsonBackend.h

This file was deleted.

72 changes: 0 additions & 72 deletions Framework/src/tobject2json/TObject2JsonBackendFactory.cxx

This file was deleted.

50 changes: 0 additions & 50 deletions Framework/src/tobject2json/TObject2JsonBackendFactory.h

This file was deleted.

Loading

0 comments on commit 904c886

Please sign in to comment.