comparison OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp @ 5722:3fd4d5833c55 find-refactoring-clean

removed StatelessDatabaseOperations::ApplyLookupResources()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 19 Jul 2024 10:09:08 +0200
parents 3f97590cc0c9
children 58c549b881ae
comparison
equal deleted inserted replaced
5721:3f97590cc0c9 5722:3fd4d5833c55
1559 1559
1560 bool found; 1560 bool found;
1561 Operations operations; 1561 Operations operations;
1562 operations.Apply(*this, found, target, publicId, parentType); 1562 operations.Apply(*this, found, target, publicId, parentType);
1563 return found; 1563 return found;
1564 }
1565
1566
1567 void StatelessDatabaseOperations::ApplyLookupResources(std::vector<std::string>& resourcesId,
1568 std::vector<std::string>* instancesId,
1569 const DatabaseLookup& lookup,
1570 ResourceType queryLevel,
1571 const std::set<std::string>& labels,
1572 LabelsConstraint labelsConstraint,
1573 uint32_t limit)
1574 {
1575 class Operations : public ReadOnlyOperationsT6<bool, const DatabaseConstraints&, ResourceType,
1576 const std::set<std::string>&, LabelsConstraint, size_t>
1577 {
1578 private:
1579 std::list<std::string> resourcesList_;
1580 std::list<std::string> instancesList_;
1581
1582 public:
1583 const std::list<std::string>& GetResourcesList() const
1584 {
1585 return resourcesList_;
1586 }
1587
1588 const std::list<std::string>& GetInstancesList() const
1589 {
1590 return instancesList_;
1591 }
1592
1593 virtual void ApplyTuple(ReadOnlyTransaction& transaction,
1594 const Tuple& tuple) ORTHANC_OVERRIDE
1595 {
1596 // TODO - CANDIDATE FOR "TransactionType_Implicit"
1597 if (tuple.get<0>())
1598 {
1599 transaction.ApplyLookupResources(
1600 resourcesList_, &instancesList_, tuple.get<1>(), tuple.get<2>(), tuple.get<3>(), tuple.get<4>(), tuple.get<5>());
1601 }
1602 else
1603 {
1604 transaction.ApplyLookupResources(
1605 resourcesList_, NULL, tuple.get<1>(), tuple.get<2>(), tuple.get<3>(), tuple.get<4>(), tuple.get<5>());
1606 }
1607 }
1608 };
1609
1610 if (!labels.empty() &&
1611 !db_.GetDatabaseCapabilities().HasLabelsSupport())
1612 {
1613 throw OrthancException(ErrorCode_NotImplemented, "The database backend doesn't support labels");
1614 }
1615
1616 for (std::set<std::string>::const_iterator it = labels.begin(); it != labels.end(); ++it)
1617 {
1618 ServerToolbox::CheckValidLabel(*it);
1619 }
1620
1621 DatabaseConstraints normalized;
1622
1623 assert(mainDicomTagsRegistry_.get() != NULL);
1624 mainDicomTagsRegistry_->NormalizeLookup(normalized, lookup, queryLevel);
1625
1626 Operations operations;
1627 operations.Apply(*this, (instancesId != NULL), normalized, queryLevel, labels, labelsConstraint, limit);
1628
1629 CopyListToVector(resourcesId, operations.GetResourcesList());
1630
1631 if (instancesId != NULL)
1632 {
1633 CopyListToVector(*instancesId, operations.GetInstancesList());
1634 }
1635 } 1564 }
1636 1565
1637 1566
1638 bool StatelessDatabaseOperations::DeleteResource(Json::Value& remainingAncestor, 1567 bool StatelessDatabaseOperations::DeleteResource(Json::Value& remainingAncestor,
1639 const std::string& uuid, 1568 const std::string& uuid,