comparison OrthancServer/DatabaseWrapperBase.cpp @ 1746:d143db00a794 db-changes

SetOfResources
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 26 Oct 2015 16:04:58 +0100
parents 38dda23c7d7d
children 55d52567bebb
comparison
equal deleted inserted replaced
1745:38dda23c7d7d 1746:d143db00a794
32 32
33 #include "PrecompiledHeadersServer.h" 33 #include "PrecompiledHeadersServer.h"
34 #include "DatabaseWrapperBase.h" 34 #include "DatabaseWrapperBase.h"
35 35
36 #include <stdio.h> 36 #include <stdio.h>
37 #include <memory>
37 38
38 namespace Orthanc 39 namespace Orthanc
39 { 40 {
40 void DatabaseWrapperBase::SetGlobalProperty(GlobalProperty property, 41 void DatabaseWrapperBase::SetGlobalProperty(GlobalProperty property,
41 const std::string& value) 42 const std::string& value)
663 s.BindInt64(0, internalId); 664 s.BindInt64(0, internalId);
664 return s.Step(); 665 return s.Step();
665 } 666 }
666 667
667 668
669
670 /**
671
672 TODO REMOVE THIS
673
668 void DatabaseWrapperBase::LookupIdentifierExact(std::list<int64_t>& target, 674 void DatabaseWrapperBase::LookupIdentifierExact(std::list<int64_t>& target,
669 ResourceType level, 675 ResourceType level,
670 const DicomTag& tag, 676 const DicomTag& tag,
671 const std::string& value) 677 const std::string& value)
672 { 678 {
690 while (s.Step()) 696 while (s.Step())
691 { 697 {
692 target.push_back(s.ColumnInt64(0)); 698 target.push_back(s.ColumnInt64(0));
693 } 699 }
694 } 700 }
695 701 */
696 702
697 703
698 void DatabaseWrapperBase::LookupIdentifier(const LookupIdentifierQuery& query) 704
699 { 705 void DatabaseWrapperBase::LookupIdentifier(std::list<int64_t>& target,
700 // TODO 706 ResourceType level,
701 throw OrthancException(ErrorCode_NotImplemented); 707 const DicomTag& tag,
708 IdentifierConstraintType type,
709 const std::string& value)
710 {
711 static const char* COMMON = ("SELECT d.id FROM DicomIdentifiers AS d, Resources AS r WHERE "
712 "d.id = r.internalId AND r.resourceType=? AND "
713 "d.tagGroup=? AND d.tagElement=? AND ");
714
715 std::auto_ptr<SQLite::Statement> s;
716
717 switch (type)
718 {
719 case IdentifierConstraintType_Equal:
720 s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value=?"));
721 break;
722
723 case IdentifierConstraintType_GreaterOrEqual:
724 s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value>=?"));
725 break;
726
727 case IdentifierConstraintType_SmallerOrEqual:
728 s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value<=?"));
729 break;
730
731 case IdentifierConstraintType_Wildcard:
732 s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value LIKE ?"));
733 break;
734
735 default:
736 throw OrthancException(ErrorCode_ParameterOutOfRange);
737 }
738
739 assert(s.get() != NULL);
740
741 s->BindInt(0, level);
742 s->BindInt(1, tag.GetGroup());
743 s->BindInt(2, tag.GetElement());
744 s->BindString(3, value);
745
746 target.clear();
747
748 while (s->Step())
749 {
750 target.push_back(s->ColumnInt64(0));
751 }
702 } 752 }
703 } 753 }