Author: mrisaliti
Date: Sun Jun 8 03:25:14 2008 New Revision: 664479 URL: http://svn.apache.org/viewvc?rev=664479&view=rev Log: Converted EditProductContentContent.bsh to groovy (Part of issue OFBIZ-1801) Added: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContentContent.groovy - copied, changed from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContentContent.bsh Removed: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContentContent.bsh Modified: ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml Copied: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContentContent.groovy (from r664476, ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContentContent.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContentContent.groovy?p2=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContentContent.groovy&p1=ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContentContent.bsh&r1=664476&r2=664479&rev=664479&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContentContent.bsh (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContentContent.groovy Sun Jun 8 03:25:14 2008 @@ -17,112 +17,120 @@ * under the License. */ -import java.util.*; -import java.io.*; + import org.ofbiz.entity.*; 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; +} productContentTypeId = request.getParameter("productContentTypeId"); + 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("ProductContent", UtilMisc.toMap("contentId", contentId, "productId", productId, "productContentTypeId", productContentTypeId, "fromDate", fromDate)); -if(productContent == null) { - productContent = new HashMap(); - productContent.put("productId", productId); - productContent.put("contentId", contentId); - productContent.put("productContentTypeId", productContentTypeId); - productContent.put("fromDate", fromDate); - productContent.put("thruDate", request.getParameter("thruDate")); - productContent.put("purchaseFromDate", request.getParameter("purchaseFromDate")); - productContent.put("purchaseThruDate", request.getParameter("purchaseThruDate")); - productContent.put("useCountLimit", request.getParameter("useCountLimit")); - productContent.put("useTime", request.getParameter("useTime")); - productContent.put("useTimeUomId", request.getParameter("useTimeUomId")); - productContent.put("useRoleTypeId", request.getParameter("useRoleTypeId")); +productContent = delegator.findOne("ProductContent", [contentId : contentId, productId : productId, productContentTypeId : productContentTypeId, fromDate : fromDate], false); +if (!productContent) { + productContent = [:]; + productContent.productId = productId; + productContent.contentId = contentId; + productContent.productContentTypeId = productContentTypeId; + productContent.fromDate = fromDate; + productContent.thruDate = request.getParameter("thruDate"); + productContent.purchaseFromDate = request.getParameter("purchaseFromDate"); + productContent.purchaseThruDate = request.getParameter("purchaseThruDate"); + productContent.useCountLimit = request.getParameter("useCountLimit"); + productContent.useTime = request.getParameter("useTime"); + productContent.useTimeUomId = request.getParameter("useTimeUomId"); + productContent.useRoleTypeId = request.getParameter("useRoleTypeId"); } -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); +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; + } } if ("FULFILLMENT_EMAIL".equals(productContentTypeId)) { - emailData = new HashMap(); - if (contentId != null && content != null) { + emailData = [:]; + if (contentId && content) { subjectDr = content.getRelatedOne("DataResource"); - if (subjectDr != null) { + if (subjectDr) { subject = subjectDr.getRelatedOne("ElectronicText"); - emailData.put("subject", subject.get("textData")); - emailData.put("subjectDataResourceId", subject.get("dataResourceId")); + emailData.subject = subject.textData; + emailData.subjectDataResourceId = subject.dataResourceId; } - serviceCtx = UtilMisc.toMap("userLogin", userLogin, "contentId", contentId, "mapKeys", UtilMisc.toList("plainBody", "htmlBody")); + serviceCtx = [userLogin : userLogin, contentId : contentId, mapKeys : ['plainBody', 'htmlBody']]; result = dispatcher.runSync("findAssocContent", serviceCtx); contentAssocs = result.get("contentAssocs"); - if (contentAssocs != null) { - for (java.util.Iterator iterator = contentAssocs.iterator(); iterator.hasNext(); ) { - contentAssoc = iterator.next(); + if (contentAssocs) { + for (contentAssocIter = contentAssocs.iterator(); contentAssocIter;) { + contentAssoc = contentAssocIter.next(); bodyContent = contentAssoc.getRelatedOne("ToContent"); bodyDr = bodyContent.getRelatedOne("DataResource"); body = bodyDr.getRelatedOne("ElectronicText"); - emailData.put(contentAssoc.get("mapKey"), body.get("textData")); - emailData.put(contentAssoc.get("mapKey")+"DataResourceId", body.get("dataResourceId")); + emailData.put(contentAssoc.mapKey, body.textData); + emailData.put(contentAssoc.get("mapKey")+"DataResourceId", body.dataResourceId); } } } - context.put("contentFormName", "EditProductContentEmail"); - context.put("emailData", emailData); + context.contentFormName = "EditProductContentEmail"; + context.emailData = emailData; } else if ("DIGITAL_DOWNLOAD".equals(productContentTypeId)) { - downloadData = new HashMap(); - if (contentId != null && content != null) { + downloadData = [:]; + if (contentId && content) { downloadDr = content.getRelatedOne("DataResource"); - if (subjectDr != null) { + if (subjectDr) { download = downloadDr.getRelatedOne("OtherDataResource"); - if (download != null) { - downloadData.put("file", download.get("dataResourceContent")); - downloadData.put("fileDataResourceId", download.get("dataResourceId")); + if (download) { + downloadData.file = download.dataResourceContent; + downloadData.fileDataResourceId = download.dataResourceId; } } } - context.put("contentFormName", "EditProductContentDownload"); - context.put("downloadData", downloadData); + context.contentFormName = "EditProductContentDownload"; + context.downloadData = downloadData; } else if ("FULFILLMENT_EXTERNAL".equals(productContentTypeId)) { - context.put("contentFormName", "EditProductContentExternal"); + context.contentFormName = "EditProductContentExternal"; } else { //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; + } } } - context.put("contentFormName", "EditProductContentSimpleText"); - context.put("textData", textData); + context.contentFormName = "EditProductContentSimpleText"; + context.textData = textData; } -context.put("productContentData", productContentData); -context.put("content", content); -context.put("contentId", contentId); +context.productContentData = productContentData; +context.content = content; +context.contentId = contentId; \ No newline at end of file Modified: ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml?rev=664479&r1=664478&r2=664479&view=diff ============================================================================== --- ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml (original) +++ ofbiz/trunk/applications/product/widget/catalog/ProductScreens.xml Sun Jun 8 03:25:14 2008 @@ -1288,7 +1288,7 @@ <set field="productId" from-field="parameters.productId"/> <entity-one entity-name="Product" value-name="product"/> <entity-one entity-name="ProductContent" value-name="productContent"/> - <script location="component://product/webapp/catalog/WEB-INF/actions/product/EditProductContentContent.bsh"/> + <script location="component://product/webapp/catalog/WEB-INF/actions/product/EditProductContentContent.groovy"/> </actions> <widgets> <decorator-screen name="CommonProductDecorator" location="${parameters.mainDecoratorLocation}"> |
Free forum by Nabble | Edit this page |