Author: stianh
Date: 2007-02-21 11:25:37 +0100 (Wed, 21 Feb 2007)
New Revision: 4489

Modified:
   
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/CatalogueSearchResultItem.java
Log:
GULD-216 added utility methods.


Modified: 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/CatalogueSearchResultItem.java
===================================================================
--- 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/CatalogueSearchResultItem.java
     2007-02-20 11:23:03 UTC (rev 4488)
+++ 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/result/CatalogueSearchResultItem.java
     2007-02-21 10:25:37 UTC (rev 4489)
@@ -1,3 +1,6 @@
+/*
+ * $Id:$
+ */
 // Copyright (2006) Schibsted Søk AS
 package no.schibstedsok.searchportal.result;
 
@@ -9,18 +12,174 @@
  */
 public class CatalogueSearchResultItem extends BasicSearchResultItem {
 
+       /**
+        * TODO: javadoc.
+        */
     private ProductResult products = null;
 
-    public void addProducts(ProductResult products) {
+    /**
+     * TODO javadoc.
+     * @param products
+     */
+    public void addProducts(final ProductResult products) {
        this.products = products;
     }
     
+    /**
+     * TODO javadoc.
+     * @return
+     */
     public boolean hasProducts(){
        return this.products != null ? true : false;
     }
     
+    /**
+     * TODO  javadoc.
+     * @return
+     */
     public ProductResult getProducts(){
        return this.products;
     }
     
+    /**
+     * Utility method for checking if the entry belongs to a paying customer.
+     * @return true if the result item is an entry for a paying customer.
+     */
+    public boolean isCommercial(){
+       String productPackage = getField("iyppakke");
+       if(productPackage != null && productPackage.length() > 0){
+               return true;
+       }
+       return false;
+    }
+    
+    /**
+     * Responsible for getting the phone number to display for this result 
item.
+     * @return The phone number to display for this result item.
+     */
+    public String getPhoneNumber(){
+       String phoneNumber = getField("iypnrtelefon");
+       if(phoneNumber != null && phoneNumber.length() > 0){
+               return phoneNumber;
+       }
+       phoneNumber = getField("iypnrtelefonandre");
+       
+       if(phoneNumber != null && phoneNumber.length() > 0){
+               return phoneNumber.replace(";", "");
+       }
+       return null;
+    }
+    
+    /**
+     * Returns a description of the result item. 
+     * @return  a description of the result item.
+     */
+    public String getCompanyDescription(){
+       if(!isCommercial()){
+               return null;
+       }
+       
+       String description = getField("iyplogotekst");
+       
+       if(description != null && description.length() > 0){
+               return description;
+       }
+       return null;
+    }
+    
+    /**
+     * Returns the url for the logo to display for this result item.
+     * @return URL for the logo to display.
+     */
+    public String getLogoURL(){
+       //TODO: check product
+       if(!isCommercial()){
+               return null;
+       }
+       
+       final String logoURL = getField("iyplogourl");
+       if(logoURL != null && logoURL.length() > 0){
+               return logoURL;
+       }
+       return null;
+    }
+    
+    /**
+     * Returns the address for for this result item.
+     * @return The address in format: street, zipcode city.
+     */
+    public String getAddress(){
+       
+       String address = getField("iypadresse");
+       String zipCode = getField("iyppostnr");
+       String city = getField("iypstedsnavn");
+       
+       StringBuffer compositAddress = new StringBuffer();
+       if(address != null && address.length() > 0){
+               compositAddress.append(address);
+               compositAddress.append(", ");
+       }
+       
+       if(zipCode != null && zipCode.length() > 0){
+               compositAddress.append(zipCode);
+       }
+       
+       if(city != null && city.length() > 0){
+               compositAddress.append(" ");
+               compositAddress.append(city);
+       }
+       
+       if(compositAddress.length() > 0){
+               return compositAddress.toString();
+       }
+       return null;
+    }
+    
+    public String getEmailAddress(){
+       //TODO: check product.
+       if(!isCommercial()){
+               return null;
+       }
+       
+       String email = getField("iypepost");
+       if(email != null && email.length() > 0){
+               return email;
+       }
+       return null;
+    }
+    
+    /**
+     * Returns the url of the homepage for this result item.
+     * @return The URL of the homepage for a paying customer.
+     */
+    public String getHomePageURL(){
+       if(!isCommercial()){
+               return null;
+       }
+       //TODO: check product.
+       String homePageURL = getField("iypurl");
+       if(homePageURL != null && homePageURL.length() > 0){
+               return homePageURL;
+       }
+       return null;
+    }
+    
+    /**
+     * Returns a string with opening hours.
+     * @return the opening hours, or null if its not available.
+     */
+    public String getOpeningHours(){
+       //TODO: check product.
+       //åpningstider er lenke til infosiden dersom denne inneholder 
åpningstider (er kjøpt OG lagt inn)
+       return null;
+    }
+    
+    /**
+     * Checks if the result item should be rendered with a bold title.
+     * @return true if the product has bold title.
+     */
+    public boolean isBoldTitle(){
+       //TODO: check rules for product;
+       return isCommercial();
+    }
 }

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

Reply via email to