Exemplo n.º 1
0
  /*
   * (non-Javadoc)
   *
   * @see com.dtcc.awsticker.dao.IDaoTicker#getAllTickerRows()
   */
  public List<TickerRow> getAllTickerRows() {
    // return LocalTickerTable.getAll();
    List<TickerRow> rows = new ArrayList<TickerRow>();

    ScanRequest scanRequest = new ScanRequest(tableName);
    ScanResult scanResult = db.scan(scanRequest);
    List<Map<String, AttributeValue>> items = scanResult.getItems();
    if (items == null || items.isEmpty()) return rows;
    for (Map<String, AttributeValue> item : items) {

      Integer index = new Integer(0);
      try {
        index = Integer.decode(item.get("Index").getN());
      } catch (NumberFormatException e) {
        log.warning("bad key " + e);
      }

      TickerRow tr = new TickerRow();
      tr.setIndex(index);
      ItemToModel(item, tr);
      rows.add(tr);
    }

    return rows;
  }
Exemplo n.º 2
0
  /*
   * (non-Javadoc)
   *
   * @see com.dtcc.awsticker.dao.IDaoTicker#getTickerRow(java.lang.Integer)
   */
  public TickerRow getTickerRow(Integer index) {
    // return LocalTickerTable.get(index);

    AttributeValue id = new AttributeValue().withN(index + "");
    Key primaryKey = new Key().withHashKeyElement(id);
    GetItemRequest request = new GetItemRequest().withTableName(tableName).withKey(primaryKey);

    GetItemResult result = db.getItem(request);
    if (result.getItem() == null) return null;
    TickerRow tr = new TickerRow();
    tr.setIndex(index);
    ItemToModel(result.getItem(), tr);

    return tr;
  }