1
2
3
4
5
6
7
8
9
10
11 package com.sri.emo.controller.nodefilter;
12
13 import com.jcorporate.expresso.core.controller.*;
14 import com.jcorporate.expresso.core.db.DBException;
15 import com.sri.common.controller.StateHandler;
16 import com.sri.emo.controller.NodeAction;
17
18 import java.util.Map;
19 import java.util.Iterator;
20 import java.util.HashMap;
21 import java.util.HashSet;
22
23 /***
24 * sets filtering criteria
25 *
26 * @author Michael Rimov
27 */
28 public class DoFilterNodes implements StateHandler {
29
30 /***
31 * The name of this state as referred to by the Expresso Controller
32 */
33 public static final String STATE_NAME = "doFilterNodes";
34
35 /***
36 * The description of this state as referred to by the Expresso Controller.
37 */
38 public static final String STATE_DESCRIPTION = "Set Filter";
39
40 /***
41 * The public parent.
42 */
43
44
45
46
47
48
49
50 public void handleRequest(ExpressoRequest request, ExpressoResponse response)
51 throws DBException, ControllerException {
52
53 NodeFilter filter = new NodeFilter(request);
54 filter.saveNewCriteria();
55
56 Transition t = new Transition("", NodeAction.class, NodeAction.LIST_NODE);
57 Map allParameters = new HashMap(request.getAllParameters());
58 for (Iterator iterator = new HashSet(allParameters.keySet()).iterator(); iterator.hasNext();) {
59 String key = (String) iterator.next();
60 if (key.indexOf("button") != -1) {
61 allParameters.remove(key);
62 }
63 if (key.indexOf("Filter") != -1) {
64 allParameters.remove(key);
65 }
66
67 if ( key.indexOf("state") != -1) {
68 allParameters.remove(key);
69 }
70 if ( key.indexOf("controller") != -1) {
71 allParameters.remove(key);
72 }
73 if ( key.indexOf("FILTER_") != -1) {
74 allParameters.remove(key);
75 }
76 if ( key.indexOf("_params") != -1) {
77 allParameters.remove(key);
78 }
79 }
80 t.setParams(allParameters);
81 t.redirectTransition(request, response);
82 }
83 }