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

Method BuildNodePredicate

Modules/RESTAPI/src/mitkDataStorageBridge.cpp:356–476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

354 }
355
356 NodePredicateBase::Pointer DataStorageBridge::BuildNodePredicate(const NodeQueryParams& params) const
357 {
358 auto dataStorage = m_DataStorage.Lock();
359 if (dataStorage.IsNull())
360 mitkThrow() << "BuildNodePredicate called without a valid DataStorage.";
361
362 std::vector<NodePredicateBase::Pointer> predicates;
363
364 // Hierarchy filter (toplevel = root nodes only)
365 if (params.hierarchy == Hierarchy::Toplevel)
366 {
367 auto isRootPredicate = NodePredicateFunction::New(
368 [dataStorage](const DataNode* node) -> bool {
369 auto sources = dataStorage->GetSources(node);
370 return sources->Size() == 0;
371 });
372 predicates.push_back(isRootPredicate.GetPointer());
373 }
374
375 // Path filter
376 if (params.path.has_value())
377 {
378 const std::string targetPath = params.path.value();
379 auto pathPredicate = NodePredicateFunction::New(
380 [this, targetPath](const DataNode* node) -> bool {
381 return this->BuildNodePath(node) == targetPath;
382 });
383 predicates.push_back(pathPredicate.GetPointer());
384 }
385
386 // Data type filter
387 if (params.dataType.has_value())
388 {
389 std::string dataType = params.dataType.value();
390
391 auto dataTypePredicate = NodePredicateDataType::New(dataType.c_str());
392 predicates.push_back(dataTypePredicate.GetPointer());
393 }
394
395 // Parent UID filter
396 if (params.parentUid.has_value())
397 {
398 const std::string targetParentUid = params.parentUid.value();
399 auto parentPredicate = NodePredicateFunction::New(
400 [this, dataStorage, targetParentUid](const DataNode* node) -> bool {
401 auto sources = dataStorage->GetSources(node);
402
403 if (targetParentUid == "null")
404 {
405 // Filter for root nodes (no parent)
406 return sources->Size() == 0;
407 }
408 else
409 {
410 // Check if parent matches the target UID
411 for (auto srcIt = sources->Begin(); srcIt != sources->End(); ++srcIt)
412 {
413 auto parentUid = m_UidMapper->GetUid(srcIt->Value().GetPointer());

Callers 1

GetNodesMethod · 0.95

Calls 15

BuildNodePathMethod · 0.95
JsonValueToFilterStringFunction · 0.85
MatchesPropertyFilterFunction · 0.85
GetSourcesMethod · 0.80
GetPointerMethod · 0.80
ValueMethod · 0.80
GetConstPropertyFunction · 0.70
NewFunction · 0.50
LockMethod · 0.45
IsNullMethod · 0.45
SizeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected