Example #1
0
 public static SearchType forName(String name) {
   for (SearchType type : values()) {
     if (type.name().equalsIgnoreCase(name)) {
       return type;
     }
   }
   return COMMIT;
 }
  public void testDeepScrollingDoesNotBlowUp() throws Exception {
    client()
        .prepareIndex("index", "type", "1")
        .setSource("field", "value")
        .setRefresh(true)
        .execute()
        .get();

    for (SearchType searchType : SearchType.values()) {
      SearchRequestBuilder builder =
          client()
              .prepareSearch("index")
              .setSearchType(searchType)
              .setQuery(QueryBuilders.matchAllQuery())
              .setSize(Integer.MAX_VALUE)
              .setScroll("1m");

      SearchResponse response = builder.execute().actionGet();
      try {
        ElasticsearchAssertions.assertHitCount(response, 1l);
      } finally {
        String scrollId = response.getScrollId();
        if (scrollId != null) {
          clearScroll(scrollId);
        }
      }
    }
  }
  @SuppressWarnings("unchecked")
  public static SearchFilter getSearchFilter(HttpServletRequest request) {
    SearchFilter searchFilter = new SearchFilter();
    Enumeration<String> enumeration = request.getParameterNames();
    while (enumeration.hasMoreElements()) {
      String string = enumeration.nextElement();
      if (!string.startsWith(SearchFilter.STARTPREFIX)) continue;

      String[] split = string.split(SearchFilter.SPLITTAG);
      if (split.length != 3) continue;

      SearchType searchType = SearchType.parseString(split[1]);
      String fieldName = split[2];
      String fieldValue = request.getParameter(string);
      SearchOperator searchOperator = new SearchOperator(fieldName, fieldValue, searchType);
      searchFilter.getSearchOperatorList().add(searchOperator);
    }
    return searchFilter;
  }
Example #4
0
  /**
   * Marshalls the additional parameters and returns them as a string.
   *
   * @return A string holding the marshalled parameters
   */
  private String marshallAdditionalParameters() {
    String parameters = "";

    if (accessions != null && accessions.size() > 0) {
      parameters += "ACCESSION=";
      for (int i = 0; i < accessions.size(); i++)
        parameters += ((i > 0) ? "," : "") + "\"" + accessions.get(i) + "\"";
      parameters += "\n";
    }

    if (charge != null) parameters += "CHARGE=" + charge + "\n";

    if (enzyme != null) parameters += "CLE=" + enzyme + "\n";

    if (searchTitle != null) parameters += "COM=" + searchTitle + "\n";

    if (precursorRemoval != null) parameters += "CUTOUT=" + precursorRemoval + "\n";

    if (database != null) parameters += "DB=" + database + "\n";

    if (performDecoySearch != null)
      parameters += "DECOY=" + ((performDecoySearch) ? "1" : "0") + "\n";

    if (isErrorTolerant != null)
      parameters += "ERRORTOLERANT=" + ((isErrorTolerant) ? "1" : "0") + "\n";

    if (format != null) parameters += "FORMAT=" + format + "\n";

    if (frames != null && frames.size() > 0) {
      parameters += "FRAMES=";
      for (int i = 0; i < frames.size(); i++)
        parameters += ((i > 0) ? "," : "") + frames.get(i).toString();
      parameters += "\n";
    }

    if (instrument != null) parameters += "INSTRUMENT=" + instrument + "\n";

    if (variableModifications != null) parameters += "IT_MODS=" + variableModifications + "\n";

    if (fragmentIonTolerance != null)
      parameters += "ITOL=" + fragmentIonTolerance.toString() + "\n";

    if (fragmentIonToleranceUnit != null)
      parameters +=
          "ITOLU="
              + ((fragmentIonToleranceUnit == FragmentToleranceUnits.MMU) ? "mmu" : "Da")
              + "\n";

    if (massType != null)
      parameters += "MASS=" + ((massType == MassType.AVERAGE) ? "Average" : "Monoisotopic") + "\n";

    if (fixedMofications != null) parameters += "MODS=" + fixedMofications + "\n";

    if (peptideIsotopeError != null)
      parameters += "PEP_ISOTOPE_ERROR=" + peptideIsotopeError.toString() + "\n";

    if (partials != null) parameters += "PFA=" + partials.toString() + "\n";

    if (precursor != null) parameters += "PRECURSOR=" + precursor.toString() + "\n";

    if (quantitation != null) parameters += "QUANTITATION=" + quantitation + "\n";

    if (maxHitsToReport != null) parameters += "REPORT=" + maxHitsToReport + "\n";

    if (reportType != null) parameters += "REPTYPE=" + reportType.toString() + "\n";

    if (searchType != null) parameters += "SEARCH=" + searchType.toString() + "\n";

    if (proteinMass != null) parameters += "SEG=" + proteinMass + "\n";

    if (taxonomy != null) parameters += "TAXONOMY=" + taxonomy + "\n";

    if (peptideMassTolerance != null) parameters += "TOL=" + peptideMassTolerance.toString() + "\n";

    if (peptideMassToleranceUnit != null)
      parameters += "TOLU=" + peptideMassToleranceUnit.toString() + "\n";

    if (userMail != null) parameters += "USEREMAIL=" + userMail + "\n";

    if (userName != null) parameters += "USERNAME="******"\n";

    if (userParameter != null) {
      for (Integer i = 0; i < userParameter.size(); i++) {
        parameters +=
            "USER" + ((i < 10) ? "0" : "") + i.toString() + "=" + userParameter.get(i) + "\n";
      }
    }

    return parameters;
  }
Example #5
0
  /** Check query string to see if the user wants to load previous search data into the forms. */
  private void loadPreviousSearch(final ClientLoadedSearch result) {
    if (result == null) {
      return;
    }
    final ClientSwiftSearchDefinition definition = result.getDefinition();
    displayMessage("Loaded previous search " + definition.getSearchTitle());

    if (result.getClientParamSetList() != null) {
      // We transfered a new parameter set list together with search definition
      // Update the parameter editor.
      paramsEditor.setParamSetList(result.getClientParamSetList());
    }

    paramsEditor.setSelectedParamSet(result.getDefinition().getParamSet());

    // Determine search type
    SearchType searchType = null;
    for (final ClientFileSearch clientFileSearch : definition.getInputFiles()) {
      final String fileNamefileNameWithoutExtension =
          FilePathWidget.getFileNameWithoutExtension(clientFileSearch.getPath());
      final SearchType newSearchType =
          SearchTypeList.getSearchTypeFromSetup(
              definition.getSearchTitle(),
              fileNamefileNameWithoutExtension,
              clientFileSearch.getExperiment(),
              clientFileSearch.getBiologicalSample());
      if (searchType == null) {
        searchType = newSearchType;
      } else {
        if (!searchType.equals(newSearchType)) {
          searchType = SearchType.Custom;
          break;
        }
      }
    }

    final String title = definition.getSearchTitle();
    setTitleText(title);
    if (spectrumQaSetupPanel != null) {
      spectrumQaSetupPanel.setParameters(definition.getSpectrumQa());
    }
    if (reportSetupPanel != null) {
      reportSetupPanel.setParameters(definition.getPeptideReport());
    }
    final List<ClientFileSearch> inputFiles = definition.getInputFiles();

    files.setFiles(inputFiles, searchType);

    selectUser(definition.getUser().getEmail());

    final String filePath = getOutputPathFromFileTable(inputFiles);
    // If the loaded path differs from what the file table would produce, it is user-specified
    // .. set the proper flags
    if (definition.getOutputFolder() == null || !definition.getOutputFolder().equals(filePath)) {
      outputPathUserSpecified = true;
    }
    outputPath = definition.getOutputFolder();
    output.setText(outputPath);
    updateOutputLocation();

    additionalSettingsPanel.setDefinition(definition);

    showPageContentsAfterLoad();
  }