Skip to content
Snippets Groups Projects

ENH: Allow insertion and deletion of single entities

Merged Florian Spreckelsen requested to merge f-insert into dev
All threads resolved!
Compare and Show latest version
2 files
+ 2
1
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 40
29
@@ -19,29 +19,31 @@
*
*/
#include "caosdb/configuration.h"
#include "boost/iterator/iterator_facade.hpp" // for iterator_facad...
#include "boost/json/impl/object.hpp" // for object::at
#include "boost/json/string.hpp" // for string
#include "boost/json/string_view.hpp" // for string_view
#include "boost/log/core/record.hpp" // for record
#include "boost/log/sources/record_ostream.hpp" // for basic_record_o...
#include "boost/preprocessor/seq/limits/enum_256.hpp" // for BOOST_PP_SEQ_E...
#include "boost/preprocessor/seq/limits/size_256.hpp" // for BOOST_PP_SEQ_S...
#include "caosdb/authentication.h" // for Authenticator
#include "caosdb/connection.h" // for ConnectionManager
#include "caosdb/constants.h" // for LIBCAOSDB_CONF...
#include "caosdb/exceptions.h" // for ConfigurationE...
#include "caosdb/log_level.h" // for CAOSDB_DEFAULT...
#include "caosdb/status_code.h" // for StatusCode
#include "caosdb/utility.h" // for get_home_direc...
#include <bits/exception.h> // for exception
#include <cassert> // for assert
#include <cstdlib> // for getenv
#include <grpcpp/security/credentials.h> // for SslCredentials
#include <iterator> // for next
#include <map> // for map
#include <stdexcept> // for out_of_range
#include <string> // for string, operator+
#include "boost/iterator/iterator_facade.hpp" // for iterator_facad...
#include "boost/json/impl/object.hpp" // for object::at
#include "boost/json/string.hpp" // for string
#include "boost/json/string_view.hpp" // for string_view
#include "boost/log/core/record.hpp" // for record
#include "boost/log/detail/attachable_sstream_buf.hpp" // for basic_ostring...
#include "boost/log/sources/record_ostream.hpp" // for basic_record_o...
#include "boost/preprocessor/seq/limits/enum_256.hpp" // for BOOST_PP_SEQ_E...
#include "boost/preprocessor/seq/limits/size_256.hpp" // for BOOST_PP_SEQ_S...
#include "caosdb/authentication.h" // for Authenticator
#include "caosdb/connection.h" // for ConnectionManager
#include "caosdb/constants.h" // for LIBCAOSDB_CONF...
#include "caosdb/exceptions.h" // for ConfigurationE...
#include "caosdb/log_level.h" // for CAOSDB_DEFAULT...
#include "caosdb/status_code.h" // for StatusCode
#include "caosdb/utility.h" // for get_home_direc...
#include <bits/exception.h> // for exception
#include <cassert> // for assert
#include <cstdlib> // for getenv
#include <cstring> // for strcmp
#include <grpcpp/security/credentials.h> // for SslCredentials
#include <iterator> // for next
#include <map> // for map
#include <stdexcept> // for out_of_range
#include <string> // for string, operator+
namespace caosdb::configuration {
using boost::filesystem::exists;
@@ -462,15 +464,18 @@ auto ConfigurationManager::GetConnection(const std::string &name) const
"' has not been defined.");
}
auto ConfigurationManager::InitializeDefaults() -> int {
// TODO(tf) This has apparently a cognitive complexity of 34>25 (threshold).
auto ConfigurationManager::InitializeDefaults() -> int { // NOLINT
// find the configuration file...
std::unique_ptr<path> configuration_file_path;
for (const std::string &configuration_file :
for (const char *const &configuration_file :
caosdb::LIBCAOSDB_CONFIGURATION_FILES_PRECEDENCE) {
if (configuration_file == "$CAOSDB_CLIENT_CONFIGURATION") {
if (strcmp(configuration_file, "$CAOSDB_CLIENT_CONFIGURATION") == 0) {
// user specified a file via the environment variable
const auto *from_env_var = getenv("CAOSDB_CLIENT_CONFIGURATION");
// TODO(tf) make this thread-secure (concurrency-mt-unsafe)
const auto *from_env_var =
getenv("CAOSDB_CLIENT_CONFIGURATION"); // NOLINT
if (from_env_var != nullptr) {
configuration_file_path = std::make_unique<path>(from_env_var);
if (exists(*configuration_file_path)) {
@@ -504,7 +509,6 @@ auto ConfigurationManager::InitializeDefaults() -> int {
// ... and use the configuration file
if (configuration_file_path != nullptr) {
// TODO(tf): log which file has been used.
mLoadSingleJSONConfiguration(*configuration_file_path);
}
@@ -517,7 +521,14 @@ auto ConfigurationManager::InitializeDefaults() -> int {
logging::initialize_logging(logging_configuration);
} else {
logging::initialize_logging_defaults();
CAOSDB_LOG_WARN(logger_name) << "No configuration has been found.";
CAOSDB_LOG_INFO(logger_name) << "No logging configuration has been found. "
"We are using the default configuration";
}
if (configuration_file_path != nullptr &&
this->json_configuration.is_object()) {
CAOSDB_LOG_INFO(logger_name) << "Loaded configuration from "
<< *(configuration_file_path.get()) << ".";
}
return 0;
Loading