Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional features for save&restore search #2531

Merged
merged 3 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified app/save-and-restore/app/doc/images/search-and-filter-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
import javafx.fxml.Initializable;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextField;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import org.phoebus.applications.saveandrestore.model.NodeType;
import org.phoebus.applications.saveandrestore.model.Tag;
import org.phoebus.applications.saveandrestore.model.search.Filter;
import org.phoebus.applications.saveandrestore.model.search.SearchQueryUtil;
import org.phoebus.applications.saveandrestore.model.search.SearchQueryUtil.Keys;
import org.phoebus.applications.saveandrestore.ui.ImageRepository;
import org.phoebus.applications.saveandrestore.ui.SaveAndRestoreService;
import org.phoebus.ui.dialog.ListSelectionPopOver;

Expand Down Expand Up @@ -74,6 +76,30 @@ public class SearchQueryEditorController implements Initializable {
@FXML
private TextField descTextField;

@FXML
private TextField startTime;

@FXML
private TextField endTime;

@FXML
private CheckBox goldenOnlyCheckbox;

@FXML
private ImageView goldenImageView;

@FXML
private ImageView folderImageView;

@FXML
private ImageView configurationImageView;

@FXML
private ImageView snapshotImageView;

@FXML
private ImageView compositeSnapshotImageView;

private final SimpleStringProperty nodeNameProperty = new SimpleStringProperty();

private final SimpleBooleanProperty nodeTypeFolderProperty = new SimpleBooleanProperty();
Expand All @@ -85,8 +111,13 @@ public class SearchQueryEditorController implements Initializable {
private final SimpleStringProperty tagsProperty = new SimpleStringProperty();
private final SimpleStringProperty userProperty = new SimpleStringProperty();

private final SimpleStringProperty startTimeProperty = new SimpleStringProperty();
private final SimpleStringProperty endTimeProperty = new SimpleStringProperty();

private final SimpleStringProperty descProperty = new SimpleStringProperty();

private final SimpleBooleanProperty goldenOnlyProperty = new SimpleBooleanProperty();

private boolean searchDisabled = false;

private ListSelectionPopOver tagSearchPopover;
Expand All @@ -102,30 +133,36 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
}
});
nodeTypeFolderCheckBox.selectedProperty().bindBidirectional(nodeTypeFolderProperty);
folderImageView.imageProperty().set(ImageRepository.FOLDER);
nodeTypeFolderCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null && !newValue.equals(oldValue)) {
updateParametersAndSearch();
}
});
nodeTypeConfigurationCheckBox.selectedProperty().bindBidirectional(nodeTypeConfigurationProperty);
configurationImageView.imageProperty().set(ImageRepository.CONFIGURATION);
nodeTypeConfigurationCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null && !newValue.equals(oldValue)) {
updateParametersAndSearch();
}
});
nodeTypeSnapshotCheckBox.selectedProperty().bindBidirectional(nodeTypeSnapshotProperty);
snapshotImageView.imageProperty().set(ImageRepository.SNAPSHOT);
nodeTypeSnapshotCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null && !newValue.equals(oldValue)) {
updateParametersAndSearch();
}
});
nodeTypeCompositeSnapshotCheckBox.selectedProperty().bindBidirectional(nodeTypeCompositeSnapshotProperty);
compositeSnapshotImageView.imageProperty().set(ImageRepository.COMPOSITE_SNAPSHOT);
nodeTypeCompositeSnapshotCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null && !newValue.equals(oldValue)) {
updateParametersAndSearch();
}
});

goldenImageView.imageProperty().set(ImageRepository.GOLDEN_SNAPSHOT);

descTextField.textProperty().bindBidirectional(descProperty);
descTextField.setOnKeyPressed(e -> {
if (e.getCode() == KeyCode.ENTER) {
Expand All @@ -141,7 +178,20 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
tagsTextField.textProperty().bindBidirectional(tagsProperty);
tagsTextField.setOnKeyPressed(e -> {
if (e.getCode() == KeyCode.ENTER) {
tagSearchPopover.hide();
updateParametersAndSearch();
}
});

startTime.textProperty().bindBidirectional(startTimeProperty);
startTime.setOnKeyPressed(e -> {
if (e.getCode() == KeyCode.ENTER) {
updateParametersAndSearch();
}
});

endTime.textProperty().bindBidirectional(endTimeProperty);
endTime.setOnKeyPressed(e -> {
if (e.getCode() == KeyCode.ENTER) {
updateParametersAndSearch();
}
});
Expand All @@ -161,6 +211,8 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
}
}
);

startTime.textProperty().bindBidirectional(startTimeProperty);
}

public void setFilter(Filter filter) {
Expand All @@ -172,6 +224,8 @@ public void setFilter(Filter filter) {
userProperty.set(searchParams.get(Keys.USER.getName()));
descProperty.set(searchParams.get(Keys.DESC.getName()));
tagsProperty.set(searchParams.get(Keys.TAGS.getName()));
startTimeProperty.set(searchParams.get(Keys.STARTTIME.getName()));
endTimeProperty.set(searchParams.get(Keys.ENDTIME.getName()));

String typeValue = searchParams.get(Keys.TYPE.getName());
nodeTypeFolderProperty.set(false);
Expand Down Expand Up @@ -244,11 +298,25 @@ private String buildQueryString() {
if (!types.isEmpty()) {
map.put(Keys.TYPE.getName(), String.join(",", types));
}
if (startTimeProperty.get() != null && !startTimeProperty.get().isEmpty()) {
map.put(Keys.STARTTIME.getName(), startTimeProperty.get());
}
if (endTimeProperty.get() != null && !endTimeProperty.get().isEmpty()) {
map.put(Keys.ENDTIME.getName(), endTimeProperty.get());
}
if (goldenOnlyProperty.get()) {
String tags = map.get(Keys.TAGS.getName());
if (tags == null) {
map.put(Keys.TAGS.getName(), Tag.GOLDEN);
} else if(!tags.toLowerCase().contains(Tag.GOLDEN.toLowerCase())){
map.put(Keys.TAGS.getName(), tags + "," + Tag.GOLDEN);
}
}
return SearchQueryUtil.toQueryString(map);
}

@FXML
public void showPopOver() {
public void showTagsSelectionPopover() {
if (tagSearchPopover.isShowing()) {
tagSearchPopover.hide();
} else {
Expand All @@ -260,7 +328,7 @@ public void showPopOver() {
try {
List<String> tagNames = new ArrayList<>();
SaveAndRestoreService.getInstance().getAllTags().forEach(tag -> {
if (!tagNames.contains(tag.getName())) {
if (!tagNames.contains(tag.getName()) && !tag.getName().equalsIgnoreCase(Tag.GOLDEN)) {
tagNames.add(tag.getName());
}
});
Expand All @@ -276,4 +344,10 @@ public void showPopOver() {
tagSearchPopover.show(tagsTextField);
}
}

@FXML
public void goldenClicked() {
goldenOnlyProperty.set(goldenOnlyCheckbox.isSelected());
updateParametersAndSearch();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public void search(String queryString) {

query.set(null);
} else {
query.setValue(queryString);
query.set(queryString);
}
}

Expand Down Expand Up @@ -325,7 +325,7 @@ public void saveFilter() {
ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);
alert.getButtonTypes().setAll(buttonTypeOverwrite, buttonTypeCancel);
Optional<ButtonType> overwrite = alert.showAndWait();
if (overwrite.get() == buttonTypeOverwrite) {
if (overwrite.isPresent() && overwrite.get() == buttonTypeOverwrite) {
saveFilter(filterNameProperty.get());
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@

<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>

<BorderPane fx:id="advancedSearchPane" prefWidth="250.0" style="-fx-background-color: #f4f4f4;" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.phoebus.applications.saveandrestore.ui.search.SearchQueryEditorController">
<BorderPane prefWidth="250.0" style="-fx-background-color: #f4f4f4;" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.phoebus.applications.saveandrestore.ui.search.SearchQueryEditorController">
<center>

<GridPane>
Expand All @@ -45,49 +46,87 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER" />
<RowConstraints />
<RowConstraints />
<RowConstraints />
</rowConstraints>
<children>
<Label text="%filterEditorNodeName" GridPane.columnSpan="2" GridPane.rowIndex="0" />
<TextField fx:id="nodeNameTextField" GridPane.columnSpan="2" GridPane.rowIndex="1" />
<CheckBox fx:id="nodeTypeFolderCheckBox" text="%filterEditorNodeTypeFolder" GridPane.columnSpan="2" GridPane.rowIndex="2" />
<CheckBox fx:id="nodeTypeConfigurationCheckBox" text="%filterEditorNodeTypeConfiguration" GridPane.columnSpan="2" GridPane.rowIndex="3" />
<CheckBox fx:id="nodeTypeSnapshotCheckBox" text="%filterEditorNodeTypeSnapshot" GridPane.columnSpan="2" GridPane.rowIndex="4" />
<CheckBox fx:id="nodeTypeCompositeSnapshotCheckBox" text="%filterEditorNodeTypeCompositeSnapshot" GridPane.columnSpan="2" GridPane.rowIndex="5" />
<CheckBox fx:id="nodeTypeFolderCheckBox" GridPane.columnSpan="2" GridPane.rowIndex="2">
<graphic>
<ImageView fx:id="folderImageView" translateX="8.0" />
</graphic>
<tooltip>
<Tooltip text="%filterEditorNodeTypeFolder" />
</tooltip>
</CheckBox>
<CheckBox fx:id="nodeTypeConfigurationCheckBox" GridPane.columnSpan="2" GridPane.rowIndex="3">
<graphic>
<ImageView fx:id="configurationImageView" translateX="8.0" />
</graphic>
<tooltip>
<Tooltip text="%filterEditorNodeTypeConfiguration" />
</tooltip>
</CheckBox>
<CheckBox fx:id="nodeTypeSnapshotCheckBox" GridPane.columnSpan="2" GridPane.rowIndex="4">
<graphic>
<ImageView fx:id="snapshotImageView" translateX="8.0" />
</graphic>
<tooltip>
<Tooltip text="%filterEditorNodeTypeSnapshot" />
</tooltip>
</CheckBox>
<CheckBox fx:id="nodeTypeCompositeSnapshotCheckBox" GridPane.columnSpan="2" GridPane.rowIndex="5">
<graphic>
<ImageView fx:id="compositeSnapshotImageView" translateX="8.0" />
</graphic>
<tooltip>
<Tooltip text="%filterEditorNodeTypeCompositeSnapshot" />
</tooltip>
</CheckBox>
<Label text="%filterEditorDescriptionOrComment" GridPane.columnSpan="2" GridPane.rowIndex="6" />
<TextField fx:id="descTextField" GridPane.columnSpan="2" GridPane.rowIndex="7" />
<Label fx:id="tagsLabel" text="%filterEditorTags" GridPane.columnSpan="2" GridPane.rowIndex="8" />
<Label text="%filterEditorTags" GridPane.columnSpan="2" GridPane.rowIndex="8" />
<HBox GridPane.columnSpan="2" GridPane.hgrow="ALWAYS" GridPane.rowIndex="9">
<TextField fx:id="tagsTextField" HBox.hgrow="ALWAYS">
<HBox.margin>
<Insets bottom="3.0" right="3.0" top="3.0" />
</HBox.margin>
</TextField>
<Button onAction="#showPopOver" text="...">
<Button onAction="#showTagsSelectionPopover" text="...">
<HBox.margin>
<Insets bottom="3.0" left="3.0" top="3.0" />
</HBox.margin>
</Button>
</HBox>
<Label text="%filterEditorUser" GridPane.columnSpan="2" GridPane.rowIndex="10" />
<TextField fx:id="userTextField" GridPane.columnSpan="2" GridPane.rowIndex="11" />
<Label text="%Time" GridPane.columnSpan="2" GridPane.rowIndex="12">
<CheckBox fx:id="goldenOnlyCheckbox" onAction="#goldenClicked" GridPane.columnSpan="2" GridPane.rowIndex="10">
<graphic>
<ImageView fx:id="goldenImageView" translateX="8.0" />
</graphic>
<tooltip>
<Tooltip text="%golden" />
</tooltip>
</CheckBox>
<Label text="%filterEditorUser" GridPane.columnSpan="2" GridPane.rowIndex="11" />
<TextField fx:id="userTextField" GridPane.columnSpan="2" GridPane.rowIndex="12" />
<Label text="%Time" GridPane.columnSpan="2" GridPane.rowIndex="13">
<GridPane.margin>
<Insets top="5.0" />
</GridPane.margin>
</Label>

<Label text="%StartTime" GridPane.rowIndex="13">
<Label text="%StartTime" GridPane.rowIndex="14">
<GridPane.margin>
<Insets />
</GridPane.margin>
</Label>
<TextField fx:id="startTime" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="13">
<TextField fx:id="startTime" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="14">
<GridPane.margin>
<Insets bottom="3.0" left="3.0" top="3.0" />
</GridPane.margin>
</TextField>
<Label text="%EndTime" GridPane.rowIndex="14" />
<TextField fx:id="endTime" GridPane.columnIndex="1" GridPane.rowIndex="14">
<Label text="%EndTime" GridPane.rowIndex="15" />
<TextField fx:id="endTime" GridPane.columnIndex="1" GridPane.rowIndex="15">
<GridPane.margin>
<Insets bottom="3.0" left="3.0" top="3.0" />
</GridPane.margin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@
</Button>
<TableView fx:id="resultTableView" prefHeight="200.0" prefWidth="200.0" GridPane.columnSpan="6" GridPane.rowIndex="1">
<columns>
<TableColumn fx:id="typeColumn" editable="false" maxWidth="50.0" minWidth="50.0" prefWidth="50.0" style="-fx-alignment: TOP-CENTER;" text="%searchTableEntryTypeColumn" />
<TableColumn fx:id="nameColumn" editable="false" minWidth="250.0" prefWidth="250.0" style="-fx-alignment: TOP-LEFT;" text="%searchTableNameColumn" />
<TableColumn fx:id="commentColumn" editable="false" minWidth="300.0" prefWidth="300.0" text="%searchTableCommentColumn" />
<TableColumn fx:id="tagsColumn" editable="false" minWidth="300.0" prefWidth="300.0" text="%searchTableTagsColumn" />
<TableColumn fx:id="lastUpdatedColumn" editable="false" minWidth="250.0" prefWidth="250.0" style="-fx-alignment: TOP-RIGHT;" styleClass="timestamp-column" text="%searchLastUpdatedColumn" />
<TableColumn fx:id="userColumn" editable="false" minWidth="150.0" prefWidth="150.0" style="-fx-alignment: TOP-RIGHT;" text="%searchUserColumn" />
<TableColumn fx:id="typeColumn" editable="false" prefWidth="40.0" minWidth="40.0" maxWidth="40.0" style="-fx-alignment: TOP-CENTER;" text="%searchTableEntryTypeColumn" />
<TableColumn fx:id="nameColumn" editable="false" prefWidth="200.0" style="-fx-alignment: TOP-LEFT;" text="%searchTableNameColumn" />
<TableColumn fx:id="commentColumn" editable="false" prefWidth="250.0" text="%searchTableCommentColumn" />
<TableColumn fx:id="tagsColumn" editable="false" prefWidth="100.0" text="%searchTableTagsColumn" />
<TableColumn fx:id="lastUpdatedColumn" editable="false" prefWidth="200.0" style="-fx-alignment: TOP-RIGHT;" styleClass="timestamp-column" text="%searchLastUpdatedColumn" />
<TableColumn fx:id="userColumn" editable="false" prefWidth="150.0" style="-fx-alignment: TOP-RIGHT;" text="%searchUserColumn" />
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public SearchRequest buildSearchRequest(MultiValueMap<String, String> searchPara
case "tags":
DisMaxQuery.Builder tagsQuery = new DisMaxQuery.Builder();
tagsQuery.queries(Collections.emptyList());

for (String value : parameter.getValue()) {
for (String pattern : value.split("[|,;]")) {
String[] tagsSearchFields;
Expand All @@ -156,12 +157,14 @@ public SearchRequest buildSearchRequest(MultiValueMap<String, String> searchPara
else {
bqb.must(WildcardQuery.of(w -> w.caseInsensitive(true).field("node.tags." + tagsSearchFields[0]).value(tagsSearchFields[1].trim().toLowerCase()))._toQuery());
}
NestedQuery innerNestedQuery;
innerNestedQuery = NestedQuery.of(n1 -> n1.path("node.tags").query(bqb.build()._toQuery()));
NestedQuery innerNestedQuery = NestedQuery.of(n1 -> n1.path("node.tags").query(bqb.build()._toQuery()));
tagsQuery.queries(q -> q.nested(NestedQuery.of(n -> n.path("node").query(innerNestedQuery._toQuery()).scoreMode(ChildScoreMode.None))));
}
}
boolQueryBuilder.must(tagsQuery.build()._toQuery());
DisMaxQuery disMaxQuery = tagsQuery.build();
if(!disMaxQuery.queries().isEmpty()){
boolQueryBuilder.must(disMaxQuery._toQuery());
}
break;
case "size":
case "limit":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ <h3>tags</h3>
Multiple values can be specified using a comma separator, e.g. <code>tags=value1,value2</code>. This will
match nodes tagged with any of the tags.

To limit search on snapshots tagged with the "golden" tag, user should check the dedicated checkbox.

<p>
<b>NOTE 1</b>: A save-and-restore tag is composed of both a name and a comment. By default, an expression like <code>tags=foo</code>
will search for nodes where the <i>name</i> matches the value "foo". To search for tags where the comment matches "bar",
Expand Down