MCPcopy Create free account
hub / github.com/MITK/MITK / HandleGET_nodes

Method HandleGET_nodes

Modules/RESTAPI/src/mitkDataStorageController.cpp:909–1021  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

907}
908
909void DataStorageController::HandleGET_nodes(const httplib::Request& req, httplib::Response& res)
910{
911 if (!m_Bridge.HasDataStorage())
912 {
913 this->SendErrorResponse(res, 503, ErrorResponse::DataStorageNotAvailable(req.path));
914 return;
915 }
916
917 // Parse query parameters
918 NodeQueryParams params;
919 try
920 {
921 params = this->ParseNodeQueryParams(req);
922 }
923 catch (const InvalidQueryParam& e)
924 {
925 this->SendErrorResponse(res, 400, ErrorResponse::InvalidRequest(e.detail, req.path));
926 return;
927 }
928
929 auto queryResult = m_Bridge.GetNodes(params);
930
931 int returnedCount = static_cast<int>(queryResult.nodes.size());
932
933 nlohmann::json response;
934 response["data"] = queryResult.nodes;
935 response["meta"]["total_count"] = queryResult.totalCount;
936 response["meta"]["limit"] = queryResult.limit;
937 response["meta"]["offset"] = queryResult.offset;
938 response["meta"]["returned_count"] = returnedCount;
939
940 // Include pagination links if applicable
941 auto links = BuildPaginationLinks(req, queryResult.limit, queryResult.offset, queryResult.totalCount, returnedCount);
942 if (!links.empty())
943 {
944 response["meta"]["links"] = links;
945 }
946
947 // Include query info: context, filters, sorting, field limitations
948 response["meta"]["context"] = params.context.has_value() ? nlohmann::json(params.context.value()) : nlohmann::json(nullptr);
949
950 // Property scope
951 std::string scopeStr = "all";
952 if (params.propertyScope == PropertyScope::Node)
953 {
954 scopeStr = "node";
955 }
956 else if (params.propertyScope == PropertyScope::Data)
957 {
958 scopeStr = "data";
959 }
960 response["meta"]["property_scope"] = scopeStr;
961
962 // Echo the request's path filter back in meta as path_query (see "Path Query
963 // Response" in the MITK REST API specification under Documentation/).
964 if (params.path.has_value())
965 {
966 response["meta"]["path_query"] = params.path.value();

Calls 9

SendErrorResponseMethod · 0.95
ParseNodeQueryParamsMethod · 0.95
SendJsonResponseMethod · 0.95
BuildPaginationLinksFunction · 0.85
HasDataStorageMethod · 0.45
GetNodesMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
valueMethod · 0.45