Author: gttersen
Date: 2007-03-14 17:44:57 +0100 (Wed, 14 Mar 2007)
New Revision: 4577

Modified:
   trunk/core-api/pom.xml
   
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/NewsAggregatorSearchCommand.java
   
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/config/NewsAggregatorSearchConfiguration.java
Log:
Uppdate for nyheter.sesam.no

Modified: trunk/core-api/pom.xml
===================================================================
--- trunk/core-api/pom.xml      2007-03-14 12:54:14 UTC (rev 4576)
+++ trunk/core-api/pom.xml      2007-03-14 16:44:57 UTC (rev 4577)
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
     <modelVersion>4.0.0</modelVersion>
-      <parent>
-          <groupId>schibstedsok</groupId>
-          <artifactId>search-portal</artifactId>
-          <version>2.10-SNAPSHOT</version>
-      </parent>
+    <parent>
+        <groupId>schibstedsok</groupId>
+        <artifactId>search-portal</artifactId>
+        <version>2.10-SNAPSHOT</version>
+    </parent>
     <artifactId>search-portal-core-api</artifactId>
     <packaging>jar</packaging>
     <name>Sesam Search Engine Core API</name>
@@ -20,7 +21,7 @@
     </scm>
 
     <build>
-       <testResources>
+        <testResources>
             <testResource>
                 <filtering>true</filtering>
                 <directory>src/test/resources</directory>
@@ -31,16 +32,16 @@
         </testResources>
         <plugins>
             <plugin>
-               <groupId>org.apache.maven.plugins</groupId>
-               <artifactId>maven-jar-plugin</artifactId>
-               <executions>
-                 <execution>
-                   <goals>
-                     <goal>test-jar</goal>
-                   </goals>
-                 </execution>
-               </executions>
-             </plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>axistools-maven-plugin</artifactId>
@@ -128,7 +129,7 @@
             <groupId>axis</groupId>
             <artifactId>axis-jaxrpc</artifactId>
         </dependency>
-        <dependency>
+        <dependency>
             <groupId>axis</groupId>
             <artifactId>axis-saaj</artifactId>
         </dependency>
@@ -157,47 +158,47 @@
             <artifactId>jep</artifactId>
         </dependency>
 
-      <!--dependency>
-        <groupId>org.jboss</groupId>
-        <artifactId>jbossall-client</artifactId>
-        <type>jar</type>
-        <version>4.0.5</version>
-      </dependency>
-      
-      <dependency>
-        <groupId>org.jboss</groupId>
-        <artifactId>jboss-ejb3-client</artifactId>
-        <type>jar</type>
-        <version>RC9</version>
-      </dependency>
-      
-      <dependency>
-        <groupId>org.jboss</groupId>
-        <artifactId>jboss-aspect-jdk50-client</artifactId>
-        <type>jar</type>
-        <version>4.0.5</version>
-      </dependency>
-      
-      <dependency>
-        <groupId>org.jboss</groupId>
-        <artifactId>jboss-aop-jdk50-client</artifactId>
-        <type>jar</type>
-        <version>4.0.5</version>
-      </dependency-->       
-      
-      <dependency>
-        <groupId>no.schibstedsok.alfa</groupId>
-        <artifactId>alfa-remote</artifactId>
-        <type>ejb-client</type>
-        <version>1.0-SNAPSHOT</version>
-      </dependency>     
-      
-      <dependency>
-        <groupId>schibstedsok</groupId>
-        <artifactId>search-portal-user-service</artifactId>
-        <type>ejb-client</type>
-      </dependency>  
+        <dependency>
+            <groupId>org.jboss</groupId>
+            <artifactId>jbossall-client</artifactId>
+            <type>jar</type>
+            <version>4.0.5</version>
+        </dependency>
 
+        <dependency>
+            <groupId>org.jboss</groupId>
+            <artifactId>jboss-ejb3-client</artifactId>
+            <type>jar</type>
+            <version>RC9</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.jboss</groupId>
+            <artifactId>jboss-aspect-jdk50-client</artifactId>
+            <type>jar</type>
+            <version>4.0.5</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.jboss</groupId>
+            <artifactId>jboss-aop-jdk50-client</artifactId>
+            <type>jar</type>
+            <version>4.0.5</version>
+        </dependency>
+
+        <dependency>
+            <groupId>no.schibstedsok.alfa</groupId>
+            <artifactId>alfa-remote</artifactId>
+            <type>ejb-client</type>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>schibstedsok</groupId>
+            <artifactId>search-portal-user-service</artifactId>
+            <type>ejb-client</type>
+        </dependency>
+
         <!-- Testin -->
         <dependency>
             <groupId>schibstedsok</groupId>

Modified: 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/NewsAggregatorSearchCommand.java
===================================================================
--- 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/NewsAggregatorSearchCommand.java
     2007-03-14 12:54:14 UTC (rev 4576)
+++ 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/NewsAggregatorSearchCommand.java
     2007-03-14 16:44:57 UTC (rev 4577)
@@ -9,6 +9,9 @@
 import no.schibstedsok.searchportal.result.NewsAggregatorSearchResult;
 import no.schibstedsok.searchportal.result.SearchResult;
 import no.schibstedsok.searchportal.result.SearchResultItem;
+import no.schibstedsok.searchportal.result.FastSearchResult;
+import no.schibstedsok.searchportal.result.Modifier;
+import no.schibstedsok.searchportal.result.Navigator;
 import org.apache.log4j.Logger;
 import org.jdom.Document;
 import org.jdom.Element;
@@ -24,7 +27,7 @@
 import java.util.List;
 
 
-public class NewsAggregatorSearchCommand extends AbstractSearchCommand {
+public class NewsAggregatorSearchCommand extends AbstractESPFastSearchCommand {
 
     private final static Logger LOG = 
Logger.getLogger(NewsAggregatorSearchCommand.class);
 
@@ -37,49 +40,58 @@
     }
 
     public SearchResult execute() {
-        try {
-            LOG.debug("News aggregator search executed with: " + 
getParameters());
-            LOG.debug("News aggregator search executed with: " + 
datamodel.getParameters());
+        LOG.debug("News aggregator search executed with: " + getParameters());
+        LOG.debug("News aggregator search executed with: " + 
datamodel.getParameters());
 
-            NewsAggregatorSearchConfiguration config = 
(NewsAggregatorSearchConfiguration) getSearchConfiguration();
-            LOG.debug("Loading xml file at: " + config.getXmlSource());
-            LOG.debug("Update interval: " + config.getUpdateIntervalMinutes());
+        NewsAggregatorSearchConfiguration config = 
(NewsAggregatorSearchConfiguration) getSearchConfiguration();
+        LOG.debug("Loading xml file at: " + config.getXmlSource());
+        LOG.debug("Update interval: " + config.getUpdateIntervalMinutes());
 
-            StringDataObject geoNav = 
datamodel.getParameters().getValue("geonav");
-            StringDataObject clusterId = 
datamodel.getParameters().getValue("clusterId");
+        StringDataObject geoNav = datamodel.getParameters().getValue("geonav");
+        StringDataObject clusterId = 
datamodel.getParameters().getValue("clusterId");
 
-            String xmlFile = geoNav == null ? config.getXmlMainFile() : 
geoNav.getString();
+        String xmlFile = geoNav == null ? config.getXmlMainFile() : 
geoNav.getString();
 
-            if (clusterId == null) {
-                return getPageResult(config, xmlFile);
-            } else {
-                return getClusterResult(config, clusterId, xmlFile);
-            }
+        if (clusterId == null) {
+            return getPageResult(config, xmlFile);
+        } else {
+            return getClusterResult(config, clusterId, xmlFile);
+        }
+    }
+
+    private SearchResult getClusterResult(NewsAggregatorSearchConfiguration 
config, StringDataObject clusterId, String xmlFile) {
+        try {
+            final NewsAggregatorXmlParser newsAggregatorXmlParser = new 
NewsAggregatorXmlParser();
+            final InputStream inputStream = getInputStream(config, xmlFile);
+            return newsAggregatorXmlParser.parseCluster(config, inputStream, 
clusterId.getString(), this);
+        } catch (IOException e) {
+            LOG.debug("Falling back to search instead of xml parse", e);
         } catch (JDOMException e) {
-            // todo: Handle error in a defined way
-            BasicSearchResult errorResult = new BasicSearchResult(this);
-            BasicSearchResultItem resultItem = new BasicSearchResultItem();
-            resultItem.addField("error", "Cold not parse clusters");
-            errorResult.addResult(resultItem);
-            return errorResult;
-        } catch (IOException e) {
-            // todo: Handle error in a defined way
-            BasicSearchResult errorResult = new BasicSearchResult(this);
-            BasicSearchResultItem resultItem = new BasicSearchResultItem();
-            resultItem.addField("error", "Cold not find clusters");
-            errorResult.addResult(resultItem);
-            return errorResult;
+            LOG.debug("Falling back to search instead of xml parse", e);
         }
+        return search(config, clusterId.getString());
     }
 
-    private SearchResult getClusterResult(NewsAggregatorSearchConfiguration 
config, StringDataObject clusterId, String xmlFile) throws IOException, 
JDOMException {
-        NewsAggregatorXmlParser newsAggregatorXmlParser = new 
NewsAggregatorXmlParser();
-        return newsAggregatorXmlParser.parseCluster(config, 
getInputStream(config, xmlFile), clusterId.getString(), this);
+    private SearchResult search(NewsAggregatorSearchConfiguration config, 
String clusterId) {
+        LOG.debug("------ Running search to get clusters ---------");
+        LOG.debug("clusterId=" + clusterId);
+        LOG.debug("result-fields=" + config.getResultFields());
+        LOG.debug("query-server=" + config.getQueryServer());
+        LOG.debug("-----------------------------------------------");
+        return null;  //To change body of created methods use File | Settings 
| File Templates.
     }
 
-    private SearchResult getPageResult(NewsAggregatorSearchConfiguration 
config, String xmlFile) throws JDOMException, IOException {
-        NewsAggregatorXmlParser newsAggregatorXmlParser = new 
NewsAggregatorXmlParser();
-        return newsAggregatorXmlParser.parseFullPage(config, 
getInputStream(config, xmlFile), this);
+
+    private SearchResult getPageResult(NewsAggregatorSearchConfiguration 
config, String xmlFile) {
+        final NewsAggregatorXmlParser newsAggregatorXmlParser = new 
NewsAggregatorXmlParser();
+        try {
+            return newsAggregatorXmlParser.parseFullPage(config, 
getInputStream(config, xmlFile), this);
+        } catch (JDOMException e) {
+            LOG.debug("Falling back to search instead of xml parse", e);
+        } catch (IOException e) {
+            LOG.debug("Falling back to search instead of xml parse", e);
+        }
+        return search(config, null);
     }
 
     private InputStream getInputStream(NewsAggregatorSearchConfiguration 
config, String xmlFile) throws IOException {
@@ -119,7 +131,7 @@
 
         public SearchResult parseCluster(NewsAggregatorSearchConfiguration 
config, InputStream inputStream, String clusterId, NewsAggregatorSearchCommand 
searchCommand) throws JDOMException, IOException {
             try {
-                final NewsAggregatorSearchResult searchResult = new 
NewsAggregatorSearchResult(searchCommand);
+                final FastSearchResult searchResult = new 
FastSearchResult(searchCommand);
                 final Document doc = getDocument(inputStream);
                 final Element root = doc.getRootElement();
                 List<Element> clusters = root.getChildren(ELEMENT_CLUSTER);
@@ -145,7 +157,8 @@
 
         public SearchResult parseFullPage(NewsAggregatorSearchConfiguration 
config, InputStream inputStream, SearchCommand searchCommand) throws 
JDOMException, IOException {
             try {
-                final NewsAggregatorSearchResult searchResult = new 
NewsAggregatorSearchResult(searchCommand);
+
+                final FastSearchResult searchResult = new 
FastSearchResult(searchCommand);
                 final Document doc = getDocument(inputStream);
                 final Element root = doc.getRootElement();
 
@@ -164,32 +177,29 @@
             }
         }
 
-        private void handleGeoNav(Element geonavElement, 
NewsAggregatorSearchResult searchResult) {
+        private void handleGeoNav(Element geonavElement, FastSearchResult 
searchResult) {
             final List<Element> geoNavElements = geonavElement.getChildren();
             for (Element geoNavElement : geoNavElements) {
                 String navigationType = 
geoNavElement.getAttributeValue(ATTRIBUTE_TYPE);
-                NewsAggregatorSearchResult.Navigation navigation = new 
NewsAggregatorSearchResult.Navigation(
-                        navigationType,
-                        geoNavElement.getAttributeValue(ATTRIBUTE_NAME),
-                        geoNavElement.getAttributeValue(ATTRIBUTE_XML));
-                searchResult.addNavigation(navigationType, navigation);
+                Navigator nav = new 
Navigator(geoNavElement.getAttributeValue(ATTRIBUTE_XML), null, 
geoNavElement.getAttributeValue(ATTRIBUTE_NAME), null);
+                Modifier modifier = new 
Modifier(geoNavElement.getAttributeValue(ATTRIBUTE_NAME), -1, nav);
+                searchResult.addModifier(navigationType, modifier);
             }
         }
 
-        private void handleRelated(NewsAggregatorSearchConfiguration config, 
Element relatedElement, NewsAggregatorSearchResult searchResult) {
+        private void handleRelated(NewsAggregatorSearchConfiguration config, 
Element relatedElement, FastSearchResult searchResult) {
             final List<Element> categoryElements = 
relatedElement.getChildren(ELEMENT_CATEGORY);
             for (Element categoryElement : categoryElements) {
                 final String categoryType = 
categoryElement.getAttributeValue(ATTRIBUTE_TYPE);
 
-                final SearchResult relatedResult = 
searchResult.getRelatedResult(categoryType);
+                final List<Modifier> relatedList = 
searchResult.getModifiers(categoryType);
                 int categoryCount = 0;
-                if (relatedResult != null) {
-                    categoryCount = relatedResult.getResults().size();
+                if (relatedList != null) {
+                    categoryCount = relatedList.size();
                 }
                 if (categoryCount < config.getRelatedMaxCount()) {
-                    final SearchResultItem searchResultItem = new 
BasicSearchResultItem();
-                    searchResultItem.addField(ATTRIBUTE_NAME, 
categoryElement.getTextTrim());
-                    searchResult.addRelatedResultItem(categoryType, 
searchResultItem);
+                    final Modifier modifier = new 
Modifier(categoryElement.getTextTrim(), -1, null);
+                    searchResult.addModifier(categoryType, modifier);
                 }
             }
         }

Modified: 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/config/NewsAggregatorSearchConfiguration.java
===================================================================
--- 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/config/NewsAggregatorSearchConfiguration.java
        2007-03-14 12:54:14 UTC (rev 4576)
+++ 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/config/NewsAggregatorSearchConfiguration.java
        2007-03-14 16:44:57 UTC (rev 4577)
@@ -3,10 +3,7 @@
 
 import org.apache.log4j.Logger;
 
-import java.util.Set;
-import java.util.Collections;
-
-public class NewsAggregatorSearchConfiguration extends 
AbstractSearchConfiguration {
+public class NewsAggregatorSearchConfiguration extends 
ESPFastSearchConfiguration {
     private final static Logger log = 
Logger.getLogger(NewsAggregatorSearchConfiguration.class);
 
     private String xmlSource;

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

Reply via email to