Author: ashish
Date: Wed Jun 4 03:30:33 2008 New Revision: 663050 URL: http://svn.apache.org/viewvc?rev=663050&view=rev Log: Groovy Feature applied to remaining files from Party component. Party of Jira Issue 1801. Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/HasPartyPermissions.groovy ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/communication/pendingCommunications.groovy ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/editShoppingList.groovy ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/findMatches.groovy ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/viewprofile.groovy Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/HasPartyPermissions.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/HasPartyPermissions.groovy?rev=663050&r1=663049&r2=663050&view=diff ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/HasPartyPermissions.groovy (original) +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/HasPartyPermissions.groovy Wed Jun 4 03:30:33 2008 @@ -18,12 +18,12 @@ */ // standard partymgr permissions -context.put("hasViewPermission", security.hasEntityPermission("PARTYMGR", "_VIEW", session)); -context.put("hasCreatePermission", security.hasEntityPermission("PARTYMGR", "_CREATE", session)); -context.put("hasUpdatePermission", security.hasEntityPermission("PARTYMGR", "_UPDATE", session)); -context.put("hasDeletePermission", security.hasEntityPermission("PARTYMGR", "_DELETE", session)); +context.hasViewPermission = security.hasEntityPermission("PARTYMGR", "_VIEW", session); +context.hasCreatePermission = security.hasEntityPermission("PARTYMGR", "_CREATE", session); +context.hasUpdatePermission = security.hasEntityPermission("PARTYMGR", "_UPDATE", session); +context.hasDeletePermission = security.hasEntityPermission("PARTYMGR", "_DELETE", session); // extended pay_info permissions -context.put("hasPayInfoPermission", security.hasEntityPermission("PAY_INFO", "_VIEW", session)); +context.hasPayInfoPermission = security.hasEntityPermission("PAY_INFO", "_VIEW", session); // extended pcm (party contact mechanism) permissions -context.put("hasPcmCreatePermission", security.hasEntityPermission("PARTYMGR_PCM", "_CREATE", session)); -context.put("hasPcmUpdatePermission", security.hasEntityPermission("PARTYMGR_PCM", "_UPDATE", session)); +context.hasPcmCreatePermission = security.hasEntityPermission("PARTYMGR_PCM", "_CREATE", session); +context.hasPcmUpdatePermission = security.hasEntityPermission("PARTYMGR_PCM", "_UPDATE", session); Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/communication/pendingCommunications.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/communication/pendingCommunications.groovy?rev=663050&r1=663049&r2=663050&view=diff ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/communication/pendingCommunications.groovy (original) +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/communication/pendingCommunications.groovy Wed Jun 4 03:30:33 2008 @@ -17,63 +17,62 @@ * under the License. */ -import org.ofbiz.base.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.entity.util.*; -import org.ofbiz.entity.condition.*; -import org.ofbiz.entity.transaction.*; +import org.ofbiz.base.util.Debug; +import org.ofbiz.entity.util.EntityFindOptions; +import org.ofbiz.entity.condition.EntityCondition; +import org.ofbiz.entity.condition.EntityOperator; +import org.ofbiz.entity.transaction.TransactionUtil; -module = "pendingCommunications.bsh"; +import javolution.util.FastList; -partyId = userLogin.getString("partyId"); +module = "pendingCommunications.groovy"; + +partyId = userLogin.partyId; // indicator to display messages FROM this user -fromFlag = request.getParameter("showFromEvents"); +fromFlag = parameters.showFromEvents; // get the sort field -sortField = request.getParameter("sort"); -previousSort = request.getParameter("previousSort"); +sortField = parameters.sort; +//previous sort field +previousSort = parameters.previousSort; -// previous sort field -previousSort = request.getParameter("previousSort"); -if (previousSort != null && sortField != null && previousSort.equals(sortField)) { +if (previousSort && sortField && previousSort.equals(sortField)) { sortField = sortField.startsWith("-") ? sortField : "-" + sortField; } -if (sortField == null) sortField = previousSort; -if (sortField == null) sortField = "entryDate"; -context.put("previousSort", sortField); +if (!sortField) sortField = previousSort; +if (!sortField) sortField = "entryDate"; +context.previousSort = sortField; // set the page parameters viewIndex = 1; try { - viewIndex = Integer.valueOf((String) request.getParameter("VIEW_INDEX")).intValue(); + viewIndex = Integer.valueOf((String) parameters.VIEW_INDEX).intValue(); } catch (Exception e) { viewIndex = 1; } -context.put("viewIndex", viewIndex); +context.viewIndex = viewIndex; viewSize = 20; try { - viewSize = Integer.valueOf((String) request.getParameter("VIEW_SIZE")).intValue(); + viewSize = Integer.valueOf((String) parameters.VIEW_SIZE).intValue(); } catch (Exception e) { viewSize = 20; } if (viewSize > 100) { viewSize = 100; } -context.put("viewSize", viewSize); +context.viewSize = viewSize; // get the logged in user's roles -partyRoles = delegator.findByAnd("PartyRole", UtilMisc.toMap("partyId", partyId)); +partyRoles = delegator.findByAnd("PartyRole", [partyId : partyId]); // build the party role list -pri = partyRoles.iterator(); -pRolesList = new ArrayList(); -while (pri.hasNext()) { - partyRole = (GenericValue) pri.next(); - if (!partyRole.getString("roleTypeId").equals("_NA_")) { - pRolesList.add(EntityCondition.makeCondition("roleTypeIdTo", EntityOperator.EQUALS, partyRole.getString("roleTypeId"))); +pRolesList = FastList.newInstance(); +partyRoles.each { partyRole -> + if (!partyRole.roleTypeId.equals("_NA_")) { + pRolesList.add(EntityCondition.makeCondition("roleTypeIdTo", EntityOperator.EQUALS, partyRole.roleTypeId)); } } @@ -81,7 +80,7 @@ pRolesList.add(EntityCondition.makeCondition("roleTypeIdTo", EntityOperator.EQUALS, null)); // limit to just this user's events, or those not attached to a user -partyList = new ArrayList(); +partyList = FastList.newInstance(); partyList.add(EntityCondition.makeCondition("partyIdTo", EntityOperator.EQUALS, null)); partyList.add(EntityCondition.makeCondition("partyIdTo", EntityOperator.EQUALS, partyId)); if ("Y".equalsIgnoreCase(fromFlag)) { @@ -90,13 +89,13 @@ } // limit to non-completed items -statusList = new ArrayList(); +statusList = FastList.newInstance(); statusList.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "COM_COMPLETE")); statusList.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "COM_RESOLVED")); statusList.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "COM_REFERRED")); // build the condition -expressions = new ArrayList(); +expressions = FastList.newInstance(); expressions.add(EntityCondition.makeCondition(partyList, EntityOperator.OR)); expressions.add(EntityCondition.makeCondition(pRolesList, EntityOperator.OR)); expressions.add(EntityCondition.makeCondition(statusList, EntityOperator.AND)); @@ -106,7 +105,7 @@ fieldsToSelect = null; // sort order -orderBy = UtilMisc.toList(sortField); +orderBy = [sortField]; // entity find options findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, false); @@ -125,7 +124,7 @@ // get the partial list for this page eventList = eli.getPartialList(lowIndex, viewSize); - if (eventList == null) { + if (!eventList) { eventList = new ArrayList(); } @@ -139,13 +138,13 @@ // close the list iterator eli.close(); TransactionUtil.commit(beganTransaction); -} catch (GenericEntityException e) { +} catch (Exception e) { String errMsg = "Failure in operation, rolling back transaction"; Debug.logError(e, errMsg, module); try { // only rollback the transaction if we started one... TransactionUtil.rollback(beganTransaction, errMsg, e); - } catch (GenericEntityException e2) { + } catch (Exception e2) { Debug.logError(e2, "Could not rollback transaction: " + e2.toString(), module); } // after rolling back, rethrow the exception @@ -156,7 +155,7 @@ } -context.put("eventList", eventList); -context.put("eventListSize", eventListSize); -context.put("highIndex", highIndex); -context.put("lowIndex", lowIndex); +context.eventList = eventList; +context.eventListSize = eventListSize; +context.highIndex = highIndex; +context.lowIndex = lowIndex; Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/editShoppingList.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/editShoppingList.groovy?rev=663050&r1=663049&r2=663050&view=diff ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/editShoppingList.groovy (original) +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/editShoppingList.groovy Wed Jun 4 03:30:33 2008 @@ -17,124 +17,113 @@ * under the License. */ -import java.util.*; -import org.ofbiz.base.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.entity.util.*; -import org.ofbiz.entity.condition.*; -import org.ofbiz.product.catalog.*; +import org.ofbiz.entity.util.EntityUtil; +import org.ofbiz.base.util.UtilHttp; +import org.ofbiz.product.catalog.CatalogWorker; prodCatalogId = CatalogWorker.getCurrentCatalogId(request); webSiteId = CatalogWorker.getWebSiteId(request); -currencyUomId = request.getParameter("currencyUomId"); -if (currencyUomId == null) { - currencyUomId = UtilHttp.getCurrencyUom(request); -} -context.put("currencyUomId", currencyUomId); +currencyUomId = parameters.currencyUomId ? parameters.currencyUomId : UtilHttp.getCurrencyUom(request); +context.currencyUomId = currencyUomId; -partyId = request.getParameter("partyId"); -if (partyId == null) partyId = (String) request.getAttribute("partyId"); +partyId = parameters.partyId; +if (!partyId) partyId = parameters.partyId; -party = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", partyId)); -context.put("party", party); -if (party != null) { - context.put("lookupPerson", party.getRelatedOne("Person")); - context.put("lookupGroup", party.getRelatedOne("PartyGroup")); +party = delegator.findByPrimaryKey("Party", [partyId : partyId]); +context.party = party; +if (party) { + context.lookupPerson = party.getRelatedOne("Person"); + context.lookupGroup = party.getRelatedOne("PartyGroup"); } -shoppingListId = parameters.get("shoppingListId"); -if (shoppingListId == null || shoppingListId.equals("")) +shoppingListId = parameters.shoppingListId; +if (!shoppingListId) shoppingListId = request.getAttribute("shoppingListId"); //get the party for listid if it exists -if(partyId == null && shoppingListId != null){ - partyId = delegator.findByPrimaryKey("ShoppingList",UtilMisc.toMap("shoppingListId",shoppingListId)).getString("partyId"); +if(!partyId && shoppingListId){ + partyId = delegator.findByPrimaryKey("ShoppingList", [shoppingListId : shoppingListId]).partyId; } -context.put("partyId", partyId); +context.partyId = partyId; // get the top level shopping lists for the party -allShoppingLists = delegator.findByAnd("ShoppingList", UtilMisc.toMap("partyId",partyId), UtilMisc.toList("listName")); -shoppingLists = EntityUtil.filterByAnd(allShoppingLists, UtilMisc.toMap("parentShoppingListId", null)); -context.put("allShoppingLists", allShoppingLists); -context.put("shoppingLists", shoppingLists); +allShoppingLists = delegator.findByAnd("ShoppingList", [partyId : partyId], ["listName"]); +shoppingLists = EntityUtil.filterByAnd(allShoppingLists, [parentShoppingListId : null]); +context.allShoppingLists = allShoppingLists; +context.shoppingLists = shoppingLists; // get all shoppingListTypes -shoppingListTypes = delegator.findList("ShoppingListType", null, null, UtilMisc.toList("description"), null, true); -context.put("shoppingListTypes", shoppingListTypes); +shoppingListTypes = delegator.findList("ShoppingListType", null, null, ["description"], null, true); +context.shoppingListTypes = shoppingListTypes; // no passed shopping list id default to first list -if (shoppingListId == null || shoppingListId.length() == 0) { +if (!shoppingListId || shoppingListId.length() == 0) { firstList = EntityUtil.getFirst(shoppingLists); - if (firstList != null) { - shoppingListId = firstList.getString("shoppingListId"); + if (firstList) { + shoppingListId = firstList.shoppingListId; } } // if we passed a shoppingListId get the shopping list info -if (shoppingListId != null) { - shoppingList = delegator.findByPrimaryKey("ShoppingList", UtilMisc.toMap("shoppingListId", shoppingListId)); - context.put("shoppingList", shoppingList); +if (shoppingListId) { + shoppingList = delegator.findByPrimaryKey("ShoppingList", [shoppingListId : shoppingListId]); + context.shoppingList = shoppingList; - if (shoppingList != null) { + if (shoppingList) { shoppingListItemTotal = 0.0; shoppingListChildTotal = 0.0; shoppingListItems = shoppingList.getRelatedCache("ShoppingListItem"); - if (shoppingListItems != null) { + if (shoppingListItems) { shoppingListItemDatas = new ArrayList(shoppingListItems.size()); - shoppingListItemIter = shoppingListItems.iterator(); - while (shoppingListItemIter.hasNext()) { - shoppingListItem = shoppingListItemIter.next(); + shoppingListItemDatas.each { shoppingListItem -> shoppingListItemData = new HashMap(); product = shoppingListItem.getRelatedOneCache("Product"); // DEJ20050704 not sure about calculating price here, will have some bogus data when not in a store webapp - calcPriceInMap = UtilMisc.toMap("product", product, "quantity", shoppingListItem.get("quantity"), "currencyUomId", currencyUomId, "userLogin", userLogin, "productStoreId", shoppingList.get("productStoreId")); + calcPriceInMap = [product : product, quantity : shoppingListItem.quantity , currencyUomId : currencyUomId, userLogin : userLogin, productStoreId : shoppingList.productStoreId]; calcPriceOutMap = dispatcher.runSync("calculateProductPrice", calcPriceInMap); - price = calcPriceOutMap.get("price"); + price = calcPriceOutMap.price; totalPrice = price * shoppingListItem.getDouble("quantity"); shoppingListItemTotal += totalPrice; productVariantAssocs = null; - if ("Y".equals(product.getString("isVirtual"))) { - productVariantAssocs = product.getRelatedCache("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("sequenceNum")); + if ("Y".equals(product.isVirtual)) { + productVariantAssocs = product.getRelatedCache("MainProductAssoc", [productAssocTypeId : "PRODUCT_VARIANT"], ["sequenceNum"]); productVariantAssocs = EntityUtil.filterByDate(productVariantAssocs); } - shoppingListItemData.put("shoppingListItem", shoppingListItem); - shoppingListItemData.put("product", product); - shoppingListItemData.put("unitPrice", price); - shoppingListItemData.put("totalPrice", totalPrice); - shoppingListItemData.put("productVariantAssocs", productVariantAssocs); + shoppingListItemData.shoppingListItem = shoppingListItem; + shoppingListItemData.product = product; + shoppingListItemData.unitPrice = price; + shoppingListItemData.totalPrice = totalPrice; + shoppingListItemData.productVariantAssocs = productVariantAssocs; shoppingListItemDatas.add(shoppingListItemData); } - context.put("shoppingListItemDatas", shoppingListItemDatas); + context.shoppingListItemDatas = shoppingListItemDatas; } shoppingListType = shoppingList.getRelatedOne("ShoppingListType"); - context.put("shoppingListType", shoppingListType); + context.shoppingListType = shoppingListType; // get the child shopping lists of the current list for the logged in user - childShoppingLists = delegator.findByAndCache("ShoppingList", UtilMisc.toMap("partyId", partyId, "parentShoppingListId", shoppingListId), UtilMisc.toList("listName")); + childShoppingLists = delegator.findByAndCache("ShoppingList", [partyId : partyId, parentShoppingListId : shoppingListId], ["listName"]); // now get prices for each child shopping list... - if (childShoppingLists != null) { + if (childShoppingLists) { childShoppingListDatas = new ArrayList(childShoppingLists.size()); - childShoppingListIter = childShoppingLists.iterator(); - while (childShoppingListIter.hasNext()) { - childShoppingList = childShoppingListIter.next(); + childShoppingListDatas.each { childShoppingList -> childShoppingListData = new HashMap(); - - calcListPriceInMap = UtilMisc.toMap("shoppingListId", childShoppingList.get("shoppingListId"), "prodCatalogId", prodCatalogId, "webSiteId", webSiteId, "userLogin", userLogin); - childShoppingListData.put("childShoppingList", childShoppingList); + calcListPriceInMap = [shoppingListId : childShoppingList.shoppingListId , prodCatalogId : prodCatalogId , webSiteId : webSiteId, userLogin : userLogin]; + childShoppingListData.childShoppingList = childShoppingList; childShoppingListDatas.add(childShoppingListData); } - context.put("childShoppingListDatas", childShoppingListDatas); + context.childShoppingListDatas = childShoppingListDatas; } // get the parent shopping list if there is one parentShoppingList = shoppingList.getRelatedOne("ParentShoppingList"); - context.put("parentShoppingList", parentShoppingList); + context.parentShoppingList = parentShoppingList; } } Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/findMatches.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/findMatches.groovy?rev=663050&r1=663049&r2=663050&view=diff ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/findMatches.groovy (original) +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/findMatches.groovy Wed Jun 4 03:30:33 2008 @@ -17,51 +17,47 @@ * under the License. */ -import java.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.entity.condition.*; -import org.ofbiz.base.util.*; -import org.ofbiz.party.party.*; - -match = request.getParameter("match"); -if (match != null) { - context.put("match", match); +import org.ofbiz.party.party.PartyWorker; + +match = parameters.match; +if (match) { + context.match = match; - lastName = request.getParameter("lastName"); - if (UtilValidate.isEmpty(lastName)) lastName = null; + lastName = parameters.lastName; + if (!lastName) lastName = null; - firstName = request.getParameter("firstName"); - if (UtilValidate.isEmpty(firstName)) firstName = null; + firstName = parameters.firstName; + if (!firstName) firstName = null; - address1 = request.getParameter("address1"); - if (UtilValidate.isEmpty(address1)) address1 = null; + address1 = parameters.address1; + if (!address1) address1 = null; - address2 = request.getParameter("address2"); - if (UtilValidate.isEmpty(address2)) address2 = null; + address2 = parameters.address2; + if (!address2) address2 = null; - city = request.getParameter("city"); - if (UtilValidate.isEmpty(city)) city = null; + city = parameters.city; + if (!city) city = null; - state = request.getParameter("stateProvinceGeoId"); - if (UtilValidate.isEmpty(state)) state = null; + state = parameters.stateProvinceGeoId; + if (!state) state = null; if ("ANY".equals(state)) state = null; - postalCode = request.getParameter("postalCode"); - if (UtilValidate.isEmpty(postalCode)) postalCode = null; + postalCode = parameters.postalCode; + if (!postalCode) postalCode = null; if (state != null) { - context.put("currentStateGeo", delegator.findByPrimaryKey("Geo", UtilMisc.toMap("geoId", state))); + context.currentStateGeo = delegator.findByPrimaryKey("Geo", [geoId : state]); } - if (firstName == null || lastName == null || address1 == null || city == null || postalCode == null) { + if (!firstName || !lastName || !address1 || !city || !postalCode) { request.setAttribute("_ERROR_MESSAGE_", "Required fields not set!"); return; } - context.put("matches", PartyWorker.findMatchingPartyAndPostalAddress(delegator, address1, address2, city, - state, postalCode, null, null, firstName, null, lastName)); + context.matches = PartyWorker.findMatchingPartyAndPostalAddress(delegator, address1, address2, city, + state, postalCode, null, null, firstName, null, lastName); - context.put("addressString", PartyWorker.makeMatchingString(delegator, address1)); - context.put("lastName", lastName); - context.put("firstName", firstName); + context.addressString = PartyWorker.makeMatchingString(delegator, address1); + context.lastName = lastName; + context.firstName = firstName; } Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/viewprofile.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/viewprofile.groovy?rev=663050&r1=663049&r2=663050&view=diff ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/viewprofile.groovy (original) +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/viewprofile.groovy Wed Jun 4 03:30:33 2008 @@ -17,29 +17,27 @@ * under the License. */ -import org.ofbiz.base.util.*; +import org.ofbiz.base.util.UtilDateTime; -partyId = parameters.get("partyId"); -if (partyId == null) - partyId = parameters.get("party_id"); - -userLoginId = parameters.get("userlogin_id"); -if (UtilValidate.isEmpty(userLoginId)) { - userLoginId = parameters.get("userLoginId"); +partyId = parameters.partyId; +if (!partyId) + partyId = parameters.party_id; + +userLoginId = parameters.userlogin_id; +if (!userLoginId) { + userLoginId = parameters.userLoginId; } -if (UtilValidate.isEmpty(partyId) && UtilValidate.isNotEmpty(userLoginId)) { - thisUserLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", userLoginId)); - if (thisUserLogin != null) { - partyId = thisUserLogin.getString("partyId"); - parameters.put("partyId", partyId); +if (!partyId && userLoginId) { + thisUserLogin = delegator.findByPrimaryKey("UserLogin", [userLoginId : userLoginId]); + if (thisUserLogin) { + partyId = thisUserLogin.partyId; + parameters.partyId = partyId; } } -boolean showOld = "true".equals(parameters.get("SHOW_OLD")); -context.put("showOld", new Boolean(showOld)); - -context.put("partyId", partyId); -context.put("party", delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", partyId))); -context.put("nowStr", UtilDateTime.nowTimestamp().toString()); - +boolean showOld = "true".equals(parameters.SHOW_OLD); +context.showOld = new Boolean(showOld); +context.partyId = partyId; +context.party = delegator.findByPrimaryKey("Party", [partyId : partyId]); +context.nowStr = UtilDateTime.nowTimestamp().toString(); \ No newline at end of file |
Free forum by Nabble | Edit this page |