Esempio n. 1
0
  private void doUpdateHistoricalQuotes(IProgressMonitor monitor, List<IStatus> errors) {
    for (Security security : securities) {
      monitor.subTask(MessageFormat.format(Messages.JobMsgUpdatingQuotesFor, security.getName()));
      try {
        QuoteFeed feed = Factory.getQuoteFeedProvider(security.getFeed());
        if (feed != null) {
          ArrayList<Exception> exceptions = new ArrayList<Exception>();
          feed.updateHistoricalQuotes(security, exceptions);

          if (!exceptions.isEmpty()) addToErrors(security.getName(), exceptions, errors);
        }
      } catch (IOException e) {
        errors.add(
            new Status(
                IStatus.ERROR,
                PortfolioPlugin.PLUGIN_ID,
                security.getName()
                    + ": " //$NON-NLS-1$
                    + e.getMessage(),
                e));
      }

      monitor.worked(1);
    }
  }
Esempio n. 2
0
  private void doUpdateLatestQuotes(IProgressMonitor monitor, List<IStatus> errors) {
    Map<String, List<Security>> byFeeds = new HashMap<String, List<Security>>();
    for (Security s : securities) {
      List<Security> l = byFeeds.get(s.getFeed());
      if (l == null) byFeeds.put(s.getFeed(), l = new ArrayList<Security>());
      l.add(s);
    }

    for (Map.Entry<String, List<Security>> entry : byFeeds.entrySet()) {
      if (monitor.isCanceled()) return;

      try {
        QuoteFeed feed = Factory.getQuoteFeedProvider(entry.getKey());
        if (feed != null) {
          ArrayList<Exception> exceptions = new ArrayList<Exception>();
          feed.updateLatestQuotes(entry.getValue(), exceptions);

          if (!exceptions.isEmpty()) addToErrors(feed.getName(), exceptions, errors);
        }
      } catch (IOException e) {
        errors.add(new Status(IStatus.ERROR, PortfolioPlugin.PLUGIN_ID, e.getMessage(), e));
      }
    }
  }