コード例 #1
0
ファイル: JSTORFetcher.java プロジェクト: supartha/jabref
  @Override
  public boolean processQuery(String query, ImportInspector dialog, OutputPrinter status) {

    try {
      // First open a ticket with JStor
      String ticket = openTicket();

      // Then execute the query
      String citations = getCitations(ticket, query);

      // Last retrieve the Bibtex-entries of the citations found
      Collection<BibtexEntry> entries = getBibtexEntries(ticket, citations);

      if (entries.isEmpty()) {
        status.showMessage(
            Globals.lang("No entries found for the search string '%0'", query),
            Globals.lang("Search JSTOR"),
            JOptionPane.INFORMATION_MESSAGE);
        return false;
      }

      for (BibtexEntry entry : entries) {
        dialog.addEntry(entry);
      }
      return true;
    } catch (IOException e) {
      status.showMessage(Globals.lang("Error while fetching from JSTOR") + ": " + e.getMessage());
    }
    return false;
  }
コード例 #2
0
ファイル: INSPIREFetcher.java プロジェクト: valhallasw/jabref
  /*
   * @see java.lang.Runnable
   */
  @Override
  public boolean processQuery(String query, ImportInspector dialog, OutputPrinter frame) {
    try {
      frame.setStatus("Fetching entries from Inspire");
      /* query the archive and load the results into the BibtexEntry */
      BibtexDatabase bd = importInspireEntries(query, frame);

      /* addSpiresURLtoDatabase(bd); */

      frame.setStatus("Adding fetched entries");
      /* add the entry to the inspection dialog */
      if (bd.getEntryCount() > 0) {
        for (BibtexEntry entry : bd.getEntries()) {
          dialog.addEntry(entry);
        }
      }

      /* update the dialogs progress bar */
      // dialog.setProgress(i + 1, keys.length);
      /* inform the inspection dialog, that we're done */
    } catch (Exception e) {
      frame.showMessage(Localization.lang("Error while fetching from Inspire: ") + e.getMessage());
      e.printStackTrace();
    }
    return true;
  }
コード例 #3
0
  private void parse(ImportInspector dialog, String text, int startIndex, int firstEntryNumber) {
    piv = startIndex;
    int entryNumber = firstEntryNumber;

    if (importBibtex) {
      // TODO: Login
      ArrayList<String> idSelected = new ArrayList<String>();
      String id;
      while ((id = parseNextEntryId(text, piv)) != null && shouldContinue) {
        idSelected.add(id);
        entryNumber++;
      }
      try {
        BibtexDatabase dbase = parseBibtexDatabase(idSelected, includeAbstract);
        Collection<BibtexEntry> items = dbase.getEntries();
        for (BibtexEntry entry : items) {
          dialog.addEntry(cleanup(entry));
          dialog.setProgress(parsed + unparseable, hits);
          parsed++;
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
      // for
    } else {
      BibtexEntry entry;
      while ((entry = parseNextEntry(text, piv)) != null && shouldContinue) {
        if (entry.getField("title") != null) {
          dialog.addEntry(entry);
          dialog.setProgress(parsed + unparseable, hits);
          parsed++;
        }
        entryNumber++;
      }
    }
  }
コード例 #4
0
ファイル: ACMPortalFetcher.java プロジェクト: steimlfk/jabref
  @Override
  public void getEntries(Map<String, Boolean> selection, ImportInspector inspector) {
    for (Map.Entry<String, Boolean> selentry : selection.entrySet()) {
      if (!shouldContinue) {
        break;
      }
      boolean sel = selentry.getValue();
      if (sel) {
        BibEntry entry = downloadEntryBibTeX(selentry.getKey(), fetchAbstract);
        if (entry != null) {
          // Convert from HTML and optionally add curly brackets around key words to keep the case
          entry
              .getFieldOptional("title")
              .ifPresent(
                  title -> {
                    title = title.replaceAll("\\\\&", "&").replaceAll("\\\\#", "#");
                    title = convertHTMLChars(title);

                    // Unit formatting
                    if (Globals.prefs.getBoolean(JabRefPreferences.USE_UNIT_FORMATTER_ON_SEARCH)) {
                      title = unitFormatter.format(title);
                    }

                    // Case keeping
                    if (Globals.prefs.getBoolean(JabRefPreferences.USE_CASE_KEEPER_ON_SEARCH)) {
                      title = caseKeeper.format(title);
                    }
                    entry.setField("title", title);
                  });

          entry
              .getFieldOptional("abstract")
              .ifPresent(
                  abstr -> {
                    entry.setField("abstract", convertHTMLChars(abstr));
                  });
          inspector.addEntry(entry);
        }
      }
    }
  }