Example usage for java.lang String join

List of usage examples for java.lang String join

Introduction

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

Prototype

public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements) 

Source Link

Document

Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter .

Usage

From source file:org.elasticsearch.client.RequestConvertersTests.java

public void testClearCache() {
    String[] indices = randomBoolean() ? null : randomIndicesNames(0, 5);
    ClearIndicesCacheRequest clearIndicesCacheRequest;
    if (randomBoolean()) {
        clearIndicesCacheRequest = new ClearIndicesCacheRequest(indices);
    } else {/*  ww  w  .j  a  v a  2  s  .  co m*/
        clearIndicesCacheRequest = new ClearIndicesCacheRequest();
        clearIndicesCacheRequest.indices(indices);
    }
    Map<String, String> expectedParams = new HashMap<>();
    setRandomIndicesOptions(clearIndicesCacheRequest::indicesOptions, clearIndicesCacheRequest::indicesOptions,
            expectedParams);
    if (randomBoolean()) {
        clearIndicesCacheRequest.queryCache(randomBoolean());
    }
    expectedParams.put("query", Boolean.toString(clearIndicesCacheRequest.queryCache()));
    if (randomBoolean()) {
        clearIndicesCacheRequest.fieldDataCache(randomBoolean());
    }
    expectedParams.put("fielddata", Boolean.toString(clearIndicesCacheRequest.fieldDataCache()));
    if (randomBoolean()) {
        clearIndicesCacheRequest.requestCache(randomBoolean());
    }
    expectedParams.put("request", Boolean.toString(clearIndicesCacheRequest.requestCache()));
    if (randomBoolean()) {
        clearIndicesCacheRequest.fields(randomIndicesNames(1, 5));
        expectedParams.put("fields", String.join(",", clearIndicesCacheRequest.fields()));
    }

    Request request = RequestConverters.clearCache(clearIndicesCacheRequest);
    StringJoiner endpoint = new StringJoiner("/", "/", "");
    if (indices != null && indices.length > 0) {
        endpoint.add(String.join(",", indices));
    }
    endpoint.add("_cache/clear");
    assertThat(request.getEndpoint(), equalTo(endpoint.toString()));
    assertThat(request.getParameters(), equalTo(expectedParams));
    assertThat(request.getEntity(), nullValue());
    assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME));
}

From source file:com.hortonworks.historian.nifi.reporter.HistorianDeanReporter.java

private void indexLateData(List<String> dataSourceExclusions) {
    String nifiControllersUrl = nifiUrl + "/nifi-api/flow/process-groups/root/controller-services";

    try {//from w  w w  .  jav a 2 s . co m
        JSONArray controllers = getJSONFromUrl(nifiControllersUrl, basicAuth)
                .getJSONArray("controllerServices");
        getLogger().info("********** Getting List of Druid Tranquility Controllers...");
        for (int i = 0; i < controllers.length(); i++) {
            JSONObject currentController = controllers.getJSONObject(i).getJSONObject("component");
            String currentControllerType = currentController.getString("type");
            if (currentControllerType
                    .equalsIgnoreCase("com.hortonworks.nifi.controller.DruidTranquilityController")) {
                String lateDataPath = lateDataRoot + "/" + currentController.getJSONObject("properties")
                        .getString("query_granularity").toLowerCase() + "/";
                getLogger().info("********** Checking for Late Arriving Data at HDFS Path: " + lateDataPath);
                if (fs.exists(new Path(lateDataPath))) {
                    FileStatus[] fileStatus = fs.listStatus(new Path(lateDataPath));
                    List<Date> dates = new ArrayList<Date>();
                    List<String> sourceData = new ArrayList<String>();
                    for (FileStatus status : fileStatus) {
                        String[] address = status.getPath().toString().split("/");
                        String currentBin = address[address.length - 1];
                        Date binDate = new SimpleDateFormat("yyyy-MM-dd-HH-mm").parse(currentBin);
                        sourceData.add(lateDataPath + currentBin);
                        dates.add(binDate);
                    }
                    ((Collection<?>) sourceData).removeAll(dataSourceExclusions);
                    getLogger().info("********** Detected " + sourceData.size()
                            + " bins of relevant late data, initiating Delta Indexing task...");

                    if (fileStatus.length > 0 && sourceData.size() > 0) {
                        String intervalStart = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
                                .format(Collections.min(dates));
                        String intervalEnd = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
                                .format(Collections.max(dates));
                        String bins = String.join(",", sourceData);
                        JSONArray dimensionsList = new JSONArray(Arrays.asList(currentController
                                .getJSONObject("properties").getString("dimensions_list").split(",")));
                        String ingestSpec = "{" + "     \"type\" : \"index_hadoop\"," + "     \"spec\" : {"
                                + "      \"dataSchema\" : {" + "         \"dataSource\": \""
                                + currentController.getJSONObject("properties").getString("data_source") + "\","
                                + "         \"parser\" : {" + "            \"type\" : \"hadoopyString\","
                                + "            \"parseSpec\" : {" + "               \"format\" : \"json\","
                                + "               \"timestampSpec\" : {" + "                  \"column\" : \""
                                + currentController.getJSONObject("properties").getString("timestamp_field")
                                + "\"," + "                  \"format\" : \"auto\"" + "               },"
                                + "               \"dimensionsSpec\" : {" + "                  \"dimensions\": "
                                + dimensionsList + "               }" + "            }" + "         },"
                                + "         \"metricsSpec\" : "
                                + currentController.getJSONObject("properties")
                                        .getString("aggregators_descriptor")
                                + "," + "         \"granularitySpec\" : {"
                                + "            \"type\" : \"uniform\","
                                + "            \"segmentGranularity\" : \""
                                + currentController.getJSONObject("properties").getString("segment_granularity")
                                + "\"," + "            \"queryGranularity\" : \""
                                + currentController.getJSONObject("properties").getString("query_granularity")
                                + "\"," + "            \"intervals\": [\"" + intervalStart + "/" + intervalEnd
                                + "\"]" + "         }" + "      }," + "      \"ioConfig\" : {"
                                + "         \"type\" : \"hadoop\"," + "         \"inputSpec\" : {"
                                + "            \"type\" : \"multi\"," + "            \"children\": ["
                                + "               {" + "                  \"type\" : \"dataSource\","
                                + "                  \"ingestionSpec\" : {"
                                + "                     \"dataSource\": \""
                                + currentController.getJSONObject("properties").getString("data_source") + "\","
                                + "                     \"intervals\": [\"" + intervalStart + "/" + intervalEnd
                                + "\"]" + "                  }" + "               }," + "               {"
                                + "                  \"type\" : \"static\"," + "                  \"paths\": \""
                                + bins + "\"" + "               }" + "            ]" + "         }" + "      },"
                                + "      \"tuningConfig\" : {" + "         \"type\": \"hadoop\"" + "      }"
                                + "     }" + "}";
                        getLogger().info("********** Delta Ingestion Spec: " + ingestSpec);
                        String indexTaskId = createDruidIndexingTask(ingestSpec);
                        getLogger().info("********** Created Indexing Task " + indexTaskId);
                        Map<String, Object> currentTaskMetaData = new HashMap<String, Object>();
                        currentTaskMetaData.put("ingestSpec", ingestSpec);
                        currentTaskMetaData.put("sourceData", sourceData);
                        deltaIndexTasks.put(indexTaskId, currentTaskMetaData);
                        String currentTaskDirPath = lateDataTasksPath + "/" + indexTaskId.replace(":", "__");
                        getLogger().info("********** Persisting Record of Task: " + currentTaskDirPath);
                        currentTaskDirPath = createHDFSDirectory(currentTaskDirPath);
                        writeHDFSFile(currentTaskDirPath + "/ingestSpec", ingestSpec);
                        writeHDFSFile(currentTaskDirPath + "/sourceData", bins);
                    } else {
                        getLogger().info("********** " + lateDataPath + " does not contain any data...");
                    }
                } else {
                    getLogger().info("********** There is a Druid Controller mapped to " + lateDataPath
                            + ", however, the path does not yet exist...");
                }
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ParseException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:io.siddhi.doc.gen.core.utils.DocumentationUtils.java

/**
 * Executing a command/*from  w w  w  . j a v a 2 s. co  m*/
 *
 * @param command The command to be executed
 * @param logger  The maven plugin logger
 * @return The output lines from executing the command
 * @throws Throwable if any error occurs during the execution of the command
 */
private static List<String> getCommandOutput(String[] command, Log logger) throws Throwable {
    logger.info("Executing: " + String.join(" ", command));
    Process process = Runtime.getRuntime().exec(command);
    List<String> executionOutputLines = new ArrayList<>();

    // Logging the output of the command execution
    InputStream[] inputStreams = new InputStream[] { process.getInputStream(), process.getErrorStream() };
    BufferedReader bufferedReader = null;
    try {
        for (InputStream inputStream : inputStreams) {
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream, Constants.DEFAULT_CHARSET));
            String commandOutput;
            while (true) {
                commandOutput = bufferedReader.readLine();
                if (commandOutput == null) {
                    break;
                }

                executionOutputLines.add(commandOutput);
            }
        }
        process.waitFor();
    } finally {
        IOUtils.closeQuietly(bufferedReader);
    }

    return executionOutputLines;
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopWindow.java

@Override
public String getStyleName() {
    return String.join(" ", styles);
}

From source file:net.sf.jabref.gui.BasePanel.java

private void copyCiteKey() {
    List<BibEntry> bes = mainTable.getSelectedEntries();
    if (!bes.isEmpty()) {
        storeCurrentEdit();// w  ww .  j  av  a  2s .  c o m
        List<String> keys = new ArrayList<>(bes.size());
        // Collect all non-null keys.
        for (BibEntry be : bes) {
            if (be.getCiteKey() != null) {
                keys.add(be.getCiteKey());
            }
        }
        if (keys.isEmpty()) {
            output(Localization.lang("None of the selected entries have BibTeX keys."));
            return;
        }

        String sb = String.join(",", keys);
        StringSelection ss = new StringSelection("\\cite{" + sb + '}');
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, BasePanel.this);

        if (keys.size() == bes.size()) {
            // All entries had keys.
            output(bes.size() > 1 ? Localization.lang("Copied keys") : Localization.lang("Copied key") + '.');
        } else {
            output(Localization.lang("Warning: %0 out of %1 entries have undefined BibTeX key.",
                    Integer.toString(bes.size() - keys.size()), Integer.toString(bes.size())));
        }
    }
}

From source file:net.sf.jabref.gui.BasePanel.java

private void copyKey() {
    List<BibEntry> bes = mainTable.getSelectedEntries();
    if (!bes.isEmpty()) {
        storeCurrentEdit();//w  w w .  java  2  s.com
        List<String> keys = new ArrayList<>(bes.size());
        // Collect all non-null keys.
        for (BibEntry be : bes) {
            if (be.getCiteKey() != null) {
                keys.add(be.getCiteKey());
            }
        }
        if (keys.isEmpty()) {
            output(Localization.lang("None of the selected entries have BibTeX keys."));
            return;
        }

        StringSelection ss = new StringSelection(String.join(",", keys));
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, BasePanel.this);

        if (keys.size() == bes.size()) {
            // All entries had keys.
            output((bes.size() > 1 ? Localization.lang("Copied keys") : Localization.lang("Copied key")) + '.');
        } else {
            output(Localization.lang("Warning: %0 out of %1 entries have undefined BibTeX key.",
                    Integer.toString(bes.size() - keys.size()), Integer.toString(bes.size())));
        }
    }
}

From source file:servlets.SearchServlet.java

/**
 * Handles the HTTP <code>POST</code> method.
 *
 * @param request servlet request//from   ww  w.  j a v  a  2s  .  c  o  m
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    /**********************************************************************/
    // Initializing connection and search regardless of search type (may move)
    /**********************************************************************/
    Connection conn = null;
    try {
        conn = ClassSearcher.classSearch();
    } catch (URISyntaxException ex) {
        Logger.getLogger(SearchServlet.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(SearchServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
    Search searcher;

    /**********************************************************************/
    // getting parameters here regardless of search type
    /**********************************************************************/

    String college = request.getParameter("college_value").toLowerCase();
    String term = request.getParameter("term_value");
    String dept = request.getParameter("dept_value");
    String course_num = request.getParameter("course_num_value");
    String keyword = request.getParameter("keyword_value");
    String prof = request.getParameter("prof_value");
    int id_num = Integer.parseInt(request.getParameter("id_num"));

    System.out.println(term);

    MatchValuePair mvpair = null;
    if (!"".equals(course_num)) {
        mvpair = new MatchValuePair(ID.contains, course_num);
    }

    if ("".equals(keyword))
        keyword = null;
    if ("".equals(prof))
        prof = null;

    boolean[] findErrors = new boolean[] { false, false, false };

    System.out.println(request.getParameter("search_type"));

    if (request.getParameter("search_type").equals("DEFAULT_SEARCH")) {

        searcher = Search.createSearch(conn, id_num, college.toUpperCase(), term);

        searcher.find(mvpair, null, null, keyword, prof, new int[] {},
                ("none".equalsIgnoreCase(dept)) ? null : Arrays.asList(new String[] { dept }), findErrors);
        /******************************************************************/
        // Response parsing -- leave this to Ashley unless you're testing
        //  If you're testing, remember to change the table names where relevant
        //      ex: bestfit, someconflicts, etc
        /******************************************************************/

        response.setContentType("text/html");
        response.setHeader("Cache-Control", "no-cache");
        college = college.toLowerCase();

        String query1 = "select * into combined_section_table_" + id_num + " from " + searcher.tableName()
                + " left join college_courses" + college + " on " + searcher.tableName()
                + ".cdept = college_courses" + college + ".dept and " + searcher.tableName()
                + ".cnbr = college_courses" + college + ".nbr;";

        String query2 = "alter table combined_section_table_" + id_num + " drop column dept";
        String query3 = "alter table combined_section_table_" + id_num + " drop column nbr";
        String query4 = "select * from combined_section_table_" + id_num;
        String query5 = "drop table combined_section_table_" + id_num;
        String query6 = "drop table " + searcher.tableName();

        PreparedStatement preparedStatement;
        ResultSet resultSet;

        try {

            preparedStatement = conn.prepareStatement(query1);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query2);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query3);
            preparedStatement.execute();

            preparedStatement = conn.prepareStatement(query4);
            resultSet = preparedStatement.executeQuery();
            response.getWriter().write(
                    "ERRORS_BEGIN" + findErrors[0] + "," + findErrors[1] + "," + findErrors[2] + "ERRORS_END");
            while (resultSet.next()) {
                response.getWriter().write("Dept~" + resultSet.getString("cdept") + "FIELD_END");
                response.getWriter().write("CNum~" + resultSet.getString("cnbr") + "FIELD_END");
                response.getWriter().write("Name~" + resultSet.getString("name") + "FIELD_END");
                response.getWriter().write("Comp~" + resultSet.getString("components") + "FIELD_END");
                response.getWriter().write("Req~" + resultSet.getString("requirements") + "FIELD_END");
                response.getWriter().write("Desc~" + resultSet.getString("description") + "FIELD_END");
                response.getWriter().write("SNum~" + resultSet.getString("sec") + "FIELD_END");
                response.getWriter().write("STime~" + resultSet.getString("starttime") + "FIELD_END");
                response.getWriter().write("ETime~" + resultSet.getString("endtime") + "FIELD_END");
                response.getWriter().write("Days~" + resultSet.getString("days") + "FIELD_END");
                response.getWriter().write("Room~" + resultSet.getString("room") + "FIELD_END");
                response.getWriter().write("Inst~" + resultSet.getString("instructor") + "FIELD_END");
                response.getWriter().write("Flag~" + resultSet.getString("open") + "FIELD_END");
                response.getWriter().write("Cr~" + resultSet.getString("credits") + "FIELD_END" + "ENTRY_END");
            }
            preparedStatement = conn.prepareStatement(query5);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query6);
            preparedStatement.execute();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    /**********************************************************************/
    // Time focused search
    /**********************************************************************/
    else if (request.getParameter("search_type").equals("TIME_FOCUSED_SEARCH")) {

        /**********************************************************************/
        // parsing of parameters specific to this search goes here
        /**********************************************************************/

        Schedule schedule = new Schedule();
        putTimeSlotsInSched(schedule, request);

        /**********************************************************************/
        // Finds go here
        /**********************************************************************/
        searcher = Search.createSearch(conn, id_num, college.toUpperCase(), term);

        /* since time-focused searches cannot be run 
         *  without selecting some open block,
         *  find() is guaranteed to be called at least once
         *  and create the table
         */
        Day day;
        Pair time;
        for (int i = 0; i < schedule.getSize(); ++i) {
            day = schedule.getElementFromSchedule(i);
            for (int t = 0; t < day.getOpenTimeSize(); ++t) {
                time = day.getOpenTimeElement(t);
                searcher.find(null, time.X(), time.Y(), null, null, new int[] { day.getDay() }, null,
                        findErrors);
            }
        }

        /**********************************************************************/
        // Sorting goes here
        /**********************************************************************/

        assignPts(conn, sort_reqs(parseJSON(request.getParameter("reqs"))), schedule, searcher, true);
        createPtBasedTables(conn, searcher, id_num);

        /**********************************************************************/
        // Response parsing
        //  uncomment this when search/sort is functional
        /**********************************************************************/

        response.setContentType("text/html");
        response.setHeader("Cache-Control", "no-cache");
        college = college.toLowerCase();

        String queryBF;
        queryBF = "select * into combined_section_table_" + id_num + " from " + "best_fit_" + id_num
                + " left join college_courses" + college + " on " + "best_fit_" + id_num
                + ".cdept = college_courses" + college + ".dept and " + "best_fit_" + id_num
                + ".cnbr = college_courses" + college + ".nbr;";

        String querySC;
        querySC = "select * into combined_section_table_" + id_num + " from " + "some_conflicts_" + id_num
                + " left join college_courses" + college + " on " + "some_conflicts_" + id_num
                + ".cdept = college_courses" + college + ".dept and " + "some_conflicts_" + id_num
                + ".cnbr = college_courses" + college + ".nbr;";

        String queryO;
        queryO = "select * into combined_section_table_" + id_num + " from " + "others_" + id_num
                + " left join college_courses" + college + " on " + "others_" + id_num
                + ".cdept = college_courses" + college + ".dept and " + "others_" + id_num
                + ".cnbr = college_courses" + college + ".nbr;";

        String query1 = "alter table combined_section_table_" + id_num + " drop column dept";
        String query2 = "alter table combined_section_table_" + id_num + " drop column nbr";
        String query3 = "select * from combined_section_table_" + id_num;
        String query4 = "drop table combined_section_table_" + id_num;

        String queryBFDrop = "drop table " + "best_fit_" + id_num;
        String querySCDrop = "drop table " + "some_conflicts_" + id_num;
        String queryODrop = "drop table " + "others_" + id_num;
        String querySectionsDrop = "drop table " + searcher.tableName();

        PreparedStatement preparedStatement;
        ResultSet resultSet;

        try {
            // BEST FIT RESPONSE
            preparedStatement = conn.prepareStatement(queryBF);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query1);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query2);
            preparedStatement.execute();

            preparedStatement = conn.prepareStatement(query3);
            resultSet = preparedStatement.executeQuery();
            response.getWriter().write(
                    "ERRORS_BEGIN" + findErrors[0] + "," + findErrors[1] + "," + findErrors[2] + "ERRORS_END");
            response.getWriter().write("BEST_FIT_START");
            while (resultSet.next()) {
                response.getWriter().write("Dept~" + resultSet.getString("cdept") + "FIELD_END");
                response.getWriter().write("CNum~" + resultSet.getString("cnbr") + "FIELD_END");
                response.getWriter().write("Name~" + resultSet.getString("name") + "FIELD_END");
                response.getWriter().write("Comp~" + resultSet.getString("components") + "FIELD_END");
                response.getWriter().write("Req~" + resultSet.getString("requirements") + "FIELD_END");
                response.getWriter().write("Desc~" + resultSet.getString("description") + "FIELD_END");
                response.getWriter().write("SNum~" + resultSet.getString("sec") + "FIELD_END");
                response.getWriter().write("STime~" + resultSet.getString("starttime") + "FIELD_END");
                response.getWriter().write("ETime~" + resultSet.getString("endtime") + "FIELD_END");
                response.getWriter().write("Days~" + resultSet.getString("days") + "FIELD_END");
                response.getWriter().write("Room~" + resultSet.getString("room") + "FIELD_END");
                response.getWriter().write("Inst~" + resultSet.getString("instructor") + "FIELD_END");
                response.getWriter().write("Flag~" + resultSet.getString("open") + "FIELD_END");
                response.getWriter().write("Cr~" + resultSet.getString("credits") + "FIELD_END" + "ENTRY_END");
            }
            response.getWriter().write("BEST_FIT_END");
            preparedStatement = conn.prepareStatement(query4);
            preparedStatement.execute();

            // SOME CONFLICTS RESPONSE
            preparedStatement = conn.prepareStatement(querySC);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query1);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query2);
            preparedStatement.execute();

            preparedStatement = conn.prepareStatement(query3);
            resultSet = preparedStatement.executeQuery();

            response.getWriter().write("SOME_CONFLICTS_START");
            while (resultSet.next()) {
                response.getWriter().write("Dept~" + resultSet.getString("cdept") + "FIELD_END");
                response.getWriter().write("CNum~" + resultSet.getString("cnbr") + "FIELD_END");
                response.getWriter().write("Name~" + resultSet.getString("name") + "FIELD_END");
                response.getWriter().write("Comp~" + resultSet.getString("components") + "FIELD_END");
                response.getWriter().write("Req~" + resultSet.getString("requirements") + "FIELD_END");
                response.getWriter().write("Desc~" + resultSet.getString("description") + "FIELD_END");
                response.getWriter().write("SNum~" + resultSet.getString("sec") + "FIELD_END");
                response.getWriter().write("STime~" + resultSet.getString("starttime") + "FIELD_END");
                response.getWriter().write("ETime~" + resultSet.getString("endtime") + "FIELD_END");
                response.getWriter().write("Days~" + resultSet.getString("days") + "FIELD_END");
                response.getWriter().write("Room~" + resultSet.getString("room") + "FIELD_END");
                response.getWriter().write("Inst~" + resultSet.getString("instructor") + "FIELD_END");
                response.getWriter().write("Flag~" + resultSet.getString("open") + "FIELD_END");
                response.getWriter().write("Cr~" + resultSet.getString("credits") + "FIELD_END" + "ENTRY_END");
            }
            response.getWriter().write("SOME_CONFLICTS_END");
            preparedStatement = conn.prepareStatement(query4);
            preparedStatement.execute();

            // OTHERS RESPONSE
            preparedStatement = conn.prepareStatement(queryO);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query1);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query2);
            preparedStatement.execute();

            preparedStatement = conn.prepareStatement(query3);
            resultSet = preparedStatement.executeQuery();

            response.getWriter().write("OTHERS_START");
            while (resultSet.next()) {
                response.getWriter().write("Dept~" + resultSet.getString("cdept") + "FIELD_END");
                response.getWriter().write("CNum~" + resultSet.getString("cnbr") + "FIELD_END");
                response.getWriter().write("Name~" + resultSet.getString("name") + "FIELD_END");
                response.getWriter().write("Comp~" + resultSet.getString("components") + "FIELD_END");
                response.getWriter().write("Req~" + resultSet.getString("requirements") + "FIELD_END");
                response.getWriter().write("Desc~" + resultSet.getString("description") + "FIELD_END");
                response.getWriter().write("SNum~" + resultSet.getString("sec") + "FIELD_END");
                response.getWriter().write("STime~" + resultSet.getString("starttime") + "FIELD_END");
                response.getWriter().write("ETime~" + resultSet.getString("endtime") + "FIELD_END");
                response.getWriter().write("Days~" + resultSet.getString("days") + "FIELD_END");
                response.getWriter().write("Room~" + resultSet.getString("room") + "FIELD_END");
                response.getWriter().write("Inst~" + resultSet.getString("instructor") + "FIELD_END");
                response.getWriter().write("Flag~" + resultSet.getString("open") + "FIELD_END");
                response.getWriter().write("Cr~" + resultSet.getString("credits") + "FIELD_END" + "ENTRY_END");
            }
            response.getWriter().write("OTHERS_END");
            preparedStatement = conn.prepareStatement(query4);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(queryODrop);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(queryBFDrop);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(querySCDrop);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(querySectionsDrop);
            preparedStatement.execute();
        } catch (SQLException e) {

            e.printStackTrace();
        }

    }

    /**********************************************************************/
    // Requirement focused search
    /**********************************************************************/
    else if (request.getParameter("search_type").equals("REQ_FOCUSED_SEARCH")) {

        Schedule schedule = new Schedule();
        putTimeSlotsInSched(schedule, request);

        /**********************************************************************/
        // parsing of parameters specific to this search goes here
        /**********************************************************************/

        // find all unique departments and get all courses from them 
        // to cut down on search time
        searcher = Search.createSearch(conn, id_num, college.toUpperCase(), term);

        HashMap<String, List<JSONObject>> reqs_by_dept = sort_reqs(parseJSON(request.getParameter("reqs")));

        /**********************************************************************/
        // Finds go here
        /**********************************************************************/

        // check for entries with only one course number
        // search for each by itself
        // it takes the same amount of time search-wise
        // and results are more specific
        for (Entry<String, List<JSONObject>> entry : reqs_by_dept.entrySet()) {
            if (entry.getValue().size() == 1) {
                MatchValuePair courseNumber;
                try {
                    JSONObject req = entry.getValue().get(0);
                    String cnum;
                    // check if cnum is null (ie. ANY course from dept)
                    try {
                        cnum = Integer.toString(req.getInt("cnum"));
                    } catch (JSONException e) {
                        cnum = null;
                    }
                    if (req.getBoolean("hasAt")) {
                        // any cnum
                        if (null == cnum) {
                            courseNumber = null;
                        } else {
                            // this is contains and not beginsWith 
                            // but it's as close as it gets
                            // we'll drop the rest later, anyway
                            courseNumber = new MatchValuePair(ID.contains, cnum);
                        }
                    } else {
                        courseNumber = new MatchValuePair(ID.exact, cnum);
                    }
                    searcher.find(courseNumber, null, null, null, null, null,
                            Arrays.asList(new String[] { entry.getKey() }), findErrors);
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }
        }

        // get departments with more than one course
        List<String> others = reqs_by_dept.entrySet().stream().filter(en -> en.getValue().size() > 1)
                .map(Entry::getKey).collect(Collectors.toList());

        searcher.find(null, null, null, null, null, null, others, findErrors);

        /**********************************************************************/
        // Sorting goes here
        /**********************************************************************/

        // delete any rows that aren't actually requirements

        // get all 1-course depts where hasAt is true and cnum is not null
        // since contains is not foolproof
        for (Entry<String, List<JSONObject>> entry : reqs_by_dept.entrySet()) {
            if (entry.getValue().size() == 1) {
                try {
                    JSONObject obj = entry.getValue().get(0);
                    if (obj.getBoolean("hasAt") && obj.get("cnum") != JSONObject.NULL) {
                        others.add(entry.getKey());
                    }
                } catch (JSONException e) {
                    continue;
                }
            }
        }

        PreparedStatement delete;
        for (String department : others) {
            // courses to keep
            List<JSONObject> courses = reqs_by_dept.get(department);
            // the conditions to be and'ed together
            String[] conditions = new String[courses.size()];

            for (int i = 0; i < courses.size(); ++i) {
                try {
                    String cnum = Integer.toString(courses.get(i).getInt("cnum"));
                    if (courses.get(i).getBoolean("hasAt")) {
                        conditions[i] = "cnbr NOT LIKE '" + cnum + "%'";
                    } else {
                        conditions[i] = "cnbr!='" + cnum + "'";
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                    conditions[i] = "";
                }
            }

            String ands = String.join(" AND ", conditions);
            try {
                delete = conn.prepareStatement(
                        "DELETE FROM " + searcher.tableName() + " WHERE " + "cdept=? AND " + ands + ";");
                delete.setString(1, department);
                delete.executeUpdate();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        // check if any requirements fall within closed times
        assignPts(conn, sort_reqs(parseJSON(request.getParameter("reqs"))), schedule, searcher, false);
        createPtBasedTables(conn, searcher, id_num);

        /**********************************************************************/
        // Response parsing
        //  uncomment this when search/sort is functional
        /**********************************************************************/

        response.setContentType("text/html");
        response.setHeader("Cache-Control", "no-cache");
        college = college.toLowerCase();

        String queryBF;
        queryBF = "select * into combined_section_table_" + id_num + " from " + "best_fit_" + id_num
                + " left join college_courses" + college + " on " + "best_fit_" + id_num
                + ".cdept = college_courses" + college + ".dept and " + "best_fit_" + id_num
                + ".cnbr = college_courses" + college + ".nbr;";

        String querySC;
        querySC = "select * into combined_section_table_" + id_num + " from " + "some_conflicts_" + id_num
                + " left join college_courses" + college + " on " + "some_conflicts_" + id_num
                + ".cdept = college_courses" + college + ".dept and " + "some_conflicts_" + id_num
                + ".cnbr = college_courses" + college + ".nbr;";

        String queryO;
        queryO = "select * into combined_section_table_" + id_num + " from " + "others_" + id_num
                + " left join college_courses" + college + " on " + "others_" + id_num
                + ".cdept = college_courses" + college + ".dept and " + "others_" + id_num
                + ".cnbr = college_courses" + college + ".nbr;";

        String query1 = "alter table combined_section_table_" + id_num + " drop column dept";
        String query2 = "alter table combined_section_table_" + id_num + " drop column nbr";
        String query3 = "select * from combined_section_table_" + id_num;
        String query4 = "drop table combined_section_table_" + id_num;

        String queryBFDrop = "drop table " + "best_fit_" + id_num;
        String querySCDrop = "drop table " + "some_conflicts_" + id_num;
        String queryODrop = "drop table " + "others_" + id_num;
        String querySectionsDrop = "drop table " + searcher.tableName();

        PreparedStatement preparedStatement;
        ResultSet resultSet;

        try {
            // BEST FIT RESPONSE
            preparedStatement = conn.prepareStatement(queryBF);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query1);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query2);
            preparedStatement.execute();

            preparedStatement = conn.prepareStatement(query3);
            resultSet = preparedStatement.executeQuery();
            response.getWriter().write(
                    "ERRORS_BEGIN" + findErrors[0] + "," + findErrors[1] + "," + findErrors[2] + "ERRORS_END");

            response.getWriter().write("BEST_FIT_START");
            while (resultSet.next()) {
                response.getWriter().write("Dept~" + resultSet.getString("cdept") + "FIELD_END");
                response.getWriter().write("CNum~" + resultSet.getString("cnbr") + "FIELD_END");
                response.getWriter().write("Name~" + resultSet.getString("name") + "FIELD_END");
                response.getWriter().write("Comp~" + resultSet.getString("components") + "FIELD_END");
                response.getWriter().write("Req~" + resultSet.getString("requirements") + "FIELD_END");
                response.getWriter().write("Desc~" + resultSet.getString("description") + "FIELD_END");
                response.getWriter().write("SNum~" + resultSet.getString("sec") + "FIELD_END");
                response.getWriter().write("STime~" + resultSet.getString("starttime") + "FIELD_END");
                response.getWriter().write("ETime~" + resultSet.getString("endtime") + "FIELD_END");
                response.getWriter().write("Days~" + resultSet.getString("days") + "FIELD_END");
                response.getWriter().write("Room~" + resultSet.getString("room") + "FIELD_END");
                response.getWriter().write("Inst~" + resultSet.getString("instructor") + "FIELD_END");
                response.getWriter().write("Flag~" + resultSet.getString("open") + "FIELD_END");
                response.getWriter().write("Cr~" + resultSet.getString("credits") + "FIELD_END" + "ENTRY_END");
            }
            response.getWriter().write("BEST_FIT_END");
            preparedStatement = conn.prepareStatement(query4);
            preparedStatement.execute();

            // SOME CONFLICTS RESPONSE
            preparedStatement = conn.prepareStatement(querySC);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query1);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query2);
            preparedStatement.execute();

            preparedStatement = conn.prepareStatement(query3);
            resultSet = preparedStatement.executeQuery();

            response.getWriter().write("SOME_CONFLICTS_START");
            while (resultSet.next()) {
                response.getWriter().write("Dept~" + resultSet.getString("cdept") + "FIELD_END");
                response.getWriter().write("CNum~" + resultSet.getString("cnbr") + "FIELD_END");
                response.getWriter().write("Name~" + resultSet.getString("name") + "FIELD_END");
                response.getWriter().write("Comp~" + resultSet.getString("components") + "FIELD_END");
                response.getWriter().write("Req~" + resultSet.getString("requirements") + "FIELD_END");
                response.getWriter().write("Desc~" + resultSet.getString("description") + "FIELD_END");
                response.getWriter().write("SNum~" + resultSet.getString("sec") + "FIELD_END");
                response.getWriter().write("STime~" + resultSet.getString("starttime") + "FIELD_END");
                response.getWriter().write("ETime~" + resultSet.getString("endtime") + "FIELD_END");
                response.getWriter().write("Days~" + resultSet.getString("days") + "FIELD_END");
                response.getWriter().write("Room~" + resultSet.getString("room") + "FIELD_END");
                response.getWriter().write("Inst~" + resultSet.getString("instructor") + "FIELD_END");
                response.getWriter().write("Flag~" + resultSet.getString("open") + "FIELD_END");
                response.getWriter().write("Cr~" + resultSet.getString("credits") + "FIELD_END" + "ENTRY_END");
            }
            response.getWriter().write("SOME_CONFLICTS_END");
            preparedStatement = conn.prepareStatement(query4);
            preparedStatement.execute();

            // OTHERS RESPONSE
            preparedStatement = conn.prepareStatement(queryO);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query1);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(query2);
            preparedStatement.execute();

            preparedStatement = conn.prepareStatement(query3);
            resultSet = preparedStatement.executeQuery();

            response.getWriter().write("OTHERS_START");
            while (resultSet.next()) {
                response.getWriter().write("Dept~" + resultSet.getString("cdept") + "FIELD_END");
                response.getWriter().write("CNum~" + resultSet.getString("cnbr") + "FIELD_END");
                response.getWriter().write("Name~" + resultSet.getString("name") + "FIELD_END");
                response.getWriter().write("Comp~" + resultSet.getString("components") + "FIELD_END");
                response.getWriter().write("Req~" + resultSet.getString("requirements") + "FIELD_END");
                response.getWriter().write("Desc~" + resultSet.getString("description") + "FIELD_END");
                response.getWriter().write("SNum~" + resultSet.getString("sec") + "FIELD_END");
                response.getWriter().write("STime~" + resultSet.getString("starttime") + "FIELD_END");
                response.getWriter().write("ETime~" + resultSet.getString("endtime") + "FIELD_END");
                response.getWriter().write("Days~" + resultSet.getString("days") + "FIELD_END");
                response.getWriter().write("Room~" + resultSet.getString("room") + "FIELD_END");
                response.getWriter().write("Inst~" + resultSet.getString("instructor") + "FIELD_END");
                response.getWriter().write("Flag~" + resultSet.getString("open") + "FIELD_END");
                response.getWriter().write("Cr~" + resultSet.getString("credits") + "FIELD_END" + "ENTRY_END");
            }
            response.getWriter().write("OTHERS_END");
            preparedStatement = conn.prepareStatement(query4);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(queryODrop);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(queryBFDrop);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(querySCDrop);
            preparedStatement.execute();
            preparedStatement = conn.prepareStatement(querySectionsDrop);
            preparedStatement.execute();

        } catch (SQLException e) {

            e.printStackTrace();
        }

    }

    try {
        conn.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }

}