Skip to content

Commit 906bec1

Browse files
authored
Merge pull request #4162 from gchq/gh-4159_vis_params
#4159 Fix StroomQL vis params
2 parents 28e7c9a + 3741314 commit 906bec1

File tree

3 files changed

+45
-16
lines changed

3 files changed

+45
-16
lines changed

Diff for: stroom-app/src/test/java/stroom/search/TestVisualisationTokenConsumer.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ void testVis() {
6161
eval count = count()
6262
group by EventTime
6363
select EventTime, count
64-
show LineChart (x = EventTime, y = count)
64+
show LineChart (x = EventTime, y = count, interpolationMode = "basis-open", maxValues = 500)
6565
""";
6666

67-
6867
SearchRequest searchRequest = new SearchRequest(
6968
null,
7069
null,
@@ -80,5 +79,4 @@ show LineChart (x = EventTime, y = count)
8079

8180

8281
}
83-
8482
}

Diff for: stroom-dashboard/stroom-dashboard-impl/src/main/java/stroom/dashboard/impl/visualisation/VisualisationTokenConsumerImpl.java

+20-13
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private Map<String, String> getVisParameters(final List<AbstractToken> children,
184184
for (int i = 0; i < children.size(); i++) {
185185
AbstractToken t = children.get(i);
186186
String controlId;
187-
String columnName;
187+
String controlValue;
188188

189189
// Get param name.
190190
if (!TokenType.isString(t)) {
@@ -221,18 +221,25 @@ private Map<String, String> getVisParameters(final List<AbstractToken> children,
221221
i++;
222222
if (i < children.size()) {
223223
t = children.get(i);
224-
if (!TokenType.isString(t)) {
225-
throw new TokenException(t, "Expected column name");
224+
if (TokenType.STRING.equals(t.getTokenType()) || TokenType.PARAM.equals(t.getTokenType())) {
225+
final String columnName = t.getUnescapedText();
226+
227+
// Validate the column name.
228+
final Column column = columnMap.get(columnName);
229+
if (column == null) {
230+
throw new TokenException(t, "Unable to find selected column: " + columnName);
231+
}
232+
233+
controlValue = columnName;
234+
235+
} else if (TokenType.isString(t) || TokenType.NUMBER.equals(t.getTokenType())) {
236+
controlValue = t.getUnescapedText();
237+
238+
} else {
239+
throw new TokenException(t, "Expected column name or value");
226240
}
227-
columnName = t.getUnescapedText();
228241
} else {
229-
throw new TokenException(t, "Expected column name");
230-
}
231-
232-
// Validate the column name.
233-
final Column column = columnMap.get(columnName);
234-
if (column == null) {
235-
throw new TokenException(t, "Unable to find selected column: " + columnName);
242+
throw new TokenException(t, "Expected column name or value");
236243
}
237244

238245
// Strip comma if there is one.
@@ -244,8 +251,8 @@ private Map<String, String> getVisParameters(final List<AbstractToken> children,
244251
}
245252
}
246253

247-
if (controlId != null && columnName != null) {
248-
params.put(controlId, columnName);
254+
if (controlId != null && controlValue != null) {
255+
params.put(controlId, controlValue);
249256
}
250257
}
251258
return params;

Diff for: unreleased_changes/20240314_164759_770__4159.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
* Issue **#4159** : Fix StroomQL vis params.
2+
3+
4+
```sh
5+
# ********************************************************************************
6+
# Issue title: sQL show, how to pass strings as params
7+
# Issue link: https://github.com/gchq/stroom/issues/4159
8+
# ********************************************************************************
9+
10+
# ONLY the top line will be included as a change entry in the CHANGELOG.
11+
# The entry should be in GitHub flavour markdown and should be written on a SINGLE
12+
# line with no hard breaks. You can have multiple change files for a single GitHub issue.
13+
# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than
14+
# 'Fixed nasty bug'.
15+
#
16+
# Examples of acceptable entries are:
17+
#
18+
#
19+
# * Issue **123** : Fix bug with an associated GitHub issue in this repository
20+
#
21+
# * Issue **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository
22+
#
23+
# * Fix bug with no associated GitHub issue.
24+
```

0 commit comments

Comments
 (0)