svn commit: r664482 - in /ofbiz/trunk/applications/product: webapp/catalog/WEB-INF/ webapp/catalog/WEB-INF/actions/category/ webapp/catalog/WEB-INF/actions/lookup/ 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: r664482 - in /ofbiz/trunk/applications/product: webapp/catalog/WEB-INF/ webapp/catalog/WEB-INF/actions/category/ webapp/catalog/WEB-INF/actions/lookup/ widget/catalog/

mrisaliti
Author: mrisaliti
Date: Sun Jun  8 04:08:56 2008
New Revision: 664482

URL: http://svn.apache.org/viewvc?rev=664482&view=rev
Log:
Converted createProductInCategoryCheckExisting.bsh/EditCategory.bsh/EditCategoryProducts.bsh/LookupVariantProduct.bsh to groovy (Part of issue OFBIZ-1801)

Added:
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/CreateProductInCategoryCheckExisting.groovy
      - copied unchanged from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/createProductInCategoryCheckExisting.bsh
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy
      - copied, changed from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.bsh
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategoryProducts.groovy
      - copied, changed from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategoryProducts.bsh
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/lookup/LookupVariantProduct.groovy
      - copied, changed from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/lookup/LookupVariantProduct.bsh
Removed:
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.bsh
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategoryProducts.bsh
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/createProductInCategoryCheckExisting.bsh
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/lookup/LookupVariantProduct.bsh
Modified:
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
    ofbiz/trunk/applications/product/widget/catalog/CategoryScreens.xml
    ofbiz/trunk/applications/product/widget/catalog/LookupScreens.xml

Copied: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy (from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.bsh)
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy?p2=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy&p1=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.bsh&r1=664476&r2=664482&rev=664482&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.bsh (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy Sun Jun  8 04:08:56 2008
@@ -17,38 +17,37 @@
  * under the License.
  */
 
-import org.ofbiz.base.util.*;
-import org.ofbiz.base.util.string.*;
-import org.ofbiz.entity.*;
+import org.ofbiz.base.util.*
+import org.ofbiz.base.util.string.*
 
 productCategoryType = null;
-if (productCategory != null) {
+if (productCategory) {
     productCategoryType = productCategory.getRelatedOne("ProductCategoryType");
-    context.put("productCategoryType", productCategoryType);
+    context.productCategoryType = productCategoryType;
 }
 
 primaryParentCategory = null;
 primParentCatIdParam = request.getParameter("primaryParentCategoryId");
-if(productCategory != null) {
+if(productCategory) {
     primaryParentCategory = productCategory.getRelatedOne("PrimaryParentProductCategory");
-} else if (primParentCatIdParam != null && primParentCatIdParam.length() > 0) {
-    primaryParentCategory = delegator.findByPrimaryKey("ProductCategory", UtilMisc.toMap("productCategoryId", primParentCatIdParam));
+} else if (primParentCatIdParam && primParentCatIdParam.length() > 0) {
+    primaryParentCategory = delegator.findOne("ProductCategory", [productCategoryId : primParentCatIdParam], false);
 }
-context.put("primaryParentCategory", primaryParentCategory);
+context.primaryParentCategory = primaryParentCategory;
 
 
 // make the image file formats
 String imageFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format");
 String imageServerPath = UtilProperties.getPropertyValue("catalog", "image.server.path");
 String imageUrlPrefix = UtilProperties.getPropertyValue("catalog", "image.url.prefix");
-context.put("imageFilenameFormat", imageFilenameFormat);
-context.put("imageServerPath", imageServerPath);
-context.put("imageUrlPrefix", imageUrlPrefix);
+context.imageFilenameFormat = imageFilenameFormat;
+context.imageServerPath = imageServerPath;
+context.imageUrlPrefix = imageUrlPrefix;
 
 FlexibleStringExpander filenameExpander = new FlexibleStringExpander(imageFilenameFormat);
-context.put("imageNameCategory", imageUrlPrefix + "/" + filenameExpander.expandString(UtilMisc.toMap("location","categories", "type", "category", "id", productCategoryId)));
-context.put("imageNameLinkOne", imageUrlPrefix + "/" + filenameExpander.expandString(UtilMisc.toMap("location","categories", "type", "linkOne", "id", productCategoryId)));
-context.put("imageNameLinkTwo", imageUrlPrefix + "/" + filenameExpander.expandString(UtilMisc.toMap("location","categories", "type", "linkTwo", "id", productCategoryId)));
+context.imageNameCategory = imageUrlPrefix + "/" + filenameExpander.expandString([location : "categories", type : "category", id : productCategoryId]);
+context.imageNameLinkOne  = imageUrlPrefix + "/" + filenameExpander.expandString([location : "categories", type : "linkOne", id : productCategoryId]);
+context.imageNameLinkTwo  = imageUrlPrefix + "/" + filenameExpander.expandString([location : "categories", type : "linkTwo", id : productCategoryId]);
 
 
 // UPLOADING STUFF
@@ -56,10 +55,10 @@
 Object forLock = new Object();
 String contentType = null;
 String fileType = request.getParameter("upload_file_type");
-if (fileType != null) {
-    context.put("fileType", fileType);
+if (fileType) {
+    context.fileType = fileType;
 
-    String fileLocation = filenameExpander.expandString(UtilMisc.toMap("location", "categories", "type", fileType, "id", productCategoryId));
+    String fileLocation = filenameExpander.expandString([location : "categories", type : fileType, id : productCategoryId]);
     String filePathPrefix = "";
     String filenameToUse = fileLocation;
     if (fileLocation.lastIndexOf("/") != -1) {
@@ -68,7 +67,7 @@
     }
 
     int i1;
-    if (contentType != null && (i1 = contentType.indexOf("boundary=")) != -1) {
+    if (contentType && (i1 = contentType.indexOf("boundary=")) != -1) {
         contentType = contentType.substring(i1 + 9);
         contentType = "--" + contentType;
     }
@@ -80,17 +79,19 @@
     uploadObject.doUpload(request);
 
     String clientFileName = uploadObject.getFilename();
-    if (clientFileName != null) context.put("clientFileName", clientFileName);
+    if (clientFileName) {
+        context.clientFileName = clientFileName;
+    }
 
-    if (clientFileName != null && clientFileName.length() > 0) {
+    if (clientFileName && clientFileName.length() > 0) {
         if (clientFileName.lastIndexOf(".") > 0 && clientFileName.lastIndexOf(".") < clientFileName.length()) {
             filenameToUse += clientFileName.substring(clientFileName.lastIndexOf("."));
         } else {
             filenameToUse += ".jpg";
         }
 
-        context.put("clientFileName", clientFileName);
-        context.put("filenameToUse", filenameToUse);
+        context.clientFileName = clientFileName;
+        context.filenameToUse = filenameToUse;
 
         String characterEncoding = request.getCharacterEncoding();
         String imageUrl = imageUrlPrefix + "/" + filePathPrefix + java.net.URLEncoder.encode(filenameToUse, characterEncoding);
@@ -108,10 +109,10 @@
             e.printStackTrace();
         }
 
-        if (imageUrl != null && imageUrl.length() > 0) {
-            context.put("imageUrl", imageUrl);
+        if (imageUrl && imageUrl.length() > 0) {
+            context.imageUrl = imageUrl;
             productCategory.set(fileType + "ImageUrl", imageUrl);
             productCategory.store();
         }
     }
-}
+}
\ No newline at end of file

Copied: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategoryProducts.groovy (from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategoryProducts.bsh)
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategoryProducts.groovy?p2=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategoryProducts.groovy&p1=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategoryProducts.bsh&r1=664476&r2=664482&rev=664482&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategoryProducts.bsh (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/category/EditCategoryProducts.groovy Sun Jun  8 04:08:56 2008
@@ -17,32 +17,27 @@
  * under the License.
  */
 
-import org.ofbiz.base.util.*;
-import org.ofbiz.entity.*;
-import org.ofbiz.entity.util.*;
-import org.ofbiz.entity.model.*;
-import org.ofbiz.entity.condition.*;
-import org.ofbiz.entity.transaction.*;
+import org.ofbiz.base.util.*
 
 //default this to true, ie only show active
-boolean activeOnly = !"false".equals(request.getParameter("activeOnly"));
-context.put("activeOnly", activeOnly);
+activeOnly = !"false".equals(request.getParameter("activeOnly"));
+context.activeOnly = activeOnly;
 
-paramInMap = new HashMap();
-paramInMap.put("productCategoryId", UtilFormatOut.checkNull(request.getParameter("productCategoryId")));
-paramInMap.put("defaultViewSize", 20);
-paramInMap.put("limitView", true);
-paramInMap.put("useCacheForMembers", false);
-paramInMap.put("checkViewAllow", false);
-paramInMap.put("activeOnly", activeOnly);
-paramInMap.put("viewIndexString", parameters.get("VIEW_INDEX"));
-paramInMap.put("viewSizeString", parameters.get("VIEW_SIZE"));
+paramInMap = [:];
+paramInMap.productCategoryId = UtilFormatOut.checkNull(request.getParameter("productCategoryId"));
+paramInMap.defaultViewSize = 20;
+paramInMap.limitView = true;
+paramInMap.useCacheForMembers = false;
+paramInMap.checkViewAllow = false;
+paramInMap.activeOnly = activeOnly;
+paramInMap.viewIndexString = parameters.get("VIEW_INDEX");
+paramInMap.viewSizeString = parameters.get("VIEW_SIZE");
 
 // Returns: viewIndex, viewSize, lowIndex, highIndex, listSize, productCategory, productCategoryMembers
 outMap = dispatcher.runSync("getProductCategoryAndLimitedMembers", paramInMap);
-context.put("viewIndex", outMap.get("viewIndex"));
-context.put("viewSize", outMap.get("viewSize"));
-context.put("lowIndex", outMap.get("lowIndex"));
-context.put("highIndex", outMap.get("highIndex"));
-context.put("listSize", outMap.get("listSize"));
-context.put("productCategoryMembers", outMap.get("productCategoryMembers"));
+context.viewIndex = outMap.viewIndex;
+context.viewSize = outMap.viewSize;
+context.lowIndex = outMap.lowIndex;
+context.highIndex = outMap.highIndex;
+context.listSize = outMap.listSize;
+context.productCategoryMembers = outMap.productCategoryMembers;
\ No newline at end of file

Copied: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/lookup/LookupVariantProduct.groovy (from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/lookup/LookupVariantProduct.bsh)
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/lookup/LookupVariantProduct.groovy?p2=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/lookup/LookupVariantProduct.groovy&p1=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/lookup/LookupVariantProduct.bsh&r1=664476&r2=664482&rev=664482&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/lookup/LookupVariantProduct.bsh (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/lookup/LookupVariantProduct.groovy Sun Jun  8 04:08:56 2008
@@ -17,68 +17,65 @@
  * under the License.
  */
 
-import java.util.*;
 import org.ofbiz.base.util.*;
 
-delegator = request.getAttribute("delegator");
-dispatcher = request.getAttribute("dispatcher");
-security = request.getAttribute("security");
-
 productId = request.getParameter("productId");
 productVariantId = productId + "_";
 productFeatureIds = "";
-product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
+product = delegator.findOne("Product", [productId : productId], false);
 
-result = dispatcher.runSync("getProductFeaturesByType", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "SELECTABLE_FEATURE"));
+result = dispatcher.runSync("getProductFeaturesByType", [productId : productId, productFeatureApplTypeId : "SELECTABLE_FEATURE"]);
 featureTypes = result.get("productFeatureTypes");
 featuresByTypes = result.get("productFeaturesByType");
-searchFeatures = new ArrayList();
-selectedFeatureTypeValues = new ArrayList();
-for (int i = 0; i < featureTypes.size(); i++) {
-    featureType = featureTypes.get(i);
-    featuresByType = featuresByTypes.get(featureType);
-    featureTypeAndValues = UtilMisc.toMap("featureType", featureType, "features", featuresByType);
-    searchFeatures.add(featureTypeAndValues);
-    //
-    selectedFeatureTypeValue = request.getParameter(featureType);
-    if (selectedFeatureTypeValue != null && selectedFeatureTypeValue.length() > 0) {
-        featureTypeAndValues.put("selectedFeatureId", selectedFeatureTypeValue);
-        selectedFeatureTypeValues.add(selectedFeatureTypeValue);
-        feature = delegator.findByPrimaryKey("ProductFeature", UtilMisc.toMap("productFeatureId", selectedFeatureTypeValue));
-        productVariantId += (feature.getString("idCode") != null? feature.getString("idCode"): "");
-        productFeatureIds += "|" + selectedFeatureTypeValue;
+searchFeatures = [];
+selectedFeatureTypeValues = [];
+if (featureTypes) {
+    for (int i = 0; i < featureTypes.size(); i++) {
+        featureType = featureTypes.get(i);
+        featuresByType = featuresByTypes.get(featureType);
+        featureTypeAndValues = [featureType : featureType, features : featuresByType];
+        searchFeatures.add(featureTypeAndValues);
+        //
+        selectedFeatureTypeValue = request.getParameter(featureType);
+        if (selectedFeatureTypeValue && selectedFeatureTypeValue.length() > 0) {
+            featureTypeAndValues.selectedFeatureId = selectedFeatureTypeValue;
+            selectedFeatureTypeValues.add(selectedFeatureTypeValue);
+            feature = delegator.findOne("ProductFeature", [productFeatureId : selectedFeatureTypeValue]);
+            productVariantId += (feature.getString("idCode") != null? feature.getString("idCode"): "");
+            productFeatureIds += "|" + selectedFeatureTypeValue;
+        }
     }
 }
 
-variants = new ArrayList();
-//if (selectedFeatureTypeValues.size() > 0) {
-    result = dispatcher.runSync("getAllExistingVariants", UtilMisc.toMap("productId", productId, "productFeatureAppls", selectedFeatureTypeValues));
+variants = [];
+//if (selectedFeatureTypeValues) {
+    result = dispatcher.runSync("getAllExistingVariants", [productId : productId, productFeatureAppls : selectedFeatureTypeValues]);
     variants = result.get("variantProductIds");
 //}
 
 // Quick Add Variant
 productFeatureIdsPar = request.getParameter("productFeatureIds");
 productVariantIdPar = request.getParameter("productVariantId");
-if (productVariantIdPar != null && productFeatureIdsPar != null) {
-    result = dispatcher.runSync("quickAddVariant", UtilMisc.toMap("productId", productId, "productFeatureIds", productFeatureIdsPar, "productVariantId", productVariantIdPar));
+if (productVariantIdPar && productFeatureIdsPar) {
+    result = dispatcher.runSync("quickAddVariant", [productId : productId, productFeatureIds : productFeatureIdsPar, productVariantId : productVariantIdPar]);
 }
 
-context.put("product", product);
-context.put("searchFeatures", searchFeatures);
-context.put("variants", variants);
+context.product = product;
+context.searchFeatures = searchFeatures;
+context.variants = variants;
 
 // also need the variant products themselves
-variantProducts = new ArrayList();
+variantProducts = [];
 iter = variants.iterator();
-while (iter.hasNext()) {
+while (iter) {
     variantId = iter.next();
-    variantProducts.add(delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", variantId)));
+    variantProducts.add(delegator.findOne("Product", [productId : variantId], true));
 }
-context.put("variantProducts", variantProducts);
+context.variantProducts = variantProducts;
 
 if(security.hasEntityPermission("CATALOG", "_CREATE", session)) {
     if (selectedFeatureTypeValues.size() == featureTypes.size() && variants.size() == 0) {
-        context.put("productFeatureIds", productFeatureIds);
-        context.put("productVariantId", productVariantId);
+        context.productFeatureIds = productFeatureIds;
+        context.productVariantId = productVariantId;
     }
-}
+}
\ No newline at end of file

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?rev=664482&r1=664481&r2=664482&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml Sun Jun  8 04:08:56 2008
@@ -225,9 +225,9 @@
         <security https="true" auth="true"/>
         <response name="success" type="view" value="createProductInCategoryStart"/>
     </request-map>
-    <request-map uri="createProductInCategoryCheckExisting">
+    <request-map uri="CreateProductInCategoryCheckExisting">
         <security https="true" auth="true"/>
-        <response name="success" type="view" value="createProductInCategoryCheckExisting"/>
+        <response name="success" type="view" value="CreateProductInCategoryCheckExisting"/>
     </request-map>
     <request-map uri="createProductInCategory">
         <security https="true" auth="true"/>
@@ -2544,7 +2544,7 @@
     <view-map name="EditProductCategoryLinks" type="screen" page="component://product/widget/catalog/CategoryScreens.xml#EditProductCategoryLinks"/>
 
     <view-map name="createProductInCategoryStart" type="screen" page="component://product/widget/catalog/CategoryScreens.xml#createProductInCategoryStart"/>
-    <view-map name="createProductInCategoryCheckExisting" type="screen" page="component://product/widget/catalog/CategoryScreens.xml#createProductInCategoryCheckExisting"/>
+    <view-map name="CreateProductInCategoryCheckExisting" type="screen" page="component://product/widget/catalog/CategoryScreens.xml#CreateProductInCategoryCheckExisting"/>
 
     <view-map name="EditProduct" type="screen" page="component://product/widget/catalog/ProductScreens.xml#EditProduct"/>
     <view-map name="EditProductPrices" type="screen" page="component://product/widget/catalog/ProductScreens.xml#EditProductPrices"/>

Modified: ofbiz/trunk/applications/product/widget/catalog/CategoryScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/CategoryScreens.xml?rev=664482&r1=664481&r2=664482&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/CategoryScreens.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/CategoryScreens.xml Sun Jun  8 04:08:56 2008
@@ -80,7 +80,7 @@
                     <order-by field-name="description"/>
                 </entity-condition>
 
-                <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.bsh"/>
+                <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategory.groovy"/>
             </actions>
             <widgets>
                 <decorator-screen name="CommonCategoryDecorator">
@@ -281,7 +281,7 @@
 
                 <set field="productCategoryId" from-field="parameters.productCategoryId"/>
 
-                <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategoryProducts.bsh"/>
+                <script location="component://product/webapp/catalog/WEB-INF/actions/category/EditCategoryProducts.groovy"/>
             </actions>
             <widgets>
                 <decorator-screen name="CommonCategoryDecorator">
@@ -471,7 +471,7 @@
             </widgets>
         </section>
     </screen>    
-    <screen name="createProductInCategoryCheckExisting">
+    <screen name="CreateProductInCategoryCheckExisting">
         <section>
             <actions>
                 <set field="titleProperty" value="PageTitleCreateProductCategoryCheckExisting"/>
@@ -481,7 +481,7 @@
                 <set field="productCategoryId" from-field="parameters.productCategoryId"/>
                 <entity-one entity-name="ProductCategory" value-name="productCategory"/>
 
-                <script location="component://product/webapp/catalog/WEB-INF/actions/category/createProductInCategoryCheckExisting.bsh"/>
+                <script location="component://product/webapp/catalog/WEB-INF/actions/category/CreateProductInCategoryCheckExisting.groovy"/>
             </actions>
             <widgets>
                 <decorator-screen name="CommonCategoryDecorator">

Modified: ofbiz/trunk/applications/product/widget/catalog/LookupScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/LookupScreens.xml?rev=664482&r1=664481&r2=664482&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/LookupScreens.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/LookupScreens.xml Sun Jun  8 04:08:56 2008
@@ -108,7 +108,7 @@
                 <set field="queryString" from-field="result.queryString"/>
                 <set field="viewIndex" from-field="parameters.VIEW_INDEX" type="Integer"/>
                 <set field="viewSize" from-field="parameters.VIEW_SIZE" type="Integer" default-value="20"/>
-                <script location="component://product/webapp/catalog/WEB-INF/actions/lookup/LookupVariantProduct.bsh"/>
+                <script location="component://product/webapp/catalog/WEB-INF/actions/lookup/LookupVariantProduct.groovy"/>
             </actions>
             <widgets>
                 <decorator-screen name="LookupDecorator" location="component://common/widget/CommonScreens.xml">