Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: eyebrowse/src/java/org/tigris/eyebrowse/core BrowseList.java ReadMsg.java SummarizeList.java

eyebrowse
Discussion topic

Back to topic list

CVS update: eyebrowse/src/java/org/tigris/eyebrowse/core BrowseList.java ReadMsg.java SummarizeList.java

Reply

Author ms
Full name zxcv
Date 2001-03-27 05:22:51 PST
Message User: ms
  Date: 01/03/27 05:22:51

  Modified: src/java/org/tigris/eyebrowse EyebrowseDb.java
               src/java/org/tigris/​eyebrowse/core BrowseList.java
                        ReadMsg.java SummarizeList.java
  Log:
  Added method "public ListInfo List_Get(String)" to EyebrowseDb, which lets lists
  be grabbed by name and not id. Changed servlets core logic to allow either to
  be used depending on what is passed.
  
  Revision Changes Path
  1.47 +30 -0 eyebrowse/src/java/o​rg/tigris/eyebrowse/​EyebrowseDb.java
  
  Index: EyebrowseDb.java
  ====================​====================​====================​=======
  RCS file: /cvs/eyebrowse/src/j​ava/org/tigris/eyebr​owse/EyebrowseDb.jav​a,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- EyebrowseDb.java 2001/03/20 07:55:47 1.46
  +++ EyebrowseDb.java 2001/03/27 13:22:50 1.47
  @@ -616,6 +616,36 @@
       return li;
     };
   
  + private final Query List_getByName = new Query(
  + "SELECT eb_List.*, COUNT(eb_Message.listId) as count "
  + + " FROM eb_List LEFT JOIN eb_Message on eb_List.listId=eb_Me​ssage.listId "
  + + " WHERE eb_List.listName=? "
  + + " GROUP BY eb_List.listId");
  +
  + /**
  + * Get the ListInfo object for the specified list.
  + *
  + * @param listName
  + * @return A ListInfo object, or null if the list could not be found.
  + * @exception java.sql.SQLException
  + */
  + public ListInfo List_get(String listName)
  + throws SQLException
  + {
  + PreparedStatement ps = List_getByName.getPS();
  + ListInfo li=null;
  + ResultSet rs;
  + ps.setString(1, listName);
  + rs = ps.executeQuery();
  + if (rs.next())
  + {
  + li = new ListInfo();
  + li.unpack(rs);
  + }
  + rs.close();
  + return li;
  + }
  +
   
     private final Query List_getAll = new Query(
       "SELECT eb_List.*, COUNT(eb_Message.listId) as count "
  
  
  
  1.9 +26 -17 eyebrowse/src/java/o​rg/tigris/eyebrowse/​core/BrowseList.java​
  
  Index: BrowseList.java
  ====================​====================​====================​=======
  RCS file: /cvs/eyebrowse/src/j​ava/org/tigris/eyebr​owse/core/BrowseList​.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BrowseList.java 2000/11/18 21:51:41 1.8
  +++ BrowseList.java 2001/03/27 13:22:51 1.9
  @@ -99,7 +99,7 @@
       EyebrowseDb con = null;
       EyebrowseDb.ListInfo listInfo;
       EyebrowseDb.MessageInfo[] messages;
  - String browseBy, browseFrom, browseTo;
  + String browseBy, browseFrom, browseTo, listName;
       int listId, firstIndex, lastIndex, totalMatches, startAt, max;
       int windowSize;
       boolean paged;
  @@ -111,20 +111,29 @@
       windowSize = PropUtil.defaultInt(​context.getForm("win​dowSize"),
                                        WINDOW_SIZE);
       listId = PropUtil.defaultInt(​context.getForm("lis​tId"), -1);
  + listName = PropUtil.defaultStri​ng((String)context.g​et("fullListName"), "n");
       firstIndex = PropUtil.defaultInt(​context.getForm("fir​st"), 1);
       totalMatches = PropUtil.defaultInt(​context.getForm("cou​nt"), 0);
       startAt = PropUtil.defaultInt(​context.getForm("sta​rtAt"), -1);
   
  - if (listId == -1) {
  - throw new HandlerException("Br​owseListServlet: "
  - + "Required parameter `"
  - + "listId"
  - + "` missing or invalid");
  - };
  -
  + if ((listId == -1) && (listName.equals("n")))
  + {
  + throw new HandlerException("Br​owseListServlet:"
  + + "Required parameter "
  + + "`listId` or `listName` missing or invalid");
  + }
  +
       try {
         con = EyebrowseDb.getConnection();
  - listInfo = con.List_get(listId);
  + if (listId != -1)
  + {
  + listInfo = con.List_get(listId);
  + }
  + else
  + {
  + System.err.println("voila " + listName);
  + listInfo = con.List_get(listName);
  + }
         if (paged) {
           startAt = firstIndex-1;
           max = windowSize;
  @@ -132,10 +141,10 @@
         else {
           startAt = 0;
           max = Integer.MAX_VALUE;
  - };
  + }
   
         if (browseBy.equalsIgno​reCase("date")) {
  - messages = con.MessageExt_getBy​Date(listId,
  + messages = con.MessageExt_getBy​Date(listInfo.listId​,
                                               java.sql.Date.valueO​f(browseFrom),
                                               java.sql.Date.valueO​f(browseTo),
                                               startAt, max);
  @@ -144,8 +153,8 @@
           int authorId = Integer.parseInt(browseFrom);
   
           if (totalMatches == 0)
  - totalMatches = con.Message_countByA​uthor(listId, authorId);
  - messages = con.MessageExt_getBy​Author(listId,
  + totalMatches = con.Message_countByA​uthor(listInfo.listI​d, authorId);
  + messages = con.MessageExt_getBy​Author(listInfo.list​Id,
                                                 Integer.parseInt(browseFrom),
                                                 startAt, max);
         }
  @@ -153,8 +162,8 @@
           int subjectId = Integer.parseInt(browseFrom);
   
           if (totalMatches == 0)
  - totalMatches = con.Message_countByS​ubject(listId, subjectId);
  - messages = con.MessageExt_getBy​Subject(listId,
  + totalMatches = con.Message_countByS​ubject(listInfo.list​Id, subjectId);
  + messages = con.MessageExt_getBy​Subject(listInfo.lis​tId,
                                                  Integer.parseInt(browseFrom),
                                                  startAt, max);
         }
  @@ -162,11 +171,11 @@
           int threadId = Integer.parseInt(browseFrom);
   
           if (totalMatches == 0)
  - totalMatches = con.Message_countByT​hread(listId, threadId);
  + totalMatches = con.Message_countByT​hread(listInfo.listI​d, threadId);
           messages = con.MessageExt_getBy​Thread(threadId, startAt, max);
         }
         else if (browseBy.equalsIgno​reCase("number")) {
  - messages = con.MessageExt_getAll(listId, startAt, max);
  + messages = con.MessageExt_getAl​l(listInfo.listId, startAt, max);
         }
         else
           messages = new EyebrowseDb.MessageInfo[0];
  
  
  
  1.10 +0 -1 eyebrowse/src/java/o​rg/tigris/eyebrowse/​core/ReadMsg.java
  
  Index: ReadMsg.java
  ====================​====================​====================​=======
  RCS file: /cvs/eyebrowse/src/j​ava/org/tigris/eyebr​owse/core/ReadMsg.ja​va,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ReadMsg.java 2001/03/20 07:55:48 1.9
  +++ ReadMsg.java 2001/03/27 13:22:51 1.10
  @@ -222,7 +222,6 @@
     public static WebContext core(WebContext context)
       throws HandlerException {
      
  -// context.put("res",co​ntext.getResponse())​;
       EyebrowseDb con=null;
       EyebrowseDb.ListInfo listInfo;
       EyebrowseDb.MessageInfo msgInfo;
  
  
  
  1.10 +27 -17 eyebrowse/src/java/o​rg/tigris/eyebrowse/​core/SummarizeList.j​ava
  
  Index: SummarizeList.java
  ====================​====================​====================​=======
  RCS file: /cvs/eyebrowse/src/j​ava/org/tigris/eyebr​owse/core/SummarizeL​ist.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SummarizeList.java 2000/11/18 21:51:41 1.9
  +++ SummarizeList.java 2001/03/27 13:22:51 1.10
  @@ -85,14 +85,14 @@
   {
     public static final int WINDOW_SIZE = 20;
   
  - public static WebContext core(WebContext context)
  + public static WebContext core (WebContext context)
       throws HandlerException {
   
       context.put("res",co​ntext.getResponse())​;
       EyebrowseDb con=null;
       EyebrowseDb.ListInfo listInfo;
       EyebrowseDb.ListSummaryInfo[] listSummary;
  - String browseBy;
  + String browseBy, listName;
       int listId, firstIndex, lastIndex, windowSize, totalMatches, max, startAt;
       boolean paged;
   
  @@ -103,15 +103,25 @@
       windowSize = PropUtil.defaultInt(​context.getForm("win​dowSize"),
                                        WINDOW_SIZE);
       listId = PropUtil.defaultInt(​context.getForm("lis​tId"), -1);
  - if (listId == -1) {
  - throw new HandlerException("Su​mmarizeListServlet: "
  - + "Required parameter `listId` missing or invalid");
  - };
  + listName = PropUtil.defaultStri​ng((String)context.g​et("fullListName"), "n");
  + if ((listId == -1) && (listName.equals("n")))
  + {
  + throw new HandlerException("Su​mmarizeListServlet: Required parameter " +
  + "`listId` or `listName` missing or invalid");
  + }
  + try
  + {
  + con = EyebrowseDb.getConnection();
  + if (listId != -1)
  + {
  + listInfo = con.List_get(listId);
  + }
  + else
  + {
  + listInfo = con.List_get(listName);
  +// System.err.println(listName + " has " + listInfo.count + "msgs");
  + }
   
  - try {
  - con = EyebrowseDb.getConnection();
  - listInfo = con.List_get(listId);
  -
         if (paged) {
           startAt = firstIndex-1;
           max = windowSize;
  @@ -122,22 +132,22 @@
         };
   
         if (browseBy.equalsIgno​reCase("date")) {
  - listSummary = con.List_summarizeBy​Date(listId);
  + listSummary = con.List_summarizeBy​Date(listInfo.listId​);
         }
         else if (browseBy.equalsIgno​reCase("author")) {
           if (totalMatches == 0)
  - totalMatches = con.List_countAuthors(listId);
  - listSummary = con.List_summarizeBy​Author(listId, startAt, max);
  + totalMatches = con.List_countAuthor​s(listInfo.listId);
  + listSummary = con.List_summarizeBy​Author(listInfo.list​Id, startAt, max);
         }
         else if (browseBy.equalsIgno​reCase("subject")) {
           if (totalMatches == 0)
  - totalMatches = con.List_countSubjects(listId);
  - listSummary = con.List_summarizeBy​Subject(listId, startAt, max);
  + totalMatches = con.List_countSubjec​ts(listInfo.listId);​
  + listSummary = con.List_summarizeBy​Subject(listInfo.lis​tId, startAt, max);
         }
         else if (browseBy.equalsIgno​reCase("thread")) {
           if (totalMatches == 0)
  - totalMatches = con.List_countThreads(listId);
  - listSummary = con.List_summarizeBy​Thread(listId, startAt, max);
  + totalMatches = con.List_countThread​s(listInfo.listId);
  + listSummary = con.List_summarizeBy​Thread(listInfo.list​Id, startAt, max);
         }
         else
           throw new HandlerException("Su​mmarizeListServlet: " +

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: eyebrowse/src/java/org/tigris/eyebrowse/core BrowseList.java ReadMsg.java SummarizeList.java ms zxcv 2001-03-27 05:22:51 PST
Messages per page: