Search in sources :

Example 1 with DynamoDbMapper

use of api.aws.DynamoDbMapper in project amos-ss17-alexa by c-i-ber.

the class Transaction method getPeriodicTransactions.

/**
 * gets all periodic transaction from DB/API
 * @param accountNumber account number
 * @return List of all periodic transactions
 */
public static List<Transaction> getPeriodicTransactions(String accountNumber) {
    ArrayList<Transaction> periodicTransactions = new ArrayList<>();
    DynamoDbMapper dynamoDbMapper = DynamoDbMapper.getInstance();
    List<TransactionDB> transactionsDB = dynamoDbMapper.loadAll(TransactionDB.class);
    for (TransactionDB transactionDB : transactionsDB) {
        if (transactionDB.isPeriodic() && transactionDB.getAccountNumber().equals(accountNumber)) {
            Transaction transaction = getCachedTransactionForAccount(accountNumber, transactionDB.getTransactionId());
            periodicTransactions.add(transaction);
        }
    }
    return periodicTransactions;
}
Also used : DynamoDbMapper(api.aws.DynamoDbMapper) ArrayList(java.util.ArrayList) TransactionDB(model.db.TransactionDB)

Example 2 with DynamoDbMapper

use of api.aws.DynamoDbMapper in project amos-ss17-alexa by c-i-ber.

the class TransactionTest method createPeriodicTransactionTest.

@Ignore
public void createPeriodicTransactionTest() {
    DynamoDbMapper dynamoDbMapper = DynamoDbMapper.getInstance();
    String source = AccountAPI.getAccount(AccountData.ACCOUNT_DEFAULT).getIban();
    String destination = AccountAPI.getAccount(AccountData.ACCOUNT_DEFAULT_2).getIban();
    // create sample transactions
    String date = new DateTime(2017, 8, 14, 12, 0).toLocalDate().toString();
    Transaction transaction = TransactionAPI.createTransaction(10, source, destination, date, "Netflix", "Netflix", "Peter Müller");
    TransactionDB tDB1 = new TransactionDB(transaction.getTransactionId().toString(), "", AccountData.ACCOUNT_DEFAULT);
    tDB1.setPeriodic(true);
    dynamoDbMapper.save(tDB1);
}
Also used : DynamoDbMapper(api.aws.DynamoDbMapper) Transaction(model.banking.Transaction) TransactionDB(model.db.TransactionDB) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore)

Aggregations

DynamoDbMapper (api.aws.DynamoDbMapper)2 TransactionDB (model.db.TransactionDB)2 ArrayList (java.util.ArrayList)1 Transaction (model.banking.Transaction)1 DateTime (org.joda.time.DateTime)1 Ignore (org.junit.Ignore)1