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

Method GetNodeProperties

Modules/RESTAPI/src/mitkDataStorageBridge.cpp:921–985  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

919 }
920
921 std::optional<DataStorageBridge::Json> DataStorageBridge::GetNodeProperties(
922 const std::string& uid,
923 const PropertyQueryParams& params) const
924 {
925 std::lock_guard<std::mutex> lock(m_Mutex);
926 return this->DispatchTask<std::optional<Json>>([this, uid, params]()
927 {
928 auto dataStorage = m_DataStorage.Lock();
929 if (dataStorage.IsNull())
930 {
931 return std::optional<Json>(std::nullopt);
932 }
933
934 auto node = m_UidMapper->FindNodeByUid(uid);
935 if (node == nullptr)
936 {
937 return std::optional<Json>(std::nullopt);
938 }
939
940 const std::string contextName = params.context.has_value() ? params.context.value() : "";
941
942 // Get the correct set of property keys for the requested scope
943 auto keys = GetPropertyKeysForScope(node, contextName, params.scope);
944 DataNode::PropertyListKeyNames filterdKeys;
945 for (const auto& key : keys)
946 {
947 // Skip internal properties (restapi.*)
948 if (IsInternalProperty(key))
949 {
950 continue;
951 }
952
953 // Filter by names if specified
954 if (params.names.empty() ||
955 std::find(params.names.begin(), params.names.end(), key) != params.names.end())
956 {
957 filterdKeys.push_back(key);
958 }
959 }
960
961 // Check if we should return content or just names
962 if (!params.includeContent)
963 {
964 // Return just property names as array
965 Json names = Json::array();
966 for (const auto& key : filterdKeys)
967 {
968 names.push_back(key);
969 }
970 return std::optional<Json>(names);
971 }
972
973 Json result = Json::object();
974 for (const auto& key : filterdKeys)
975 {
976 auto prop = GetConstProperty(node, key, params.context, params.scope);
977 if (prop != nullptr)
978 {

Callers 1

Calls 10

GetPropertyKeysForScopeFunction · 0.85
IsInternalPropertyFunction · 0.85
FindNodeByUidMethod · 0.80
GetConstPropertyFunction · 0.70
LockMethod · 0.45
IsNullMethod · 0.45
valueMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected