comparison OrthancServer/ServerIndex.cpp @ 704:4789da60d655

recycling with custom attachments
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Feb 2014 17:03:18 +0100
parents 7592a48e97e4
children 6a1dbba0cca7
comparison
equal deleted inserted replaced
703:fd86dfe8f584 704:4789da60d655
1606 if (!db_->LookupResource(publicId, resourceId, resourceType)) 1606 if (!db_->LookupResource(publicId, resourceId, resourceType))
1607 { 1607 {
1608 return StoreStatus_Failure; // Inexistent resource 1608 return StoreStatus_Failure; // Inexistent resource
1609 } 1609 }
1610 1610
1611 // Remove possible previous attachment
1611 db_->DeleteAttachment(resourceId, attachment.GetContentType()); 1612 db_->DeleteAttachment(resourceId, attachment.GetContentType());
1612 1613
1613 // TODO Integrate the recycling mechanism!! 1614 // Locate the patient of the target resource
1615 int64_t patientId = resourceId;
1616 for (;;)
1617 {
1618 int64_t parent;
1619 if (db_->LookupParent(parent, patientId))
1620 {
1621 // We have not reached the patient level yet
1622 patientId = parent;
1623 }
1624 else
1625 {
1626 // We have reached the patient level
1627 break;
1628 }
1629 }
1630
1631 // Possibly apply the recycling mechanism while preserving this patient
1632 assert(db_->GetResourceType(patientId) == ResourceType_Patient);
1633 Recycle(attachment.GetCompressedSize(), db_->GetPublicId(patientId));
1634
1614 db_->AddAttachment(resourceId, attachment); 1635 db_->AddAttachment(resourceId, attachment);
1615 1636
1616 t.Commit(attachment.GetCompressedSize()); 1637 t.Commit(attachment.GetCompressedSize());
1617 1638
1618 return StoreStatus_Success; 1639 return StoreStatus_Success;