Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPluginDatabase.cpp @ 1646:da799f767e5d
simplification in error casting with plugins
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 24 Sep 2015 16:01:09 +0200 |
parents | eb8fbcf008b5 |
children | 2e692c83e2f3 |
comparison
equal
deleted
inserted
replaced
1645:1558b3226b18 | 1646:da799f767e5d |
---|---|
234 | 234 |
235 OrthancPluginErrorCode error = backend_.addAttachment(payload_, id, &tmp); | 235 OrthancPluginErrorCode error = backend_.addAttachment(payload_, id, &tmp); |
236 | 236 |
237 if (error != OrthancPluginErrorCode_Success) | 237 if (error != OrthancPluginErrorCode_Success) |
238 { | 238 { |
239 throw OrthancException(Plugins::Convert(error)); | 239 throw OrthancException(static_cast<ErrorCode>(error)); |
240 } | 240 } |
241 } | 241 } |
242 | 242 |
243 | 243 |
244 void OrthancPluginDatabase::AttachChild(int64_t parent, | 244 void OrthancPluginDatabase::AttachChild(int64_t parent, |
246 { | 246 { |
247 OrthancPluginErrorCode error = backend_.attachChild(payload_, parent, child); | 247 OrthancPluginErrorCode error = backend_.attachChild(payload_, parent, child); |
248 | 248 |
249 if (error != OrthancPluginErrorCode_Success) | 249 if (error != OrthancPluginErrorCode_Success) |
250 { | 250 { |
251 throw OrthancException(Plugins::Convert(error)); | 251 throw OrthancException(static_cast<ErrorCode>(error)); |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 | 255 |
256 void OrthancPluginDatabase::ClearChanges() | 256 void OrthancPluginDatabase::ClearChanges() |
257 { | 257 { |
258 OrthancPluginErrorCode error = backend_.clearChanges(payload_); | 258 OrthancPluginErrorCode error = backend_.clearChanges(payload_); |
259 | 259 |
260 if (error != OrthancPluginErrorCode_Success) | 260 if (error != OrthancPluginErrorCode_Success) |
261 { | 261 { |
262 throw OrthancException(Plugins::Convert(error)); | 262 throw OrthancException(static_cast<ErrorCode>(error)); |
263 } | 263 } |
264 } | 264 } |
265 | 265 |
266 | 266 |
267 void OrthancPluginDatabase::ClearExportedResources() | 267 void OrthancPluginDatabase::ClearExportedResources() |
268 { | 268 { |
269 OrthancPluginErrorCode error = backend_.clearExportedResources(payload_); | 269 OrthancPluginErrorCode error = backend_.clearExportedResources(payload_); |
270 | 270 |
271 if (error != OrthancPluginErrorCode_Success) | 271 if (error != OrthancPluginErrorCode_Success) |
272 { | 272 { |
273 throw OrthancException(Plugins::Convert(error)); | 273 throw OrthancException(static_cast<ErrorCode>(error)); |
274 } | 274 } |
275 } | 275 } |
276 | 276 |
277 | 277 |
278 int64_t OrthancPluginDatabase::CreateResource(const std::string& publicId, | 278 int64_t OrthancPluginDatabase::CreateResource(const std::string& publicId, |
282 | 282 |
283 OrthancPluginErrorCode error = backend_.createResource(&id, payload_, publicId.c_str(), Convert(type)); | 283 OrthancPluginErrorCode error = backend_.createResource(&id, payload_, publicId.c_str(), Convert(type)); |
284 | 284 |
285 if (error != OrthancPluginErrorCode_Success) | 285 if (error != OrthancPluginErrorCode_Success) |
286 { | 286 { |
287 throw OrthancException(Plugins::Convert(error)); | 287 throw OrthancException(static_cast<ErrorCode>(error)); |
288 } | 288 } |
289 | 289 |
290 return id; | 290 return id; |
291 } | 291 } |
292 | 292 |
296 { | 296 { |
297 OrthancPluginErrorCode error = backend_.deleteAttachment(payload_, id, static_cast<int32_t>(attachment)); | 297 OrthancPluginErrorCode error = backend_.deleteAttachment(payload_, id, static_cast<int32_t>(attachment)); |
298 | 298 |
299 if (error != OrthancPluginErrorCode_Success) | 299 if (error != OrthancPluginErrorCode_Success) |
300 { | 300 { |
301 throw OrthancException(Plugins::Convert(error)); | 301 throw OrthancException(static_cast<ErrorCode>(error)); |
302 } | 302 } |
303 } | 303 } |
304 | 304 |
305 | 305 |
306 void OrthancPluginDatabase::DeleteMetadata(int64_t id, | 306 void OrthancPluginDatabase::DeleteMetadata(int64_t id, |
308 { | 308 { |
309 OrthancPluginErrorCode error = backend_.deleteMetadata(payload_, id, static_cast<int32_t>(type)); | 309 OrthancPluginErrorCode error = backend_.deleteMetadata(payload_, id, static_cast<int32_t>(type)); |
310 | 310 |
311 if (error != OrthancPluginErrorCode_Success) | 311 if (error != OrthancPluginErrorCode_Success) |
312 { | 312 { |
313 throw OrthancException(Plugins::Convert(error)); | 313 throw OrthancException(static_cast<ErrorCode>(error)); |
314 } | 314 } |
315 } | 315 } |
316 | 316 |
317 | 317 |
318 void OrthancPluginDatabase::DeleteResource(int64_t id) | 318 void OrthancPluginDatabase::DeleteResource(int64_t id) |
319 { | 319 { |
320 OrthancPluginErrorCode error = backend_.deleteResource(payload_, id); | 320 OrthancPluginErrorCode error = backend_.deleteResource(payload_, id); |
321 | 321 |
322 if (error != OrthancPluginErrorCode_Success) | 322 if (error != OrthancPluginErrorCode_Success) |
323 { | 323 { |
324 throw OrthancException(Plugins::Convert(error)); | 324 throw OrthancException(static_cast<ErrorCode>(error)); |
325 } | 325 } |
326 } | 326 } |
327 | 327 |
328 | 328 |
329 void OrthancPluginDatabase::GetAllMetadata(std::map<MetadataType, std::string>& target, | 329 void OrthancPluginDatabase::GetAllMetadata(std::map<MetadataType, std::string>& target, |
355 | 355 |
356 OrthancPluginErrorCode error = backend_.getAllPublicIds(GetContext(), payload_, Convert(resourceType)); | 356 OrthancPluginErrorCode error = backend_.getAllPublicIds(GetContext(), payload_, Convert(resourceType)); |
357 | 357 |
358 if (error != OrthancPluginErrorCode_Success) | 358 if (error != OrthancPluginErrorCode_Success) |
359 { | 359 { |
360 throw OrthancException(Plugins::Convert(error)); | 360 throw OrthancException(static_cast<ErrorCode>(error)); |
361 } | 361 } |
362 | 362 |
363 ForwardAnswers(target); | 363 ForwardAnswers(target); |
364 } | 364 } |
365 | 365 |
377 OrthancPluginErrorCode error = extensions_.getAllPublicIdsWithLimit | 377 OrthancPluginErrorCode error = extensions_.getAllPublicIdsWithLimit |
378 (GetContext(), payload_, Convert(resourceType), since, limit); | 378 (GetContext(), payload_, Convert(resourceType), since, limit); |
379 | 379 |
380 if (error != OrthancPluginErrorCode_Success) | 380 if (error != OrthancPluginErrorCode_Success) |
381 { | 381 { |
382 throw OrthancException(Plugins::Convert(error)); | 382 throw OrthancException(static_cast<ErrorCode>(error)); |
383 } | 383 } |
384 | 384 |
385 ForwardAnswers(target); | 385 ForwardAnswers(target); |
386 } | 386 } |
387 else | 387 else |
430 | 430 |
431 OrthancPluginErrorCode error = backend_.getChanges(GetContext(), payload_, since, maxResults); | 431 OrthancPluginErrorCode error = backend_.getChanges(GetContext(), payload_, since, maxResults); |
432 | 432 |
433 if (error != OrthancPluginErrorCode_Success) | 433 if (error != OrthancPluginErrorCode_Success) |
434 { | 434 { |
435 throw OrthancException(Plugins::Convert(error)); | 435 throw OrthancException(static_cast<ErrorCode>(error)); |
436 } | 436 } |
437 } | 437 } |
438 | 438 |
439 | 439 |
440 void OrthancPluginDatabase::GetChildrenInternalId(std::list<int64_t>& target, | 440 void OrthancPluginDatabase::GetChildrenInternalId(std::list<int64_t>& target, |
444 | 444 |
445 OrthancPluginErrorCode error = backend_.getChildrenInternalId(GetContext(), payload_, id); | 445 OrthancPluginErrorCode error = backend_.getChildrenInternalId(GetContext(), payload_, id); |
446 | 446 |
447 if (error != OrthancPluginErrorCode_Success) | 447 if (error != OrthancPluginErrorCode_Success) |
448 { | 448 { |
449 throw OrthancException(Plugins::Convert(error)); | 449 throw OrthancException(static_cast<ErrorCode>(error)); |
450 } | 450 } |
451 | 451 |
452 ForwardAnswers(target); | 452 ForwardAnswers(target); |
453 } | 453 } |
454 | 454 |
460 | 460 |
461 OrthancPluginErrorCode error = backend_.getChildrenPublicId(GetContext(), payload_, id); | 461 OrthancPluginErrorCode error = backend_.getChildrenPublicId(GetContext(), payload_, id); |
462 | 462 |
463 if (error != OrthancPluginErrorCode_Success) | 463 if (error != OrthancPluginErrorCode_Success) |
464 { | 464 { |
465 throw OrthancException(Plugins::Convert(error)); | 465 throw OrthancException(static_cast<ErrorCode>(error)); |
466 } | 466 } |
467 | 467 |
468 ForwardAnswers(target); | 468 ForwardAnswers(target); |
469 } | 469 } |
470 | 470 |
481 | 481 |
482 OrthancPluginErrorCode error = backend_.getExportedResources(GetContext(), payload_, since, maxResults); | 482 OrthancPluginErrorCode error = backend_.getExportedResources(GetContext(), payload_, since, maxResults); |
483 | 483 |
484 if (error != OrthancPluginErrorCode_Success) | 484 if (error != OrthancPluginErrorCode_Success) |
485 { | 485 { |
486 throw OrthancException(Plugins::Convert(error)); | 486 throw OrthancException(static_cast<ErrorCode>(error)); |
487 } | 487 } |
488 } | 488 } |
489 | 489 |
490 | 490 |
491 void OrthancPluginDatabase::GetLastChange(std::list<ServerIndexChange>& target /*out*/) | 491 void OrthancPluginDatabase::GetLastChange(std::list<ServerIndexChange>& target /*out*/) |
498 | 498 |
499 OrthancPluginErrorCode error = backend_.getLastChange(GetContext(), payload_); | 499 OrthancPluginErrorCode error = backend_.getLastChange(GetContext(), payload_); |
500 | 500 |
501 if (error != OrthancPluginErrorCode_Success) | 501 if (error != OrthancPluginErrorCode_Success) |
502 { | 502 { |
503 throw OrthancException(Plugins::Convert(error)); | 503 throw OrthancException(static_cast<ErrorCode>(error)); |
504 } | 504 } |
505 } | 505 } |
506 | 506 |
507 | 507 |
508 void OrthancPluginDatabase::GetLastExportedResource(std::list<ExportedResource>& target /*out*/) | 508 void OrthancPluginDatabase::GetLastExportedResource(std::list<ExportedResource>& target /*out*/) |
515 | 515 |
516 OrthancPluginErrorCode error = backend_.getLastExportedResource(GetContext(), payload_); | 516 OrthancPluginErrorCode error = backend_.getLastExportedResource(GetContext(), payload_); |
517 | 517 |
518 if (error != OrthancPluginErrorCode_Success) | 518 if (error != OrthancPluginErrorCode_Success) |
519 { | 519 { |
520 throw OrthancException(Plugins::Convert(error)); | 520 throw OrthancException(static_cast<ErrorCode>(error)); |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 | 524 |
525 void OrthancPluginDatabase::GetMainDicomTags(DicomMap& map, | 525 void OrthancPluginDatabase::GetMainDicomTags(DicomMap& map, |
530 | 530 |
531 OrthancPluginErrorCode error = backend_.getMainDicomTags(GetContext(), payload_, id); | 531 OrthancPluginErrorCode error = backend_.getMainDicomTags(GetContext(), payload_, id); |
532 | 532 |
533 if (error != OrthancPluginErrorCode_Success) | 533 if (error != OrthancPluginErrorCode_Success) |
534 { | 534 { |
535 throw OrthancException(Plugins::Convert(error)); | 535 throw OrthancException(static_cast<ErrorCode>(error)); |
536 } | 536 } |
537 } | 537 } |
538 | 538 |
539 | 539 |
540 std::string OrthancPluginDatabase::GetPublicId(int64_t resourceId) | 540 std::string OrthancPluginDatabase::GetPublicId(int64_t resourceId) |
544 | 544 |
545 OrthancPluginErrorCode error = backend_.getPublicId(GetContext(), payload_, resourceId); | 545 OrthancPluginErrorCode error = backend_.getPublicId(GetContext(), payload_, resourceId); |
546 | 546 |
547 if (error != OrthancPluginErrorCode_Success) | 547 if (error != OrthancPluginErrorCode_Success) |
548 { | 548 { |
549 throw OrthancException(Plugins::Convert(error)); | 549 throw OrthancException(static_cast<ErrorCode>(error)); |
550 } | 550 } |
551 | 551 |
552 if (!ForwardSingleAnswer(s)) | 552 if (!ForwardSingleAnswer(s)) |
553 { | 553 { |
554 throw OrthancException(ErrorCode_DatabasePlugin); | 554 throw OrthancException(ErrorCode_DatabasePlugin); |
564 | 564 |
565 OrthancPluginErrorCode error = backend_.getResourceCount(&count, payload_, Convert(resourceType)); | 565 OrthancPluginErrorCode error = backend_.getResourceCount(&count, payload_, Convert(resourceType)); |
566 | 566 |
567 if (error != OrthancPluginErrorCode_Success) | 567 if (error != OrthancPluginErrorCode_Success) |
568 { | 568 { |
569 throw OrthancException(Plugins::Convert(error)); | 569 throw OrthancException(static_cast<ErrorCode>(error)); |
570 } | 570 } |
571 | 571 |
572 return count; | 572 return count; |
573 } | 573 } |
574 | 574 |
579 | 579 |
580 OrthancPluginErrorCode error = backend_.getResourceType(&type, payload_, resourceId); | 580 OrthancPluginErrorCode error = backend_.getResourceType(&type, payload_, resourceId); |
581 | 581 |
582 if (error != OrthancPluginErrorCode_Success) | 582 if (error != OrthancPluginErrorCode_Success) |
583 { | 583 { |
584 throw OrthancException(Plugins::Convert(error)); | 584 throw OrthancException(static_cast<ErrorCode>(error)); |
585 } | 585 } |
586 | 586 |
587 return Convert(type); | 587 return Convert(type); |
588 } | 588 } |
589 | 589 |
594 | 594 |
595 OrthancPluginErrorCode error = backend_.getTotalCompressedSize(&size, payload_); | 595 OrthancPluginErrorCode error = backend_.getTotalCompressedSize(&size, payload_); |
596 | 596 |
597 if (error != OrthancPluginErrorCode_Success) | 597 if (error != OrthancPluginErrorCode_Success) |
598 { | 598 { |
599 throw OrthancException(Plugins::Convert(error)); | 599 throw OrthancException(static_cast<ErrorCode>(error)); |
600 } | 600 } |
601 | 601 |
602 return size; | 602 return size; |
603 } | 603 } |
604 | 604 |
609 | 609 |
610 OrthancPluginErrorCode error = backend_.getTotalUncompressedSize(&size, payload_); | 610 OrthancPluginErrorCode error = backend_.getTotalUncompressedSize(&size, payload_); |
611 | 611 |
612 if (error != OrthancPluginErrorCode_Success) | 612 if (error != OrthancPluginErrorCode_Success) |
613 { | 613 { |
614 throw OrthancException(Plugins::Convert(error)); | 614 throw OrthancException(static_cast<ErrorCode>(error)); |
615 } | 615 } |
616 | 616 |
617 return size; | 617 return size; |
618 } | 618 } |
619 | 619 |
624 | 624 |
625 OrthancPluginErrorCode error = backend_.isExistingResource(&existing, payload_, internalId); | 625 OrthancPluginErrorCode error = backend_.isExistingResource(&existing, payload_, internalId); |
626 | 626 |
627 if (error != OrthancPluginErrorCode_Success) | 627 if (error != OrthancPluginErrorCode_Success) |
628 { | 628 { |
629 throw OrthancException(Plugins::Convert(error)); | 629 throw OrthancException(static_cast<ErrorCode>(error)); |
630 } | 630 } |
631 | 631 |
632 return (existing != 0); | 632 return (existing != 0); |
633 } | 633 } |
634 | 634 |
639 | 639 |
640 OrthancPluginErrorCode error = backend_.isProtectedPatient(&isProtected, payload_, internalId); | 640 OrthancPluginErrorCode error = backend_.isProtectedPatient(&isProtected, payload_, internalId); |
641 | 641 |
642 if (error != OrthancPluginErrorCode_Success) | 642 if (error != OrthancPluginErrorCode_Success) |
643 { | 643 { |
644 throw OrthancException(Plugins::Convert(error)); | 644 throw OrthancException(static_cast<ErrorCode>(error)); |
645 } | 645 } |
646 | 646 |
647 return (isProtected != 0); | 647 return (isProtected != 0); |
648 } | 648 } |
649 | 649 |
655 | 655 |
656 OrthancPluginErrorCode error = backend_.listAvailableMetadata(GetContext(), payload_, id); | 656 OrthancPluginErrorCode error = backend_.listAvailableMetadata(GetContext(), payload_, id); |
657 | 657 |
658 if (error != OrthancPluginErrorCode_Success) | 658 if (error != OrthancPluginErrorCode_Success) |
659 { | 659 { |
660 throw OrthancException(Plugins::Convert(error)); | 660 throw OrthancException(static_cast<ErrorCode>(error)); |
661 } | 661 } |
662 | 662 |
663 if (type_ != _OrthancPluginDatabaseAnswerType_None && | 663 if (type_ != _OrthancPluginDatabaseAnswerType_None && |
664 type_ != _OrthancPluginDatabaseAnswerType_Int32) | 664 type_ != _OrthancPluginDatabaseAnswerType_Int32) |
665 { | 665 { |
686 | 686 |
687 OrthancPluginErrorCode error = backend_.listAvailableAttachments(GetContext(), payload_, id); | 687 OrthancPluginErrorCode error = backend_.listAvailableAttachments(GetContext(), payload_, id); |
688 | 688 |
689 if (error != OrthancPluginErrorCode_Success) | 689 if (error != OrthancPluginErrorCode_Success) |
690 { | 690 { |
691 throw OrthancException(Plugins::Convert(error)); | 691 throw OrthancException(static_cast<ErrorCode>(error)); |
692 } | 692 } |
693 | 693 |
694 if (type_ != _OrthancPluginDatabaseAnswerType_None && | 694 if (type_ != _OrthancPluginDatabaseAnswerType_None && |
695 type_ != _OrthancPluginDatabaseAnswerType_Int32) | 695 type_ != _OrthancPluginDatabaseAnswerType_Int32) |
696 { | 696 { |
722 | 722 |
723 OrthancPluginErrorCode error = backend_.logChange(payload_, &tmp); | 723 OrthancPluginErrorCode error = backend_.logChange(payload_, &tmp); |
724 | 724 |
725 if (error != OrthancPluginErrorCode_Success) | 725 if (error != OrthancPluginErrorCode_Success) |
726 { | 726 { |
727 throw OrthancException(Plugins::Convert(error)); | 727 throw OrthancException(static_cast<ErrorCode>(error)); |
728 } | 728 } |
729 } | 729 } |
730 | 730 |
731 | 731 |
732 void OrthancPluginDatabase::LogExportedResource(const ExportedResource& resource) | 732 void OrthancPluginDatabase::LogExportedResource(const ExportedResource& resource) |
744 | 744 |
745 OrthancPluginErrorCode error = backend_.logExportedResource(payload_, &tmp); | 745 OrthancPluginErrorCode error = backend_.logExportedResource(payload_, &tmp); |
746 | 746 |
747 if (error != OrthancPluginErrorCode_Success) | 747 if (error != OrthancPluginErrorCode_Success) |
748 { | 748 { |
749 throw OrthancException(Plugins::Convert(error)); | 749 throw OrthancException(static_cast<ErrorCode>(error)); |
750 } | 750 } |
751 } | 751 } |
752 | 752 |
753 | 753 |
754 bool OrthancPluginDatabase::LookupAttachment(FileInfo& attachment, | 754 bool OrthancPluginDatabase::LookupAttachment(FileInfo& attachment, |
760 OrthancPluginErrorCode error = backend_.lookupAttachment | 760 OrthancPluginErrorCode error = backend_.lookupAttachment |
761 (GetContext(), payload_, id, static_cast<int32_t>(contentType)); | 761 (GetContext(), payload_, id, static_cast<int32_t>(contentType)); |
762 | 762 |
763 if (error != OrthancPluginErrorCode_Success) | 763 if (error != OrthancPluginErrorCode_Success) |
764 { | 764 { |
765 throw OrthancException(Plugins::Convert(error)); | 765 throw OrthancException(static_cast<ErrorCode>(error)); |
766 } | 766 } |
767 | 767 |
768 if (type_ == _OrthancPluginDatabaseAnswerType_None) | 768 if (type_ == _OrthancPluginDatabaseAnswerType_None) |
769 { | 769 { |
770 return false; | 770 return false; |
790 OrthancPluginErrorCode error = backend_.lookupGlobalProperty | 790 OrthancPluginErrorCode error = backend_.lookupGlobalProperty |
791 (GetContext(), payload_, static_cast<int32_t>(property)); | 791 (GetContext(), payload_, static_cast<int32_t>(property)); |
792 | 792 |
793 if (error != OrthancPluginErrorCode_Success) | 793 if (error != OrthancPluginErrorCode_Success) |
794 { | 794 { |
795 throw OrthancException(Plugins::Convert(error)); | 795 throw OrthancException(static_cast<ErrorCode>(error)); |
796 } | 796 } |
797 | 797 |
798 return ForwardSingleAnswer(target); | 798 return ForwardSingleAnswer(target); |
799 } | 799 } |
800 | 800 |
812 | 812 |
813 OrthancPluginErrorCode error = backend_.lookupIdentifier(GetContext(), payload_, &tmp); | 813 OrthancPluginErrorCode error = backend_.lookupIdentifier(GetContext(), payload_, &tmp); |
814 | 814 |
815 if (error != OrthancPluginErrorCode_Success) | 815 if (error != OrthancPluginErrorCode_Success) |
816 { | 816 { |
817 throw OrthancException(Plugins::Convert(error)); | 817 throw OrthancException(static_cast<ErrorCode>(error)); |
818 } | 818 } |
819 | 819 |
820 ForwardAnswers(target); | 820 ForwardAnswers(target); |
821 } | 821 } |
822 | 822 |
828 | 828 |
829 OrthancPluginErrorCode error = backend_.lookupIdentifier2(GetContext(), payload_, value.c_str()); | 829 OrthancPluginErrorCode error = backend_.lookupIdentifier2(GetContext(), payload_, value.c_str()); |
830 | 830 |
831 if (error != OrthancPluginErrorCode_Success) | 831 if (error != OrthancPluginErrorCode_Success) |
832 { | 832 { |
833 throw OrthancException(Plugins::Convert(error)); | 833 throw OrthancException(static_cast<ErrorCode>(error)); |
834 } | 834 } |
835 | 835 |
836 ForwardAnswers(target); | 836 ForwardAnswers(target); |
837 } | 837 } |
838 | 838 |
845 | 845 |
846 OrthancPluginErrorCode error = backend_.lookupMetadata(GetContext(), payload_, id, static_cast<int32_t>(type)); | 846 OrthancPluginErrorCode error = backend_.lookupMetadata(GetContext(), payload_, id, static_cast<int32_t>(type)); |
847 | 847 |
848 if (error != OrthancPluginErrorCode_Success) | 848 if (error != OrthancPluginErrorCode_Success) |
849 { | 849 { |
850 throw OrthancException(Plugins::Convert(error)); | 850 throw OrthancException(static_cast<ErrorCode>(error)); |
851 } | 851 } |
852 | 852 |
853 return ForwardSingleAnswer(target); | 853 return ForwardSingleAnswer(target); |
854 } | 854 } |
855 | 855 |
861 | 861 |
862 OrthancPluginErrorCode error = backend_.lookupParent(GetContext(), payload_, resourceId); | 862 OrthancPluginErrorCode error = backend_.lookupParent(GetContext(), payload_, resourceId); |
863 | 863 |
864 if (error != OrthancPluginErrorCode_Success) | 864 if (error != OrthancPluginErrorCode_Success) |
865 { | 865 { |
866 throw OrthancException(Plugins::Convert(error)); | 866 throw OrthancException(static_cast<ErrorCode>(error)); |
867 } | 867 } |
868 | 868 |
869 return ForwardSingleAnswer(parentId); | 869 return ForwardSingleAnswer(parentId); |
870 } | 870 } |
871 | 871 |
878 | 878 |
879 OrthancPluginErrorCode error = backend_.lookupResource(GetContext(), payload_, publicId.c_str()); | 879 OrthancPluginErrorCode error = backend_.lookupResource(GetContext(), payload_, publicId.c_str()); |
880 | 880 |
881 if (error != OrthancPluginErrorCode_Success) | 881 if (error != OrthancPluginErrorCode_Success) |
882 { | 882 { |
883 throw OrthancException(Plugins::Convert(error)); | 883 throw OrthancException(static_cast<ErrorCode>(error)); |
884 } | 884 } |
885 | 885 |
886 if (type_ == _OrthancPluginDatabaseAnswerType_None) | 886 if (type_ == _OrthancPluginDatabaseAnswerType_None) |
887 { | 887 { |
888 return false; | 888 return false; |
907 | 907 |
908 OrthancPluginErrorCode error = backend_.selectPatientToRecycle(GetContext(), payload_); | 908 OrthancPluginErrorCode error = backend_.selectPatientToRecycle(GetContext(), payload_); |
909 | 909 |
910 if (error != OrthancPluginErrorCode_Success) | 910 if (error != OrthancPluginErrorCode_Success) |
911 { | 911 { |
912 throw OrthancException(Plugins::Convert(error)); | 912 throw OrthancException(static_cast<ErrorCode>(error)); |
913 } | 913 } |
914 | 914 |
915 return ForwardSingleAnswer(internalId); | 915 return ForwardSingleAnswer(internalId); |
916 } | 916 } |
917 | 917 |
923 | 923 |
924 OrthancPluginErrorCode error = backend_.selectPatientToRecycle2(GetContext(), payload_, patientIdToAvoid); | 924 OrthancPluginErrorCode error = backend_.selectPatientToRecycle2(GetContext(), payload_, patientIdToAvoid); |
925 | 925 |
926 if (error != OrthancPluginErrorCode_Success) | 926 if (error != OrthancPluginErrorCode_Success) |
927 { | 927 { |
928 throw OrthancException(Plugins::Convert(error)); | 928 throw OrthancException(static_cast<ErrorCode>(error)); |
929 } | 929 } |
930 | 930 |
931 return ForwardSingleAnswer(internalId); | 931 return ForwardSingleAnswer(internalId); |
932 } | 932 } |
933 | 933 |
938 OrthancPluginErrorCode error = backend_.setGlobalProperty | 938 OrthancPluginErrorCode error = backend_.setGlobalProperty |
939 (payload_, static_cast<int32_t>(property), value.c_str()); | 939 (payload_, static_cast<int32_t>(property), value.c_str()); |
940 | 940 |
941 if (error != OrthancPluginErrorCode_Success) | 941 if (error != OrthancPluginErrorCode_Success) |
942 { | 942 { |
943 throw OrthancException(Plugins::Convert(error)); | 943 throw OrthancException(static_cast<ErrorCode>(error)); |
944 } | 944 } |
945 } | 945 } |
946 | 946 |
947 | 947 |
948 void OrthancPluginDatabase::SetMainDicomTag(int64_t id, | 948 void OrthancPluginDatabase::SetMainDicomTag(int64_t id, |
965 error = backend_.setMainDicomTag(payload_, id, &tmp); | 965 error = backend_.setMainDicomTag(payload_, id, &tmp); |
966 } | 966 } |
967 | 967 |
968 if (error != OrthancPluginErrorCode_Success) | 968 if (error != OrthancPluginErrorCode_Success) |
969 { | 969 { |
970 throw OrthancException(Plugins::Convert(error)); | 970 throw OrthancException(static_cast<ErrorCode>(error)); |
971 } | 971 } |
972 } | 972 } |
973 | 973 |
974 | 974 |
975 void OrthancPluginDatabase::SetMetadata(int64_t id, | 975 void OrthancPluginDatabase::SetMetadata(int64_t id, |
979 OrthancPluginErrorCode error = backend_.setMetadata | 979 OrthancPluginErrorCode error = backend_.setMetadata |
980 (payload_, id, static_cast<int32_t>(type), value.c_str()); | 980 (payload_, id, static_cast<int32_t>(type), value.c_str()); |
981 | 981 |
982 if (error != OrthancPluginErrorCode_Success) | 982 if (error != OrthancPluginErrorCode_Success) |
983 { | 983 { |
984 throw OrthancException(Plugins::Convert(error)); | 984 throw OrthancException(static_cast<ErrorCode>(error)); |
985 } | 985 } |
986 } | 986 } |
987 | 987 |
988 | 988 |
989 void OrthancPluginDatabase::SetProtectedPatient(int64_t internalId, | 989 void OrthancPluginDatabase::SetProtectedPatient(int64_t internalId, |
991 { | 991 { |
992 OrthancPluginErrorCode error = backend_.setProtectedPatient(payload_, internalId, isProtected); | 992 OrthancPluginErrorCode error = backend_.setProtectedPatient(payload_, internalId, isProtected); |
993 | 993 |
994 if (error != OrthancPluginErrorCode_Success) | 994 if (error != OrthancPluginErrorCode_Success) |
995 { | 995 { |
996 throw OrthancException(Plugins::Convert(error)); | 996 throw OrthancException(static_cast<ErrorCode>(error)); |
997 } | 997 } |
998 } | 998 } |
999 | 999 |
1000 | 1000 |
1001 class OrthancPluginDatabase::Transaction : public SQLite::ITransaction | 1001 class OrthancPluginDatabase::Transaction : public SQLite::ITransaction |
1016 { | 1016 { |
1017 OrthancPluginErrorCode error = backend_.startTransaction(payload_); | 1017 OrthancPluginErrorCode error = backend_.startTransaction(payload_); |
1018 | 1018 |
1019 if (error != OrthancPluginErrorCode_Success) | 1019 if (error != OrthancPluginErrorCode_Success) |
1020 { | 1020 { |
1021 throw OrthancException(Plugins::Convert(error)); | 1021 throw OrthancException(static_cast<ErrorCode>(error)); |
1022 } | 1022 } |
1023 } | 1023 } |
1024 | 1024 |
1025 virtual void Rollback() | 1025 virtual void Rollback() |
1026 { | 1026 { |
1027 OrthancPluginErrorCode error = backend_.rollbackTransaction(payload_); | 1027 OrthancPluginErrorCode error = backend_.rollbackTransaction(payload_); |
1028 | 1028 |
1029 if (error != OrthancPluginErrorCode_Success) | 1029 if (error != OrthancPluginErrorCode_Success) |
1030 { | 1030 { |
1031 throw OrthancException(Plugins::Convert(error)); | 1031 throw OrthancException(static_cast<ErrorCode>(error)); |
1032 } | 1032 } |
1033 } | 1033 } |
1034 | 1034 |
1035 virtual void Commit() | 1035 virtual void Commit() |
1036 { | 1036 { |
1037 OrthancPluginErrorCode error = backend_.commitTransaction(payload_); | 1037 OrthancPluginErrorCode error = backend_.commitTransaction(payload_); |
1038 | 1038 |
1039 if (error != OrthancPluginErrorCode_Success) | 1039 if (error != OrthancPluginErrorCode_Success) |
1040 { | 1040 { |
1041 throw OrthancException(Plugins::Convert(error)); | 1041 throw OrthancException(static_cast<ErrorCode>(error)); |
1042 } | 1042 } |
1043 } | 1043 } |
1044 }; | 1044 }; |
1045 | 1045 |
1046 | 1046 |
1091 uint32_t version; | 1091 uint32_t version; |
1092 OrthancPluginErrorCode error = extensions_.getDatabaseVersion(&version, payload_); | 1092 OrthancPluginErrorCode error = extensions_.getDatabaseVersion(&version, payload_); |
1093 | 1093 |
1094 if (error != OrthancPluginErrorCode_Success) | 1094 if (error != OrthancPluginErrorCode_Success) |
1095 { | 1095 { |
1096 throw OrthancException(Plugins::Convert(error)); | 1096 throw OrthancException(static_cast<ErrorCode>(error)); |
1097 } | 1097 } |
1098 | 1098 |
1099 return version; | 1099 return version; |
1100 } | 1100 } |
1101 else | 1101 else |
1117 payload_, targetVersion, | 1117 payload_, targetVersion, |
1118 reinterpret_cast<OrthancPluginStorageArea*>(&storageArea)); | 1118 reinterpret_cast<OrthancPluginStorageArea*>(&storageArea)); |
1119 | 1119 |
1120 if (error != OrthancPluginErrorCode_Success) | 1120 if (error != OrthancPluginErrorCode_Success) |
1121 { | 1121 { |
1122 throw OrthancException(Plugins::Convert(error)); | 1122 throw OrthancException(static_cast<ErrorCode>(error)); |
1123 } | 1123 } |
1124 } | 1124 } |
1125 } | 1125 } |
1126 | 1126 |
1127 | 1127 |