You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mr...@apache.org on 2008/06/08 17:29:00 UTC
svn commit: r664512 - in /ofbiz/trunk/applications/product:
webapp/catalog/WEB-INF/actions/config/ widget/catalog/
Author: mrisaliti
Date: Sun Jun 8 08:28:59 2008
New Revision: 664512
URL: http://svn.apache.org/viewvc?rev=664512&view=rev
Log:
Converted FindProductConfigItems.bsh/EditProductConfigOptions.bsh/EditProductConfigItemContent.bsh/EditProductConfigItemContentContent.bsh to groovy (Part of issue OFBIZ-1801)
Added:
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy
- copied, changed from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.bsh
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContentContent.groovy
- copied, changed from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContentContent.bsh
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigOptions.groovy
- copied, changed from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigOptions.bsh
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/FindProductConfigItems.groovy
- copied, changed from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/FindProductConfigItems.bsh
Removed:
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.bsh
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContentContent.bsh
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigOptions.bsh
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/FindProductConfigItems.bsh
Modified:
ofbiz/trunk/applications/product/widget/catalog/ConfigScreens.xml
Copied: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy (from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.bsh)
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy?p2=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy&p1=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.bsh&r1=664476&r2=664512&rev=664512&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.bsh (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy Sun Jun 8 08:28:59 2008
@@ -17,100 +17,110 @@
* under the License.
*/
-import org.ofbiz.entity.*;
-import org.ofbiz.base.util.*;
-import org.ofbiz.base.util.string.*;
-import org.ofbiz.widget.html.*;
+import org.ofbiz.base.util.*
+import org.ofbiz.base.util.string.*
+import org.ofbiz.entity.*
+import org.ofbiz.widget.html.*
// make the image file formats
-String imageFilenameFormat = "configitems/${size}/${configItemId}";
-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);
+imageFilenameFormat = "configitems/${configItemId}";
+imageServerPath = UtilProperties.getPropertyValue("catalog", "image.server.path");
+imageUrlPrefix = UtilProperties.getPropertyValue("catalog", "image.url.prefix");
+context.imageFilenameFormat = imageFilenameFormat;
+context.imageServerPath = imageServerPath;
+context.imageUrlPrefix = imageUrlPrefix;
FlexibleStringExpander filenameExpander = new FlexibleStringExpander(imageFilenameFormat);
-context.put("imageNameSmall", imageUrlPrefix + "/" + filenameExpander.expandString(UtilMisc.toMap("size", "small", "configItemId", configItemId)));
+context.imageNameSmall = imageUrlPrefix + "/" + filenameExpander.expandString(['size' : 'small', configItemId : configItemId]);
+
// Start ProdConfItemContent stuff
productContent = null;
-if (configItem != null) productContent = configItem.getRelated("ProdConfItemContent", null, UtilMisc.toList("confItemContentTypeId"));
-context.put("productContent", productContent);
+if (configItem) {
+ productContent = configItem.getRelated("ProdConfItemContent", null, ['confItemContentTypeId']);
+}
+context.productContent = productContent;
-List productContentDatas = new LinkedList();
+productContentDatas = [];
Iterator productContentIter = productContent.iterator();
-while (productContentIter.hasNext()) {
+while (productContentIter) {
GenericValue productContent = (GenericValue) productContentIter.next();
GenericValue content = productContent.getRelatedOne("Content");
- productContentDatas.add(UtilMisc.toMap("productContent", productContent, "content", content));
+ productContentDatas.add([productContent : productContent, content : content]);
}
HtmlFormWrapper updateProductContentWrapper = new HtmlFormWrapper("component://product/webapp/catalog/config/ConfigForms.xml", "UpdateProductConfigItemContentAssoc", request, response);
-context.put("updateProductContentWrapper", updateProductContentWrapper);
+context.updateProductContentWrapper = updateProductContentWrapper;
updateProductContentWrapper.putInContext("productContentDatas", productContentDatas);
HtmlFormWrapper prepareAddProductContentWrapper = new HtmlFormWrapper("component://product/webapp/catalog/config/ConfigForms.xml", "PrepareAddProductConfigItemContentAssoc", request, response);
-context.put("prepareAddProductContentWrapper", prepareAddProductContentWrapper);
+context.prepareAddProductContentWrapper = prepareAddProductContentWrapper;
prepareAddProductContentWrapper.putInContext("configItem", configItem);
HtmlFormWrapper addProductContentWrapper = new HtmlFormWrapper("component://product/webapp/catalog/config/ConfigForms.xml", "AddProductConfigItemContentAssoc", request, response);
-context.put("addProductContentWrapper", addProductContentWrapper);
+context.addProductContentWrapper = addProductContentWrapper;
addProductContentWrapper.putInContext("configItem", configItem);
-context.put("productContentList", productContentDatas);
+context.productContentList = productContentDatas;
// End ProductContent stuff
-boolean tryEntity = true;
-if (request.getAttribute("_ERROR_MESSAGE_") != null) tryEntity = false;
-if (configItem == null) tryEntity = false;
-if("true".equalsIgnoreCase((String) request.getParameter("tryEntity"))) tryEntity = true;
-context.put("tryEntity", tryEntity);
+tryEntity = true;
+if (request.getAttribute("_ERROR_MESSAGE_")) {
+ tryEntity = false;
+}
+if (!configItem) {
+ tryEntity = false;
+}
+if ("true".equalsIgnoreCase((String)request.getParameter("tryEntity"))) {
+ tryEntity = true;
+}
+context.tryEntity = tryEntity;
// UPLOADING STUFF
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 fileNameToUse = "productConfigItem." + configItemId + "." + fileType;
- String fileNameToUse = "productConfigItem." + configItemId;
- String fileLocation = filenameExpander.expandString(UtilMisc.toMap("size", fileType, "configItemId", configItemId));
- String filePathPrefix = "";
- String filenameToUse = fileLocation;
+ fileNameToUse = "productConfigItem." + configItemId;
+ fileLocation = filenameExpander.expandString(['size', fileType, configItemId, configItemId]);
+ filePathPrefix = "";
+ filenameToUse = fileLocation;
if (fileLocation.lastIndexOf("/") != -1) {
filePathPrefix = fileLocation.substring(0, fileLocation.lastIndexOf("/") + 1); // adding 1 to include the trailing slash
filenameToUse = fileLocation.substring(fileLocation.lastIndexOf("/") + 1);
}
int i1;
- if (contentType != null && (i1 = contentType.indexOf("boundary=")) != -1) {
+ if (contentType && (i1 = contentType.indexOf("boundary=")) != -1) {
contentType = contentType.substring(i1 + 9);
contentType = "--" + contentType;
}
- String defaultFileName = filenameToUse + "_temp";
+ defaultFileName = filenameToUse + "_temp";
HttpRequestFileUpload uploadObject = new HttpRequestFileUpload();
uploadObject.setOverrideFilename(defaultFileName);
uploadObject.setSavePath(imageServerPath + "/" + filePathPrefix);
uploadObject.doUpload(request);
- String clientFileName = uploadObject.getFilename();
- if (clientFileName != null) context.put("clientFileName", clientFileName);
+ clientFileName = uploadObject.getFilename();
+ 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);
- String characterEncoding = request.getCharacterEncoding();
- String imageUrl = imageUrlPrefix + "/" + filePathPrefix + java.net.URLEncoder.encode(filenameToUse, characterEncoding);
+ context.clientFileName = clientFileName;
+ context.filenameToUse = filenameToUse;
+
+ characterEncoding = request.getCharacterEncoding();
+ imageUrl = imageUrlPrefix + "/" + filePathPrefix + java.net.URLEncoder.encode(filenameToUse, characterEncoding);
try {
File file = new File(imageServerPath + "/" + filePathPrefix, defaultFileName);
@@ -124,12 +134,11 @@
} catch(Exception e) {
e.printStackTrace();
}
-
- if (imageUrl != null && imageUrl.length() > 0) {
- context.put("imageUrl", imageUrl);
+
+ if (imageUrl && imageUrl.length() > 0) {
+ context.imageUrl = imageUrl;
configItem.set("imageUrl", imageUrl);
configItem.store();
}
}
-}
-
+}
\ No newline at end of file
Copied: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContentContent.groovy (from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContentContent.bsh)
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContentContent.groovy?p2=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContentContent.groovy&p1=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContentContent.bsh&r1=664476&r2=664512&rev=664512&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContentContent.bsh (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContentContent.groovy Sun Jun 8 08:28:59 2008
@@ -21,60 +21,69 @@
import org.ofbiz.entity.util.*;
import org.ofbiz.base.util.*;
import org.ofbiz.widget.html.*;
-import javax.servlet.HttpServletRequest;
contentId = request.getParameter("contentId");
-if("".equals(contentId)) contentId = null;
+if ("".equals(contentId)) {
+ contentId = null;
+}
confItemContentTypeId = request.getParameter("confItemContentTypeId");
fromDate = request.getParameter("fromDate");
-if("".equals(fromDate)) fromDate = null;
+if ("".equals(fromDate)) {
+ fromDate = null;
+}
description = request.getParameter("description");
-if("".equals(description)) description = null;
+if ("".equals(description)) {
+ description = null;
+}
-productContent = delegator.findByPrimaryKey("ProdConfItemContent", UtilMisc.toMap("contentId", contentId, "configItemId", configItemId, "confItemContentTypeId", confItemContentTypeId, "fromDate", fromDate));
-if(productContent == null) {
- productContent = new HashMap();
- productContent.put("configItemId", configItemId);
- productContent.put("contentId", contentId);
- productContent.put("confItemContentTypeId", confItemContentTypeId);
- productContent.put("fromDate", fromDate);
- productContent.put("thruDate", request.getParameter("thruDate"));
+productContent = delegator.findOne("ProdConfItemContent", [contentId : contentId, configItemId : configItemId, confItemContentTypeId : confItemContentTypeId, fromDate : fromDate], false);
+if (!productContent) {
+ productContent = [:];
+ productContent.configItemId = configItemId;
+ productContent.contentId = contentId;
+ productContent.confItemContentTypeId = confItemContentTypeId;
+ productContent.fromDate = fromDate;
+ productContent.thruDate = request.getParameter("thruDate");
}
-context.put("productContent", productContent);
+context.productContent = productContent;
-productContentData = new HashMap();
+productContentData = [:];
productContentData.putAll(productContent);
Map content = null;
-context.put("contentId", contentId);
-if(contentId != null) {
- content = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId));
- context.put("content", content);
+context.contentId = contentId;
+if (contentId) {
+ content = delegator.findOne("Content", [contentId : contentId], false);
+ context.content = content;
} else {
- content = new HashMap();
- if(description != null) content.put("description", description);
+ content = [:];
+ if (description) {
+ content.description = description;
+ }
}
HtmlFormWrapper updateProductContentWrapper = null;
//Assume it is a generic simple text content
-textData = new HashMap();
-if (contentId != null && content != null) {
+textData = [:];
+if (contentId && content) {
textDr = content.getRelatedOne("DataResource");
- if (textDr != null) {
+ if (textDr) {
text = textDr.getRelatedOne("ElectronicText");
- textData.put("text", text.get("textData"));
- textData.put("textDataResourceId", text.get("dataResourceId"));
+ if (text) {
+ textData.text = text.textData;
+ textData.textDataResourceId = text.dataResourceId;
+ }
}
}
updateProductContentWrapper = new HtmlFormWrapper("component://product/webapp/catalog/config/ConfigForms.xml", "EditProductConfigItemContentSimpleText", request, response);
updateProductContentWrapper.putInContext("textData", textData);
-context.put("updateProductContentWrapper", updateProductContentWrapper);
+context.updateProductContentWrapper = updateProductContentWrapper;
updateProductContentWrapper.putInContext("productContentData", productContentData);
-context.put("productContentData", productContentData);
+context.productContentData = productContentData;
updateProductContentWrapper.putInContext("content", content);
-updateProductContentWrapper.putInContext("contentId", contentId);
+updateProductContentWrapper.putInContext("contentId", contentId);
\ No newline at end of file
Copied: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigOptions.groovy (from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigOptions.bsh)
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigOptions.groovy?p2=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigOptions.groovy&p1=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigOptions.bsh&r1=664476&r2=664512&rev=664512&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigOptions.bsh (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/EditProductConfigOptions.groovy Sun Jun 8 08:28:59 2008
@@ -17,23 +17,19 @@
* under the License.
*/
-import org.ofbiz.entity.*;
-import org.ofbiz.base.util.*;
-import org.ofbiz.widget.html.*;
-
+import org.ofbiz.widget.html.*
HtmlFormWrapper createConfigOptionWrapper = new HtmlFormWrapper("component://product/webapp/catalog/config/ConfigForms.xml", "CreateConfigOption", request, response);
createConfigOptionWrapper.putInContext("configItemId", configItemId);
createConfigOptionWrapper.putInContext("configOption", configOption);
-context.put("createConfigOptionWrapper", createConfigOptionWrapper);
+context.createConfigOptionWrapper = createConfigOptionWrapper;
-if (configOption != null) {
+if (configOption) {
HtmlFormWrapper createConfigProductWrapper = new HtmlFormWrapper("component://product/webapp/catalog/config/ConfigForms.xml", "CreateProductConfigProduct", request, response);
createConfigProductWrapper.putInContext("productConfigProduct", configProduct);
createConfigProductWrapper.putInContext("configOptionId", configOptionId);
createConfigProductWrapper.putInContext("configItemId", configItemId);
- context.put("createConfigProductWrapper", createConfigProductWrapper);
-}
-
+ context.createConfigProductWrapper = createConfigProductWrapper;
+}
\ No newline at end of file
Copied: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/FindProductConfigItems.groovy (from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/FindProductConfigItems.bsh)
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/FindProductConfigItems.groovy?p2=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/FindProductConfigItems.groovy&p1=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/FindProductConfigItems.bsh&r1=664476&r2=664512&rev=664512&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/FindProductConfigItems.bsh (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/config/FindProductConfigItems.groovy Sun Jun 8 08:28:59 2008
@@ -17,12 +17,8 @@
* under the License.
*/
-import org.ofbiz.entity.*;
-import org.ofbiz.entity.condition.*;
-import org.ofbiz.base.util.*;
-
-itemsList = delegator.findList("ProductConfigItem", null, null, UtilMisc.toList("configItemId"), null, false);
-context.put("itemsList", itemsList);
+itemsList = delegator.findList("ProductConfigItem", null, null, ['configItemId'], null, false);
+context.itemsList = itemsList;
// set the page parameters
viewIndex = 0;
@@ -40,7 +36,7 @@
}
listSize = 0;
-if (itemsList != null) {
+if (itemsList) {
listSize = itemsList.size();
}
@@ -50,8 +46,8 @@
if (listSize < highIndex) {
highIndex = listSize;
}
-context.put("viewIndex", viewIndex);
-context.put("listSize", listSize);
-context.put("highIndex", highIndex);
-context.put("lowIndex", lowIndex);
-context.put("viewSize", viewSize);
+context.viewIndex = viewIndex;
+context.listSize = listSize;
+context.highIndex = highIndex;
+context.lowIndex = lowIndex;
+context.viewSize = viewSize;
\ No newline at end of file
Modified: ofbiz/trunk/applications/product/widget/catalog/ConfigScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/ConfigScreens.xml?rev=664512&r1=664511&r2=664512&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/ConfigScreens.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/ConfigScreens.xml Sun Jun 8 08:28:59 2008
@@ -68,7 +68,7 @@
<set field="titleProperty" value="PageTitleFindConfigItems"/>
<set field="headerItem" value="configs"/>
- <script location="component://product/webapp/catalog/WEB-INF/actions/config/FindProductConfigItems.bsh"/>
+ <script location="component://product/webapp/catalog/WEB-INF/actions/config/FindProductConfigItems.groovy"/>
</actions>
<widgets>
<decorator-screen name="CommonConfigDecorator">
@@ -187,7 +187,7 @@
<set field="configItemId" from-field="parameters.configItemId"/>
<entity-one entity-name="ProductConfigItem" value-name="configItem" auto-field-map="true"/>
- <script location="component://product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.bsh"/>
+ <script location="component://product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContent.groovy"/>
</actions>
<widgets>
<decorator-screen name="CommonConfigDecorator">
@@ -211,7 +211,7 @@
<set field="configItemId" from-field="parameters.configItemId"/>
<entity-one entity-name="ProductConfigItem" value-name="configItem" auto-field-map="true"/>
- <script location="component://product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContentContent.bsh"/>
+ <script location="component://product/webapp/catalog/WEB-INF/actions/config/EditProductConfigItemContentContent.groovy"/>
</actions>
<widgets>
<decorator-screen name="CommonConfigDecorator">