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:org.pentaho.platform.uifoundation.chart.XYZSeriesCollectionChartDefinition.java

public void setMaxBubbleSize(final Node maxBubbleSizeNode) {
    if (maxBubbleSizeNode != null) {
        String doubleStr = maxBubbleSizeNode.getText();
        Double doubleValue = new Double(doubleStr);
        setMaxBubbleSize(doubleValue.doubleValue());
    }// w w  w .ja  va 2s  .c  o m
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.StackedBar.java

/**
 * Override this functions from BarCharts beacuse I want the hidden serie to be the first!
 * //  w  ww  .ja va  2s.  co m
 * @return the dataset
 * 
 * @throws Exception the exception
 */

public DatasetMap calculateValue() throws Exception {
    logger.debug("IN");
    String res = DataSetAccessFunctions.getDataSetResultFromId(profile, getData(), parametersObject);
    categories = new HashMap();

    double cumulativeValue = 0.0;

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    SourceBean sbRows = SourceBean.fromXMLString(res);
    List listAtts = sbRows.getAttributeAsList("ROW");

    // run all categories (one for each row)
    categoriesNumber = 0;
    seriesNames = new Vector();
    catGroupNames = new Vector();
    if (filterCatGroups == true) {
        catGroups = new HashMap();
    }

    //categories.put(new Integer(0), "All Categories");
    boolean first = true;
    for (Iterator iterator = listAtts.iterator(); iterator.hasNext();) {
        SourceBean category = (SourceBean) iterator.next();
        List atts = category.getContainedAttributes();

        HashMap series = new HashMap();
        HashMap additionalValues = new HashMap();
        String catValue = "";
        String cat_group_name = "";

        String nameP = "";
        String value = "";

        ArrayList orderSeries = new ArrayList();

        if (first) {
            if (name.indexOf("$F{") >= 0) {
                setTitleParameter(atts);
            }
            if (getSubName() != null && getSubName().indexOf("$F") >= 0) {
                setSubTitleParameter(atts);
            }
            first = false;
        }

        //run all the attributes, to define series!
        int contSer = 0;
        for (Iterator iterator2 = atts.iterator(); iterator2.hasNext();) {
            SourceBeanAttribute object = (SourceBeanAttribute) iterator2.next();

            nameP = new String(object.getKey());
            value = new String((String) object.getValue());
            if (nameP.equalsIgnoreCase("x")) {
                catValue = value;
                categoriesNumber = categoriesNumber + 1;
                categories.put(new Integer(categoriesNumber), value);

            } else if (nameP.equalsIgnoreCase("cat_group")) {
                cat_group_name = value;
            } else {
                nameP = nameP.toUpperCase();
                if (nameP.startsWith("ADD_")) {
                    if (additionalLabels) {
                        String ind = nameP.substring(4);
                        additionalValues.put(ind, value);
                    }
                } else if (this.getNumberSerVisualization() > 0 && contSer < this.getNumberSerVisualization()) {

                    String serieName = nameP;
                    if (seriesLabelsMap != null && seriesLabelsMap.keySet().contains(nameP)) {
                        serieName = seriesLabelsMap.get(nameP).toString();
                    }
                    series.put(serieName, value);
                    orderSeries.add(serieName);
                    contSer++;

                } else if (this.getNumberSerVisualization() == 0) {
                    String serieName = nameP;
                    if (seriesLabelsMap != null && seriesLabelsMap.keySet().contains(nameP)) {
                        serieName = seriesLabelsMap.get(nameP).toString();
                    }
                    series.put(serieName, value);
                    orderSeries.add(serieName);
                }

                // for now I make like if addition value is checked he seek for an attribute with name with value+name_serie
            }
        }

        // if a category group was found add it
        if (!cat_group_name.equalsIgnoreCase("") && !catValue.equalsIgnoreCase("") && catGroups != null) {
            catGroups.put(catValue, cat_group_name);
            if (!(catGroupNames.contains(cat_group_name))) {
                catGroupNames.add(cat_group_name);
            }
        }

        // if it is cumulative automatically get the vamount value
        if (cumulative) {
            dataset.addValue(cumulativeValue, "CUMULATIVE", catValue);
        }

        // if there is an hidden serie put that one first!!! if it is not cumulative
        /*if(serieHidden!=null && !this.cumulative && !serieHidden.equalsIgnoreCase("")){
           String valueS=(String)series.get(serieHidden);
           dataset.addValue(Double.valueOf(valueS).doubleValue(), serieHidden, catValue);
           if(!seriesNames.contains(serieHidden)){
              seriesNames.add(serieHidden);
           }            
        }*/

        for (Iterator iterator3 = orderSeries.iterator(); iterator3.hasNext();) {
            String nameS = (String) iterator3.next();
            if (!hiddenSeries.contains(nameS)) {
                String valueS = ((String) series.get(nameS)).equalsIgnoreCase("null") ? "0"
                        : (String) series.get(nameS);
                Double valueD = null;
                try {
                    valueD = Double.valueOf(valueS);
                } catch (Exception e) {
                    logger.warn("error in double conversion, put default to null");
                    valueD = null;
                }

                // check if serie must be rinominated!
                //               String serieName = nameS;
                //               if(seriesLabelsMap != null && seriesLabelsMap.keySet().contains(nameS)){
                //                  serieName = seriesLabelsMap.get(nameS).toString();
                //               }

                dataset.addValue(valueD != null ? valueD.doubleValue() : null, nameS, catValue);
                cumulativeValue += valueD != null ? valueD.doubleValue() : 0.0;
                if (!seriesNames.contains(nameS)) {
                    seriesNames.add(nameS);
                }
                // if there is an additional label are 
                if (additionalValues.get(nameS) != null) {
                    String val = (String) additionalValues.get(nameS);
                    String index = catValue + "-" + nameS;
                    //String totalVal = valueS;
                    String totalVal = val;
                    //if (percentageValue) totalVal += "%";
                    //totalVal += "\n" + val;
                    catSerLabels.put(index, totalVal);
                }

            }

        }
        // Check additional Values for CUmulative
        if (additionalValues.get("CUMULATIVE") != null) {
            String val = (String) additionalValues.get("CUMULATIVE");
            String index = catValue + "-" + "CUMULATIVE";
            catSerLabels.put(index, val);
        }

    }
    logger.debug("OUT");
    DatasetMap datasets = new DatasetMap();
    datasets.addDataset("1", dataset);
    return datasets;
}

From source file:org.sakaiproject.tool.gradebook.ui.GradebookSetupBean.java

private boolean isMappingValid(LetterGradePercentMapping lgpm) {
    boolean valid = true;
    Double previousPercentage = null;
    for (Iterator iter = letterGradesList.iterator(); iter.hasNext();) {
        String grade = (String) iter.next();
        Double percentage = (Double) lgpm.getValue(grade);
        if (logger.isDebugEnabled())
            logger.debug("checking percentage " + percentage + " for validity");

        // Grades that are percentage-based need to remain percentage-based,
        // be in descending order, and end with 0.
        if (percentage == null) {
            FacesUtil.addUniqueErrorMessage(getLocalizedString("gb_setup_require_all_values"));
            valid = false;/* w  w w  .  jav a  2 s .c  o m*/
        } else if (percentage.doubleValue() < 0) {
            FacesUtil.addUniqueErrorMessage(getLocalizedString("gb_setup_require_positive"));
            valid = false;
        } else if ((previousPercentage != null)
                && (previousPercentage.doubleValue() < percentage.doubleValue())) {
            FacesUtil.addUniqueErrorMessage(getLocalizedString("gb_setup_require_descending_order"));
            valid = false;
        }
        previousPercentage = percentage;
    }
    return valid;
}

From source file:rb.app.RBSystem.java

/**
 * A private helper function to get the SCM from AffineFunctions
 * in the case that SCM_TYPE = NONE//from   w ww  .j av a  2s  . co  m
 */
protected double get_SCM_from_AffineFunction() {
    // we assume that an SCM LB function has been specified
    // in AffineFunctions.jar
    Method meth;

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

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

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

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

    return SCM_val.doubleValue();
}

From source file:org.openmicroscopy.shoola.agents.util.EditorUtil.java

/**
 * Transforms the detector.// w ww .j a va2  s.c  o m
 *
 * @param data The value to convert.
 * @return See above.
 */
public static Map<String, Object> transformDetector(DetectorData data) {

    LinkedHashMap<String, Object> details = new LinkedHashMap<String, Object>();
    details.put(MODEL, "");
    details.put(MANUFACTURER, "");
    details.put(SERIAL_NUMBER, "");
    details.put(LOT_NUMBER, "");
    details.put(TYPE, "");
    details.put(GAIN, new Double(0));
    details.put(VOLTAGE, new Double(0));
    details.put(OFFSET, new Double(0));
    details.put(ZOOM, new Double(0));
    details.put(AMPLIFICATION, "");
    List<String> notSet = new ArrayList<String>();
    if (data == null) {
        notSet.add(MODEL);
        notSet.add(MANUFACTURER);
        notSet.add(SERIAL_NUMBER);
        notSet.add(LOT_NUMBER);
        notSet.add(GAIN);
        notSet.add(VOLTAGE);
        notSet.add(ZOOM);
        notSet.add(AMPLIFICATION);
        notSet.add(TYPE);
        notSet.add(OFFSET);
        details.put(NOT_SET, notSet);
        return details;
    }
    String s = data.getModel();
    if (StringUtils.isBlank(s))
        notSet.add(MODEL);
    details.put(MODEL, s);
    s = data.getManufacturer();
    if (StringUtils.isBlank(s))
        notSet.add(MANUFACTURER);
    details.put(MANUFACTURER, s);
    s = data.getSerialNumber();
    if (StringUtils.isBlank(s))
        notSet.add(SERIAL_NUMBER);
    details.put(SERIAL_NUMBER, s);
    s = data.getLotNumber();
    if (StringUtils.isBlank(s))
        notSet.add(LOT_NUMBER);
    details.put(LOT_NUMBER, s);

    Double f = data.getGain();
    double v = 0;
    if (f == null)
        notSet.add(GAIN);
    else
        v = f.doubleValue();
    details.put(GAIN, v);
    f = data.getVoltage();
    if (f == null) {
        v = 0;
        notSet.add(VOLTAGE);
    } else
        v = f.doubleValue();
    details.put(VOLTAGE, v);
    f = data.getOffset();
    if (f == null) {
        v = 0;
        notSet.add(OFFSET);
    } else
        v = f.doubleValue();
    details.put(OFFSET, v);
    f = data.getZoom();
    if (f == null) {
        v = 0;
        notSet.add(ZOOM);
    } else
        v = f.doubleValue();
    details.put(ZOOM, v);
    f = data.getAmplificationGain();
    if (f == null) {
        v = 0;
        notSet.add(AMPLIFICATION);
    } else
        v = f.doubleValue();
    details.put(AMPLIFICATION, v);
    s = data.getType();
    if (StringUtils.isBlank(s))
        notSet.add(TYPE);
    details.put(TYPE, s);
    details.put(NOT_SET, notSet);
    return details;
}

From source file:edu.hawaii.soest.hioos.isus.ISUSSource.java

/**
 * A method that processes the data object passed and flushes the
 * data to the DataTurbine given the sensor properties in the XMLConfiguration
 * passed in./*from w w w. ja  va  2  s.com*/
 *
 * @param xmlConfig - the XMLConfiguration object containing the list of
 *                    sensor properties
 * @param frameMap  - the parsed data as a HierarchicalMap object
 */
public boolean process(XMLConfiguration xmlConfig, HierarchicalMap frameMap) {

    logger.debug("ISUSSource.process() called.");
    // do not execute the stream if there is no connection
    if (!isConnected())
        return false;

    boolean success = false;

    try {

        // add channels of data that will be pushed to the server.  
        // Each sample will be sent to the Data Turbine as an rbnb frame.  Information
        // on each channel is found in the XMLConfiguration file (email.account.properties.xml)
        // and the StorXParser object (to get the data string)
        ChannelMap rbnbChannelMap = new ChannelMap(); // used to flush channels
        ChannelMap registerChannelMap = new ChannelMap(); // used to register channels
        int channelIndex = 0;

        String sensorName = null;
        String sensorSerialNumber = null;
        String sensorDescription = null;
        boolean isImmersed = false;
        String[] calibrationURLs = null;
        String calibrationURL = null;
        String type = null;

        List sensorList = xmlConfig.configurationsAt("account.logger.sensor");

        for (Iterator sIterator = sensorList.iterator(); sIterator.hasNext();) {
            //  
            HierarchicalConfiguration sensorConfig = (HierarchicalConfiguration) sIterator.next();
            sensorSerialNumber = sensorConfig.getString("serialNumber");

            // find the correct sensor configuration properties
            if (sensorSerialNumber.equals(frameMap.get("serialNumber"))) {

                sensorName = sensorConfig.getString("name");
                sensorDescription = sensorConfig.getString("description");
                isImmersed = new Boolean(sensorConfig.getString("isImmersed")).booleanValue();
                calibrationURLs = sensorConfig.getStringArray("calibrationURL");
                type = (String) frameMap.get("type");

                // find the correct calibrationURL from the list given the type
                for (String url : calibrationURLs) {

                    if (url.indexOf(type) > 0) {
                        calibrationURL = url;
                        break;

                    } else {
                        logger.debug("There was no match for " + type);
                    }
                }

                // get a Calibration instance to interpret raw sensor values
                Calibration calibration = new Calibration();

                if (calibration.parse(calibrationURL)) {

                    // Build the RBNB channel map 

                    // get the sample date and convert it to seconds since the epoch
                    Date frameDate = (Date) frameMap.get("date");
                    Calendar frameDateTime = Calendar.getInstance();
                    frameDateTime.setTime(frameDate);
                    double sampleTimeAsSecondsSinceEpoch = (double) (frameDateTime.getTimeInMillis() / 1000);
                    // and create a string formatted date for the given time zone
                    DATE_FORMAT.setTimeZone(TZ);
                    String frameDateAsString = DATE_FORMAT.format(frameDate).toString();

                    // get the sample data from the frame map
                    ByteBuffer rawFrame = (ByteBuffer) frameMap.get("rawFrame");
                    ISUSFrame isusFrame = (ISUSFrame) frameMap.get("parsedFrameObject");
                    String serialNumber = isusFrame.getSerialNumber();
                    String sampleDate = isusFrame.getSampleDate();
                    String sampleTime = isusFrame.getSampleTime();
                    SimpleDateFormat dtFormat = new SimpleDateFormat();
                    Date sampleDateTime = isusFrame.getSampleDateTime();
                    dtFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
                    dtFormat.applyPattern("MM/dd/yy");
                    String sampleDateUTC = dtFormat.format(sampleDateTime);
                    dtFormat.applyPattern("HH:mm:ss");
                    String sampleTimeUTC = dtFormat.format(sampleDateTime);
                    dtFormat.setTimeZone(TimeZone.getTimeZone("HST"));
                    dtFormat.applyPattern("MM/dd/yy");
                    String sampleDateHST = dtFormat.format(sampleDateTime);
                    dtFormat.applyPattern("HH:mm:ss");
                    String sampleTimeHST = dtFormat.format(sampleDateTime);
                    dtFormat.applyPattern("dd-MMM-yy HH:mm");
                    String sampleDateTimeHST = dtFormat.format(sampleDateTime);

                    double rawNitrogenConcentration = isusFrame.getNitrogenConcentration();
                    double rawAuxConcentration1 = isusFrame.getAuxConcentration1();
                    double rawAuxConcentration2 = isusFrame.getAuxConcentration2();
                    double rawAuxConcentration3 = isusFrame.getAuxConcentration3();
                    double rawRmsError = isusFrame.getRmsError();
                    double rawInsideTemperature = isusFrame.getInsideTemperature();
                    double rawSpectrometerTemperature = isusFrame.getSpectrometerTemperature();
                    double rawLampTemperature = isusFrame.getLampTemperature();
                    int rawLampTime = isusFrame.getLampTime();
                    double rawHumidity = isusFrame.getHumidity();
                    double rawLampVoltage12 = isusFrame.getLampVoltage12();
                    double rawInternalPowerVoltage5 = isusFrame.getInternalPowerVoltage5();
                    double rawMainPowerVoltage = isusFrame.getMainPowerVoltage();
                    double rawReferenceAverage = isusFrame.getReferenceAverage();
                    double rawReferenceVariance = isusFrame.getReferenceVariance();
                    double rawSeaWaterDarkCounts = isusFrame.getSeaWaterDarkCounts();
                    double rawSpectrometerAverage = isusFrame.getSpectrometerAverage();
                    int checksum = isusFrame.getChecksum();

                    //// apply calibrations to the observed data
                    double nitrogenConcentration = calibration.apply(rawNitrogenConcentration, isImmersed,
                            "NITRATE");
                    double auxConcentration1 = calibration.apply(rawAuxConcentration1, isImmersed, "AUX1");
                    double auxConcentration2 = calibration.apply(rawAuxConcentration2, isImmersed, "AUX2");
                    double auxConcentration3 = calibration.apply(rawAuxConcentration3, isImmersed, "AUX3");
                    double rmsError = calibration.apply(rawRmsError, isImmersed, "RMSe");
                    double insideTemperature = calibration.apply(rawInsideTemperature, isImmersed, "T_INT");
                    double spectrometerTemperature = calibration.apply(rawSpectrometerTemperature, isImmersed,
                            "T_SPEC");
                    double lampTemperature = calibration.apply(rawLampTemperature, isImmersed, "T_LAMP");
                    int lampTime = rawLampTime;
                    double humidity = calibration.apply(rawHumidity, isImmersed, "HUMIDITY");
                    double lampVoltage12 = calibration.apply(rawLampVoltage12, isImmersed, "VOLT_12");
                    double internalPowerVoltage5 = calibration.apply(rawInternalPowerVoltage5, isImmersed,
                            "VOLT_5");
                    double mainPowerVoltage = calibration.apply(rawMainPowerVoltage, isImmersed, "VOLT_MAIN");
                    double referenceAverage = calibration.apply(rawReferenceAverage, isImmersed, "REF_AVG");
                    double referenceVariance = calibration.apply(rawReferenceVariance, isImmersed, "REF_STD");
                    double seaWaterDarkCounts = calibration.apply(rawSeaWaterDarkCounts, isImmersed, "SW_DARK");
                    double spectrometerAverage = calibration.apply(rawSpectrometerAverage, isImmersed,
                            "SPEC_AVG");

                    // iterate through the individual wavelengths
                    List<String> variableNames = calibration.getVariableNames();
                    TreeMap<String, Double> wavelengthsMap = new TreeMap<String, Double>();
                    Collections.sort(variableNames);
                    int rawWavelengthCounts = 0;
                    int count = 1;

                    for (String name : variableNames) {

                        // just handle the wavelength channels
                        if (name.startsWith("UV_")) {
                            rawWavelengthCounts = isusFrame.getChannelWavelengthCounts(count);

                            double value = calibration.apply(rawWavelengthCounts, isImmersed, name);
                            count++;
                            wavelengthsMap.put(name, new Double(value));

                        }

                    }

                    String sampleString = "";
                    sampleString += sampleDate + "\t";
                    sampleString += sampleDateUTC + "\t";
                    sampleString += sampleTime + "\t";
                    sampleString += sampleTimeUTC + "\t";
                    sampleString += sampleDateHST + "\t";
                    sampleString += sampleTimeHST + "\t";
                    sampleString += sampleDateTimeHST + "\t";
                    sampleString += String.format("%-15.11f", nitrogenConcentration) + "\t";
                    //sampleString += String.format("%15.11f", auxConcentration1)     + "\t";
                    //sampleString += String.format("%15.11f", auxConcentration2)     + "\t";
                    //sampleString += String.format("%15.11f", auxConcentration3)     + "\t";
                    sampleString += String.format("%15.11f", rmsError) + "\t";
                    sampleString += String.format("%15.11f", insideTemperature) + "\t";
                    sampleString += String.format("%15.11f", spectrometerTemperature) + "\t";
                    sampleString += String.format("%15.11f", lampTemperature) + "\t";
                    sampleString += String.format("%6d", lampTime) + "\t";
                    sampleString += String.format("%15.11f", humidity) + "\t";
                    sampleString += String.format("%15.11f", lampVoltage12) + "\t";
                    sampleString += String.format("%15.11f", internalPowerVoltage5) + "\t";
                    sampleString += String.format("%15.11f", mainPowerVoltage) + "\t";
                    sampleString += String.format("%15.11f", referenceAverage) + "\t";
                    sampleString += String.format("%15.11f", referenceVariance) + "\t";
                    sampleString += String.format("%15.11f", seaWaterDarkCounts) + "\t";
                    sampleString += String.format("%15.11f", spectrometerAverage) + "\t";

                    Set<String> wavelengths = wavelengthsMap.keySet();
                    Iterator wIterator = wavelengths.iterator();

                    while (wIterator.hasNext()) {
                        String name = (String) wIterator.next();
                        Double wavelengthValue = (Double) wavelengthsMap.get(name);
                        sampleString += String.format("%6d", wavelengthValue.intValue()) + "\t";
                        channelIndex = registerChannelMap.Add(name);
                        registerChannelMap.PutUserInfo(channelIndex, "units=counts");
                        channelIndex = rbnbChannelMap.Add(name);
                        rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                        rbnbChannelMap.PutDataAsFloat64(channelIndex,
                                new double[] { wavelengthValue.doubleValue() });

                    }

                    sampleString += String.format("%03d", checksum);
                    sampleString += "\n";

                    // add the sample timestamp to the rbnb channel map
                    //registerChannelMap.PutTime(sampleTimeAsSecondsSinceEpoch, 0d);
                    rbnbChannelMap.PutTime(sampleTimeAsSecondsSinceEpoch, 0d);

                    // add the BinaryRawSatlanticFrameData channel to the channelMap
                    channelIndex = registerChannelMap.Add("BinaryRawSatlanticFrameData");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("BinaryRawSatlanticFrameData");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsByteArray(channelIndex, rawFrame.array());

                    // add the DecimalASCIISampleData channel to the channelMap
                    channelIndex = registerChannelMap.Add(getRBNBChannelName());
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add(getRBNBChannelName());
                    rbnbChannelMap.PutMime(channelIndex, "text/plain");
                    rbnbChannelMap.PutDataAsString(channelIndex, sampleString);

                    // add the serialNumber channel to the channelMap
                    channelIndex = registerChannelMap.Add("serialNumber");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("serialNumber");
                    rbnbChannelMap.PutMime(channelIndex, "text/plain");
                    rbnbChannelMap.PutDataAsString(channelIndex, serialNumber);

                    // add the sampleDateUTC channel to the channelMap
                    channelIndex = registerChannelMap.Add("sampleDateUTC");
                    registerChannelMap.PutUserInfo(channelIndex, "units=YYYYDDD");
                    channelIndex = rbnbChannelMap.Add("sampleDateUTC");
                    rbnbChannelMap.PutMime(channelIndex, "text/plain");
                    rbnbChannelMap.PutDataAsString(channelIndex, sampleDate);

                    // add the sampleTimeUTC channel to the channelMap
                    channelIndex = registerChannelMap.Add("sampleTimeUTC");
                    registerChannelMap.PutUserInfo(channelIndex, "units=hh.hhhhhh");
                    channelIndex = rbnbChannelMap.Add("sampleTimeUTC");
                    rbnbChannelMap.PutMime(channelIndex, "text/plain");
                    rbnbChannelMap.PutDataAsString(channelIndex, sampleTimeUTC);

                    // add the nitrogenConcentration channel to the channelMap
                    channelIndex = registerChannelMap.Add("nitrogenConcentration");
                    registerChannelMap.PutUserInfo(channelIndex, "units=uM");
                    channelIndex = rbnbChannelMap.Add("nitrogenConcentration");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { nitrogenConcentration });

                    // add the auxConcentration1 channel to the channelMap
                    channelIndex = registerChannelMap.Add("auxConcentration1");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("auxConcentration1");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { auxConcentration1 });

                    // add the auxConcentration3 channel to the channelMap
                    channelIndex = registerChannelMap.Add("auxConcentration2");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("auxConcentration2");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { auxConcentration2 });

                    // add the serialNumber channel to the channelMap
                    channelIndex = registerChannelMap.Add("auxConcentration3");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("auxConcentration3");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { auxConcentration3 });

                    // add the rmsError channel to the channelMap
                    channelIndex = registerChannelMap.Add("rmsError");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("rmsError");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { rmsError });

                    // add the insideTemperature channel to the channelMap
                    channelIndex = registerChannelMap.Add("insideTemperature");
                    registerChannelMap.PutUserInfo(channelIndex, "units=Celsius");
                    channelIndex = rbnbChannelMap.Add("insideTemperature");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { insideTemperature });

                    // add the spectrometerTemperature channel to the channelMap
                    channelIndex = registerChannelMap.Add("spectrometerTemperature");
                    registerChannelMap.PutUserInfo(channelIndex, "units=Celsius");
                    channelIndex = rbnbChannelMap.Add("spectrometerTemperature");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { spectrometerTemperature });

                    // add the lampTemperature channel to the channelMap
                    channelIndex = registerChannelMap.Add("lampTemperature");
                    registerChannelMap.PutUserInfo(channelIndex, "units=Celsius");
                    channelIndex = rbnbChannelMap.Add("lampTemperature");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { lampTemperature });

                    // add the lampTime channel to the channelMap
                    channelIndex = registerChannelMap.Add("lampTime");
                    registerChannelMap.PutUserInfo(channelIndex, "units=seconds");
                    channelIndex = rbnbChannelMap.Add("lampTime");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsInt32(channelIndex, new int[] { lampTime });

                    // add the humidity channel to the channelMap
                    channelIndex = registerChannelMap.Add("humidity");
                    registerChannelMap.PutUserInfo(channelIndex, "units=%");
                    channelIndex = rbnbChannelMap.Add("humidity");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { humidity });

                    // add the lampVoltage12 channel to the channelMap
                    channelIndex = registerChannelMap.Add("lampVoltage12");
                    registerChannelMap.PutUserInfo(channelIndex, "units=V");
                    channelIndex = rbnbChannelMap.Add("lampVoltage12");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { lampVoltage12 });

                    // add the internalPowerVoltage5 channel to the channelMap
                    channelIndex = registerChannelMap.Add("internalPowerVoltage5");
                    registerChannelMap.PutUserInfo(channelIndex, "units=V");
                    channelIndex = rbnbChannelMap.Add("internalPowerVoltage5");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { internalPowerVoltage5 });

                    // add the mainPowerVoltage channel to the channelMap
                    channelIndex = registerChannelMap.Add("mainPowerVoltage");
                    registerChannelMap.PutUserInfo(channelIndex, "units=V");
                    channelIndex = rbnbChannelMap.Add("mainPowerVoltage");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { mainPowerVoltage });

                    // add the referenceAverage channel to the channelMap
                    channelIndex = registerChannelMap.Add("referenceAverage");
                    registerChannelMap.PutUserInfo(channelIndex, "units=count");
                    channelIndex = rbnbChannelMap.Add("referenceAverage");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { referenceAverage });

                    // add the referenceVariance channel to the channelMap
                    channelIndex = registerChannelMap.Add("referenceVariance");
                    registerChannelMap.PutUserInfo(channelIndex, "units=count");
                    channelIndex = rbnbChannelMap.Add("referenceVariance");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { referenceVariance });

                    // add the seaWaterDarkCounts channel to the channelMap
                    channelIndex = registerChannelMap.Add("seaWaterDarkCounts");
                    registerChannelMap.PutUserInfo(channelIndex, "units=count");
                    channelIndex = rbnbChannelMap.Add("seaWaterDarkCounts");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { seaWaterDarkCounts });

                    // add the spectrometerAverage channel to the channelMap
                    channelIndex = registerChannelMap.Add("spectrometerAverage");
                    registerChannelMap.PutUserInfo(channelIndex, "units=count");
                    channelIndex = rbnbChannelMap.Add("averageWavelength");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { spectrometerAverage });

                    // Now register the RBNB channels, and flush the rbnbChannelMap to the
                    // DataTurbine
                    getSource().Register(registerChannelMap);
                    getSource().Flush(rbnbChannelMap);
                    logger.info(frameDateAsString + " " + "Sample sent to the DataTurbine: (" + serialNumber
                            + ") " + sampleString);

                    registerChannelMap.Clear();
                    rbnbChannelMap.Clear();

                } else {

                    logger.info("Couldn't apply the calibration coefficients. " + "Skipping this sample.");

                } // end if()

            } // end if()

        } // end for()                                             

        //getSource.Detach();

        success = true;
    } catch (ParseException pe) {
        // parsing of the calibration file failed.  Log the exception, return false
        success = false;
        logger.debug("There was a problem parsing the calibration file. The " + "error message was: "
                + pe.getMessage());
        return success;

    } catch (SAPIException sapie) {
        // In the event of an RBNB communication  exception, log the exception, 
        // and allow execute() to return false, which will prompt a retry.
        success = false;
        sapie.printStackTrace();
        return success;

    }

    return success;
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.PreviewPane.java

private void updateZoomModel(final double zoom) {
    for (int i = 0; i < zoomModel.getSize(); i++) {
        final Object o = zoomModel.getKeyAt(i);
        if (o instanceof Double) {
            Double d = (Double) o;
            if (d.doubleValue() == zoom) {
                zoomModel.setSelectedKey(d);
                return;
            }/*from w w w  . ja  v  a 2  s.co m*/
        }
    }
    zoomModel.setSelectedItem(formatZoomText(zoom));
}

From source file:com.ignou.aadhar.controllers.TransactionController.java

@RequestMapping(value = "/authenticate", method = RequestMethod.GET)
public String getTransactionForm(@RequestParam(value = "clientTxnId") String clientTxnId,
        @RequestParam(value = "clientUsername") String clientUsername,
        @RequestParam(value = "clientPassword") String clientPassword, @RequestParam(value = "uid") String uid,
        @RequestParam(value = "amount") Double amount, Model model) {

    /* Check if Client Transaction ID is provided or not */
    if (clientTxnId == null || clientTxnId.isEmpty()) {
        model.addAttribute("msg", "No Transaction ID provided");
        return "common/error";
    }/*from w w  w. j a  v a2s .  c  om*/

    /* Check if the Client Username is provided or not */
    if (clientUsername == null || clientUsername.isEmpty()) {
        model.addAttribute("msg", "Service Provider username is mandatory." + " Not provided");
        return "common/error";
    }

    /* Check if the Client password is provided or not */
    if (clientPassword == null || clientPassword.isEmpty()) {
        model.addAttribute("msg", "Service Provider password is mandatory." + " Not provided");
        return "common/error";
    }

    /* Check if the UID is provided or not */
    if (uid == null || uid.isEmpty() || uid.trim().length() != 15 || (!UIDGenerator.validateUID(uid))) {
        model.addAttribute("msg", "Invalid or empty UID provided");
        return "common/error";
    }

    /* Check if the amount value provided is corrent or not */
    if (amount == null || amount.doubleValue() == 0.0) {
        model.addAttribute("msg", "Invalid transaction amount");
        return "common/error";
    }

    /* Basic validation done. We will now fetch the Service Provider
     * details from the database.
     */
    ServiceProvider client = serviceProviderService.getByNameAndPassword(clientUsername, clientPassword);

    /* Check if any Service Provider was returned or not */
    if (client == null) {
        model.addAttribute("msg", "Service Provider authentication failed");
        return "common/error";
    }

    //TODO: Validating that the originating URL and that saved in the
    //System.out.println("--> Request Originitated From : " + request.getHeader("Referer"));

    /* Lets now fetch the UID for which transaction need to be performed */
    Citizen citizen = citizenService.getByUID(uid);

    if (citizen == null) {
        model.addAttribute("msg", "UID provided does not exist.");
        return "common/error";
    }

    /* Authentication Done for Service Provider. Create the Transaction
     * object.
     */
    Transaction transaction = new Transaction();
    transaction.setCitizen(citizen);
    transaction.setServiceProvider(client);
    transaction.setAmount(amount);
    transaction.setSpTransactionId(clientTxnId);
    transaction.setCreated(new Date());
    transaction.setStatus(TransactionStatus.PENDING.getCode());

    /* Lets now save the Transaction in the database */
    Transaction dbTransaction = transactionService.add(transaction);

    /* Lets now create a TransactionToken and email the token on the
     * citizen's email id.
     */
    TransactionToken token = new TransactionToken();
    token.setCitizen(dbTransaction.getCitizen());
    token.setTransaction(dbTransaction);
    token.setToken(TokenGenerator.getToken());

    TransactionToken dbToken = transactionTokenService.add(token);

    /* Lets now send this token on the email */
    mailSender.send("justdpk@gmail.com", "Authentication Token",
            "You authentication token is : " + dbToken.getToken());

    /* Redirect the request to UID authentication page where the Citizen
     * will provide his/her credentials to completely validate this
     * transaction request from the Service Provider.
     */
    model.addAttribute("transaction", dbTransaction);

    return "transaction/uid_auth";
}

From source file:net.cbtltd.server.ReservationService.java

/**
 * Gets the deposit percentage required by a property manager (organization) on the specified date.
 * /*w w w.  j  ava 2s .  c om*/
 * @param reservation the reservation for which the deposit percentage is to be calculated.
 * @param propertyManagerInfo property manager that is responsible for the reservation.
 * @return the deposit percentage.
 */
public static final Double getDeposit(Reservation reservation, PropertyManagerInfo propertyManagerInfo) {
    if (propertyManagerInfo.getNumberOfPayments() == null) {
        throw new ServiceException(Error.database_cannot_find, "numberOfPayments in property manager info");
    }
    // 1. Check number_of_payments, return 100 if 1 payment should be processed
    if (propertyManagerInfo.getNumberOfPayments() == 1) {
        return 100.;
    }

    // 2. Return 100 if current date is between payment remainder date and arrival date 
    Integer secondPaymentRemainder = propertyManagerInfo.getRemainderPaymentDate();
    if (Time.getDuration(new Date(), reservation.getFromdate(), Time.DAY) <= secondPaymentRemainder) {
        return 100.;
    }

    // 3. Calculate deposit percentage regarding the payment rules
    Integer paymentType = propertyManagerInfo.getPaymentType();
    switch (paymentType) {
    case 1:
        return propertyManagerInfo.getPaymentAmount().doubleValue();
    case 2:
        Double percentage = propertyManagerInfo.getPaymentAmount() / reservation.getQuote() * 100.;
        return percentage.doubleValue();
    default:
        throw new ServiceException(Error.payment_type_unsupported);
    }
}

From source file:org.sakaiproject.component.gradebook.GradebookExternalAssessmentServiceImpl.java

public void updateExternalAssessment(final String gradebookUid, final String externalId,
        final String externalUrl, final String title, final Double points, final Date dueDate,
        final Boolean ungraded) throws GradebookNotFoundException, AssessmentNotFoundException,
        ConflictingAssignmentNameException, AssignmentHasIllegalPointsException {
    final Assignment asn = getExternalAssignment(gradebookUid, externalId);

    if (asn == null) {
        throw new AssessmentNotFoundException(
                "There is no assessment id=" + externalId + " in gradebook uid=" + gradebookUid);
    }//  w  w  w  . ja  va 2 s.c  o  m

    // Ensure that points is > zero
    if ((ungraded != null && !ungraded.booleanValue() && (points == null || points.doubleValue() <= 0))
            || (ungraded == null && (points == null || points.doubleValue() <= 0))) {
        throw new AssignmentHasIllegalPointsException("Points can't be null or Points must be > 0");
    }

    // Ensure that the required strings are not empty
    if (StringUtils.trimToNull(externalId) == null || StringUtils.trimToNull(title) == null) {
        throw new RuntimeException("ExternalId, and title must not be empty");
    }

    HibernateCallback hc = new HibernateCallback() {
        public Object doInHibernate(Session session) throws HibernateException {
            asn.setExternalInstructorLink(externalUrl);
            asn.setExternalStudentLink(externalUrl);
            asn.setName(title);
            asn.setDueDate(dueDate);
            //support selective release
            asn.setReleased(true);
            asn.setPointsPossible(points);
            if (ungraded != null)
                asn.setUngraded(ungraded.booleanValue());
            else
                asn.setUngraded(false);
            session.update(asn);
            if (log.isInfoEnabled())
                log.info("External assessment updated in gradebookUid=" + gradebookUid + ", externalId="
                        + externalId + " by userUid=" + getUserUid());
            return null;

        }
    };
    getHibernateTemplate().execute(hc);
}