Skip to content
Snippets Groups Projects
Verified Commit db9524b4 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

WIP: consolidation

parent 81198e1e
Branches
Tags
1 merge request!12F consolidation
Pipeline #12010 failed
...@@ -91,7 +91,7 @@ enum Role { ...@@ -91,7 +91,7 @@ enum Role {
RECORD = EntityRole::ENTITY_ROLE_RECORD, ///< Record RECORD = EntityRole::ENTITY_ROLE_RECORD, ///< Record
PROPERTY = EntityRole::ENTITY_ROLE_PROPERTY, ///< Property PROPERTY = EntityRole::ENTITY_ROLE_PROPERTY, ///< Property
FILE = EntityRole::ENTITY_ROLE_FILE, ///< File FILE = EntityRole::ENTITY_ROLE_FILE, ///< File
} };
struct FileDescriptor { struct FileDescriptor {
FileTransmissionId *file_transmission_id; FileTransmissionId *file_transmission_id;
...@@ -568,7 +568,7 @@ public: ...@@ -568,7 +568,7 @@ public:
inline auto SetLocalPath(const boost::filesystem::path &local_path) noexcept inline auto SetLocalPath(const boost::filesystem::path &local_path) noexcept
-> StatusCode { -> StatusCode {
if (GetRole() != "File") { if (GetRole() != Role::FILE) {
CAOSDB_LOG_WARN(logger_name) CAOSDB_LOG_WARN(logger_name)
<< "Entity::SetLocalPath failed. This is not a file entity."; << "Entity::SetLocalPath failed. This is not a file entity.";
return StatusCode::NOT_A_FILE_ENTITY; return StatusCode::NOT_A_FILE_ENTITY;
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <boost/log/sources/record_ostream.hpp> // for basic_record_o... #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/enum_256.hpp> // for BOOST_PP_SEQ_E...
#include <boost/preprocessor/seq/limits/size_256.hpp> // for BOOST_PP_SEQ_S... #include <boost/preprocessor/seq/limits/size_256.hpp> // for BOOST_PP_SEQ_S...
#include "google/protobuf/generated_message_util.h" // for CreateMessage...
#include <google/protobuf/arena.h> // for Arena #include <google/protobuf/arena.h> // for Arena
#include <google/protobuf/util/json_util.h> // for MessageToJsonS... #include <google/protobuf/util/json_util.h> // for MessageToJsonS...
#include <grpcpp/impl/codegen/completion_queue.h> // for CompletionQueue #include <grpcpp/impl/codegen/completion_queue.h> // for CompletionQueue
......
...@@ -20,10 +20,11 @@ ...@@ -20,10 +20,11 @@
* *
*/ */
#include "caosdb/entity.h" #include "caosdb/entity.h"
#include "caosdb/data_type.h" #include "caosdb/data_type.h" // for DataType
#include "caosdb/entity/v1alpha1/main.pb.h" // for Parent, Arena::CreateMay... #include "caosdb/entity/v1alpha1/main.pb.h" // for Messages
#include "caosdb/protobuf_helper.h" // for get_arena #include "caosdb/protobuf_helper.h" // for get_arena
#include "caosdb/value.h" #include "caosdb/value.h" // for Value
#include <google/protobuf/generated_message_util.h> // for Arena::Create...
#include <google/protobuf/arena.h> // for Arena #include <google/protobuf/arena.h> // for Arena
#include <new> // for operator new #include <new> // for operator new
...@@ -190,10 +191,9 @@ auto Entity::CreateProtoEntity() -> ProtoEntity * { ...@@ -190,10 +191,9 @@ auto Entity::CreateProtoEntity() -> ProtoEntity * {
Entity::Entity(IdResponse *id_response) : Entity() { Entity::Entity(IdResponse *id_response) : Entity() {
this->wrapped->set_id(id_response->id()); this->wrapped->set_id(id_response->id());
this->wrapped->mutable_version()->Swap(id_response->mutable_version()); this->wrapped->mutable_version()->Swap(id_response->mutable_version());
this->wrapped->mutable_errors()->Swap(id_response->mutable_entity_errors()); this->errors.wrapped->Swap(id_response->mutable_errors());
this->wrapped->mutable_warnings()->Swap( this->warnings.wrapped->Swap(id_response->mutable_warnings());
id_response->mutable_entity_warnings()); this->infos.wrapped->Swap(id_response->mutable_infos());
this->wrapped->mutable_infos()->Swap(id_response->mutable_entity_infos());
} }
Entity::Entity() : Entity(Entity::CreateProtoEntity()) {} Entity::Entity() : Entity(Entity::CreateProtoEntity()) {}
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <exception> // IWYU pragma: keep #include <exception> // IWYU pragma: keep
// IWYU pragma: no_include <bits/exception.h> // IWYU pragma: no_include <bits/exception.h>
#include <google/protobuf/arena.h> // for Arena #include <google/protobuf/arena.h> // for Arena
#include <google/protobuf/generated_message_util.h> // for CreateMessage...
#include <grpcpp/impl/codegen/async_stream.h> // for ClientAsyncWr... #include <grpcpp/impl/codegen/async_stream.h> // for ClientAsyncWr...
#include <grpcpp/impl/codegen/call_op_set.h> // for WriteOptions #include <grpcpp/impl/codegen/call_op_set.h> // for WriteOptions
#include <grpcpp/impl/codegen/client_context.h> // for ClientContext #include <grpcpp/impl/codegen/client_context.h> // for ClientContext
......
...@@ -316,10 +316,12 @@ auto Transaction::ExecuteAsynchronously() noexcept -> StatusCode { ...@@ -316,10 +316,12 @@ auto Transaction::ExecuteAsynchronously() noexcept -> StatusCode {
} }
} }
CAOSDB_LOG_DEBUG(logger_name) << "RPC Request: " << RequestToString();
handler_ = std::make_unique<EntityTransactionHandler>( handler_ = std::make_unique<EntityTransactionHandler>(
&handler_, entity_service.get(), &completion_queue, request, response); &handler_, entity_service.get(), &completion_queue, request, response);
this->status = ProcessCalls(); this->status = ProcessCalls();
CAOSDB_LOG_DEBUG(logger_name) << "RPC Response: " << ResponseToString();
// file download afterwards // file download afterwards
if (status.GetCode() == StatusCode::SUCCESS && !download_files.empty()) { if (status.GetCode() == StatusCode::SUCCESS && !download_files.empty()) {
......
#include "caosdb/transaction_handler.h" #include "caosdb/transaction_handler.h"
#include "caosdb/logging.h" // for CAOSDB_LOG_TRACE #include "caosdb/logging.h" // for CAOSDB_LOG_TRACE
#include <boost/log/core/record.hpp> // for record #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_... #include <boost/log/sources/record_ostream.hpp> // for basic_record_...
#include <boost/preprocessor/seq/limits/enum_256.hpp> // for BOOST_PP_SEQ_... #include <boost/preprocessor/seq/limits/enum_256.hpp> // for BOOST_PP_SEQ_...
#include <boost/preprocessor/seq/limits/size_256.hpp> // for BOOST_PP_SEQ_... #include <boost/preprocessor/seq/limits/size_256.hpp> // for BOOST_PP_SEQ_...
...@@ -8,6 +9,7 @@ ...@@ -8,6 +9,7 @@
// IWYU pragma: no_include <bits/exception.h> // IWYU pragma: no_include <bits/exception.h>
#include <grpcpp/impl/codegen/async_unary_call.h> // for ClientAsyncRes... #include <grpcpp/impl/codegen/async_unary_call.h> // for ClientAsyncRes...
#include <grpcpp/impl/codegen/completion_queue.h> // for CompletionQueue #include <grpcpp/impl/codegen/completion_queue.h> // for CompletionQueue
#include <iosfwd> // for streamsize
namespace caosdb::transaction { namespace caosdb::transaction {
......
...@@ -176,8 +176,6 @@ TEST(test_entity, test_insert_entity) { ...@@ -176,8 +176,6 @@ TEST(test_entity, test_insert_entity) {
EXPECT_EQ(entity.GetRole(), Role::RECORD_TYPE); EXPECT_EQ(entity.GetRole(), Role::RECORD_TYPE);
EXPECT_EQ(entity.GetName(), "entity_name"); EXPECT_EQ(entity.GetName(), "entity_name");
EXPECT_EQ(transaction.RequestToString(), "");
} }
TEST(test_entity, test_insert_with_role) { TEST(test_entity, test_insert_with_role) {
...@@ -305,14 +303,14 @@ TEST(test_entity, test_add_file_to_non_file_entity) { ...@@ -305,14 +303,14 @@ TEST(test_entity, test_add_file_to_non_file_entity) {
TEST(test_entity, test_add_non_existing_file) { TEST(test_entity, test_add_non_existing_file) {
Entity entity; Entity entity;
entity.SetRole("File"); entity.SetRole(Role::FILE);
EXPECT_EQ(entity.SetLocalPath("non-existing/path"), EXPECT_EQ(entity.SetLocalPath("non-existing/path"),
StatusCode::FILE_DOES_NOT_EXIST_LOCALLY); StatusCode::FILE_DOES_NOT_EXIST_LOCALLY);
} }
TEST(test_entity, test_add_directory_path) { TEST(test_entity, test_add_directory_path) {
Entity entity; Entity entity;
entity.SetRole("File"); entity.SetRole(Role::FILE);
EXPECT_EQ(entity.SetLocalPath("./"), StatusCode::PATH_IS_A_DIRECTORY); EXPECT_EQ(entity.SetLocalPath("./"), StatusCode::PATH_IS_A_DIRECTORY);
} }
...@@ -346,7 +344,7 @@ TEST(test_entity, test_role) { ...@@ -346,7 +344,7 @@ TEST(test_entity, test_role) {
TEST(test_entity, test_add_file) { TEST(test_entity, test_add_file) {
Entity entity; Entity entity;
entity.SetRole("File"); entity.SetRole(Role::FILE);
EXPECT_EQ(entity.SetLocalPath(TEST_DATA_DIR + "/test.json"), EXPECT_EQ(entity.SetLocalPath(TEST_DATA_DIR + "/test.json"),
StatusCode::SUCCESS); StatusCode::SUCCESS);
} }
......
...@@ -41,6 +41,7 @@ using caosdb::configuration::InsecureConnectionConfiguration; ...@@ -41,6 +41,7 @@ using caosdb::configuration::InsecureConnectionConfiguration;
using caosdb::connection::Connection; using caosdb::connection::Connection;
using caosdb::entity::Entity; using caosdb::entity::Entity;
using ProtoEntity = caosdb::entity::v1alpha1::Entity; using ProtoEntity = caosdb::entity::v1alpha1::Entity;
using caosdb::entity::Role;
using caosdb::entity::v1alpha1::RetrieveResponse; using caosdb::entity::v1alpha1::RetrieveResponse;
TEST(test_transaction, create_transaction) { TEST(test_transaction, create_transaction) {
...@@ -215,7 +216,7 @@ TEST(test_transaction, test_insert_with_file) { ...@@ -215,7 +216,7 @@ TEST(test_transaction, test_insert_with_file) {
Connection connection(configuration); Connection connection(configuration);
auto transaction = connection.CreateTransaction(); auto transaction = connection.CreateTransaction();
Entity entity; Entity entity;
entity.SetRole("File"); entity.SetRole(Role::FILE);
entity.SetLocalPath(TEST_DATA_DIR + "/test.json"); entity.SetLocalPath(TEST_DATA_DIR + "/test.json");
EXPECT_TRUE(transaction->GetUploadFiles().empty()); EXPECT_TRUE(transaction->GetUploadFiles().empty());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment