Exemplo n.º 1
0
  @Override
  public void processMessage(Message msg) {
    final Element arraySecurityData = msg.getElement("securityData");
    final int numItems = arraySecurityData.numValues();
    for (int i = 0; i < numItems; ++i) {
      final Element securityData = arraySecurityData.getValueAsElement(i);

      final String security = securityData.getElementAsString("security");

      Map<String, Map<String, String>> pv;
      if (answer.containsKey(security)) {
        pv = answer.get(security);
      } else {
        pv = new HashMap<>();
        answer.put(security, pv);
      }
      final Map<String, String> values = new HashMap<>();
      pv.put(period, values);

      if (securityData.hasElement("securityError")) {
        final String value = securityData.getElementAsString("securityError");
        log.error("SecurityError:" + value);
        values.put("securityError", value);
        continue;
      }

      final Element fieldData = securityData.getElement("fieldData");
      for (String field : fields) {
        if (fieldData.hasElement(field)) {
          try {
            String value = fieldData.getElementAsString(field);
            values.put(field, value);
          } catch (Exception e) {
            log.error(e);
          }
        }
      }
    }
  }
Exemplo n.º 2
0
  @Override
  public void processMessage(Message message) {
    Element ReferenceDataResponse = message.asElement();
    Element securityDataArray = ReferenceDataResponse.getElement("securityData");
    for (int i = 0; i < securityDataArray.numValues(); ++i) {
      final Element securityData = securityDataArray.getValueAsElement(i);

      final String security = securityData.getElementAsString("security");

      if (securityData.hasElement("securityError")) {
        log.error("SecurityError:" + securityData.getElement("securityError"));
        continue;
      }

      final Element fieldData = securityData.getElement("fieldData");

      for (String p : fields) {
        if (p.equals("BEST_ANALYST_RECS_BULK")) {
          final List<BEST_ANALYST_RECS_BULK> values = new ArrayList<>();
          bestAnalyst.put(security, values);

          final Element best_anal_recs_bulk = fieldData.getElement("BEST_ANALYST_RECS_BULK");
          for (int m = 0; m < best_anal_recs_bulk.numValues(); m++) {
            final Element e = best_anal_recs_bulk.getValueAsElement(m);
            values.add(new BEST_ANALYST_RECS_BULK(e));
          }
        }

        if (p.equals("EARN_ANN_DT_TIME_HIST_WITH_EPS")) {
          final List<EARN_ANN_DT_TIME_HIST_WITH_EPS> values = new ArrayList<>();
          earnHistWithEps.put(security, values);

          final Element element = fieldData.getElement("EARN_ANN_DT_TIME_HIST_WITH_EPS");
          for (int t = 0; t < element.numValues(); t++) {
            final Element e = element.getValueAsElement(t);
            values.add(new EARN_ANN_DT_TIME_HIST_WITH_EPS(e));
          }
        }

        if (p.equals("ERN_ANN_DT_AND_PER")) {
          final List<ERN_ANN_DT_AND_PER> values = new ArrayList<>();
          ernAnnDTandPer.put(security, values);

          final Element element = fieldData.getElement("ERN_ANN_DT_AND_PER");
          final int ernItems = element.numValues();
          for (int j = 0; j < ernItems; ++j) {
            final Element e = element.getValueAsElement(j);
            values.add(new ERN_ANN_DT_AND_PER(e));
          }
        }

        if (p.equals("BLOOMBERG_PEERS")) {
          final List<String> values = new ArrayList<String>();
          peerTicker.put(security, values);

          final Element blm_peers = fieldData.getElement("BLOOMBERG_PEERS");
          for (int j = 0; j < blm_peers.numValues(); ++j) {
            final Element e = blm_peers.getValueAsElement(j);
            final String peer = e.getElementAsString("Peer Ticker");
            values.add(peer);

            peers.add(peer);
          }
        }
      }
    }
  }