Author: ssmiweve
Date: 2009-01-31 23:03:03 +0100 (Sat, 31 Jan 2009)
New Revision: 7194

Modified:
   branches/2.18/generic.sesam/war/src/main/templates/VM_sesat_library.vm
   
branches/2.18/view-control-spi/src/main/java/no/sesat/search/view/navigation/NavigationHelper.java
Log:
>>> don't ask for modifiers that are children to a parent that hasn't been 
>>> selected.
>>> upto 500K saving in the xml result from the result per request
>> there was a lot more work to this as hierarchical Navigators and Modifiers 
>> were not at all handled.
> configure navigators to be hierarchical so to optimise result size. 
> takes advantage of sesat-kernel changes (r7171,7173) quoted above.
SEARCH-5475 - IndexOutOfBoundsException i katalogNavigator.vm

Modified: branches/2.18/generic.sesam/war/src/main/templates/VM_sesat_library.vm
===================================================================
--- branches/2.18/generic.sesam/war/src/main/templates/VM_sesat_library.vm      
2009-01-31 19:14:51 UTC (rev 7193)
+++ branches/2.18/generic.sesam/war/src/main/templates/VM_sesat_library.vm      
2009-01-31 22:03:03 UTC (rev 7194)
@@ -72,7 +72,7 @@
             <<
             #if ($nav.backText != "")
                 $nav.backText
-            #else
+            
#elseif($datamodel.navigation.getNavigation($nav.getParent().getId()).getResults().size()
 > 0)
                 
$datamodel.navigation.getNavigation($nav.getParent().getId()).getResults().get(0).getTitle()
             #end
             </a>

Modified: 
branches/2.18/view-control-spi/src/main/java/no/sesat/search/view/navigation/NavigationHelper.java
===================================================================
--- 
branches/2.18/view-control-spi/src/main/java/no/sesat/search/view/navigation/NavigationHelper.java
  2009-01-31 19:14:51 UTC (rev 7193)
+++ 
branches/2.18/view-control-spi/src/main/java/no/sesat/search/view/navigation/NavigationHelper.java
  2009-01-31 22:03:03 UTC (rev 7194)
@@ -1,4 +1,4 @@
-/* Copyright (2007-2008) Schibsted Søk AS
+/* Copyright (2007-2009) Schibsted Søk AS
  *   This file is part of SESAT.
  *
  *   SESAT is free software: you can redistribute it and/or modify
@@ -38,20 +38,29 @@
 public final class NavigationHelper {
 
     // Constants -----------------------------------------------------
+
+    // Static --------------------------------------------------------
+
     public static String removeQuery(final String url) {
         return url.replaceAll("(&amp;)?q=[^&]*", "");
     }
 
-    /**
-     * @todo move into domain? (NavigationItem & BasicNavigationItem)
+    /** Drill down the navigation hierarchy and find the first Nav that hasn't 
yet been selected.
+     * Any Nav that has autoNavigation and has only one child will be 
automatically selected,
+     *      (as along as the child has a corresponding NavigationItem).
+     * @param dm the datamodel
+     * @param nav the current nav
+     * @return the first non-selected nav inside the current nav given
      */
     public static NavigationConfig.Nav getFirstNotSelected(DataModel dm, 
NavigationConfig.Nav nav) {
 
+        NavigationConfig.Nav result = null;
+
         if (dm.getParameters().getValue(nav.getId()) != null
                 && !nav.getChildNavs().isEmpty()
                 && !nav.getChildNavs().get(0).isVirtual()) {
 
-            return getFirstNotSelected(dm, nav.getChildNavs().get(0));
+            result = getFirstNotSelected(dm, nav.getChildNavs().get(0));
 
         } else {
 
@@ -61,6 +70,8 @@
                     ? 
dm.getNavigation().getNavigation(nav.getId()).getResults().size()
                     : 0;
 
+            if(1 == navResultSize && !nav.getChildNavs().isEmpty() && 
(nav.isAutoNavigation() || isOslo(dm, nav))){
+
 // TODO: Specification is a mess, so this becomes ugly. See history in 
prio-198 & SEARCH-3320.
 // TODO: Haven't found a general way to solve this. Special case for Oslo.
 // TODO: New JIRA created to resolve this: SEARCH-3451
@@ -69,10 +80,15 @@
 //                    : nav;
 
 
-            return 1 == navResultSize && !nav.getChildNavs().isEmpty() && 
(nav.isAutoNavigation() || isOslo(dm, nav))
-                    ? getFirstNotSelected(dm, nav.getChildNavs().get(0))
-                    : nav;
+                // don't go automatically selecting any navigator we haven't 
built a NavigationItem for
+                final NavigationItem childNavItem = 
dm.getNavigation().getNavigation(nav.getChildNavs().get(0).getId());
+                if(null != childNavItem && 0 < 
childNavItem.getResults().size()){
+
+                    result = getFirstNotSelected(dm, 
nav.getChildNavs().get(0));
+                }
+            }
         }
+        return null != result ? result : nav;
     }
 
     public static NavigationItem getSingleNavigationItem(DataModel dm, final 
String navId, final String value) {
@@ -91,10 +107,17 @@
         }
     }
 
-    public String getResetUrl(final DataModel dm, final String navId) {
+    public static String getResetUrl(final DataModel dm, final String navId) {
         return dm.getNavigation().getNavigation("reset_" + navId).getUrl();
     }
 
+    // Constructors --------------------------------------------------
+
+    /** Velocity templates need an instance to put into the context just to 
call the static methods. **/
+    public NavigationHelper(){}
+
+    // Private -------------------------------------------------------
+
     /** Checks if navigation is "oslo".
      *
      * @deprecated {...@link http://sesat.no/scarab/issues/id/SKER5009} A 
general solution is required here

_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits

Reply via email to