1 19 package org.netbeans.modules.exceptions.web; 20 21 import java.util.ArrayList ; 22 import java.util.Arrays ; 23 import java.util.Collections ; 24 import java.util.Hashtable ; 25 import java.util.List ; 26 import java.util.logging.Level ; 27 import java.util.logging.Logger ; 28 import javax.naming.Context ; 29 import javax.naming.InitialContext ; 30 import javax.persistence.EntityManager; 31 import javax.persistence.EntityManagerFactory; 32 import javax.persistence.Persistence; 33 import javax.servlet.http.HttpServletRequest ; 34 import javax.servlet.http.HttpServletResponse ; 35 import org.apache.struts.action.Action; 36 import org.apache.struts.action.ActionForm; 37 import org.apache.struts.action.ActionMapping; 38 import org.apache.struts.action.ActionForward; 39 import org.netbeans.modules.exceptions.entity.Issue; 40 45 46 public class ListAction extends MyAction { 47 48 49 private final static String SUCCESS = "success"; 50 private final static String QUERY = "query"; 51 private final static String COUNT = "count"; 52 61 public ActionForward execute(ActionMapping mapping, ActionForm form, 62 HttpServletRequest request, HttpServletResponse response) 63 throws Exception { 64 65 String [] components = request.getParameterValues("component"); 66 String [] subcomponents = request.getParameterValues("subcomponent"); 67 String [] os = request.getParameterValues("os"); 68 String [] vm = request.getParameterValues("vm"); 69 String username = request.getParameter("username"); 70 71 Hashtable params = new Hashtable (); 72 73 if (components != null) { 74 params.put("component", Arrays.asList(components)); 75 } 76 if (subcomponents != null) { 77 params.put("subcomponent", Arrays.asList(subcomponents)); 78 } 79 if (os != null) { 80 params.put("operatingsystem", Arrays.asList(os)); 81 } 82 if (vm != null) { 83 params.put("vm", Arrays.asList(vm)); 84 } 85 if ((username != null) && (username.length() > 0)) { 86 params.put("username", Collections.singletonList(username)); 87 } 88 89 String query = request.getParameter("query"); 90 if (query != null) { 91 return mapping.findForward(QUERY); 92 } 93 94 String unmapped = request.getParameter("unmapped"); 95 if (unmapped != null) { 96 request.setAttribute("issues", findUnmapped()); 97 return mapping.findForward(SUCCESS); 98 } 99 100 101 102 String count = request.getParameter("count"); 103 if (count != null) { 104 request.setAttribute("count", count(Issue.class, params)); 105 return mapping.findForward(COUNT); 106 } 107 108 request.setAttribute("issues", find(Issue.class, params)); 109 return mapping.findForward(SUCCESS); 110 111 } 112 113 114 115 116 } 117 | Popular Tags |