Example usage for java.math BigDecimal doubleValue

List of usage examples for java.math BigDecimal doubleValue

Introduction

In this page you can find the example usage for java.math BigDecimal doubleValue.

Prototype

@Override
public double doubleValue() 

Source Link

Document

Converts this BigDecimal to a double .

Usage

From source file:de.forsthaus.webui.customer.CustomerChartCtrl.java

/**
 * onClick button PieChart. <br>/*from  www  .  j a v a2s .c o m*/
 * 
 * @param event
 * @throws IOException
 */
public void onClick$button_CustomerChart_PieChart(Event event) throws InterruptedException, IOException {
    // logger.debug(event.toString());

    div_chartArea.getChildren().clear();

    // get the customer ID for which we want show a chart
    long kunId = getCustomer().getId();

    // get a list of data
    List<ChartData> kunAmountList = getChartService().getChartDataForCustomer(kunId);

    if (kunAmountList.size() > 0) {

        DefaultPieDataset pieDataset = new DefaultPieDataset();

        for (ChartData chartData : kunAmountList) {

            Calendar calendar = new GregorianCalendar();
            calendar.setTime(chartData.getChartKunInvoiceDate());

            int month = calendar.get(Calendar.MONTH) + 1;
            int year = calendar.get(Calendar.YEAR);
            String key = String.valueOf(month) + "/" + String.valueOf(year);

            BigDecimal bd = chartData.getChartKunInvoiceAmount().setScale(15, 3);
            String amount = String.valueOf(bd.doubleValue());

            // fill the data
            pieDataset.setValue(key + " " + amount,
                    new Double(chartData.getChartKunInvoiceAmount().doubleValue()));
        }

        String title = "Monthly amount for year 2009";
        JFreeChart chart = ChartFactory.createPieChart(title, pieDataset, true, true, true);
        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setForegroundAlpha(0.5f);
        BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null);
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);

        AImage chartImage = new AImage("Pie Chart", bytes);

        Image img = new Image();
        img.setContent(chartImage);
        img.setParent(div_chartArea);

    } else {

        div_chartArea.getChildren().clear();

        Label label = new Label();
        label.setValue("This customer have no data for showing in a chart!");

        label.setParent(div_chartArea);

    }
}

From source file:de.forsthaus.webui.customer.CustomerChartCtrl.java

/**
 * onClick button PieChart 3D. <br>
 * /*from   w  ww. j ava 2s  .c  o m*/
 * @param event
 * @throws IOException
 */
public void onClick$button_CustomerChart_PieChart3D(Event event) throws InterruptedException, IOException {
    // logger.debug(event.toString());

    div_chartArea.getChildren().clear();

    // get the customer ID for which we want show a chart
    long kunId = getCustomer().getId();

    // get a list of data
    List<ChartData> kunAmountList = getChartService().getChartDataForCustomer(kunId);

    if (kunAmountList.size() > 0) {

        DefaultPieDataset pieDataset = new DefaultPieDataset();

        for (ChartData chartData : kunAmountList) {

            Calendar calendar = new GregorianCalendar();
            calendar.setTime(chartData.getChartKunInvoiceDate());

            int month = calendar.get(Calendar.MONTH) + 1;
            int year = calendar.get(Calendar.YEAR);
            String key = String.valueOf(month) + "/" + String.valueOf(year);

            BigDecimal bd = chartData.getChartKunInvoiceAmount().setScale(15, 3);
            String amount = String.valueOf(bd.doubleValue());

            // fill the data
            pieDataset.setValue(key + " " + amount,
                    new Double(chartData.getChartKunInvoiceAmount().doubleValue()));
        }

        String title = "Monthly amount for year 2009";
        JFreeChart chart = ChartFactory.createPieChart3D(title, pieDataset, true, true, true);
        PiePlot3D plot = (PiePlot3D) chart.getPlot();
        plot.setForegroundAlpha(0.5f);
        BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null);
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);

        AImage chartImage = new AImage("Pie Chart", bytes);

        Image img = new Image();
        img.setContent(chartImage);
        img.setParent(this.div_chartArea);

    } else {

        div_chartArea.getChildren().clear();

        Label label = new Label();
        label.setValue("This customer have no data for showing in a chart!");

        label.setParent(div_chartArea);

    }
}

From source file:de.forsthaus.webui.customer.CustomerChartCtrl.java

/**
 * onClick button Ring Chart. <br>
 * // ww  w .j av a2 s .c o m
 * @param event
 * @throws IOException
 */
public void onClick$button_CustomerChart_RingChart(Event event) throws InterruptedException, IOException {
    // logger.debug(event.toString());

    div_chartArea.getChildren().clear();

    // get the customer ID for which we want show a chart
    long kunId = getCustomer().getId();

    // get a list of data
    List<ChartData> kunAmountList = getChartService().getChartDataForCustomer(kunId);

    if (kunAmountList.size() > 0) {

        DefaultPieDataset pieDataset = new DefaultPieDataset();

        for (ChartData chartData : kunAmountList) {

            Calendar calendar = new GregorianCalendar();
            calendar.setTime(chartData.getChartKunInvoiceDate());

            int month = calendar.get(Calendar.MONTH) + 1;
            int year = calendar.get(Calendar.YEAR);
            String key = String.valueOf(month) + "/" + String.valueOf(year);

            BigDecimal bd = chartData.getChartKunInvoiceAmount().setScale(15, 3);
            String amount = String.valueOf(bd.doubleValue());

            // fill the data
            pieDataset.setValue(key + " " + amount,
                    new Double(chartData.getChartKunInvoiceAmount().doubleValue()));
        }

        String title = "Monthly amount for year 2009";
        JFreeChart chart = ChartFactory.createRingChart(title, pieDataset, true, true, true);
        RingPlot plot = (RingPlot) chart.getPlot();
        plot.setForegroundAlpha(0.5f);
        BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null);
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);

        AImage chartImage = new AImage("Ring Chart", bytes);

        Image img = new Image();
        img.setContent(chartImage);
        img.setParent(this.div_chartArea);

    } else {

        div_chartArea.getChildren().clear();

        final Label label = new Label();
        label.setValue("This customer have no data for showing in a chart!");

        label.setParent(div_chartArea);

    }
}

From source file:de.forsthaus.webui.customer.CustomerChartCtrl.java

/**
 * onClick button Bar Chart 3D. <br>
 * //from  www .ja  v a  2  s  . c  om
 * @param event
 * @throws IOException
 */
public void onClick$button_CustomerChart_BarChart3D(Event event) throws InterruptedException, IOException {
    // logger.debug(event.toString());

    div_chartArea.getChildren().clear();

    // get the customer ID for which we want show a chart
    long kunId = getCustomer().getId();

    // get a list of data
    List<ChartData> kunAmountList = getChartService().getChartDataForCustomer(kunId);

    if (kunAmountList.size() > 0) {

        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        for (ChartData chartData : kunAmountList) {

            Calendar calendar = new GregorianCalendar();
            calendar.setTime(chartData.getChartKunInvoiceDate());

            int month = calendar.get(Calendar.MONTH) + 1;
            int year = calendar.get(Calendar.YEAR);
            String key = String.valueOf(month) + "/" + String.valueOf(year);

            BigDecimal bd = chartData.getChartKunInvoiceAmount().setScale(15, 3);
            String amount = String.valueOf(bd.doubleValue());

            // fill the data
            dataset.setValue(new Double(chartData.getChartKunInvoiceAmount().doubleValue()), key + " " + amount,
                    key + " " + amount);
        }

        String title = "Monthly amount for year 2009";
        PlotOrientation po = PlotOrientation.VERTICAL;
        JFreeChart chart = ChartFactory.createBarChart3D(title, "Month", "Amount", dataset, po, true, true,
                true);

        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setForegroundAlpha(0.5f);
        BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null);
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);

        AImage chartImage = new AImage("Bar Chart 3D", bytes);

        Image img = new Image();
        img.setContent(chartImage);
        img.setParent(div_chartArea);

    } else {

        div_chartArea.getChildren().clear();

        Label label = new Label();
        label.setValue("This customer have no data for showing in a chart!");

        label.setParent(div_chartArea);
    }
}

From source file:de.forsthaus.webui.customer.CustomerChartCtrl.java

/**
 * onClick button Bar Chart. <br>/*w  ww.  j ava  2s  .  c om*/
 * 
 * @param event
 * @throws IOException
 */
public void onClick$button_CustomerChart_BarChart(Event event) throws InterruptedException, IOException {
    // logger.debug(event.toString());

    div_chartArea.getChildren().clear();

    // get the customer ID for which we want show a chart
    long kunId = getCustomer().getId();

    // get a list of data
    List<ChartData> kunAmountList = getChartService().getChartDataForCustomer(kunId);

    if (kunAmountList.size() > 0) {

        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        for (ChartData chartData : kunAmountList) {

            Calendar calendar = new GregorianCalendar();
            calendar.setTime(chartData.getChartKunInvoiceDate());

            int month = calendar.get(Calendar.MONTH) + 1;
            int year = calendar.get(Calendar.YEAR);
            String key = String.valueOf(month) + "/" + String.valueOf(year);

            BigDecimal bd = chartData.getChartKunInvoiceAmount().setScale(15, 3);
            String amount = String.valueOf(bd.doubleValue());

            // fill the data
            dataset.setValue(new Double(chartData.getChartKunInvoiceAmount().doubleValue()), key + " " + amount,
                    key + " " + amount);
        }

        String title = "Monthly amount for year 2009";
        PlotOrientation po = PlotOrientation.VERTICAL;
        JFreeChart chart = ChartFactory.createBarChart(title, "Month", "Amount", dataset, po, true, true, true);

        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setForegroundAlpha(0.5f);

        BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null);
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);

        AImage chartImage = new AImage("Bar Chart", bytes);

        Image img = new Image();
        img.setContent(chartImage);
        img.setParent(div_chartArea);

    } else {

        div_chartArea.getChildren().clear();

        Label label = new Label();
        label.setValue("This customer have no data for showing in a chart!");

        label.setParent(div_chartArea);

    }
}

From source file:de.forsthaus.webui.customer.CustomerChartCtrl.java

/**
 * onClick button Stacked Bar Chart. <br>
 * //from w  w  w .ja  v  a  2 s .c  o  m
 * @param event
 * @throws IOException
 */
public void onClick$button_CustomerChart_StackedBar(Event event) throws InterruptedException, IOException {
    // logger.debug(event.toString());

    div_chartArea.getChildren().clear();

    // get the customer ID for which we want show a chart
    long kunId = getCustomer().getId();

    // get a list of data
    List<ChartData> kunAmountList = getChartService().getChartDataForCustomer(kunId);

    if (kunAmountList.size() > 0) {

        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        for (ChartData chartData : kunAmountList) {

            Calendar calendar = new GregorianCalendar();
            calendar.setTime(chartData.getChartKunInvoiceDate());

            int month = calendar.get(Calendar.MONTH) + 1;
            int year = calendar.get(Calendar.YEAR);
            String key = String.valueOf(month) + "/" + String.valueOf(year);

            BigDecimal bd = chartData.getChartKunInvoiceAmount().setScale(15, 3);
            String amount = String.valueOf(bd.doubleValue());

            // fill the data
            dataset.setValue(new Double(chartData.getChartKunInvoiceAmount().doubleValue()), key + " " + amount,
                    key + " " + amount);
        }

        String title = "Monthly amount for year 2009";
        PlotOrientation po = PlotOrientation.VERTICAL;
        JFreeChart chart = ChartFactory.createStackedBarChart(title, "Month", "Amount", dataset, po, true, true,
                true);

        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setForegroundAlpha(0.5f);
        BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null);
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);

        AImage chartImage = new AImage("Stacked Bar Chart", bytes);

        Image img = new Image();
        img.setContent(chartImage);
        img.setParent(div_chartArea);

    } else {

        div_chartArea.getChildren().clear();

        Label label = new Label();
        label.setValue("This customer have no data for showing in a chart!");

        label.setParent(div_chartArea);

    }
}

From source file:de.forsthaus.webui.customer.CustomerChartCtrl.java

/**
 * onClick button Stacked Bar 3D Chart. <br>
 * /*from   w w  w. jav  a 2  s  .  com*/
 * @param event
 * @throws IOException
 */
public void onClick$button_CustomerChart_StackedBar3D(Event event) throws InterruptedException, IOException {
    // logger.debug(event.toString());

    div_chartArea.getChildren().clear();

    // get the customer ID for which we want show a chart
    long kunId = getCustomer().getId();

    // get a list of data
    List<ChartData> kunAmountList = getChartService().getChartDataForCustomer(kunId);

    if (kunAmountList.size() > 0) {

        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        for (ChartData chartData : kunAmountList) {

            Calendar calendar = new GregorianCalendar();
            calendar.setTime(chartData.getChartKunInvoiceDate());

            int month = calendar.get(Calendar.MONTH) + 1;
            int year = calendar.get(Calendar.YEAR);
            String key = String.valueOf(month) + "/" + String.valueOf(year);

            BigDecimal bd = chartData.getChartKunInvoiceAmount().setScale(15, 3);
            String amount = String.valueOf(bd.doubleValue());

            // fill the data
            dataset.setValue(new Double(chartData.getChartKunInvoiceAmount().doubleValue()), key + " " + amount,
                    key + " " + amount);
        }

        String title = "Monthly amount for year 2009";
        PlotOrientation po = PlotOrientation.VERTICAL;
        JFreeChart chart = ChartFactory.createStackedBarChart3D(title, "Month", "Amount", dataset, po, true,
                true, true);

        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setForegroundAlpha(0.5f);
        BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null);
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);

        AImage chartImage = new AImage("Stacked Bar Chart 3D", bytes);

        Image img = new Image();
        img.setContent(chartImage);
        img.setParent(div_chartArea);

    } else {

        div_chartArea.getChildren().clear();

        Label label = new Label();
        label.setValue("This customer have no data for showing in a chart!");

        label.setParent(div_chartArea);

    }
}

From source file:de.forsthaus.webui.customer.CustomerChartCtrl.java

/**
 * onClick button Line Bar Chart. <br>
 * /*from   w  w  w. j a v  a  2s .c o  m*/
 * @param event
 * @throws IOException
 */
public void onClick$button_CustomerChart_LineBar(Event event) throws InterruptedException, IOException {
    // logger.debug(event.toString());

    div_chartArea.getChildren().clear();

    // get the customer ID for which we want show a chart
    long kunId = getCustomer().getId();

    // get a list of data
    List<ChartData> kunAmountList = getChartService().getChartDataForCustomer(kunId);

    if (kunAmountList.size() > 0) {

        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        for (ChartData chartData : kunAmountList) {

            Calendar calendar = new GregorianCalendar();
            calendar.setTime(chartData.getChartKunInvoiceDate());

            int month = calendar.get(Calendar.MONTH) + 1;
            int year = calendar.get(Calendar.YEAR);
            String key = String.valueOf(month) + "/" + String.valueOf(year);

            BigDecimal bd = chartData.getChartKunInvoiceAmount().setScale(15, 3);
            String amount = String.valueOf(bd.doubleValue());

            // fill the data
            dataset.setValue(new Double(chartData.getChartKunInvoiceAmount().doubleValue()), "2009",
                    key + " " + amount);
        }

        String title = "Monthly amount for year 2009";
        PlotOrientation po = PlotOrientation.VERTICAL;
        JFreeChart chart = ChartFactory.createLineChart(title, "Month", "Amount", dataset, po, true, true,
                true);

        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setForegroundAlpha(0.5f);
        BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null);
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);

        AImage chartImage = new AImage("Line Bar Chart", bytes);

        Image img = new Image();
        img.setContent(chartImage);
        img.setParent(div_chartArea);

    } else {

        div_chartArea.getChildren().clear();

        Label label = new Label();
        label.setValue("This customer have no data for showing in a chart!");

        label.setParent(div_chartArea);

    }
}

From source file:de.forsthaus.webui.customer.CustomerChartCtrl.java

/**
 * onClick button Line Bar 3D Chart. <br>
 * //from www. j  a va  2s  .  com
 * @param event
 * @throws IOException
 */
public void onClick$button_CustomerChart_LineBar3D(Event event) throws InterruptedException, IOException {
    // logger.debug(event.toString());

    div_chartArea.getChildren().clear();

    // get the customer ID for which we want show a chart
    long kunId = getCustomer().getId();

    // get a list of data
    List<ChartData> kunAmountList = getChartService().getChartDataForCustomer(kunId);

    if (kunAmountList.size() > 0) {

        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        for (ChartData chartData : kunAmountList) {

            Calendar calendar = new GregorianCalendar();
            calendar.setTime(chartData.getChartKunInvoiceDate());

            int month = calendar.get(Calendar.MONTH) + 1;
            int year = calendar.get(Calendar.YEAR);
            String key = String.valueOf(month) + "/" + String.valueOf(year);

            BigDecimal bd = chartData.getChartKunInvoiceAmount().setScale(15, 3);
            String amount = String.valueOf(bd.doubleValue());

            // fill the data
            dataset.setValue(new Double(chartData.getChartKunInvoiceAmount().doubleValue()), "2009",
                    key + " " + amount);
        }

        String title = "Monthly amount for year 2009";
        PlotOrientation po = PlotOrientation.VERTICAL;
        JFreeChart chart = ChartFactory.createLineChart3D(title, "Month", "Amount", dataset, po, true, true,
                true);

        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setForegroundAlpha(0.5f);
        BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null);
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);

        AImage chartImage = new AImage("Line Bar Chart 3D", bytes);

        Image img = new Image();
        img.setContent(chartImage);
        img.setParent(div_chartArea);

    } else {

        div_chartArea.getChildren().clear();

        Label label = new Label();
        label.setValue("This customer have no data for showing in a chart!");

        label.setParent(div_chartArea);

    }
}

From source file:com.salesmanager.core.util.CheckoutUtil.java

/**
 * OrderProductAttribute is configured from javascript This code needs to
 * invoke catalog objects because it requires getProductOptionValueId, will
 * not change any price Add attributes to product, add attribute offset
 * price to original product price/* w  w  w  . j ava 2 s .  c  o  m*/
 * 
 * @param attributes
 * @param lineId
 * @param currency
 * @param request
 * @return
 * @throws Exception
 */
public static OrderProduct addAttributesFromRawObjects(List<OrderProductAttribute> attributes, long productId,
        String lineId, String currency, HttpServletRequest request) throws Exception {

    Locale loc = request.getLocale();
    String lang = loc.getLanguage();

    HttpSession session = request.getSession();

    Map cartLines = SessionUtil.getOrderProducts(request);

    if (cartLines == null) {
        throw new Exception("No OrderProduct exixt yet, cannot assign attributes");
    }

    OrderProduct scp = (OrderProduct) cartLines.get(lineId);

    if (scp == null) {
        throw new Exception("No OrderProduct exixt for lineId " + lineId);
    }

    CatalogService cservice = (CatalogService) ServiceFactory.getService(ServiceFactory.CatalogService);

    BigDecimal sumPrice = null;

    // make sure OrderProduct and productId match
    if (scp.getProductId() == productId) {

        Locale locale = (Locale) request.getSession().getAttribute("WW_TRANS_I18N_LOCALE");
        if (locale == null)
            locale = request.getLocale();

        // get attributes for this product
        Collection productAttributes = cservice.getProductAttributes(productId, locale.getLanguage());
        Map mapAttributes = new HashMap();
        if (productAttributes != null) {

            Iterator i = productAttributes.iterator();
            while (i.hasNext()) {
                ProductAttribute p = (ProductAttribute) i.next();
                mapAttributes.put(p.getOptionValueId(), p);
            }

        }

        if (scp != null) {

            StringBuffer attributesLine = null;

            if (attributes != null) {
                attributesLine = new StringBuffer();
                int count = 0;
                Iterator i = attributes.iterator();
                while (i.hasNext()) {
                    OrderProductAttribute opa = (OrderProductAttribute) i.next();
                    String attrPriceText = opa.getPrice();
                    BigDecimal attrPrice = null;
                    if (attrPriceText != null) {
                        attrPrice = CurrencyUtil.validateCurrency(attrPriceText, currency);
                    } else {
                        attrPrice = opa.getOptionValuePrice();
                    }
                    // get all information from the attribute
                    ProductAttribute pa = (ProductAttribute) mapAttributes.get(opa.getProductOptionValueId());
                    if (pa != null) {
                        if (attrPrice == null) {
                            attrPrice = pa.getOptionValuePrice();
                        }
                    }
                    if (attrPrice != null) {
                        opa.setOptionValuePrice(attrPrice);
                        opa.setPrice(CurrencyUtil.displayFormatedAmountNoCurrency(attrPrice, currency));
                        if (sumPrice == null) {
                            sumPrice = new BigDecimal(attrPrice.doubleValue()).setScale(2);
                        } else {
                            // double pr = sumPrice.doubleValue() +
                            // attrPrice.doubleValue();
                            // sumPrice = new
                            // BigDecimal(sumPrice.doubleValue() +
                            // attrPrice.doubleValue());
                            BigDecimal currentPrice = sumPrice;
                            sumPrice = currentPrice.add(attrPrice);
                        }
                    }
                    // opa.setOrderId(Long.parseLong(orderId));
                    opa.setOrderProductId(productId);
                    opa.setProductAttributeIsFree(pa.isProductAttributeIsFree());

                    opa.setProductOption("");
                    if (StringUtils.isBlank(opa.getProductOptionValue())) {
                        opa.setProductOptionValue("");
                    }

                    ProductOption po = pa.getProductOption();
                    Set poDescriptions = po.getDescriptions();
                    if (poDescriptions != null) {
                        Iterator pi = poDescriptions.iterator();
                        while (pi.hasNext()) {
                            ProductOptionDescription pod = (ProductOptionDescription) pi.next();
                            if (pod.getId().getLanguageId() == LanguageUtil.getLanguageNumberCode(lang)) {
                                opa.setProductOption(pod.getProductOptionName());
                                break;
                            }
                        }
                    }

                    if (StringUtils.isBlank(opa.getProductOptionValue())) {
                        ProductOptionValue pov = pa.getProductOptionValue();
                        if (pov != null) {
                            Set povDescriptions = pov.getDescriptions();
                            if (povDescriptions != null) {
                                Iterator povi = povDescriptions.iterator();
                                while (povi.hasNext()) {
                                    ProductOptionValueDescription povd = (ProductOptionValueDescription) povi
                                            .next();
                                    if (povd.getId().getLanguageId() == LanguageUtil
                                            .getLanguageNumberCode(lang)) {
                                        opa.setProductOptionValue(povd.getProductOptionValueName());
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    opa.setProductAttributeWeight(pa.getProductAttributeWeight());
                    if (count == 0) {
                        attributesLine.append("[ ");
                    }
                    attributesLine.append(opa.getProductOption()).append(" -> ")
                            .append(opa.getProductOptionValue());
                    if (count + 1 == attributes.size()) {
                        attributesLine.append("]");
                    } else {
                        attributesLine.append(", ");
                    }
                    count++;
                }
            }

            // add attribute price to productprice
            if (sumPrice != null) {
                // sumPrice = sumPrice.multiply(new
                // BigDecimal(scp.getProductQuantity()));

                scp.setAttributeAdditionalCost(sumPrice);// add additional
                // attribute
                // price

                // get product price
                BigDecimal productPrice = scp.getProductPrice();
                productPrice = productPrice.add(sumPrice);

                // added
                scp.setProductPrice(productPrice);

                // BigDecimal finalPrice = scp.getFinalPrice();
                BigDecimal finalPrice = productPrice.multiply(new BigDecimal(scp.getProductQuantity()));
                // finalPrice = finalPrice.add(sumPrice);
                // BigDecimal cost = scp.get

                scp.setPriceText(CurrencyUtil.displayFormatedAmountNoCurrency(productPrice, currency));
                scp.setPriceFormated(CurrencyUtil.displayFormatedAmountWithCurrency(finalPrice, currency));
            }

            if (attributesLine != null) {
                scp.setAttributesLine(attributesLine.toString());
            }

            Set attributesSet = new HashSet(attributes);

            scp.setOrderattributes(attributesSet);

        }

    }

    return scp;
}