Example usage for java.lang Boolean Boolean

List of usage examples for java.lang Boolean Boolean

Introduction

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

Prototype

@Deprecated(since = "9")
public Boolean(String s) 

Source Link

Document

Allocates a Boolean object representing the value true if the string argument is not null and is equal, ignoring case, to the string "true" .

Usage

From source file:org.openmrs.module.spreadsheetimport.web.controller.SpreadsheetImportFormController.java

@RequestMapping(value = { "/module/spreadsheetimport/spreadsheetimport.form" }, method = RequestMethod.POST)
public String processSubmit(@ModelAttribute("template") SpreadsheetImportTemplate template,
        BindingResult result, HttpServletRequest request) throws Exception {

    log.debug("process import, step = " + request.getParameter("step"));

    Map<String, List<String>> tableColumnListMap = DatabaseBackend.getTableColumnListMap();

    // creating import template from Form. Import data will be treated as 1 encounter
    if (request.getParameter("createFromForm") != null) {
        template.getColumns().clear();//from w ww  .  j  a  v a2 s. c  o m
        String formId = request.getParameter("targetForm");
        Form selectedForm = Context.getService(FormService.class).getForm(Integer.parseInt(formId));

        for (FormField field : selectedForm.getFormFields()) {
            FieldType fieldType = field.getField().getFieldType();

            // ignore the field of type set
            if (fieldType.getIsSet().booleanValue())
                continue;

            // ignore encounter mapping
            if ("encounter".equals(field.getField().getTableName()))
                continue;

            boolean willAdd = true;
            SpreadsheetImportTemplateColumn column = new SpreadsheetImportTemplateColumn();
            column.setName(field.getField().getName());
            column.setTemplate(template);

            Concept concept = field.getField().getConcept();
            SpreadsheetImportTemplateColumn dateColumn = null;
            if (concept == null) {
                String tableName = field.getField().getTableName();
                String columnName = field.getField().getAttributeName();
                // if we can't find a table name, likely it's person
                if (tableName.startsWith("patient")) {
                    if (!tableColumnListMap.containsKey(tableName))
                        tableName = tableName.replace("patient", "person");
                    else {
                        List<String> columns = tableColumnListMap.get(tableName);
                        if (!columns.contains(columnName))
                            tableName = tableName.replace("patient", "person");
                    }
                }

                // final check: if there is really no such table and column
                if ((!tableColumnListMap.containsKey(tableName))
                        || (!tableColumnListMap.get(tableName).contains(columnName)))
                    willAdd = false;

                column.setTableDotColumn(tableName + "." + field.getField().getAttributeName());
            } else {
                // getting data type of the concept
                ConceptDatatype conceptDataType = concept.getDatatype();
                String hl7Abbrev = conceptDataType.getHl7Abbreviation();
                if ("NM".equals(hl7Abbrev))
                    column.setTableDotColumn("obs.value_numeric");
                else if ("CWE".equals(hl7Abbrev))
                    column.setTableDotColumn("obs.value_coded");
                else if ("BIT".equals(hl7Abbrev))
                    column.setTableDotColumn("obs.value_boolean");
                else if ("DT".equals(hl7Abbrev) || "TM".equals(hl7Abbrev) || "TS".equals(hl7Abbrev))
                    column.setTableDotColumn("obs.value_datetime");
                else if ("ST".equals(hl7Abbrev))
                    column.setTableDotColumn("obs.value_text");
                else
                    willAdd = false; // don't know type

                if (willAdd) {
                    dateColumn = new SpreadsheetImportTemplateColumn();
                    dateColumn.setTableDotColumn("obs.obs_datetime");
                    dateColumn.setName(field.getField().getName() + " datetime");
                    dateColumn.setTemplate(template);
                }

            }
            if (willAdd) {
                template.getColumns().add(column);
                if (dateColumn != null)
                    template.getColumns().add(dateColumn);
                log.debug("Adding column " + column.getData());
            }
        }

        SpreadsheetImportTemplateColumn encounterId = new SpreadsheetImportTemplateColumn();
        encounterId.setName("Encounter ID");
        encounterId.setTableDotColumn("encounter.encounter_id");
        encounterId.setTemplate(template);
        encounterId.setDisallowDuplicateValue(new Boolean(false));
        template.getColumns().add(encounterId);

        return "/module/spreadsheetimport/spreadsheetimportFormColumn";
    }

    Map<UniqueImport, Set<SpreadsheetImportTemplateColumn>> rowDataTemp = template
            .getMapOfUniqueImportToColumnSetSortedByImportIdx();

    for (UniqueImport uniqueImport : rowDataTemp.keySet()) {
        Set<SpreadsheetImportTemplateColumn> columnSet = rowDataTemp.get(uniqueImport);
        boolean isFirst = true;
        for (SpreadsheetImportTemplateColumn column : columnSet) {

            if (isFirst) {
                isFirst = false;
                // Should be same for all columns in unique import
                //               System.out.println("SpreadsheetImportUtil.importTemplate: column.getColumnPrespecifiedValues(): " + column.getColumnPrespecifiedValues().size());
                if (column.getColumnPrespecifiedValues().size() > 0) {
                    Set<SpreadsheetImportTemplateColumnPrespecifiedValue> columnPrespecifiedValueSet = column
                            .getColumnPrespecifiedValues();
                    for (SpreadsheetImportTemplateColumnPrespecifiedValue columnPrespecifiedValue : columnPrespecifiedValueSet) {
                        //                     System.out.println(columnPrespecifiedValue.getPrespecifiedValue().getTableDotColumn() + " :: " + columnPrespecifiedValue.getPrespecifiedValue().getId() + " :: " + columnPrespecifiedValue.getColumnName() + " ==> " + columnPrespecifiedValue.getPrespecifiedValue().getValue());
                    }
                }
            }
        }
    }

    template.setTest("abc");
    template.setRowDataTemp(rowDataTemp);

    if (request.getParameter("step").equals("columns")) {

        // Delete columns, must use iterator to update module iterator
        if (request.getParameter("Delete Columns") != null) {
            int i = 0;
            Iterator<SpreadsheetImportTemplateColumn> iterator = template.getColumns().iterator();
            while (iterator.hasNext()) {
                iterator.next();
                if (request.getParameter(Integer.toString(i)) != null) {
                    iterator.remove();
                }
                i++;
            }
            return "/module/spreadsheetimport/spreadsheetimportFormColumn";
        }

        // Add column
        if (request.getParameter("Add Column") != null) {
            SpreadsheetImportTemplateColumn column = new SpreadsheetImportTemplateColumn();
            column.setTemplate(template);
            template.getColumns().add(column);
            return "/module/spreadsheetimport/spreadsheetimportFormColumn";
        }

    }

    if (request.getParameter("step").equals("prespecifiedValues")
            && request.getParameter("Previous Step") != null) {

        //         template.clearPrespecifiedValues();
        //         template.clearColumnColumns();

        //         try {
        //            SpreadsheetImportUtil.resolveTemplateDependencies(template);
        //         } catch (Exception e) {
        //            e.printStackTrace();
        //         }

        return "/module/spreadsheetimport/spreadsheetimportFormColumn";

    }

    new SpreadsheetImportTemplateValidator().validate(template, result);

    if (result.hasErrors()) {
        if (request.getParameter("step").equals("columns")) {
            return "/module/spreadsheetimport/spreadsheetimportFormColumn";
        } else {
            return "/module/spreadsheetimport/spreadsheetimportFormPrespecifiedValue";
        }
    }

    if (request.getParameter("step").equals("columns")) {

        template.clearPrespecifiedValues();
        template.clearColumnColumns();
        SpreadsheetImportUtil.resolveTemplateDependencies(template);
        if (template.getPrespecifiedValues().size() != 0) {
            return "/module/spreadsheetimport/spreadsheetimportFormPrespecifiedValue";
        }

    }

    Context.getService(SpreadsheetImportService.class).saveSpreadsheetImportTemplate(template);
    return "redirect:/module/spreadsheetimport/spreadsheetimport.list";

}

From source file:com.germinus.easyconf.ComponentProperties.java

public boolean getBoolean(String key, Filter filter, boolean defaultValue) {
    return getBoolean(key, filter, new Boolean(defaultValue)).booleanValue();
}

From source file:com.duroty.application.files.manager.StoreManager.java

/**
 * DOCUMENT ME!/*from   w w  w .  j a v  a 2 s . co m*/
 *
 * @param hsession DOCUMENT ME!
 * @param user DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 *
 * @throws FilesException DOCUMENT ME!
 */
protected Identity getDefaultIdentity(org.hibernate.Session hsession, Users user) throws FilesException {
    try {
        Criteria crit = hsession.createCriteria(Identity.class);
        crit.add(Restrictions.eq("users", user));
        crit.add(Restrictions.eq("ideActive", new Boolean(true)));
        crit.add(Restrictions.eq("ideDefault", new Boolean(true)));

        Identity identity = (Identity) crit.uniqueResult();

        return identity;
    } catch (Exception ex) {
        return null;
    } finally {
    }
}

From source file:it.eng.spagobi.tools.catalogue.service.SaveArtifactAction.java

private Content getContentFromRequest() {
    Content content = null;/*w  w w  . j a  v a 2s .c o  m*/
    FileItem uploaded = (FileItem) getAttribute("UPLOADED_FILE");
    if (uploaded != null && uploaded.getSize() > 0) {
        checkUploadedFile(uploaded);
        String fileName = GeneralUtilities.getRelativeFileNames(uploaded.getName());
        content = new Content();
        content.setActive(new Boolean(true));
        UserProfile userProfile = (UserProfile) this.getUserProfile();
        content.setCreationUser(userProfile.getUserId().toString());
        content.setCreationDate(new Date());
        content.setDimension(Long.toString(uploaded.getSize() / 1000) + " KByte");
        content.setFileName(fileName);
        byte[] uplCont = uploaded.get();
        content.setContent(uplCont);
    } else {
        logger.debug("Uploaded file missing or it is empty");
    }
    return content;
}

From source file:com._17od.upm.gui.MainWindow.java

public MainWindow(String title) throws ClassNotFoundException, InstantiationException, IllegalAccessException,
        UnsupportedLookAndFeelException, IllegalBlockSizeException, IOException, GeneralSecurityException,
        ProblemReadingDatabaseFile {/*from  w  ww .j a va2 s. c  om*/
    super(title);

    setIconImage(Util.loadImage("upm.gif").getImage());

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    PlatformSpecificCode.getInstance().initialiseApplication(this);

    dbActions = new DatabaseActions(this);

    // Set up the content pane.
    addComponentsToPane();

    // Add listener to store current position and size on closing
    this.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            storeWindowBounds();
            try {
                Preferences.save();
            } catch (IOException ex) {
                // Not much we can do at this point
                ex.printStackTrace();
            }
        }

    });

    // Display the window.
    pack();
    setLocationRelativeTo(null);
    boolean restore = Preferences.get(Preferences.ApplicationOptions.REMEMBER_WINDOW_POSITION, "false")
            .equals("true");
    if (restore) {
        restoreWindowBounds();
    }
    Boolean appAlwaysonTop = new Boolean(
            Preferences.get(Preferences.ApplicationOptions.MAINWINDOW_ALWAYS_ON_TOP, "false"));
    setAlwaysOnTop(appAlwaysonTop.booleanValue());
    setVisible(true);

    try {
        // Load the startup database if it's configured
        String db = Preferences.get(Preferences.ApplicationOptions.DB_TO_LOAD_ON_STARTUP);
        if (db != null && !db.equals("")) {
            File dbFile = new File(db);
            if (!dbFile.exists()) {
                dbActions.errorHandler(new Exception(Translator.translate("dbDoesNotExist", db)));
            } else {
                dbActions.openDatabase(db);
            }
        }
    } catch (Exception e) {
        dbActions.errorHandler(e);
    }

    // Give the search field focus
    // I'm using requestFocusInWindow() rathar than requestFocus()
    // because the javadocs recommend it
    searchField.requestFocusInWindow();

}

From source file:com.autentia.tnt.util.ReportUtil.java

public static void createReportParameterDefinition(List<ParameterReport> parameters,
        ArrayList<ReportParameterDefinition> reportParametersDefinitions,
        Map<String, List<SelectItem>> dataPanel) {
    String name;/* w  w w  .  j  a  v  a2s .c  om*/
    String desc;
    String def;
    ReportParameterDefinition pdef;
    boolean showRol = false;

    if (parameters != null) {
        for (ParameterReport parameter : parameters) {
            name = parameter.getName();
            desc = parameter.getDescription();
            def = parameter.getDefaultValue();

            if (desc != null) {
                desc = desc.toUpperCase();

                if (desc.equals("DATE")) {
                    pdef = new ReportParameterDefinition(name, "date", name, new Date());
                } else if (desc.equals("YEAR")) {
                    pdef = new ReportParameterDefinition(name, "year", name, dataPanel.get("years"));
                } else if (desc.equals("USER")) {
                    pdef = new ReportParameterDefinition(name, "selectOne", name, dataPanel.get("users"));
                } else if (desc.equals("ROL")) {
                    showRol = true;
                    pdef = new ReportParameterDefinition(name, "selectOne", name, dataPanel.get("roles"));
                } else if (desc.equals("ORGANIZATION")) {
                    pdef = new ReportParameterDefinition(name, "selectMany", name, dataPanel.get("orgs"));
                } else if (desc.equals("PROJECTS")) {
                    pdef = new ReportParameterDefinition(name, "selectOne", name, dataPanel.get("projects"));
                } else if (desc.equals("PROJECT")) {
                    pdef = new ReportParameterDefinition(name, "selectOne-selectMany", name,
                            dataPanel.get("orgs"), dataPanel.get("projects"));
                } else if (desc.equals("PROJECT_OUR_COMPANY")) {
                    pdef = new ReportParameterDefinition(name, "selectOne", name, dataPanel.get("projects"));
                } else if (desc.equals("SUBREPORT")) {
                    pdef = new ReportParameterDefinition(name, "hidden", name, def.replace('"', ' ').trim());
                } else if (desc.equals("DESCRIPTION")) {
                    pdef = new ReportParameterDefinition(name, "info", name, def.replace('"', ' '));
                } else if (desc.equals("TIMESTAMP")) {
                    pdef = new ReportParameterDefinition(name, "timestamp", name, new Date());
                } else if (desc.equals("ACCOUNT")) {
                    pdef = new ReportParameterDefinition(name, "selectOne", name, dataPanel.get("accounts"));
                } else if (desc.equals("BILLABLE")) {
                    pdef = new ReportParameterDefinition(name, "checkbox", name, new Boolean(false));
                } else {
                    continue;
                }
                reportParametersDefinitions.add(pdef);
            }
        }
    }

    if (showRol) {
        for (ReportParameterDefinition rp : reportParametersDefinitions) {
            if (rp.getId().equalsIgnoreCase("Proyecto")) {
                rp.setIsRol(true);
            }
        }
    }
}

From source file:com.germinus.easyconf.taglib.PropertyTag.java

private Object readProperty(ComponentProperties conf) throws JspException {
    Object value;//from  w  w  w. ja  v  a2  s  .co m
    if (getType().equals("java.util.List")) {
        value = conf.getList(property, getPropertyFilter(), EMPTY_LIST);
    } else if (getType().equals("java.lang.Integer")) {
        value = conf.getInteger(property, getPropertyFilter(), new Integer(0));
    } else if (getType().equals("java.lang.String[]")) {
        value = conf.getStringArray(property, getPropertyFilter(), new String[0]);
    } else if (getType().equals("java.lang.String")) {
        if (defaultValue != null) {
            value = conf.getString(property, getPropertyFilter(), defaultValue);
        } else {
            value = conf.getString(property, getPropertyFilter());
        }
    } else if (getType().equals("java.lang.Double")) {
        value = new Double(conf.getDouble(property, getPropertyFilter()));
    } else if (getType().equals("java.lang.Float")) {
        value = new Float(conf.getFloat(property, getPropertyFilter()));
    } else if (getType().equals("java.lang.Byte")) {
        value = new Byte(conf.getByte(property, getPropertyFilter()));
    } else if (getType().equals("java.math.BigDecimal")) {
        value = conf.getBigDecimal(property, getPropertyFilter());
    } else if (getType().equals("java.lang.BigInteger")) {
        value = conf.getBigInteger(property, getPropertyFilter());
    } else if (getType().equals("java.lang.Boolean")) {
        value = new Boolean(conf.getBoolean(property, getPropertyFilter()));
    } else if (getType().equals("java.lang.Short")) {
        value = new Short(conf.getShort(property, getPropertyFilter()));
    } else if (getType().equals("java.lang.Long")) {
        value = new Long(conf.getLong(property, getPropertyFilter()));
    } else {
        JspException e = new JspException("Unsupported type: " + type);
        RequestUtils.saveException(pageContext, e);
        throw e;
    }
    return value;
}

From source file:org.openmrs.module.rwandaprimarycare.EnterSimpleEncounterController.java

@RequestMapping(method = RequestMethod.POST)
public String processSubmit(@RequestParam("patientId") Integer patientId,
        @RequestParam("encounterType") Integer encounterTypeId, @RequestParam("form") String form,
        @RequestParam(required = false, value = "visitDate") Long visitDate, WebRequest request,
        HttpSession session) throws PrimaryCareException {
    //LK: Need to ensure that all primary care methods only throw a PrimaryCareException
    //So that errors will be directed to a touch screen error page
    try {// w  ww .j av  a2 s  . c  o m

        Patient patient = getPatient(patientId);
        Location workstationLocation = PrimaryCareBusinessLogic.getLocationLoggedIn(session);
        EncounterType encounterType = Context.getEncounterService().getEncounterType(encounterTypeId);
        if (encounterType == null)
            throw new RuntimeException("encounterType is required");
        List<Obs> obsToCreate = new ArrayList<Obs>();
        int i = 0;
        while (true) {
            String conceptId = request.getParameter("obs_concept_" + i);
            String value = request.getParameter("obs_value_" + i);
            ++i;
            if (conceptId == null)
                break;
            if (!StringUtils.hasText(value))
                continue;
            Obs obs = new Obs();
            obs.setPerson(patient);
            obs.setConcept(Context.getConceptService().getConcept(Integer.valueOf(conceptId)));
            obs.setLocation(workstationLocation);
            try {
                obs.setValueAsString(value);
            } catch (ParseException ex) {
                throw new IllegalArgumentException("Cannot set "
                        + obs.getConcept().getName(Context.getLocale()).getName() + " to " + value);
            }
            obsToCreate.add(obs);
        }

        //LK: if we are entering vitals we are going to check to see if we should 
        //be automatically calculating the BMI, based on a global property  
        Boolean calculateBMI = new Boolean(
                Context.getAdministrationService().getGlobalProperty("registration.calculateBMI"));
        if (calculateBMI) {
            //LK: we are only going to calcuate BMI for people over 20 as kiddies have different rules
            patient = getPatient(patient.getPatientId());
            if (patient.getAge() > 20) {
                String bmi = PrimaryCareUtil.calculateBMI(patient, obsToCreate);
                if (bmi != null) {
                    Obs obs = new Obs();
                    obs.setPerson(patient);
                    obs.setConcept(Context.getConceptService()
                            .getConcept(PrimaryCareBusinessLogic.getBMIConcept().getConceptId()));
                    obs.setLocation(workstationLocation);
                    obs.setValueAsString(bmi);
                    obsToCreate.add(obs);
                }
            }
        }

        if (visitDate != null) {
            PrimaryCareBusinessLogic.createEncounter(patient, encounterType, workstationLocation,
                    new Date(visitDate), Context.getAuthenticatedUser(), obsToCreate);
            return "redirect:/module/rwandaprimarycare/patient.form?patientId=" + patientId + "&visitDate="
                    + visitDate;
        } else {
            PrimaryCareBusinessLogic.createEncounter(patient, encounterType, workstationLocation, new Date(),
                    Context.getAuthenticatedUser(), obsToCreate);
            return "redirect:/module/rwandaprimarycare/patient.form?patientId=" + patientId;
        }

    } catch (Exception e) {
        throw new PrimaryCareException(e);
    }
}

From source file:edu.hawaii.soest.hioos.storx.StorXSource.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  ww . j  a  v a 2 s  .  c o m
 *
 * @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("StorXSource.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;

        // this.storXParser = new StorXParser(storXFrame);

        String sensorName = null;
        String sensorSerialNumber = null;
        String sensorDescription = null;
        boolean isImmersed = false;
        String calibrationURL = 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();
                calibrationURL = sensorConfig.getString("calibrationURL");

                // 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 sampleDate = (Date) frameMap.get("date");
                    Calendar sampleDateTime = Calendar.getInstance();
                    sampleDateTime.setTime(sampleDate);
                    double sampleTimeAsSecondsSinceEpoch = (double) (sampleDateTime.getTimeInMillis() / 1000);
                    // and create a string formatted date
                    DATE_FORMAT.setTimeZone(TZ);
                    String sampleDateAsString = DATE_FORMAT.format(sampleDate).toString();

                    // get the sample data from the frame map
                    ByteBuffer rawFrame = (ByteBuffer) frameMap.get("rawFrame");
                    StorXFrame storXFrame = (StorXFrame) frameMap.get("parsedFrameObject");
                    String serialNumber = storXFrame.getSerialNumber();
                    int rawAnalogChannelOne = storXFrame.getAnalogChannelOne();
                    int rawAnalogChannelTwo = storXFrame.getAnalogChannelTwo();
                    int rawAnalogChannelThree = storXFrame.getAnalogChannelThree();
                    int rawAnalogChannelFour = storXFrame.getAnalogChannelFour();
                    int rawAnalogChannelFive = storXFrame.getAnalogChannelFive();
                    int rawAnalogChannelSix = storXFrame.getAnalogChannelSix();
                    int rawAnalogChannelSeven = storXFrame.getAnalogChannelSeven();
                    double rawInternalVoltage = new Float(storXFrame.getInternalVoltage()).doubleValue();

                    // apply calibrations to the observed data
                    double analogChannelOne = calibration.apply((double) rawAnalogChannelOne, isImmersed,
                            "AUX_1");
                    double analogChannelTwo = calibration.apply((double) rawAnalogChannelTwo, isImmersed,
                            "AUX_2");
                    double analogChannelThree = calibration.apply((double) rawAnalogChannelThree, isImmersed,
                            "AUX_3");
                    double analogChannelFour = calibration.apply((double) rawAnalogChannelFour, isImmersed,
                            "AUX_4");
                    double analogChannelFive = calibration.apply((double) rawAnalogChannelFive, isImmersed,
                            "AUX_5");
                    double analogChannelSix = calibration.apply((double) rawAnalogChannelSix, isImmersed,
                            "AUX_6");
                    double analogChannelSeven = calibration.apply((double) rawAnalogChannelSeven, isImmersed,
                            "AUX_7");
                    double internalVoltage = calibration.apply(rawInternalVoltage, isImmersed, "SV");

                    String sampleString = "";
                    sampleString += String.format("%s", serialNumber) + ", ";
                    sampleString += String.format("%5d", rawAnalogChannelOne) + ", ";
                    sampleString += String.format("%5d", rawAnalogChannelTwo) + ", ";
                    sampleString += String.format("%5d", rawAnalogChannelThree) + ", ";
                    sampleString += String.format("%5d", rawAnalogChannelFour) + ", ";
                    sampleString += String.format("%5d", rawAnalogChannelFive) + ", ";
                    sampleString += String.format("%5d", rawAnalogChannelSix) + ", ";
                    sampleString += String.format("%5d", rawAnalogChannelSeven) + ", ";
                    sampleString += String.format("%05.2f", internalVoltage) + ", ";
                    sampleString += sampleDateAsString;
                    sampleString += storXFrame.getTerminator();

                    // 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 analogChannelOne channel to the channelMap
                    channelIndex = registerChannelMap.Add("analogChannelOne");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("analogChannelOne");
                    rbnbChannelMap.PutMime(channelIndex, "application/octet-stream");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { analogChannelOne });

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

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

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

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

                    // add the analogChannelSix channel to the channelMap
                    channelIndex = registerChannelMap.Add("analogChannelSix");
                    registerChannelMap.PutUserInfo(channelIndex, "units=none");
                    channelIndex = rbnbChannelMap.Add("analogChannelSix");
                    rbnbChannelMap.PutMime(channelIndex, "text/plain");
                    rbnbChannelMap.PutDataAsFloat64(channelIndex, new double[] { analogChannelSix });

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

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

                    // Now register the RBNB channels, and flush the rbnbChannelMap to the
                    // DataTurbine
                    getSource().Register(registerChannelMap);
                    getSource().Flush(rbnbChannelMap);
                    logger.info("Sample sent to the DataTurbine:" + 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 (Exception sapie) {
        //} 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.messic.server.facade.controllers.rest.PlaylistController.java

@ApiMethod(path = "/services/playlists?filterSid=${playlistSid}&songsInfo=true|false", verb = ApiVerb.GET, description = "Get all playlists", produces = {
        MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
@ApiErrors(apierrors = { @ApiError(code = UnknownMessicRESTException.VALUE, description = "Unknown error"),
        @ApiError(code = NotFoundMessicRESTException.VALUE, description = "Forbidden access") })
@RequestMapping(value = "", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)//from ww w.java2s  .c o  m
@ResponseBody
@ApiResponseObject
public List<Playlist> getAll(
        @RequestParam(value = "filterSid", required = false) @ApiParam(name = "filterSid", description = "SID of the playlist to filter playlists", paramType = ApiParamType.QUERY, required = false) Long filterSid,
        @RequestParam(value = "songsInfo", required = false) @ApiParam(name = "songsInfo", description = "flag to return also the songs info of the playlist or not. By default, true", paramType = ApiParamType.QUERY, required = false, allowedvalues = {
                "true", "false" }, format = "Boolean") Boolean songsInfo)
        throws UnknownMessicRESTException, NotAuthorizedMessicRESTException, NotFoundMessicRESTException {
    User user = SecurityUtil.getCurrentUser();

    try {
        if (songsInfo == null) {
            songsInfo = new Boolean(true);
        }

        if (filterSid == null || filterSid <= 0) {
            return this.playlistAPI.getAllLists(user, songsInfo);
        } else {
            ArrayList<Playlist> result = new ArrayList<Playlist>();
            result.add(this.playlistAPI.getPlaylist(user, filterSid, songsInfo));
            return result;
        }
    } catch (ResourceNotFoundMessicException rnfme) {
        throw new NotFoundMessicRESTException(rnfme);
    } catch (Exception e) {
        log.error("failed!", e);
        throw new UnknownMessicRESTException(e);
    }
}