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;
}
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);
}
Aggregations