Example usage for java.lang NumberFormatException getStackTrace

List of usage examples for java.lang NumberFormatException getStackTrace

Introduction

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

Prototype

public StackTraceElement[] getStackTrace() 

Source Link

Document

Provides programmatic access to the stack trace information printed by #printStackTrace() .

Usage

From source file:org.generationcp.breeding.manager.crossingmanager.SelectGermplasmListTreeComponent.java

public void displayGermplasmListDetails(int germplasmListId) throws InternationalizableException {
    try {//  www . j  a  v a2 s  .c o m
        displayGermplasmListInfo(germplasmListId);
    } catch (NumberFormatException e) {
        LOG.error(e.toString() + "\n" + e.getStackTrace());
        e.printStackTrace();
        MessageNotifier.showWarning(messageSource.getMessage(Message.ERROR_INVALID_FORMAT),
                messageSource.getMessage(Message.ERROR_IN_NUMBER_FORMAT), Position.MIDDLE_CENTER);
    } catch (MiddlewareQueryException e) {
        LOG.error(e.toString() + "\n" + e.getStackTrace());
        throw new InternationalizableException(e, Message.ERROR_DATABASE,
                Message.ERROR_IN_CREATING_GERMPLASMLIST_DETAILS_WINDOW);
    }

}

From source file:com.redhat.rhn.frontend.struts.RequestContext.java

/**
 * Returns the value of the parameter named param of the request as a Long.
 *
 * This method will trim the String as well to check for "" and " ". If the
 * String is "1234 " it will return a Long with value: 1234. If the String
 * is "" and required is true it will treat it like a null value and throw
 * BadParameterException.// w  ww.  jav  a 2 s.co m
 *
 * @param param Name of request parameter to be converted.
 *
 * @throws BadParameterException if the parameter <code>param</code> can
 * not be converted to a Long
 *
 * @return the value of the parameter named param of the request as a Long.
 *         <code>null</code> if the parameter is blank.
 */
public Long getParamAsLong(String param) {
    String p = request.getParameter(param);
    Long result = null;

    // Make sure we catch empty strings as well
    if (!StringUtils.isBlank(p)) {
        try {
            result = Long.valueOf(p.trim());
        } catch (NumberFormatException e) {
            BadParameterException bad = new BadParameterException(
                    "The parameter " + param + " must be a Long, but was '" + p + "'", e);
            bad.setStackTrace(e.getStackTrace());
            throw bad;
        }
    }
    return result;
}

From source file:edu.uiowa.icts.bluebutton.controller.LoincCodeCategoryController.java

@ResponseBody
@RequestMapping(value = "datatable", produces = "application/json")
public String datatable(HttpServletRequest request,
        @RequestParam(value = "length", required = false) Integer limit,
        @RequestParam(value = "start", required = false) Integer start,
        @RequestParam(value = "draw", required = false) String draw,
        @RequestParam(value = "search[regex]", required = false, defaultValue = "false") Boolean searchRegularExpression,
        @RequestParam(value = "search[value]", required = false) String search,
        @RequestParam(value = "columnCount", required = false, defaultValue = "0") Integer columnCount,
        @RequestParam(value = "individualSearch", required = false, defaultValue = "false") Boolean individualSearch,
        @RequestParam(value = "display", required = false, defaultValue = "list") String display) {

    List<DataTableHeader> headers = new ArrayList<DataTableHeader>();
    for (int i = 0; i < columnCount; i++) {
        DataTableHeader dth = new DataTableHeader();
        dth.setData(request.getParameter("columns[" + i + "][data]"));
        dth.setName(request.getParameter("columns[" + i + "][name]"));
        dth.setOrderable(Boolean.valueOf(request.getParameter("columns[" + i + "][orderable]")));
        dth.setSearchable(Boolean.valueOf(request.getParameter("columns[" + i + "][searchable]")));
        dth.setSearchValue(request.getParameter("columns[" + i + "][search][value]"));
        dth.setSearchRegex(Boolean.valueOf(request.getParameter("columns[" + i + "][search][regex]")));
        headers.add(dth);//from   www.j av a2 s .  c o  m
    }

    ArrayList<SortColumn> sorts = new ArrayList<SortColumn>();

    JSONObject ob = new JSONObject();

    try {

        for (int i = 0; i < columnCount; i++) {
            Integer columnIndex = null;
            String columnIndexString = request.getParameter("order[" + i + "][column]");
            if (columnIndexString != null) {
                try {
                    columnIndex = Integer.parseInt(columnIndexString);
                } catch (NumberFormatException e) {
                    continue;
                }
                if (columnIndex != null) {
                    sorts.add(new SortColumn(headers.get(columnIndex).getName(),
                            request.getParameter("order[" + i + "][dir]")));
                }
            }
        }

        GenericDaoListOptions options = new GenericDaoListOptions();

        if (!individualSearch) {
            ArrayList<String> searchColumns = new ArrayList<String>();
            for (int i = 0; i < columnCount; i++) {
                if (headers.get(i).getSearchable()) {
                    searchColumns.add(headers.get(i).getName());
                }
            }
            options.setSearch(search);
            options.setSearchColumns(searchColumns);
        } else {
            Map<String, List<Object>> likes = new HashMap<String, List<Object>>();
            for (DataTableHeader header : headers) {
                if (header.getSearchable() && header.getSearchValue() != null) {
                    List<Object> values = new ArrayList<Object>();
                    for (String splitColumnValue : StringUtils.split(header.getSearchValue().trim(), ' ')) {
                        values.add(splitColumnValue.trim());
                    }
                    likes.put(header.getName(), values);
                }
            }
            options.setLikes(likes);
        }

        Integer count = bluebuttonDaoService.getLoincCodeCategoryService().count(options);

        options.setLimit(limit);
        options.setStart(start);
        options.setSorts(sorts);

        List<LoincCodeCategory> loincCodeCategoryList = bluebuttonDaoService.getLoincCodeCategoryService()
                .list(options);

        ob.put("draw", draw);
        ob.put("recordsFiltered", count);
        ob.put("recordsTotal", count);
        JSONArray jsonArray = new JSONArray();
        for (LoincCodeCategory loincCodeCategory : loincCodeCategoryList) {
            JSONArray tableRow = new JSONArray();
            for (DataTableHeader header : headers) {
                String headerName = header.getName();
                if (StringUtils.equals("id", headerName)) {
                    tableRow.put(loincCodeCategory.getId());
                } else if (StringUtils.equals("loincCode", headerName)) {
                    tableRow.put(loincCodeCategory.getLoincCode());
                } else if (StringUtils.equals("name", headerName)) {
                    tableRow.put(loincCodeCategory.getName());
                } else if (StringUtils.equals("rootCategoryName", headerName)) {
                    tableRow.put(loincCodeCategory.getRootCategoryName());
                } else if (StringUtils.equals("subrootCategoryName", headerName)) {
                    tableRow.put(loincCodeCategory.getSubrootCategoryName());
                } else if (StringUtils.equals("urls", headerName)) {
                    String urls = "";
                    if (StringUtils.equals("list", display)) {
                        urls += "<a href=\"show?" + "id=" + loincCodeCategory.getId()
                                + "\"><span class=\"glyphicon glyphicon-eye-open\"></a>";
                        urls += "<a href=\"edit?" + "id=" + loincCodeCategory.getId()
                                + "\"><span class=\"glyphicon glyphicon-pencil\"></a>";
                        urls += "<a href=\"delete?" + "id=" + loincCodeCategory.getId()
                                + "\"><span class=\"glyphicon glyphicon-trash\"></a>";
                    } else {

                    }
                    tableRow.put(urls);
                } else {
                    tableRow.put("[error: column " + headerName + " not supported]");
                }
            }
            jsonArray.put(tableRow);
        }
        ob.put("data", jsonArray);

    } catch (Exception e) {
        log.error("error builing datatable json object for LoincCodeCategory", e);
        try {
            String stackTrace = e.getMessage() + String.valueOf('\n');
            for (StackTraceElement ste : e.getStackTrace()) {
                stackTrace += ste.toString() + String.valueOf('\n');
            }
            JSONObject error = new JSONObject();
            error.put("draw", draw);
            error.put("recordsFiltered", 0);
            error.put("recordsTotal", 0);
            error.put("error", stackTrace);
            return error.toString();
        } catch (JSONException je) {
            log.error("error building json error object for LoincCodeCategory", je);
        }
    }

    return ob.toString();
}

From source file:edu.uiowa.icts.bluebutton.controller.LabTestRangeController.java

@ResponseBody
@RequestMapping(value = "datatable", produces = "application/json")
public String datatable(HttpServletRequest request,
        @RequestParam(value = "length", required = false) Integer limit,
        @RequestParam(value = "start", required = false) Integer start,
        @RequestParam(value = "draw", required = false) String draw,
        @RequestParam(value = "search[regex]", required = false, defaultValue = "false") Boolean searchRegularExpression,
        @RequestParam(value = "search[value]", required = false) String search,
        @RequestParam(value = "columnCount", required = false, defaultValue = "0") Integer columnCount,
        @RequestParam(value = "individualSearch", required = false, defaultValue = "false") Boolean individualSearch,
        @RequestParam(value = "display", required = false, defaultValue = "list") String display) {

    List<DataTableHeader> headers = new ArrayList<DataTableHeader>();
    for (int i = 0; i < columnCount; i++) {
        DataTableHeader dth = new DataTableHeader();
        dth.setData(request.getParameter("columns[" + i + "][data]"));
        dth.setName(request.getParameter("columns[" + i + "][name]"));
        dth.setOrderable(Boolean.valueOf(request.getParameter("columns[" + i + "][orderable]")));
        dth.setSearchable(Boolean.valueOf(request.getParameter("columns[" + i + "][searchable]")));
        dth.setSearchValue(request.getParameter("columns[" + i + "][search][value]"));
        dth.setSearchRegex(Boolean.valueOf(request.getParameter("columns[" + i + "][search][regex]")));
        headers.add(dth);//  w  w w.  ja  v a2 s.  c o  m
    }

    ArrayList<SortColumn> sorts = new ArrayList<SortColumn>();

    JSONObject ob = new JSONObject();

    try {

        for (int i = 0; i < columnCount; i++) {
            Integer columnIndex = null;
            String columnIndexString = request.getParameter("order[" + i + "][column]");
            if (columnIndexString != null) {
                try {
                    columnIndex = Integer.parseInt(columnIndexString);
                } catch (NumberFormatException e) {
                    continue;
                }
                if (columnIndex != null) {
                    sorts.add(new SortColumn(headers.get(columnIndex).getName(),
                            request.getParameter("order[" + i + "][dir]")));
                }
            }
        }

        GenericDaoListOptions options = new GenericDaoListOptions();

        if (!individualSearch) {
            ArrayList<String> searchColumns = new ArrayList<String>();
            for (int i = 0; i < columnCount; i++) {
                if (headers.get(i).getSearchable()) {
                    searchColumns.add(headers.get(i).getName());
                }
            }
            options.setSearch(search);
            options.setSearchColumns(searchColumns);
        } else {
            Map<String, Object> likes = new HashMap<String, Object>();
            for (DataTableHeader header : headers) {
                if (header.getSearchable() && header.getSearchValue() != null) {
                    for (String splitColumnValue : StringUtils.split(header.getSearchValue().trim(), ' ')) {
                        likes.put(header.getName(), splitColumnValue);
                    }
                }
            }
            options.setIndividualLikes(likes);
        }

        Integer count = bluebuttonDaoService.getLabTestRangeService().count(options);

        options.setLimit(limit);
        options.setStart(start);
        options.setSorts(sorts);

        List<LabTestRange> labTestRangeList = bluebuttonDaoService.getLabTestRangeService().list(options);

        ob.put("draw", draw);
        ob.put("recordsFiltered", count);
        ob.put("recordsTotal", count);
        JSONArray jsonArray = new JSONArray();
        for (LabTestRange labTestRange : labTestRangeList) {
            JSONArray tableRow = new JSONArray();
            for (DataTableHeader header : headers) {
                String headerName = header.getName();
                if (StringUtils.equals("labTestRangeId", headerName)) {
                    tableRow.put(labTestRange.getLabTestRangeId());
                } else if (StringUtils.equals("sex", headerName)) {
                    tableRow.put(labTestRange.getSex());
                } else if (StringUtils.equals("minAgeYears", headerName)) {
                    tableRow.put(labTestRange.getMinAgeYears());
                } else if (StringUtils.equals("maxAgeYears", headerName)) {
                    tableRow.put(labTestRange.getMaxAgeYears());
                } else if (StringUtils.equals("minNormal", headerName)) {
                    tableRow.put(labTestRange.getMinNormal());
                } else if (StringUtils.equals("maxNormal", headerName)) {
                    tableRow.put(labTestRange.getMaxNormal());
                } else if (StringUtils.equals("labTest", headerName)) {
                    tableRow.put(labTestRange.getLabTest().getName());
                } else if (StringUtils.equals("urls", headerName)) {
                    String urls = "";
                    if (StringUtils.equals("list", display)) {
                        urls += "<a href=\"show?" + "labTestRangeId=" + labTestRange.getLabTestRangeId()
                                + "\"><span class=\"glyphicon glyphicon-eye-open\"></a>";
                        //urls += "<a href=\"edit?"+"labTestRangeId="+labTestRange.getLabTestRangeId()+"\"><span class=\"glyphicon glyphicon-pencil\"></a>";
                        urls += "<a href=\"delete?" + "labTestRangeId=" + labTestRange.getLabTestRangeId()
                                + "\"><span class=\"glyphicon glyphicon-trash\"></a>";
                    } else {

                    }
                    tableRow.put(urls);
                } else {
                    tableRow.put("[error: column " + headerName + " not supported]");
                }
            }
            jsonArray.put(tableRow);
        }
        ob.put("data", jsonArray);

    } catch (Exception e) {
        log.error("error builing datatable json object for LabTestRange", e);
        try {
            String stackTrace = e.getMessage() + String.valueOf('\n');
            for (StackTraceElement ste : e.getStackTrace()) {
                stackTrace += ste.toString() + String.valueOf('\n');
            }
            ob = new JSONObject();
            ob.put("draw", draw);
            ob.put("recordsFiltered", 0);
            ob.put("recordsTotal", 0);
            ob.put("error", stackTrace);
        } catch (JSONException je) {
            log.error("error building json error object for LabTestRange", je);
        }
    }

    return ob.toString();
}

From source file:edu.uiowa.icts.bluebutton.controller.LabTestController.java

@ResponseBody
@RequestMapping(value = "datatable", produces = "application/json")
public String datatable(HttpServletRequest request,
        @RequestParam(value = "length", required = false) Integer limit,
        @RequestParam(value = "start", required = false) Integer start,
        @RequestParam(value = "draw", required = false) String draw,
        @RequestParam(value = "search[regex]", required = false, defaultValue = "false") Boolean searchRegularExpression,
        @RequestParam(value = "search[value]", required = false) String search,
        @RequestParam(value = "columnCount", required = false, defaultValue = "0") Integer columnCount,
        @RequestParam(value = "individualSearch", required = false, defaultValue = "false") Boolean individualSearch,
        @RequestParam(value = "display", required = false, defaultValue = "list") String display) {

    List<DataTableHeader> headers = new ArrayList<DataTableHeader>();
    for (int i = 0; i < columnCount; i++) {
        DataTableHeader dth = new DataTableHeader();
        dth.setData(request.getParameter("columns[" + i + "][data]"));
        dth.setName(request.getParameter("columns[" + i + "][name]"));
        dth.setOrderable(Boolean.valueOf(request.getParameter("columns[" + i + "][orderable]")));
        dth.setSearchable(Boolean.valueOf(request.getParameter("columns[" + i + "][searchable]")));
        dth.setSearchValue(request.getParameter("columns[" + i + "][search][value]"));
        dth.setSearchRegex(Boolean.valueOf(request.getParameter("columns[" + i + "][search][regex]")));
        headers.add(dth);/*from  w w  w  . j  av  a  2  s.  co m*/
    }

    ArrayList<SortColumn> sorts = new ArrayList<SortColumn>();

    JSONObject ob = new JSONObject();

    try {

        for (int i = 0; i < columnCount; i++) {
            Integer columnIndex = null;
            String columnIndexString = request.getParameter("order[" + i + "][column]");
            if (columnIndexString != null) {
                try {
                    columnIndex = Integer.parseInt(columnIndexString);
                } catch (NumberFormatException e) {
                    continue;
                }
                if (columnIndex != null) {
                    sorts.add(new SortColumn(headers.get(columnIndex).getName(),
                            request.getParameter("order[" + i + "][dir]")));
                }
            }
        }

        GenericDaoListOptions options = new GenericDaoListOptions();

        if (!individualSearch) {
            ArrayList<String> searchColumns = new ArrayList<String>();
            for (int i = 0; i < columnCount; i++) {
                if (headers.get(i).getSearchable()) {
                    searchColumns.add(headers.get(i).getName());
                }
            }
            options.setSearch(search);
            options.setSearchColumns(searchColumns);
        } else {
            Map<String, Object> likes = new HashMap<String, Object>();
            for (DataTableHeader header : headers) {
                if (header.getSearchable() && header.getSearchValue() != null) {
                    for (String splitColumnValue : StringUtils.split(header.getSearchValue().trim(), ' ')) {
                        likes.put(header.getName(), splitColumnValue);
                    }
                }
            }
            options.setIndividualLikes(likes);
        }

        Integer count = bluebuttonDaoService.getLabTestService().count(options);

        options.setLimit(limit);
        options.setStart(start);
        options.setSorts(sorts);

        List<LabTest> labTestList = bluebuttonDaoService.getLabTestService().list(options);

        ob.put("draw", draw);
        ob.put("recordsFiltered", count);
        ob.put("recordsTotal", count);
        JSONArray jsonArray = new JSONArray();
        for (LabTest labTest : labTestList) {
            JSONArray tableRow = new JSONArray();
            for (DataTableHeader header : headers) {
                String headerName = header.getName();
                if (StringUtils.equals("labTestId", headerName)) {
                    tableRow.put(labTest.getLabTestId());
                } else if (StringUtils.equals("name", headerName)) {
                    tableRow.put(labTest.getName());
                } else if (StringUtils.equals("description", headerName)) {
                    tableRow.put(labTest.getDescription());
                } else if (StringUtils.equals("units", headerName)) {
                    tableRow.put(labTest.getUnits());
                } else if (StringUtils.equals("loincCode", headerName)) {
                    tableRow.put(labTest.getLoincCode());
                } else if (StringUtils.equals("dateCreated", headerName)) {
                    tableRow.put(labTest.getDateCreated());
                } else if (StringUtils.equals("dateUpdated", headerName)) {
                    tableRow.put(labTest.getDateUpdated());
                } else if (StringUtils.equals("labTestRanges", headerName)) {
                    tableRow.put(labTest.getLabTestRanges().size());
                } else if (StringUtils.equals("urls", headerName)) {
                    String urls = "";
                    if (StringUtils.equals("list", display)) {
                        urls += "<a href=\"show?" + "labTestId=" + labTest.getLabTestId()
                                + "\"><span class=\"glyphicon glyphicon-eye-open\"></a>";
                        //   urls += "<a href=\"edit?"+"labTestId="+labTest.getLabTestId()+"\"><span class=\"glyphicon glyphicon-pencil\"></a>";
                        urls += "<a href=\"delete?" + "labTestId=" + labTest.getLabTestId()
                                + "\"><span class=\"glyphicon glyphicon-trash\"></a>";
                    } else {

                    }
                    tableRow.put(urls);
                } else {
                    tableRow.put("[error: column " + headerName + " not supported]");
                }
            }
            jsonArray.put(tableRow);
        }
        ob.put("data", jsonArray);

    } catch (Exception e) {
        log.error("error builing datatable json object for LabTest", e);
        try {
            String stackTrace = e.getMessage() + String.valueOf('\n');
            for (StackTraceElement ste : e.getStackTrace()) {
                stackTrace += ste.toString() + String.valueOf('\n');
            }
            ob = new JSONObject();
            ob.put("draw", draw);
            ob.put("recordsFiltered", 0);
            ob.put("recordsTotal", 0);
            ob.put("error", stackTrace);
        } catch (JSONException je) {
            log.error("error building json error object for LabTest", je);
        }
    }

    return ob.toString();
}

From source file:edu.uiowa.icts.bluebutton.controller.LabResultSynonymController.java

@ResponseBody
@RequestMapping(value = "datatable", produces = "application/json")
public DataTable datatable(HttpServletRequest request,
        @RequestParam(value = "length", required = false) Integer limit,
        @RequestParam(value = "start", required = false) Integer start,
        @RequestParam(value = "draw", required = false) String draw,
        @RequestParam(value = "search[regex]", required = false, defaultValue = "false") Boolean searchRegularExpression,
        @RequestParam(value = "search[value]", required = false) String search,
        @RequestParam(value = "columnCount", required = false, defaultValue = "0") Integer columnCount,
        @RequestParam(value = "individualSearch", required = false, defaultValue = "false") Boolean individualSearch,
        @RequestParam(value = "display", required = false, defaultValue = "list") String display) {

    String contextPath = request.getContextPath();

    List<DataTableHeader> headers = new ArrayList<DataTableHeader>();
    for (int i = 0; i < columnCount; i++) {
        DataTableHeader dth = new DataTableHeader();
        dth.setData(request.getParameter("columns[" + i + "][data]"));
        dth.setName(request.getParameter("columns[" + i + "][name]"));
        dth.setOrderable(Boolean.valueOf(request.getParameter("columns[" + i + "][orderable]")));
        dth.setSearchable(Boolean.valueOf(request.getParameter("columns[" + i + "][searchable]")));
        dth.setSearchValue(request.getParameter("columns[" + i + "][search][value]"));
        dth.setSearchRegex(Boolean.valueOf(request.getParameter("columns[" + i + "][search][regex]")));
        headers.add(dth);//  www  .  j a v a2  s . co m
    }

    ArrayList<SortColumn> sorts = new ArrayList<SortColumn>();

    DataTable dt = new DataTable();

    try {

        for (int i = 0; i < columnCount; i++) {
            Integer columnIndex = null;
            String columnIndexString = request.getParameter("order[" + i + "][column]");
            if (columnIndexString != null) {
                try {
                    columnIndex = Integer.parseInt(columnIndexString);
                } catch (NumberFormatException e) {
                    continue;
                }
                if (columnIndex != null) {
                    sorts.add(new SortColumn(headers.get(columnIndex).getName(),
                            request.getParameter("order[" + i + "][dir]")));
                }
            }
        }

        GenericDaoListOptions options = new GenericDaoListOptions();

        if (!individualSearch) {
            ArrayList<String> searchColumns = new ArrayList<String>();
            for (int i = 0; i < columnCount; i++) {
                if (headers.get(i).getSearchable()) {
                    searchColumns.add(headers.get(i).getName());
                }
            }
            options.setSearch(search);
            options.setSearchColumns(searchColumns);
        } else {
            Map<String, List<Object>> likes = new HashMap<String, List<Object>>();
            for (DataTableHeader header : headers) {
                if (header.getSearchable() && header.getSearchValue() != null) {
                    List<Object> values = new ArrayList<Object>();
                    for (String splitColumnValue : StringUtils.split(header.getSearchValue().trim(), ' ')) {
                        values.add(splitColumnValue.trim());
                    }
                    likes.put(header.getName(), values);
                }
            }
            options.setLikes(likes);
        }

        Integer count = bluebuttonDaoService.getLabResultSynonymService().count(options);

        options.setLimit(limit);
        options.setStart(start);
        options.setSorts(sorts);

        List<LabResultSynonym> labResultSynonymList = bluebuttonDaoService.getLabResultSynonymService()
                .list(options);

        List<LinkedHashMap<String, Object>> data = new ArrayList<LinkedHashMap<String, Object>>();

        for (LabResultSynonym labResultSynonym : labResultSynonymList) {
            LinkedHashMap<String, Object> tableRow = new LinkedHashMap<String, Object>();
            for (DataTableHeader header : headers) {
                String headerName = header.getName();
                String dataName = header.getData();
                if (StringUtils.equals("labResultSynonymId", headerName)) {
                    tableRow.put(dataName, labResultSynonym.getLabResultSynonymId());
                } else if (StringUtils.equals("officialName", headerName)) {
                    tableRow.put(dataName, labResultSynonym.getOfficialName());
                } else if (StringUtils.equals("unofficialName", headerName)) {
                    tableRow.put(dataName, labResultSynonym.getUnofficialName());
                } else if (StringUtils.equals("panel", headerName)) {
                    tableRow.put(dataName, labResultSynonym.getPanel());
                } else if (StringUtils.equals("urls", headerName)) {
                    String urls = "";
                    if (StringUtils.equals("list", display)) {
                        urls += "<a href=\"" + contextPath + "/labresultsynonym/show?" + "labResultSynonymId="
                                + labResultSynonym.getLabResultSynonymId()
                                + "\"><span class=\"glyphicon glyphicon-eye-open\"></a>";
                        urls += "<a href=\"" + contextPath + "/labresultsynonym/edit?" + "labResultSynonymId="
                                + labResultSynonym.getLabResultSynonymId()
                                + "\"><span class=\"glyphicon glyphicon-pencil\"></a>";
                        urls += "<a href=\"" + contextPath + "/labresultsynonym/delete?" + "labResultSynonymId="
                                + labResultSynonym.getLabResultSynonymId()
                                + "\"><span class=\"glyphicon glyphicon-trash\"></a>";
                    } else {

                    }
                    tableRow.put(dataName, urls);
                } else {
                    tableRow.put("error", "[error: column " + headerName + " not supported]");
                }
            }
            data.add(tableRow);
        }

        dt.setDraw(draw);
        dt.setRecordsFiltered(count);
        dt.setRecordsTotal(count);
        dt.setData(data);

    } catch (Exception e) {
        log.error("error builing datatable json object for LabResultSynonym", e);
        String stackTrace = e.getMessage() + String.valueOf('\n');
        for (StackTraceElement ste : e.getStackTrace()) {
            stackTrace += ste.toString() + String.valueOf('\n');
        }
        DataTable error = new DataTable();
        error.setDraw(draw);
        error.setRecordsFiltered(0);
        error.setRecordsTotal(0);
        error.setError(stackTrace);
        return error;
    }

    return dt;
}

From source file:edu.uiowa.icts.bluebutton.controller.PersonController.java

@ResponseBody
@RequestMapping(value = "datatable", produces = "application/json")
public String datatable(HttpServletRequest request,
        @RequestParam(value = "length", required = false) Integer limit,
        @RequestParam(value = "start", required = false) Integer start,
        @RequestParam(value = "draw", required = false) String draw,
        @RequestParam(value = "search[regex]", required = false, defaultValue = "false") Boolean searchRegularExpression,
        @RequestParam(value = "search[value]", required = false) String search,
        @RequestParam(value = "columnCount", required = false, defaultValue = "0") Integer columnCount,
        @RequestParam(value = "individualSearch", required = false, defaultValue = "false") Boolean individualSearch,
        @RequestParam(value = "display", required = false, defaultValue = "list") String display) {

    List<DataTableHeader> headers = new ArrayList<DataTableHeader>();
    for (int i = 0; i < columnCount; i++) {
        DataTableHeader dth = new DataTableHeader();
        dth.setData(request.getParameter("columns[" + i + "][data]"));
        dth.setName(request.getParameter("columns[" + i + "][name]"));
        dth.setOrderable(Boolean.valueOf(request.getParameter("columns[" + i + "][orderable]")));
        dth.setSearchable(Boolean.valueOf(request.getParameter("columns[" + i + "][searchable]")));
        dth.setSearchValue(request.getParameter("columns[" + i + "][search][value]"));
        dth.setSearchRegex(Boolean.valueOf(request.getParameter("columns[" + i + "][search][regex]")));
        headers.add(dth);/*from  w  w  w  .  j av  a2s.com*/
    }

    ArrayList<SortColumn> sorts = new ArrayList<SortColumn>();

    JSONObject ob = new JSONObject();

    try {

        for (int i = 0; i < columnCount; i++) {
            Integer columnIndex = null;
            String columnIndexString = request.getParameter("order[" + i + "][column]");
            if (columnIndexString != null) {
                try {
                    columnIndex = Integer.parseInt(columnIndexString);
                } catch (NumberFormatException e) {
                    continue;
                }
                if (columnIndex != null) {
                    sorts.add(new SortColumn(headers.get(columnIndex).getName(),
                            request.getParameter("order[" + i + "][dir]")));
                }
            }
        }

        GenericDaoListOptions options = new GenericDaoListOptions();

        if (!individualSearch) {
            ArrayList<String> searchColumns = new ArrayList<String>();
            for (int i = 0; i < columnCount; i++) {
                if (headers.get(i).getSearchable()) {
                    searchColumns.add(headers.get(i).getName());
                }
            }
            options.setSearch(search);
            options.setSearchColumns(searchColumns);
        } else {
            Map<String, List<Object>> likes = new HashMap<String, List<Object>>();
            for (DataTableHeader header : headers) {
                if (header.getSearchable() && header.getSearchValue() != null) {
                    List<Object> values = new ArrayList<Object>();
                    for (String splitColumnValue : StringUtils.split(header.getSearchValue().trim(), ' ')) {
                        values.add(splitColumnValue.trim());
                    }
                    likes.put(header.getName(), values);
                }
            }
            options.setLikes(likes);
        }

        Integer count = bluebuttonDaoService.getPersonService().count(options);

        options.setLimit(limit);
        options.setStart(start);
        options.setSorts(sorts);

        List<Person> personList = bluebuttonDaoService.getPersonService().list(options);

        ob.put("draw", draw);
        ob.put("recordsFiltered", count);
        ob.put("recordsTotal", count);
        JSONArray jsonArray = new JSONArray();
        for (Person person : personList) {
            JSONArray tableRow = new JSONArray();
            for (DataTableHeader header : headers) {
                String headerName = header.getName();
                if (StringUtils.equals("personId", headerName)) {
                    tableRow.put(person.getPersonId());
                } else if (StringUtils.equals("firstName", headerName)) {
                    tableRow.put(person.getFirstName());
                } else if (StringUtils.equals("middleName", headerName)) {
                    tableRow.put(person.getMiddleName());
                } else if (StringUtils.equals("lastName", headerName)) {
                    tableRow.put(person.getLastName());
                } else if (StringUtils.equals("dateOfBirth", headerName)) {
                    tableRow.put(person.getDateOfBirth());
                } else if (StringUtils.equals("addressLineOne", headerName)) {
                    tableRow.put(person.getAddressLineOne());
                } else if (StringUtils.equals("addressLineTwo", headerName)) {
                    tableRow.put(person.getAddressLineTwo());
                } else if (StringUtils.equals("city", headerName)) {
                    tableRow.put(person.getCity());
                } else if (StringUtils.equals("state", headerName)) {
                    tableRow.put(person.getState());
                } else if (StringUtils.equals("zipcode", headerName)) {
                    tableRow.put(person.getZipcode());
                } else if (StringUtils.equals("country", headerName)) {
                    tableRow.put(person.getCountry());
                } else if (StringUtils.equals("email", headerName)) {
                    tableRow.put(person.getEmail());
                } else if (StringUtils.equals("registrationDate", headerName)) {
                    tableRow.put(person.getRegistrationDate());
                } else if (StringUtils.equals("firstLogin", headerName)) {
                    tableRow.put(person.getFirstLogin());
                } else if (StringUtils.equals("lastLogin", headerName)) {
                    tableRow.put(person.getLastLogin());
                } else if (StringUtils.equals("lastUpdated", headerName)) {
                    tableRow.put(person.getLastUpdated());
                } else if (StringUtils.equals("signature", headerName)) {
                    tableRow.put(person.getSignature());
                } else if (StringUtils.equals("clinicalDocuments", headerName)) {
                    tableRow.put(person.getClinicalDocuments().size());
                } else if (StringUtils.equals("urls", headerName)) {
                    String urls = "";
                    if (StringUtils.equals("list", display)) {
                        urls += "<a href=\"show?" + "personId=" + person.getPersonId()
                                + "\"><span class=\"glyphicon glyphicon-eye-open\"></a>";
                        urls += "<a href=\"edit?" + "personId=" + person.getPersonId()
                                + "\"><span class=\"glyphicon glyphicon-pencil\"></a>";
                        //      urls += "<a href=\"delete?"+"personId="+person.getPersonId()+"\"><span class=\"glyphicon glyphicon-trash\"></a>";
                    } else {

                    }
                    tableRow.put(urls);
                } else {
                    tableRow.put("[error: column " + headerName + " not supported]");
                }
            }
            jsonArray.put(tableRow);
        }
        ob.put("data", jsonArray);

    } catch (Exception e) {
        log.error("error builing datatable json object for Person", e);
        try {
            String stackTrace = e.getMessage() + String.valueOf('\n');
            for (StackTraceElement ste : e.getStackTrace()) {
                stackTrace += ste.toString() + String.valueOf('\n');
            }
            JSONObject error = new JSONObject();
            error.put("draw", draw);
            error.put("recordsFiltered", 0);
            error.put("recordsTotal", 0);
            error.put("error", stackTrace);
            return error.toString();
        } catch (JSONException je) {
            log.error("error building json error object for Person", je);
        }
    }

    return ob.toString();
}

From source file:edu.uiowa.icts.bluebutton.controller.ClinicalDocumentController.java

@ResponseBody
@RequestMapping(value = "datatable", produces = "application/json")
public String datatable(HttpServletRequest request,
        @RequestParam(value = "personId", required = false) Integer personId,
        @RequestParam(value = "length", required = false) Integer limit,
        @RequestParam(value = "start", required = false) Integer start,
        @RequestParam(value = "draw", required = false) String draw,
        @RequestParam(value = "search[regex]", required = false, defaultValue = "false") Boolean searchRegularExpression,
        @RequestParam(value = "search[value]", required = false) String search,
        @RequestParam(value = "columnCount", required = false, defaultValue = "0") Integer columnCount,
        @RequestParam(value = "individualSearch", required = false, defaultValue = "false") Boolean individualSearch,
        @RequestParam(value = "display", required = false, defaultValue = "list") String display) {

    List<DataTableHeader> headers = new ArrayList<DataTableHeader>();
    for (int i = 0; i < columnCount; i++) {
        DataTableHeader dth = new DataTableHeader();
        dth.setData(Integer.valueOf(request.getParameter("columns[" + i + "][data]")));
        dth.setName(request.getParameter("columns[" + i + "][name]"));
        dth.setOrderable(Boolean.valueOf(request.getParameter("columns[" + i + "][orderable]")));
        dth.setSearchable(Boolean.valueOf(request.getParameter("columns[" + i + "][searchable]")));
        dth.setSearchValue(request.getParameter("columns[" + i + "][search][value]"));
        dth.setSearchRegex(Boolean.valueOf(request.getParameter("columns[" + i + "][search][regex]")));
        headers.add(dth);//ww  w. j  a  v  a  2  s . c  o  m
    }

    ArrayList<SortColumn> sorts = new ArrayList<SortColumn>();

    JSONObject ob = new JSONObject();

    try {

        for (int i = 0; i < columnCount; i++) {
            Integer columnIndex = null;
            String columnIndexString = request.getParameter("order[" + i + "][column]");
            if (columnIndexString != null) {
                try {
                    columnIndex = Integer.parseInt(columnIndexString);
                } catch (NumberFormatException e) {
                    continue;
                }
                if (columnIndex != null) {
                    if (StringUtils.equalsIgnoreCase("person", headers.get(columnIndex).getName())) {
                        sorts.add(new SortColumn("person.lastName",
                                request.getParameter("order[" + i + "][dir]")));
                        sorts.add(new SortColumn("person.firstName",
                                request.getParameter("order[" + i + "][dir]")));
                    } else {
                        sorts.add(new SortColumn(headers.get(columnIndex).getName(),
                                request.getParameter("order[" + i + "][dir]")));
                    }
                }
            }
        }

        GenericDaoListOptions options = new GenericDaoListOptions();

        List<Alias> aliases = new ArrayList<Alias>();
        aliases.add(new Alias("person", "person"));
        options.setAliases(aliases);

        Map<String, Object> individualEquals = new HashMap<String, Object>();
        if (personId != null) {
            individualEquals.put("person.personId", personId);
        }
        options.setIndividualEquals(individualEquals);

        if (!individualSearch) {
            ArrayList<String> searchColumns = new ArrayList<String>();
            for (int i = 0; i < columnCount; i++) {
                if (headers.get(i).getSearchable()) {
                    if (StringUtils.equalsIgnoreCase("person", headers.get(i).getName())) {
                        searchColumns.add("person.lastName");
                        searchColumns.add("person.firstName");
                    } else {
                        searchColumns.add(headers.get(i).getName());
                    }
                }
            }
            options.setSearch(search);
            options.setSearchColumns(searchColumns);
        } else {

            List<Junction> disjunctions = new ArrayList<Junction>();

            for (DataTableHeader header : headers) {
                if (header.getSearchable() && header.getSearchValue() != null
                        && !StringUtils.equals("", header.getSearchValue().trim())) {
                    for (String splitColumnValue : StringUtils.split(header.getSearchValue().trim(), ' ')) {
                        Disjunction disjunction = Restrictions.disjunction();
                        if (StringUtils.equalsIgnoreCase("person", header.getName())) {
                            disjunction
                                    .add(Restrictions.ilike("person.lastName", "%" + splitColumnValue + "%"));
                            disjunction
                                    .add(Restrictions.ilike("person.firstName", "%" + splitColumnValue + "%"));
                        } else {
                            disjunction.add(Restrictions.ilike(header.getName(), "%" + splitColumnValue + "%"));
                        }
                        disjunctions.add(disjunction);
                    }
                }
            }
            options.setJunctions(disjunctions);
        }

        Integer count = bluebuttonDaoService.getClinicalDocumentService().count(options);

        options.setLimit(limit);
        options.setStart(start);
        options.setSorts(sorts);

        List<ClinicalDocument> clinicalDocumentList = bluebuttonDaoService.getClinicalDocumentService()
                .list(options);

        ob.put("draw", draw);
        ob.put("recordsFiltered", count);
        ob.put("recordsTotal", count);
        JSONArray jsonArray = new JSONArray();
        for (ClinicalDocument clinicalDocument : clinicalDocumentList) {
            JSONArray tableRow = new JSONArray();
            for (DataTableHeader header : headers) {
                String headerName = header.getName();
                if (StringUtils.equals("clinicalDocumentId", headerName)) {
                    tableRow.put(clinicalDocument.getClinicalDocumentId());
                } else if (StringUtils.equals("document", headerName)) {
                    tableRow.put(clinicalDocument.getDocument());
                } else if (StringUtils.equals("name", headerName)) {
                    tableRow.put(clinicalDocument.getName());
                } else if (StringUtils.equals("source", headerName)) {
                    tableRow.put(clinicalDocument.getSource());
                } else if (StringUtils.equals("description", headerName)) {
                    tableRow.put(clinicalDocument.getDescription());
                } else if (StringUtils.equals("dateUploaded", headerName)) {
                    tableRow.put(clinicalDocument.getDateUploaded());
                } else if (StringUtils.equals("jsonParserVersion", headerName)) {
                    tableRow.put(clinicalDocument.getJsonParserVersion());
                } else if (StringUtils.equals("person", headerName)) {
                    String toPut = "";
                    if (clinicalDocument.getPerson() != null) {
                        toPut = clinicalDocument.getPerson().getLastName() + ", "
                                + clinicalDocument.getPerson().getFirstName();
                    }
                    tableRow.put(toPut);
                } else if (StringUtils.equals("urls", headerName)) {
                    String urls = "";
                    if (StringUtils.equals("list", display)) {
                        urls += "<a href=\"show?" + "clinicalDocumentId="
                                + clinicalDocument.getClinicalDocumentId()
                                + "\"><span class=\"glyphicon glyphicon-eye-open\"></a> ";
                        urls += "<a href=\"edit?" + "clinicalDocumentId="
                                + clinicalDocument.getClinicalDocumentId()
                                + "\"><span class=\"glyphicon glyphicon-pencil\"></a> ";
                        urls += "<a href=\"delete?" + "clinicalDocumentId="
                                + clinicalDocument.getClinicalDocumentId()
                                + "\"><span class=\"glyphicon glyphicon-trash\"></a>";
                    } else if (StringUtils.equals("person", display)) {
                        urls += "<a href=\"" + request.getContextPath()
                                + "/clinicaldocument/show.html?clinicalDocumentId="
                                + clinicalDocument.getClinicalDocumentId() + "\">[view]</a>";
                    } else {

                    }
                    tableRow.put(urls);
                } else {
                    tableRow.put("[error: column " + headerName + " not supported]");
                }
            }
            jsonArray.put(tableRow);
        }
        ob.put("data", jsonArray);

    } catch (Exception e) {
        log.error("error builing datatable json object for ClinicalDocument", e);
        try {
            String stackTrace = e.getMessage() + String.valueOf('\n');
            for (StackTraceElement ste : e.getStackTrace()) {
                stackTrace += ste.toString() + String.valueOf('\n');
            }
            ob = new JSONObject();
            ob.put("draw", draw);
            ob.put("recordsFiltered", 0);
            ob.put("recordsTotal", 0);
            ob.put("error", stackTrace);
        } catch (JSONException je) {
            log.error("error building json error object for ClinicalDocument", je);
        }
    }

    return ob.toString();
}

From source file:rems.Program.java

/**
 * @param args the command line arguments
 *//*from  ww w.  j a v a 2 s .c o m*/
public static void main(String[] args) {
    try {

        Global.UsrsOrg_ID = 3;
        Global.dataBasDir = "C:\\1_DESIGNS\\MYAPPS\\Enterprise_Management_System\\Enterprise_Management_System\\bin\\Debug\\Images\\test_database";
        Global.rnnrsBasDir = "C:\\1_DESIGNS\\MYAPPS\\Enterprise_Management_System\\Enterprise_Management_System\\bin\\Debug\\bin";

        String pname = ManagementFactory.getRuntimeMXBean().getName();
        if (pname.contains("@")) {
            Global.pid = Integer.parseInt(pname.substring(0, pname.lastIndexOf("@")));
        } else {
            Global.pid = Thread.currentThread().getId();
        }
        Global.HostOSNme = System.getProperty("os.name");
        System.out.println(Global.pid);
        System.out.println(Global.HostOSNme);

        String[] macDet = Global.getMachDetails();
        System.out.println(Arrays.toString(macDet));
        System.out.println(args.length);
        System.out.println(Arrays.toString(args));
        Global.errorLog += Global.pid + System.getProperty("line.separator") + Global.HostOSNme
                + System.getProperty("line.separator") + Arrays.toString(Global.getMachDetails())
                + System.getProperty("line.separator");
        //Global.writeToLog();
        if (args.length >= 8) {
            Global.rnnrsBasDir = StringUtils.strip(args[7], "\"");
            runnerName = StringUtils.strip(args[5], "\"");
            Global.errorLog = args[0] + System.getProperty("line.separator") + args[1]
                    + System.getProperty("line.separator") + args[2] + System.getProperty("line.separator")
                    + "********************" + System.getProperty("line.separator") + args[4]
                    + System.getProperty("line.separator") + args[5] + System.getProperty("line.separator")
                    + args[6] + System.getProperty("line.separator") + Global.rnnrsBasDir
                    + System.getProperty("line.separator");

            if (args.length >= 10) {
                Global.callngAppType = StringUtils.strip(args[8], "\"");
                Global.dataBasDir = StringUtils.strip(args[9], "\"");
                Global.errorLog += args[8] + System.getProperty("line.separator") + args[9]
                        + System.getProperty("line.separator");
                if (args.length == 11) {
                    Global.AppUrl = StringUtils.strip(args[10], "\"");
                    Global.errorLog += args[10] + System.getProperty("line.separator");
                }
            }
            Global.errorLog += "PID: " + Global.pid + " Running on: " + macDet[0] + " / " + macDet[1] + " / "
                    + macDet[2];
            Global.writeToLog();
            Global.runID = Long.valueOf(args[6]);
            do_connection(args[0], args[1], args[2], args[3], args[4]);
            Global.appStatPath = Global.rnnrsBasDir;
            //Program.updateRates("2015-07-02");
            if (Global.runID > 0) {
                Global.rnUser_ID = Long.valueOf(
                        Global.getGnrlRecNm("rpt.rpt_report_runs", "rpt_run_id", "run_by", Global.runID));
                Global.UsrsOrg_ID = Global.getUsrOrgID(Global.rnUser_ID);
            }

            if (!Global.globalSQLConn.isClosed()) {
                Global.globalSQLConn.close();
                boolean isLstnrRnng = false;
                if (Program.runnerName.equals("REQUESTS LISTENER PROGRAM")) {
                    int isIPAllwd = Global.getEnbldPssblValID(macDet[2],
                            Global.getEnbldLovID("Allowed IP Address for Request Listener"));
                    int isDBAllwd = Global.getEnbldPssblValID(Global.Dbase,
                            Global.getEnbldLovID("Allowed DB Name for Request Listener"));
                    if (isIPAllwd <= 0 || isDBAllwd <= 0) {
                        Program.killThreads();
                        Thread.currentThread().interrupt();
                        //Program.killThreads();
                        return;
                    }

                    isLstnrRnng = Global.isRunnrRnng(Program.runnerName);
                    if (isLstnrRnng == true) {
                        Program.killThreads();
                        Thread.currentThread().interrupt();
                        //Program.killThreads();
                        return;
                    }
                }
                Global.errorLog = "Successfully Connected to Database\r\n" + String.valueOf(isLstnrRnng)
                        + System.getProperty("line.separator");
                Global.writeToLog();
                String rnnPryty = Global.getGnrlRecNm("rpt.rpt_prcss_rnnrs", "rnnr_name", "crnt_rnng_priority",
                        Program.runnerName);

                if (isLstnrRnng == false && Program.runnerName.equals("REQUESTS LISTENER PROGRAM")) {
                    Global.updatePrcsRnnrCmd(Program.runnerName, "0", -1);
                    thread1 = new RqstLstnrUpdtrfunc("ThreadOne");
                    thread1.setDaemon(true);
                    thread1.setName("ThreadOne");
                    thread1.setPriority(Thread.MIN_PRIORITY);
                    //System.out.println("Starting ThreadOne thread...");
                    thread1.start();
                    Global.minimizeMemory();
                    if (Program.runnerName.equals("REQUESTS LISTENER PROGRAM")) {
                        //Thread for Generating Run Requests for Scheduled Programs/Reports
                        thread2 = new GnrtSchldRnsfunc("ThreadTwo");
                        thread2.setDaemon(true);
                        thread2.setName("ThreadTwo");
                        thread2.setPriority(Thread.MIN_PRIORITY);
                        //System.out.println("Starting ThreadTwo thread...");
                        thread2.start();

                        //Thread for Generating Run Requests for Scheduled Alerts
                        thread6 = new GnrtSchldAlertsfunc("ThreadSix");
                        thread6.setDaemon(true);
                        thread6.setName("ThreadSix");
                        thread6.setPriority(Thread.MIN_PRIORITY);
                        //System.out.println("Starting ThreadSix thread...");
                        thread6.start();

                        //Thread for Monitoring Scheduled Request Runs that are due but not running
                        // and starting their appropriate process runners
                        thread3 = new MntrSchdldRqtsNtRnngfunc("ThreadThree");
                        thread3.setDaemon(true);
                        thread3.setName("ThreadThree");
                        thread3.setPriority(Thread.MIN_PRIORITY);
                        //System.out.println("Starting ThreadThree thread...");
                        thread3.start();

                        //Thread for Monitoring User Request Runs that are due but not running
                        // and starting their appropriate process runners
                        thread4.setDaemon(true);
                        thread4.setName("ThreadFour");
                        thread4.setPriority(Thread.MIN_PRIORITY);
                        //System.out.println("Starting ThreadFour thread...");
                        thread4.start();

                        //Thread for Generating Run Requests for Scheduled Alerts
                        thread7 = new MntrSchdldAlertsNtRnngfunc("ThreadSeven");
                        thread7.setDaemon(true);
                        thread7.setName("ThreadSeven");
                        thread7.setPriority(Thread.MIN_PRIORITY);
                        //System.out.println("Starting ThreadSeven thread...");
                        thread7.start();

                        //Thread for Running Requests for User Initiated Alerts
                        thread8 = new MntrUserAlertsNtRnngfunc("ThreadEight");
                        thread8.setDaemon(true);
                        thread8.setName("ThreadEight");
                        thread8.setPriority(Thread.MIN_PRIORITY);
                        //System.out.println("Starting ThreadEight thread...");
                        thread8.start();
                    }
                } else {
                    //Thread for running the actual Code behind the Request Run if this is the
                    //Program supposed to run that request
                    //i.e. if Global.runID >0
                    Global.minimizeMemory();
                    if (Global.runID > 0) {
                        thread1 = new RqstLstnrUpdtrfunc("ThreadOne");
                        thread1.setDaemon(true);
                        thread1.setName("ThreadOne");
                        thread1.setPriority(Thread.MIN_PRIORITY);
                        //System.out.println("Starting ThreadOne thread...");
                        thread1.start();

                        thread5 = new RunActualRqtsfunc("ThreadFive");
                        thread5.setDaemon(true);
                        thread5.setName("ThreadFive");
                        //System.out.println("Starting ThreadFive thread...");
                        if (rnnPryty.equals("1-Highest")) {
                            thread1.setPriority(Thread.MAX_PRIORITY);
                        } else if (rnnPryty.equals("2-AboveNormal")) {
                            thread1.setPriority(7);
                        } else if (rnnPryty.equals("3-Normal")) {
                            thread1.setPriority(Thread.NORM_PRIORITY);
                        } else if (rnnPryty.equals("4-BelowNormal")) {
                            thread1.setPriority(3);
                        } else {
                            thread1.setPriority(1);
                        }
                        thread5.start();
                    }
                    // Allow counting for 10 seconds.
                    //Thread.Sleep(1000);
                }
            }
        }
    } catch (NumberFormatException ex) {
        Global.errorLog = ex.getMessage() + System.getProperty("line.separator")
                + Arrays.toString(ex.getStackTrace());
        String fileLoc = Global.rnnrsBasDir + "/log_files/";
        Date dNow = new Date();
        SimpleDateFormat ft = new SimpleDateFormat("ddMMMyyyyHHmmss");
        fileLoc += "Global.errorLog" + ft.format(dNow.getTime()) + ".rho";
        PrintWriter fileWriter;
        try {
            fileWriter = new PrintWriter(fileLoc, "UTF-8");
            fileWriter.println(Global.errorLog);
            fileWriter.close();
        } catch (FileNotFoundException ex1) {
            Logger.getLogger(Program.class.getName()).log(Level.SEVERE, null, ex1);
        } catch (UnsupportedEncodingException ex1) {
            Logger.getLogger(Program.class.getName()).log(Level.SEVERE, null, ex1);
        }
        killThreads();
    } catch (SQLException ex) {
        Global.errorLog = ex.getMessage() + System.getProperty("line.separator")
                + Arrays.toString(ex.getStackTrace());
        String fileLoc = Global.rnnrsBasDir + "/log_files/";
        Date dNow = new Date();
        SimpleDateFormat ft = new SimpleDateFormat("ddMMMyyyyHHmmss");
        fileLoc += "Global.errorLog" + ft.format(dNow.getTime()) + ".rho";
        PrintWriter fileWriter;
        try {
            fileWriter = new PrintWriter(fileLoc, "UTF-8");
            fileWriter.println(Global.errorLog);
            fileWriter.close();
        } catch (FileNotFoundException ex1) {
            Logger.getLogger(Program.class.getName()).log(Level.SEVERE, null, ex1);
        } catch (UnsupportedEncodingException ex1) {
            Logger.getLogger(Program.class.getName()).log(Level.SEVERE, null, ex1);
        }
        killThreads();
    } finally {

    }
}