Author: daniele
Date: 2007-01-18 15:54:31 +0100 (Thu, 18 Jan 2007)
New Revision: 4351
Modified:
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueAdsSearchCommand.java
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/handler/CatalogueResultHandler.java
trunk/war/pom.xml
trunk/war/src/webapp/WEB-INF/web.xml
Log:
removed the datasource, using standard jdbc connection for now, will be
replaced with a webservice call soon
Modified:
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueAdsSearchCommand.java
===================================================================
---
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueAdsSearchCommand.java
2007-01-18 14:00:59 UTC (rev 4350)
+++
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueAdsSearchCommand.java
2007-01-18 14:54:31 UTC (rev 4351)
@@ -49,7 +49,7 @@
queryTwo = query.getQueryString();
}else{
- queryTwo = " ingen";
+ queryTwo = "ingensteds";
}
}
Modified:
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
2007-01-18 14:00:59 UTC (rev 4350)
+++
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/handler/CatalogueResultHandler.java
2007-01-18 14:54:31 UTC (rev 4351)
@@ -3,41 +3,60 @@
import java.sql.Connection;
+import java.sql.DriverManager;
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.commons.ioc.ContextWrapper;
+import no.schibstedsok.searchportal.mode.config.FastSearchConfiguration;
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;
+import no.schibstedsok.searchportal.site.config.SiteConfiguration;
+import org.apache.log4j.Logger;
+
/**
- * @author <a href="mailto:[EMAIL PROTECTED]">Magnus Eklund</a>
+ * Resulthandler to fetch sales from the catalogue sales system.
+ * This class is called after a search command with <catalogue/>
+ * resulthandler tag is defined. It loops through all result
+ * items and load data with sql/jdbc from the sales system.
+ *
+ * @todo Replace all JDBC/SQL code with call to Webservice in
+ * sales system.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Daniel Engfeldt</a>
* @version <tt>$Revision: 3436 $</tt>
*/
public final class CatalogueResultHandler implements ResultHandler {
private static final Logger LOG =
Logger.getLogger(CatalogueResultHandler.class);
+ private String url = null;
+ private String username = null;
+ private String password = null;
public void handleResult(final Context cxt, final Map parameters) {
LOG.info("Starter Catalogue ResultHandler.");
+
+ final SiteConfiguration siteConf
+ =
SiteConfiguration.valueOf(ContextWrapper.wrap(SiteConfiguration.Context.class,
cxt));
+ url = siteConf.getProperty("catalogue_ds.db");
+ username = siteConf.getProperty("catalogue_ds.username");
+ password = siteConf.getProperty("catalogue_ds.password");
+
final SearchResult result = cxt.getSearchResult();
+ fetchProducts(result);
- fetchProducts(result);
-
}
@@ -48,7 +67,7 @@
*/
private void fetchProducts(SearchResult result) {
LOG.info("fetchProducts");
-
+
// if result is missing, just exit this method
if(result == null)
return;
@@ -64,11 +83,13 @@
//placeholder for products
ProductResult products = new ProductSearchResult();
try {
- InitialContext ctxt = new InitialContext();
- DataSource ds = (DataSource)
ctxt.lookup("java:comp/env/jdbc/catalogue");
+
+
+ Class.forName("com.mysql.jdbc.Driver");
+
+ con
+ = DriverManager.getConnection(url,username,password);
- 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");
@@ -78,7 +99,7 @@
stmt.setString(1,resultItem.getField("iyporgnr"));
- LOG.info("Hent produkter for firma med
organisasjonsnr> "+resultItem.getField("iyporgnr"));
+ LOG.info("Hent produkter for firma med
organisasjonsnr: "+resultItem.getField("iyporgnr"));
res = stmt.executeQuery();
LOG.info("sql er kjørt");
@@ -113,9 +134,8 @@
} catch (SQLException e) {
LOG.error("SQLException, Feil ved uthenting av
produkter",e);
-
- } catch (NamingException e) {
- LOG.error("NamingException, Feil ved uthenting
av produkter",e);
+ }catch(ClassNotFoundException e){
+ LOG.error("ClassNotFoundException, Feil ved
uthenting av jdbc driver",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);}
Modified: trunk/war/pom.xml
===================================================================
--- trunk/war/pom.xml 2007-01-18 14:00:59 UTC (rev 4350)
+++ trunk/war/pom.xml 2007-01-18 14:54:31 UTC (rev 4351)
@@ -136,10 +136,17 @@
<groupId>axis</groupId>
<artifactId>axis-jaxrpc</artifactId>
</dependency>
- <dependency>
+ <dependency>
<groupId>axis</groupId>
<artifactId>axis-saaj</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.0.4</version>
+ </dependency>
+
</dependencies>
<profiles>
<profile>
@@ -155,9 +162,6 @@
<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>
@@ -174,9 +178,6 @@
<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,9 +194,6 @@
<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>
@@ -212,9 +210,6 @@
<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>
@@ -231,9 +226,6 @@
<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>
@@ -250,9 +242,6 @@
<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>
@@ -277,9 +266,6 @@
<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>
Modified: trunk/war/src/webapp/WEB-INF/web.xml
===================================================================
--- trunk/war/src/webapp/WEB-INF/web.xml 2007-01-18 14:00:59 UTC (rev
4350)
+++ trunk/war/src/webapp/WEB-INF/web.xml 2007-01-18 14:54:31 UTC (rev
4351)
@@ -191,14 +191,4 @@
- <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