Mercurial > hg > orthanc-databases
comparison SQLite/Plugins/IndexPlugin.cpp @ 208:696bc0c9fddb
fix build
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 19 Mar 2021 15:40:50 +0100 |
parents | d9ef3f16e6a2 |
children | 13a3863df7fa |
comparison
equal
deleted
inserted
replaced
207:d9ef3f16e6a2 | 208:696bc0c9fddb |
---|---|
556 tmp.metadata = metadata; | 556 tmp.metadata = metadata; |
557 tmp.value = StoreString(value); | 557 tmp.value = StoreString(value); |
558 | 558 |
559 metadata_.push_back(tmp); | 559 metadata_.push_back(tmp); |
560 } | 560 } |
561 | |
562 | |
563 void AnswerStrings(const std::list<std::string>& values) | |
564 { | |
565 SetupAnswerType(_OrthancPluginDatabaseAnswerType_String); | |
566 | |
567 stringAnswers_.reserve(values.size()); | |
568 std::copy(std::begin(values), std::end(values), std::back_inserter(stringAnswers_)); | |
569 } | |
561 }; | 570 }; |
562 | 571 |
563 | 572 |
564 class Factory : public IDatabaseBackendOutput::IFactory | 573 class Factory : public IDatabaseBackendOutput::IFactory |
565 { | 574 { |
755 | 764 |
756 try | 765 try |
757 { | 766 { |
758 t->GetOutput().Clear(); | 767 t->GetOutput().Clear(); |
759 t->GetBackend().AddAttachment(id, *attachment); | 768 t->GetBackend().AddAttachment(id, *attachment); |
769 return OrthancPluginErrorCode_Success; | |
770 } | |
771 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
772 } | |
773 | |
774 | |
775 static OrthancPluginErrorCode ClearChanges(OrthancPluginDatabaseTransaction* transaction) | |
776 { | |
777 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
778 | |
779 try | |
780 { | |
781 t->GetOutput().Clear(); | |
782 t->GetBackend().ClearChanges(); | |
783 return OrthancPluginErrorCode_Success; | |
784 } | |
785 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
786 } | |
787 | |
788 | |
789 static OrthancPluginErrorCode ClearExportedResources(OrthancPluginDatabaseTransaction* transaction) | |
790 { | |
791 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
792 | |
793 try | |
794 { | |
795 t->GetOutput().Clear(); | |
796 t->GetBackend().ClearExportedResources(); | |
797 return OrthancPluginErrorCode_Success; | |
798 } | |
799 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
800 } | |
801 | |
802 | |
803 static OrthancPluginErrorCode ClearMainDicomTags(OrthancPluginDatabaseTransaction* transaction, | |
804 int64_t resourceId) | |
805 { | |
806 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
807 | |
808 try | |
809 { | |
810 t->GetOutput().Clear(); | |
811 t->GetBackend().ClearMainDicomTags(resourceId); | |
812 return OrthancPluginErrorCode_Success; | |
813 } | |
814 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
815 } | |
816 | |
817 | |
818 static OrthancPluginErrorCode CreateInstance(OrthancPluginDatabaseTransaction* transaction, | |
819 OrthancPluginCreateInstanceResult* target /* out */, | |
820 const char* hashPatient, | |
821 const char* hashStudy, | |
822 const char* hashSeries, | |
823 const char* hashInstance) | |
824 { | |
825 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
826 | |
827 try | |
828 { | |
829 t->GetOutput().Clear(); | |
830 t->GetBackend().CreateInstance(*target, hashPatient, hashStudy, hashSeries, hashInstance); | |
831 return OrthancPluginErrorCode_Success; | |
832 } | |
833 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
834 } | |
835 | |
836 | |
837 static OrthancPluginErrorCode DeleteAttachment(OrthancPluginDatabaseTransaction* transaction, | |
838 int64_t id, | |
839 int32_t contentType) | |
840 { | |
841 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
842 | |
843 try | |
844 { | |
845 t->GetOutput().Clear(); | |
846 t->GetBackend().DeleteAttachment(t->GetOutput(), id, contentType); | |
847 return OrthancPluginErrorCode_Success; | |
848 } | |
849 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
850 } | |
851 | |
852 | |
853 static OrthancPluginErrorCode DeleteMetadata(OrthancPluginDatabaseTransaction* transaction, | |
854 int64_t id, | |
855 int32_t metadataType) | |
856 { | |
857 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
858 | |
859 try | |
860 { | |
861 t->GetOutput().Clear(); | |
862 t->GetBackend().DeleteMetadata(id, metadataType); | |
863 return OrthancPluginErrorCode_Success; | |
864 } | |
865 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
866 } | |
867 | |
868 | |
869 static OrthancPluginErrorCode DeleteResource(OrthancPluginDatabaseTransaction* transaction, | |
870 int64_t id) | |
871 { | |
872 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
873 | |
874 try | |
875 { | |
876 t->GetOutput().Clear(); | |
877 t->GetBackend().DeleteResource(t->GetOutput(), id); | |
878 return OrthancPluginErrorCode_Success; | |
879 } | |
880 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
881 } | |
882 | |
883 | |
884 static OrthancPluginErrorCode GetAllMetadata(OrthancPluginDatabaseTransaction* transaction, | |
885 int64_t id) | |
886 { | |
887 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
888 | |
889 try | |
890 { | |
891 t->GetOutput().Clear(); | |
892 | |
893 std::map<int32_t, std::string> values; | |
894 t->GetBackend().GetAllMetadata(values, id); | |
895 | |
896 for (std::map<int32_t, std::string>::const_iterator it = values.begin(); it != values.end(); ++it) | |
897 { | |
898 t->GetOutput().AnswerMetadata(it->first, it->second); | |
899 } | |
900 | |
901 return OrthancPluginErrorCode_Success; | |
902 } | |
903 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
904 } | |
905 | |
906 | |
907 static OrthancPluginErrorCode GetAllPublicIds(OrthancPluginDatabaseTransaction* transaction, | |
908 OrthancPluginResourceType resourceType) | |
909 { | |
910 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
911 | |
912 try | |
913 { | |
914 t->GetOutput().Clear(); | |
915 | |
916 std::list<std::string> values; | |
917 t->GetBackend().GetAllPublicIds(values, resourceType); | |
918 t->GetOutput().AnswerStrings(values); | |
919 | |
920 return OrthancPluginErrorCode_Success; | |
921 } | |
922 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
923 } | |
924 | |
925 | |
926 static OrthancPluginErrorCode GetAllPublicIdsWithLimit(OrthancPluginDatabaseTransaction* transaction, | |
927 OrthancPluginResourceType resourceType, | |
928 uint64_t since, | |
929 uint64_t limit) | |
930 { | |
931 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
932 | |
933 try | |
934 { | |
935 t->GetOutput().Clear(); | |
936 | |
937 std::list<std::string> values; | |
938 t->GetBackend().GetAllPublicIds(values, resourceType, since, limit); | |
939 t->GetOutput().AnswerStrings(values); | |
940 | |
941 return OrthancPluginErrorCode_Success; | |
942 } | |
943 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | |
944 } | |
945 | |
946 | |
947 static OrthancPluginErrorCode GetChanges(OrthancPluginDatabaseTransaction* transaction, | |
948 uint8_t* targetDone /* out */, | |
949 int64_t since, | |
950 uint32_t maxResults) | |
951 { | |
952 Transaction* t = reinterpret_cast<Transaction*>(transaction); | |
953 | |
954 try | |
955 { | |
956 t->GetOutput().Clear(); | |
957 | |
958 bool done; | |
959 t->GetBackend().GetChanges(t->GetOutput(), done, since, maxResults); | |
960 *targetDone = (done ? 1 : 0); | |
961 | |
760 return OrthancPluginErrorCode_Success; | 962 return OrthancPluginErrorCode_Success; |
761 } | 963 } |
762 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); | 964 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetContext()); |
763 } | 965 } |
764 | 966 |
792 params.destructTransaction = DestructTransaction; | 994 params.destructTransaction = DestructTransaction; |
793 params.rollback = Rollback; | 995 params.rollback = Rollback; |
794 params.commit = Commit; | 996 params.commit = Commit; |
795 | 997 |
796 params.addAttachment = AddAttachment; | 998 params.addAttachment = AddAttachment; |
999 params.clearChanges = ClearChanges; | |
1000 params.clearExportedResources = ClearExportedResources; | |
1001 params.clearMainDicomTags = ClearMainDicomTags; | |
1002 params.createInstance = CreateInstance; | |
1003 params.deleteAttachment = DeleteAttachment; | |
1004 params.deleteMetadata = DeleteMetadata; | |
1005 params.deleteResource = DeleteResource; | |
1006 params.getAllMetadata = GetAllMetadata; | |
1007 params.getAllPublicIds = GetAllPublicIds; | |
1008 params.getAllPublicIdsWithLimit = GetAllPublicIdsWithLimit; | |
1009 params.getChanges = GetChanges; | |
797 | 1010 |
798 OrthancPluginContext* context = database.GetContext(); | 1011 OrthancPluginContext* context = database.GetContext(); |
799 | 1012 |
800 if (OrthancPluginRegisterDatabaseBackendV3(context, ¶ms, sizeof(params), &database) != OrthancPluginErrorCode_Success) | 1013 if (OrthancPluginRegisterDatabaseBackendV3(context, ¶ms, sizeof(params), &database) != OrthancPluginErrorCode_Success) |
801 { | 1014 { |