Skip to content

Commit da32693

Browse files
thomaslowsolth
andauthored
Refactor Bean Scopes: Task List (#6906)
* Refactor process list and make it view scoped. * Make selenium test work again. Fix extended search page for process search. Preserve select box state showInactiveProjects and showClosedProcesses as additional URL query parameters in process list view. * Refactor kitodo script dialog and process list view statistics dialog into separate files. * Remember last filter of process list in separate session scoped bean. * Remove unnecessary file BatchListView.java. * Remove ProcessListView from constructor of SearchForm, which is not required any more after bean scope refactoring of ProcessForm. * Refactor CurrentTaskForm to view scoped edit and list view beans. * Do not remove empty query parameters to distinguish empty filters from unspecified filters that are replaced with default values. * Improve nagivation from and to task list, task edit view and task work view. * Fix checkstyle issues. * Fix integration test for TaskListView which doesn't call init method. * Rename ProcessFormIT to ProcessListViewIT. * Fix spelling mistakes in Javadoc. * Update Javadoc and implement CodeQL suggestions. * Fix referrer navigation to and from task edit view. * Rename taskForm to taskListView in FilterMenu.java. * Include @solth's review feedback cleaning up unused methods in ProcessListView and improving code style. * Use utf8 from StandardCharsets when url encoding or decoding. * Fix spelling error. * Fix missing quote in processes.xhtml. Co-authored-by: Arved Solth <solth@effective-webwork.de> * Implement review feedback by @solth. * Remove unused methods in TaskListView and minor code style fixes based on @solth's review. --------- Co-authored-by: Arved Solth <solth@effective-webwork.de>
1 parent 04163de commit da32693

26 files changed

Lines changed: 1447 additions & 1177 deletions

Kitodo/src/main/java/org/kitodo/production/filters/FilterMenu.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
import org.kitodo.production.enums.FilterPart;
2626
import org.kitodo.production.enums.FilterString;
27-
import org.kitodo.production.forms.CurrentTaskForm;
2827
import org.kitodo.production.forms.process.ProcessListView;
28+
import org.kitodo.production.forms.task.TaskListView;
2929
import org.kitodo.production.forms.user.UserListView;
3030
import org.kitodo.production.services.ServiceManager;
3131
import org.kitodo.production.services.data.FilterService;
@@ -75,7 +75,7 @@ public class FilterMenu {
7575
);
7676

7777
private ProcessListView processListView = null;
78-
private CurrentTaskForm taskForm = null;
78+
private TaskListView taskListView = null;
7979
private UserListView userListView = null;
8080
private List<Suggestion> suggestions;
8181
private final List<ParsedFilter> parsedFilters;
@@ -95,10 +95,10 @@ public FilterMenu(ProcessListView processListView) {
9595
/**
9696
* Constructor of filter menu for tasks.
9797
*
98-
* @param taskForm instance of CurrentTaskForm
98+
* @param taskListView instance of TaskListView
9999
*/
100-
public FilterMenu(CurrentTaskForm taskForm) {
101-
this.taskForm = taskForm;
100+
public FilterMenu(TaskListView taskListView) {
101+
this.taskListView = taskListView;
102102
suggestions = createSuggestionsForTaskCategory("");
103103
parsedFilters = new ArrayList<>();
104104
}
@@ -146,7 +146,7 @@ public void updateSuggestions(String input) {
146146
// category should be suggested
147147
if (Objects.nonNull(processListView)) {
148148
suggestions = createSuggestionsForProcessCategory(input);
149-
} else if (Objects.nonNull(taskForm)) {
149+
} else if (Objects.nonNull(taskListView)) {
150150
suggestions = createSuggestionsForTaskCategory(input);
151151
} else if (Objects.nonNull(userListView)) {
152152
suggestions = createSuggestionsForUserCategory(input);
@@ -167,7 +167,7 @@ public void updateSuggestions(String input) {
167167
String category = matcherPreviousCategory.find() ? matcherPreviousCategory.group() : "";
168168
suggestions = createSuggestionsForProcessValue(checkFilterCategory(category, processCategories), lastPart);
169169
}
170-
} else if (Objects.nonNull(taskForm)) {
170+
} else if (Objects.nonNull(taskListView)) {
171171
if (matcherNextCategory.find()) {
172172
// strings ends with " | "
173173
suggestions = createSuggestionsForTaskCategory(matcherNextCategory.group());
@@ -397,8 +397,8 @@ public void updateFilters() {
397397
}
398398
if (Objects.nonNull(processListView)) {
399399
processListView.setFilter(newFilter.toString());
400-
} else if (Objects.nonNull(taskForm)) {
401-
taskForm.setFilter(newFilter.toString());
400+
} else if (Objects.nonNull(taskListView)) {
401+
taskListView.setFilter(newFilter.toString());
402402
} else if (Objects.nonNull(userListView)) {
403403
userListView.setFilter(newFilter.toString());
404404
}

Kitodo/src/main/java/org/kitodo/production/forms/BaseEditView.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
package org.kitodo.production.forms;
1313

14+
import java.net.URLDecoder;
15+
import java.nio.charset.StandardCharsets;
16+
import java.util.Objects;
17+
1418
/**
1519
* Base class for an edit view.
1620
*
@@ -37,8 +41,13 @@ public String getReferrerListOptions() {
3741
* @param referrerListOptions the referrer list options (URL query parameters)
3842
*/
3943
public void setReferrerListOptionsFromTemplate(String referrerListOptions) {
40-
this.referrerListOptions = referrerListOptions;
44+
if (Objects.nonNull(referrerListOptions) && referrerListOptions.startsWith("_")) {
45+
// referrerListOptions were URL encoded twice due to JSF's auto encoding of view paths
46+
// manually decode them again
47+
this.referrerListOptions = URLDecoder.decode(referrerListOptions.substring(1), StandardCharsets.UTF_8);
48+
} else {
49+
this.referrerListOptions = referrerListOptions;
50+
}
4151
}
42-
4352

4453
}

0 commit comments

Comments
 (0)