Mercurial > hg > orthanc
changeset 3078:147497152ce3 db-changes
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 03 Jan 2019 12:47:17 +0100 |
parents | aae1d6d31fef |
children | 65e2bfa953ef |
files | OrthancServer/SQLiteDatabaseWrapper.cpp OrthancServer/Search/DatabaseConstraint.cpp OrthancServer/Search/ISqlLookupFormatter.cpp OrthancServer/Search/ISqlLookupFormatter.h Plugins/Engine/OrthancPluginDatabase.cpp |
diffstat | 5 files changed, 23 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- 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<std::string>(level); + } + void Bind(SQLite::Statement& statement) const { size_t pos = 0;
--- 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 }
--- 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<std::string>(queryLevel) + comparisons); + formatter.FormatResourceType(queryLevel) + comparisons); if (limit != 0) {
--- 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<DatabaseConstraint>& lookup,
--- 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<const OrthancPluginChange*>(answer.valueGeneric); + const OrthancPluginChange& change = + *reinterpret_cast<const OrthancPluginChange*>(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),