public static Map leaveFeedback()

in ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayFeedback.java [264:384]


    public static Map<String, Object> leaveFeedback(DispatchContext dctx, Map<String, ? extends Object> context) {
        Map<String, Object>result = new HashMap<>();
        Delegator delegator = dctx.getDelegator();
        Locale locale = (Locale) context.get("locale");
        String productStoreId = (String) context.get("productStoreId");
        ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);

        String itemId = (String) context.get("itemId");
        String targetUser = (String) context.get("targetUser");
        String transactionId = (String) context.get("transactionId");
        String commentingUser = (String) context.get("commentingUser");
        String role = (String) context.get("role");
        String commentType = (String) context.get("commentType");
        String commentText = (String) context.get("commentText");
        String ratingItem = (String) context.get("ratingItem");
        String ratingComm = (String) context.get("ratingComm");
        String ratingShip = (String) context.get("ratingShip");
        String ratingShipHand = (String) context.get("ratingShipHand");
        try {
            if (commentType != null) {
                LeaveFeedbackCall leaveFeedbackCall = new LeaveFeedbackCall();
                leaveFeedbackCall.setApiContext(apiContext);
                leaveFeedbackCall.setTargetUser(targetUser);
                leaveFeedbackCall.setTransactionID(transactionId);

                if ("seller".equals(role)) {
                    ItemRatingDetailArrayType sellerItemRatingDetailArray = new ItemRatingDetailArrayType();

                    //The item description
                    ItemRatingDetailsType itemRatingDetailsType1 = new ItemRatingDetailsType();
                    int ratingItemValue = 0;
                    if (UtilValidate.isInteger(ratingItem)) {
                        ratingItemValue = Integer.parseInt(ratingItem);
                    }
                    if (ratingItemValue < 3) {
                        /*
                        String AqItemAsDescribed = null;
                        int AqItemAsDescribedId = Integer.parseInt((String) context.get("AqItemAsDescribedId"));
                        switch (AqItemAsDescribedId) {
                        case 5:
                            AqItemAsDescribed = "ItemNotReceived";
                            break;
                        case 6:
                            AqItemAsDescribed = "ItemBadQuality";
                            break;
                        case 2:
                            AqItemAsDescribed = "ItemDamaged";
                            break;
                        case 1:
                            AqItemAsDescribed = "ItemIneligible";
                            break;
                        case 3:
                            AqItemAsDescribed = "ItemLost";
                            break;
                        default:
                            AqItemAsDescribed = "Other";
                            break;
                        }
                        */
                    }
                    itemRatingDetailsType1.setRating(ratingItemValue);
                    itemRatingDetailsType1.setRatingDetail(FeedbackRatingDetailCodeType.ITEM_AS_DESCRIBED);

                    //The seller's communication
                    ItemRatingDetailsType itemRatingDetailsType2 = new ItemRatingDetailsType();
                    int ratingCommValue = 0;
                    if (UtilValidate.isInteger(ratingComm)) {
                        ratingCommValue = Integer.parseInt(ratingComm);
                    }
                    itemRatingDetailsType2.setRating(ratingCommValue);
                    itemRatingDetailsType2.setRatingDetail(FeedbackRatingDetailCodeType.COMMUNICATION);

                    //the seller ship the item
                    ItemRatingDetailsType itemRatingDetailsType3 = new ItemRatingDetailsType();
                    int ratingShipValue = 0;
                    if (UtilValidate.isInteger(ratingShip)) {
                        ratingShipValue = Integer.parseInt(ratingShip);
                    }
                    itemRatingDetailsType3.setRating(ratingShipValue);
                    itemRatingDetailsType3.setRatingDetail(FeedbackRatingDetailCodeType.SHIPPING_TIME);

                    //the shipping and handling charges
                    ItemRatingDetailsType itemRatingDetailsType4 = new ItemRatingDetailsType();
                    int ratingShipHandValue = 0;
                    if (UtilValidate.isInteger(ratingShipHand)) {
                        ratingShipHandValue = Integer.parseInt(ratingShipHand);
                    }
                    itemRatingDetailsType4.setRating(ratingShipHandValue);
                    itemRatingDetailsType4.setRatingDetail(FeedbackRatingDetailCodeType.SHIPPING_AND_HANDLING_CHARGES);

                    //Rating Summary
                    ItemRatingDetailsType[] itemRatingDetailsType = {itemRatingDetailsType1, itemRatingDetailsType2, itemRatingDetailsType3, itemRatingDetailsType4};
                    sellerItemRatingDetailArray.setItemRatingDetails(itemRatingDetailsType);

                    leaveFeedbackCall.setSellerItemRatingDetailArray(sellerItemRatingDetailArray);
                }
                FeedbackDetailType feedbackDetail = new FeedbackDetailType();
                feedbackDetail.setItemID(itemId);
                feedbackDetail.setCommentingUser(commentingUser);
                feedbackDetail.setCommentText(commentText);
                feedbackDetail.setCommentTime(Calendar.getInstance());
                if ("positive".equals(commentType)) {
                    feedbackDetail.setCommentType(CommentTypeCodeType.POSITIVE);
                } else if ("neutral".equals(commentType)) {
                    feedbackDetail.setCommentType(CommentTypeCodeType.NEUTRAL);
                } else if ("negative".equals(commentType)) {
                    feedbackDetail.setCommentType(CommentTypeCodeType.NEGATIVE);
                }
                leaveFeedbackCall.setFeedbackDetail(feedbackDetail);
                leaveFeedbackCall.leaveFeedback();
            }
        } catch (ApiException e) {
            result = ServiceUtil.returnError("ApiException ".concat(e.getMessage()));
        } catch (SdkException e) {
            result = ServiceUtil.returnError("SdkException ".concat(e.getMessage()));
        } catch (Exception e) {
            result = ServiceUtil.returnError("Exception ".concat(e.getMessage()));
        }
        result = ServiceUtil.returnSuccess();
        return result;
    }