Author: sshafroi
Date: 2008-03-27 14:44:26 +0100 (Thu, 27 Mar 2008)
New Revision: 6282
Removed:
branches/2.16/generic.sesam/result-handler-config/src/main/java/no/sesat/search/result/handler/CombineModifiersResultHandlerConfig.java
branches/2.16/generic.sesam/result-handler-control/src/main/java/no/sesat/search/result/handler/CombineModifiersResultHandler.java
Log:
Depricated classes, functionality ported to the navigation framework.
Deleted:
branches/2.16/generic.sesam/result-handler-config/src/main/java/no/sesat/search/result/handler/CombineModifiersResultHandlerConfig.java
===================================================================
---
branches/2.16/generic.sesam/result-handler-config/src/main/java/no/sesat/search/result/handler/CombineModifiersResultHandlerConfig.java
2008-03-27 13:40:31 UTC (rev 6281)
+++
branches/2.16/generic.sesam/result-handler-config/src/main/java/no/sesat/search/result/handler/CombineModifiersResultHandlerConfig.java
2008-03-27 13:44:26 UTC (rev 6282)
@@ -1,121 +0,0 @@
-/* Copyright (2007) Schibsted Søk AS
- * This file is part of SESAT.
- *
- * SESAT is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * SESAT is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with SESAT. If not, see <http://www.gnu.org/licenses/>.
- */
-package no.sesat.search.result.handler;
-
-import no.sesat.search.result.handler.AbstractResultHandlerConfig.Controller;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Used to combine modifiers into new ones in a new navigator.
- *
- * @author Geir H. Pettersen
- * @version $Id$
- */
[EMAIL PROTECTED]("CombineModifiersResultHandler")
-public class CombineModifiersResultHandlerConfig extends
AbstractResultHandlerConfig {
- private String sourceNavigatorName;
- private String targetNavigatorName;
- private String allModifierName;
- private String defaultModifierName;
- private Map<String, String> modifierMap = new HashMap<String, String>();
-
- public String getSourceNavigatorName() {
- return sourceNavigatorName;
- }
-
- public void setSourceNavigatorName(String sourceNavigatorName) {
- this.sourceNavigatorName = sourceNavigatorName;
- }
-
- public String getTargetNavigatorName() {
- return targetNavigatorName;
- }
-
- public void setTargetNavigatorName(String targetNavigatorName) {
- this.targetNavigatorName = targetNavigatorName;
- }
-
- public String getAllModifierName() {
- return allModifierName;
- }
-
- public void setAllModifierName(String allModifierName) {
- this.allModifierName = allModifierName;
- }
-
- public String getDefaultModifierName() {
- return defaultModifierName;
- }
-
- public void setDefaultModifierName(String defaultModifierName) {
- this.defaultModifierName = defaultModifierName;
- }
-
- public Map<String, String> getModifierMap() {
- return modifierMap;
- }
-
- public void setModifierMap(Map<String, String> modifierMap) {
- this.modifierMap = modifierMap;
- }
-
- @Override
- public AbstractResultHandlerConfig readResultHandler(final Element
element) {
- sourceNavigatorName = element.getAttribute("source-navigator-name");
- targetNavigatorName = element.getAttribute("target-navigator-name");
- String attr = element.getAttribute("all-modifier-name");
- if (attr != null && attr.length() > 0) {
- allModifierName = attr;
- }
- attr = element.getAttribute("default-modifier-name");
- if (attr != null && attr.length() > 0) {
- defaultModifierName = attr;
- }
- List<Element> modifierList = getDirectChildren(element, "modifier");
- for (Element modifierElement : modifierList) {
- final String modifierTargetName =
modifierElement.getAttribute("name");
- List<Element> modifierSourceList =
getDirectChildren(modifierElement, "source");
- for (Element modifierSource : modifierSourceList) {
- final String modifierSourceName =
modifierSource.getAttribute("name");
- modifierMap.put(modifierSourceName, modifierTargetName);
- }
- }
- return this;
- }
-
- private static List<Element> getDirectChildren(final Element element,
final String elementName) {
- final List<Element> children = new ArrayList<Element>();
- if (element != null) {
- final NodeList childNodes = element.getChildNodes();
- for (int i = 0; i < childNodes.getLength(); i++) {
- final Node childNode = childNodes.item(i);
- if (childNode instanceof Element &&
childNode.getNodeName().equals(elementName)) {
- children.add((Element) childNode);
- }
- }
- }
- return children;
- }
-
-}
Deleted:
branches/2.16/generic.sesam/result-handler-control/src/main/java/no/sesat/search/result/handler/CombineModifiersResultHandler.java
===================================================================
---
branches/2.16/generic.sesam/result-handler-control/src/main/java/no/sesat/search/result/handler/CombineModifiersResultHandler.java
2008-03-27 13:40:31 UTC (rev 6281)
+++
branches/2.16/generic.sesam/result-handler-control/src/main/java/no/sesat/search/result/handler/CombineModifiersResultHandler.java
2008-03-27 13:44:26 UTC (rev 6282)
@@ -1,91 +0,0 @@
-/* Copyright (2007) Schibsted Søk AS
- * This file is part of SESAT.
- *
- * SESAT is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * SESAT is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with SESAT. If not, see <http://www.gnu.org/licenses/>.
- */
-package no.sesat.search.result.handler;
-
-import no.sesat.search.datamodel.DataModel;
-import no.sesat.search.result.FastSearchResult;
-import no.sesat.search.result.Modifier;
-import org.apache.log4j.Logger;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Used to combine modifiers into new ones in a new navigator.
- *
- * @author Geir H. Pettersen
- * @version $Id$
- */
-public class CombineModifiersResultHandler implements ResultHandler {
- private static final Logger LOG =
Logger.getLogger(CombineModifiersResultHandler.class);
- private CombineModifiersResultHandlerConfig config;
-
-
- public CombineModifiersResultHandler(ResultHandlerConfig config) {
- this.config = (CombineModifiersResultHandlerConfig) config;
- }
-
- public void handleResult(Context cxt, DataModel datamodel) {
- // Checking parameters
- if (!(cxt.getSearchResult() instanceof FastSearchResult)) {
- LOG.debug(CombineModifiersResultHandler.class.getName() + " can
only be applied to fast search results. Result is " +
cxt.getSearchResult().getClass().getName());
- return;
- }
-
- // Initializing
- final FastSearchResult result = (FastSearchResult)
cxt.getSearchResult();
- final List<Modifier> sourceModifierList =
result.getModifiers(config.getSourceNavigatorName());
- final LinkedHashMap<String, Modifier> targetModifierMap = new
LinkedHashMap<String, Modifier>();
- final Map<String, String> modifierMap = config.getModifierMap();
- Modifier defaultModifier = null;
- if (config.getDefaultModifierName() != null) {
- defaultModifier = new Modifier(config.getDefaultModifierName(), 0,
null);
- }
-
- // The business
- if (sourceModifierList != null && sourceModifierList.size() > 0) {
- for (Modifier sourceModifier : sourceModifierList) {
- final String targetModifierName =
modifierMap.get(sourceModifier.getName());
-// LOG.debug("Combining modifier: " + sourceModifier.getName()
+ "=" + sourceModifier.getCount() + " to " + targetModifierName);
- if (targetModifierName != null) {
- Modifier targetModifier =
targetModifierMap.get(targetModifierName);
- if (targetModifier == null) {
- targetModifier = new Modifier(targetModifierName, 0,
null);
- targetModifierMap.put(targetModifierName,
targetModifier);
- }
- targetModifier.addCount(sourceModifier.getCount());
- } else if (defaultModifier != null) {
- defaultModifier.addCount(sourceModifier.getCount());
- }
- }
-
- // Add the result
- if (config.getAllModifierName() != null) {
- result.addModifier(config.getTargetNavigatorName(), new
Modifier(config.getAllModifierName(), result.getHitCount(), null));
- }
- for (Modifier modifier : targetModifierMap.values()) {
- result.addModifier(config.getTargetNavigatorName(), modifier);
- }
- if (defaultModifier != null) {
- result.addModifier(config.getTargetNavigatorName(),
defaultModifier);
- }
- }
- }
-
-
-}
_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits