Mercurial > hg > orthanc
comparison OrthancServer/ServerIndex.cpp @ 2188:7cfc2e0383b3
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 29 Nov 2016 15:39:46 +0100 |
parents | 5a8840920121 |
children | c4b3259c8bce |
comparison
equal
deleted
inserted
replaced
2187:ad72fbd700b7 | 2188:7cfc2e0383b3 |
---|---|
589 } | 589 } |
590 } | 590 } |
591 | 591 |
592 | 592 |
593 | 593 |
594 void ServerIndex::SetInstanceMetadata(std::map<MetadataType, std::string>& instanceMetadata, | |
595 int64_t instance, | |
596 MetadataType metadata, | |
597 const std::string& value) | |
598 { | |
599 db_.SetMetadata(instance, metadata, value); | |
600 instanceMetadata[metadata] = value; | |
601 } | |
602 | |
603 | |
604 | |
594 StoreStatus ServerIndex::Store(std::map<MetadataType, std::string>& instanceMetadata, | 605 StoreStatus ServerIndex::Store(std::map<MetadataType, std::string>& instanceMetadata, |
595 DicomInstanceToStore& instanceToStore, | 606 DicomInstanceToStore& instanceToStore, |
596 const Attachments& attachments) | 607 const Attachments& attachments) |
597 { | 608 { |
598 boost::mutex::scoped_lock lock(mutex_); | 609 boost::mutex::scoped_lock lock(mutex_); |
744 case ResourceType_Series: | 755 case ResourceType_Series: |
745 db_.SetMetadata(series, it->first.second, it->second); | 756 db_.SetMetadata(series, it->first.second, it->second); |
746 break; | 757 break; |
747 | 758 |
748 case ResourceType_Instance: | 759 case ResourceType_Instance: |
749 db_.SetMetadata(instance, it->first.second, it->second); | 760 SetInstanceMetadata(instanceMetadata, instance, it->first.second, it->second); |
750 instanceMetadata[it->first.second] = it->second; | |
751 break; | 761 break; |
752 | 762 |
753 default: | 763 default: |
754 throw OrthancException(ErrorCode_ParameterOutOfRange); | 764 throw OrthancException(ErrorCode_ParameterOutOfRange); |
755 } | 765 } |
761 db_.SetMetadata(study, MetadataType_LastUpdate, now); | 771 db_.SetMetadata(study, MetadataType_LastUpdate, now); |
762 db_.SetMetadata(patient, MetadataType_LastUpdate, now); | 772 db_.SetMetadata(patient, MetadataType_LastUpdate, now); |
763 | 773 |
764 // Attach the auto-computed metadata for the instance level, | 774 // Attach the auto-computed metadata for the instance level, |
765 // reflecting these additions into the input metadata map | 775 // reflecting these additions into the input metadata map |
766 db_.SetMetadata(instance, MetadataType_Instance_ReceptionDate, now); | 776 SetInstanceMetadata(instanceMetadata, instance, MetadataType_Instance_ReceptionDate, now); |
767 instanceMetadata[MetadataType_Instance_ReceptionDate] = now; | 777 SetInstanceMetadata(instanceMetadata, instance, MetadataType_Instance_RemoteAet, instanceToStore.GetRemoteAet()); |
768 | |
769 db_.SetMetadata(instance, MetadataType_Instance_RemoteAet, instanceToStore.GetRemoteAet()); | |
770 instanceMetadata[MetadataType_Instance_RemoteAet] = instanceToStore.GetRemoteAet(); | |
771 | 778 |
772 { | 779 { |
773 std::string s = EnumerationToString(instanceToStore.GetRequestOrigin()); | 780 std::string s = EnumerationToString(instanceToStore.GetRequestOrigin()); |
774 db_.SetMetadata(instance, MetadataType_Instance_Origin, s); | 781 SetInstanceMetadata(instanceMetadata, instance, MetadataType_Instance_Origin, s); |
775 instanceMetadata[MetadataType_Instance_Origin] = s; | |
776 } | 782 } |
777 | 783 |
778 const DicomValue* value; | 784 const DicomValue* value; |
779 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_INSTANCE_NUMBER)) != NULL || | 785 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_INSTANCE_NUMBER)) != NULL || |
780 (value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGE_INDEX)) != NULL) | 786 (value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGE_INDEX)) != NULL) |
781 { | 787 { |
782 if (!value->IsNull() && | 788 if (!value->IsNull() && |
783 !value->IsBinary()) | 789 !value->IsBinary()) |
784 { | 790 { |
785 db_.SetMetadata(instance, MetadataType_Instance_IndexInSeries, value->GetContent()); | 791 SetInstanceMetadata(instanceMetadata, instance, MetadataType_Instance_IndexInSeries, value->GetContent()); |
786 instanceMetadata[MetadataType_Instance_IndexInSeries] = value->GetContent(); | |
787 } | 792 } |
788 } | 793 } |
789 | 794 |
790 // Check whether the series of this new instance is now completed | 795 // Check whether the series of this new instance is now completed |
791 if (isNewSeries) | 796 if (isNewSeries) |