comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5684:9b3816c21008 find-refactoring

integration mainline->find-refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 09 Jul 2024 11:39:07 +0200
parents dc96401dbe88 0c218d90096e
children d0a264b803f1
comparison
equal deleted inserted replaced
5682:fd4c5e064cbe 5684:9b3816c21008
3500 query.AddRestConstraint(FromDcmtkBridge::ParseTag(members[i]), 3500 query.AddRestConstraint(FromDcmtkBridge::ParseTag(members[i]),
3501 value, caseSensitive, true); 3501 value, caseSensitive, true);
3502 } 3502 }
3503 } 3503 }
3504 3504
3505 std::set<std::string> labels;
3506
3505 if (request.isMember(KEY_LABELS)) // New in Orthanc 1.12.0 3507 if (request.isMember(KEY_LABELS)) // New in Orthanc 1.12.0
3506 { 3508 {
3507 for (Json::Value::ArrayIndex i = 0; i < request[KEY_LABELS].size(); i++) 3509 for (Json::Value::ArrayIndex i = 0; i < request[KEY_LABELS].size(); i++)
3508 { 3510 {
3509 if (request[KEY_LABELS][i].type() != Json::stringValue) 3511 if (request[KEY_LABELS][i].type() != Json::stringValue)
3510 { 3512 {
3511 throw OrthancException(ErrorCode_BadRequest, "Field \"" + std::string(KEY_LABELS) + "\" must contain strings"); 3513 throw OrthancException(ErrorCode_BadRequest, "Field \"" + std::string(KEY_LABELS) + "\" must contain strings");
3512 } 3514 }
3513 else 3515 else
3514 { 3516 {
3515 query.AddLabel(request[KEY_LABELS][i].asString()); 3517 labels.insert(request[KEY_LABELS][i].asString());
3516 } 3518 }
3517 } 3519 }
3518 } 3520 }
3519 3521
3520 query.SetLabelsConstraint(LabelsConstraint_All); 3522 LabelsConstraint labelsConstraint = LabelsConstraint_All;
3521 3523
3522 if (request.isMember(KEY_LABELS_CONSTRAINT)) 3524 if (request.isMember(KEY_LABELS_CONSTRAINT))
3523 { 3525 {
3524 const std::string& s = request[KEY_LABELS_CONSTRAINT].asString(); 3526 const std::string& s = request[KEY_LABELS_CONSTRAINT].asString();
3525 if (s == "All") 3527 if (s == "All")
3526 { 3528 {
3527 query.SetLabelsConstraint(LabelsConstraint_All); 3529 labelsConstraint = LabelsConstraint_All;
3528 } 3530 }
3529 else if (s == "Any") 3531 else if (s == "Any")
3530 { 3532 {
3531 query.SetLabelsConstraint(LabelsConstraint_Any); 3533 labelsConstraint = LabelsConstraint_Any;
3532 } 3534 }
3533 else if (s == "None") 3535 else if (s == "None")
3534 { 3536 {
3535 query.SetLabelsConstraint(LabelsConstraint_None); 3537 labelsConstraint = LabelsConstraint_None;
3536 } 3538 }
3537 else 3539 else
3538 { 3540 {
3539 throw OrthancException(ErrorCode_BadRequest, "Field \"" + std::string(KEY_LABELS_CONSTRAINT) + "\" must be \"All\", \"Any\", or \"None\""); 3541 throw OrthancException(ErrorCode_BadRequest, "Field \"" + std::string(KEY_LABELS_CONSTRAINT) + "\" must be \"All\", \"Any\", or \"None\"");
3540 } 3542 }
3541 } 3543 }
3542 3544
3543 FindVisitor visitor(OrthancRestApi::GetDicomFormat(request, DicomToJsonFormat_Human), context.GetFindStorageAccessMode()); 3545 FindVisitor visitor(OrthancRestApi::GetDicomFormat(request, DicomToJsonFormat_Human), context.GetFindStorageAccessMode());
3544 context.Apply(visitor, query, level, since, limit); 3546 context.Apply(visitor, query, level, labels, labelsConstraint, since, limit);
3545 visitor.Answer(call.GetOutput(), context, level, expand, requestedTags); 3547 visitor.Answer(call.GetOutput(), context, level, expand, requestedTags);
3546 } 3548 }
3547 } 3549 }
3548 3550
3549 3551