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

Method NodeToJson

Modules/RESTAPI/src/mitkDataStorageBridge.cpp:1328–1372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1326 }
1327
1328 DataStorageBridge::Json DataStorageBridge::NodeToJson(DataNode* node) const
1329 {
1330 // Note: caller must hold m_Mutex
1331 auto dataStorage = m_DataStorage.Lock();
1332 if (dataStorage.IsNull())
1333 mitkThrow() << "NodeToJson called without a valid DataStorage.";
1334
1335 Json result;
1336
1337 // Get or create UID
1338 result["uid"] = m_UidMapper->GetOrCreateUid(node);
1339 result["name"] = node->GetName();
1340 result["path"] = this->BuildNodePath(node);
1341
1342 // Get parent UID if exists
1343 auto sources = dataStorage->GetSources(node);
1344 if (sources->Size() > 0)
1345 {
1346 auto parent = sources->ElementAt(0).GetPointer();
1347 result["parent_uid"] = m_UidMapper->GetOrCreateUid(parent);
1348 }
1349 else
1350 {
1351 result["parent_uid"] = nullptr;
1352 }
1353
1354 // Get data type
1355 auto data = node->GetData();
1356 if (data != nullptr)
1357 {
1358 result["data_type"] = data->GetNameOfClass();
1359 }
1360 else
1361 {
1362 result["data_type"] = nullptr;
1363 }
1364
1365 // Children count
1366 result["children_count"] = this->GetChildrenCount(node);
1367
1368 // Timestamp: ITK modified time (ever-increasing integer, session-only, higher is newer)
1369 result["timestamp"] = static_cast<unsigned long>(node->GetMTime());
1370
1371 return result;
1372 }
1373
1374 std::string DataStorageBridge::BuildNodePath(const DataNode* node) const
1375 {

Callers 2

GetNodesMethod · 0.95
GetNodeMethod · 0.95

Calls 12

BuildNodePathMethod · 0.95
GetChildrenCountMethod · 0.95
GetOrCreateUidMethod · 0.80
GetSourcesMethod · 0.80
GetPointerMethod · 0.80
LockMethod · 0.45
IsNullMethod · 0.45
GetNameMethod · 0.45
SizeMethod · 0.45
GetDataMethod · 0.45
GetNameOfClassMethod · 0.45
GetMTimeMethod · 0.45

Tested by

no test coverage detected