[pal-cvs 2798] [542] language support

svnno****@sourc***** svnno****@sourc*****
2007年 9月 6日 (木) 16:45:26 JST


Revision: 542
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=542
Author:   shinsuke
Date:     2007-09-06 16:45:26 +0900 (Thu, 06 Sep 2007)

Log Message:
-----------
language support

Modified Paths:
--------------
    pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/admin/product/ProductListPage.java
    pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductListAction.java
    pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductListPage.java


-------------- next part --------------
Modified: pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/admin/product/ProductListPage.java
===================================================================
--- pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/admin/product/ProductListPage.java	2007-09-06 03:47:37 UTC (rev 541)
+++ pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/admin/product/ProductListPage.java	2007-09-06 07:45:26 UTC (rev 542)
@@ -5,6 +5,7 @@
 import java.util.List;
 import java.util.Map;
 
+import jp.sf.pal.pompei.PompeiConstants;
 import jp.sf.pal.pompei.exentity.ProductsDescription;
 import jp.sf.pal.pompei.service.LanguageService;
 
@@ -305,7 +306,7 @@
     public String getProductsDefaultName() {
         if (productsItems != null && productsIndex < productsItems.size()) {
             List<ProductsDescription> list = (List<ProductsDescription>) productsItems
-                    .get(productsIndex).get("productsDescriptionList");
+                    .get(productsIndex).get(PompeiConstants.PRODUCTS_DESCRIPTION_LIST);
             if (list != null) {
                 for (ProductsDescription pd : list) {
                     BigDecimal languagesId = getLanguageService()

Modified: pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductListAction.java
===================================================================
--- pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductListAction.java	2007-09-06 03:47:37 UTC (rev 541)
+++ pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductListAction.java	2007-09-06 07:45:26 UTC (rev 542)
@@ -7,10 +7,13 @@
 import java.util.List;
 import java.util.Map;
 
+import org.seasar.teeda.extension.util.LabelHelper;
+
 import jp.sf.pal.pompei.PompeiConstants;
 import jp.sf.pal.pompei.dxo.CategoriesDxo;
 import jp.sf.pal.pompei.dxo.ProductDxo;
 import jp.sf.pal.pompei.exentity.CategoriesDescription;
+import jp.sf.pal.pompei.exentity.Products;
 import jp.sf.pal.pompei.service.CategoryService;
 import jp.sf.pal.pompei.service.ProductService;
 
@@ -38,6 +41,22 @@
     /**	 */
     private CategoriesDxo categoriesDxo;
 
+    private LabelHelper labelHelper;
+
+    /**
+    * @return labelHelper
+    */
+    public LabelHelper getLabelHelper() {
+        return labelHelper;
+    }
+
+    /**
+     * @param labelHelper 設定する labelHelper
+     */
+    public void setLabelHelper(LabelHelper labelHelper) {
+        this.labelHelper = labelHelper;
+    }
+
     public Class<?> initialize() {
         return null;
     }
@@ -50,10 +69,11 @@
         if (productListPage.getBreadcrumbItems() == null) {
             productListPage.setCategoriesId(new BigDecimal("0"));
 
-            List<Map> list = new ArrayList<Map>();
+            List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
             Map<String, Object> m = new HashMap<String, Object>();
             m.put(PompeiConstants.CATEGORIES_ID, new BigDecimal("0"));
-            m.put(PompeiConstants.BREADCRUMB, "TOP");
+            m.put(PompeiConstants.BREADCRUMB, getLabelHelper().getLabelValue(
+                    PompeiConstants.TOP_CATEGORY));
             list.add(m);
             productListPage.setBreadcrumbItems(list);
 
@@ -63,19 +83,19 @@
             }
 
             //パンくずリストを再セット
-            List list = setBreadcrumb(productListPage.getBreadcrumbItems(),
-                    productListPage.getParentId());
+            List<Map<String, Object>> list = setBreadcrumb(productListPage
+                    .getBreadcrumbItems(), productListPage.getParentId());
             productListPage.setBreadcrumbItems(list);
         }
 
         //カテゴリ一覧の取得
-        List cList = getCategoriesList();
+        List<Map<String, Object>> cList = getCategoriesList();
         productListPage.setCategoryItems(cList);
 
         //商品一覧の取得
-        List list = productService.getProductsList(productListPage
+        List<Products> list = productService.getProductsList(productListPage
                 .getParentId());
-        List sList = new ArrayList();
+        List<Map<String, Object>> sList = new ArrayList<Map<String, Object>>();
         productDxo.convert(list, sList);
         productListPage.setProductItems(sList);
 
@@ -88,9 +108,10 @@
      * @param id
      * @return
      */
-    private List<Map> setBreadcrumb(List<Map> breadcrumbItems, BigDecimal id) {
-        List<Map> list = new ArrayList<Map>();
-        for (Map m : breadcrumbItems) {
+    private List<Map<String, Object>> setBreadcrumb(
+            List<Map<String, Object>> breadcrumbItems, BigDecimal id) {
+        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
+        for (Map<String, Object> m : breadcrumbItems) {
             list.add(m);
             if (((BigDecimal) m.get(PompeiConstants.CATEGORIES_ID)).equals(id)) {
                 return list;
@@ -99,17 +120,17 @@
         CategoriesDescription d = categoryService
                 .getCategoriesDescription(productListPage.getCategoriesId());
 
-        Map m = new HashMap();
+        Map<String, Object> m = new HashMap<String, Object>();
         m.put(PompeiConstants.CATEGORIES_ID, id);
         m.put(PompeiConstants.BREADCRUMB, d.getCategoriesName());
         list.add(m);
         return list;
     }
 
-    private List getCategoriesList() {
-        List list = categoryService.getSubCategoryList(productListPage
-                .getParentId());
-        List cList = new ArrayList();
+    private List<Map<String, Object>> getCategoriesList() {
+        List<CategoriesDescription> list = categoryService
+                .getSubCategoryList(productListPage.getParentId());
+        List<Map<String, Object>> cList = new ArrayList<Map<String, Object>>();
         categoriesDxo.convert(list, cList);
         return cList;
     }

Modified: pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductListPage.java
===================================================================
--- pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductListPage.java	2007-09-06 03:47:37 UTC (rev 541)
+++ pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductListPage.java	2007-09-06 07:45:26 UTC (rev 542)
@@ -3,12 +3,17 @@
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 
+import jp.sf.pal.pompei.PompeiConstants;
 import jp.sf.pal.pompei.exentity.ProductsDescription;
+import jp.sf.pal.pompei.service.LanguageService;
 import jp.sf.pal.pompei.util.UrlBuilderUtil;
 
 import org.seasar.teeda.extension.annotation.scope.SubapplicationScope;
 
+import com.sun.java_cup.internal.production;
+
 public class ProductListPage implements Serializable {
 
     /**
@@ -25,30 +30,30 @@
     /** 改行ポイント*/
     //	private boolean breakPoint;
     @SubapplicationScope
-    private List breadcrumbItems;
+    private List<Map<String, Object>> breadcrumbItems;
 
     private String categoriesName;
 
     private int categoryIndex;
 
     @SubapplicationScope
-    private List categoryItems;
+    private List<Map<String, Object>> categoryItems;
 
     @SubapplicationScope
     private BigDecimal parentId;
 
     private int productIndex;
 
-    private List productItems;
+    private List<Map<String, Object>> productItems;
 
     private BigDecimal productsId;
 
-    private String productsName;
-
     private BigDecimal productsPrice;
 
     private String title;
 
+    private LanguageService languageService;
+
     public String getBreadcrumb() {
         return breadcrumb;
     }
@@ -65,11 +70,11 @@
         this.breadcrumbIndex = breadcrumbIndex;
     }
 
-    public List getBreadcrumbItems() {
+    public List<Map<String, Object>> getBreadcrumbItems() {
         return breadcrumbItems;
     }
 
-    public void setBreadcrumbItems(List breadcrumbItems) {
+    public void setBreadcrumbItems(List<Map<String, Object>> breadcrumbItems) {
         this.breadcrumbItems = breadcrumbItems;
     }
 
@@ -89,11 +94,11 @@
         this.categoryIndex = categoryIndex;
     }
 
-    public List getCategoryItems() {
+    public List<Map<String, Object>> getCategoryItems() {
         return categoryItems;
     }
 
-    public void setCategoryItems(List categoryItems) {
+    public void setCategoryItems(List<Map<String, Object>> categoryItems) {
         this.categoryItems = categoryItems;
     }
 
@@ -113,22 +118,14 @@
         this.productIndex = productIndex;
     }
 
-    public List getProductItems() {
+    public List<Map<String, Object>> getProductItems() {
         return productItems;
     }
 
-    public void setProductItems(List productItems) {
+    public void setProductItems(List<Map<String, Object>> productItems) {
         this.productItems = productItems;
     }
 
-    public String getProductsName() {
-        return productsName;
-    }
-
-    public void setProductsName(String productsName) {
-        this.productsName = productsName;
-    }
-
     public BigDecimal getProductsPrice() {
         return productsPrice;
     }
@@ -153,14 +150,14 @@
         this.categoriesId = categoriesId;
     }
 
-    public void setDescriptionList(List list) {
-        if (list != null && list.size() > 0) {
-            this.productsName = ((ProductsDescription) list.get(0))
-                    .getProductsName();
-        } else {
-            this.productsName = "";
-        }
-    }
+    //    public void setDescriptionList(List list) {
+    //        if (list != null && list.size() > 0) {
+    //            this.productsName = ((ProductsDescription) list.get(0))
+    //                    .getProductsName();
+    //        } else {
+    //            this.productsName = "";
+    //        }
+    //    }
 
     public boolean isBreakPoint() {
         if (productIndex % 4 == 0) {
@@ -180,8 +177,39 @@
     public String getCartLinkHref() {
         return UrlBuilderUtil.createCartUrl();
     }
+
     //	public void setBreakPoint(boolean test) {
     //		this.breakPoint = test;
     //	}
 
+    /**
+     * @return languageService
+     */
+    public LanguageService getLanguageService() {
+        return languageService;
+    }
+
+    /**
+     * @param languageService 設定する languageService
+     */
+    public void setLanguageService(LanguageService languageService) {
+        this.languageService = languageService;
+    }
+
+    public String getProductsName() {
+        if (productItems != null && productIndex < productItems.size()) {
+            List<ProductsDescription> list = (List<ProductsDescription>) productItems
+                    .get(productIndex).get(
+                            PompeiConstants.PRODUCTS_DESCRIPTION_LIST);
+            for (ProductsDescription pd : list) {
+                BigDecimal languagesId = getLanguageService()
+                        .getCurrentLanguage().getLanguagesId();
+                if (pd.getLanguageId().equals(languagesId)) {
+                    return pd.getProductsName();
+                }
+            }
+            // TODO need default lang?
+        }
+        return "-";
+    }
 }


pal-cvs メーリングリストの案内