svn commit: r508723 - in /ofbiz/trunk/applications/product: config/ src/org/ofbiz/product/product/ webapp/catalog/WEB-INF/ webapp/catalog/find/ widget/catalog/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r508723 - in /ofbiz/trunk/applications/product: config/ src/org/ofbiz/product/product/ webapp/catalog/WEB-INF/ webapp/catalog/find/ widget/catalog/

byersa-3
Author: byersa
Date: Fri Feb 16 23:57:29 2007
New Revision: 508723

URL: http://svn.apache.org/viewvc?view=rev&rev=508723
Log:
Not quite finished product export utility. Available off the keyword search page of the catalog manager

Added:
    ofbiz/trunk/applications/product/webapp/catalog/find/exportproducts.ftl
Modified:
    ofbiz/trunk/applications/product/config/ProductUiLabels.properties
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
    ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearch.ftl
    ofbiz/trunk/applications/product/widget/catalog/FindScreens.xml

Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.properties?view=diff&rev=508723&r1=508722&r2=508723
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductUiLabels.properties (original)
+++ ofbiz/trunk/applications/product/config/ProductUiLabels.properties Fri Feb 16 23:57:29 2007
@@ -178,6 +178,7 @@
 PageTitlePickListOptions=Pick List Options
 PageTitlePickingMoveStock=Picking : Move Stock
 PageTitlePickingViewStartedPicks=Picking : View Started Picks
+PageTitleProductExport=Product Export
 PageTitleQuickAddProductVariants=Quick Add Product Variants
 PageTitleSearchInventoryItems=Search Inventory Items
 PageTitleSearchResults=Search Results
@@ -1132,6 +1133,8 @@
 ProductScheduleTheseRouteSegments=Schedule These Route Segments
 ProductScheduling=Scheduling
 ProductSearchCatalog=Search Catalog
+ProductSearchExportProductList=Export Product List to Screen
+ProductSearchExport=Export
 ProductSearchFor=you searched for
 ProductSearchProducts=Search Products
 ProductSearchResultsFound=ID Value was the actual productId of this product.

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java?view=diff&rev=508723&r1=508722&r2=508723
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java Fri Feb 16 23:57:29 2007
@@ -19,6 +19,8 @@
 package org.ofbiz.product.product;
 
 import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
@@ -40,6 +42,7 @@
 import org.ofbiz.entity.transaction.GenericTransactionException;
 import org.ofbiz.entity.transaction.TransactionUtil;
 import org.ofbiz.entity.util.EntityListIterator;
+import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.product.product.ProductSearch.ProductSearchContext;
 import org.ofbiz.product.product.ProductSearch.ResultSortOrder;
 
@@ -208,6 +211,7 @@
            try {
 
                GenericValue searchResultView = null;
+               List searchResultList = new ArrayList();
                int numAdded = 0;
                while ((searchResultView = (GenericValue) eli.next()) != null) {
                    String productId = searchResultView.getString("productId");
@@ -378,6 +382,62 @@
             return "error";
         }
 
+        return "success";
+    }
+
+    /**  Formats the results of a search to the screen as a tab-delimited output
+     *@param request The HTTPRequest object for the current request
+     *@param response The HTTPResponse object for the current request
+     *@return String specifying the exit status of this event
+     */
+    public static String searchExportProductList(HttpServletRequest request, HttpServletResponse response) {
+        GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
+        String errMsg = null;
+        List productExportList = new ArrayList();
+
+        EntityListIterator eli = getProductSearchResults(request);
+        if (eli == null) {
+            errMsg = UtilProperties.getMessage(resource,"productsearchevents.no_results_found_probably_error_constraints", UtilHttp.getLocale(request));
+            request.setAttribute("_ERROR_MESSAGE_", errMsg);
+            return "error";
+        }
+
+        try {
+            boolean beganTransaction = TransactionUtil.begin();
+            try {
+
+                GenericValue searchResultView = null;
+                while ((searchResultView = (GenericValue) eli.next()) != null) {
+                    Map productMap = new HashMap();
+                    String productId = searchResultView.getString("productId");
+                    productMap.put("productId", productId);
+                    List productCategoriesRaw = delegator.findByAnd("ProductCategoryAndMember", UtilMisc.toMap("productId", productId));
+                    List productCategories = EntityUtil.filterByDate(productCategoriesRaw);
+                    productMap.put("productCategories", productCategories);
+                    List productFeaturesRaw = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId) );
+                    List productFeatures = EntityUtil.filterByDate(productFeaturesRaw);
+                    productMap.put("productFeatures", productFeatures);
+                    productExportList.add(productMap);
+                }
+                eli.close();
+                TransactionUtil.commit(beganTransaction);
+            } catch (GenericEntityException e) {
+                Map messageMap = UtilMisc.toMap("errSearchResult", e.toString());
+                errMsg = UtilProperties.getMessage(resource,"productsearchevents.error_getting_search_results", messageMap, UtilHttp.getLocale(request));
+                Debug.logError(e, errMsg, module);
+                request.setAttribute("_ERROR_MESSAGE_", errMsg);
+                TransactionUtil.rollback(beganTransaction, errMsg, e);
+                return "error";
+            }
+        } catch (GenericTransactionException e) {
+            Map messageMap = UtilMisc.toMap("errSearchResult", e.toString());
+            errMsg = UtilProperties.getMessage(resource,"productsearchevents.error_getting_search_results", messageMap, UtilHttp.getLocale(request));
+            Debug.logError(e, errMsg, module);
+            request.setAttribute("_ERROR_MESSAGE_", errMsg);
+            return "error";
+        }
+
+        request.setAttribute("productExportList", productExportList);
         return "success";
     }
 

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml?view=diff&rev=508723&r1=508722&r2=508723
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml Fri Feb 16 23:57:29 2007
@@ -147,6 +147,12 @@
         <response name="success" type="view" value="keywordsearch"/>
         <response name="error" type="view" value="keywordsearch"/>
     </request-map>
+    <request-map uri="searchExportProductList">
+        <security https="true" auth="true"/>
+        <event type="java" path="org.ofbiz.product.product.ProductSearchEvents" invoke="searchExportProductList"/>
+        <response name="success" type="view" value="exportproducts"/>
+        <response name="error" type="view" value="exportproducts"/>
+    </request-map>
 
     <request-map uri="FindProductById">
         <security https="true" auth="true"/>
@@ -2295,6 +2301,7 @@
 
     <view-map name="advancedsearch" type="screen" page="component://product/widget/catalog/FindScreens.xml#advancedsearch"/>
     <view-map name="keywordsearch" type="screen" page="component://product/widget/catalog/FindScreens.xml#keywordsearch"/>
+    <view-map name="exportproducts" type="screen" page="component://product/widget/catalog/FindScreens.xml#exportproducts"/>
     <view-map name="FindProductById" type="screen" page="component://product/widget/catalog/FindScreens.xml#FindProductById"/>
 
     <view-map name="EditCategory" type="screen" page="component://product/widget/catalog/CategoryScreens.xml#EditCategory"/>

Added: ofbiz/trunk/applications/product/webapp/catalog/find/exportproducts.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/find/exportproducts.ftl?view=auto&rev=508723
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/find/exportproducts.ftl (added)
+++ ofbiz/trunk/applications/product/webapp/catalog/find/exportproducts.ftl Fri Feb 16 23:57:29 2007
@@ -0,0 +1,20 @@
+<#--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+--><#list productExportList as productExportMap><#assign productCategoryCount=0/><#assign productFeatureCount=0/>
+${productExportMap.productId} <#list productExportMap.productCategories as productCategoryAndMember><#if productCategoryAndMember.categoryName?has_content><#if productCategoryCount &gt; 0>,</#if>${productCategoryAndMember.categoryName}<#assign productCategoryCount=productCategoryCount + 1/></#if></#list> <#list productExportMap.productFeatures as productFeatureAndAppl><#if productFeatureAndAppl.description?has_content><#if productFeatureCount &gt; 0>,</#if>${productFeatureAndAppl.description}<#assign productFeatureCount=productFeatureCount + 1/></#if></#list>
+</#list>
\ No newline at end of file

Modified: ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearch.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearch.ftl?view=diff&rev=508723&r1=508722&r2=508723
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearch.ftl (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearch.ftl Fri Feb 16 23:57:29 2007
@@ -184,4 +184,12 @@
   <input type="submit" value="${uiLabelMap.ProductRemoveFeature}" class="smallSubmit"><br/>
 </form>
 </div>
+<hr class="sepbar"/>
+<div class="tabletext">
+<form method="post" action="<@ofbizUrl>searchExportProductList</@ofbizUrl>" name="searchRemoveFeature">
+  <b>${uiLabelMap.ProductSearchExportProductList}:</b>
+  <input type="hidden" name="clearSearch" value="N">
+  <input type="submit" value="${uiLabelMap.ProductSearchExport}" class="smallSubmit"><br/>
+</form>
+</div>
 </#if>

Modified: ofbiz/trunk/applications/product/widget/catalog/FindScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/FindScreens.xml?view=diff&rev=508723&r1=508722&r2=508723
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/FindScreens.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/FindScreens.xml Fri Feb 16 23:57:29 2007
@@ -90,6 +90,19 @@
             </widgets>
         </section>
     </screen>
+    <screen name="exportproducts">
+        <section>
+            <actions>
+                <set field="titleProperty" value="PageTitleProductExport"/>
+                <set field="productExportList" from-field="parameters.productExportList"/>
+            </actions>
+            <widgets>
+                         <platform-specific>
+                              <html><html-template location="component://product/webapp/catalog/find/exportproducts.ftl"/></html>
+                         </platform-specific>
+            </widgets>
+        </section>
+    </screen>
 
     <screen name="FindProductById">
         <section>