当前位置: 首页>>代码示例>>Java>>正文


Java UtilXml.addChildElementValue方法代码示例

本文整理汇总了Java中org.ofbiz.base.util.UtilXml.addChildElementValue方法的典型用法代码示例。如果您正苦于以下问题:Java UtilXml.addChildElementValue方法的具体用法?Java UtilXml.addChildElementValue怎么用?Java UtilXml.addChildElementValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ofbiz.base.util.UtilXml的用法示例。


在下文中一共展示了UtilXml.addChildElementValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: splitEstimatePackages

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private static void splitEstimatePackages(DispatchContext dctx, Document requestDoc, Element shipmentElement, List<Map<String, Object>> shippableItemInfo, 
        BigDecimal maxWeight, BigDecimal minWeight, String totalWeightStr) {
    List<Map<String, BigDecimal>> packages = ShipmentWorker.getPackageSplit(dctx, shippableItemInfo, maxWeight);
    if (UtilValidate.isNotEmpty(packages)) {
        for (Map<String, BigDecimal> packageMap: packages) {
            addPackageElement(dctx, requestDoc, shipmentElement, shippableItemInfo, packageMap, minWeight);
        }
    } else {
        // Add a dummy package
        BigDecimal packageWeight = BigDecimal.ONE;
        try {
            packageWeight = new BigDecimal(totalWeightStr);
        } catch (NumberFormatException e) {
            Debug.logError(e, module);
        }
        Element packageElement = UtilXml.addChildElement(shipmentElement, "Package", requestDoc);
        Element packagingTypeElement = UtilXml.addChildElement(packageElement, "PackagingType", requestDoc);
        UtilXml.addChildElementValue(packagingTypeElement, "Code", "00", requestDoc);
        Element packageWeightElement = UtilXml.addChildElement(packageElement, "PackageWeight", requestDoc);
        UtilXml.addChildElementValue(packageWeightElement, "Weight", "" + packageWeight, requestDoc);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:23,代码来源:UpsServices.java

示例2: addPackageElement

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private static void addPackageElement(DispatchContext dctx, Document requestDoc, Element shipmentElement, List<Map<String, Object>> shippableItemInfo, Map<String, BigDecimal> packageMap, BigDecimal minWeight) {
    BigDecimal packageWeight = checkForDefaultPackageWeight(ShipmentWorker.calcPackageWeight(dctx,packageMap, shippableItemInfo, BigDecimal.ZERO), minWeight);
    Element packageElement = UtilXml.addChildElement(shipmentElement, "Package", requestDoc);
    Element packagingTypeElement = UtilXml.addChildElement(packageElement, "PackagingType", requestDoc);
    UtilXml.addChildElementValue(packagingTypeElement, "Code", "00", requestDoc);
    UtilXml.addChildElementValue(packagingTypeElement, "Description", "Unknown PackagingType", requestDoc);
    UtilXml.addChildElementValue(packageElement, "Description", "Package Description", requestDoc);
    Element packageWeightElement = UtilXml.addChildElement(packageElement, "PackageWeight", requestDoc);
    UtilXml.addChildElementValue(packageWeightElement, "Weight", packageWeight.toPlainString(), requestDoc);
    //If product is in shippable Package then it we should have one product per packagemap
    if (packageMap.size() ==1) {
        Iterator<String> i = packageMap.keySet().iterator();
        String productId = i.next();
        Map<String, Object> productInfo = ShipmentWorker.getProductItemInfo(shippableItemInfo, productId);
        if (productInfo.get("inShippingBox") != null &&  ((String) productInfo.get("inShippingBox")).equalsIgnoreCase("Y")
                && productInfo.get("shippingDepth") !=null && productInfo.get("shippingWidth") !=null && productInfo.get("shippingHeight") !=null) {
            Element dimensionsElement = UtilXml.addChildElement(packageElement, "Dimensions", requestDoc);
            UtilXml.addChildElementValue(dimensionsElement, "Length", productInfo.get("shippingDepth").toString(), requestDoc);
            UtilXml.addChildElementValue(dimensionsElement, "Width", productInfo.get("shippingWidth").toString(), requestDoc);
            UtilXml.addChildElementValue(dimensionsElement, "Height", productInfo.get("shippingHeight").toString(), requestDoc);
        }
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:24,代码来源:UpsServices.java

示例3: buildSecondaryTxRequest

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private static Document buildSecondaryTxRequest(Map<String, Object> context, String id, String type, BigDecimal amount, Delegator delegator) {

        String paymentConfig = (String) context.get("paymentConfig");
        if (UtilValidate.isEmpty(paymentConfig)) {
            paymentConfig = "payment.properties";
        }

        Document requestDocument = createRequestDocument(paymentConfig, delegator);

        Element engineDocElement = UtilXml.firstChildElement(requestDocument.getDocumentElement(), "EngineDoc");
        Element orderFormDocElement = UtilXml.firstChildElement(engineDocElement, "OrderFormDoc");
        UtilXml.addChildElementValue(orderFormDocElement, "Id", id, requestDocument);

        // Default to currency code 840 (USD)
        String currencyCode = EntityUtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.currencyCode", "840", delegator);

        appendTransactionNode(orderFormDocElement, type, amount, currencyCode);

        return requestDocument;
    }
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:21,代码来源:CCPaymentServices.java

示例4: appendAddressNode

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private static void appendAddressNode(Element element, GenericValue address) {

        Document document = element.getOwnerDocument();

        Element addressElement = UtilXml.addChildElement(element, "Address", document);

        UtilXml.addChildElementValue(addressElement, "Name", address.getString("toName"), document);
        UtilXml.addChildElementValue(addressElement, "Street1", address.getString("address1"), document);
        UtilXml.addChildElementValue(addressElement, "Street2", address.getString("address2"), document);
        UtilXml.addChildElementValue(addressElement, "City", address.getString("city"), document);
        UtilXml.addChildElementValue(addressElement, "StateProv", address.getString("stateProvinceGeoId"), document);
        UtilXml.addChildElementValue(addressElement, "PostalCode", address.getString("postalCode"), document);

        String countryGeoId = address.getString("countryGeoId");
        if (UtilValidate.isNotEmpty(countryGeoId)) {
            try {
                GenericValue countryGeo = address.getRelatedOne("CountryGeo", true);
                UtilXml.addChildElementValue(addressElement, "Country", countryGeo.getString("geoSecCode"), document);
            } catch (GenericEntityException gee) {
                Debug.logInfo(gee, "Error finding related Geo for countryGeoId: " + countryGeoId, module);
            }
        }
    }
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:24,代码来源:CCPaymentServices.java

示例5: appendTransactionNode

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private static void appendTransactionNode(Element element, String type, BigDecimal amount, String currencyCode) {

        Document document = element.getOwnerDocument();

        Element transactionElement = UtilXml.addChildElement(element, "Transaction", document);
        UtilXml.addChildElementValue(transactionElement, "Type", type, document);

        // Some transactions will not have an amount (release, reAuth)
        if (amount != null) {
            Element currentTotalsElement = UtilXml.addChildElement(transactionElement, "CurrentTotals", document);
            Element totalsElement = UtilXml.addChildElement(currentTotalsElement, "Totals", document);

            // DecimalFormat("#") is used here in case the total is something like 9.9999999...
            // in that case, we want to send 999, not 999.9999999...
            String totalString = amount.setScale(decimals, rounding).movePointRight(2).toPlainString();

            Element totalElement = UtilXml.addChildElementValue(totalsElement, "Total", totalString, document);
            totalElement.setAttribute("DataType", "Money");
            totalElement.setAttribute("Currency", currencyCode);
        }
    }
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:22,代码来源:CCPaymentServices.java

示例6: createAccessRequestDocument

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public static Document createAccessRequestDocument(Delegator delegator, String shipmentGatewayConfigId, 
        String serviceConfigProps) {
    Document accessRequestDocument = UtilXml.makeEmptyXmlDocument("AccessRequest");
    Element accessRequestElement = accessRequestDocument.getDocumentElement();
    String accessLicenseNumber = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessLicenseNumber", serviceConfigProps, "shipment.ups.access.license.number", "");
    String userId = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessUserId", serviceConfigProps, "shipment.ups.access.user.id", "");
    String password = getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessPassword", serviceConfigProps, "shipment.ups.access.password", "");
    UtilXml.addChildElementValue(accessRequestElement, "AccessLicenseNumber",accessLicenseNumber, accessRequestDocument);
    UtilXml.addChildElementValue(accessRequestElement, "UserId", userId, accessRequestDocument);
    UtilXml.addChildElementValue(accessRequestElement, "Password", password, accessRequestDocument);
    return accessRequestDocument;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:13,代码来源:UpsServices.java

示例7: createAccessRequestDocument

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public static Document createAccessRequestDocument(Delegator delegator, String shipmentGatewayConfigId, String resource) {
    Document eCommerceRequestDocument = UtilXml.makeEmptyXmlDocument("eCommerce");
    Element eCommerceRequestElement = eCommerceRequestDocument.getDocumentElement();
    eCommerceRequestElement.setAttribute("version", getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "headVersion", resource, "shipment.dhl.head.version"));
    eCommerceRequestElement.setAttribute("action", getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "headAction", resource, "shipment.dhl.head.action"));
    Element requestorRequestElement = UtilXml.addChildElement(eCommerceRequestElement, "Requestor", eCommerceRequestDocument);
    UtilXml.addChildElementValue(requestorRequestElement, "ID", getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessUserId", resource, "shipment.dhl.access.userid"),
            eCommerceRequestDocument);
    UtilXml.addChildElementValue(requestorRequestElement, "Password", getShipmentGatewayConfigValue(delegator, shipmentGatewayConfigId, "accessPassword", resource, "shipment.dhl.access.password"),
            eCommerceRequestDocument);
    return eCommerceRequestDocument;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:13,代码来源:DhlServices.java

示例8: appendPaymentMechNode

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private static void appendPaymentMechNode(Element element, GenericValue creditCard, String cardSecurityCode, String localeCode) {

        Document document = element.getOwnerDocument();

        Element paymentMechElement = UtilXml.addChildElement(element, "PaymentMech", document);
        Element creditCardElement = UtilXml.addChildElement(paymentMechElement, "CreditCard", document);

        UtilXml.addChildElementValue(creditCardElement, "Number", creditCard.getString("cardNumber"), document);

        String expDate = creditCard.getString("expireDate");
        Element expiresElement = UtilXml.addChildElementValue(creditCardElement, "Expires",
                expDate.substring(0, 3) + expDate.substring(5), document);
        expiresElement.setAttribute("DataType", "ExpirationDate");
        expiresElement.setAttribute("Locale", localeCode);

        if (UtilValidate.isNotEmpty(cardSecurityCode)) {
            // Cvv2Val must be exactly 4 characters
            if (cardSecurityCode.length() < 4) {
                while (cardSecurityCode.length() < 4) {
                    cardSecurityCode = cardSecurityCode + " ";
                }
            } else if (cardSecurityCode.length() > 4) {
                cardSecurityCode = cardSecurityCode.substring(0, 4);
            }
            UtilXml.addChildElementValue(creditCardElement, "Cvv2Val", cardSecurityCode, document);
            UtilXml.addChildElementValue(creditCardElement, "Cvv2Indicator", "1", document);
        }
    }
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:29,代码来源:CCPaymentServices.java

示例9: uspsCityStateLookup

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public static Map<String, Object> uspsCityStateLookup(DispatchContext dctx, Map<String, ? extends Object> context) {
    Delegator delegator = dctx.getDelegator();
    String shipmentGatewayConfigId = (String) context.get("shipmentGatewayConfigId");
    String resource = (String) context.get("configProps");
    Locale locale = (Locale) context.get("locale");

    Document requestDocument = createUspsRequestDocument("CityStateLookupRequest", true, delegator, shipmentGatewayConfigId, resource);

    Element zipCodeElement = UtilXml.addChildElement(requestDocument.getDocumentElement(), "ZipCode", requestDocument);
    zipCodeElement.setAttribute("ID", "0");

    String zipCode = ((String) context.get("zip5")).trim(); // trim leading/trailing spaces

    // only the first 5 digits are used, the rest are ignored
    UtilXml.addChildElementValue(zipCodeElement, "Zip5", zipCode, requestDocument);

    Document responseDocument = null;
    try {
        responseDocument = sendUspsRequest("CityStateLookup", requestDocument, delegator, shipmentGatewayConfigId, resource, locale);
    } catch (UspsRequestException e) {
        // SCIPIO: Handle config errors more gracefully and use logError
        if (e instanceof UspsConfigurationException) {
            Debug.logError(e.getMessage(), module);
        } else {
            Debug.logError(e, module);
        }
        return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, 
                "FacilityShipmentUspsCityStateLookupSendingError", 
                UtilMisc.toMap("errorString", e.getMessage()), locale));
    }

    Element respAddressElement = UtilXml.firstChildElement(responseDocument.getDocumentElement(), "ZipCode");
    if (respAddressElement == null) {
        return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, 
                "FacilityShipmentUspsCityStateLookupIncompleteResponse", locale));
    }

    Element respErrorElement = UtilXml.firstChildElement(respAddressElement, "Error");
    if (respErrorElement != null) {
        return ServiceUtil.returnFailure(UtilProperties.getMessage(resourceError, 
                "FacilityShipmentUspsCityStateLookupResponseError", 
                UtilMisc.toMap("errorString", UtilXml.childElementValue(respErrorElement, "Description")), locale));
    }

    Map<String, Object> result = ServiceUtil.returnSuccess();

    String city = UtilXml.childElementValue(respAddressElement, "City");
    if (UtilValidate.isEmpty(city)) {
        return ServiceUtil.returnFailure(UtilProperties.getMessage(resourceError, 
                "FacilityShipmentUspsCityStateLookupIncompleteCityElement", locale));
    }
    result.put("city", city);

    String state = UtilXml.childElementValue(respAddressElement, "State");
    if (UtilValidate.isEmpty(state)) {
        return ServiceUtil.returnFailure(UtilProperties.getMessage(resourceError, 
                "FacilityShipmentUspsCityStateLookupIncompleteStateElement", locale));
    }
    result.put("state", state);

    return result;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:63,代码来源:UspsServices.java

示例10: uspsServiceStandards

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private static Map<String, Object> uspsServiceStandards(DispatchContext dctx, Map<String, ? extends Object> context) {
    Delegator delegator = dctx.getDelegator();
    String shipmentGatewayConfigId = (String) context.get("shipmentGatewayConfigId");
    String resource = (String) context.get("configProps");
    String type = (String) context.get("serviceType");
    Locale locale = (Locale) context.get("locale");
    if (!type.matches("PriorityMail|StandardB")) {
        return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, 
                "FacilityShipmentUspsUnsupporteServiceType", 
                UtilMisc.toMap("serviceType", type), locale));
    }

    Document requestDocument = createUspsRequestDocument(type + "Request", true, delegator, shipmentGatewayConfigId, resource);

    UtilXml.addChildElementValue(requestDocument.getDocumentElement(), "OriginZip",
            (String) context.get("originZip"), requestDocument);
    UtilXml.addChildElementValue(requestDocument.getDocumentElement(), "DestinationZip",
            (String) context.get("destinationZip"), requestDocument);

    Document responseDocument = null;
    try {
        responseDocument = sendUspsRequest(type, requestDocument, delegator, shipmentGatewayConfigId, resource, locale);
    } catch (UspsRequestException e) {
        // SCIPIO: Handle config errors more gracefully and use logError
        if (e instanceof UspsConfigurationException) {
            Debug.logError(e.getMessage(), module);
        } else {
            Debug.logError(e, module);
        }
        return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, 
                "FacilityShipmentUspsServiceStandardSendingError", 
                UtilMisc.toMap("serviceType", type, "errorString", e.getMessage()), locale));
    }

    Map<String, Object> result = ServiceUtil.returnSuccess();

    String days = UtilXml.childElementValue(responseDocument.getDocumentElement(), "Days");
    if (UtilValidate.isEmpty(days)) {
        return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, 
                "FacilityShipmentUspsServiceStandardResponseIncompleteDaysElement", 
                UtilMisc.toMap("serviceType", type), locale));
    }
    result.put("days", days);

    return result;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:47,代码来源:UspsServices.java

示例11: createRequestDocument

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private static Document createRequestDocument(String paymentConfig, Delegator delegator) {

        // EngineDocList
        Document requestDocument = UtilXml.makeEmptyXmlDocument("EngineDocList");
        Element engineDocListElement = requestDocument.getDocumentElement();
        UtilXml.addChildElementValue(engineDocListElement, "DocVersion", "1.0", requestDocument);

        // EngineDocList.EngineDoc
        Element engineDocElement = UtilXml.addChildElement(engineDocListElement, "EngineDoc", requestDocument);
        UtilXml.addChildElementValue(engineDocElement, "ContentType", "OrderFormDoc", requestDocument);

        String sourceId = EntityUtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.sourceId", delegator);
        if (UtilValidate.isNotEmpty(sourceId)) {
            UtilXml.addChildElementValue(engineDocElement, "SourceId", sourceId, requestDocument);
        }

        String groupId = EntityUtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.groupId", delegator);
        if (UtilValidate.isNotEmpty(groupId)) {
            UtilXml.addChildElementValue(engineDocElement, "GroupId", groupId, requestDocument);
        }

        // EngineDocList.EngineDoc.User
        Element userElement = UtilXml.addChildElement(engineDocElement, "User", requestDocument);
        UtilXml.addChildElementValue(userElement, "Name",
                EntityUtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.username", "", delegator), requestDocument);
        UtilXml.addChildElementValue(userElement, "Password",
                EntityUtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.password", "", delegator), requestDocument);
        UtilXml.addChildElementValue(userElement, "Alias",
                EntityUtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.alias", "", delegator), requestDocument);

        String effectiveAlias = EntityUtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.effectiveAlias", delegator);
        if (UtilValidate.isNotEmpty(effectiveAlias)) {
            UtilXml.addChildElementValue(userElement, "EffectiveAlias", effectiveAlias, requestDocument);
        }

        // EngineDocList.EngineDoc.Instructions
        Element instructionsElement = UtilXml.addChildElement(engineDocElement, "Instructions", requestDocument);

        String pipeline = "PaymentNoFraud";
        if (EntityUtilProperties.propertyValueEqualsIgnoreCase(paymentConfig, "payment.clearcommerce.enableFraudShield", "Y", delegator)) {
            pipeline = "Payment";
        }
        UtilXml.addChildElementValue(instructionsElement, "Pipeline", pipeline, requestDocument);

        // EngineDocList.EngineDoc.OrderFormDoc
        Element orderFormDocElement = UtilXml.addChildElement(engineDocElement, "OrderFormDoc", requestDocument);

        // default to "P" for Production Mode
        String mode = EntityUtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.processMode", "P", delegator);
        UtilXml.addChildElementValue(orderFormDocElement, "Mode", mode, requestDocument);

        return requestDocument;
    }
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:54,代码来源:CCPaymentServices.java


注:本文中的org.ofbiz.base.util.UtilXml.addChildElementValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。