# HG changeset patch # User Sebastien Jodogne # Date 1546516037 -3600 # Node ID 147497152ce3d706530bb09e6cafae1b5c513823 # Parent aae1d6d31fef657262412a4a76e265fdc20d7bdb fix diff -r aae1d6d31fef -r 147497152ce3 OrthancServer/SQLiteDatabaseWrapper.cpp --- a/OrthancServer/SQLiteDatabaseWrapper.cpp Thu Jan 03 10:06:42 2019 +0100 +++ b/OrthancServer/SQLiteDatabaseWrapper.cpp Thu Jan 03 12:47:17 2019 +0100 @@ -1132,6 +1132,11 @@ return "?"; } + virtual std::string FormatResourceType(ResourceType level) + { + return boost::lexical_cast(level); + } + void Bind(SQLite::Statement& statement) const { size_t pos = 0; diff -r aae1d6d31fef -r 147497152ce3 OrthancServer/Search/DatabaseConstraint.cpp --- a/OrthancServer/Search/DatabaseConstraint.cpp Thu Jan 03 10:06:42 2019 +0100 +++ b/OrthancServer/Search/DatabaseConstraint.cpp Thu Jan 03 12:47:17 2019 +0100 @@ -176,7 +176,7 @@ mandatory_(constraint.isMandatory) { if (constraintType_ != ConstraintType_List && - values_.size() != 1) + constraint.valuesCount != 1) { throw OrthancException(ErrorCode_ParameterOutOfRange); } @@ -185,6 +185,7 @@ for (uint32_t i = 0; i < constraint.valuesCount; i++) { + assert(constraint.values[i] != NULL); values_[i].assign(constraint.values[i]); } } @@ -223,6 +224,13 @@ { memset(&constraint, 0, sizeof(constraint)); + tmpValues.resize(values_.size()); + + for (size_t i = 0; i < values_.size(); i++) + { + tmpValues[i] = values_[i].c_str(); + } + constraint.level = Plugins::Convert(level_); constraint.tagGroup = tag_.GetGroup(); constraint.tagElement = tag_.GetElement(); @@ -231,13 +239,7 @@ constraint.isMandatory = mandatory_; constraint.type = Plugins::Convert(constraintType_); constraint.valuesCount = values_.size(); - - tmpValues.resize(values_.size()); - - for (size_t i = 0; i < values_.size(); i++) - { - tmpValues[i] = values_[i].c_str(); - } + constraint.values = (tmpValues.empty() ? NULL : &tmpValues[0]); } #endif } diff -r aae1d6d31fef -r 147497152ce3 OrthancServer/Search/ISqlLookupFormatter.cpp --- a/OrthancServer/Search/ISqlLookupFormatter.cpp Thu Jan 03 10:06:42 2019 +0100 +++ b/OrthancServer/Search/ISqlLookupFormatter.cpp Thu Jan 03 12:47:17 2019 +0100 @@ -260,12 +260,6 @@ ResourceType queryLevel, size_t limit) { - for (size_t i = 0; i < lookup.size(); i++) - { - std::cout << i << ": " << lookup[i].GetTag() << " - " << EnumerationToString(lookup[i].GetLevel()); - std::cout << std::endl; - } - assert(ResourceType_Patient < ResourceType_Study && ResourceType_Study < ResourceType_Series && ResourceType_Series < ResourceType_Instance); @@ -336,7 +330,7 @@ } sql += (joins + " WHERE " + FormatLevel(queryLevel) + ".resourceType = " + - boost::lexical_cast(queryLevel) + comparisons); + formatter.FormatResourceType(queryLevel) + comparisons); if (limit != 0) { diff -r aae1d6d31fef -r 147497152ce3 OrthancServer/Search/ISqlLookupFormatter.h --- a/OrthancServer/Search/ISqlLookupFormatter.h Thu Jan 03 10:06:42 2019 +0100 +++ b/OrthancServer/Search/ISqlLookupFormatter.h Thu Jan 03 12:47:17 2019 +0100 @@ -47,6 +47,8 @@ virtual std::string GenerateParameter(const std::string& value) = 0; + virtual std::string FormatResourceType(ResourceType level) = 0; + static void Apply(std::string& sql, ISqlLookupFormatter& formatter, const std::vector& lookup, diff -r aae1d6d31fef -r 147497152ce3 Plugins/Engine/OrthancPluginDatabase.cpp --- a/Plugins/Engine/OrthancPluginDatabase.cpp Thu Jan 03 10:06:42 2019 +0100 +++ b/Plugins/Engine/OrthancPluginDatabase.cpp Thu Jan 03 12:47:17 2019 +0100 @@ -1059,7 +1059,8 @@ } else { - const OrthancPluginChange& change = *reinterpret_cast(answer.valueGeneric); + const OrthancPluginChange& change = + *reinterpret_cast(answer.valueGeneric); assert(answerChanges_ != NULL); answerChanges_->push_back (ServerIndexChange(change.seq, @@ -1113,6 +1114,8 @@ throw OrthancException(ErrorCode_DatabasePlugin); } + printf(" ++ [%s]\n", match.resourceId); + assert(answerMatchingResources_ != NULL); answerMatchingResources_->push_back(match.resourceId); @@ -1176,11 +1179,10 @@ lookup[i].EncodeForPlugins(constraints[i], constraintsValues[i]); } + ResetAnswers(); answerMatchingResources_ = &resourcesId; answerMatchingInstances_ = instancesId; - ResetAnswers(); - CheckSuccess(extensions_.lookupResources(GetContext(), payload_, lookup.size(), (lookup.empty() ? NULL : &constraints[0]), Plugins::Convert(queryLevel),