Author: daniele
Date: 2007-01-15 17:38:37 +0100 (Mon, 15 Jan 2007)
New Revision: 4328

Added:
   
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/handler/CatalogueResultHandler.java
   
trunk/query-transform-spi/src/main/java/no/schibstedsok/searchportal/query/transform/CatalogueInfopageQueryTransformer.java
   trunk/war/src/webapp/META-INF/
   trunk/war/src/webapp/META-INF/context.xml
Modified:
   
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/SearchModeFactory.java
   
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueSearchCommand.java
   trunk/war/pom.xml
   trunk/war/src/webapp/WEB-INF/web.xml
Log:
New search functionality for Catalogue-site.

Modified: 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/SearchModeFactory.java
===================================================================
--- 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/SearchModeFactory.java
       2007-01-15 14:05:00 UTC (rev 4327)
+++ 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/SearchModeFactory.java
       2007-01-15 16:38:37 UTC (rev 4328)
@@ -41,9 +41,11 @@
 import no.schibstedsok.searchportal.mode.executor.SearchCommandExecutor;
 import 
no.schibstedsok.searchportal.mode.executor.SequentialSearchCommandExecutor;
 import no.schibstedsok.searchportal.query.transform.QueryTransformer;
+import 
no.schibstedsok.searchportal.query.transform.CatalogueInfopageQueryTransformer;
 import no.schibstedsok.searchportal.result.Navigator;
 import no.schibstedsok.searchportal.result.handler.AddDocCountModifier;
 import no.schibstedsok.searchportal.result.handler.AgeCalculatorResultHandler;
+import no.schibstedsok.searchportal.result.handler.CatalogueResultHandler;
 import no.schibstedsok.searchportal.result.handler.CategorySplitter;
 import no.schibstedsok.searchportal.result.handler.CombineNavigatorsHandler;
 import no.schibstedsok.searchportal.result.handler.ContentSourceCollector;
@@ -261,17 +263,21 @@
 
             // loop through modes.
             final NodeList modeList = root.getElementsByTagName("mode");
+            
             for (int i = 0; i < modeList.getLength(); ++i) {
                 final Element modeE = (Element) modeList.item(i);
                 final String id = modeE.getAttribute("id");
+                
                 LOG.info(INFO_PARSING_MODE + modeE.getLocalName() + " " + id);
                 final SearchMode inherit = 
getMode(modeE.getAttribute("inherit"));
+                
                 final SearchMode mode = new SearchMode(inherit);
+                
                 mode.setId(id);
                 mode.setExecutor(parseExecutor(modeE.getAttribute("executor"),
                         inherit != null ? inherit.getExecutor() : new 
SequentialSearchCommandExecutor()));
                 fillBeanProperty(mode, inherit, "analysis", ParseType.Boolean, 
modeE, "false");
-
+                
                 // setup new commands list for this mode
                 final Map<String,SearchConfiguration> modesCommands = new 
HashMap<String,SearchConfiguration>();
                 try{
@@ -283,9 +289,12 @@
 
                 // now loop through commands
                 for(CommandTypes commandType : CommandTypes.values()){
-                    final NodeList commandsList = 
modeE.getElementsByTagName(commandType.getXmlName());
+                       final NodeList commandsList = 
modeE.getElementsByTagName(commandType.getXmlName());
+
+                    
                     for (int j = 0; j < commandsList.getLength(); ++j) {
                         final Element commandE = (Element) 
commandsList.item(j);
+                       
                         final SearchConfiguration sc = 
commandType.parseSearchConfiguration(context, commandE, mode);
                         modesCommands.put(sc.getName(), sc);
                         mode.addSearchConfiguration(sc);
@@ -673,6 +682,11 @@
                     fillBeanProperty(twsc, inherit, "waitOn", 
ParseType.String, commandE, null);
                     fillBeanProperty(twsc, inherit, "useMyChannels", 
ParseType.Boolean, commandE, "false");
                 }
+                
+                if(sc instanceof CatalogueSearchConfiguration){
+                       final CatalogueSearchConfiguration csc = 
(CatalogueSearchConfiguration) sc;
+                    fillBeanProperty(csc, inherit, "queryParameterWhere", 
ParseType.String , commandE, "");
+                }
 
                 // query transformers
                 NodeList qtNodeList = 
commandE.getElementsByTagName("query-transformers");
@@ -792,6 +806,7 @@
         }
     }
 
+
     private static final class QueryTransformerFactory {
 
         private QueryTransformerFactory(){}
@@ -864,7 +879,8 @@
         TEXT_OUTPUT(TextOutputResultHandler.class),
         VELOCITY_OUTPUT(VelocityResultHandler.class),
         FIELD_ESCAPE(FieldEscapeHandler.class),
-        XML_OUTPUT(XmlOutputResultHandler.class);
+        XML_OUTPUT(XmlOutputResultHandler.class),
+        CATALOGUE(CatalogueResultHandler.class);
 
 
         private final Class<? extends ResultHandler> clazz;
@@ -885,6 +901,10 @@
                 LOG.info(INFO_PARSING_RESULT_HANDLER + xmlName);
                 final ResultHandler handler = clazz.newInstance();
                 switch(this){
+                       case CATALOGUE: 
+                               final CatalogueResultHandler crh = 
(CatalogueResultHandler) handler;
+                               break;
+                               
                     case ADD_DOC_COUNT:
                         final AddDocCountModifier adc = (AddDocCountModifier) 
handler;
                         adc.setModifierName(rh.getAttribute("modifier"));

Modified: 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueSearchCommand.java
===================================================================
--- 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueSearchCommand.java
  2007-01-15 14:05:00 UTC (rev 4327)
+++ 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueSearchCommand.java
  2007-01-15 16:38:37 UTC (rev 4328)
@@ -4,363 +4,64 @@
 package no.schibstedsok.searchportal.mode.command;
 
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
-
-import no.schibstedsok.searchportal.query.IntegerClause;
-import no.schibstedsok.searchportal.query.LeafClause;
-import no.schibstedsok.searchportal.query.PhoneNumberClause;
-import no.schibstedsok.searchportal.query.Visitor;
-import no.schibstedsok.searchportal.query.XorClause;
-import no.schibstedsok.searchportal.query.token.TokenEvaluationEngine;
-import no.schibstedsok.searchportal.query.token.TokenMatch;
-import no.schibstedsok.searchportal.query.token.TokenPredicate;
+import no.schibstedsok.searchportal.query.Query;
 import no.schibstedsok.searchportal.result.BasicSearchResultItem;
 import no.schibstedsok.searchportal.result.CatalogueSearchResultItem;
 import no.schibstedsok.searchportal.result.FastSearchResult;
-import no.schibstedsok.searchportal.result.ProductResult;
-import no.schibstedsok.searchportal.result.ProductResultItem;
-import no.schibstedsok.searchportal.result.ProductSearchResult;
-import no.schibstedsok.searchportal.result.ProductSearchResultItem;
 import no.schibstedsok.searchportal.result.SearchResult;
-import no.schibstedsok.searchportal.result.YellowSearchResult;
 
 import org.apache.log4j.Logger;
 
+
 /**
- * TODO. Rewrite from scratch. This class is insane.
  * 
- * COMMENT: Jag har tagit utgångspunkt i YellowCommand. Det är massa i denna 
klass
- * som jag inte har koll på i detalj!
- * 
- * top3 är gamla (dagens) import av produkter från IK som ska bytas ut. 
- *
- * Begreppet local är jag osäker på?
- * 
- * 
  */
 public class CatalogueSearchCommand extends AbstractSimpleFastSearchCommand {
 
     private static final Logger LOG = 
Logger.getLogger(CatalogueSearchCommand.class);
+    private String queryTwo=null;
+    
 
-    private boolean ignoreGeoNav = false;
-
-    private boolean isLocal;
-
-    private boolean isTop3 = false;
-
-    private boolean ypkeywordsgeo = false;
-
-    private StringBuilder filterBuilder = null;
-
-    boolean exactCompany;
-    boolean companyRank = false;
-
-    private boolean correct = false;
-
     /** Creates a new catalogue search command.
      * TODO. Rewrite from scratch. This is insane.
      **/
     public CatalogueSearchCommand(final Context cxt, final Map parameters) {
-        super(cxt, parameters);
-    }
+       super(cxt, parameters);
+       LOG.info("CatalogueSearchCommand constructor.");
+       LOG.info("Where:"+getSingleParameter("where"));
 
-    /** TODO comment me. **/
-    protected Map getNavigators() {
-
-        if (ignoreGeoNav && super.getNavigators() != null) {
-            final Map m = new HashMap();
-            m.putAll(super.getNavigators());
-            m.remove("geographic");
-            return m;
-        }
-
-        return super.getNavigators();
+       // hvis "where" parametern er sendt inn, så tar vi og leser inn query 
fra
+       // den.
+       if(getSingleParameter("where") != null){
+               final ReconstructedQuery rq = 
createQuery(getSingleParameter("where"));
+               final Query query = rq.getQuery();
+       
+               queryTwo = query.getQueryString();
+       }
+   
     }
 
     /** TODO comment me. **/
     public SearchResult execute() {
-        LOG.info("Execute");
+        LOG.info("execute()");
+       LOG.info("Catalogue query is :" + getTransformedQuery());     
+       
 
-        boolean viewAll = false;
-
-        if (getParameters().containsKey("ypviewall")) {
-            viewAll = true;
-        }
-
-
-        if (isLocalSearch() && !viewAll) {
-            correct = false;
-            ignoreGeoNav = true;
-            isLocal = false;
-            ypkeywordsgeo = true;
-            final FastSearchResult nationalHits = (FastSearchResult) 
super.execute();
-            ypkeywordsgeo = false;
-
-            correct = false;
-            ignoreGeoNav = false;
-            isTop3 = true;
-            final FastSearchResult top3 = (FastSearchResult) super.execute();
-            isTop3 = false;
-
-            // Perform local search.
-            correct = true;
-            ignoreGeoNav = false;
-            isLocal = true;
-            final FastSearchResult localResult = (FastSearchResult) 
super.execute();
-
-            final YellowSearchResult result = new YellowSearchResult(this, 
localResult, nationalHits, top3, isLocalSearch() && !viewAll);
-
-            final String yprank = companyRank ? "company" : "default";
-            result.addField("yprank", yprank);
-
-            return result;
-        } else if (!viewAll) {
-            isLocal = false;
-            isTop3 = true;
-            correct = false;
-            final FastSearchResult top3 = (FastSearchResult) super.execute();
-            isTop3 = false;
-            ypkeywordsgeo = true;
-            correct = true;
-            final FastSearchResult nationalHits = (FastSearchResult) 
super.execute();
-            ypkeywordsgeo = false;
-
-            final YellowSearchResult result = new YellowSearchResult(this, 
null, nationalHits, top3, false);
-            
- //           fetchProducts(result);
-            final String yprank = companyRank ? "company" : "default";
-            result.addField("yprank", yprank);
-
-            return result;
-        } else {
-            correct = true;
-            ypkeywordsgeo = false;
-            isLocal = true;
-            ignoreGeoNav = true;
-            final FastSearchResult localResult = (FastSearchResult) 
super.execute();
-            ignoreGeoNav = false;
-            isLocal = false;
-
-            isTop3 = true;
-            correct = false;
-            final FastSearchResult top3 = (FastSearchResult) super.execute();
-            isTop3 = false;
-
-            isLocal = false;
-            ypkeywordsgeo = true;
-            correct = false;
-            final FastSearchResult nationalHits = (FastSearchResult) 
super.execute();
-            ypkeywordsgeo = false;
-
-            final String yprank = companyRank ? "company" : "default";
-
-            final YellowSearchResult result = new YellowSearchResult(this, 
localResult, nationalHits, top3, false);
-
-            result.addField("yprank", yprank);
-            return result;
-        }
-    }
-
-    private boolean isLocalSearch() {
-        return getRunningQuery().getGeographicMatches().size() > 0;
-    }
-
-
-    private TokenMatch getLastGeoMatch() {
-        final List<TokenMatch> matches = 
getRunningQuery().getGeographicMatches();
-
-        if (matches.size() > 0) {
-            return matches.get(matches.size() - 1);
-        } else {
-            return null;
-        }
-    }
-
-
-    /** TODO comment me. **/
-    public String getTransformedQuery() {
-
-        final String t = super.getTransformedQuery();
-
-        final TokenEvaluationEngine engine = 
context.getTokenEvaluationEngine();
-
-        exactCompany = engine.evaluateQuery(TokenPredicate.EXACT_COMPANYRANK, 
context.getQuery());
-
-        companyRank = exactCompany && !isTop3 && 
!getParameter("yprank").equals("standard") || 
getParameter("yprank").equals("company");
-
-        if (companyRank) {
-            return t.replaceAll("yellowphon", "yellownamephon");
-        }
-
-        if (isTop3) {
-            return t.replaceAll("yellowphon:", "").replaceAll("-", " ");
-        }
-
-        if (isLocal) {
-            return t.replaceAll("-", " ");
-        } else {
-            return t.replaceAll("yellowphon", "yellowgeophon").replaceAll("-", 
" ");
-        }
-    }
-
-
-    /** TODO comment me. **/
-    protected boolean isCorrectionEnabled() {
-        return correct;
-    }
-
-    /** TODO comment me. **/
-    protected int getResultsToReturn() {
-        if (isTop3) {
-            return 3;
-        } else {
-            return super.getResultsToReturn();
-        }
-    }
-
-    /** TODO comment me. **/
-    protected String getAdditionalFilter() {
-
-        synchronized (this) {
-            if (filterBuilder == null) {
-                filterBuilder = new StringBuilder(super.getAdditionalFilter());
-            }
-
-            return ypkeywordsgeo && getLastGeoMatch() != null
-                    ? filterBuilder.toString() + " +ypkeywordsgeo:" + 
getLastGeoMatch().getMatch()
-                    : filterBuilder.toString();
-        }
-    }
-
-    /** TODO comment me. **/
-    protected String getSortBy() {
-
-        final TokenEvaluationEngine engine = 
context.getTokenEvaluationEngine();
-
-        if (engine.evaluateQuery(TokenPredicate.EXACT_COMPANYRANK, 
context.getQuery())) {
-            return "yellowname";
-        }
-
-        return (isLocal ? "yellowpages2new +ypnavn" : "yellowpages2geo 
+ypnavn");
-    }
-
-    /** TODO comment me. **/
-    public String getQueryInfo() {
-        return getTransformedQuery() + " " + getSortBy() + " " + 
getAdditionalFilter();
-    }
-
-
-    // Query Builder
-
-    private static final String PREFIX_INTEGER="yellowpages:";
-    private static final String PREFIX_PHONETIC="yellowphon:";
-
-    /**
-     * Adds non phonetic prefix to integer terms.
-     *
-     * @param clause The clause to prefix.
-     */
-    protected void visitImpl(final IntegerClause clause) {
-        if (!getTransformedTerm(clause).equals("")) {
-            appendToQueryRepresentation(PREFIX_INTEGER);
-        }
-
-        super.visitImpl(clause);
-    }
-
-    /**
-     * Adds non phonetic prefix to phone number terms.
-     *
-     * @param clause The clause to prefix.
-     */
-    protected void visitImpl(final PhoneNumberClause clause) {
-        if (!getTransformedTerm(clause).equals("")) {
-            appendToQueryRepresentation(PREFIX_INTEGER);
-        }
-        super.visitImpl(clause);
-    }
-
-    /**
-     * Adds phonetic prefix to a leaf clause.
-     * Remove dots from words. (people, street, suburb, or city names do not 
have dots.)
-     *
-     * @param clause The clause to prefix.
-     */
-    protected void visitImpl(final LeafClause clause) {
-        
-        if (clause.getField() == null) {
-            if (!getTransformedTerm(clause).equals("")) {
-                appendToQueryRepresentation(PREFIX_PHONETIC 
-                        + getTransformedTerm(clause).replaceAll("\\.", " "));
-            }
-            
-        }else if(null == getFieldFilter(clause)){
-            
-            if (!getTransformedTerm(clause).equals("")) {
-                // we also accept terms with fields that haven't been 
permitted for the searchConfiguration
-                appendToQueryRepresentation(PREFIX_PHONETIC 
-                        + clause.getField() + "\\:" + 
getTransformedTerm(clause).replaceAll("\\.", " "));
-                
-            }
-
-        }
-    }
-
-    /**
-     * An implementation that ignores phrase searches.
-     *
-     * Visits only the left clause, unless that clause is a clause, in which
-     * case only the right clause is visited. Phrase searches are not possible
-     * against the yellow index.
-     */
-    protected void visitXorClause(final Visitor visitor, final XorClause 
clause) {
-        
-        // If we have a match on an international phone number, but it is not 
recognized as
-        // a local phone number, force it to use the original number string.
-        if (clause.getHint() == XorClause.Hint.PHONE_NUMBER_ON_LEFT
-                && 
!clause.getFirstClause().getKnownPredicates().contains(TokenPredicate.PHONENUMBER))
 {
-            
-            clause.getSecondClause().accept(visitor);
-            
-        } else if(XorClause.Hint.PHRASE_ON_LEFT == clause.getHint()){
-            clause.getSecondClause().accept(visitor);
-            
-        } else {
-            super.visitXorClause(visitor, clause);
-        }
-    }
-    
-    /**
-     * This function gets all products for the resultList.
-     * 
-     * @param result
-     */
-    private void fetchProducts(YellowSearchResult result) {
-        LOG.info("fetchProducts");
-                       
-               if(result == null)
-               return;
        
+        // kør vanligt søk.
+        SearchResult result = super.execute();
                
-               List<CatalogueSearchResultItem> nyResultListe = new 
ArrayList<CatalogueSearchResultItem>();
+        // konverter til denne.
+        List<CatalogueSearchResultItem> nyResultListe = new 
ArrayList<CatalogueSearchResultItem>();
                
        //TODO: get all keys to lookup and execute one call instead of 
iterating like this...
        Iterator iter = result.getResults().listIterator();
        
-               //placeholder for products
-               ProductResult products = new ProductSearchResult();     
        
        while (iter.hasNext()) {
                BasicSearchResultItem basicResultItem = (BasicSearchResultItem) 
iter.next();
@@ -373,68 +74,23 @@
                }
                
                nyResultListe.add(resultItem);
-               
-               //jdbc version
-               Connection con = null;
-               try {
-                       InitialContext ctxt = new InitialContext();
-                       DataSource ds = (DataSource) 
ctxt.lookup("java:comp/env/jdbc/ag");
-                       
-                       con = ds.getConnection();
-                               
-                               PreparedStatement stmt = con
-                                               .prepareStatement("select 
S.companyId, C.organizationNo, C.businessName, S.textShort, S.text1" +
-                                                                               
  " from AG_SALE S, AG_COMPANY C " +
-                                                                               
  " where C.companyId = S.companyId and C.organizationNo = ? and toDate > now() 
and S.text1 is not null");
-                               
stmt.setString(1,resultItem.getField("yporgnummer"));
-                               LOG.info("Hent produkter for firma med 
organisasjonsnr. "+resultItem.getField("yporgnummer"));
-                               
-                               ResultSet res = stmt.executeQuery();
-                               
-                               if(res.next()){
-                                       
-                                       //listingProducts goes on the result 
listing page
-                                       if(res.getString("textShort") != null){
-                                               ProductResultItem 
listingProduct = new ProductSearchResultItem();
-                                               
listingProduct.addField("shortText", res.getString("textShort"));
-                                               
products.addListingResult(listingProduct);
-                                       }
-
-                                       //infoPageProducts goes on the infopage
-                                       if(res.getString("text1") != null){
-                                               ProductResultItem 
infoPageProduct = new ProductSearchResultItem();
-                                               
infoPageProduct.addField("text1", res.getString("text1"));
-                                               
products.addInfoPageResult(infoPageProduct);
-                                       }
-
-                                       //add the products to the searchResult
-                                       if(products.hasInfoPageProducts() || 
products.hasListingProducts())
-                                               
resultItem.addProducts(products);
-
-                               }else{
-                               LOG.info("ingen produkter funnet for firma.");
-                               }
-                               
-                               
-                       } catch (SQLException e) {
-                               e.printStackTrace();
-                       } catch (NamingException e) {
-                               e.printStackTrace();
-                       } finally{
-                               try {
-                                       con.close();
-                               } catch (SQLException e) {
-                                       e.printStackTrace();
-                               }
-                       }
-               
-                       
-               }
+       }
        
-       // bytt ut den gamle mot den nye listen.
+       // fjern de gamle BasicResultItems, og erstatt dem med nye 
CatalogueResultItems. 
        result.getResults().clear();
        result.getResults().addAll(nyResultListe);
+       
+       return result;
     }
-     
 
+    /** TODO comment me. **/
+    public String getTransformedQuery() {
+       LOG.info("Catalogue Transformed Query");
+       
+       // hvis det finnes en ekstra query, legg til denne i søket.     
+        return queryTwo!=null ? super.getTransformedQuery()+" 
iypcfgeo:\""+queryTwo+"\"" : super.getTransformedQuery();
+    }
+    
+    
+
 }

Added: 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/handler/CatalogueResultHandler.java
===================================================================
--- 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/handler/CatalogueResultHandler.java
                                (rev 0)
+++ 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/handler/CatalogueResultHandler.java
        2007-01-15 16:38:37 UTC (rev 4328)
@@ -0,0 +1,132 @@
+// Copyright (2006) Schibsted Søk AS
+package no.schibstedsok.searchportal.result.handler;
+
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
+import org.apache.log4j.Logger;
+
+import no.schibstedsok.searchportal.result.CatalogueSearchResultItem;
+import no.schibstedsok.searchportal.result.ProductResult;
+import no.schibstedsok.searchportal.result.ProductResultItem;
+import no.schibstedsok.searchportal.result.ProductSearchResult;
+import no.schibstedsok.searchportal.result.ProductSearchResultItem;
+import no.schibstedsok.searchportal.result.SearchResult;
+
+
+/**
+ * @author <a href="mailto:[EMAIL PROTECTED]">Magnus Eklund</a>
+ * @version <tt>$Revision: 3436 $</tt>
+ */
+public final class CatalogueResultHandler implements ResultHandler {
+    
+    private static final Logger LOG = 
Logger.getLogger(CatalogueResultHandler.class);
+    
+    public void handleResult(final Context cxt, final Map parameters) {
+       LOG.info("Starter Catalogue ResultHandler.");
+
+       final SearchResult result = cxt.getSearchResult();
+
+        fetchProducts(result);
+        
+    }
+
+    
+    /**
+     * This function gets all products for the resultList.
+     * 
+     * @param result
+     */
+    private void fetchProducts(SearchResult result) {
+        LOG.info("fetchProducts");
+               
+        // if result is missing, just exit this method
+        if(result == null)
+               return;
+       
+        
+        //jdbc objects.
+               Connection con = null;
+               PreparedStatement stmt = null;
+               ResultSet res = null;
+        
+       Iterator iter = result.getResults().listIterator();
+       
+               //placeholder for products
+               ProductResult products = new ProductSearchResult();     
+               try {
+                       InitialContext ctxt = new InitialContext();
+               DataSource ds = (DataSource) 
ctxt.lookup("java:comp/env/jdbc/catalogue");
+               
+               con = ds.getConnection();
+
+                       stmt = con.prepareStatement("select S.companyId, 
C.organizationNo, C.businessName, S.textShort, S.text1" +
+                                         " from AG_SALE S, AG_COMPANY C " +
+                                         " where C.companyId = S.companyId and 
C.organizationNo = ? and toDate > now() and S.text1 is not null");
+               
+               while (iter.hasNext()) {
+                       CatalogueSearchResultItem resultItem = 
(CatalogueSearchResultItem) iter.next();
+       
+                                       
+                                       
stmt.setString(1,resultItem.getField("iyporgnr"));
+                                       LOG.info("Hent produkter for firma med 
organisasjonsnr> "+resultItem.getField("iyporgnr"));
+                                       
+                                       res = stmt.executeQuery();
+                                       LOG.info("sql er kjørt");
+                                       
+                                       if(res.next()){
+                                               LOG.info("Finne produkter for 
firma, les inn data.");
+                                               ProductResultItem 
infoPageProduct = new ProductSearchResultItem();
+                                               
+       
+                                               //infoPageProducts goes on the 
infopage
+                                               if(res.getString("text1") != 
null){
+                                                       
infoPageProduct.addField("text1", res.getString("text1"));
+                                                       LOG.info("lagt inn 
text1 felt i produktet: "+infoPageProduct.getField("text1"));
+                                               }
+                                               //infoPageProducts goes on the 
infopage
+                                               if(res.getString("textShort") 
!= null){
+                                                       
infoPageProduct.addField("textShort", res.getString("textShort"));
+                                                       LOG.info("lagt inn 
textShort felt i produktet: "+infoPageProduct.getField("textShort"));
+                                               }
+       
+                                               
products.addInfoPageResult(infoPageProduct);
+       
+                                               //add the products to the 
searchResult
+                                               
if(products.hasInfoPageProducts() || products.hasListingProducts())
+                                                       
resultItem.addProducts(products);
+       
+                                       }else{
+                                       LOG.info("ingen produkter funnet for 
firma.");
+                                       }
+                                       
+                       } // end while.
+                               
+                       } catch (SQLException e) {
+                               LOG.error("SQLException, Feil ved uthenting av 
produkter",e);
+
+                       } catch (NamingException e) {
+                               LOG.error("NamingException, Feil ved uthenting 
av produkter",e);
+                       }finally {
+                             try {if (res != null) res.close();} catch 
(SQLException e) { LOG.error("Could not close ResultSet",e);}
+                             try {if (stmt != null) stmt.close();} catch 
(SQLException e) { LOG.error("Could not close Statement",e);}
+                             try {if (con != null) con.close();} catch 
(SQLException e) { LOG.error("Could not close Connection",e);}
+                           
+                       }
+               
+                       
+       
+    }
+         
+    
+    
+}

Added: 
trunk/query-transform-spi/src/main/java/no/schibstedsok/searchportal/query/transform/CatalogueInfopageQueryTransformer.java
===================================================================
--- 
trunk/query-transform-spi/src/main/java/no/schibstedsok/searchportal/query/transform/CatalogueInfopageQueryTransformer.java
                         (rev 0)
+++ 
trunk/query-transform-spi/src/main/java/no/schibstedsok/searchportal/query/transform/CatalogueInfopageQueryTransformer.java
 2007-01-15 16:38:37 UTC (rev 4328)
@@ -0,0 +1,17 @@
+// Copyright (2006) Schibsted Søk AS
+package no.schibstedsok.searchportal.query.transform;
+
+
+/**
+ * @author <a href="mailto:[EMAIL PROTECTED]">Magnus Eklund</a>
+ * @version <tt>$Revision: 3359 $</tt>
+ */
+public final class CatalogueInfopageQueryTransformer extends 
AbstractQueryTransformer {
+    
+    public String getTransformedQuery() {
+
+        final String originalQuery = getContext().getTransformedQuery();
+
+        return "iypcompanyid:" + originalQuery;
+    }
+}

Modified: trunk/war/pom.xml
===================================================================
--- trunk/war/pom.xml   2007-01-15 14:05:00 UTC (rev 4327)
+++ trunk/war/pom.xml   2007-01-15 16:38:37 UTC (rev 4328)
@@ -43,6 +43,16 @@
                 <artifactId>maven-war-plugin</artifactId>
                 <configuration>
                     <warSourceDirectory>src/webapp</warSourceDirectory>
+                               <webResources>        
+                                       <resource>
+                                               
<directory>war/src/webapp/META-INF</directory>
+                                               
<targetPath>META-INF</targetPath>
+                                       <includes>
+                                                       <include>*.xml</include>
+                                       </includes>           
+                                               <filtering>true</filtering>     
                        
+                                       </resource>
+                               </webResources>
                 </configuration>
             </plugin>
         </plugins>
@@ -145,6 +155,9 @@
                 <linkpulse.url>http://go.sesam.no/</linkpulse.url>
                 <log.file>sesam</log.file>
                 <linkpulse.enable>false</linkpulse.enable>
+                               
<catalogue_ds.db>jdbc:mysql://localhost:3306/aguiden</catalogue_ds.db>          
      
+                               
<catalogue_ds.username>root</catalogue_ds.username>
+                               <catalogue_ds.password></catalogue_ds.password>
             </properties>
         </profile>
        <profile>
@@ -161,6 +174,9 @@
                 <linkpulse.url>http://go.sesam.no/</linkpulse.url>
                 <log.file>sesam</log.file>
                 <linkpulse.enable>true</linkpulse.enable>
+                               
<catalogue_ds.db>jdbc:mysql://sch-mysql01.dev.osl.basefarm.net:3306/alfa</catalogue_ds.db>
                
+                               
<catalogue_ds.username>alfaweb</catalogue_ds.username>
+                               
<catalogue_ds.password>cwxDdTRv</catalogue_ds.password>
             </properties>
         </profile>
        <profile>
@@ -177,6 +193,9 @@
                 <linkpulse.url>http://go.sesam.no/</linkpulse.url>
                 <log.file>sesam</log.file>
                 <linkpulse.enable>true</linkpulse.enable>
+                               
<catalogue_ds.db>jdbc:mysql://sch-mysql01.dev.osl.basefarm.net:3306/alfa</catalogue_ds.db>
                
+                               
<catalogue_ds.username>alfaweb</catalogue_ds.username>
+                               
<catalogue_ds.password>cwxDdTRv</catalogue_ds.password>
             </properties>
         </profile>
        <profile>
@@ -193,6 +212,9 @@
                 <linkpulse.url>http://go.sesam.no/</linkpulse.url>
                 <log.file>sesam</log.file>
                 <linkpulse.enable>true</linkpulse.enable>
+                               
<catalogue_ds.db>jdbc:mysql://sch-mysql01.dev.osl.basefarm.net:3306/alfa</catalogue_ds.db>
                
+                               
<catalogue_ds.username>alfaweb</catalogue_ds.username>
+                               
<catalogue_ds.password>cwxDdTRv</catalogue_ds.password>
             </properties>
         </profile>
        <profile>
@@ -209,6 +231,9 @@
                 <linkpulse.url>http://go.sesam.no/</linkpulse.url>
                 <log.file>sesam</log.file>
                 <linkpulse.enable>true</linkpulse.enable>
+                               
<catalogue_ds.db>jdbc:mysql://sch-mysql01.dev.osl.basefarm.net:3306/alfa</catalogue_ds.db>
                
+                               
<catalogue_ds.username>alfaweb</catalogue_ds.username>
+                               
<catalogue_ds.password>cwxDdTRv</catalogue_ds.password>
             </properties>
         </profile>
        <profile>
@@ -225,6 +250,9 @@
                 <linkpulse.url>http://go.sesam.no/</linkpulse.url>
                 <log.file>sesam</log.file>
                 <linkpulse.enable>true</linkpulse.enable>
+                               
<catalogue_ds.db>jdbc:mysql://sch-mysql01.dev.osl.basefarm.net:3306/alfa</catalogue_ds.db>
                
+                               
<catalogue_ds.username>alfaweb</catalogue_ds.username>
+                               
<catalogue_ds.password>cwxDdTRv</catalogue_ds.password>
             </properties>
         </profile>
         <profile>
@@ -249,6 +277,9 @@
                 <linkpulse.url>http://go.sesam.no/</linkpulse.url>
                 <log.file>sesam</log.file>
                 <linkpulse.enable>true</linkpulse.enable>
+                               
<catalogue_ds.db>jdbc:mysql://sch-mysql01.dev.osl.basefarm.net:3306/alfa</catalogue_ds.db>
                
+                               
<catalogue_ds.username>alfaweb</catalogue_ds.username>
+                               
<catalogue_ds.password>cwxDdTRv</catalogue_ds.password>
             </properties>
         </profile>
     </profiles>

Added: trunk/war/src/webapp/META-INF/context.xml
===================================================================
--- trunk/war/src/webapp/META-INF/context.xml                           (rev 0)
+++ trunk/war/src/webapp/META-INF/context.xml   2007-01-15 16:38:37 UTC (rev 
4328)
@@ -0,0 +1,8 @@
+<Context path="/" debug="0">
+       <Resource name="jdbc/catalogue" auth="Container"
+              type="javax.sql.DataSource" 
driverClassName="com.mysql.jdbc.Driver"
+              url="@catalogue_ds.db@"
+              username="@catalogue_ds.username@" 
password="@catalogue_ds.password@" maxActive="20" maxIdle="10"
+              removeAbandoned="true" removeAbandonedTimeout="60" 
logAbandoned="true"
+              maxWait="2000"/>
+</Context>
\ No newline at end of file

Modified: trunk/war/src/webapp/WEB-INF/web.xml
===================================================================
--- trunk/war/src/webapp/WEB-INF/web.xml        2007-01-15 14:05:00 UTC (rev 
4327)
+++ trunk/war/src/webapp/WEB-INF/web.xml        2007-01-15 16:38:37 UTC (rev 
4328)
@@ -191,4 +191,14 @@
 
     
 
+    <resource-ref>
+       <description>
+               Resource ref to the Datasource configured in context.xml 
+               mysql-xxx.jar must be copied to $CATALINA_HOME/common/lib
+       </description>
+       <res-ref-name>jdbc/catalogue</res-ref-name>
+       <res-type>javax.sql.DataSource</res-type>
+       <res-auth>Container</res-auth>
+    </resource-ref>
+   
     </web-app>

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

Reply via email to