Author: doogie
Date: Sat Mar 21 23:48:04 2009 New Revision: 757104 URL: http://svn.apache.org/viewvc?rev=757104&view=rev Log: Fix purely empty whitespace lines, and remove trailing whitespace. Modified: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/transaction/WebPosTransaction.java Modified: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java?rev=757104&r1=757103&r2=757104&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java (original) +++ ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java Sat Mar 21 23:48:04 2009 @@ -6,9 +6,9 @@ * 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 @@ -33,15 +33,15 @@ import org.ofbiz.webpos.session.WebPosSession; public class WebPosEvents { - + public static String module = WebPosEvents.class.getName(); - + public static String posLogin(HttpServletRequest request, HttpServletResponse response) { String responseString = LoginEvents.storeLogin(request, response); - + if ("success".equals(responseString)) { - HttpSession session = request.getSession(true); - + HttpSession session = request.getSession(true); + // get the posTerminalId String posTerminalId = (String) request.getParameter("posTerminalId"); session.removeAttribute("shoppingCart"); @@ -50,12 +50,12 @@ } return responseString; } - + public static String existsWebPosSession(HttpServletRequest request, HttpServletResponse response) { String responseString = "success"; HttpSession session = request.getSession(true); WebPosSession webPosSession = (WebPosSession) session.getAttribute("webPosSession"); - + if (UtilValidate.isEmpty(webPosSession)) { responseString = "error"; } @@ -68,26 +68,26 @@ ShoppingCart cart = (ShoppingCart) session.getAttribute("shoppingCart"); GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); - + if (UtilValidate.isEmpty(webPosSession)) { String productStoreId = ProductStoreWorker.getProductStoreId(request); GenericValue productStore = ProductStoreWorker.getProductStore(productStoreId, delegator); String facilityId = null; String currencyUomId = request.getParameter("currencyUomId"); - + if (UtilValidate.isNotEmpty(productStore)) { facilityId = productStore.getString("inventoryFacilityId"); if (UtilValidate.isEmpty(currencyUomId)) { currencyUomId = productStore.getString("defaultCurrencyUomId"); } } - + if (UtilValidate.isEmpty(cart)) { cart = new ShoppingCart(delegator, productStoreId, request.getLocale(), currencyUomId); session.setAttribute("shoppingCart", cart); - + } - + if (UtilValidate.isNotEmpty(posTerminalId)) { webPosSession = new WebPosSession(posTerminalId, null, userLogin, request.getLocale(), productStoreId, facilityId, currencyUomId, delegator, dispatcher, cart); session.setAttribute("webPosSession", webPosSession); @@ -97,7 +97,7 @@ } public static void removeWebPosSession(HttpServletRequest request, String posTerminalId) { - HttpSession session = request.getSession(true); + HttpSession session = request.getSession(true); session.removeAttribute("shoppingCart"); session.removeAttribute("webPosSession"); getWebPosSession(request, posTerminalId); @@ -107,7 +107,7 @@ HttpSession session = request.getSession(true); WebPosSession webPosSession = (WebPosSession) session.getAttribute("webPosSession"); if (UtilValidate.isNotEmpty(webPosSession)) { - webPosSession.getCurrentTransaction().processSale(); + webPosSession.getCurrentTransaction().processSale(); String posTerminalId = webPosSession.getId(); removeWebPosSession(request, posTerminalId); } Modified: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java?rev=757104&r1=757103&r2=757104&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java (original) +++ ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java Sat Mar 21 23:48:04 2009 @@ -6,9 +6,9 @@ * 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 @@ -39,9 +39,9 @@ import org.ofbiz.webpos.transaction.WebPosTransaction; public class WebPosSession { - + public static final String module = WebPosSession.class.getName(); - + private String id = null; private Map<String, Object> attributes = FastMap.newInstance(); private GenericValue userLogin = null; @@ -55,7 +55,7 @@ private Boolean mgrLoggedIn = null; private WebPosTransaction webPosTransaction = null; private ShoppingCart cart = null; - + public WebPosSession(String id, Map<String, Object> attributes, GenericValue userLogin, Locale locale, String productStoreId, String facilityId, String currencyUomId, GenericDelegator delegator, LocalDispatcher dispatcher, ShoppingCart cart) { this.id = id; this.attributes = attributes; @@ -64,8 +64,8 @@ this.productStoreId = productStoreId; this.facilityId = facilityId; this.currencyUomId = currencyUomId; - - if (UtilValidate.isNotEmpty(delegator)) + + if (UtilValidate.isNotEmpty(delegator)) { this.delegator = delegator; this.delegatorName = delegator.getDelegatorName(); @@ -73,28 +73,28 @@ this.delegator = this.getDelegator(); this.delegatorName = delegator.getDelegatorName(); } - + this.dispatcher = dispatcher; this.cart = cart; Debug.logInfo("Created WebPosSession [" + id + "]", module); } - + public GenericValue getUserLogin() { return this.userLogin; } - + public void setAttribute(String name, Object value) { this.attributes.put(name, value); } - + public Object getAttribute(String name) { return this.attributes.get(name); } - + public String getId() { return this.id; } - + public String getUserLoginId() { if (UtilValidate.isEmpty(getUserLogin())) { return null; @@ -102,7 +102,7 @@ return this.getUserLogin().getString("userLoginId"); } } - + public String getUserPartyId() { if (UtilValidate.isEmpty(getUserLogin())) { return null; @@ -110,69 +110,69 @@ return this.getUserLogin().getString("partyId"); } } - + public Locale getLocale() { return (Locale) this.locale; } - + public void setLocale(Locale locale) { this.locale = locale; } - + public String getProductStoreId() { return this.productStoreId; } - + public void setProductStoreId(String productStoreId) { this.productStoreId = productStoreId; } - + public String getFacilityId() { return this.facilityId; } - + public void setFacilityId(String facilityId) { this.facilityId = facilityId; } - + public String getCurrencyUomId() { return this.currencyUomId; - } - + } + public void setCurrencyUomId(String currencyUomId) { this.currencyUomId = currencyUomId; } - + public GenericDelegator getDelegator() { if (UtilValidate.isEmpty(delegator)) { delegator = GenericDelegator.getGenericDelegator(delegatorName); } return delegator; } - + public LocalDispatcher getDispatcher() { return dispatcher; } - + public ShoppingCart getCart() { return this.cart; } - + public void logout() { if (UtilValidate.isNotEmpty(webPosTransaction)) { webPosTransaction.closeTx(); webPosTransaction = null; } - + if (UtilValidate.isNotEmpty(getUserLogin())) { LoginWorker.setLoggedOut(this.getUserLogin().getString("userLoginId"), this.getDelegator()); } } - + public void login(String username, String password, LocalDispatcher dispatcher) throws UserLoginFailure { this.checkLogin(username, password, dispatcher); } - + public GenericValue checkLogin(String username, String password, LocalDispatcher dispatcher) throws UserLoginFailure { // check the required parameters and objects if (UtilValidate.isEmpty(dispatcher)) { @@ -184,7 +184,7 @@ if (UtilValidate.isEmpty(password)) { throw new UserLoginFailure(UtilProperties.getMessage("PartyUiLabels", "PartyPasswordMissing", getLocale())); } - + // call the login service Map<String, Object> result = null; try { @@ -195,7 +195,7 @@ } catch (Throwable t) { Debug.logError(t, "Throwable caught!", module); } - + // check for errors if (ServiceUtil.isError(result)) { throw new UserLoginFailure(ServiceUtil.getErrorMessage(result)); @@ -207,7 +207,7 @@ return ul; } } - + public boolean hasRole(GenericValue userLogin, String roleTypeId) { if (UtilValidate.isEmpty(userLogin) || UtilValidate.isEmpty(roleTypeId)) { return false; @@ -220,45 +220,45 @@ Debug.logError(e, module); return false; } - + if (UtilValidate.isEmpty(partyRole)) { return false; } - + return true; } - + public boolean isManagerLoggedIn() { if (UtilValidate.isEmpty(mgrLoggedIn)) { mgrLoggedIn = new Boolean(hasRole(getUserLogin(), "MANAGER")); } return mgrLoggedIn.booleanValue(); } - + public WebPosTransaction getCurrentTransaction() { if (UtilValidate.isEmpty(webPosTransaction)) { webPosTransaction = new WebPosTransaction(this); } return webPosTransaction; } - + public void setCurrentTransaction(WebPosTransaction webPosTransaction) { this.webPosTransaction = webPosTransaction; } - + public class UserLoginFailure extends GeneralException { public UserLoginFailure() { super(); } - + public UserLoginFailure(String str) { super(str); } - + public UserLoginFailure(String str, Throwable nested) { super(str, nested); } - + public UserLoginFailure(Throwable nested) { super(nested); } Modified: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/transaction/WebPosTransaction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/transaction/WebPosTransaction.java?rev=757104&r1=757103&r2=757104&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/transaction/WebPosTransaction.java (original) +++ ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/transaction/WebPosTransaction.java Sat Mar 21 23:48:04 2009 @@ -6,9 +6,9 @@ * 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 @@ -47,13 +47,13 @@ import org.ofbiz.webpos.session.WebPosSession; public class WebPosTransaction { - + public static final String resource = "WebPosUiLabels"; public static final String module = WebPosTransaction.class.getName(); public static final int NO_PAYMENT = 0; public static final int INTERNAL_PAYMENT = 1; public static final int EXTERNAL_PAYMENT = 2; - + private CheckOutHelper ch = null; private GenericValue txLog = null; private String transactionId = null; @@ -63,7 +63,7 @@ private int drawerIdx = 0; private GenericValue shipAddress = null; private WebPosSession webPosSession = null; - + public WebPosTransaction(WebPosSession session) { this.webPosSession = session; this.partyId = "_NA_"; @@ -73,11 +73,11 @@ cart.setChannelType("POS_SALES_CHANNEL"); cart.setFacilityId(session.getFacilityId()); cart.setTerminalId(session.getId()); - + if (session.getUserLogin() != null) { cart.addAdditionalPartyRole(session.getUserLogin().getString("partyId"), "SALES_REP"); } - + // setup the TX log this.transactionId = delegator.getNextSeqId("PosTerminalLog"); txLog = delegator.makeValue("PosTerminalLog"); @@ -93,34 +93,34 @@ } catch (GenericEntityException e) { Debug.logError(e, "Unable to create TX log - not fatal", module); } - + Debug.logInfo("Created WebPosTransaction [" + this.transactionId + "]", module); } - + public String getUserLoginId() { return webPosSession.getUserLoginId(); } - + public int getDrawerNumber() { return drawerIdx + 1; } - + public String getTransactionId() { return this.transactionId; } - + public String getTerminalId() { return webPosSession.getId(); } - + public String getFacilityId() { return webPosSession.getFacilityId(); } - + public String getTerminalLogId() { return txLog.getString("posTerminalLogId"); } - + public boolean isOpen() { GenericValue terminalState = this.getTerminalState(); if (terminalState != null) { @@ -130,7 +130,7 @@ } return this.isOpen; } - + public GenericValue getTerminalState() { GenericDelegator delegator = webPosSession.getDelegator(); List<GenericValue> states = null; @@ -142,7 +142,7 @@ states = EntityUtil.filterByDate(states, UtilDateTime.nowTimestamp(), "openedDate", "closedDate", true); return EntityUtil.getFirst(states); } - + public void closeTx() { if (UtilValidate.isNotEmpty(txLog)) { txLog.set("statusId", "POSTX_CLOSED"); @@ -157,7 +157,7 @@ Debug.logInfo("Transaction closed", module); } } - + public void paidInOut(String type) { if (UtilValidate.isNotEmpty(txLog)) { txLog.set("statusId", "POSTX_PAID_" + type); @@ -171,7 +171,7 @@ Debug.logInfo("Paid "+ type, module); } } - + public void modifyPrice(String productId, BigDecimal price) { Debug.logInfo("Modify item price " + productId + "/" + price, module); ShoppingCartItem item = getCart().findCartItem(productId, null, null, null, BigDecimal.ZERO); @@ -181,7 +181,7 @@ Debug.logInfo("Item not found " + productId, module); } } - + public void calcTax() { try { ch.calcAndAddTax(this.getStoreOrgAddress()); @@ -189,7 +189,7 @@ Debug.logError(e, module); } } - + public BigDecimal processSale() throws GeneralException { //TODO insert check if not enough funds Debug.log("process sale", module); @@ -198,27 +198,27 @@ if (grandTotal.compareTo(paymentAmt) > 0) { throw new IllegalStateException(); } - + // attach the party ID to the cart getCart().setOrderPartyId(partyId); - + // validate payment methods Debug.log("Validating payment methods", module); Map<String, ? extends Object> valRes = ch.validatePaymentMethods(); if (valRes != null && ServiceUtil.isError(valRes)) { throw new GeneralException(ServiceUtil.getErrorMessage(valRes)); } - + // store the "order" Debug.log("Store order", module); Map<String, ? extends Object> orderRes = ch.createOrder(webPosSession.getUserLogin()); - + if (orderRes != null && ServiceUtil.isError(orderRes)) { throw new GeneralException(ServiceUtil.getErrorMessage(orderRes)); } else if (orderRes != null) { this.orderId = (String) orderRes.get("orderId"); } - + // process the payment(s) Debug.log("Processing the payment(s)", module); Map<String, ? extends Object> payRes = null; @@ -228,20 +228,20 @@ Debug.logError(e, module); throw e; } - + if (payRes != null && ServiceUtil.isError(payRes)) { throw new GeneralException(ServiceUtil.getErrorMessage(payRes)); } - + // get the change due BigDecimal change = grandTotal.subtract(paymentAmt); - + // TODO notify the change due - + // threaded drawer/receipt printing // TODO open the drawer // TODO print the receipt - + // save the TX Log txLog.set("statusId", "POSTX_SOLD"); txLog.set("orderId", orderId); @@ -252,10 +252,10 @@ } catch (GenericEntityException e) { Debug.logError(e, "Unable to store TX log - not fatal", module); } - + return change; } - + private synchronized GenericValue getStoreOrgAddress() { if (UtilValidate.isEmpty(this.shipAddress)) { // locate the store's physical address - use this for tax @@ -268,7 +268,7 @@ if (UtilValidate.isEmpty(facility)) { return null; } - + List<GenericValue> fcp = null; try { fcp = facility.getRelatedByAnd("FacilityContactMechPurpose", UtilMisc.toMap("contactMechPurposeTypeId", "SHIP_ORIG_LOCATION")); @@ -288,30 +288,30 @@ } return this.shipAddress; } - + public void clearPayments() { Debug.logInfo("all payments cleared from sale", module); getCart().clearPayments(); } - + public void clearPayment(int index) { Debug.logInfo("removing payment " + index, module); getCart().clearPayment(index); } - + public void clearPayment(String id) { Debug.logInfo("removing payment " + id, module); getCart().clearPayment(id); } - + public CartPaymentInfo getPaymentInfo(int index) { return getCart().getPaymentInfo(index); } - + public String getPaymentMethodTypeId(int index) { return getCart().getPaymentInfo(index).paymentMethodTypeId; } - + public int checkPaymentMethodType(String paymentMethodTypeId) { Map<String, ? extends Object> fields = UtilMisc.toMap("paymentMethodTypeId", paymentMethodTypeId, "productStoreId", webPosSession.getProductStoreId()); List<GenericValue> values = null; @@ -320,7 +320,7 @@ } catch (GenericEntityException e) { Debug.logError(e, module); } - + final String externalCode = "PRDS_PAY_EXTERNAL"; if (UtilValidate.isEmpty(values)) { return NO_PAYMENT; @@ -334,7 +334,7 @@ isExternal = false; } } - + if (isExternal) { return EXTERNAL_PAYMENT; } else { @@ -342,23 +342,23 @@ } } } - + public static int getNoPaymentCode() { return NO_PAYMENT; } - + public static int getExternalPaymentCode() { return EXTERNAL_PAYMENT; } - + public static int getInternalPaymentCode() { return INTERNAL_PAYMENT; } - + public BigDecimal addPayment(String id, BigDecimal amount) { return this.addPayment(id, amount, null, null); } - + public BigDecimal addPayment(String id, BigDecimal amount, String refNum, String authCode) { Debug.logInfo("Added payment " + id + "/" + amount, module); if ("CASH".equals(id)) { @@ -368,7 +368,7 @@ getCart().addPaymentAmount(id, amount, refNum, authCode, true, true, false); return this.getTotalDue(); } - + public BigDecimal processAmount(String amtStr) throws GeneralException { BigDecimal amount; if (UtilValidate.isNotEmpty(amtStr)) { @@ -387,36 +387,36 @@ } return amount; } - + public synchronized void processNoPayment(String paymentMethodTypeId) { try { BigDecimal amount = processAmount(null); Debug.log("Processing [" + paymentMethodTypeId + "] Amount : " + amount, module); - + // add the payment addPayment(paymentMethodTypeId, amount, null, null); } catch (GeneralException e) { // errors handled } } - + public synchronized void processExternalPayment(String paymentMethodTypeId, String amountStr, String refNum) { if (refNum == null) { //TODO handle error message return; } - + try { BigDecimal amount = processAmount(amountStr); Debug.log("Processing [" + paymentMethodTypeId + "] Amount : " + amount, module); - + // add the payment addPayment(paymentMethodTypeId, amount, refNum, null); } catch (GeneralException e) { // errors handled } } - + public String makeCreditCardVo(String cardNumber, String expDate, String firstName, String lastName) { LocalDispatcher dispatcher = webPosSession.getDispatcher(); String expMonth = expDate.substring(0, 2); @@ -425,7 +425,7 @@ if (expYear.length() == 2) { expYear = "20" + expYear; } - + Map<String, Object> svcCtx = FastMap.newInstance(); svcCtx.put("userLogin", webPosSession.getUserLogin()); svcCtx.put("partyId", partyId); @@ -435,7 +435,7 @@ svcCtx.put("expMonth", expMonth); svcCtx.put("expYear", expYear); svcCtx.put("cardType", UtilValidate.getCardType(cardNumber)); - + Map<String, Object> svcRes = null; try { svcRes = dispatcher.runSync("createCreditCard", svcCtx); @@ -450,14 +450,14 @@ return (String) svcRes.get("paymentMethodId"); } } - + public void setPaymentRefNum(int paymentIndex, String refNum, String authCode) { Debug.log("setting payment index reference number " + paymentIndex + " / " + refNum + " / " + authCode, module); ShoppingCart.CartPaymentInfo inf = getCart().getPaymentInfo(paymentIndex); inf.refNum[0] = refNum; inf.refNum[1] = authCode; } - + /* CVV2 code should be entered when a card can't be swiped */ public void setPaymentSecurityCode(String paymentId, String refNum, String securityCode) { Debug.log("setting payment security code " + paymentId, module); @@ -466,7 +466,7 @@ inf.securityCode = securityCode; inf.isSwiped = false; } - + /* Track2 data should be sent to processor when a card is swiped. */ public void setPaymentTrack2(String paymentId, String refNum, String securityCode) { Debug.log("setting payment security code " + paymentId, module); @@ -475,7 +475,7 @@ inf.securityCode = securityCode; inf.isSwiped = true; } - + /* Postal code should be entered when a card can't be swiped */ public void setPaymentPostalCode(String paymentId, String refNum, String postalCode) { Debug.log("setting payment security code " + paymentId, module); @@ -483,35 +483,35 @@ ShoppingCart.CartPaymentInfo inf = getCart().getPaymentInfo(paymentIndex); inf.postalCode = postalCode; } - + public BigDecimal getTaxTotal() { return getCart().getTotalSalesTax(); } - + public BigDecimal getGrandTotal() { return getCart().getGrandTotal(); } - + public int getNumberOfPayments() { return getCart().selectedPayments(); } - + public BigDecimal getPaymentTotal() { return getCart().getPaymentTotal(); } - + public BigDecimal getTotalDue() { BigDecimal grandTotal = this.getGrandTotal(); BigDecimal paymentAmt = this.getPaymentTotal(); return grandTotal.subtract(paymentAmt); } - + public String addProductPromoCode(String code) { String result = getCart().addProductPromoCode(code, webPosSession.getDispatcher()); calcTax(); return result; } - + public ShoppingCart getCart() { return webPosSession.getCart(); } |
Free forum by Nabble | Edit this page |