1.1 --- a/logger/uihandlerserver/src/java/org/netbeans/modules/exceptions/entity/Exceptions.java Fri Jan 18 07:40:28 2008 +0000
1.2 +++ b/logger/uihandlerserver/src/java/org/netbeans/modules/exceptions/entity/Exceptions.java Fri Jan 18 08:30:17 2008 +0000
1.3 @@ -88,7 +88,10 @@
1.4 @NamedQuery(name = "Exceptions.countByBuildInterval", query = "SELECT COUNT(e) FROM Exceptions e WHERE e.build BETWEEN :start AND :end"),
1.5 @NamedQuery(name = "Exceptions.countByBuild", query = "SELECT COUNT(e) FROM Exceptions e WHERE e.build = :build"),
1.6 @NamedQuery(name = "Exceptions.selectBuilds", query = "SELECT DISTINCT e.build FROM Exceptions e WHERE e.build > :from ORDER BY e.build"),
1.7 -@NamedQuery(name = "Exceptions.findByStatus", query = "SELECT e FROM Exceptions e WHERE e.status = :status")})
1.8 +@NamedQuery(name = "Exceptions.findByStatus", query = "SELECT e FROM Exceptions e WHERE e.status = :status"),
1.9 +@NamedQuery(name = "Exceptions.findByLikeLine", query = "SELECT DISTINCT e FROM Exceptions e, Line l WHERE e.stacktrace = l.stacktrace AND l.method.name LIKE :line"),
1.10 +@NamedQuery(name = "Exceptions.findByLikeLineWithoutDups", query = "SELECT DISTINCT e FROM Exceptions e, Line l WHERE e.stacktrace = l.stacktrace " +
1.11 +"AND l.method.name LIKE :line AND e.duplicateof IS NULL")})
1.12
1.13 public class Exceptions implements Serializable {
1.14
2.1 --- a/logger/uihandlerserver/src/java/org/netbeans/modules/exceptions/utils/PersistenceUtils.java Fri Jan 18 07:40:28 2008 +0000
2.2 +++ b/logger/uihandlerserver/src/java/org/netbeans/modules/exceptions/utils/PersistenceUtils.java Fri Jan 18 08:30:17 2008 +0000
2.3 @@ -50,9 +50,6 @@
2.4 import java.util.Set;
2.5 import java.util.logging.Level;
2.6 import java.util.logging.Logger;
2.7 -import javax.naming.Context;
2.8 -import javax.naming.InitialContext;
2.9 -import javax.naming.NamingException;
2.10 import javax.persistence.EntityManager;
2.11 import javax.persistence.EntityManagerFactory;
2.12 import javax.persistence.NoResultException;
2.13 @@ -131,6 +128,21 @@
2.14 public static String getSettingsDirectory(){
2.15 return SETTINGS_DIRECTORY;
2.16 }
2.17 +
2.18 + public List<Exceptions> findExceptionsBySimilarLines(String searchedLine, boolean originals) {
2.19 + EntityManager em = createEntityManager();
2.20 + Query query;
2.21 + if (originals){
2.22 + query = em.createNamedQuery("Exceptions.findByLikeLine");
2.23 + }else{
2.24 + query = em.createNamedQuery("Exceptions.findByLikeLineWithoutDups");
2.25 + }
2.26 + query.setParameter("line", "%"+searchedLine+"%");
2.27 + query.setMaxResults(200);
2.28 + List<Exceptions> result = query.getResultList();
2.29 + em.close();
2.30 + return result;
2.31 + }
2.32
2.33 public Components getComponents() {
2.34 if (components == null) {
3.1 --- a/logger/uihandlerserver/src/java/org/netbeans/web/action/ListAction.java Fri Jan 18 07:40:28 2008 +0000
3.2 +++ b/logger/uihandlerserver/src/java/org/netbeans/web/action/ListAction.java Fri Jan 18 08:30:17 2008 +0000
3.3 @@ -38,13 +38,11 @@
3.4 * Version 2 license, then the option applies only if the new code is
3.5 * made subject to such option by the copyright holder.
3.6 */
3.7 -package org.netbeans.modules.exceptions.web.action;
3.8 +package org.netbeans.web.action;
3.9
3.10 import java.util.ArrayList;
3.11 -import java.util.Arrays;
3.12 import java.util.Collection;
3.13 import java.util.Collections;
3.14 -import java.util.Hashtable;
3.15 import java.util.List;
3.16 import java.util.Map;
3.17 import javax.servlet.http.HttpServletRequest;
3.18 @@ -82,6 +80,7 @@
3.19 * @throws java.lang.Exception
3.20 * @return
3.21 */
3.22 + @Override
3.23 public ActionForward execute(ActionMapping mapping, ActionForm form,
3.24 HttpServletRequest request, HttpServletResponse response)
3.25 throws Exception {
3.26 @@ -90,9 +89,10 @@
3.27 String query = request.getParameter("query");
3.28 String unmapped = request.getParameter("unmapped");
3.29 String count = request.getParameter("count");
3.30 + String searchedLine = request.getParameter("searchedLine");
3.31 boolean duplicates = "on".equals(request.getParameter("duplicates")); //show only issues with one or more duplicates
3.32 boolean originals = "on".equals(request.getParameter("originals"));
3.33 -
3.34 +
3.35 Map params = Utils.getParamsFromRequest(request);
3.36
3.37 if (order != null) {
3.38 @@ -105,7 +105,13 @@
3.39 order = (String) o;
3.40 }
3.41 }
3.42 -
3.43 +
3.44 + if (searchedLine != null){
3.45 + List<Exceptions> data = PersistenceUtils.getInstance().findExceptionsBySimilarLines(searchedLine, !originals);
3.46 + request.setAttribute("count", data.size());
3.47 + request.setAttribute("exceptions", data);
3.48 + return mapping.findForward(SUCCESS);
3.49 + }
3.50
3.51 if (query != null) {
3.52 return mapping.findForward(QUERY);
4.1 --- a/logger/uihandlerserver/test/org/netbeans/server/uihandler/DbInsertionTest.java Fri Jan 18 07:40:28 2008 +0000
4.2 +++ b/logger/uihandlerserver/test/org/netbeans/server/uihandler/DbInsertionTest.java Fri Jan 18 08:30:17 2008 +0000
4.3 @@ -41,6 +41,7 @@
4.4
4.5 package org.netbeans.server.uihandler;
4.6
4.7 +import java.io.File;
4.8 import java.util.Arrays;
4.9 import java.util.Iterator;
4.10 import java.util.List;
4.11 @@ -48,6 +49,7 @@
4.12 import java.util.logging.LogRecord;
4.13 import org.junit.Test;
4.14 import org.netbeans.modules.exceptions.entity.Comment;
4.15 +import org.netbeans.modules.exceptions.entity.Exceptions;
4.16 import org.netbeans.modules.exceptions.entity.Jarfile;
4.17 import org.netbeans.modules.exceptions.entity.Line;
4.18 import org.netbeans.modules.exceptions.entity.Logfile;
4.19 @@ -310,5 +312,46 @@
4.20 comp = DbInsertion.getComponentFromComment(comment);
4.21 assertNull("NON EXISTING COMPONENT", comp);
4.22
4.23 - }
4.24 -}
4.25 \ No newline at end of file
4.26 + }
4.27 +
4.28 + @Test
4.29 + public void testFindBySimilarLine() throws Exception {
4.30 + File log = LogsManagerTest.extractResourceAs(data, "dup1", "NB2040811605.0");
4.31 + addLog(log, "NB2040811605");
4.32 + log = LogsManagerTest.extractResourceAs(data, "dup2", "NB2040811605.1");
4.33 + addLog(log, "NB2040811605");
4.34 + String e1Line = "org.openide.text.QuietEditorPane.firePropertyChange";
4.35 + String e2Line = "java.awt.EventDispatchThread.run";
4.36 + String justDup1 = "javax.swing.text.JTextComponent.getSelection";
4.37 + String substring ="java.awt.";
4.38 + String nothing = "my.class.Error";
4.39 + List<Exceptions> list = perUtils.findExceptionsBySimilarLines(e1Line, false);
4.40 + assertEquals(2, list.size());
4.41 +
4.42 + list = perUtils.findExceptionsBySimilarLines(e2Line, false);
4.43 + assertEquals(2, list.size());
4.44 +
4.45 + list = perUtils.findExceptionsBySimilarLines(substring, false);
4.46 + assertEquals(2, list.size());
4.47 +
4.48 + list = perUtils.findExceptionsBySimilarLines(nothing, true);
4.49 + assertEquals(0, list.size());
4.50 +
4.51 + list = perUtils.findExceptionsBySimilarLines(justDup1, true);
4.52 + assertEquals(1, list.size());
4.53 + List<Exceptions> all = perUtils.getAll(Exceptions.class);
4.54 +
4.55 + assertTrue(all.size() >= 2);
4.56 + Exceptions latest = all.get(all.size() - 1);
4.57 + latest.setDuplicateof(all.get(all.size() - 2));
4.58 + perUtils.merge(latest);
4.59 +
4.60 + list = perUtils.findExceptionsBySimilarLines(substring, true);
4.61 + assertEquals(2, list.size());
4.62 +
4.63 + list = perUtils.findExceptionsBySimilarLines(substring, false);
4.64 + assertEquals(1, list.size());
4.65 + }
4.66 +
4.67 +}
4.68 +
5.1 --- a/logger/uihandlerserver/web/WEB-INF/struts-config.xml Fri Jan 18 07:40:28 2008 +0000
5.2 +++ b/logger/uihandlerserver/web/WEB-INF/struts-config.xml Fri Jan 18 08:30:17 2008 +0000
5.3 @@ -21,7 +21,7 @@
5.4 </global-forwards>
5.5
5.6 <action-mappings>
5.7 - <action path="/list" type="org.netbeans.modules.exceptions.web.action.ListAction">
5.8 + <action path="/list" type="org.netbeans.web.action.ListAction">
5.9 <forward name="success" path="/exceptions/issueList.jsp"/>
5.10 <forward name="query" path="/exceptions/queryPage.jsp"/>
5.11 <forward name="count" path="/exceptions/count.jsp"/>
6.1 --- a/logger/uihandlerserver/web/exceptions/queryPage.jsp Fri Jan 18 07:40:28 2008 +0000
6.2 +++ b/logger/uihandlerserver/web/exceptions/queryPage.jsp Fri Jan 18 08:30:17 2008 +0000
6.3 @@ -66,6 +66,24 @@
6.4 </tr>
6.5 </table>
6.6 </form>
6.7 + <br/>
6.8 + <h3>Line search</h3>
6.9 + <form method="get" action="list.do" enctype="application/x-www-form-urlencoded">
6.10 + <table>
6.11 + <tr>
6.12 + <th>Searched substring in stacktrace line:</th>
6.13 + <td>
6.14 + <input type="text" name="searchedLine" value="" style="width: 300px"/>
6.15 + </td>
6.16 + </tr>
6.17 + <tr>
6.18 + <td><input type="submit" name="Search" value="Search" /></td>
6.19 + </tr>
6.20 + <tr>
6.21 + <td colspan="3"><input type='checkbox' name='originals' checked='checked'/> Don't search in duplicates</td>
6.22 + </tr>
6.23 + </table>
6.24 + </form>
6.25 <%--
6.26 <table class="axial">
6.27 <tr>