Search in sources :

Example 6 with TransactionDB

use of model.db.TransactionDB in project amos-ss17-alexa by c-i-ber.

the class PeriodicTransactionService method deletePeriodicTransaction.

private SpeechletResponse deletePeriodicTransaction(Intent intent, Session session, boolean confirmed) {
    if (!confirmed) {
        if (intent.getSlot(TRANSACTION_NUMBER_KEY) == null || StringUtils.isBlank(intent.getSlot(TRANSACTION_NUMBER_KEY).getValue())) {
            session.getAttributes().clear();
            return getAskResponse(PERIODIC_TRANSACTION, "Das habe ich nicht verstanden. Bitte wiederhole deine Eingabe.");
        } else {
            String transactionId = intent.getSlot(TRANSACTION_NUMBER_KEY).getValue();
            TransactionDB transactionDb = (TransactionDB) dynamoDbMapper.load(TransactionDB.class, transactionId);
            LOGGER.info("TransactionDb: " + transactionDb);
            if (transactionDb == null) {
                return getAskResponse(PERIODIC_TRANSACTION, "Ich kann Transaktion Nummer " + transactionId + " nicht finden." + " Bitte aendere deine Eingabe.");
            }
            session.setAttribute(TRANSACTION_NUMBER_KEY, transactionId);
            return getAskResponse(PERIODIC_TRANSACTION, "Moechtest du die Markierung als periodisch fuer die" + " Transaktion mit der Nummer " + transactionId + " wirklich entfernen?");
        }
    } else {
        String transactionId = (String) session.getAttribute(TRANSACTION_NUMBER_KEY);
        if (transactionId != null) {
            TransactionDB transactionDb = (TransactionDB) dynamoDbMapper.load(TransactionDB.class, transactionId);
            dynamoDbMapper.delete(transactionDb);
            List<TransactionDB> allDbts = dynamoDbMapper.loadAll(TransactionDB.class);
            LOGGER.info("AllDBTransactions: " + allDbts);
            return getResponse(PERIODIC_TRANSACTION, "Transaktion Nummer " + transactionId + " ist nun nicht mehr als periodisch markiert.");
        }
    }
    return null;
}
Also used : TransactionDB(model.db.TransactionDB)

Example 7 with TransactionDB

use of model.db.TransactionDB in project amos-ss17-alexa by c-i-ber.

the class ContactTransferService method transactionCategoryResponse.

private SpeechletResponse transactionCategoryResponse(Intent intent, Session session) {
    String categoryName = intent.getSlot(CATEGORY_SLOT) != null ? intent.getSlot(CATEGORY_SLOT).getValue().toLowerCase() : null;
    // DynamoDbClient.instance.getItems(Category.TABLE_NAME, Category::new);
    List<Category> categories = DynamoDbMapper.getInstance().loadAll(Category.class);
    for (Category category : categories) {
        if (category.getName().equals(categoryName)) {
            String transactionId = (String) session.getAttribute(TRANSACTION_ID_ATTRIBUTE);
            dynamoDbMapper.save(new TransactionDB(transactionId, "" + category.getId(), ACCOUNT_NUMBER));
            return getResponse(CONTACT_TRANSFER_CARD, "Verstanden. Die Transaktion wurde zur Kategorie " + categoryName + " hinzugefügt");
        }
    }
    return getResponse(CONTACT_TRANSFER_CARD, "Ich konnte die Kategorie nicht finden. Tschüss");
}
Also used : Category(model.db.Category) TransactionDB(model.db.TransactionDB)

Aggregations

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