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


Java UtilXml.addChildElement方法代码示例

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


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

示例4: 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

示例5: PcChargeApi

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public PcChargeApi(boolean isFile) {
    // initialize the document
    String initialElement = rootElement;
    if (!isFile) {
        initialElement = reqElement;
    }

    this.document = UtilXml.makeEmptyXmlDocument(initialElement);
    Element root = this.document.getDocumentElement();
    if (isFile) {
        root.setAttribute("xmlns", xschema);
        this.req = UtilXml.addChildElement(root, reqElement, document);
    } else {
        this.req = root;
    }
    this.mode = MODE_IN;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:18,代码来源:PcChargeApi.java

示例6: 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

示例7: 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

示例8: EntityAnd

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public EntityAnd(ModelNode.ModelSubNode modelSubNode, Element entityAndElement) {
    super(modelSubNode, entityAndElement);
    boolean useCache = "true".equalsIgnoreCase(entityAndElement.getAttribute("use-cache"));
    Document ownerDoc = entityAndElement.getOwnerDocument();
    if (!useCache)
        UtilXml.addChildElement(entityAndElement, "use-iterator", ownerDoc);
    String listName = UtilFormatOut.checkEmpty(entityAndElement.getAttribute("list"),
            entityAndElement.getAttribute("list-name"));
    if (UtilValidate.isEmpty(listName))
        listName = "_LIST_ITERATOR_";
    this.listName = listName;
    entityAndElement.setAttribute("list-name", this.listName);
    finder = new ByAndFinder(entityAndElement);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:15,代码来源:ModelTreeAction.java

示例9: EntityCondition

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public EntityCondition(ModelNode.ModelSubNode modelSubNode, Element entityConditionElement) {
    super(modelSubNode, entityConditionElement);
    Document ownerDoc = entityConditionElement.getOwnerDocument();
    boolean useCache = "true".equalsIgnoreCase(entityConditionElement.getAttribute("use-cache"));
    if (!useCache)
        UtilXml.addChildElement(entityConditionElement, "use-iterator", ownerDoc);
    String listName = UtilFormatOut.checkEmpty(entityConditionElement.getAttribute("list"),
            entityConditionElement.getAttribute("list-name"));
    if (UtilValidate.isEmpty(listName))
        listName = "_LIST_ITERATOR_";
    this.listName = listName;
    entityConditionElement.setAttribute("list-name", this.listName);
    finder = new ByConditionFinder(entityConditionElement);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:15,代码来源:ModelTreeAction.java

示例10: uspsTrackConfirm

import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public static Map<String, Object> uspsTrackConfirm(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("TrackRequest", true, delegator, shipmentGatewayConfigId, resource);

    Element trackingElement = UtilXml.addChildElement(requestDocument.getDocumentElement(), "TrackID", requestDocument);
    trackingElement.setAttribute("ID", (String) context.get("trackingId"));

    Document responseDocument = null;
    try {
        responseDocument = sendUspsRequest("TrackV2", 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, 
                "FacilityShipmentUspsTrackingSendingError", UtilMisc.toMap("errorString", e.getMessage()), locale));
    }

    Element trackInfoElement = UtilXml.firstChildElement(responseDocument.getDocumentElement(), "TrackInfo");
    if (trackInfoElement == null) {
        return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, 
                "FacilityShipmentUspsTrackingIncompleteResponse", locale));
    }

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

    result.put("trackingSummary", UtilXml.childElementValue(trackInfoElement, "TrackSummary"));

    List<? extends Element> detailElementList = UtilXml.childElementList(trackInfoElement, "TrackDetail");
    if (UtilValidate.isNotEmpty(detailElementList)) {
        List<String> trackingDetailList = FastList.newInstance();
        for (Element detailElement: detailElementList) {
            trackingDetailList.add(UtilXml.elementValue(detailElement));
        }
        result.put("trackingDetailList", trackingDetailList);
    }

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

示例11: 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

示例12: 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.addChildElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。