Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp @ 5025:afa427f65444
Added an Asynchronous mode to /modalities/../move
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 21 Jun 2022 10:55:45 +0200 |
parents | c014ab79fca5 |
children | 98da039474b1 |
comparison
equal
deleted
inserted
replaced
5021:559b35d18ef7 | 5025:afa427f65444 |
---|---|
1515 | 1515 |
1516 static void DicomMove(RestApiPostCall& call) | 1516 static void DicomMove(RestApiPostCall& call) |
1517 { | 1517 { |
1518 if (call.IsDocumentation()) | 1518 if (call.IsDocumentation()) |
1519 { | 1519 { |
1520 OrthancRestApi::DocumentSubmitCommandsJob(call); | |
1520 call.GetDocumentation() | 1521 call.GetDocumentation() |
1521 .SetTag("Networking") | 1522 .SetTag("Networking") |
1522 .SetSummary("Trigger C-MOVE SCU") | 1523 .SetSummary("Trigger C-MOVE SCU") |
1523 .SetDescription("Start a C-MOVE SCU command as a job, in order to drive the execution of a sequence of " | 1524 .SetDescription("Start a C-MOVE SCU command as a job, in order to drive the execution of a sequence of " |
1524 "C-STORE commands by some remote DICOM modality whose identifier is provided in the URL: " | 1525 "C-STORE commands by some remote DICOM modality whose identifier is provided in the URL: " |
1532 "Ignored if `DicomModalities` already sets `LocalAet` for this modality.", false) | 1533 "Ignored if `DicomModalities` already sets `LocalAet` for this modality.", false) |
1533 .SetRequestField(KEY_TARGET_AET, RestApiCallDocumentation::Type_String, | 1534 .SetRequestField(KEY_TARGET_AET, RestApiCallDocumentation::Type_String, |
1534 "Target AET that will be used by the remote DICOM modality as a target for its C-STORE SCU " | 1535 "Target AET that will be used by the remote DICOM modality as a target for its C-STORE SCU " |
1535 "commands, defaults to `DicomAet` configuration option in order to do a simple query/retrieve", false) | 1536 "commands, defaults to `DicomAet` configuration option in order to do a simple query/retrieve", false) |
1536 .SetRequestField(KEY_TIMEOUT, RestApiCallDocumentation::Type_Number, | 1537 .SetRequestField(KEY_TIMEOUT, RestApiCallDocumentation::Type_Number, |
1537 "Timeout for the C-STORE command, in seconds", false) | 1538 "Timeout for the C-MOVE command, in seconds", false) |
1538 .SetUriArgument("id", "Identifier of the modality of interest"); | 1539 .SetUriArgument("id", "Identifier of the modality of interest"); |
1539 return; | 1540 return; |
1540 } | 1541 } |
1541 | 1542 |
1542 const ServerContext& context = OrthancRestApi::GetContext(call); | 1543 ServerContext& context = OrthancRestApi::GetContext(call); |
1543 | 1544 |
1544 Json::Value request; | 1545 Json::Value request; |
1545 | 1546 |
1546 if (!call.ParseJsonRequest(request) || | 1547 if (!call.ParseJsonRequest(request) || |
1547 request.type() != Json::objectValue || | 1548 request.type() != Json::objectValue || |
1562 (request, KEY_TARGET_AET, context.GetDefaultLocalApplicationEntityTitle()); | 1563 (request, KEY_TARGET_AET, context.GetDefaultLocalApplicationEntityTitle()); |
1563 | 1564 |
1564 const RemoteModalityParameters source = | 1565 const RemoteModalityParameters source = |
1565 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); | 1566 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); |
1566 | 1567 |
1567 DicomAssociationParameters params(localAet, source); | 1568 std::unique_ptr<DicomMoveScuJob> job(new DicomMoveScuJob(context)); |
1568 InjectAssociationTimeout(params, request); // Handles KEY_TIMEOUT | 1569 |
1569 | 1570 job->SetQueryFormat(DicomToJsonFormat_Short); |
1570 DicomControlUserConnection connection(params); | 1571 |
1572 // QueryAccessor query(call); | |
1573 job->SetTargetAet(targetAet); | |
1574 job->SetLocalAet(localAet); | |
1575 job->SetRemoteModality(source); | |
1576 | |
1577 if (request.isMember(KEY_TIMEOUT)) | |
1578 { | |
1579 job->SetTimeout(SerializationToolbox::ReadUnsignedInteger(request, KEY_TIMEOUT)); | |
1580 } | |
1571 | 1581 |
1572 for (Json::Value::ArrayIndex i = 0; i < request[KEY_RESOURCES].size(); i++) | 1582 for (Json::Value::ArrayIndex i = 0; i < request[KEY_RESOURCES].size(); i++) |
1573 { | 1583 { |
1574 DicomMap resource; | 1584 DicomMap resource; |
1575 FromDcmtkBridge::FromJson(resource, request[KEY_RESOURCES][i], "Resources elements"); | 1585 FromDcmtkBridge::FromJson(resource, request[KEY_RESOURCES][i], "Resources elements"); |
1576 | 1586 |
1577 connection.Move(targetAet, level, resource); | 1587 resource.SetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL, std::string(ResourceTypeToDicomQueryRetrieveLevel(level)), false); |
1578 } | 1588 |
1579 | 1589 job->AddQuery(resource); |
1580 // Move has succeeded | 1590 } |
1581 call.GetOutput().AnswerBuffer("{}", MimeType_Json); | 1591 |
1592 OrthancRestApi::GetApi(call).SubmitCommandsJob | |
1593 (call, job.release(), true /* synchronous by default */, request); | |
1594 return; | |
1582 } | 1595 } |
1583 | 1596 |
1584 | 1597 |
1585 | 1598 |
1586 /*************************************************************************** | 1599 /*************************************************************************** |