Skip to content

Commit

Permalink
squash. genquery2 msi
Browse files Browse the repository at this point in the history
  • Loading branch information
korydraughn committed Mar 19, 2024
1 parent 52e4bfe commit 816af51
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/re/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ add_library(
irods_server_re
OBJECT
"${CMAKE_CURRENT_SOURCE_DIR}/src/extractAvuMS.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/genquery2.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/genQueryMS.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/icatAdminMS.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/icatGeneralMS.cpp"
Expand Down
6 changes: 6 additions & 0 deletions server/re/include/irods/msi_genquery2.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef IRODS_MSI_GENQUERY2_HPP
#define IRODS_MSI_GENQUERY2_HPP



#endif // IRODS_MSI_GENQUERY2_HPP
1 change: 1 addition & 0 deletions server/re/include/irods/reAction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "irods/reNaraMetaData.hpp"
#include "irods/reIn2p3SysRule.hpp"
#include "irods/irods_ms_plugin.hpp"
#include "irods/msi_genquery2.hpp"

int msiRollback( ruleExecInfo_t *rei );
int msiSetACL( msParam_t *recursiveFlag, msParam_t *accessLevel, msParam_t *userName,
Expand Down
88 changes: 88 additions & 0 deletions server/re/src/msi_genquery2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include "irods/msi_genquery2.hpp"

#include "irods/irods_at_scope_exit.hpp"
#include "irods/rs_genquery2.hpp"
#include "irods/msParam.h"
#include "irods/irods_re_structs.hpp"
#include "irods/irods_logger.hpp"
//#include "irods/irods_plugin_context.hpp"
//#include "irods/irods_re_plugin.hpp"
#include "irods/irods_state_table.h"
#include "irods/rodsError.h"
#include "irods/rodsErrorTable.h"
#include "irods/msi_preconditions.hpp"

#include <fmt/format.h>
#include <boost/any.hpp>
#include <nlohmann/json.hpp>

#include <algorithm>
#include <cstdint>
#include <cstring>
#include <functional>
#include <iterator>
#include <list>
#include <string>
#include <string_view>
#include <vector>

namespace
{
using log_msi = irods::experimental::log::microservice;

// TODO Replace with process_stash, eventually.
struct genquery_context
{
nlohmann::json rows;
std::int32_t current_row = -1;
}; // struct genquery_context

std::vector<genquery_context> gq2_context;
} // anonymous namespace

auto msi_genquery2_execute(MsParam* _handle, MsParam* _query_string, RuleExecInfo* _rei) -> int
{
IRODS_MSI_REQUIRE_VALID_POINTER(_handle);
IRODS_MSI_REQUIRE_VALID_POINTER(_query_string);
IRODS_MSI_REQUIRE_VALID_POINTER(_rei);

IRODS_MSI_REQUIRE_VALID_POINTER(_handle->type);
IRODS_MSI_REQUIRE_VALID_POINTER(_query_string->type);

IRODS_MSI_REQUIRE_TYPE(_query_string->type, STR_MS_T);

IRODS_MSI_REQUIRE_VALID_POINTER(_query_string->inOutStruct);

GenQuery2Input input{};
input.query_string = static_cast<char*>(_query_string->inOutStruct);

char* results{};

if (const auto ec = rs_genquery2(_rei->rsComm, &input, &results); ec < 0) {
log_msi::error("Error while executing GenQuery2 query [error_code=[{}]].", ec);
return ec;
}

gq2_context.push_back({.rows = nlohmann::json::parse(results), .current_row = -1});
std::free(results); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc)

// Return the handle to the caller.
fillStrInMsParam(_handle, std::to_string(gq2_context.size() - 1).c_str());

return 0;
} // msi_genquery2_execute

auto msi_genquery2_next_row() -> int
{
return 0;
} // msi_genquery2_next_row

auto msi_genquery2_column() -> int
{
return 0;
} // msi_genquery2_column

auto msi_genquery2_destroy() -> int
{
return 0;
} // msi_genquery2_destroy

0 comments on commit 816af51

Please sign in to comment.