private ExchangeRate constructExchangeRateFromRecord(DatabaseTableRecord record) throws CantCreateExchangeRateException { UUID id = record.getUUIDValue( BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_ID_COLUMN_NAME); double salePrice = record.getDoubleValue( BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_SALE_PRICE_COLUMN_NAME); double purchasePrice = record.getDoubleValue( BitcoinVenezuelaProviderDatabaseConstants .DAILY_EXCHANGE_RATES_PURCHASE_PRICE_COLUMN_NAME); long timestamp = record.getLongValue( BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_TIMESTAMP_COLUMN_NAME); Currency fromCurrency; try { String fromCurrencyStr = record.getStringValue( BitcoinVenezuelaProviderDatabaseConstants .DAILY_EXCHANGE_RATES_FROM_CURRENCY_COLUMN_NAME); if (FiatCurrency.codeExists(fromCurrencyStr)) fromCurrency = FiatCurrency.getByCode(fromCurrencyStr); else if (CryptoCurrency.codeExists(fromCurrencyStr)) fromCurrency = CryptoCurrency.getByCode(fromCurrencyStr); else throw new InvalidParameterException(); } catch (InvalidParameterException e) { throw new CantCreateExchangeRateException( e.getMessage(), e, "BitcoinVenezuela provider plugin", "Invalid From Currency value stored in table" + BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_TABLE_NAME + " for id " + id); } Currency toCurrency; try { String toCurrencyStr = record.getStringValue( BitcoinVenezuelaProviderDatabaseConstants .DAILY_EXCHANGE_RATES_TO_CURRENCY_COLUMN_NAME); if (FiatCurrency.codeExists(toCurrencyStr)) toCurrency = FiatCurrency.getByCode(toCurrencyStr); else if (CryptoCurrency.codeExists(toCurrencyStr)) toCurrency = CryptoCurrency.getByCode(toCurrencyStr); else throw new InvalidParameterException(); } catch (InvalidParameterException e) { throw new CantCreateExchangeRateException( e.getMessage(), e, "BitcoinVenezuela provider plugin", "Invalid To Currency value stored in table" + BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_TABLE_NAME + " for id " + id); } return new ExchangeRateImpl(fromCurrency, toCurrency, salePrice, purchasePrice, timestamp); }
private CashMoneyWalletTransaction constructCashMoneyWalletTransactionFromRecord( DatabaseTableRecord record) throws CantCreateCashMoneyWalletTransactionException { UUID transactionId = record.getUUIDValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_TRANSACTION_ID_COLUMN_NAME); String publicKeyWallet = record.getStringValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_WALLET_PUBLIC_KEY_COLUMN_NAME); String publicKeyActor = record.getStringValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_ACTOR_PUBLIC_KEY_COLUMN_NAME); String publicKeyPlugin = record.getStringValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_PLUGIN_PUBLIC_KEY_COLUMN_NAME); BigDecimal amount = new BigDecimal( record.getStringValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_AMOUNT_COLUMN_NAME)); String memo = record.getStringValue(CashMoneyWalletDatabaseConstants.TRANSACTIONS_MEMO_COLUMN_NAME); long timestamp = record.getLongValue(CashMoneyWalletDatabaseConstants.TRANSACTIONS_TIMESTAMP_COLUMN_NAME); TransactionType transactionType; try { transactionType = TransactionType.getByCode( record.getStringValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_TRANSACTION_TYPE_COLUMN_NAME)); } catch (InvalidParameterException e) { throw new CantCreateCashMoneyWalletTransactionException( e.getMessage(), e, "Cash Money Wallet", "Invalid TransactionType value stored in table" + CashMoneyWalletDatabaseConstants.TRANSACTIONS_TABLE_NAME + " for id " + transactionId); } BalanceType balanceType; try { balanceType = BalanceType.getByCode( record.getStringValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_BALANCE_TYPE_COLUMN_NAME)); } catch (InvalidParameterException e) { throw new CantCreateCashMoneyWalletTransactionException( e.getMessage(), e, "Cash Money Wallet", "Invalid BalanceType value stored in table" + CashMoneyWalletDatabaseConstants.TRANSACTIONS_TABLE_NAME + " for id " + transactionId); } return new CashMoneyWalletTransactionImpl( transactionId, publicKeyWallet, publicKeyActor, publicKeyPlugin, transactionType, balanceType, amount, memo, timestamp); }