comparison OrthancServer/Sources/OrthancRestApi/OrthancRestChanges.cpp @ 5804:25df40a274fd find-refactoring

/changes: allowing filtering on multiple changes
author Alain Mazy <am@orthanc.team>
date Mon, 23 Sep 2024 15:40:27 +0200
parents ca06dde85358
children 8a8756b2dd0b
comparison
equal deleted inserted replaced
5803:e219e272650d 5804:25df40a274fd
87 } 87 }
88 88
89 ServerContext& context = OrthancRestApi::GetContext(call); 89 ServerContext& context = OrthancRestApi::GetContext(call);
90 90
91 int64_t since, to; 91 int64_t since, to;
92 ChangeType filterType = ChangeType_INTERNAL_All; 92 std::set<ChangeType> filterType; // = ChangeType_INTERNAL_All;
93 93
94 unsigned int limit; 94 unsigned int limit;
95 bool last; 95 bool last;
96 GetSinceToAndLimit(since, to, limit, last, call); 96 GetSinceToAndLimit(since, to, limit, last, call);
97 97
98 std::string filterArgument = call.GetArgument("type", "all"); 98 std::string filterArgument = call.GetArgument("type", "all");
99 if (filterArgument != "all" && filterArgument != "All") 99 if (filterArgument != "all" && filterArgument != "All")
100 { 100 {
101 filterType = StringToChangeType(filterArgument); 101 std::set<std::string> filterTypeStrings;
102 Toolbox::SplitString(filterTypeStrings, filterArgument, ';');
103
104 for (std::set<std::string>::const_iterator it = filterTypeStrings.begin(); it != filterTypeStrings.end(); ++it)
105 {
106 filterType.insert(StringToChangeType(*it));
107 }
102 } 108 }
103 109
104 Json::Value result; 110 Json::Value result;
105 if (last) 111 if (last)
106 { 112 {
110 { 116 {
111 context.GetIndex().GetChangesExtended(result, since, to, limit, filterType); 117 context.GetIndex().GetChangesExtended(result, since, to, limit, filterType);
112 } 118 }
113 else 119 else
114 { 120 {
115 if (filterType != ChangeType_INTERNAL_All) 121 if (filterType.size() > 0)
116 { 122 {
117 throw OrthancException(ErrorCode_ParameterOutOfRange, "CAPABILITIES: Trying to filter changes while the Database backend does not support it (requires a DB backend with support for ExtendedChanges)"); 123 throw OrthancException(ErrorCode_ParameterOutOfRange, "CAPABILITIES: Trying to filter changes while the Database backend does not support it (requires a DB backend with support for ExtendedChanges)");
118 } 124 }
119 125
120 if (to != DEFAULT_TO) 126 if (to != DEFAULT_TO)