/** * Construct a DatabaseTableRecord whit the values of the a FermatMessage pass by parameter * * @param incomingTemplateNetworkServiceMessage the contains the values * @return DatabaseTableRecord whit the values */ private DatabaseTableRecord constructFrom(FermatMessage incomingTemplateNetworkServiceMessage) { /* * Create the record to the entity */ DatabaseTableRecord entityRecord = getDatabaseTable().getEmptyRecord(); /* * Set the entity values */ entityRecord.setStringValue( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_ID_COLUMN_NAME, incomingTemplateNetworkServiceMessage.getId().toString()); entityRecord.setStringValue( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_SENDER_ID_COLUMN_NAME, incomingTemplateNetworkServiceMessage.getSender().toString()); entityRecord.setStringValue( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_RECEIVER_ID_COLUMN_NAME, incomingTemplateNetworkServiceMessage.getReceiver().toString()); entityRecord.setStringValue( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_TEXT_CONTENT_COLUMN_NAME, incomingTemplateNetworkServiceMessage.getContent()); entityRecord.setStringValue( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_TYPE_COLUMN_NAME, incomingTemplateNetworkServiceMessage.getFermatMessageContentType().getCode()); if (incomingTemplateNetworkServiceMessage.getShippingTimestamp() != null) { entityRecord.setLongValue( CommunicationNetworkServiceDatabaseConstants .OUTGOING_MESSAGES_SHIPPING_TIMESTAMP_COLUMN_NAME, incomingTemplateNetworkServiceMessage.getShippingTimestamp().getTime()); } else { entityRecord.setLongValue( CommunicationNetworkServiceDatabaseConstants .OUTGOING_MESSAGES_SHIPPING_TIMESTAMP_COLUMN_NAME, new Long(0)); } if (incomingTemplateNetworkServiceMessage.getDeliveryTimestamp() != null) { entityRecord.setLongValue( CommunicationNetworkServiceDatabaseConstants .INCOMING_MESSAGES_SHIPPING_TIMESTAMP_COLUMN_NAME, incomingTemplateNetworkServiceMessage.getDeliveryTimestamp().getTime()); } else { entityRecord.setLongValue( CommunicationNetworkServiceDatabaseConstants .INCOMING_MESSAGES_DELIVERY_TIMESTAMP_COLUMN_NAME, new Long(0)); } entityRecord.setStringValue( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_STATUS_COLUMN_NAME, incomingTemplateNetworkServiceMessage.getFermatMessagesStatus().getCode()); /* * return the new table record */ return entityRecord; }
private void constructRecordFromCashMoneyWalletTransaction( DatabaseTableRecord newRecord, CashMoneyWalletTransaction cashMoneyWalletTransaction) { newRecord.setUUIDValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_TRANSACTION_ID_COLUMN_NAME, cashMoneyWalletTransaction.getTransactionId()); newRecord.setStringValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_WALLET_PUBLIC_KEY_COLUMN_NAME, cashMoneyWalletTransaction.getPublicKeyWallet()); newRecord.setStringValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_ACTOR_PUBLIC_KEY_COLUMN_NAME, cashMoneyWalletTransaction.getPublicKeyActor()); newRecord.setStringValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_PLUGIN_PUBLIC_KEY_COLUMN_NAME, cashMoneyWalletTransaction.getPublicKeyPlugin()); newRecord.setStringValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_TRANSACTION_TYPE_COLUMN_NAME, cashMoneyWalletTransaction.getTransactionType().getCode()); newRecord.setStringValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_BALANCE_TYPE_COLUMN_NAME, cashMoneyWalletTransaction.getBalanceType().getCode()); newRecord.setStringValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_AMOUNT_COLUMN_NAME, cashMoneyWalletTransaction.getAmount().toPlainString()); newRecord.setStringValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_MEMO_COLUMN_NAME, cashMoneyWalletTransaction.getMemo()); newRecord.setLongValue( CashMoneyWalletDatabaseConstants.TRANSACTIONS_TIMESTAMP_COLUMN_NAME, cashMoneyWalletTransaction.getTimestamp()); }
/** * Construct a DatabaseTableRecord whit the values of the a WalletStoreNetworkServiceMessage pass * by parameter * * @param incomingIntraUserNetworkServiceMessage the contains the values * @return DatabaseTableRecord whit the values */ private DatabaseTableRecord constructFrom( WalletStoreNetworkServiceMessage incomingIntraUserNetworkServiceMessage) { /* * Create the record to the entity */ DatabaseTableRecord entityRecord = getDatabaseTable().getEmptyRecord(); /* * Set the entity values */ entityRecord.setLongValue( WalletStoreNetworkServiceDatabaseConstants.INCOMING_MESSAGES_TABLE_ID_COLUMN_NAME, incomingIntraUserNetworkServiceMessage.getId()); entityRecord.setStringValue( WalletStoreNetworkServiceDatabaseConstants.INCOMING_MESSAGES_TABLE_SENDER_ID_COLUMN_NAME, incomingIntraUserNetworkServiceMessage.getSender().toString()); entityRecord.setStringValue( WalletStoreNetworkServiceDatabaseConstants.INCOMING_MESSAGES_TABLE_RECEIVER_ID_COLUMN_NAME, incomingIntraUserNetworkServiceMessage.getReceiver().toString()); entityRecord.setStringValue( WalletStoreNetworkServiceDatabaseConstants.INCOMING_MESSAGES_TABLE_TEXT_CONTENT_COLUMN_NAME, incomingIntraUserNetworkServiceMessage.getTextContent()); entityRecord.setStringValue( WalletStoreNetworkServiceDatabaseConstants.INCOMING_MESSAGES_TABLE_TYPE_COLUMN_NAME, incomingIntraUserNetworkServiceMessage.getMessageType().getCode()); entityRecord.setLongValue( WalletStoreNetworkServiceDatabaseConstants .INCOMING_MESSAGES_TABLE_SHIPPING_TIMESTAMP_COLUMN_NAME, incomingIntraUserNetworkServiceMessage.getShippingTimestamp().getTime()); entityRecord.setLongValue( WalletStoreNetworkServiceDatabaseConstants .INCOMING_MESSAGES_TABLE_DELIVERY_TIMESTAMP_COLUMN_NAME, incomingIntraUserNetworkServiceMessage.getDeliveryTimestamp().getTime()); entityRecord.setStringValue( WalletStoreNetworkServiceDatabaseConstants.INCOMING_MESSAGES_TABLE_STATUS_COLUMN_NAME, incomingIntraUserNetworkServiceMessage.getStatus().getCode()); /* * return the new table record */ return entityRecord; }
/*SAVE NEW EVENT*/ public void saveNewEventTransaction(String eventType, String eventSource) throws CantSaveEventException { try { UUID eventId = UUID.randomUUID(); Date time = new Date(); long timestamp = time.getTime(); DatabaseTable table = this.database.getTable( CustomerBrokerNewNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_NEW_EVENT_TABLE_NAME); DatabaseTableRecord eventRecord = table.getEmptyRecord(); eventRecord.setUUIDValue( CustomerBrokerNewNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_NEW_EVENT_ID_COLUMN_NAME, eventId); eventRecord.setStringValue( CustomerBrokerNewNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_NEW_EVENT_TYPE_COLUMN_NAME, eventType); eventRecord.setStringValue( CustomerBrokerNewNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_NEW_EVENT_SOURCE_COLUMN_NAME, eventSource); eventRecord.setStringValue( CustomerBrokerNewNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_NEW_EVENT_STATUS_COLUMN_NAME, EventStatus.PENDING.getCode()); eventRecord.setLongValue( CustomerBrokerNewNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_NEW_EVENT_TIMESTAMP_COLUMN_NAME, timestamp); table.insertRecord(eventRecord); // System.out.print("\n\n**** 17) MOCK NEGOTIATION TRANSACTION - NEGOTIATION // TRANSMISSION - DAO - REGISTER NEW EVENT ****\n"); } catch (CantInsertRecordException exception) { throw new CantSaveEventException( exception, "Saving new event.", "Cannot insert a record in Asset Distribution database"); } catch (Exception exception) { throw new CantSaveEventException( FermatException.wrapException(exception), "Saving new event.", "Unexpected exception"); } }
public void saveNewEvent(String eventType, String eventSource) throws CantSaveEventException { try { this.database = openDatabase(); DatabaseTable databaseTable = this.database.getTable( AssetReceptionDatabaseConstants.ASSET_RECEPTION_EVENTS_RECORDED_TABLE_NAME); DatabaseTableRecord eventRecord = databaseTable.getEmptyRecord(); UUID eventRecordID = UUID.randomUUID(); long unixTime = System.currentTimeMillis(); Logger LOG = Logger.getGlobal(); LOG.info("ASSET DAO:\nUUID:" + eventRecordID + "\n" + unixTime); eventRecord.setUUIDValue( AssetReceptionDatabaseConstants.ASSET_RECEPTION_EVENTS_RECORDED_ID_COLUMN_NAME, eventRecordID); eventRecord.setStringValue( AssetReceptionDatabaseConstants.ASSET_RECEPTION_EVENTS_RECORDED_EVENT_COLUMN_NAME, eventType); eventRecord.setStringValue( AssetReceptionDatabaseConstants.ASSET_RECEPTION_EVENTS_RECORDED_SOURCE_COLUMN_NAME, eventSource); eventRecord.setStringValue( AssetReceptionDatabaseConstants.ASSET_RECEPTION_EVENTS_RECORDED_STATUS_COLUMN_NAME, EventStatus.PENDING.getCode()); eventRecord.setLongValue( AssetReceptionDatabaseConstants.ASSET_RECEPTION_EVENTS_RECORDED_TIMESTAMP_COLUMN_NAME, unixTime); databaseTable.insertRecord(eventRecord); LOG.info( "record:" + eventRecord.getStringValue( AssetReceptionDatabaseConstants .ASSET_RECEPTION_EVENTS_RECORDED_TABLE_FIRST_KEY_COLUMN)); } catch (CantExecuteDatabaseOperationException exception) { throw new CantSaveEventException( exception, "Saving new event.", "Cannot open or find the Asset Reception database"); } catch (CantInsertRecordException exception) { throw new CantSaveEventException( exception, "Saving new event.", "Cannot insert a record in Asset Reception database"); } catch (Exception exception) { throw new CantSaveEventException( FermatException.wrapException(exception), "Saving new event.", "Unexpected exception"); } }
// SAVE NEW EVENT public void saveNewEventTansaction(String eventType, String eventSource) throws CantSaveEventException { try { DatabaseTable table = this.database.getTable( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_EVENT_TABLE_NAME); DatabaseTableRecord eventRecord = table.getEmptyRecord(); UUID eventRecordID = UUID.randomUUID(); long unixTime = System.currentTimeMillis(); // Logger LOG = Logger.getGlobal(); // LOG.info("Distribution DAO:\nUUID:" + eventRecordID + "\n" + unixTime); eventRecord.setUUIDValue( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_EVENT_ID_COLUMN_NAME, eventRecordID); eventRecord.setStringValue( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_EVENT_TYPE_COLUMN_NAME, eventType); eventRecord.setStringValue( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_EVENT_SOURCE_COLUMN_NAME, eventSource); eventRecord.setStringValue( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_EVENT_STATUS_COLUMN_NAME, EventStatus.PENDING.getCode()); eventRecord.setLongValue( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_EVENT_TIMESTAMP_COLUMN_NAME, unixTime); table.insertRecord(eventRecord); } catch (CantInsertRecordException exception) { throw new CantSaveEventException( exception, "Saving new event.", "Cannot insert a record in Asset Distribution database"); } catch (Exception exception) { throw new CantSaveEventException( FermatException.wrapException(exception), "Saving new event.", "Unexpected exception"); } }
private void constructRecordFromExchangeRate( DatabaseTableRecord newRecord, ExchangeRate exchangeRate) { newRecord.setUUIDValue( BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_ID_COLUMN_NAME, UUID.randomUUID()); newRecord.setStringValue( BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_FROM_CURRENCY_COLUMN_NAME, exchangeRate.getFromCurrency().getCode()); newRecord.setStringValue( BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_TO_CURRENCY_COLUMN_NAME, exchangeRate.getToCurrency().getCode()); newRecord.setStringValue( BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_SALE_PRICE_COLUMN_NAME, String.valueOf(exchangeRate.getSalePrice())); newRecord.setStringValue( BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_PURCHASE_PRICE_COLUMN_NAME, String.valueOf(exchangeRate.getPurchasePrice())); newRecord.setLongValue( BitcoinVenezuelaProviderDatabaseConstants.DAILY_EXCHANGE_RATES_TIMESTAMP_COLUMN_NAME, exchangeRate.getTimestamp()); }
public void createCashMoneyWallet(String walletPublicKey, FiatCurrency fiatCurrency) throws CantCreateCashMoneyWalletException { if (walletExists(walletPublicKey)) throw new CantCreateCashMoneyWalletException( CantCreateCashMoneyWalletException.DEFAULT_MESSAGE, null, "Cant create Cash Money Wallet", "Cash Wallet already exists! publicKey:" + walletPublicKey); try { DatabaseTable table = this.database.getTable(CashMoneyWalletDatabaseConstants.WALLETS_TABLE_NAME); DatabaseTableRecord record = table.getEmptyRecord(); record.setStringValue( CashMoneyWalletDatabaseConstants.WALLETS_WALLET_PUBLIC_KEY_COLUMN_NAME, walletPublicKey); record.setStringValue( CashMoneyWalletDatabaseConstants.WALLETS_AVAILABLE_BALANCE_COLUMN_NAME, "0"); record.setStringValue(CashMoneyWalletDatabaseConstants.WALLETS_BOOK_BALANCE_COLUMN_NAME, "0"); record.setStringValue( CashMoneyWalletDatabaseConstants.WALLETS_CURRENCY_COLUMN_NAME, fiatCurrency.getCode()); record.setLongValue( CashMoneyWalletDatabaseConstants.WALLETS_TIMESTAMP_WALLET_CREATION_COLUMN_NAME, (new Date().getTime() / 1000)); table.insertRecord(record); } catch (CantInsertRecordException e) { errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_CSH_WALLET_CASH_MONEY, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw new CantCreateCashMoneyWalletException( CantCreateCashMoneyWalletException.DEFAULT_MESSAGE, e, "Cant create Cash Money Wallet", "Cant insert record into database"); } }
/** * (non-javadoc) * * @see AbstractBaseDao#getDatabaseTableRecordFromEntity */ @Override protected DatabaseTableRecord getDatabaseTableRecordFromEntity(NodeConnectionHistory entity) { DatabaseTableRecord databaseTableRecord = getDatabaseTable().getEmptyRecord(); databaseTableRecord.setUUIDValue( CommunicationsNetworkNodeP2PDatabaseConstants.NODES_CONNECTIONS_HISTORY_UUID_COLUMN_NAME, entity.getUuid()); databaseTableRecord.setLongValue( CommunicationsNetworkNodeP2PDatabaseConstants .NODES_CONNECTIONS_HISTORY_CONNECTION_TIMESTAMP_COLUMN_NAME, entity.getConnectionTimestamp().getTime()); databaseTableRecord.setIntegerValue( CommunicationsNetworkNodeP2PDatabaseConstants .NODES_CONNECTIONS_HISTORY_DEFAULT_PORT_COLUMN_NAME, entity.getDefaultPort()); databaseTableRecord.setStringValue( CommunicationsNetworkNodeP2PDatabaseConstants .NODES_CONNECTIONS_HISTORY_IDENTITY_PUBLIC_KEY_COLUMN_NAME, entity.getIdentityPublicKey()); databaseTableRecord.setStringValue( CommunicationsNetworkNodeP2PDatabaseConstants.NODES_CONNECTIONS_HISTORY_IP_COLUMN_NAME, entity.getIp()); databaseTableRecord.setDoubleValue( CommunicationsNetworkNodeP2PDatabaseConstants .NODES_CONNECTIONS_HISTORY_LAST_LATITUDE_COLUMN_NAME, entity.getLastLatitude()); databaseTableRecord.setDoubleValue( CommunicationsNetworkNodeP2PDatabaseConstants .NODES_CONNECTIONS_HISTORY_LAST_LONGITUDE_COLUMN_NAME, entity.getLastLongitude()); databaseTableRecord.setStringValue( CommunicationsNetworkNodeP2PDatabaseConstants.NODES_CONNECTIONS_HISTORY_STATUS_COLUMN_NAME, entity.getStatus()); return databaseTableRecord; }
// CREATE SEND NEW NEGOTIATION TRANSACTION public void createCustomerBrokerCloseNegotiationTransaction( UUID transactionId, Negotiation negotiation, NegotiationType negotiationType, NegotiationTransactionStatus statusTransaction) throws CantRegisterCustomerBrokerCloseNegotiationTransactionException { Date time = new Date(); long timestamp = time.getTime(); String negotiationXML = XMLParser.parseObject(negotiation); try { DatabaseTable table = this.database.getTable( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_TABLE_NAME); DatabaseTableRecord record = table.getEmptyRecord(); record.setUUIDValue( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_TRANSACTION_ID_COLUMN_NAME, transactionId); record.setUUIDValue( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_NEGOTIATION_ID_COLUMN_NAME, negotiation.getNegotiationId()); record.setStringValue( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_PUBLIC_KEY_BROKER_COLUMN_NAME, negotiation.getBrokerPublicKey()); record.setStringValue( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_PUBLIC_KEY_CUSTOMER_COLUMN_NAME, negotiation.getCustomerPublicKey()); record.setStringValue( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_STATUS_COLUMN_NAME, statusTransaction.getCode()); record.setStringValue( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_NEGOTIATION_TYPE_COLUMN_NAME, negotiationType.getCode()); record.setStringValue( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_NEGOTIATION_XML_COLUMN_NAME, negotiationXML); record.setLongValue( CustomerBrokerCloseNegotiationTransactionDatabaseConstants .CUSTOMER_BROKER_CLOSE_TIMESTAMP_COLUMN_NAME, timestamp); table.insertRecord(record); if (statusTransaction.getCode() == NegotiationTransactionStatus.PENDING_SUBMIT_CONFIRM.getCode()) { System.out.print( "\n\n**** 22) MOCK NEGOTIATION TRANSACTION - CUSTOMER BROKER CLOSE - DAO. CONFIRM negotiationType: " + negotiationType.getCode() + " transactionId: " + transactionId + " ****\n"); } else { System.out.print( "\n\n**** 4) MOCK NEGOTIATION TRANSACTION - CUSTOMER BROKER CLOSE - DAO. NEGOTIATION negotiationType: " + negotiationType.getCode() + "transactionId: " + transactionId + " ****\n"); } } catch (CantInsertRecordException e) { throw new CantRegisterCustomerBrokerCloseNegotiationTransactionException( e.getMessage(), e, "customer broker close Negotiation Transaction", "Cant create new customer broker close Negotiation Transaction, insert database problems."); } catch (Exception e) { throw new CantRegisterCustomerBrokerCloseNegotiationTransactionException( e.getMessage(), FermatException.wrapException(e), "customer broker close Negotiation Transaction", "Cant create new customer broker close Negotiation Transaction, unknown failure."); } }
private DatabaseTableRecord loadRecordAsSendNegotiationTransmission( DatabaseTableRecord record, NegotiationTransmission negotiationTransmission) { record.setUUIDValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_TRANSMISSION_ID_COLUMN_NAME, negotiationTransmission.getTransmissionId()); record.setUUIDValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_TRANSACTION_ID_COLUMN_NAME, negotiationTransmission.getTransactionId()); record.setUUIDValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_NEGOTIATION_ID_COLUMN_NAME, negotiationTransmission.getNegotiationId()); record.setStringValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_NEGOTIATION_TRANSACTION_TYPE_COLUMN_NAME, negotiationTransmission.getNegotiationTransactionType().getCode()); record.setStringValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_PUBLIC_KEY_ACTOR_SEND_COLUMN_NAME, negotiationTransmission.getPublicKeyActorSend()); record.setStringValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_ACTOR_SEND_TYPE_COLUMN_NAME, negotiationTransmission.getActorSendType().getCode()); record.setStringValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_PUBLIC_KEY_ACTOR_RECEIVE_COLUMN_NAME, negotiationTransmission.getPublicKeyActorReceive()); record.setStringValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_ACTOR_RECEIVE_TYPE_COLUMN_NAME, negotiationTransmission.getActorReceiveType().getCode()); record.setStringValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_TRANSMISSION_TYPE_COLUMN_NAME, negotiationTransmission.getTransmissionType().getCode()); record.setStringValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_TRANSMISSION_STATE_COLUMN_NAME, negotiationTransmission.getTransmissionState().getCode()); record.setStringValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_NEGOTIATION_TYPE_COLUMN_NAME, negotiationTransmission.getNegotiationType().getCode()); record.setStringValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_NEGOTIATION_XML_COLUMN_NAME, negotiationTransmission.getNegotiationXML()); record.setLongValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_TIMESTAMP_COLUMN_NAME, negotiationTransmission.getTimestamp()); // // record.setStringValue(NegotiationTransmissionNetworkServiceDatabaseConstants.OUTGOING_NOTIFICATION_PROTOCOL_STATE_COLUMN_NAME, negotiationTransmission.getActorProtocolState().getCode()); record.setStringValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_READ_MARK_COLUMN_NAME, String.valueOf(negotiationTransmission.isFlagRead())); record.setStringValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_NETWORK_SERVICE_PENDING_FLAG_COLUMN_NAME, String.valueOf(negotiationTransmission.isPendingFlag())); record.setIntegerValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_SENT_COUNT_COLUMN_NAME, negotiationTransmission.getSentCount()); if (negotiationTransmission.getResponseToNotificationId() != null) record.setUUIDValue( NegotiationTransmissionNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_RESPONSE_TO_NOTIFICATION_ID_COLUMN_NAME, negotiationTransmission.getResponseToNotificationId()); return record; }
private List<DatabaseTableRecord> constructBalanceInitialRecord( final DatabaseTable balancesTable) { List<DatabaseTableRecord> list = new ArrayList<>(); DatabaseTableRecord balancesRecord1 = balancesTable.getEmptyRecord(); UUID balanceRecordId = UUID.randomUUID(); balancesRecord1.setUUIDValue( BitcoinLossProtectedWalletDatabaseConstants .LOSS_PROTECTED_WALLET_BALANCE_TABLE_ID_COLUMN_NAME, balanceRecordId); balancesRecord1.setLongValue( BitcoinLossProtectedWalletDatabaseConstants .LOSS_PROTECTED_WALLET_BALANCE_TABLE_AVAILABLE_BALANCE_COLUMN_NAME, 0); balancesRecord1.setLongValue( BitcoinLossProtectedWalletDatabaseConstants .LOSS_PROTECTED_WALLET_BALANCE_TABLE_BOOK_BALANCE_COLUMN_NAME, 0); balancesRecord1.setStringValue( BitcoinLossProtectedWalletDatabaseConstants .LOSS_PROTECTED_WALLET_BALANCE_TABLE_RUNNING_NETWORK_TYPE, BlockchainNetworkType.PRODUCTION.getCode()); DatabaseTableRecord balancesRecord2 = balancesTable.getEmptyRecord(); UUID balanceRecordId2 = UUID.randomUUID(); balancesRecord2.setUUIDValue( BitcoinLossProtectedWalletDatabaseConstants .LOSS_PROTECTED_WALLET_BALANCE_TABLE_ID_COLUMN_NAME, balanceRecordId2); balancesRecord2.setLongValue( BitcoinLossProtectedWalletDatabaseConstants .LOSS_PROTECTED_WALLET_BALANCE_TABLE_AVAILABLE_BALANCE_COLUMN_NAME, 0); balancesRecord2.setLongValue( BitcoinLossProtectedWalletDatabaseConstants .LOSS_PROTECTED_WALLET_BALANCE_TABLE_BOOK_BALANCE_COLUMN_NAME, 0); balancesRecord2.setStringValue( BitcoinLossProtectedWalletDatabaseConstants .LOSS_PROTECTED_WALLET_BALANCE_TABLE_RUNNING_NETWORK_TYPE, BlockchainNetworkType.REG_TEST.getCode()); DatabaseTableRecord balancesRecord3 = balancesTable.getEmptyRecord(); UUID balanceRecordId3 = UUID.randomUUID(); balancesRecord3.setUUIDValue( BitcoinLossProtectedWalletDatabaseConstants .LOSS_PROTECTED_WALLET_BALANCE_TABLE_ID_COLUMN_NAME, balanceRecordId3); balancesRecord3.setLongValue( BitcoinLossProtectedWalletDatabaseConstants .LOSS_PROTECTED_WALLET_BALANCE_TABLE_AVAILABLE_BALANCE_COLUMN_NAME, 0); balancesRecord3.setLongValue( BitcoinLossProtectedWalletDatabaseConstants .LOSS_PROTECTED_WALLET_BALANCE_TABLE_BOOK_BALANCE_COLUMN_NAME, 0); balancesRecord3.setStringValue( BitcoinLossProtectedWalletDatabaseConstants .LOSS_PROTECTED_WALLET_BALANCE_TABLE_RUNNING_NETWORK_TYPE, BlockchainNetworkType.TEST_NET.getCode()); list.add(balancesRecord1); list.add(balancesRecord2); list.add(balancesRecord3); return list; }
private void loadRecordAsNew( DatabaseTableRecord databaseTableRecord, UUID trxId, String txHash, String walletPublicKey, CryptoAddress destinationAddress, long cryptoAmount, String op_Return, String notes, String deliveredByActorPublicKey, Actors deliveredByActorType, String deliveredToActorPublicKey, Actors deliveredToActorType, ReferenceWallet referenceWallet, boolean sameDevice, BlockchainNetworkType blockchainNetworkType) { databaseTableRecord.setUUIDValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_ID_COLUMN_NAME, trxId); // if(requestId != null) // // databaseTableRecord.setUUIDValue(OutgoingIntraActorTransactionDatabaseConstants.OUTGOING_DRAFT_REQUEST_ID_COLUMN_NAME, requestId); databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants .OUTGOING_DRAFT_WALLET_ID_TO_DEBIT_FROM_COLUMN_NAME, walletPublicKey); // TODO: This will be completed when the vault gives it to us databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_HASH_COLUMN_NAME, txHash); // TODO: This need to be completed in the future databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_ADDRESS_FROM_COLUMN_NAME, "MY_ADDRESS"); databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_ADDRESS_TO_COLUMN_NAME, destinationAddress.getAddress()); databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_CRYPTO_CURRENCY_COLUMN_NAME, destinationAddress.getCryptoCurrency().getCode()); databaseTableRecord.setLongValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_CRYPTO_AMOUNT_COLUMN_NAME, cryptoAmount); if (op_Return != null) databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_OP_RETURN_COLUMN_NAME, op_Return); databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_STATUS_COLUMN_NAME, com.bitdubai.fermat_ccp_plugin.layer.crypto_transaction.outgoing_draft.developer.bitdubai .version_1.enums.TransactionState.NEW.getCode()); // TODO: This have to be changed for the tinestamp when the network recognize the transaction // eze te saco la division para obtener el timestamp bien databaseTableRecord.setLongValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TIMESTAMP_COLUMN_NAME, System.currentTimeMillis()); databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_DESCRIPTION_COLUMN_NAME, notes); databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_CRYPTO_STATUS_COLUMN_NAME, CryptoStatus.PENDING_SUBMIT.getCode()); databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_ACTOR_FROM_PUBLIC_KEY_COLUMN_NAME, deliveredByActorPublicKey); databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_ACTOR_FROM_TYPE_COLUMN_NAME, deliveredByActorType.getCode()); databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_ACTOR_TO_PUBLIC_KEY_COLUMN_NAME, deliveredToActorPublicKey); databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_ACTOR_TO_TYPE_COLUMN_NAME, deliveredToActorType.getCode()); databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_SAME_DEVICE_COLUMN_NAME, String.valueOf(sameDevice)); databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_WALLET_REFERENCE_TYPE_COLUMN_NAME, referenceWallet.getCode()); databaseTableRecord.setStringValue( OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_RUNNING_NETWORK_TYPE, blockchainNetworkType.getCode()); }
private DatabaseTableRecord buildDatabaseRecord( final DatabaseTableRecord dbRecord, final ActorAssetNetworkServiceRecord record) throws CantBuildDataBaseRecordException { try { dbRecord.setUUIDValue( AssetUserNetworkServiceDatabaseConstants.INCOMING_NOTIFICATION_ID_COLUMN_NAME, record.getId()); dbRecord.setStringValue( AssetUserNetworkServiceDatabaseConstants.INCOMING_NOTIFICATION_SENDER_ALIAS_COLUMN_NAME, record.getActorSenderAlias()); dbRecord.setStringValue( AssetUserNetworkServiceDatabaseConstants.INCOMING_NOTIFICATION_DESCRIPTOR_COLUMN_NAME, record.getAssetNotificationDescriptor().getCode()); dbRecord.setStringValue( AssetUserNetworkServiceDatabaseConstants.INCOMING_NOTIFICATION_RECEIVER_TYPE_COLUMN_NAME, record.getActorDestinationType().getCode()); dbRecord.setStringValue( AssetUserNetworkServiceDatabaseConstants.INCOMING_NOTIFICATION_SENDER_TYPE_COLUMN_NAME, record.getActorSenderType().getCode()); dbRecord.setStringValue( AssetUserNetworkServiceDatabaseConstants .INCOMING_NOTIFICATION_SENDER_PUBLIC_KEY_COLUMN_NAME, record.getActorSenderPublicKey()); dbRecord.setStringValue( AssetUserNetworkServiceDatabaseConstants .INCOMING_NOTIFICATION_RECEIVER_PUBLIC_KEY_COLUMN_NAME, record.getActorDestinationPublicKey()); dbRecord.setLongValue( AssetUserNetworkServiceDatabaseConstants.INCOMING_NOTIFICATION_TIMESTAMP_COLUMN_NAME, record.getSentDate()); dbRecord.setStringValue( AssetUserNetworkServiceDatabaseConstants.INCOMING_NOTIFICATION_PROTOCOL_STATE_COLUMN_NAME, record.getActorAssetProtocolState().getCode()); dbRecord.setStringValue( AssetUserNetworkServiceDatabaseConstants.INCOMING_NOTIFICATION_READ_MARK_COLUMN_NAME, String.valueOf(record.isFlagRead())); if (record.getBlockchainNetworkType() != null) dbRecord.setStringValue( AssetUserNetworkServiceDatabaseConstants .INCOMING_NOTIFICATION_BLOCKCHAIN_NETWORK_TYPE_COLUMN_NAME, record.getBlockchainNetworkType().getCode()); if (record.getResponseToNotificationId() != null) dbRecord.setUUIDValue( AssetUserNetworkServiceDatabaseConstants .INCOMING_NOTIFICATION_RESPONSE_TO_NOTIFICATION_ID_COLUMN_NAME, record.getResponseToNotificationId()); /** Persist profile image on a file */ if (record.getActorSenderProfileImage() != null && record.getActorSenderProfileImage().length > 0) persistNewUserProfileImage( record.getActorSenderPublicKey(), record.getActorSenderProfileImage()); return dbRecord; } catch (Exception e) { throw new CantBuildDataBaseRecordException( CantBuildDataBaseRecordException.DEFAULT_MESSAGE, e, "", ""); } }