Пример #1
0
  /*
   * (non-Javadoc)
   *
   * @see com.dtcc.awsticker.dao.IDaoTicker#putTickerRow(java.lang.Integer,
   * com.dtcc.awsticker.domain.TickerRow)
   */
  public void putTickerRow(Integer index, TickerRow tickerRow) {
    // LocalTickerTable.put(index, tickerRow);

    Map<String, AttributeValue> item = new HashMap<String, AttributeValue>();

    item.put("Index", new AttributeValue().withN("" + tickerRow.getIndex()));
    // item.put("Date", new AttributeValue(tickerRow.getDate()));
    item.put("Name", new AttributeValue(tickerRow.getName()));
    item.put("Number", new AttributeValue(tickerRow.getNumber()));
    item.put("Price", new AttributeValue(tickerRow.getPrice()));
    item.put("Time", new AttributeValue(tickerRow.getDateTime()));
    item.put("CreatedTimeMs", new AttributeValue("" + System.currentTimeMillis()));

    PutItemRequest putItemRequest = new PutItemRequest(tableName, item);
    PutItemResult putItemResult = db.putItem(putItemRequest);
  }
Пример #2
0
  @Override
  public int insert(String table, String key, HashMap<String, ByteIterator> values) {
    logger.debug("insertkey: " + primaryKeyName + "-" + key + " from table: " + table);
    Map<String, AttributeValue> attributes = createAttributes(values);
    // adding primary key
    attributes.put(primaryKeyName, new AttributeValue(key));

    PutItemRequest putItemRequest = new PutItemRequest(table, attributes);
    PutItemResult res = null;
    try {
      res = dynamoDB.putItem(putItemRequest);
    } catch (AmazonServiceException ex) {
      logger.error(ex.getMessage());
      return SERVER_ERROR;
    } catch (AmazonClientException ex) {
      logger.error(ex.getMessage());
      return CLIENT_ERROR;
    }
    return OK;
  }
Пример #3
0
  private void run() throws IOException {
    InputStream resourceAsStream = getClass().getResourceAsStream("/AwsCredentials.properties");
    assert resourceAsStream != null;

    AWSCredentials credentials = new PropertiesCredentials(resourceAsStream);
    AmazonDynamoDBClient amazonDynamoDBClient = new AmazonDynamoDBClient(credentials);
    amazonDynamoDBClient.setEndpoint("https://dynamodb.us-west-1.amazonaws.com");

    String tableName = "wellsfargo-checking-01";
    //        String tableName = "table3";

    //        describeTable(amazonDynamoDBClient, tableName);

    List<String> strings = FileUtils.readLines(new File("data/subset.txt"));
    int i = 0;
    for (String record : strings) {
      //	1	1/2/00	Opening Balance	-	3504.65	X	-	[WF Checking]
      String[] ledgerEntry = record.split("\\t");
      Map<String, AttributeValue> item = new HashMap<String, AttributeValue>();
      AttributeValue txidAttribute = new AttributeValue();
      txidAttribute.setN(ledgerEntry[0]);

      item.put("txid", txidAttribute);
      item.put("date", new AttributeValue(ledgerEntry[1]));
      item.put("payee", new AttributeValue(ledgerEntry[2]));
      item.put("memo", new AttributeValue(ledgerEntry[3]));
      item.put("amount", new AttributeValue(ledgerEntry[4]));
      item.put("cleared", new AttributeValue(ledgerEntry[5]));
      item.put("checknumber", new AttributeValue(ledgerEntry[6]));
      item.put("category", new AttributeValue(ledgerEntry[7]));

      PutItemRequest putItemRequest = new PutItemRequest(tableName, item);
      PutItemResult putItemResult = amazonDynamoDBClient.putItem(putItemRequest);
      if (++i % 10 == 0) {
        System.out.println("putItemResult: " + putItemResult);
      }
    }
  }