Author: gttersen
Date: 2007-06-13 18:22:19 +0200 (Wed, 13 Jun 2007)
New Revision: 5321
Modified:
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/NavigationCommand.java
trunk/search-command-config-spi/src/main/java/no/schibstedsok/searchportal/mode/config/NavigationCommandConfig.java
Log:
Option now supports to use a searchCommand as a "navigator"
Modified:
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/NavigationCommand.java
===================================================================
---
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/NavigationCommand.java
2007-06-13 15:25:07 UTC (rev 5320)
+++
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/NavigationCommand.java
2007-06-13 16:22:19 UTC (rev 5321)
@@ -175,7 +175,7 @@
final NavigationCommandConfig.Nav navEntry,
final FastSearchResult fsr,
final NavigationItem extendedNavigators,
- StringDataObject selectedValue) {
+ StringDataObject selectedValue) throws InterruptedException {
// Only used by getNavigators. Mainly to split code.
if (extendedNavigators.getResults().size() > 0 &&
navEntry.getOptions().size() > 0) {
@@ -221,10 +221,9 @@
value = tmp;
}
}
+ NavigationItem navigator = null;
if (value != null) {
- final NavigationItem navigator
- = new
BasicNavigationItem(option.getDisplayName(), getUrlFragment(navEntry, value),
-1);
-
+ navigator = new
BasicNavigationItem(option.getDisplayName(), getUrlFragment(navEntry, value),
-1);
extendedNavigators.addResult(navigator);
if (optionSelectedValue == null &&
option.isDefaultSelect()) {
navigator.setSelected(true);
@@ -232,6 +231,14 @@
navigator.setSelected(true);
}
}
+ if (navigator != null && option.isUseHitCount()) {
+ if (option.getCommandName() != null) {
+ LOG.debug("Waiting for searchCommand: " +
option.getCommandName());
+
navigator.setHitCount(getSearchResult(option.getCommandName(),
context.getDataModel()).getHitCount());
+ } else {
+ LOG.error("Can not set hitCount. Option: " +
option + " is set to use hitCount, but commandName not set. ");
+ }
+ }
}
}
}
Modified:
trunk/search-command-config-spi/src/main/java/no/schibstedsok/searchportal/mode/config/NavigationCommandConfig.java
===================================================================
---
trunk/search-command-config-spi/src/main/java/no/schibstedsok/searchportal/mode/config/NavigationCommandConfig.java
2007-06-13 15:25:07 UTC (rev 5320)
+++
trunk/search-command-config-spi/src/main/java/no/schibstedsok/searchportal/mode/config/NavigationCommandConfig.java
2007-06-13 16:22:19 UTC (rev 5321)
@@ -310,7 +310,7 @@
final List<Element> optionElements = getDirectChildren(navElement,
OPTION_ELEMENT);
options = new ArrayList<Option>(optionElements.size());
for (Element optionElement : optionElements) {
- options.add(new Option(optionElement));
+ options.add(new Option(optionElement, this));
}
final List<Element> staticParamElements =
getDirectChildren(navElement, STATIC_PARAMETER_ELEMENT);
staticParameters = new HashMap<String, String>();
@@ -429,18 +429,38 @@
private String valueRef;
private boolean realNavigator;
private boolean defaultSelect;
+ private boolean useHitCount;
+ private String commandName;
public Option() {
}
- private Option(Element optionElement) {
+ private Option(Element optionElement, Nav parentrNav) {
AbstractDocumentFactory.fillBeanProperty(this, null, "value",
ParseType.String, optionElement, null);
AbstractDocumentFactory.fillBeanProperty(this, null,
"displayName", ParseType.String, optionElement, null);
AbstractDocumentFactory.fillBeanProperty(this, null, "valueRef",
ParseType.String, optionElement, null);
AbstractDocumentFactory.fillBeanProperty(this, null,
"realNavigator", ParseType.Boolean, optionElement, "false");
AbstractDocumentFactory.fillBeanProperty(this, null,
"defaultSelect", ParseType.Boolean, optionElement, "false");
+ AbstractDocumentFactory.fillBeanProperty(this, null,
"useHitCount", ParseType.Boolean, optionElement, "false");
+ AbstractDocumentFactory.fillBeanProperty(this, null,
"commandName", ParseType.String, optionElement, parentrNav.getCommandName());
}
+ public boolean isUseHitCount() {
+ return useHitCount;
+ }
+
+ public void setUseHitCount(boolean useHitCount) {
+ this.useHitCount = useHitCount;
+ }
+
+ public String getCommandName() {
+ return commandName;
+ }
+
+ public void setCommandName(String commandName) {
+ this.commandName = commandName;
+ }
+
public boolean isDefaultSelect() {
return defaultSelect;
}
_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits