Example usage for java.lang Double doubleValue

List of usage examples for java.lang Double doubleValue

Introduction

In this page you can find the example usage for java.lang Double doubleValue.

Prototype

@HotSpotIntrinsicCandidate
public double doubleValue() 

Source Link

Document

Returns the double value of this Double object.

Usage

From source file:eu.planets_project.tb.impl.chart.ExperimentChartServlet.java

public JFreeChart createXYChart(String expId) {
    ExperimentPersistencyRemote edao = ExperimentPersistencyImpl.getInstance();
    long eid = Long.parseLong(expId);
    log.info("Building experiment chart for eid = " + eid);
    Experiment exp = edao.findExperiment(eid);

    final String expName = exp.getExperimentSetup().getBasicProperties().getExperimentName();
    final XYSeries series = new XYSeries(expName);

    for (BatchExecutionRecordImpl batch : exp.getExperimentExecutable().getBatchExecutionRecords()) {
        int i = 1;
        for (ExecutionRecordImpl exr : batch.getRuns()) {
            //log.info("Found Record... "+exr+" stages: "+exr.getStages());
            if (exr != null && exr.getStages() != null) {
                // Look up the object, so we can get the name.
                DigitalObjectRefBean dh = new DataHandlerImpl().get(exr.getDigitalObjectReferenceCopy());
                String dobName = "Object " + i;
                if (dh != null)
                    dobName = dh.getName();

                for (ExecutionStageRecordImpl exsr : exr.getStages()) {
                    Double time = exsr.getDoubleMeasurement(TecRegMockup.PROP_SERVICE_TIME);
                    Double size = exsr.getDoubleMeasurement(TecRegMockup.PROP_DO_SIZE);
                    // Look for timing:
                    if (time != null && size != null && size.doubleValue() > 0.0 && time.doubleValue() > 0.0) {
                        series.add(size, time);
                        /*
                        if( exsr.isMarkedAsSuccessful() ) {
                        dataset.addValue( time, "Succeded", dobName);
                        } else {//from ww w.j a v a 2  s. c  o m
                        dataset.addValue( time, "Failed", dobName);
                        }
                        */
                    }
                }
            }
            // Increment, for the next run.
            i++;
        }
    }
    // Create the chart.
    JFreeChart chart = ChartFactory.createScatterPlot(null, "Size [bytes]", "Time [s]",
            new XYSeriesCollection(series), PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    LogAxis xAxis = new LogAxis("Size [bytes]");
    // Set the base appropriately:
    xAxis.setBase(1024.0);
    //        xAxis.setTickUnit( new NumberTickUnit(128.0) );
    //        xAxis.getTickUnit().getMinorTickCount();
    // FIXME This should really be a KB/MB/etc number formatter...
    xAxis.setNumberFormatOverride(new LogFormat(1024.0, "1024", true));
    //        LogAxis yAxis = new LogAxis("Y");
    //        yAxis.setNumberFormatOverride(new LogFormat(10.0, "10", true));
    plot.setDomainAxis(xAxis);
    //        plot.setRangeAxis(yAxis);

    // Add some tool-tips
    plot.getRenderer().setBaseToolTipGenerator(new StandardXYToolTipGenerator());

    return chart;

}

From source file:com.datatorrent.lib.math.MarginMap.java

/**
 * Generates tuples for each key and emits them. Only keys that are in the denominator are iterated on
 * If the key is only in the numerator, it gets ignored (cannot do divide by 0)
 * Clears internal data//from  w w  w.  j  a  v a 2 s.  c  o  m
 */
@Override
public void endWindow() {
    HashMap<K, V> tuples = new HashMap<K, V>();
    Double val;
    for (Map.Entry<K, MutableDouble> e : denominators.entrySet()) {
        MutableDouble nval = numerators.get(e.getKey());
        if (nval == null) {
            nval = new MutableDouble(0.0);
        } else {
            numerators.remove(e.getKey()); // so that all left over keys can be reported
        }
        if (percent) {
            val = (1 - nval.doubleValue() / e.getValue().doubleValue()) * 100;
        } else {
            val = 1 - nval.doubleValue() / e.getValue().doubleValue();
        }
        tuples.put(e.getKey(), getValue(val.doubleValue()));
    }
    if (!tuples.isEmpty()) {
        margin.emit(tuples);
    }
    numerators.clear();
    denominators.clear();
}

From source file:nl.strohalm.cyclos.controls.reports.statistics.graphs.ChartPostProcessorImpl.java

/**
 * This method sets the x-axis labels in a rotated position. Use this only if there are a lot of bars in the graph, so there is very limited space
 * for eacht label on the x-axis. By rotating the labels, they wont overlap each other, and there will be more space per label. Set this in the
 * jsp via the param tag, using the keyword "xlabelRotation": <cewolf:chartpostprocessor id="chartPostProcessorImpl" > <cewolf:param
 * name="xlabelRotation" value="<%= new Double(0.60)%>"/> </cewolf:chartpostprocessor> The parameter is a double, indicating the rotation angle in
 * radials. <b>NOTE:</b> the rotation is set to 0.60 by default if the number of categories > 14; otherwise, the default rotation is 0. Setting
 * the parameter overrides this default.
 * @param plot//from w  w  w . ja  v a 2  s  .c  om
 * @param params
 */
@SuppressWarnings("rawtypes")
private void setRotatedXaxisLabels(final CategoryPlot plot, final Map params) {
    Double rotation = (Double) params.get("xlabelRotation");
    final int numberOfCategories = plot.getCategories().size();
    if (rotation == null && numberOfCategories > ROTATE_XLABELS_IF_MORE_THAN) {
        rotation = new Double(0.60);
    }
    if (rotation != null && rotation != 0) {
        final CategoryAxis axis = plot.getDomainAxis();
        axis.setCategoryLabelPositions(
                CategoryLabelPositions.createUpRotationLabelPositions(rotation.doubleValue()));
    }
}

From source file:org.sakaiproject.tool.gradebook.business.impl.GradebookCalculationImpl.java

@Override
public double getTotalPointsInternal(final Gradebook gradebook, final List categories, final String studentId,
        List<AssignmentGradeRecord> studentGradeRecs, List<Assignment> countedAssigns, boolean literalTotal) {
    int gbGradeType = gradebook.getGrade_type();
    if (gbGradeType != GradebookService.GRADE_TYPE_POINTS
            && gbGradeType != GradebookService.GRADE_TYPE_PERCENTAGE) {
        if (log.isInfoEnabled())
            log.error("Wrong grade type in GradebookCalculationImpl.getTotalPointsInternal");
        return -1;
    }// ww w.  j a  v a 2s . c om

    if (studentGradeRecs == null || countedAssigns == null) {
        if (log.isDebugEnabled())
            log.debug("Returning 0 from getTotalPointsInternal "
                    + "since studentGradeRecs or countedAssigns was null");
        return 0;
    }

    double totalPointsPossible = 0;

    HashSet<Assignment> countedSet = new HashSet<Assignment>(countedAssigns);

    // we need to filter this list to identify only "counted" grade recs
    List<AssignmentGradeRecord> countedGradeRecs = new ArrayList<AssignmentGradeRecord>();
    for (AssignmentGradeRecord gradeRec : studentGradeRecs) {
        Assignment assign = gradeRec.getAssignment();
        boolean extraCredit = assign.isExtraCredit();
        if (gradebook.getCategory_type() != GradebookService.CATEGORY_TYPE_NO_CATEGORY
                && assign.getCategory() != null && assign.getCategory().isExtraCredit())
            extraCredit = true;

        if (assign.isCounted() && !assign.getUngraded() && !assign.isRemoved() && countedSet.contains(assign)
                && assign.getPointsPossible() != null && assign.getPointsPossible() > 0
                && !gradeRec.getDroppedFromGrade() && !extraCredit) {
            countedGradeRecs.add(gradeRec);
        }
    }

    Set assignmentsTaken = new HashSet();
    Set categoryTaken = new HashSet();
    for (AssignmentGradeRecord gradeRec : countedGradeRecs) {
        if (gradeRec.getPointsEarned() != null && !gradeRec.getPointsEarned().equals("")) {
            Double pointsEarned = new Double(gradeRec.getPointsEarned());
            Assignment go = gradeRec.getAssignment();
            if (pointsEarned != null) {
                if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_NO_CATEGORY) {
                    assignmentsTaken.add(go.getId());
                } else if ((gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_ONLY_CATEGORY
                        || gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_WEIGHTED_CATEGORY)
                        && go != null && categories != null) {
                    //                      assignmentsTaken.add(go.getId());
                    //                  }
                    //                  else if(gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_WEIGHTED_CATEGORY && go != null && categories != null)
                    //                  {
                    for (int i = 0; i < categories.size(); i++) {
                        Category cate = (Category) categories.get(i);
                        if (cate != null && !cate.isRemoved() && go.getCategory() != null
                                && cate.getId().equals(go.getCategory().getId())
                                && ((cate.isExtraCredit() != null && !cate.isExtraCredit())
                                        || cate.isExtraCredit() == null)) {
                            assignmentsTaken.add(go.getId());
                            categoryTaken.add(cate.getId());
                            break;
                        }
                    }
                }
            }
        }
    }

    if (!assignmentsTaken.isEmpty()) {
        if (!literalTotal && gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_WEIGHTED_CATEGORY) {
            for (int i = 0; i < categories.size(); i++) {
                Category cate = (Category) categories.get(i);
                if (cate != null && !cate.isRemoved() && categoryTaken.contains(cate.getId())) {
                    totalPointsPossible += cate.getWeight().doubleValue();
                }
            }
            return totalPointsPossible;
        }
        Iterator assignmentIter = countedAssigns.iterator();
        while (assignmentIter.hasNext()) {
            Assignment asn = (Assignment) assignmentIter.next();
            if (asn != null) {
                Double pointsPossible = asn.getPointsPossible();

                if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_NO_CATEGORY
                        && assignmentsTaken.contains(asn.getId())) {
                    totalPointsPossible += pointsPossible.doubleValue();
                } else if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_ONLY_CATEGORY
                        && assignmentsTaken.contains(asn.getId())) {
                    totalPointsPossible += pointsPossible.doubleValue();
                } else if (literalTotal
                        && gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_WEIGHTED_CATEGORY
                        && assignmentsTaken.contains(asn.getId())) {
                    totalPointsPossible += pointsPossible.doubleValue();
                }
            }
        }
    } else
        totalPointsPossible = -1;

    return totalPointsPossible;
}

From source file:com.osafe.events.CheckOutEvents.java

public static String setShipGroups(HttpServletRequest request, HttpServletResponse response) {
    LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
    Delegator delegator = (Delegator) request.getAttribute("delegator");
    Locale locale = UtilHttp.getLocale(request);
    ShoppingCart shoppingCart = ShoppingCartEvents.getCartObject(request);
    String sItemTotalQty = request.getParameter("itemTotalQuantity");
    String sNumberOfItems = request.getParameter("numberOfItems");
    int iNumberOfItems = Integer.valueOf(sNumberOfItems);
    int iItemTotalQty = 0;
    BigDecimal bcartItemTotalQty = shoppingCart.getTotalQuantity();
    Map shippingContactMechMap = FastMap.newInstance();
    Map cartLineShippingContactMechQtyMap = FastMap.newInstance();
    Map cartLineShippingContactMechGiftMsgMap = FastMap.newInstance();
    Map cartLineQtyMap = FastMap.newInstance();
    Map cartLineProductInfoMap = FastMap.newInstance();
    Map cartItemQtyMap = FastMap.newInstance();
    List<MessageString> error_list = new ArrayList<MessageString>();
    MessageString messageString = null;//ww w.  j  a  v a  2s .com
    String message = null;
    if (UtilValidate.isNotEmpty(sItemTotalQty)) {
        iItemTotalQty = Integer.valueOf(sItemTotalQty).intValue();
    }

    /* Build quantity-product maps based on items on page */
    for (int i = 0; i < iItemTotalQty; i++) {
        String shippingContactMechId = request.getParameter("shippingContactMechId_" + i);
        String sCartLineIndex = request.getParameter("cartLineIndex_" + i);
        int iCartLineIndex = Integer.valueOf(sCartLineIndex).intValue();

        String qtyInCart = request.getParameter("qtyInCart_" + i);
        String productName = request.getParameter("productName_" + i);
        String productId = request.getParameter("productId_" + i);
        String productCategoryId = request.getParameter("productCategoryId_" + i);
        String prodCatalogId = request.getParameter("prodCatelogId_" + i);
        String unitPrice = request.getParameter("unitPrice_" + i);
        Map productInfoMap = FastMap.newInstance();
        productInfoMap.put("productName", productName);
        productInfoMap.put("productId", productId);
        productInfoMap.put("productCategoryId", productCategoryId);
        productInfoMap.put("prodCatalogId", prodCatalogId);
        productInfoMap.put("unitPrice", unitPrice);
        String giftMsgFrom = request.getParameter("lineItemGiftFrom_" + i);
        String giftMsgTo = request.getParameter("lineItemGiftTo_" + i);
        String giftMsg = request.getParameter("lineItemGiftMsg_" + i);
        Map giftMessageInfoMap = FastMap.newInstance();
        if (UtilValidate.isNotEmpty(giftMsgFrom)) {
            giftMessageInfoMap.put("from", giftMsgFrom);
        }
        if (UtilValidate.isNotEmpty(giftMsgTo)) {
            giftMessageInfoMap.put("to", giftMsgTo);
        }
        if (UtilValidate.isNotEmpty(giftMsg)) {
            giftMessageInfoMap.put("msg", giftMsg);
        }
        BigDecimal bLineQty = BigDecimal.ZERO;
        BigDecimal bShipQty = BigDecimal.ZERO;
        BigDecimal bCartQty = BigDecimal.ZERO;
        try {
            if (UtilValidate.isNotEmpty(qtyInCart)) {
                Double dQty = Double.valueOf(qtyInCart);
                if (UtilValidate.isInteger(qtyInCart) && dQty >= 0) {
                    bLineQty = BigDecimal.valueOf(dQty.doubleValue());
                } else {
                    bLineQty = BigDecimal.ZERO;
                    message = OSAFE_UI_LABELS.getString("PDPQtyDecimalNumberError");
                    message = StringUtil.replaceString(message, "_PRODUCT_NAME_", productName);
                    messageString = new MessageString(message, "qtyInCart_" + i, true);
                    error_list.add(messageString);

                }
            }
        } catch (Exception e) {
            bLineQty = BigDecimal.ZERO;
            message = OSAFE_UI_LABELS.getString("PDPQtyDecimalNumberError");
            message = StringUtil.replaceString(message, "_PRODUCT_NAME_", productName);
            messageString = new MessageString(message, "qtyInCart_" + i, true);
            error_list.add(messageString);

        }
        shippingContactMechMap.put(shippingContactMechId, shippingContactMechId);

        if (cartLineShippingContactMechQtyMap.containsKey(sCartLineIndex + "_" + shippingContactMechId)) {
            BigDecimal bTempQty = (BigDecimal) cartLineShippingContactMechQtyMap
                    .get(sCartLineIndex + "_" + shippingContactMechId);
            bShipQty = bShipQty.add(bTempQty);
        }
        bShipQty = bShipQty.add(bLineQty);
        cartLineShippingContactMechQtyMap.put(sCartLineIndex + "_" + shippingContactMechId, bShipQty);

        if (UtilValidate.isNotEmpty(giftMessageInfoMap)) {
            List lGiftMsg = null;
            if (cartLineShippingContactMechGiftMsgMap
                    .containsKey(sCartLineIndex + "_" + shippingContactMechId)) {
                lGiftMsg = (List) cartLineShippingContactMechGiftMsgMap
                        .get(sCartLineIndex + "_" + shippingContactMechId);
            } else {
                lGiftMsg = FastList.newInstance();
            }
            lGiftMsg.add(giftMessageInfoMap);
            cartLineShippingContactMechGiftMsgMap.put(sCartLineIndex + "_" + shippingContactMechId, lGiftMsg);
        }

        if (cartLineQtyMap.containsKey(sCartLineIndex)) {
            BigDecimal bTempQty = (BigDecimal) cartLineQtyMap.get(sCartLineIndex);
            bCartQty = bCartQty.add(bTempQty);
        }
        bCartQty = bCartQty.add(bLineQty);
        cartLineQtyMap.put(sCartLineIndex, bCartQty);
        cartLineProductInfoMap.put(sCartLineIndex, productInfoMap);
    }

    /* Validate Quantities entered */
    if (UtilValidate.isNotEmpty(cartLineQtyMap)) {
        try {

            String pdpQtyMin = Util.getProductStoreParm(request, "PDP_QTY_MIN");
            if (UtilValidate.isEmpty(pdpQtyMin)) {
                pdpQtyMin = "1";
            }
            String pdpQtyMax = Util.getProductStoreParm(request, "PDP_QTY_MAX");
            if (UtilValidate.isEmpty(pdpQtyMax)) {
                pdpQtyMax = "99";
            }
            BigDecimal bPdpQtyMin = BigDecimal.valueOf(Double.valueOf(pdpQtyMin).doubleValue());
            BigDecimal bPdpQtyMax = BigDecimal.valueOf(Double.valueOf(pdpQtyMax).doubleValue());

            Iterator<String> cartItemIter = cartLineQtyMap.keySet().iterator();
            while (cartItemIter.hasNext()) {
                String sCartLineIndex = cartItemIter.next();
                BigDecimal bChangeQty = (BigDecimal) cartLineQtyMap.get(sCartLineIndex);
                if (bChangeQty.compareTo(BigDecimal.ZERO) == 0) {
                    continue;
                }
                int iCartLineIndex = Integer.valueOf(sCartLineIndex).intValue();
                Map productInfoMap = (Map) cartLineProductInfoMap.get(sCartLineIndex);
                GenericValue prodPdpQtyMin = delegator.findOne("ProductAttribute",
                        UtilMisc.toMap("productId", productInfoMap.get("productId"), "attrName", "PDP_QTY_MIN"),
                        true);
                GenericValue prodPdpQtyMax = delegator.findOne("ProductAttribute",
                        UtilMisc.toMap("productId", productInfoMap.get("productId"), "attrName", "PDP_QTY_MAX"),
                        true);
                if (UtilValidate.isNotEmpty(prodPdpQtyMin) && UtilValidate.isNotEmpty(prodPdpQtyMax)) {
                    bPdpQtyMin = BigDecimal
                            .valueOf(Double.valueOf(prodPdpQtyMin.getString("attrValue")).doubleValue());
                    bPdpQtyMax = BigDecimal
                            .valueOf(Double.valueOf(prodPdpQtyMax.getString("attrValue")).doubleValue());
                }
                if (bChangeQty.compareTo(bPdpQtyMin) < 0) {
                    message = OSAFE_UI_LABELS.getString("PDPMinQtyError");
                    message = StringUtil.replaceString(message, "_PRODUCT_NAME_",
                            "" + productInfoMap.get("productName"));
                    message = StringUtil.replaceString(message, "_PDP_QTY_MIN_", "" + bPdpQtyMin.intValue());
                    messageString = new MessageString(message, "qtyInCart_" + sCartLineIndex, true);
                    error_list.add(messageString);

                }
                if (bChangeQty.compareTo(bPdpQtyMax) > 0) {
                    message = OSAFE_UI_LABELS.getString("PDPMaxQtyError");
                    message = StringUtil.replaceString(message, "_PRODUCT_NAME_",
                            "" + productInfoMap.get("productName"));
                    message = StringUtil.replaceString(message, "_PDP_QTY_MAX_", "" + bPdpQtyMax.intValue());
                    messageString = new MessageString(message, "qtyInCart_" + sCartLineIndex, true);
                    error_list.add(messageString);

                }

            }
        } catch (Exception e) {
            Debug.logError(e, "Error: updating cart quantity", module);
        }

    }
    if (error_list.size() != 0) {
        request.setAttribute("_ERROR_MESSAGE_LIST_", error_list);
        return "error";
    }
    /* Check the number of items passed from the screen matches the number of items in the cart.
     * If the number of items has changed remove all products from the cart and add back.
     * If the number of items have not changed remove zero quantities and set changed item quantities
     * The number of item check is essentially protecting against the usage of the back button.
     */
    if (UtilValidate.isNotEmpty(cartLineQtyMap)) {
        if (shoppingCart.items().size() != iNumberOfItems) {
            ShoppingCartItem shoppingCartItem = null;
            try {
                Iterator<ShoppingCartItem> cartItemIter = shoppingCart.items().iterator();
                while (cartItemIter.hasNext()) {
                    shoppingCartItem = (ShoppingCartItem) cartItemIter.next();
                    shoppingCart.removeCartItem(shoppingCartItem, dispatcher);
                }

                Iterator<String> cartLineItemIter = cartLineQtyMap.keySet().iterator();
                while (cartLineItemIter.hasNext()) {
                    String sCartLineIndex = cartLineItemIter.next();
                    BigDecimal bChangeQty = (BigDecimal) cartLineQtyMap.get(sCartLineIndex);
                    if (bChangeQty.compareTo(BigDecimal.ZERO) == 0) {
                        continue;
                    }
                    Map productInfoMap = (Map) cartLineProductInfoMap.get(sCartLineIndex);
                    String unitPrice = (String) productInfoMap.get("unitPrice");
                    BigDecimal bUnitPrice = null;
                    if (UtilValidate.isNotEmpty(unitPrice)) {
                        bUnitPrice = BigDecimal.valueOf(Double.valueOf(unitPrice).doubleValue());
                    }
                    if (UtilValidate.isEmpty(bUnitPrice)) {
                        message = OSAFE_UI_LABELS.getString("PDPMaxQtyError");
                        error_list.add(messageString);
                        request.setAttribute("_ERROR_MESSAGE_LIST_", error_list);
                        return "error";

                    }

                    ShoppingCartItem item = ShoppingCartItem.makeItem(null,
                            "" + productInfoMap.get("productId"), null, bChangeQty, bUnitPrice, null, null,
                            null, null, null, null, null, null, null, "" + productInfoMap.get("prodCatelogId"),
                            null, null, null, dispatcher, shoppingCart, Boolean.TRUE, Boolean.FALSE,
                            "" + productInfoMap.get("parentProductId"), Boolean.TRUE, Boolean.TRUE);
                    shoppingCart.addItemToEnd(item);
                    com.osafe.events.ShoppingCartEvents.setProductFeaturesOnCart(shoppingCart,
                            "" + productInfoMap.get("productId"));

                }

            } catch (Exception e) {
                Debug.logError("Error: removing cart item" + shoppingCartItem, module);
            }

        } else {
            try {

                Iterator<String> cartItemIter = cartLineQtyMap.keySet().iterator();
                while (cartItemIter.hasNext()) {
                    String sCartLineIndex = cartItemIter.next();
                    BigDecimal bChangeQty = (BigDecimal) cartLineQtyMap.get(sCartLineIndex);
                    int iCartLineIndex = Integer.valueOf(sCartLineIndex).intValue();
                    ShoppingCartItem shoppingCartItem = shoppingCart.findCartItem(iCartLineIndex);
                    if (bChangeQty.compareTo(BigDecimal.ZERO) == 0) {
                        shoppingCart.removeCartItem(shoppingCartItem, dispatcher);
                        continue;
                    }
                    if (bChangeQty.compareTo(shoppingCartItem.getQuantity()) != 0) {
                        shoppingCartItem.setQuantity(bChangeQty, dispatcher, shoppingCart);
                    }

                }
            } catch (Exception e) {
                Debug.logError("Error: updating cart quantity", module);
            }

        }

    }

    if (UtilValidate.isNotEmpty(shoppingCart.items())) {
        Iterator<ShoppingCartItem> cartItemIter = shoppingCart.items().iterator();
        int iItemIndex = 0;
        while (cartItemIter.hasNext()) {
            ShoppingCartItem shoppingCartItem = (ShoppingCartItem) cartItemIter.next();
            BigDecimal itemQuantity = shoppingCartItem.getQuantity();
            cartItemQtyMap.put("" + iItemIndex, itemQuantity);
            iItemIndex++;

            /* Clear Gift Messages per item.  Will be Reset
             * 
             */
            Map<String, String> orderItemAttributesMap = shoppingCartItem.getOrderItemAttributes();
            if (UtilValidate.isNotEmpty(orderItemAttributesMap)) {
                for (Entry<String, String> itemAttr : orderItemAttributesMap.entrySet()) {
                    String sAttrName = (String) itemAttr.getKey();
                    if (sAttrName.startsWith("GIFT_MSG_FROM_")) {
                        shoppingCartItem.removeOrderItemAttribute(sAttrName);

                    }
                    if (sAttrName.startsWith("GIFT_MSG_TO_")) {
                        shoppingCartItem.removeOrderItemAttribute(sAttrName);

                    }
                    if (sAttrName.startsWith("GIFT_MSG_TEXT_")) {
                        shoppingCartItem.removeOrderItemAttribute(sAttrName);

                    }

                }
            }
        }
    } else {
        return "emptyCart";

    }
    /* Clear item Ship Groups and create new ones */
    if (UtilValidate.isNotEmpty(shippingContactMechMap)) {
        Iterator<ShoppingCartItem> cartItemIter = shoppingCart.items().iterator();
        while (cartItemIter.hasNext()) {
            shoppingCart.clearItemShipInfo(cartItemIter.next());

        }
        shoppingCart.cleanUpShipGroups();

        Iterator<String> shipGroupIter = shippingContactMechMap.keySet().iterator();
        while (shipGroupIter.hasNext()) {
            int shipGroupIndex = shoppingCart.addShipInfo();
            String shippingContactMechId = shipGroupIter.next();
            shoppingCart.setShippingContactMechId(shipGroupIndex, shippingContactMechId);
            shippingContactMechMap.put(shippingContactMechId, Integer.valueOf(shipGroupIndex));

        }

    }

    if (UtilValidate.isNotEmpty(cartLineShippingContactMechQtyMap)) {
        Map<ShoppingCartItem, String> cartItemMessageCount = FastMap.newInstance();
        Iterator<String> cartLineShippingQtyIter = cartLineShippingContactMechQtyMap.keySet().iterator();
        while (cartLineShippingQtyIter.hasNext()) {
            String cartLineShippingContactMechKey = cartLineShippingQtyIter.next();
            int iKeySeparator = cartLineShippingContactMechKey.indexOf('_');

            String sCartLineIndex = cartLineShippingContactMechKey.substring(0, iKeySeparator);
            int iCartLineIndex = Integer.valueOf(sCartLineIndex);
            int iItemGiftMsgCount = 0;

            String shippingContactMechId = cartLineShippingContactMechKey.substring(iKeySeparator + 1);

            BigDecimal bShipQty = (BigDecimal) cartLineShippingContactMechQtyMap
                    .get(cartLineShippingContactMechKey);
            BigDecimal bCartItemQty = (BigDecimal) cartItemQtyMap.get(sCartLineIndex);
            BigDecimal bCartQty = BigDecimal.ZERO;
            if (UtilValidate.isNotEmpty(bCartItemQty)) {
                bCartQty = bCartItemQty;
            }
            BigDecimal bTotalShipGroupQty = BigDecimal.ZERO;
            BigDecimal bAddShipQty = BigDecimal.ZERO;

            if (bShipQty.compareTo(BigDecimal.ZERO) > 0) {
                Map shipGroupQtyMap = shoppingCart.getShipGroups(iCartLineIndex);
                Iterator shipGroupQtyIter = shipGroupQtyMap.keySet().iterator();
                while (shipGroupQtyIter.hasNext()) {
                    BigDecimal bShipGroupQty = (BigDecimal) shipGroupQtyMap.get(shipGroupQtyIter.next());
                    bTotalShipGroupQty = bTotalShipGroupQty.add(bShipGroupQty);
                }
                /* Total quantity designated to Ship has already been met */
                if (bTotalShipGroupQty.compareTo(bCartQty) == 0) {
                    continue;
                }
                /* If the ship quantity is greater than the quantity in the cart, set the ship quantity equal to cart quantity. */
                if (bShipQty.compareTo(bCartQty) > 0) {
                    bShipQty = bCartQty;
                }
                /* Add the Ship quantity to total ship quantity, If greater set the ship quantity to the quantity left that can be shipped
                 * (cart quantity minus total ship quantity) */
                bAddShipQty = bShipQty.add(bTotalShipGroupQty);
                if (bAddShipQty.compareTo(bCartQty) > 0) {
                    bShipQty = bCartQty.subtract(bTotalShipGroupQty);
                }
                if (bShipQty.compareTo(BigDecimal.ZERO) > 0) {
                    int shipGroupIndex = ((Integer) shippingContactMechMap.get(shippingContactMechId))
                            .intValue();
                    shoppingCart.setItemShipGroupQty(iCartLineIndex, bShipQty, shipGroupIndex);
                    /* Check Cart item Gift Messages going to this Ship Group (Address)
                     * 
                     */
                    List lGiftMsg = (List) cartLineShippingContactMechGiftMsgMap
                            .get(cartLineShippingContactMechKey);
                    if (UtilValidate.isNotEmpty(lGiftMsg)) {
                        ShoppingCartItem cartItem = shoppingCart.findCartItem(iCartLineIndex);
                        for (int i = 0; i < lGiftMsg.size(); i++) {
                            if (i > bShipQty.intValue()) {
                                break;
                            }
                            String sItemGiftMsgCount = (String) cartItemMessageCount.get(cartItem);
                            if (UtilValidate.isEmpty(sItemGiftMsgCount)) {
                                iItemGiftMsgCount = 1;
                            } else {
                                iItemGiftMsgCount = Integer.valueOf(sItemGiftMsgCount);
                                iItemGiftMsgCount++;

                            }

                            sItemGiftMsgCount = "" + iItemGiftMsgCount;
                            cartItemMessageCount.put(cartItem, sItemGiftMsgCount);

                            Map giftMsgMap = (Map) lGiftMsg.get(i);
                            String msgFrom = (String) giftMsgMap.get("from");
                            if (UtilValidate.isNotEmpty(msgFrom)) {
                                cartItem.setOrderItemAttribute(
                                        "GIFT_MSG_FROM_" + sItemGiftMsgCount + "_" + (shipGroupIndex + 1),
                                        msgFrom);

                            }
                            String msgTo = (String) giftMsgMap.get("to");
                            if (UtilValidate.isNotEmpty(msgTo)) {
                                cartItem.setOrderItemAttribute(
                                        "GIFT_MSG_TO_" + sItemGiftMsgCount + "_" + (shipGroupIndex + 1), msgTo);

                            }
                            String msg = (String) giftMsgMap.get("msg");
                            if (UtilValidate.isNotEmpty(msg)) {
                                cartItem.setOrderItemAttribute(
                                        "GIFT_MSG_TEXT_" + sItemGiftMsgCount + "_" + (shipGroupIndex + 1), msg);

                            }

                        }
                    }
                }

            }

        }

        /* Now check all quantities of each cart items have been assigned to a ship group
         * If not calculate and add the missing quantity to the last ship group defined for the item
         * */
        Iterator<ShoppingCartItem> cartItemIter = shoppingCart.items().iterator();
        while (cartItemIter.hasNext()) {
            ShoppingCartItem shoppingCartItem = (ShoppingCartItem) cartItemIter.next();

            BigDecimal bTotalShipGroupQty = BigDecimal.ZERO;
            BigDecimal bCartQty = shoppingCartItem.getQuantity();
            BigDecimal bShipGroupQty = BigDecimal.ZERO;
            int iShipGroupIndex = 0;

            Map shipGroupQtyMap = shoppingCart.getShipGroups(shoppingCartItem);
            Iterator shipGroupQtyIter = shipGroupQtyMap.keySet().iterator();
            while (shipGroupQtyIter.hasNext()) {
                iShipGroupIndex = Integer.valueOf(shipGroupQtyIter.next().toString());
                bShipGroupQty = (BigDecimal) shipGroupQtyMap.get(iShipGroupIndex);
                bTotalShipGroupQty = bTotalShipGroupQty.add(bShipGroupQty);

            }

            if (bTotalShipGroupQty.compareTo(bCartQty) < 0) {
                BigDecimal bAddShipQty = bCartQty.subtract(bTotalShipGroupQty);
                bAddShipQty = bAddShipQty.add(bShipGroupQty);

                shoppingCart.setItemShipGroupQty(shoppingCartItem, bAddShipQty, iShipGroupIndex);
            }
        }

        /* Clean up ship groups, if no quantities in group the group is removed.
         * If not calculate and add the missing quantity to the last ship group defined for the item
         * */
        shoppingCart.cleanUpShipGroups();

        /* Check ship group with multiple items, if more than one item in the group check
         * the shipping options available for each item,; if different count the group is split. 
         * */

        splitShipGroupByShipOptions(request, response);

    }

    return "success";
}

From source file:de.hybris.platform.order.CartServiceTest.java

@Test
/*/* ww  w .ja  v  a2 s.  c  o  m*/
 * * PLA-7681
 */
public void testChangeQuantity() throws InvalidCartException {
    final ProductModel product = productService.getProduct("testProduct0");
    final CartModel cart = cartService.getSessionCart();
    cartService.addToCart(cart, product, 1, null);
    final List<AbstractOrderEntryModel> entries = cart.getEntries();
    assertEquals("Number of entries", 1, entries.size());
    final AbstractOrderEntryModel entry = entries.iterator().next();
    assertEquals("Quantity", Long.valueOf(1), entry.getQuantity());
    assertEquals("Cart total", entry.getTotalPrice(), cart.getTotalPrice());

    final Double singleArticlePrice = cart.getTotalPrice();
    final Double doublePrice = Double.valueOf(2 * singleArticlePrice.doubleValue());
    // change quantity
    final List<Long> newQuantities = new ArrayList<Long>();
    newQuantities.add(Long.valueOf(2));
    cartService.updateQuantities(cart, newQuantities);
    cartService.calculateCart(cart);
    final CartModel cartAfterQuantityChange = cartService.getSessionCart();
    final List<AbstractOrderEntryModel> entriesDouble = cartAfterQuantityChange.getEntries();
    assertEquals("Number of entries for two items of product", 1, entriesDouble.size());
    final AbstractOrderEntryModel entryDouble = entriesDouble.iterator().next();
    assertEquals("Quantity for two items of product", Long.valueOf(2), entryDouble.getQuantity());
    assertEquals("Cart total for two items of product", doublePrice, cartAfterQuantityChange.getTotalPrice());
    assertEquals("Total price for two items of product", doublePrice, entryDouble.getTotalPrice());
}

From source file:rb.app.QNTransientSCMSystem.java

/**
 * Evaluate theta_c (for the quadratic nonlinearity) at the current parameter.
 *///  ww w  .  j  a  va  2  s . c  o m
public double eval_theta_c() {

    Method meth;

    try {
        Class partypes[] = new Class[1];
        partypes[0] = double[].class;

        meth = mAffineFnsClass.getMethod("evaluateC", partypes);
    } catch (NoSuchMethodException nsme) {
        throw new RuntimeException("getMethod for evaluateC failed", nsme);
    }

    Double theta_val;
    try {
        Object arglist[] = new Object[1];
        arglist[0] = current_parameters.getArray();

        Object theta_obj = meth.invoke(mTheta, arglist);
        theta_val = (Double) theta_obj;
    } catch (IllegalAccessException iae) {
        throw new RuntimeException(iae);
    } catch (InvocationTargetException ite) {
        throw new RuntimeException(ite.getCause());
    }

    return SCM_theta_c_scaling * theta_val.doubleValue();
}

From source file:net.mlw.vlh.web.tag.DefaultColumnTag.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
 *//*from  w  w  w.  jav  a  2s .  co m*/
public int doEndTag() throws JspException {

    ValueListSpaceTag rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class);

    DefaultRowTag rowTag = (DefaultRowTag) JspUtils.getParent(this, DefaultRowTag.class);

    ValueListConfigBean config = rootTag.getConfig();

    appendClassCellAttribute(rowTag.getRowStyleClass());

    if (locale == null) {
        //         locale = config.getLocaleResolver().resolveLocale((HttpServletRequest) pageContext.getRequest());
        locale = Locales.getSupportedLocale((HttpServletRequest) pageContext.getRequest());
    }

    if (rowTag.getCurrentRowNumber() == 0) // if this is the 1st row == the one with cell headers
    {

        String titleKey = getTitleKey();
        String label = (titleKey == null) ? getTitle()
                : config.getMessageSource().getMessage(titleKey, null, titleKey, locale);

        ColumnInfo columnInfo = new ColumnInfo(config.getDisplayHelper().help(pageContext, label),
                getAdapterProperty(), defaultSort, getAttributes());

        // Process toolTip if any
        // toolTip or toolTipKey is set => get the string and put it into the ColumnInfo
        String toolTipKey = getToolTipKey();
        columnInfo.setToolTip((toolTipKey == null) ? getToolTip()
                : config.getMessageSource().getMessage(toolTipKey, null, toolTipKey, locale));

        columnInfo.setNestedList(this.nestedColumnInfoList);

        rowTag.addColumnInfo(columnInfo);
    }

    DisplayProvider displayProvider = rowTag.getDisplayProvider();

    StringBuffer sb = new StringBuffer(displayProvider.getCellPreProcess(getCellAttributes()));

    boolean hasBodyContent = false;

    if (displayProvider.doesIncludeBodyContent() && bodyContent != null && bodyContent.getString() != null
            && bodyContent.getString().trim().length() > 0) {
        sb.append(bodyContent.getString().trim());
        bodyContent.clearBody();
        hasBodyContent = true;
    }

    {
        if (property != null && rowTag.getBeanName() != null) {
            try {
                Object bean = pageContext.getAttribute(rowTag.getBeanName());
                if (bean != null) {
                    Object value = null;
                    try {
                        value = PropertyUtils.getProperty(bean, property);
                    } catch (Exception e) {
                        //Do nothing, if you want to handle this exception, then
                        // use a try catch in the body content.
                        //                     LOGGER.error("<vlh:column> Error getting property='" + property + "' from the iterated JavaBean name='"
                        //                           + rowTag.getBeanName() + "'\n The row's JavaBean was >>>" + bean
                        //                           + "<<<\n Check the syntax or the spelling of the column's property!");
                    }

                    if (value != null) {
                        if (sum != null && value instanceof Number) {
                            double doubleValue = ((Number) value).doubleValue();
                            Double sumValue = (Double) pageContext.getAttribute(sum);
                            if (sumValue == null) {
                                sumValue = new Double(doubleValue);
                            } else {
                                sumValue = new Double(sumValue.doubleValue() + doubleValue);
                            }
                            pageContext.setAttribute(sum, sumValue);
                        }

                        if (!hasBodyContent) {
                            String formattedValue = JspUtils.format(value, format, locale);

                            if (groupKey == null
                                    || (config.getCellInterceptor() == null || !config.getCellInterceptor()
                                            .isHidden(pageContext, groupKey, property, formattedValue))) {
                                sb.append(displayProvider.emphase(formattedValue, getEmphasisPattern(),
                                        getColumnStyleClass()));
                            }
                        }

                    } else if (!hasBodyContent) {
                        if (LOGGER.isDebugEnabled()) {
                            LOGGER.debug("The property '" + property + "' of the iterated JavaBean '" + bean
                                    + "' is null!");
                        }

                        Object nullValue = (defaultValue == null) ? config.getNullToken() : defaultValue;

                        if (groupKey == null || (config.getCellInterceptor() == null || !config
                                .getCellInterceptor().isHidden(pageContext, groupKey, property, nullValue))) {
                            sb.append(nullValue);
                        }
                    }
                }
            } catch (Exception e) {
                final String message = "DefaultColumnTag.doEndTag() - <vlh:column> error getting property: "
                        + property + " from bean.";
                LOGGER.error(message, e);
                throw new JspException(message, e);
            }
        }
    }

    sb.append(displayProvider.getCellPostProcess());
    JspUtils.write(pageContext, sb.toString());

    release();

    return EVAL_PAGE;
}

From source file:org.hammurapi.QuickHammurapiTask.java

public void execute() throws BuildException {
    if (!suppressLogo) {
        log("Quick Hammurapi 3.18.4 Copyright (C) 2004 Hammurapi Group");
    }/*from w ww.j ava  2 s  . c om*/

    File archiveTmpDir = processArchive();

    try {
        long start = System.currentTimeMillis();

        Logger logger = new AntLogger(this);

        final VisitorStack[] visitorStack = { null };
        final VisitorStackSource visitorStackSource = new VisitorStackSource() {
            public VisitorStack getVisitorStack() {
                return visitorStack[0];
            }
        };

        final SessionImpl session = new SessionImpl();

        InspectorSet inspectorSet = new InspectorSet(new InspectorContextFactory() {
            public InspectorContext newContext(InspectorDescriptor descriptor, Logger logger) {
                return new InspectorContextImpl(descriptor, logger, visitorStackSource, session,
                        violationFilters);
            }
        }, logger);

        if (embeddedInspectors) {
            log("Loading embedded inspectors", Project.MSG_VERBOSE);
            loadEmbeddedInspectors(inspectorSet);
        }

        log("Loading inspectors", Project.MSG_VERBOSE);
        Iterator it = inspectors.iterator();
        while (it.hasNext()) {
            Object o = it.next();
            if (o instanceof InspectorSource) {
                ((InspectorSource) o).loadInspectors(inspectorSet);
            } else {
                InspectorEntry inspectorEntry = (InspectorEntry) o;
                inspectorSet.addDescriptor(inspectorEntry);
                inspectorSet.addInspectorSourceInfo(
                        new InspectorSourceInfo("Inline inspector " + inspectorEntry.getName(),
                                "Build file: " + inspectorEntry.getLocation().toString(), ""));
            }
        }

        log("Inspectors loaded: " + inspectorSet.size(), Project.MSG_VERBOSE);

        log("Loading waivers", Project.MSG_VERBOSE);
        Date now = new Date();
        WaiverSet waiverSet = new WaiverSet();
        it = waivers.iterator();
        while (it.hasNext()) {
            ((WaiverSource) it.next()).loadWaivers(waiverSet, now);
        }

        log("Waivers loaded: " + waiverSet.size(), Project.MSG_VERBOSE);

        log("Loading listeners", Project.MSG_VERBOSE);
        List listeners = new LinkedList();
        it = listenerEntries.iterator();
        while (it.hasNext()) {
            listeners.add(((ListenerEntry) it.next()).getObject(null));
        }

        //Outputs
        listeners.addAll(outputs);
        listeners.add(new ReviewToLogListener(project));

        Collection inspectors = new LinkedList(inspectorSet.getInspectors());
        session.setInspectors(inspectorSet);
        Iterator inspectorsIt = inspectors.iterator();
        log("Inspectors mapping", Project.MSG_VERBOSE);
        while (inspectorsIt.hasNext()) {
            Inspector inspector = (Inspector) inspectorsIt.next();
            log("\t" + inspector.getContext().getDescriptor().getName() + " -> "
                    + inspector.getClass().getName(), Project.MSG_VERBOSE);
        }

        ClassLoader classLoader;
        if (classPath == null) {
            classLoader = this.getClass().getClassLoader();
        } else {
            classLoader = new AntClassLoader(project, classPath, false);
            session.setClassPath(classPath.list());
        }

        new QuickResultsFactory(waiverSet, classLoader, tabSize, logger).install();

        Iterator lit = listeners.iterator();
        while (lit.hasNext()) {
            ((Listener) lit.next()).onBegin(inspectorSet);
        }

        try {
            QuickResultsCollector collector = new QuickResultsCollector(this, title, listeners);

            // Initializing violation filters
            Iterator vfit = violationFilters.iterator();
            while (vfit.hasNext()) {
                Object vf = vfit.next();
                if (vf instanceof DataAccessObject) {
                    ((DataAccessObject) vf).setSQLProcessor(collector.getProcessor());
                }

                if (vf instanceof Component) {
                    ((Component) vf).start();
                }
            }

            try {
                inspectors.add(collector);

                QuickReviewEngine engine = new QuickReviewEngine(inspectors, this, collector);
                visitorStack[0] = engine.getVisitorStack();
                session.setVisitor(engine.getVisitor());

                it = srcFileSets.iterator();
                while (it.hasNext()) {
                    HammurapiFileSet fs = (HammurapiFileSet) it.next();
                    fs.setDefaultIncludes();
                    DirectoryScanner scanner = fs.getDirectoryScanner(project);
                    String[] includedFiles = scanner.getIncludedFiles();
                    for (int i = 0; i < includedFiles.length; i++) {
                        review(new File(scanner.getBasedir(), includedFiles[i]), engine, classLoader, logger);
                    }
                }

                it = srcFiles.iterator();
                while (it.hasNext()) {
                    review((File) it.next(), engine, classLoader, logger);
                }

                collector.getEngine().deleteOld();

                Collection packageResults = new ArrayList();
                Iterator pit = collector.getEngine().getPackageTotal().iterator();
                while (pit.hasNext()) {
                    CompositeResults packageResult = new QuickPackageResults((PackageTotal) pit.next(),
                            collector, inspectorSet);
                    packageResult.commit();
                    Iterator llit = listeners.iterator();
                    while (llit.hasNext()) {
                        ((Listener) llit.next()).onPackage(packageResult);
                    }

                    packageResults.add(packageResult);
                }

                log("Building summary");

                CompositeResults summary = new QuickSummary(title, collector, inspectorSet, packageResults);
                ResultsFactory.pushThreadResults(summary);

                // Stopping violation filters
                vfit = violationFilters.iterator();
                while (vfit.hasNext()) {
                    Object vf = vfit.next();
                    if (vf instanceof Component) {
                        ((Component) vf).stop();
                    }
                }

                Iterator slit = listeners.iterator();
                while (slit.hasNext()) {
                    ((Listener) slit.next()).onSummary(summary, inspectorSet);
                }

                Iterator rit = getReviewAcceptorEntries().iterator();
                while (rit.hasNext()) {
                    ((ReviewAcceptor) ((ReviewAcceptorEntry) rit.next()).getObject(null)).accept(summary);
                }

                long finish = System.currentTimeMillis();

                long elapsedSec = (finish - start) / 1000;
                long min = elapsedSec / 60;
                long sec = elapsedSec % 60;

                log("Time: " + min + " min. " + sec + " sec.");
                log(MessageFormat.format("Performance {0, number,###.000000}",
                        new Object[] { new Double((double) summary.getCodeBase() * 1000 / (finish - start)) }));

                Integer severityThreshold = getSeverityThreshold();
                if (severityThreshold != null) {
                    final int sth = getSeverityThreshold().intValue();
                    new ReviewAcceptor() {
                        public void accept(CompositeResults summary) throws HammurapiException {
                            Number severity = summary.getMaxSeverity();
                            if (severity != null && severity.intValue() <= sth) {
                                throw new HammurapiException("Severity threshold (" + sth + ") infringed");
                            }
                        }
                    }.accept(summary);
                }

                Double sigmaThreshold = getSigmaThreshold();
                if (sigmaThreshold != null) {
                    final double cth = sigmaThreshold.doubleValue();
                    new ReviewAcceptor() {
                        public void accept(CompositeResults summary) throws HammurapiException {
                            try {
                                if (Double.parseDouble(summary.getSigma()) < cth) {
                                    throw new HammurapiException("Sigma is below threshold (" + cth + ")");
                                }
                            } catch (NumberFormatException e) {
                                throw new HammurapiException("Sigma is not valid");
                            }
                        }
                    }.accept(summary);
                }

                Integer dpmoThreshold = getDpmoThreshold();
                if (dpmoThreshold != null) {
                    final int cth = dpmoThreshold.intValue();
                    new ReviewAcceptor() {
                        public void accept(CompositeResults summary) throws HammurapiException {
                            try {
                                if (Integer.parseInt(summary.getDPMO()) > cth) {
                                    throw new HammurapiException("DPMO is above threshold (" + cth + ")");
                                }
                            } catch (NumberFormatException e) {
                                throw new HammurapiException("DPMO is not valid");
                            }
                        }
                    }.accept(summary);
                }

                if (isFailOnWarnings() && !summary.getWarnings().isEmpty()) {
                    throw new HammurapiNonConsumableException("There have been warnings during execution.");
                }

                summary.commit();
            } finally {
                session.shutdown();
                collector.shutdown();
            }
        } finally {
            if (archiveTmpDir != null) {
                deleteFile(archiveTmpDir);
            }
        }

        if (hadExceptions) {
            throw new BuildException("There have been exceptions during execution. Check log output.");
        }
    } catch (ClassNotFoundException e) {
        throw new BuildException(e);
    } catch (SQLException e) {
        throw new BuildException(e);
    } catch (JselException e) {
        throw new BuildException(e);
    } catch (HammurapiException e) {
        throw new BuildException(e);
    } catch (ConfigurationException e) {
        throw new BuildException(e);
    } catch (FileNotFoundException e) {
        throw new BuildException(e);
    } catch (IOException e) {
        throw new BuildException(e);
    }
}

From source file:org.kalypso.model.wspm.tuhh.core.profile.export.knauf.beans.builders.KnaufBridgeProfileBuilder.java

@Override
public IStatus execute(final IProgressMonitor monitor) {
    final Set<IStatus> stati = new LinkedHashSet<>();

    final Coordinate vector = getBaseVector();
    final Double distanceValue = m_bridge.getBreite();
    if (distanceValue == null) {
        Collections.addAll(stati, buildDefaultBeans(m_profile));
        final String message = String.format(Messages.getString("KnaufBridgeProfileBuilder.2"), //$NON-NLS-1$
                m_profile.getStation());
        return new Status(IStatus.WARNING, KalypsoModelWspmTuhhCorePlugin.PLUGIN_ID, message);
    }//from w w  w . j a va2  s .  c o  m

    final double distance = distanceValue.doubleValue();

    /** move bridge into upstream direction */
    final IStatus status = moveBridgeProfile(distance / 2.0);
    Collections.addAll(stati, status);
    if (!status.isOK())
        return StatusUtilities.createStatus(stati, Messages.getString("KnaufBridgeProfileBuilder_0")); //$NON-NLS-1$

    /** generate new upstream and downstream profiles */
    final KnaufProfileWrapper downstream = getOberwasserProfile(vector, distance);
    final KnaufProfileWrapper upstream = getUnterwasserProfile(vector, distance);

    /** lowering of upstream profile */
    final double deltaH = getDeltaH(m_bridge, upstream);
    upstream.getProfile().accept(new ChangeProfilePointHeight(deltaH), 1);

    Collections.addAll(stati, addProfile(upstream, distance));
    Collections.addAll(stati, buildDefaultBeans(m_profile));
    Collections.addAll(stati, addProfile(downstream, distance));

    return StatusUtilities.createStatus(stati, Messages.getString("KnaufBridgeProfileBuilder_0")); //$NON-NLS-1$
}