Author: daniele
Date: 2007-03-16 11:24:48 +0100 (Fri, 16 Mar 2007)
New Revision: 4580
Modified:
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/SearchModeFactory.java
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueAdsSearchCommand.java
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueSearchCommand.java
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/config/CatalogueSearchConfiguration.java
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/CatalogueQueryTransformer.java
trunk/war/pom.xml
Log:
GULD-224: initial implementation with basic functionality. added dummy template
to view functionality temporarly in the search result, this should be removed
when functionality is moved to sesam.no skin. Did some cleanup in views.xml
that was broken and showed strange design in the webpage.
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-03-15 17:47:53 UTC (rev 4579)
+++
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/SearchModeFactory.java
2007-03-16 10:24:48 UTC (rev 4580)
@@ -762,6 +762,7 @@
final CatalogueSearchConfiguration csc =
(CatalogueSearchConfiguration) sc;
fillBeanProperty(csc, inherit, "queryParameterWhere",
ParseType.String , commandE, "");
fillBeanProperty(csc, inherit, "searchBy",
ParseType.String , commandE, "");
+ fillBeanProperty(csc, inherit, "split", ParseType.Boolean
, commandE, "false");
}
if(sc instanceof CatalogueAdsSearchConfiguration){
final CatalogueAdsSearchConfiguration casc =
(CatalogueAdsSearchConfiguration) sc;
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-03-15 17:47:53 UTC (rev 4579)
+++
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueAdsSearchCommand.java
2007-03-16 10:24:48 UTC (rev 4580)
@@ -89,6 +89,8 @@
// for a given geographic place.
whichQueryToRun = QueryType.GEO;
r = super.execute();
+
+ LOG.info("Found "+r.getHitCount()+" sponsed links");
// if there was less than 5 sponsor links from a
// specific geographic place, we could add sponsor
@@ -159,16 +161,21 @@
searchResults[i]=item;
LOG.info("Fant sponsortreff for plass "
+ (i+1) + ", " + item.getField("iypspkeywords"+(i+1)));
}
- }
+ } // end for
+
// erstatt resultatet fra første query som returneres
ut herifra,
// med det prossesserte resultatet
r.getResults().clear();
+ LOG.info("Cleared original result.");
for(SearchResultItem item:searchResults){
if(item!=null){
r.addResult(item);
+ LOG.info("Added item
"+item.getField("iypcompanyid"));
}
}
+
+ r.setHitCount(r.getResults().size());
// plass 5, er de som betalt mest, og skal da først i
lista.
// plass 1 er de som betalt minst og skal da sist i
lista.
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-03-15 17:47:53 UTC (rev 4579)
+++
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueSearchCommand.java
2007-03-16 10:24:48 UTC (rev 4580)
@@ -4,243 +4,453 @@
package no.schibstedsok.searchportal.mode.command;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import no.fast.ds.search.ISearchParameters;
-import no.fast.ds.search.SearchParameter;
+import no.schibstedsok.commons.ioc.BaseContext;
import no.schibstedsok.commons.ioc.ContextWrapper;
import no.schibstedsok.searchportal.datamodel.DataModel;
+import
no.schibstedsok.searchportal.mode.command.AbstractSearchCommand.ReconstructedQuery;
import no.schibstedsok.searchportal.mode.config.CatalogueSearchConfiguration;
-import no.schibstedsok.searchportal.mode.config.HittaSearchConfiguration;
import no.schibstedsok.searchportal.query.AndClause;
import no.schibstedsok.searchportal.query.AndNotClause;
import no.schibstedsok.searchportal.query.Clause;
import no.schibstedsok.searchportal.query.DefaultOperatorClause;
-import no.schibstedsok.searchportal.query.DoubleOperatorClause;
import no.schibstedsok.searchportal.query.LeafClause;
import no.schibstedsok.searchportal.query.NotClause;
-import no.schibstedsok.searchportal.query.OperationClause;
import no.schibstedsok.searchportal.query.OrClause;
import no.schibstedsok.searchportal.query.PhraseClause;
import no.schibstedsok.searchportal.query.Query;
import no.schibstedsok.searchportal.query.XorClause;
+import no.schibstedsok.searchportal.query.finder.WhoWhereSplitter;
+import
no.schibstedsok.searchportal.query.finder.WhoWhereSplitter.WhoWhereSplit;
import no.schibstedsok.searchportal.query.parser.AbstractReflectionVisitor;
-import no.schibstedsok.searchportal.query.token.TokenPredicate;
import no.schibstedsok.searchportal.result.BasicSearchResultItem;
import no.schibstedsok.searchportal.result.CatalogueSearchResultItem;
-import no.schibstedsok.searchportal.result.FastSearchResult;
import no.schibstedsok.searchportal.result.SearchResult;
-import no.schibstedsok.searchportal.site.config.SiteConfiguration;
import org.apache.log4j.Logger;
/**
- *
+ *
*/
public class CatalogueSearchCommand extends AdvancedFastSearchCommand {
+
+ private static final Logger LOG = Logger
+ .getLogger(CatalogueSearchCommand.class);
+
+ private String queryTwo = null;
+ private String userSortBy = "kw"; // defualtsøket er på keyword
+ private boolean split = false;
+ private List knownGeo;
+ private String extraGeo;
+
+ private static final String DEBUG_CONF_NFO = "CatalogueSearchCommand
Conf details->";
+ private static final String DEBUG_SEARCHING_1 = "Catalogue Searching for
who->";
+ private static final String DEBUG_SEARCHING_2 = "Catalogue Searching for
where->";
+ private static final String DEBUG_SEARCHING_3 = "Catalogue Searching for
geo->";
+
+ /**
+ * Creates a new catalogue search command.
+ *
+ */
+ public CatalogueSearchCommand(final Context cxt, final DataModel
datamodel) {
+ super(cxt, datamodel);
+
+ final CatalogueSearchConfiguration conf =
(CatalogueSearchConfiguration) cxt
+ .getSearchConfiguration();
+
+ LOG.debug(DEBUG_CONF_NFO + conf.getSearchBy() + ' '
+ + conf.getQueryParameterWhere() + ' '
+ + conf.getSplit());
+
+ // skal query splittes på hva og hvor?
+ split = conf.getSplit();
+
+
- private static final Logger LOG = Logger
- .getLogger(CatalogueSearchCommand.class);
+
+ // split query hvis kommandoen skal dele hva og hvor og flytte geo.
+ if(split){
+ LOG.info("Vi skal splitte query på HVA og HVOR");
+
+ final WhoWhereSplitter splitter = new WhoWhereSplitter(
+ ContextWrapper.wrap(WhoWhereSplitter.Context.class,
+ context,
+ new BaseContext(){
+
+ public Map<Clause,String> getTransformedTerms(){
+ return CatalogueSearchCommand.this.getTransformedTerms();
+ }
+
+ public Query getQuery() {
+ return datamodel.getQuery().getQuery();
+ }
+ }));
+
+ final WhoWhereSplit splitQuery = splitter.getWhoWhereSplit();
+
+ getParameters().put("catalogueWhat", splitQuery.getWho());
+ getParameters().put("catalogueWhere", splitQuery.getWhere());
+
+
+ String[] where = splitQuery.getWhere().split(" ");
+ List w = Arrays.asList(where);
+
+ LOG.debug(DEBUG_SEARCHING_1 + splitQuery.getWho());
+ LOG.debug(DEBUG_SEARCHING_2 + splitQuery.getWhere());
+
+ knownGeo=w;
+ extraGeo = splitQuery.getWhere();
+ }
- private String queryTwo = null;
+ // hvis "where" parametern er sendt inn, så tar vi og leser inn query
+ // fra den
+ ReconstructedQuery rq = null;
+ if (getSingleParameter(conf.getQueryParameterWhere()) != null) {
+ String tmp = getSingleParameter(conf.getQueryParameterWhere());
+ if(extraGeo!=null) tmp = tmp + " " + extraGeo;
+
+ rq = createQuery(tmp);
+
+ GeoVisitor geo = new GeoVisitor();
+ geo.visit(rq.getQuery().getRootClause());
+
+ queryTwo = geo.getQueryRepresentation();
+ LOG.info(DEBUG_SEARCHING_3 + queryTwo);
+ }
+
+
+
+ if (getSingleParameter("userSortBy") != null
+ && getSingleParameter("userSortBy").length() > 0
+ && getSingleParameter("userSortBy").equals("name")) {
+ userSortBy = "name";
+ } else {
+ userSortBy = "kw";
+ }
+ }
+
+
+ /** TODO comment me. * */
+ public SearchResult execute() {
+
- private String userSortBy = "kw"; // defualtsøket er på keyword
+ // kjør søk
+ SearchResult result = super.execute();
+
+ // 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();
+
+ while (iter.hasNext()) {
+ BasicSearchResultItem basicResultItem = (BasicSearchResultItem)
iter
+ .next();
+
+ CatalogueSearchResultItem resultItem = new
CatalogueSearchResultItem();
+ for (Object o : basicResultItem.getFieldNames()) {
+ String s = (String) o;
+ String v = basicResultItem.getField(s);
+ resultItem.addField(s, v);
+ }
+
+ nyResultListe.add(resultItem);
+ }
+
+ // fjern de gamle BasicResultItems, og erstatt dem med nye
+ // CatalogueResultItems.
+ result.getResults().clear();
+ result.getResults().addAll(nyResultListe);
+
+ return result;
+ }
+
+ @Override
+ public String getTransformedQuery() {
+ String query = super.getTransformedQuery();
+
+ if(query.equals("*") && (queryTwo==null || queryTwo.length()==0)){
+ return "";
+
+ }else if (queryTwo != null && queryTwo.length() > 0 &&
!query.equals("*")) {
+ query += ") " + QL_AND + " (" + queryTwo + ")";
+ query = "(" + query;
+
+ } else if (query.equals("*")) {
+ query = queryTwo;
+ }
+
+ return query;
+ }
+
+
+
+ @Override
+ protected String getSortBy() {
+ // hvis man søker etter firmanavn, sorterer vi etter "iyprpnavn"
+ // ellers søker vi etter keywords, og da sorterer vi etter "iyprpkw"
+ // istedet.
+ String sortBy = "iyprpkw";
+ if ("name".equalsIgnoreCase(userSortBy)
+ || "exact".equalsIgnoreCase(userSortBy)) {
+ sortBy = "iyprpnavn";
+ }
+ return sortBy;
+ }
+
+
+ /** TODO comment me. * */
+ protected void visitImpl(final LeafClause clause) {
+ boolean useTerm = true;
+
+ if(split && knownGeo.contains(clause.getTerm())){
+ useTerm=false;
+ }
+
+ if(useTerm){
+ if (!getTransformedTerms().get(clause).equals("*")) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("(");
+ sb.append("iypcfphnavn:" +
getTransformedTerms().get(clause)
+ + " ANY ");
+ sb.append("lemiypcfkeywords:" +
getTransformedTerms().get(clause)
+ + " ANY ");
+ sb.append("lemiypcfkeywordslow:"
+ + getTransformedTerms().get(clause));
+ sb.append(")");
+ appendToQueryRepresentation(sb.toString());
+ }
+ }
+ }
- private static final String DEBUG_CONF_NFO = "CatalogueSearch Conf
details --> ";
+ /**
+ * Legg til iypcfnavn forran alle ord.
+ *
+ */
+ protected void visitImpl(final PhraseClause clause) {
+ boolean useTerm = true;
+
+ if(split && knownGeo.contains(clause.getTerm())){
+ useTerm=false;
+ }
+
+ if(useTerm){
+ if (!getTransformedTerms().get(clause).equals("*")) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("(");
+ sb.append("iypcfnavn:" + getTransformedTerms().get(clause)
+ + " ANY ");
+ sb.append("lemiypcfkeywords:" +
getTransformedTerms().get(clause)
+ + " ANY ");
+ sb.append("lemiypcfkeywordslow:"
+ + getTransformedTerms().get(clause));
+ sb.append(")");
+ appendToQueryRepresentation(sb.toString());
+ }
+ }
+ }
- /**
- * Creates a new catalogue search command.
- *
- */
- public CatalogueSearchCommand(final Context cxt, final DataModel
datamodel) {
- super(cxt, datamodel);
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ protected void visitImpl(final DefaultOperatorClause clause) {
- final CatalogueSearchConfiguration conf =
(CatalogueSearchConfiguration) cxt
- .getSearchConfiguration();
- LOG.debug(DEBUG_CONF_NFO + conf.getSearchBy() + ' '
- + conf.getQueryParameterWhere());
+ clause.getFirstClause().accept(this);
+
+ final boolean hasKnownGeo = isKnownGeo(clause.getFirstClause()) ||
isKnownGeo(clause.getSecondClause());
+
+ if (!(hasKnownGeo || clause.getSecondClause() instanceof NotClause)) {
+ appendToQueryRepresentation(QL_AND);
+ }
- // 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"));
-
-
- GeoVisitor geo = new GeoVisitor();
- geo.visit(rq.getQuery().getRootClause());
+ clause.getSecondClause().accept(this);
+ }
+
+
+ /**
+ * Returns true iff the clause is a leaf clause and if it will not produce
any output in the query representation.
+ *
+ * @param clause The clause to examine.
+ *
+ * @return true iff leaf is empty.
+ */
+ private boolean isKnownGeo(final Clause clause) {
+ if(knownGeo==null) return false;
+
+ if (clause instanceof LeafClause) {
+ final LeafClause leafClause = (LeafClause) clause;
+ return knownGeo.contains(getTransformedTerm(clause));
+ } else {
+ return false;
+ }
+ }
+
+
- queryTwo = geo.getQueryRepresentation();
- LOG.info("Dette ble det: " + queryTwo);
- }
+ /**
+ * Query builder for creating a query syntax similar to sesam's own.
+ */
+ private final class GeoVisitor extends AbstractReflectionVisitor {
+
+ // AbstractReflectionVisitor overrides
+ // ----------------------------------------------
+ private final StringBuilder sb = new StringBuilder();
+
+ /**
+ * Returns the generated query.
+ *
+ * @return The query.
+ */
+ String getQueryRepresentation() {
+ return sb.toString();
+ }
+
+
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ protected void visitImpl(final LeafClause clause) {
+ if (clause.getTerm() != null && clause.getTerm().length() > 0) {
+ sb.append("iypcfgeo:" + clause.getTerm());
+ }
+ }
+
+ protected void visitImpl(final AndClause clause) {
+ clause.getFirstClause().accept(this);
+ if (!(clause.getSecondClause() instanceof NotClause)) {
+ sb.append(QL_AND);
+ }
+ clause.getSecondClause().accept(this);
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ protected void visitImpl(final OrClause clause) {
+ sb.append("(");
+ clause.getFirstClause().accept(this);
+
+ sb.append(QL_OR);
+
+ clause.getSecondClause().accept(this);
+ sb.append(")");
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ protected void visitImpl(final DefaultOperatorClause clause) {
+ clause.getFirstClause().accept(this);
+ if (!(clause.getSecondClause() instanceof NotClause)) {
+ sb.append(QL_AND);
+ }
+ clause.getSecondClause().accept(this);
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ protected void visitImpl(final NotClause clause) {
+
+ final String childsTerm = clause.getFirstClause().getTerm();
+ if (childsTerm != null && childsTerm.length() > 0) {
+ sb.append(QL_ANDNOT);
+ clause.getFirstClause().accept(this);
+ }
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ protected void visitImpl(final AndNotClause clause) {
+ // the first term can not be ANDNOT term.
+ if(sb.toString().trim().length()>0){
+ sb.append(QL_ANDNOT);
+ clause.getFirstClause().accept(this);
+ }
+ }
+
+ protected void visitImpl(final XorClause clause){
+ clause.getFirstClause().accept(this);
+ }
+ }
+
+
- if (getSingleParameter("userSortBy") != null
- && getSingleParameter("userSortBy").length() > 0
- &&
getSingleParameter("userSortBy").equals("name")) {
- userSortBy = "name";
- } else {
- userSortBy = "kw";
- }
+
+ /**
+ * Remove geographic places if present in what, if present in where.
+ */
+ private final class GeoZapperVisitor extends AbstractReflectionVisitor {
+
+ List knownGeo;
+
+ GeoZapperVisitor(List knownGeo){
+ this.knownGeo = knownGeo;
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ protected void visitImpl(final LeafClause clause) {
+
+ LOG.info("Split: "+split);
+ LOG.info("KnownGeo: "+knownGeo);
+ LOG.info("Clause: "+clause);
+ LOG.info("Term: "+clause.getTerm());
+ CatalogueSearchCommand.this.getTransformedTerms().put(clause,"");
+ }
- if ("exact".equals(conf.getSearchBy())) {
- userSortBy = "exact";
- }
- }
-
- /** TODO comment me. * */
- public SearchResult execute() {
- // kjør søk
- SearchResult result = super.execute();
-
- // 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();
-
- while (iter.hasNext()) {
- BasicSearchResultItem basicResultItem =
(BasicSearchResultItem) iter
- .next();
-
- CatalogueSearchResultItem resultItem = new
CatalogueSearchResultItem();
- for (Object o : basicResultItem.getFieldNames()) {
- String s = (String) o;
- String v = basicResultItem.getField(s);
- resultItem.addField(s, v);
- }
-
- nyResultListe.add(resultItem);
- }
-
- // fjern de gamle BasicResultItems, og erstatt dem med nye
- // CatalogueResultItems.
- result.getResults().clear();
- result.getResults().addAll(nyResultListe);
-
- return result;
- }
-
- @Override
- public String getTransformedQuery() {
- String query = super.getTransformedQuery();
-
- if(query.equals("*") && (queryTwo==null ||
queryTwo.length()==0)){
- return "";
-
- }else if (queryTwo != null && queryTwo.length() > 0 &&
!query.equals("*")) {
- query += ") " + QL_AND + " (" + queryTwo + ")";
- query = "(" + query;
-
- } else if (query.equals("*")) {
- query = queryTwo;
- }
-
- return query;
- }
-
-
-
- @Override
- protected String getSortBy() {
- // hvis man søker etter firmanavn, sorterer vi etter "iyprpnavn"
- // ellers søker vi etter keywords, og da sorterer vi etter
"iyprpkw"
- // istedet.
- String sortBy = "iyprpkw";
- if ("name".equalsIgnoreCase(userSortBy)
- || "exact".equalsIgnoreCase(userSortBy)) {
- sortBy = "iyprpnavn";
- }
- return sortBy;
- }
-
- /**
- * Query builder for creating a query syntax similar to sesam's own.
- */
- private final class GeoVisitor extends AbstractReflectionVisitor {
-
- // AbstractReflectionVisitor overrides
- // ----------------------------------------------
- private final StringBuilder sb = new StringBuilder();
-
- /**
- * Returns the generated query.
- *
- * @return The query.
- */
- String getQueryRepresentation() {
- return sb.toString();
- }
-
-
-
- /**
- * [EMAIL PROTECTED]
- */
- protected void visitImpl(final LeafClause clause) {
- if (clause.getTerm() != null &&
clause.getTerm().length() > 0) {
- sb.append("iypcfgeo:" + clause.getTerm());
- }
- }
-
- protected void visitImpl(final AndClause clause) {
- clause.getFirstClause().accept(this);
- if (!(clause.getSecondClause() instanceof NotClause)) {
- sb.append(QL_AND);
- }
- clause.getSecondClause().accept(this);
- }
-
- /**
- * [EMAIL PROTECTED]
- */
- protected void visitImpl(final OrClause clause) {
- sb.append("(");
- clause.getFirstClause().accept(this);
-
- sb.append(QL_OR);
-
- clause.getSecondClause().accept(this);
- sb.append(")");
- }
-
- /**
- * [EMAIL PROTECTED]
- */
- protected void visitImpl(final DefaultOperatorClause clause) {
- clause.getFirstClause().accept(this);
- if (!(clause.getSecondClause() instanceof NotClause)) {
- sb.append(QL_AND);
- }
- clause.getSecondClause().accept(this);
- }
-
- /**
- * [EMAIL PROTECTED]
- */
- protected void visitImpl(final NotClause clause) {
-
- final String childsTerm =
clause.getFirstClause().getTerm();
- if (childsTerm != null && childsTerm.length() > 0) {
- sb.append(QL_ANDNOT);
- clause.getFirstClause().accept(this);
- }
- }
-
- /**
- * [EMAIL PROTECTED]
- */
- protected void visitImpl(final AndNotClause clause) {
- // the first term can not be ANDNOT term.
- if(sb.toString().trim().length()>0){
- sb.append(QL_ANDNOT);
- clause.getFirstClause().accept(this);
- }
- }
-
- protected void visitImpl(final XorClause clause){
- clause.getFirstClause().accept(this);
- }
- }
+
+ protected void visitImpl(final AndClause clause) {
+ clause.getFirstClause().accept(this);
+ clause.getSecondClause().accept(this);
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ protected void visitImpl(final OrClause clause) {
+ clause.getFirstClause().accept(this);
+ clause.getSecondClause().accept(this);
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ protected void visitImpl(final DefaultOperatorClause clause) {
+ clause.getFirstClause().accept(this);
+ clause.getSecondClause().accept(this);
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ protected void visitImpl(final NotClause clause) {
+ final String childsTerm = clause.getFirstClause().getTerm();
+ if (childsTerm != null && childsTerm.length() > 0) {
+ clause.getFirstClause().accept(this);
+ }
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ protected void visitImpl(final AndNotClause clause) {
+ clause.getFirstClause().accept(this);
+ }
+
+ protected void visitImpl(final XorClause clause){
+ clause.getFirstClause().accept(this);
+ }
+ }
+
+
+
}
Modified:
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/config/CatalogueSearchConfiguration.java
===================================================================
---
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/config/CatalogueSearchConfiguration.java
2007-03-15 17:47:53 UTC (rev 4579)
+++
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/config/CatalogueSearchConfiguration.java
2007-03-16 10:24:48 UTC (rev 4580)
@@ -23,22 +23,30 @@
private String queryParameterWhere;
private String searchBy;
+ private Boolean split;
- public String getQueryParameterWhere() {
- return queryParameterWhere;
- }
+
+ public String getQueryParameterWhere() {
+ return queryParameterWhere;
+ }
- public void setQueryParameterWhere(String queryParameterWhere) {
- this.queryParameterWhere = queryParameterWhere;
- }
+ public void setQueryParameterWhere(String queryParameterWhere) {
+ this.queryParameterWhere = queryParameterWhere;
+ }
- public String getSearchBy() {
- return searchBy;
- }
+ public String getSearchBy() {
+ return searchBy;
+ }
- public void setSearchBy(String searchBy) {
- this.searchBy = searchBy;
- }
-
-
+ public void setSearchBy(String searchBy) {
+ this.searchBy = searchBy;
+ }
+
+ public void setSplit(Boolean split) {
+ this.split = split;
+ }
+
+ public Boolean getSplit(){
+ return this.split;
+ }
}
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-03-15 17:47:53 UTC (rev 4579)
+++
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/handler/CatalogueResultHandler.java
2007-03-16 10:24:48 UTC (rev 4580)
@@ -3,6 +3,7 @@
import java.util.Properties;
import javax.naming.InitialContext;
+import javax.naming.NamingException;
import no.schibstedsok.alfa.external.service.CompanyService;
import no.schibstedsok.commons.ioc.ContextWrapper;
import no.schibstedsok.searchportal.datamodel.DataModel;
@@ -17,11 +18,9 @@
/**
* 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.
+ * It calls a ejb3 stateless session bean in the sales system which load all
+ * productinformation to be presented in the infopage for katalog.
*
- * @todo Add code to Jboss EJB3 stateless bean in salesadmin.
- *
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Engfeldt</a>
* @version <tt>$Revision: 3436 $</tt>
*/
@@ -45,85 +44,103 @@
String url = (String) siteConf.getProperties().get(
"alfa_remote_service_url");
- String jndi = (String) siteConf.getProperties().get(
+
+ String jndi = (String) siteConf.getProperties().get(
"alfa_remote_service_jndi_name");
SearchResult searchResult = cxt.getSearchResult();
+
+ /**
+ * Denne resulthandlern skal hente ut informasjon om
+ * solgte produkter for infosiden, infosiden viser kun et
+ * firma, derfor tar vi bare å henter første objektet i
+ * listen og henter kjøpte produkter for denne.
+ */
if (searchResult.getResults().iterator().hasNext()) {
CatalogueSearchResultItem cat =
(CatalogueSearchResultItem) searchResult
.getResults().get(0);
- String sCompanyId = cat.getField("iypcompanyid");
+ String sCompanyId = cat.getField("iypcompanyid");
int intCompanyId = -1;
intCompanyId = Integer.valueOf(sCompanyId);
- // kall sl-bean i salesadmin with company id parameter.
- try {
- Properties properties = new Properties();
- properties.put("java.naming.factory.initial",
-
"org.jnp.interfaces.NamingContextFactory");
- properties.put("java.naming.factory.url.pkgs",
-
"org.jboss.naming:org.jnp.interfaces");
- properties.put("java.naming.provider.url", url);
+
+ ProductSearchResult internalResult = null;
+ no.schibstedsok.alfa.external.dto.ProductSearchResult
eksternt = null;
+
+ try {
+ Properties properties = new Properties();
+ properties.put("java.naming.factory.initial",
+
"org.jnp.interfaces.NamingContextFactory");
+ properties.put("java.naming.factory.url.pkgs",
+
"org.jboss.naming:org.jnp.interfaces");
+ properties.put("java.naming.provider.url", url);
- LOG.info("Url: " + url);
- LOG.info("JNDI_NAME: " + jndi);
- LOG.info("CompanyId: " + intCompanyId);
+ LOG.debug("Url: " + url);
+ LOG.debug("JNDI_NAME: " + jndi);
+ LOG.debug("CompanyId: " + intCompanyId);
- InitialContext ctx = new
InitialContext(properties);
- CompanyService service = (CompanyService)
ctx.lookup(jndi);
-
no.schibstedsok.alfa.external.dto.ProductSearchResult eksternt =
(no.schibstedsok.alfa.external.dto.ProductSearchResult) service
-
.getProductDataForCompany(intCompanyId);
+ InitialContext ctx = new
InitialContext(properties);
+
+ // hent ut remoteinterfacet til server side ejbn
vi vil kalle
+ CompanyService service = (CompanyService)
ctx.lookup(jndi);
+
+ // kall sl-bean i salesadmin with company id
parameter.
+ eksternt =
(no.schibstedsok.alfa.external.dto.ProductSearchResult) service
+
.getProductDataForCompany(intCompanyId);
+
+ } catch (NamingException ex) {
+ LOG.error("Jndi-lookup failed,
"+ex.getMessage(),ex);
+ }
- /**
- * Hent ut alle produkter som er lagt inn på
infosiden.
- *
- */
- ProductSearchResult internalResult = new
ProductSearchResult();
- if (eksternt.hasInfoPageProducts()) {
- for
(no.schibstedsok.alfa.external.dto.ProductResultItem prodItem : eksternt
- .getInfoPageProducts())
{
- ProductResultItem item = new
ProductSearchResultItem();
+
+
+ /**
+ * Hent ut alle produkter som er lagt inn på
infosiden.
+ */
+ internalResult = new ProductSearchResult();
+ if (eksternt.hasInfoPageProducts()) {
+ LOG.debug("Fant info page products, hent ut.");
+ for
(no.schibstedsok.alfa.external.dto.ProductResultItem prodItem : eksternt
+ .getInfoPageProducts()) {
+ ProductResultItem item = new
ProductSearchResultItem();
- if (prodItem.getFields().size()
> 0) {
-
item.setFields(prodItem.getFields());
- LOG.info("Field: " +
prodItem.getFields());
-
internalResult.addInfoPageResult(item);
- }
- }
- } else {
- LOG.info("Firmaet har ingen info page
produkter.");
- }
+ if (prodItem.getFields().size() > 0) {
+
item.setFields(prodItem.getFields());
+ LOG.info("Field: " +
prodItem.getFields());
+
internalResult.addInfoPageResult(item);
+ }
+ }
+ } else {
+ LOG.debug("Firmaet har ingen info page
produkter.");
+ }
- /**
- * Hent ut alle produkter som er lagt inn på
søkeresultatet.
- *
- */
- if (eksternt.hasListingProducts()) {
- for
(no.schibstedsok.alfa.external.dto.ProductResultItem prodItem : eksternt
- .getListingProducts()) {
- ProductResultItem item = new
ProductSearchResultItem();
+
+
+ /**
+ * Hent ut alle produkter som er lagt inn på
søkeresultatet.
+ *
+ */
+ if (eksternt.hasListingProducts()) {
+ LOG.debug("Fant listing page products, hent
ut.");
+ for
(no.schibstedsok.alfa.external.dto.ProductResultItem prodItem : eksternt
+ .getListingProducts()) {
+ ProductResultItem item = new
ProductSearchResultItem();
-
item.setFields(prodItem.getFields());
- if (prodItem.getFields().size()
> 0) {
- LOG.info("Field: " +
prodItem.getFields());
-
internalResult.addListingResult(item);
- }
+ item.setFields(prodItem.getFields());
+ if (prodItem.getFields().size() > 0) {
+ LOG.info("Field: " +
prodItem.getFields());
+
internalResult.addListingResult(item);
+ }
- }
- } else {
- LOG.info("Firmaet har ingen result page
produkter.");
- }
-
- cat.addProducts(internalResult);
-
- } catch (Exception e) {
- System.out.print(e); // What the Fuck?! you are
joking i hope.
- e.printStackTrace();
- }
+ }
+ } else {
+ LOG.debug("Firmaet har ingen result page
produkter.");
+ }
+ cat.addProducts(internalResult);
}
}
}
Modified:
trunk/query-transform-spi/src/main/java/no/schibstedsok/searchportal/query/transform/CatalogueQueryTransformer.java
===================================================================
---
trunk/query-transform-spi/src/main/java/no/schibstedsok/searchportal/query/transform/CatalogueQueryTransformer.java
2007-03-15 17:47:53 UTC (rev 4579)
+++
trunk/query-transform-spi/src/main/java/no/schibstedsok/searchportal/query/transform/CatalogueQueryTransformer.java
2007-03-16 10:24:48 UTC (rev 4580)
@@ -27,83 +27,6 @@
private static final Logger LOG = Logger
.getLogger(CatalogueQueryTransformer.class);
+
- /** TODO comment me. * */
- protected void visitImpl(final LeafClause clause) {
- if (!getTransformedTerms().get(clause).equals("*")) {
- StringBuilder sb = new StringBuilder();
- sb.append("(");
- sb.append("iypcfphnavn:" +
getTransformedTerms().get(clause)
- + " ANY ");
- sb.append("lemiypcfkeywords:" +
getTransformedTerms().get(clause)
- + " ANY ");
- sb.append("lemiypcfkeywordslow:"
- + getTransformedTerms().get(clause));
- sb.append(")");
- getContext().getTransformedTerms().put(clause,
sb.toString());
- }
- }
-
- /**
- * Legg til iypcfnavn forran alle ord.
- *
- */
- protected void visitImpl(final PhraseClause clause) {
-
- if (!getTransformedTerms().get(clause).equals("*")) {
- StringBuilder sb = new StringBuilder();
- sb.append("(");
- sb.append("iypcfnavn:" +
getTransformedTerms().get(clause)
- + " ANY ");
- sb.append("lemiypcfkeywords:" +
getTransformedTerms().get(clause)
- + " ANY ");
- sb.append("lemiypcfkeywordslow:"
- + getTransformedTerms().get(clause));
- sb.append(")");
- getContext().getTransformedTerms().put(clause,
sb.toString());
- }
- }
-
- private Map<Clause, String> getTransformedTerms() {
- return getContext().getTransformedTerms();
- }
-
- protected void visitImpl(final AndClause clause) {
- clause.getFirstClause().accept(this);
- clause.getSecondClause().accept(this);
- }
-
- /**
- * [EMAIL PROTECTED]
- */
- protected void visitImpl(final OrClause clause) {
- clause.getFirstClause().accept(this);
- clause.getSecondClause().accept(this);
- }
-
- /**
- * [EMAIL PROTECTED]
- */
- protected void visitImpl(final DefaultOperatorClause clause) {
- clause.getFirstClause().accept(this);
- clause.getSecondClause().accept(this);
- }
-
- /**
- * [EMAIL PROTECTED]
- */
- protected void visitImpl(final NotClause clause) {
-
- final String childsTerm = clause.getFirstClause().getTerm();
- if (childsTerm != null && childsTerm.length() > 0) {
- clause.getFirstClause().accept(this);
- }
- }
-
- /**
- * [EMAIL PROTECTED]
- */
- protected void visitImpl(final AndNotClause clause) {
- clause.getFirstClause().accept(this);
- }
}
Modified: trunk/war/pom.xml
===================================================================
--- trunk/war/pom.xml 2007-03-15 17:47:53 UTC (rev 4579)
+++ trunk/war/pom.xml 2007-03-16 10:24:48 UTC (rev 4580)
@@ -140,7 +140,40 @@
<groupId>axis</groupId>
<artifactId>axis-saaj</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>
</dependencies>
<profiles>
<profile>
_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits