Scarab commit: svn commit: r10990 - trunk/src/java/org/tigris/scarab/actions/QueryList.java

[email protected] Fri, 16 Apr 2010 11:23:53 -0700 (PDT)
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: dabbous
Date: 2010-04-16 11:23:53-0700
New Revision: 10990

Modified:
   trunk/src/java/org/tigris/scarab/actions/QueryList.java

Log:
SCB3036: Modified the Start_Page definition as follows:

If a user configures a personal query as start page, that query will be marked as such. If a public query exists for the same module, it will NOT be touched. Consequently now everybody who has npot configured a start page for the module, will get the public query. Everybody else will get his/her configured private query.

If a user (admin) configures a public query as start page, that query will be marked as such. Consequently now everybody who has not configured a start page for the module, will get the just configured public query. Everybody else will keep with his/her configured private query.

CAVEAT: public queries can not be customized for individual users. So whenever a user customizes a public query as start page, this customization will be taken as the new default settings for the module. It is not planned to change this behaviour as it is consistent with the idea of public/private queries.

Modified: trunk/src/java/org/tigris/scarab/actions/QueryList.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/actions/QueryList.java?view=diff&pathrev=10990&r1=10989&r2=10990
==============================================================================
--- trunk/src/java/org/tigris/scarab/actions/QueryList.java	(original)
+++ trunk/src/java/org/tigris/scarab/actions/QueryList.java	2010-04-16 11:23:53-0700
@@ -210,16 +210,31 @@
         ParameterParser pp = data.getParameters();   
         String queryId = pp.get("startpage");
         
-        List<Query> globalQueries  = getScarabRequestTool(context).getGlobalQueries();
         List<Query> privateQueries = getScarabRequestTool(context).getUserAllQueries();
         Query newStartQuery = QueryManager.getInstance(new NumberKey(queryId), false);
         
-        setStartpage(globalQueries, newStartQuery);
-        setStartpage(privateQueries, newStartQuery);       
+        boolean addedAsStartQuery;
+        
+        addedAsStartQuery = setStartpage(privateQueries, newStartQuery);       
+        if(addedAsStartQuery)
+        {
+            // We just have added a private query as startPage.
+            // We will not deal with the public queries.
+            // Consequently we can have more than one startQuery per module.
+        }
+        else
+        {
+            // Since we have not marked a personal query as start page we probably
+            // are dealing with a public query, hence we must process the public query list
+            // too.
+            List<Query> globalQueries  = getScarabRequestTool(context).getGlobalQueries();
+            setStartpage(globalQueries, newStartQuery);
+        }
     }
     
-    private void setStartpage(List<Query> queries, Query newStartQuery) throws TorqueException
+    private boolean setStartpage(List<Query> queries, Query newStartQuery) throws TorqueException
     {
+        boolean addedAsStartQuery = false;
         Iterator<Query> iter = queries.iterator();
         while(iter.hasNext())
         {
@@ -227,6 +242,7 @@
             if (query.getQueryId().equals(newStartQuery.getQueryId()))
             {
                 query.setHomePage(true);
+                addedAsStartQuery=true;
             }
             else
             {
@@ -234,5 +250,6 @@
             }
             query.save();
         }
+        return addedAsStartQuery;
     }
 }

------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2585612