A few more bsh -> groovy conversions

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@676143 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Scott Gray
2008-07-12 10:54:27 +00:00
parent 16d85012ce
commit 2b2d0d9f8f
9 changed files with 148 additions and 165 deletions
@@ -235,7 +235,7 @@ under the License.
<set field="titleProperty" value="PageTitleCheckoutOptions"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/checkoutpayment.bsh"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/checkoutoptions.bsh"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/CheckoutOptions.groovy"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/storepaymentoptions.bsh"/>
</actions>
<widgets>
@@ -0,0 +1,55 @@
/*
* 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.
*/
import org.ofbiz.order.shoppingcart.ShoppingCartEvents;
import org.ofbiz.order.shoppingcart.ShoppingCart;
import org.ofbiz.entity.*;
import org.ofbiz.base.util.*;
cart = ShoppingCartEvents.getCartObject(request);
additionalPartyRole = cart.getAdditionalPartyRoleMap();
roleData = [:];
partyData = [:];
additionalPartyRole.each { roleTypeId, partyList ->
roleData[roleTypeId] = delegator.findByPrimaryKeyCache("RoleType", [roleTypeId : roleTypeId]);
partyList.each { partyId ->
partyMap = [:];
partyMap.partyId = partyId;
party = delegator.findByPrimaryKeyCache("Party", [partyId : partyId]);
if (party.partyTypeId.equals("PERSON")) {
party = party.getRelatedOneCache("Person");
partyMap.type = "person";
partyMap.firstName = party.firstName;
partyMap.lastName = party.lastName;
} else {
party = party.getRelatedOneCache("PartyGroup");
partyMap.type = "group";
partyMap.groupName = party.groupName;
}
partyData[partyId] = partyMap;
}
}
context.additionalPartyRoleMap = additionalPartyRole;
context.roleList = additionalPartyRole.keySet();
context.roleData = roleData;
context.partyData = partyData;
@@ -24,13 +24,11 @@ import org.ofbiz.accounting.payment.*;
import org.ofbiz.order.shoppingcart.*;
import org.ofbiz.party.contact.*;
delegator = request.getAttribute("delegator");
dispatcher = request.getAttribute("dispatcher");
cart = session.getAttribute("shoppingCart");
orderPartyId = cart.getPartyId();
currencyUomId = cart.getCurrency();
context.put("cart", cart);
context.put("paymentMethodType", request.getParameter("paymentMethodType"));
context.cart = cart;
context.paymentMethodType = request.getParameter("paymentMethodType");
// nuke the event messages
request.removeAttribute("_EVENT_MESSAGE_");
@@ -38,58 +36,58 @@ request.removeAttribute("_EVENT_MESSAGE_");
// If there's a paymentMethodId request attribute, the user has just created a new payment method,
// so put the new paymentMethodId in the context for the UI
newPaymentMethodId=request.getAttribute("paymentMethodId");
if(! UtilValidate.isEmpty(newPaymentMethodId)) {
context.put("checkOutPaymentId", newPaymentMethodId);
if (newPaymentMethodId) {
context.checkOutPaymentId = newPaymentMethodId;
}
if (orderPartyId != null && !orderPartyId.equals("_NA_")) {
orderParty = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", orderPartyId));
if (orderPartyId && !orderPartyId.equals("_NA_")) {
orderParty = delegator.findByPrimaryKey("Party", [partyId : orderPartyId]);
orderPerson = orderParty.getRelatedOne("Person");
context.put("orderParty", orderParty);
context.put("orderPerson", orderPerson);
if (orderParty != null) {
context.put("paymentMethodList", EntityUtil.filterByDate(orderParty.getRelated("PaymentMethod"), true));
context.orderParty = orderParty;
context.orderPerson = orderPerson;
if (orderParty) {
context.paymentMethodList = EntityUtil.filterByDate(orderParty.getRelated("PaymentMethod"), true);
billingAccountList = BillingAccountWorker.makePartyBillingAccountList(userLogin, currencyUomId, orderPartyId, delegator, dispatcher);
if (billingAccountList != null && billingAccountList.size() > 0) {
context.put("selectedBillingAccountId", cart.getBillingAccountId());
context.put("billingAccountList", billingAccountList);
if (billingAccountList) {
context.selectedBillingAccountId = cart.getBillingAccountId();
context.billingAccountList = billingAccountList;
}
}
}
if (request.getParameter("useShipAddr") != null && cart.getShippingContactMechId() != null) {
if (request.getParameter("useShipAddr") && cart.getShippingContactMechId()) {
shippingContactMech = cart.getShippingContactMechId();
postalAddress = delegator.findByPrimaryKey("PostalAddress", UtilMisc.toMap("contactMechId", shippingContactMech));
context.put("postalFields", postalAddress);
postalAddress = delegator.findByPrimaryKey("PostalAddress", [contactMechId : shippingContactMech]);
context.postalFields = postalAddress;
} else {
context.put("postalFields", UtilHttp.getParameterMap(request));
context.postalFields = UtilHttp.getParameterMap(request);
}
if (cart != null) {
if (cart.getPaymentMethodIds().size() > 0) {
if (cart) {
if (cart.getPaymentMethodIds()) {
checkOutPaymentId = cart.getPaymentMethodIds().get(0);
context.put("checkOutPaymentId", checkOutPaymentId);
if (orderParty == null) {
paymentMethod = delegator.findByPrimaryKey("PaymentMethod", UtilMisc.toMap("paymentMethodId", checkOutPaymentId));
if (paymentMethod != null && paymentMethod.getString("paymentMethodTypeId").equals("CREDIT_CARD")) {
context.checkOutPaymentId = checkOutPaymentId;
if (!orderParty) {
paymentMethod = delegator.findByPrimaryKey("PaymentMethod", [paymentMethodId : checkOutPaymentId]);
if ("CREDIT_CARD".equals(paymentMethod?.paymentMethodTypeId)) {
paymentMethodType = "CC";
account = paymentMethod.getRelatedOne("CreditCard");
context.put("creditCard", account);
context.put("paymentMethodType", paymentMethodType);
} else if (paymentMethod != null && paymentMethod.getString("paymentMethodTypeId").equals("EFT_ACCOUNT")) {
context.creditCard = account;
context.paymentMethodType = paymentMethodType;
} else if ("EFT_ACCOUNT".equals(paymentMethod.paymentMethodTypeId)) {
paymentMethodType = "EFT";
account = paymentMethod.getRelatedOne("EftAccount");
context.put("eftAccount", account);
context.put("paymentMethodType", paymentMethodType);
context.eftAccount = account;
context.paymentMethodType = paymentMethodType;
}
if (account != null) {
if (account) {
address = account.getRelatedOne("PostalAddress");
context.put("postalAddress", address);
context.postalAddress = address;
}
}
} else if (cart.getPaymentMethodTypeIds().size() > 0) {
}
} else if (cart.getPaymentMethodTypeIds()) {
checkOutPaymentId = cart.getPaymentMethodTypeIds().get(0);
context.put("checkOutPaymentId", checkOutPaymentId);
context.checkOutPaymentId = checkOutPaymentId;
}
}
@@ -29,32 +29,24 @@ import org.ofbiz.product.store.ProductStoreWorker;
import org.ofbiz.order.shoppingcart.product.ProductDisplayWorker;
import org.ofbiz.order.shoppingcart.product.ProductPromoWorker;
delegator = request.getAttribute("delegator");
security = request.getAttribute("security");
dispatcher= (LocalDispatcher)request.getAttribute("dispatcher");
userLogin = session.getAttribute("userLogin");
context.put("dispatcher",dispatcher);
productStore = ProductStoreWorker.getProductStore(request);
if( productStore != null ){
context.put("defaultProductStore", productStore);
if( productStore.getString("defaultSalesChannelEnumId") != null )
context.put("defaultSalesChannel", delegator.findByPrimaryKeyCache("Enumeration",
UtilMisc.toMap("enumId",productStore.getString("defaultSalesChannelEnumId"))));
if (productStore) {
context.defaultProductStore = productStore;
if (productStore.defaultSalesChannelEnumId)
context.defaultSalesChannel = delegator.findByPrimaryKeyCache("Enumeration", [enumId : productStore.defaultSalesChannelEnumId]);
}
// Get the Cart
shoppingCart = session.getAttribute("shoppingCart");
context.put("shoppingCart", shoppingCart);
context.shoppingCart = shoppingCart;
salesChannels = delegator.findByAndCache("Enumeration", UtilMisc.toMap("enumTypeId", "ORDER_SALES_CHANNEL"), UtilMisc.toList("sequenceId"));
context.put("salesChannels", salesChannels);
salesChannels = delegator.findByAndCache("Enumeration", [enumTypeId : "ORDER_SALES_CHANNEL"], ["sequenceId"]);
context.salesChannels = salesChannels;
productStores = delegator.findList("ProductStore", null, null, UtilMisc.toList("storeName"), null, true);
context.put("productStores", productStores);
productStores = delegator.findList("ProductStore", null, null, ["storeName"], null, true);
context.productStores = productStores;
suppliers = delegator.findByAnd("PartyRole", UtilMisc.toMap("roleTypeId", "SUPPLIER"));
context.put("suppliers", suppliers);
suppliers = delegator.findByAnd("PartyRole", [roleTypeId : "SUPPLIER"]);
context.suppliers = suppliers;
organizations = delegator.findByAnd("PartyRole", UtilMisc.toMap("roleTypeId", "INTERNAL_ORGANIZATIO"));
context.put("organizations", organizations);
organizations = delegator.findByAnd("PartyRole", [roleTypeId : "INTERNAL_ORGANIZATIO"]);
context.organizations = organizations;
@@ -28,49 +28,49 @@ import org.ofbiz.order.shoppingcart.shipping.*;
shoppingCart = session.getAttribute("shoppingCart");
currencyUomId = shoppingCart.getCurrency();
partyId = shoppingCart.getPartyId();
party = delegator.findByPrimaryKeyCache("Party", UtilMisc.toMap("partyId", partyId));
party = delegator.findByPrimaryKeyCache("Party", [partyId : partyId]);
productStore = ProductStoreWorker.getProductStore(request);
shippingEstWpr = null;
if (shoppingCart != null) {
if (shoppingCart) {
shippingEstWpr = new ShippingEstimateWrapper(dispatcher, shoppingCart, 0);
context.put("shippingEstWpr", shippingEstWpr);
context.put("carrierShipmentMethodList", shippingEstWpr.getShippingMethods());
context.shippingEstWpr = shippingEstWpr;
context.carrierShipmentMethodList = shippingEstWpr.getShippingMethods();
}
// Reassign items requiring drop-shipping to new or existing drop-ship groups
if (shoppingCart != null) {
if (shoppingCart) {
shoppingCart.createDropShipGroups(dispatcher);
}
profiledefs = delegator.findByPrimaryKey("PartyProfileDefault", UtilMisc.toMap("partyId", userLogin.getString("partyId"), "productStoreId", productStoreId));
context.put("profiledefs", profiledefs);
profiledefs = delegator.findByPrimaryKey("PartyProfileDefault", [partyId : userLogin.partyId, productStoreId : productStoreId]);
context.profiledefs : profiledefs;
context.put("shoppingCart", shoppingCart);
context.put("userLogin", userLogin);
context.put("productStoreId", productStore.get("productStoreId"));
context.put("productStore", productStore);
shipToParty = delegator.findByPrimaryKeyCache("Party", UtilMisc.toMap("partyId", shoppingCart.getShipToCustomerPartyId()));
context.put("shippingContactMechList", ContactHelper.getContactMech(shipToParty, "SHIPPING_LOCATION", "POSTAL_ADDRESS", false));
context.put("emailList", ContactHelper.getContactMechByType(party, "EMAIL_ADDRESS", false));
context.shoppingCart = shoppingCart;
context.userLogin = userLogin;
context.productStoreId = productStore.get("productStoreId");
context.productStore = productStore;
shipToParty = delegator.findByPrimaryKeyCache("Party", [partyId : shoppingCart.getShipToCustomerPartyId()]);
context.shippingContactMechList = ContactHelper.getContactMech(shipToParty, "SHIPPING_LOCATION", "POSTAL_ADDRESS", false);
context.emailList = ContactHelper.getContactMechByType(party, "EMAIL_ADDRESS", false);
if (shoppingCart.getShipmentMethodTypeId() != null && shoppingCart.getCarrierPartyId() != null) {
context.put("chosenShippingMethod", shoppingCart.getShipmentMethodTypeId() + '@' + shoppingCart.getCarrierPartyId());
} else if (profiledefs != null && profiledefs.get("defaultShipMeth") != null) {
context.put("chosenShippingMethod", profiledefs.get("defaultShipMeth"));
if (shoppingCart.getShipmentMethodTypeId() && shoppingCart.getCarrierPartyId()) {
context.chosenShippingMethod = shoppingCart.getShipmentMethodTypeId() + '@' + shoppingCart.getCarrierPartyId();
} else if (profiledefs?.defaultShipMeth) {
context.chosenShippingMethod = profiledefs.defaultShipMeth;
}
// other profile defaults
if (shoppingCart.getShippingAddress() == null && profiledefs != null && profiledefs.get("defaultShipAddr") != null) {
shoppingCart.setShippingContactMechId(profiledefs.get("defaultShipAddr"));
if (!shoppingCart.getShippingAddress() && profiledefs?.defaultShipAddr) {
shoppingCart.setShippingContactMechId(profiledefs.defaultShipAddr);
}
if (shoppingCart.selectedPayments() == 0 && profiledefs != null && profiledefs.get("defaultPayMeth") != null) {
shoppingCart.addPayment(profiledefs.get("defaultPayMeth"));
if (shoppingCart.selectedPayments() == 0 && profiledefs?.defaultPayMeth) {
shoppingCart.addPayment(profiledefs.defaultPayMeth);
}
// create a list containing all the parties associated to the current cart, useful to change
// the ship to party id
List cartParties = UtilMisc.toList(shoppingCart.getShipToCustomerPartyId());
cartParties = [shoppingCart.getShipToCustomerPartyId()];
if (!cartParties.contains(partyId)) {
cartParties.add(partyId);
}
@@ -89,13 +89,12 @@ if (!cartParties.contains(shoppingCart.getEndUserCustomerPartyId())) {
if (!cartParties.contains(shoppingCart.getSupplierAgentPartyId())) {
cartParties.add(shoppingCart.getSupplierAgentPartyId());
}
List salesReprs = (List)shoppingCart.getAdditionalPartyRoleMap().get("SALES_REP");
if (salesReprs != null) {
for (int i = 0; i < salesReprs.size(); i++) {
String salesRep = (String)salesReprs.get(i);
salesReps = shoppingCart.getAdditionalPartyRoleMap().SALES_REP;
if (salesReps) {
salesReps.each { salesRep ->
if (!cartParties.contains(salesRep)) {
cartParties.add(salesRep);
}
}
}
context.put("cartParties", cartParties);
context.cartParties = cartParties;
@@ -28,31 +28,31 @@ cart = session.getAttribute("shoppingCart");
currencyUomId = cart.getCurrency();
userLogin = session.getAttribute("userLogin");
partyId = cart.getPartyId();
party = delegator.findByPrimaryKeyCache("Party", UtilMisc.toMap("partyId", partyId));
party = delegator.findByPrimaryKeyCache("Party", [partyId : partyId]);
productStoreId = ProductStoreWorker.getProductStoreId(request);
checkOutPaymentId = "";
if (cart != null) {
if (cart.getPaymentMethodIds().size() > 0) {
if (cart) {
if (cart.getPaymentMethodIds()) {
checkOutPaymentId = cart.getPaymentMethodIds().get(0);
} else if (cart.getPaymentMethodTypeIds().size() > 0) {
} else if (cart.getPaymentMethodTypeIds()) {
checkOutPaymentId = cart.getPaymentMethodTypeIds().get(0);
}
}
finAccounts = delegator.findByAnd("FinAccountAndRole", UtilMisc.toMap("partyId", partyId, "roleTypeId", "OWNER"));
finAccounts = delegator.findByAnd("FinAccountAndRole", [partyId : partyId, roleTypeId : "OWNER"]);
finAccounts = EntityUtil.filterByDate(finAccounts, UtilDateTime.nowTimestamp(), "roleFromDate", "roleThruDate", true);
finAccounts = EntityUtil.filterByDate(finAccounts);
context.put("finAccounts",finAccounts);
context.finAccounts = finAccounts;
context.put("shoppingCart", cart);
context.put("userLogin", userLogin);
context.put("productStoreId", productStoreId);
context.put("checkOutPaymentId", checkOutPaymentId);
context.put("paymentMethodList", EntityUtil.filterByDate(party.getRelated("PaymentMethod", null, UtilMisc.toList("paymentMethodTypeId")), true));
context.shoppingCart = cart;
context.userLogin = userLogin;
context.productStoreId = productStoreId;
context.checkOutPaymentId = checkOutPaymentId;
context.paymentMethodList = EntityUtil.filterByDate(party.getRelated("PaymentMethod", null, ["paymentMethodTypeId"]), true);
billingAccountList = BillingAccountWorker.makePartyBillingAccountList(userLogin, currencyUomId, partyId, delegator, dispatcher);
if (billingAccountList != null && billingAccountList.size() > 0) {
context.put("selectedBillingAccountId", cart.getBillingAccountId());
context.put("billingAccountList", billingAccountList);
if (billingAccountList) {
context.selectedBillingAccountId = cart.getBillingAccountId();
context.billingAccountList = billingAccountList;
}
@@ -1,61 +0,0 @@
/*
* 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.
*/
import org.ofbiz.order.shoppingcart.ShoppingCartEvents;
import org.ofbiz.order.shoppingcart.ShoppingCart;
import org.ofbiz.entity.*;
import org.ofbiz.base.util.*;
delegator = request.getAttribute("delegator");
cart = ShoppingCartEvents.getCartObject(request);
additionalPartyRole = cart.getAdditionalPartyRoleMap();
it = additionalPartyRole.entrySet().iterator();
roleData = new HashMap();
partyData = new HashMap();
while (it.hasNext()) {
me = (Map.Entry) it.next();
roleData.put(me.getKey(), delegator.findByPrimaryKeyCache("RoleType", UtilMisc.toMap("roleTypeId", me.getKey())));
pIt = ((List)me.getValue()).iterator();
while (pIt.hasNext()) {
partyId = pIt.next();
party = new HashMap();
party.put("partyId", partyId);
gv = delegator.findByPrimaryKeyCache("Party", UtilMisc.toMap("partyId", partyId));
if (gv.get("partyTypeId").equals("PERSON")) {
gv = gv.getRelatedOneCache("Person");
party.put("type", "person");
party.put("firstName", gv.get("firstName"));
party.put("lastName", gv.get("lastName"));
} else {
gv = gv.getRelatedOneCache("PartyGroup");
party.put("type", "group");
party.put("groupName", gv.get("groupName"));
}
partyData.put(partyId, party);
}
}
context.put("additionalPartyRoleMap", additionalPartyRole);
context.put("roleList", cart.getAdditionalPartyRoleMap().keySet());
context.put("roleData", roleData);
context.put("partyData", partyData);
@@ -51,7 +51,7 @@ under the License.
<set field="headerItem" value="orderentry"/>
<set field="title-property" value="PageTitleCheckoutOptions"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/checkoutpayment.bsh"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/checkoutoptions.bsh"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/CheckoutOptions.groovy"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/storepaymentoptions.bsh"/>
</actions>
<widgets>
@@ -160,7 +160,7 @@ under the License.
<actions>
<set field="stepTitleId" value="OrderOrderEntryPaymentSettings"/>
<set field="stepLabelId" value="AccountingPayment"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/billsettings.bsh"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/BillSettings.groovy"/>
</actions>
<widgets>
<decorator-screen name="CommonOrderCheckoutDecorator">
@@ -179,7 +179,7 @@ under the License.
<set field="stepTitleId" value="PartyAdditionalPartyEntry"/>
<set field="stepLabelId" value="PartyParties"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/setAdditionalParty.bsh"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/additionalPartyListing.bsh"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/AdditionalPartyListing.groovy"/>
</actions>
<widgets>
<decorator-screen name="CommonOrderCheckoutDecorator">
@@ -23,7 +23,7 @@ under the License.
<actions>
<set field="titleProperty" value="PageTitleOrderInits"/>
<set field="headerItem" value="orderentry"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/checkinits.bsh"/>
<script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/CheckInits.groovy"/>
</actions>
<widgets>
<decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">