public Database createDatabase(UUID ownerId, UUID walletId) throws CantCreateDatabaseException { Database database = null; try { database = this.pluginDatabaseSystem.createDatabase(ownerId, walletId.toString()); createLossProtetedWalletTable(ownerId, database.getDatabaseFactory()); createLossProtectedWalletBalancesTable(ownerId, database.getDatabaseFactory()); createLossProtectedWalletSpentTableFactory(ownerId, database.getDatabaseFactory()); insertInitialBalancesRecord(database); database.closeDatabase(); return database; } catch (CantCreateTableException | CantInsertRecordException exception) { if (database != null) database.closeDatabase(); throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, exception, null, "Check the cause"); } catch (CantCreateDatabaseException exception) { throw exception; } catch (Exception exception) { if (database != null) database.closeDatabase(); throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, FermatException.wrapException(exception), null, null); } }
private void setUpMockitoRules() throws Exception { when(mockDatabase.getDatabaseFactory()).thenReturn(mockDatabaseFactory); when(mockDatabaseTable.getEmptyRecord()).thenReturn(mockDatabaseTableRecord); when(mockDatabase.getTable(AssetIssuingDatabaseConstants.ASSET_ISSUING_TABLE_NAME)) .thenReturn(mockDatabaseTable); when(pluginDatabaseSystem.openDatabase( pluginId, AssetIssuingDatabaseConstants.ASSET_ISSUING_DATABASE)) .thenReturn(mockDatabase); // when(mockExtraUserActorDatabaseFactory.createDatabase(pluginId, // pluginId.toString())).thenReturn(mockDatabase); when(deviceUser.getPublicKey()).thenReturn("myPublicKey"); when(deviceUserManager.getLoggedInDeviceUser()).thenReturn(deviceUser); when(eventManager.getNewListener( EventType.INCOMING_ASSET_ON_CRYPTO_NETWORK_WAITING_TRANSFERENCE_ASSET_ISSUER)) .thenReturn(fermatEventListener1); when(eventManager.getNewListener( EventType.INCOMING_ASSET_ON_BLOCKCHAIN_WAITING_TRANSFERENCE_ASSET_ISSUER)) .thenReturn(fermatEventListener2); when(eventManager.getNewListener( EventType.INCOMING_ASSET_REVERSED_ON_BLOCKCHAIN_WAITING_TRANSFERENCE_ASSET_ISSUER)) .thenReturn(fermatEventListener3); when(eventManager.getNewListener( EventType.INCOMING_ASSET_REVERSED_ON_CRYPTO_NETWORK_WAITING_TRANSFERENCE_ASSET_ISSUER)) .thenReturn(fermatEventListener4); when(eventManager.getNewListener(EventType.RECEIVED_NEW_DIGITAL_ASSET_METADATA_NOTIFICATION)) .thenReturn(fermatEventListener5); when(actorAssetIssuerManager.getActorAssetIssuer()).thenReturn(actorAssetIssuer); }
private void setUpMockitoGeneralRules() throws Exception { when(mockPluginDatabaseSystem.createDatabase( pluginId, IntraWalletUserActorDatabaseConstants.INTRA_WALLET_USER_DATABASE_NAME)) .thenReturn(mockDatabase); when(mockDatabase.getDatabaseFactory()).thenReturn(mockDatabaseFactory); when(mockDatabaseFactory.newTableFactory( pluginId, IntraWalletUserActorDatabaseConstants.INTRA_WALLET_USER_TABLE_NAME)) .thenReturn(mockIntraUserTableFactory); when(mockDatabase.getTable(IntraWalletUserActorDatabaseConstants.INTRA_WALLET_USER_TABLE_NAME)) .thenReturn(mockTable); when(mockTable.getEmptyRecord()).thenReturn(mockTableRecord); }
public void setUpMockitoRules() throws Exception { when(mockDatabase.getDatabaseFactory()).thenReturn(mockDatabaseFactory); when(mockDatabaseTable.getEmptyRecord()).thenReturn(mockDatabaseTableRecord); when(mockDatabase.getTable(CryptoIndexDatabaseConstants.CRYPTO_INDEX_TABLE_NAME)) .thenReturn(mockDatabaseTable); when(mockPluginDatabaseSystem.openDatabase( pluginId, CryptoIndexDatabaseConstants.CRYPTO_INDEX_DATABASE_NAME)) .thenReturn(mockDatabase); when(mockCryptoIndexDatabaseFactory.createDatabase( pluginId, CryptoIndexDatabaseConstants.CRYPTO_INDEX_DATABASE_NAME)) .thenReturn(mockDatabase); cryptoIndexDao = new CryptoIndexDao(mockPluginDatabaseSystem, pluginId); }
private void setUpMockitoRules() throws Exception { when(mockDatabase.getDatabaseFactory()).thenReturn(mockDatabaseFactory); when(mockDatabaseTable.getEmptyRecord()).thenReturn(mockDatabaseTableRecord); when(mockDatabase.getTable( AssetIssuingTransactionDatabaseConstants.DIGITAL_ASSET_TRANSACTION_TABLE_NAME)) .thenReturn(mockDatabaseTable); when(mockDatabase.getTable( AssetIssuingTransactionDatabaseConstants .DIGITAL_ASSET_TRANSACTION_ASSET_ISSUING_TABLE_NAME)) .thenReturn(mockDatabaseTable2); when(mockDatabaseTable2.getEmptyRecord()).thenReturn(mockDatabaseTableRecord); when(mockDatabaseTable2.getRecords()).thenReturn(records); when(pluginDatabaseSystem.openDatabase( pluginId, AssetIssuingTransactionDatabaseConstants.DIGITAL_ASSET_TRANSACTION_DATABASE)) .thenReturn(mockDatabase); when(deviceUser.getPublicKey()).thenReturn("myPublicKey"); when(deviceUserManager.getLoggedInDeviceUser()).thenReturn(deviceUser); when(actorAssetIssuerManager.getActorAssetIssuer()).thenReturn(actorAssetIssuer); when(eventManager.getNewListener( EventType.INCOMING_ASSET_ON_CRYPTO_NETWORK_WAITING_TRANSFERENCE_ASSET_ISSUER)) .thenReturn(fermatEventListener1); when(eventManager.getNewListener( EventType.INCOMING_ASSET_ON_BLOCKCHAIN_WAITING_TRANSFERENCE_ASSET_ISSUER)) .thenReturn(fermatEventListener2); when(eventManager.getNewListener( EventType.INCOMING_ASSET_REVERSED_ON_BLOCKCHAIN_WAITING_TRANSFERENCE_ASSET_ISSUER)) .thenReturn(fermatEventListener3); when(eventManager.getNewListener( EventType.INCOMING_ASSET_REVERSED_ON_CRYPTO_NETWORK_WAITING_TRANSFERENCE_ASSET_ISSUER)) .thenReturn(fermatEventListener4); when(pluginFileSystem.createTextFile( this.pluginId, "digital-asset-issuing/publicKey", "name.xml", FilePrivacy.PUBLIC, FileLifeSpan.PERMANENT)) .thenReturn(pluginTextFile); when(bitcoinWalletManager.loadWallet(this.walletPublicKey)).thenReturn(bitcoinWalletWallet); when(bitcoinWalletWallet.getBalance(BalanceType.AVAILABLE)).thenReturn(bitcoinWalletBalance); when(bitcoinWalletBalance.getBalance()).thenReturn(bitcoinWalletAvailableBalance); when(assetVaultManager.getNewAssetVaultCryptoAddress(this.blockchainNetworkType)) .thenReturn(cryptoAddress); // doNothing().when(assetIssuingPluginRoot).issueAssets(digitalAsset, 1, walletPublicKey, // blockchainNetworkType); }
@Test public void Initialize_DatabaseNotFound_MethodSuccesfullyInvoked() throws Exception { when(mockPluginDatabaseSystem.openDatabase( testId, IncomingExtraUserDataBaseConstants.INCOMING_EXTRA_USER_DATABASE)) .thenThrow( new DatabaseNotFoundException( DatabaseNotFoundException.DEFAULT_MESSAGE, null, null, null)); when(mockPluginDatabaseSystem.createDatabase( testId, IncomingExtraUserDataBaseConstants.INCOMING_EXTRA_USER_DATABASE)) .thenReturn(mockDatabase); when(mockDatabase.getDatabaseFactory()).thenReturn(mockDatabaseFactory); when(mockDatabaseFactory.newTableFactory(any(UUID.class), anyString())) .thenReturn(mockTableFactory); testRegistry = new IncomingExtraUserRegistry(); testRegistry.setErrorManager(mockErrorManager); testRegistry.setPluginDatabaseSystem(mockPluginDatabaseSystem); catchException(testRegistry).initialize(testId); assertThat(caughtException()).isNull(); }
/** * Create the database * * @param ownerId the owner id * @param databaseName the database name * @return Database * @throws CantCreateDatabaseException */ protected Database createDatabase(UUID ownerId, String databaseName) throws CantCreateDatabaseException { Database database; /** I will create the database where I am going to store the information of this wallet. */ try { database = this.pluginDatabaseSystem.createDatabase(ownerId, databaseName); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /** I can not handle this situation. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateDatabaseException, "", "Exception not handled by the plugin, There is a problem and i cannot create the database."); } /** Next, I will add the needed tables. */ try { DatabaseTableFactory table; DatabaseFactory databaseFactory = database.getDatabaseFactory(); /** Create Wallet Identity table. */ table = databaseFactory.newTableFactory( ownerId, CustomersMiddlewareDatabaseConstants.CUSTOMERS_TABLE_NAME); table.addColumn( CustomersMiddlewareDatabaseConstants.CUSTOMERS_RELATIONSHIP_ID_COLUMN_NAME, DatabaseDataType.STRING, 36, Boolean.TRUE); table.addColumn( CustomersMiddlewareDatabaseConstants.CUSTOMERS_CRYPTO_BROKER_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( CustomersMiddlewareDatabaseConstants.CUSTOMERS_CRYPTO_CUSTOMER_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( CustomersMiddlewareDatabaseConstants.CUSTOMERS_CUSTOMER_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 20, Boolean.FALSE); table.addIndex(CustomersMiddlewareDatabaseConstants.CUSTOMERS_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } } catch (InvalidOwnerIdException invalidOwnerId) { /** * This shouldn't happen here because I was the one who gave the owner id to the database file * system, but anyway, if this happens, I can not continue. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, invalidOwnerId, "", "There is a problem with the ownerId of the database."); } return database; }
/** * Create the database * * @param ownerId the owner id * @param databaseName the database name * @return Database * @throws CantCreateDatabaseException */ protected Database createDatabase(UUID ownerId, String databaseName) throws CantCreateDatabaseException { Database database; /** I will create the database where I am going to store the information of this wallet. */ try { database = this.pluginDatabaseSystem.createDatabase(ownerId, databaseName); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /** I can not handle this situation. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateDatabaseException, "", "Exception not handled by the plugin, There is a problem and i cannot create the database."); } /** Next, I will add the needed tables. */ try { DatabaseTableFactory table; DatabaseFactory databaseFactory = database.getDatabaseFactory(); /** Create Wallets table. */ table = databaseFactory.newTableFactory( ownerId, MatchingEngineMiddlewareDatabaseConstants.WALLETS_TABLE_NAME); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.WALLETS_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.TEXT, 100, Boolean.TRUE); table.addIndex(MatchingEngineMiddlewareDatabaseConstants.WALLETS_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } /** Create Earning Pair table. */ table = databaseFactory.newTableFactory( ownerId, MatchingEngineMiddlewareDatabaseConstants.EARNING_PAIR_TABLE_NAME); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.EARNING_PAIR_ID_COLUMN_NAME, DatabaseDataType.TEXT, 100, Boolean.TRUE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.EARNING_PAIR_EARNING_CURRENCY_COLUMN_NAME, DatabaseDataType.TEXT, 10, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.EARNING_PAIR_EARNING_CURRENCY_TYPE_COLUMN_NAME, DatabaseDataType.TEXT, 10, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.EARNING_PAIR_LINKED_CURRENCY_COLUMN_NAME, DatabaseDataType.TEXT, 10, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.EARNING_PAIR_LINKED_CURRENCY_TYPE_COLUMN_NAME, DatabaseDataType.TEXT, 10, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants .EARNING_PAIR_EARNINGS_WALLET_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.TEXT, 100, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.EARNING_PAIR_WALLET_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.TEXT, 100, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.EARNING_PAIR_STATE_COLUMN_NAME, DatabaseDataType.TEXT, 10, Boolean.FALSE); table.addIndex(MatchingEngineMiddlewareDatabaseConstants.EARNING_PAIR_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } /** Create Earning Transaction table. */ table = databaseFactory.newTableFactory( ownerId, MatchingEngineMiddlewareDatabaseConstants.EARNING_TRANSACTION_TABLE_NAME); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.EARNING_TRANSACTION_ID_COLUMN_NAME, DatabaseDataType.TEXT, 100, Boolean.TRUE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants .EARNING_TRANSACTION_EARNING_CURRENCY_COLUMN_NAME, DatabaseDataType.TEXT, 10, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants .EARNING_TRANSACTION_EARNING_CURRENCY_TYPE_COLUMN_NAME, DatabaseDataType.TEXT, 10, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.EARNING_TRANSACTION_AMOUNT_COLUMN_NAME, DatabaseDataType.MONEY, 0, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.EARNING_TRANSACTION_STATE_COLUMN_NAME, DatabaseDataType.TEXT, 10, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.EARNING_TRANSACTION_TIME_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.EARNING_TRANSACTION_EARNING_PAIR_ID_COLUMN_NAME, DatabaseDataType.TEXT, 100, Boolean.FALSE); table.addIndex( MatchingEngineMiddlewareDatabaseConstants.EARNING_TRANSACTION_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } /** Create Input Transaction table. */ table = databaseFactory.newTableFactory( ownerId, MatchingEngineMiddlewareDatabaseConstants.INPUT_TRANSACTION_TABLE_NAME); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.INPUT_TRANSACTION_ID_COLUMN_NAME, DatabaseDataType.TEXT, 100, Boolean.TRUE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants .INPUT_TRANSACTION_ORIGIN_TRANSACTION_ID_COLUMN_NAME, DatabaseDataType.TEXT, 100, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.INPUT_TRANSACTION_CURRENCY_GIVING_COLUMN_NAME, DatabaseDataType.TEXT, 10, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants .INPUT_TRANSACTION_CURRENCY_GIVING_TYPE_COLUMN_NAME, DatabaseDataType.TEXT, 10, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.INPUT_TRANSACTION_AMOUNT_GIVING_COLUMN_NAME, DatabaseDataType.MONEY, 0, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants .INPUT_TRANSACTION_CURRENCY_RECEIVING_COLUMN_NAME, DatabaseDataType.TEXT, 10, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants .INPUT_TRANSACTION_CURRENCY_RECEIVING_TYPE_COLUMN_NAME, DatabaseDataType.TEXT, 10, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.INPUT_TRANSACTION_AMOUNT_RECEIVING_COLUMN_NAME, DatabaseDataType.MONEY, 0, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.INPUT_TRANSACTION_TYPE_COLUMN_NAME, DatabaseDataType.TEXT, 10, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.INPUT_TRANSACTION_STATE_COLUMN_NAME, DatabaseDataType.TEXT, 10, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants .INPUT_TRANSACTION_EARNING_TRANSACTION_ID_COLUMN_NAME, DatabaseDataType.TEXT, 100, Boolean.FALSE); table.addColumn( MatchingEngineMiddlewareDatabaseConstants.INPUT_TRANSACTION_EARNING_PAIR_ID_COLUMN_NAME, DatabaseDataType.TEXT, 100, Boolean.FALSE); table.addIndex(MatchingEngineMiddlewareDatabaseConstants.INPUT_TRANSACTION_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } } catch (InvalidOwnerIdException invalidOwnerId) { /** * This shouldn't happen here because I was the one who gave the owner id to the database file * system, but anyway, if this happens, I can not continue. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, invalidOwnerId, "", "There is a problem with the ownerId of the database."); } return database; }
/** * Create the database * * @param ownerId the owner id * @param databaseName the database name * @return Database * @throws CantCreateDatabaseException */ protected Database createDatabase(UUID ownerId, String databaseName) throws CantCreateDatabaseException { Database database; /** I will create the database where I am going to store the information of this wallet. */ try { database = this.pluginDatabaseSystem.createDatabase(ownerId, databaseName); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /** I can not handle this situation. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateDatabaseException, "", "Exception not handled by the plugin, There is a problem and i cannot create the database."); } /** Next, I will add the needed tables. */ try { DatabaseTableFactory table; DatabaseFactory databaseFactory = database.getDatabaseFactory(); /** Create Fiat Index table. */ table = databaseFactory.newTableFactory( ownerId, FiatIndexWorldDatabaseConstants.FIAT_INDEX_TABLE_NAME); table.addColumn( FiatIndexWorldDatabaseConstants.FIAT_INDEX_ID_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.TRUE); table.addColumn( FiatIndexWorldDatabaseConstants.FIAT_INDEX_CURRENCY_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( FiatIndexWorldDatabaseConstants.FIAT_INDEX_SALE_PRICE_COLUMN_NAME, DatabaseDataType.REAL, 100, Boolean.FALSE); table.addColumn( FiatIndexWorldDatabaseConstants.FIAT_INDEX_PURCHASE_PRICE_COLUMN_NAME, DatabaseDataType.REAL, 100, Boolean.FALSE); table.addColumn( FiatIndexWorldDatabaseConstants.FIAT_INDEX_PROVIDER_DESCRIPTION_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( FiatIndexWorldDatabaseConstants.FIAT_INDEX_TIMESTAMP_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 100, Boolean.FALSE); table.addIndex(FiatIndexWorldDatabaseConstants.FIAT_INDEX_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } } catch (InvalidOwnerIdException invalidOwnerId) { /** * This shouldn't happen here because I was the one who gave the owner id to the database file * system, but anyway, if this happens, I can not continue. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, invalidOwnerId, "", "There is a problem with the ownerId of the database."); } return database; }
/** * Create the database * * @param ownerId the owner id * @param databaseName the database name * @return Database * @throws CantCreateDatabaseException */ protected Database createDatabase(final UUID ownerId, final String databaseName) throws CantCreateDatabaseException { Database database; /** I will create the database where I am going to store the information of this wallet. */ try { database = this.pluginDatabaseSystem.createDatabase(ownerId, databaseName); } catch (final CantCreateDatabaseException e) { /** I can not handle this situation. */ throw new CantCreateDatabaseException( e, "", "Exception not handled by the plugin, There is a problem and i cannot create the database."); } /** Next, I will add the needed tables. */ try { DatabaseTableFactory table; com.bitdubai.fermat_api.layer.osa_android.database_system.DatabaseFactory databaseFactory = database.getDatabaseFactory(); /** Create Connection News table. */ table = databaseFactory.newTableFactory( ownerId, ChatActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_TABLE_NAME); table.addColumn( ChatActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_REQUEST_ID_COLUMN_NAME, DatabaseDataType.STRING, 36, Boolean.TRUE); table.addColumn( ChatActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_SENDER_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 130, Boolean.FALSE); table.addColumn( ChatActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_SENDER_ACTOR_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( ChatActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_SENDER_ALIAS_COLUMN_NAME, DatabaseDataType.STRING, 130, Boolean.FALSE); table.addColumn( ChatActorNetworkServiceDatabaseConstants .CONNECTION_NEWS_DESTINATION_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 130, Boolean.FALSE); table.addColumn( ChatActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_REQUEST_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( ChatActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_REQUEST_STATE_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( ChatActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_REQUEST_ACTION_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( ChatActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_SENT_TIME_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); table.addIndex(ChatActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } return database; } catch (InvalidOwnerIdException invalidOwnerId) { /** * This shouldn't happen here because I was the one who gave the owner id to the database file * system, but anyway, if this happens, I can not continue. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, invalidOwnerId, "", "There is a problem with the ownerId of the database."); } }
public Database createDatabase(UUID ownerId, String databaseName) throws CantCreateDatabaseException { try { Database database = this.pluginDatabaseSystem.createDatabase(ownerId, databaseName); DatabaseFactory databaseFactory = database.getDatabaseFactory(); DatabaseTableFactory outgoinExtraUserTable = databaseFactory.newTableFactory( ownerId, OutgoingExtraUserDatabaseConstants.OUTGOING_EXTRA_USER_TABLE_NAME); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants.OUTGOING_EXTRA_USER_TABLE_TRANSACTION_ID_COLUMN_NAME, DatabaseDataType.STRING, 36, true); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants .OUTGOING_EXTRA_USER_TABLE_WALLET_ID_TO_DEBIT_COLUMN_NAME, DatabaseDataType.STRING, 130, false); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants.OUTGOING_EXTRA_USER_TABLE_TRANSACTION_HASH_COLUMN_NAME, DatabaseDataType.STRING, 64, false); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants.OUTGOING_EXTRA_USER_TABLE_ADDRESS_FROM_COLUMN_NAME, DatabaseDataType.STRING, 34, false); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants.OUTGOING_EXTRA_USER_TABLE_ADDRESS_TO_COLUMN_NAME, DatabaseDataType.STRING, 34, false); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants.OUTGOING_EXTRA_USER_TABLE_CRYPTO_CURRENY_COLUMN_NAME, DatabaseDataType.STRING, 3, false); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants.OUTGOING_EXTRA_USER_TABLE_CRYPTO_AMOUNT_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, false); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants .OUTGOING_EXTRA_USER_TABLE_TRANSACTION_STATUS_COLUMN_NAME, DatabaseDataType.STRING, 10, false); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants.OUTGOING_EXTRA_USER_TABLE_DESCRIPTION_COLUMN_NAME, DatabaseDataType.STRING, 100, false); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants.OUTGOING_EXTRA_USER_TABLE_TIMESTAMP_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, false); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants.OUTGOING_EXTRA_USER_TABLE_CRYPTO_STATUS_COLUMN_NAME, DatabaseDataType.STRING, 10, false); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants.OUTGOING_EXTRA_USER_TABLE_ACTOR_FROM_ID_COLUMN_NAME, DatabaseDataType.STRING, 36, false); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants.OUTGOING_EXTRA_USER_TABLE_ACTOR_FROM_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 10, false); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants.OUTGOING_EXTRA_USER_TABLE_ACTOR_TO_ID_COLUMN_NAME, DatabaseDataType.STRING, 36, false); outgoinExtraUserTable.addColumn( OutgoingExtraUserDatabaseConstants.OUTGOING_EXTRA_USER_TABLE_ACTOR_TO_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 10, false); databaseFactory.createTable(ownerId, outgoinExtraUserTable); return database; } catch (CantCreateDatabaseException cantCreateDatabaseException) { throw cantCreateDatabaseException; } catch (InvalidOwnerIdException invalidOwnerId) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, invalidOwnerId); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException); } catch (Exception exception) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, FermatException.wrapException(exception), null, null); } }
protected Database createDatabase(UUID ownerId, String databaseName) throws CantCreateDatabaseException { try { Database database = this.pluginDatabaseSystem.createDatabase(ownerId, databaseName); DatabaseTableFactory table; DatabaseFactory databaseFactory = database.getDatabaseFactory(); /** Create Crypto Address Request table. */ table = databaseFactory.newTableFactory( ownerId, CryptoAddressesNetworkServiceDatabaseConstants.CRYPTO_ADDRESS_REQUEST_TABLE_NAME); table.addColumn( CryptoAddressesNetworkServiceDatabaseConstants .CRYPTO_ADDRESS_REQUEST_REQUEST_ID_COLUMN_NAME, DatabaseDataType.STRING, 40, Boolean.TRUE); table.addColumn( CryptoAddressesNetworkServiceDatabaseConstants .CRYPTO_ADDRESS_REQUEST_WALLET_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 130, Boolean.FALSE); table.addColumn( CryptoAddressesNetworkServiceDatabaseConstants .CRYPTO_ADDRESS_REQUEST_IDENTITY_TYPE_REQUESTING_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( CryptoAddressesNetworkServiceDatabaseConstants .CRYPTO_ADDRESS_REQUEST_IDENTITY_TYPE_ACCEPTING_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( CryptoAddressesNetworkServiceDatabaseConstants .CRYPTO_ADDRESS_REQUEST_IDENTITY_PUBLIC_KEY_REQUESTING_COLUMN_NAME, DatabaseDataType.STRING, 130, Boolean.FALSE); table.addColumn( CryptoAddressesNetworkServiceDatabaseConstants .CRYPTO_ADDRESS_REQUEST_IDENTITY_PUBLIC_KEY_ACCEPTING_COLUMN_NAME, DatabaseDataType.STRING, 130, Boolean.FALSE); table.addColumn( CryptoAddressesNetworkServiceDatabaseConstants .CRYPTO_ADDRESS_REQUEST_CRYPTO_ADDRESS_FROM_REQUEST_COLUMN_NAME, DatabaseDataType.STRING, 130, Boolean.FALSE); table.addColumn( CryptoAddressesNetworkServiceDatabaseConstants .CRYPTO_ADDRESS_REQUEST_CRYPTO_ADDRESS_FROM_RESPONSE_COLUMN_NAME, DatabaseDataType.STRING, 130, Boolean.FALSE); table.addColumn( CryptoAddressesNetworkServiceDatabaseConstants .CRYPTO_ADDRESS_REQUEST_CRYPTO_CURRENCY_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( CryptoAddressesNetworkServiceDatabaseConstants .CRYPTO_ADDRESS_REQUEST_BLOCKCHAIN_NETWORK_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( CryptoAddressesNetworkServiceDatabaseConstants.CRYPTO_ADDRESS_REQUEST_STATE_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addIndex( CryptoAddressesNetworkServiceDatabaseConstants.CRYPTO_ADDRESS_REQUEST_FIRST_KEY_COLUMN); try { databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } return database; } catch (CantCreateDatabaseException cantCreateDatabaseException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateDatabaseException, "", "Exception not handled by the plugin, There is a problem and i cannot create the database."); } catch (InvalidOwnerIdException invalidOwnerId) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, invalidOwnerId, "", "There is a problem with the ownerId of the database."); } }
/** * Method that create a new database and her tables. * * @return Object database. * @throws CantCreateDatabaseException */ public Database createDatabase(UUID pluginId) throws CantCreateDatabaseException { Database database; /** I will create the database where I am going to store the information of this User. */ try { database = this.pluginDatabaseSystem.createDatabase( pluginId, RedeemPointIdentityDatabaseConstants.REDEEM_POINT_IDENTITY_DB_NAME); /** Next, I will add the needed tables. */ DatabaseTableFactory table; /** Asset Issuer Identity table. */ DatabaseFactory databaseFactory = database.getDatabaseFactory(); table = databaseFactory.newTableFactory( RedeemPointIdentityDatabaseConstants.REDEEM_POINT_IDENTITY_TABLE_NAME); table.addColumn( RedeemPointIdentityDatabaseConstants.REDEEM_POINT_IDENTITY_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 130, true); table.addColumn( RedeemPointIdentityDatabaseConstants.REDEEM_POINT_IDENTITY_PRIVATE_KEY_COLUMN_NAME, DatabaseDataType.STRING, 130, false); table.addColumn( RedeemPointIdentityDatabaseConstants.REDEEM_POINT_IDENTITY_ALIAS_COLUMN_NAME, DatabaseDataType.STRING, 36, false); table.addColumn( RedeemPointIdentityDatabaseConstants.REDEEM_POINT_IDENTITY_STATUS_COLUMN_NAME, DatabaseDataType.STRING, 130, false); table.addColumn( RedeemPointIdentityDatabaseConstants .REDEEM_POINT_IDENTITY_DEVICE_USER_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 130, false); table.addIndex(RedeemPointIdentityDatabaseConstants.REDEEM_POINT_IDENTITY_FIRST_KEY_COLUMN); databaseFactory.createTable(table); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /** I can not handle this situation. */ String message = CantCreateDatabaseException.DEFAULT_MESSAGE; FermatException cause = cantCreateDatabaseException.getCause(); String context = "Asset Issuer Identity DataBase_Factory: " + cantCreateDatabaseException.getContext(); String possibleReason = "The exception is thrown the Create Database Asset Issuer Identity 'this.platformDatabaseSystem.createDatabase(\"AssetIssuerIdentity\")'" + cantCreateDatabaseException.getPossibleReason(); throw new CantCreateDatabaseException(message, cause, context, possibleReason); } catch (CantCreateTableException cantCreateTableException) { String message = CantCreateTableException.DEFAULT_MESSAGE; FermatException cause = cantCreateTableException.getCause(); String context = "Create Table Asset Issuer Identity" + cantCreateTableException.getContext(); String possibleReason = "The exception is generated when creating the table Asset Issuer Identity - DatabaseFactory.createTable(table) " + cantCreateTableException.getPossibleReason(); throw new CantCreateDatabaseException(message, cause, context, possibleReason); } catch (Exception exception) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, FermatException.wrapException(exception), null, null); } return database; }
/** * Create the database * * @param ownerId the owner id * @param databaseName the database name * @return Database * @throws CantCreateDatabaseException */ public Database createDatabase(UUID ownerId, String databaseName) throws CantCreateDatabaseException { Database database; /** I will create the database where I am going to store the information of this wallet. */ try { database = this.pluginDatabaseSystem.createDatabase(ownerId, databaseName); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /** I can not handle this situation. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateDatabaseException, "Chat Identity", "Exception not handled by the plugin, There is a problem and i cannot create the database."); } /** Next, I will add the needed tables. */ try { DatabaseTableFactory table; DatabaseFactory databaseFactory = database.getDatabaseFactory(); /** Create Chat Identity */ table = databaseFactory.newTableFactory(ownerId, ChatIdentityDatabaseConstants.CHAT_TABLE_NAME); table.addColumn( ChatIdentityDatabaseConstants.CHAT_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 255, Boolean.TRUE); table.addColumn( ChatIdentityDatabaseConstants.CHAT_ALIAS_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( ChatIdentityDatabaseConstants.CHAT_DEVICE_USER_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 255, Boolean.FALSE); table.addColumn( ChatIdentityDatabaseConstants.CHAT_EXPOSURE_LEVEL_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addIndex(ChatIdentityDatabaseConstants.CHAT_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "Chat Identity", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } } catch (InvalidOwnerIdException invalidOwnerId) { /** * This shouldn't happen here because I was the one who gave the owner id to the database file * system, but anyway, if this happens, I can not continue. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, invalidOwnerId, "Chat Identity", "There is a problem with the ownerId of the database."); } return database; }
/** * Create the database * * @param ownerId the owner id * @param databaseName the database name * @return Database * @throws CantCreateDatabaseException */ protected Database createDatabase(UUID ownerId, String databaseName) throws CantCreateDatabaseException { Database database; /** I will create the database where I am going to store the information of this wallet. */ try { database = this.pluginDatabaseSystem.createDatabase(ownerId, databaseName); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /** I can not handle this situation. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateDatabaseException, "", "Exception not handled by the plugin, There is a problem and i cannot create the database."); } /** Next, I will add the needed tables. */ try { DatabaseTableFactory table; DatabaseFactory databaseFactory = database.getDatabaseFactory(); /** Create Incoming_Transactions table. */ table = databaseFactory.newTableFactory( ownerId, BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_TABLE_NAME); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_TRX_ID_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_HASH_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_BLOCK_HASH_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_BLOCKCHAIN_NETWORK_TYPE, DatabaseDataType.STRING, 20, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_CRYPTO_STATUS_COLUMN_NAME, DatabaseDataType.STRING, 30, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_BLOCK_DEPTH_COLUMN_NAME, DatabaseDataType.INTEGER, 10, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_ADDRESS_TO_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_ADDRESS_FROM_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_BTC_AMOUNT_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 10, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_FEE_AMOUNT_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 10, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_CRYPTO_AMOUNT_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 10, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_OP_RETURN_COLUMN_NAME, DatabaseDataType.STRING, 150, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_PROTOCOL_STATUS_COLUMN_NAME, DatabaseDataType.STRING, 30, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_LAST_UPDATE_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 5, Boolean.FALSE); table.addIndex(BitcoinCryptoNetworkDatabaseConstants.TRANSACTIONS_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } /** Create CryptoVaults_Stats table. */ table = databaseFactory.newTableFactory( ownerId, BitcoinCryptoNetworkDatabaseConstants.CRYPTOVAULTS_STATS_TABLE_NAME); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.CRYPTOVAULTS_STATS_CRYPTO_VAULT_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants .CRYPTOVAULTS_STATS_LAST_CONNECTION_REQUEST_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.CRYPTOVAULTS_STATS_MONITORED_PUBLICKEYS_COLUMN_NAME, DatabaseDataType.INTEGER, 10, Boolean.FALSE); table.addIndex(BitcoinCryptoNetworkDatabaseConstants.CRYPTOVAULTS_STATS_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } /** Create CryptoVaults_detailed_Stats table. */ table = databaseFactory.newTableFactory( ownerId, BitcoinCryptoNetworkDatabaseConstants.CRYPTOVAULTS_DETAILED_STATS_TABLE_NAME); table.addColumn( BitcoinCryptoNetworkDatabaseConstants .CRYPTOVAULTS_DETAILED_STATS_CRYPTO_VAULT_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.CRYPTOVAULTS_DETAILED_STATS_NETWORK_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.CRYPTOVAULTS_DETAILED_STATS_ORDER_COLUMN_NAME, DatabaseDataType.INTEGER, 0, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants .CRYPTOVAULTS_DETAILED_STATS_MONITORED_PUBLICKEYS_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants .CRYPTOVAULTS_DETAILED_STATS_MONITORED_ADDRESSES_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addIndex( BitcoinCryptoNetworkDatabaseConstants.CRYPTOVAULTS_DETAILED_STATS_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } /** Create EventAgent_Stats table. */ table = databaseFactory.newTableFactory( ownerId, BitcoinCryptoNetworkDatabaseConstants.EVENTAGENT_STATS_TABLE_NAME); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.EVENTAGENT_STATS_EXECUTION_NUMBER_COLUMN_NAME, DatabaseDataType.INTEGER, 10, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.EVENTAGENT_STATS_LAST_EXECUTION_DATE_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants .EVENTAGENT_STATS_PENDING_INCOMING_TRANSACTIONS_COLUMN_NAME, DatabaseDataType.INTEGER, 10, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants .EVENTAGENT_STATS_PENDING_OUTGOING_TRANSACTIONS_COLUMN_NAME, DatabaseDataType.INTEGER, 10, Boolean.FALSE); table.addIndex(BitcoinCryptoNetworkDatabaseConstants.EVENTAGENT_STATS_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } /** Create Broadcast table. */ table = databaseFactory.newTableFactory( ownerId, BitcoinCryptoNetworkDatabaseConstants.BROADCAST_TABLE_NAME); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.BROADCAST_EXECUTION_NUMBER_COLUMN_NAME, DatabaseDataType.INTEGER, 10, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.BROADCAST_NETWORK, DatabaseDataType.STRING, 20, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.BROADCAST_TRANSACTION_ID, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.BROADCAST_TX_HASH, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.BROADCAST_PEER_COUNT, DatabaseDataType.INTEGER, 10, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.BROADCAST_PEER_BROADCAST_IP, DatabaseDataType.STRING, 50, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.BROADCAST_RETRIES_COUNT, DatabaseDataType.INTEGER, 5, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.BROADCAST_STATUS, DatabaseDataType.STRING, 5, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.BROADCAST_EXCEPTION, DatabaseDataType.STRING, 300, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.BROADCAST_LAST_EXECUTION_DATE_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 10, Boolean.FALSE); table.addIndex(BitcoinCryptoNetworkDatabaseConstants.BRTOADCAST_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } /** Create ACTIVENETWORKS table. */ table = databaseFactory.newTableFactory( ownerId, BitcoinCryptoNetworkDatabaseConstants.ACTIVENETWORKS_TABLE_NAME); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.ACTIVENETWORKS_NETWORKTYPE, DatabaseDataType.STRING, 20, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.ACTIVENETWORKS_KEYS, DatabaseDataType.INTEGER, 0, Boolean.FALSE); table.addColumn( BitcoinCryptoNetworkDatabaseConstants.ACTIVENETWORKS_LAST_UPDATE, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); table.addIndex(BitcoinCryptoNetworkDatabaseConstants.ACTIVENETWORKS_NETWORKTYPE); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } } catch (InvalidOwnerIdException invalidOwnerId) { /** * This shouldn't happen here because I was the one who gave the owner id to the database file * system, but anyway, if this happens, I can not continue. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, invalidOwnerId, "", "There is a problem with the ownerId of the database."); } return database; }
/** * Create the database * * @param ownerId the owner id * @param databaseName the database name * @return Database * @throws CantCreateDatabaseException */ public Database createDatabase(UUID ownerId, String databaseName) throws CantCreateDatabaseException { Database database; /** I will create the database where I am going to store the information of this wallet. */ try { database = this.pluginDatabaseSystem.createDatabase(ownerId, databaseName); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /** I can not handle this situation. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateDatabaseException, "", "Exception not handled by the plugin, There is a problem and i cannot create the database."); } /** Next, I will add the needed tables. */ try { DatabaseTableFactory table; DatabaseFactory databaseFactory = database.getDatabaseFactory(); /** Create incoming messages table. */ table = databaseFactory.newTableFactory( ownerId, CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_TABLE_NAME); table.addColumn( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_ID_COLUMN_NAME, DatabaseDataType.STRING, 36, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_SENDER_ID_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_RECEIVER_ID_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_TEXT_CONTENT_COLUMN_NAME, DatabaseDataType.STRING, 255, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .INCOMING_MESSAGES_SHIPPING_TIMESTAMP_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .INCOMING_MESSAGES_DELIVERY_TIMESTAMP_COLUMN_NAME, DatabaseDataType.STRING, 255, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_STATUS_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addIndex( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } /** Create outgoing messages table. */ table = databaseFactory.newTableFactory( ownerId, CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_TABLE_NAME); table.addColumn( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_ID_COLUMN_NAME, DatabaseDataType.STRING, 36, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_SENDER_ID_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_RECEIVER_ID_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_TEXT_CONTENT_COLUMN_NAME, DatabaseDataType.STRING, 255, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .OUTGOING_MESSAGES_SHIPPING_TIMESTAMP_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .OUTGOING_MESSAGES_DELIVERY_TIMESTAMP_COLUMN_NAME, DatabaseDataType.STRING, 255, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_STATUS_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addIndex( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } /* * Create outgoing notification table. */ table = databaseFactory.newTableFactory( ownerId, CommunicationNetworkServiceDatabaseConstants.OUTGOING_NOTIFICATION_TABLE_NAME); table.addColumn( CommunicationNetworkServiceDatabaseConstants.OUTGOING_NOTIFICATION_ID_COLUMN_NAME, DatabaseDataType.STRING, 36, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_SENDER_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 50, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_RECEIVER_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 50, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_SENDER_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 25, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_RECEIVER_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 25, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.OUTGOING_NOTIFICATION_TIMESTAMP_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 59, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_SENDER_ALIAS_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_SENDER_IMAGE_COLUMN_NAME, DatabaseDataType.STRING, 255, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.OUTGOING_NOTIFICATION_DESCRIPTOR_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .OUTGOING_NOTIFICATION_PROTOCOL_STATE_COLUMN_NAME, DatabaseDataType.STRING, 30, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.OUTGOING_NOTIFICATION_READ_MARK_COLUMN_NAME, DatabaseDataType.STRING, 6, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.OUTGOING_NOTIFICATION_SENT_COUNT_COLUMN_NAME, DatabaseDataType.INTEGER, 6, Boolean.FALSE); table.addIndex( CommunicationNetworkServiceDatabaseConstants.OUTGOING_NOTIFICATION_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } /* * Create incoming messages table. */ table = databaseFactory.newTableFactory( ownerId, CommunicationNetworkServiceDatabaseConstants.INCOMING_NOTIFICATION_TABLE_NAME); table.addColumn( CommunicationNetworkServiceDatabaseConstants.INCOMING_NOTIFICATION_ID_COLUMN_NAME, DatabaseDataType.STRING, 36, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .INCOMING_NOTIFICATION_SENDER_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 50, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .INCOMING_NOTIFICATION_RECEIVER_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 50, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .INCOMING_NOTIFICATION_SENDER_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 25, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .INCOMING_NOTIFICATION_RECEIVER_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 25, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.INCOMING_NOTIFICATION_TIMESTAMP_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 50, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .INCOMING_NOTIFICATION_SENDER_ALIAS_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .INCOMING_NOTIFICATION_SENDER_IMAGE_COLUMN_NAME, DatabaseDataType.STRING, 255, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.INCOMING_NOTIFICATION_DESCRIPTOR_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants .INCOMING_NOTIFICATION_PROTOCOL_STATE_COLUMN_NAME, DatabaseDataType.STRING, 6, Boolean.FALSE); table.addColumn( CommunicationNetworkServiceDatabaseConstants.INCOMING_NOTIFICATION_READ_MARK_COLUMN_NAME, DatabaseDataType.STRING, 6, Boolean.FALSE); table.addIndex( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } } catch (InvalidOwnerIdException invalidOwnerId) { /** * This shouldn't happen here because I was the one who gave the owner id to the database file * system, but anyway, if this happens, I can not continue. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, invalidOwnerId, "", "There is a problem with the ownerId of the database."); } return database; }
public Database createDatabase(UUID ownerId, String databaseName) throws CantCreateDatabaseException { Database database; /** I will create the database where I am going to store the information of this wallet. */ try { database = this.pluginDatabaseSystem.createDatabase(ownerId, databaseName); } catch (CantCreateDatabaseException exception) { /** I can not handle this situation. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, exception, "", "Exception not handled by the plugin, There is a problem and i cannot create the database."); } /** Next, I will add the needed tables. */ try { DatabaseTableFactory table; DatabaseFactory databaseFactory = database.getDatabaseFactory(); /** Create Asset Issuer database table. */ table = databaseFactory.newTableFactory( ownerId, RedeemPointActorDatabaseConstants.REDEEM_POINT_TABLE_NAME); // PUBLIC KEYS table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.TRUE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_LINKED_IDENTITY_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_NAME_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_CONNECTION_STATE_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTRATION_DATE_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_MODIFIED_DATE_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_CONTACT_INFORMATION_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_HOURS_OF_OPERATION_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); // COLUMNAS DE ADDRESS table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_ADDRESS_COUNTRY_NAME_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_ADDRESS_POSTAL_CODE_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_ADDRESS_PROVINCE_NAME_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_ADDRESS_CITY_NAME_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_ADDRESS_STREET_NAME_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_ADDRESS_HOUSE_NUMBER_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); // COLUMAS DE CRYPTOADDRESS table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_CRYPTO_ADDRESS_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_CRYPTO_CURRENCY_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); // COLUMNAS DE LOCATION table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_LOCATION_LATITUDE_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_LOCATION_LONGITUDE_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addIndex(RedeemPointActorDatabaseConstants.REDEEM_POINT_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } // CREATE THE REGISTERED TABLE. table = databaseFactory.newTableFactory( ownerId, RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_TABLE_NAME); // PUBLIC KEYS table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.TRUE); table.addColumn( RedeemPointActorDatabaseConstants .REDEEM_POINT_REGISTERED_LINKED_IDENTITY_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_NAME_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_CONNECTION_STATE_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_REGISTRATION_DATE_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_MODIFIED_DATE_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_CONTACT_INFORMATION_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_HOURS_OF_OPERATION_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); // COLUMNAS DE ADDRESS table.addColumn( RedeemPointActorDatabaseConstants .REDEEM_POINT_REGISTERED_ADDRESS_COUNTRY_NAME_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_ADDRESS_POSTAL_CODE_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants .REDEEM_POINT_REGISTERED_ADDRESS_PROVINCE_NAME_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_ADDRESS_CITY_NAME_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_ADDRESS_STREET_NAME_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants .REDEEM_POINT_REGISTERED_ADDRESS_HOUSE_NUMBER_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); // COLUMAS DE CRYPTOADDRESS table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_CRYPTO_ADDRESS_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_CRYPTO_CURRENCY_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); // COLUMNAS DE LOCATION table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_LOCATION_LATITUDE_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_LOCATION_LONGITUDE_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addIndex(RedeemPointActorDatabaseConstants.REDEEM_POINT_REGISTERED_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } /** Create Asset Issuer relation Redeem Point Associate table. */ // table = databaseFactory.newTableFactory(ownerId, // RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ISSUER_TABLE_NAME); // // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ISSUER_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.TRUE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ISSUER_REDEEM_POINT_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.TRUE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ISSUER_NAME_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ISSUER_STATUS_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ISSUER_ASSETS_COUNT_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ISSUER_REGISTRATION_DATE_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 10, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ISSUER_REDEEM_POINT_NAME_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ISSUER_REDEEM_POINT_STATUS_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ISSUER_REDEEM_POINT_REGISTRATION_DATE_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ISSUER_REDEEM_POINT_MODIFIED_DATE_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); // // // table.addIndex(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ISSUER_ASSET_FIRST_KEY_COLUMN); // // try { // //Create the table // databaseFactory.createTable(ownerId, table); // } catch (CantCreateTableException cantCreateTableException) { // throw new // CantCreateDatabaseException(CantCreateDatabaseException.DEFAULT_MESSAGE, // cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and // i cannot create the table."); // } /** Create Asset Issuer relation Asset User table. */ // table = databaseFactory.newTableFactory(ownerId, // RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_TABLE_NAME); // // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_USER_PUBLIC_KEY_COLUMN_NAME, DatabaseDataType.STRING, 256, Boolean.TRUE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_RELATION_ISSUER_NAME_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_ISSUER_IDENTITY_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_USER_NAME_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_USER_SEX_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_USER_UBICACION_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_USER_AGE_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_ASSET_DESCRIPTION_COLUMN_NAME, DatabaseDataType.STRING, 200, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_ASSET_NAME_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_ASSET_ID_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_ASSET_HASH_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_ASSET_STATUS_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_ASSET_RESOURCES_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_ASSET_AMOUNT_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_ASSET_CURRENCY_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_ASSET_EXPIRATION_DATE_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_REDEEMPTION_TIMESTAMP_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); // // table.addColumn(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_REDEEMPTION_DATE_COLUMN_NAME, DatabaseDataType.LONG_INTEGER, 0, Boolean.FALSE); // // // table.addIndex(RedeemPointActorDatabaseConstants.REDEEM_POINT_RELATION_ASSET_USER_FIRST_KEY_COLUMN); // // try { // //Create the table // databaseFactory.createTable(ownerId, table); // } catch (CantCreateTableException cantCreateTableException) { // throw new // CantCreateDatabaseException(CantCreateDatabaseException.DEFAULT_MESSAGE, // cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and // i cannot create the table."); // } } catch (InvalidOwnerIdException exception) { /** * This shouldn't happen here because I was the one who gave the owner id to the database file * system, but anyway, if this happens, I can not continue. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, exception, "", "There is a problem with the ownerId of the database."); } return database; }
/** * Create the database * * @param ownerId the owner id * @param databaseName the database name * @return Database * @throws CantCreateDatabaseException */ public Database createDatabase(UUID ownerId, String databaseName) throws CantCreateDatabaseException { Database database; /** I will create the database where I am going to store the information of this wallet. */ try { database = this.pluginDatabaseSystem.createDatabase(ownerId, databaseName); } catch (CantCreateDatabaseException cantCreateDatabaseException) { /** I can not handle this situation. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateDatabaseException, "", "Exception not handled by the plugin, There is a problem and i cannot create the database."); } /** Next, I will add the needed tables. */ try { DatabaseTableFactory table; DatabaseFactory databaseFactory = database.getDatabaseFactory(); /** Create System Data table. */ table = databaseFactory.newTableFactory( ownerId, SystemMonitorNetworkServiceDatabaseConstants.SYSTEM_DATA_TABLE_NAME); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.SYSTEM_DATA_SYSTEM_ID_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.TRUE); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.SYSTEM_DATA_NODE_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 10, Boolean.FALSE); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.SYSTEM_DATA_HARDWARE_COLUMN_NAME, DatabaseDataType.STRING, 15, Boolean.FALSE); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.SYSTEM_DATA_OS_COLUMN_NAME, DatabaseDataType.STRING, 50, Boolean.FALSE); table.addIndex(SystemMonitorNetworkServiceDatabaseConstants.SYSTEM_DATA_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } /** Create Connections table. */ table = databaseFactory.newTableFactory( ownerId, SystemMonitorNetworkServiceDatabaseConstants.CONNECTIONS_TABLE_NAME); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.CONNECTIONS_CONNID_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.TRUE); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.CONNECTIONS_PEERID_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.CONNECTIONS_PEER_IPV4_COLUMN_NAME, DatabaseDataType.STRING, 15, Boolean.FALSE); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.CONNECTIONS_PEER_IPV6_COLUMN_NAME, DatabaseDataType.STRING, 50, Boolean.FALSE); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.CONNECTIONS_NETWORK_SERVICE_NAME_COLUMN_NAME, DatabaseDataType.STRING, 50, Boolean.FALSE); table.addIndex(SystemMonitorNetworkServiceDatabaseConstants.CONNECTIONS_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } /** Create Services table. */ table = databaseFactory.newTableFactory( ownerId, SystemMonitorNetworkServiceDatabaseConstants.SERVICES_TABLE_NAME); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.SERVICES_ID_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.TRUE); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.SERVICES_NAME_COLUMN_NAME, DatabaseDataType.STRING, 100, Boolean.FALSE); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.SERVICES_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 15, Boolean.FALSE); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.SERVICES_SUBTYPE_COLUMN_NAME, DatabaseDataType.STRING, 15, Boolean.FALSE); table.addIndex(SystemMonitorNetworkServiceDatabaseConstants.SERVICES_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } table = databaseFactory.newTableFactory( ownerId, SystemMonitorNetworkServiceDatabaseConstants.PLATFORM_COMPONENTS_TABLE_NAME); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.COMPONENT_ID_COLUMN_NAME, DatabaseDataType.STRING, 50, Boolean.TRUE); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.COMPONENT_NAME_COLUMN_NAME, DatabaseDataType.STRING, 40, Boolean.FALSE); table.addColumn( SystemMonitorNetworkServiceDatabaseConstants.COMPONENT_TYPE_COLUMN_NAME, DatabaseDataType.STRING, 15, Boolean.FALSE); table.addIndex(SystemMonitorNetworkServiceDatabaseConstants.COMPONENT_FIRST_KEY_COLUMN); try { // Create the table databaseFactory.createTable(ownerId, table); } catch (CantCreateTableException cantCreateTableException) { throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, cantCreateTableException, "", "Exception not handled by the plugin, There is a problem and i cannot create the table."); } } catch (InvalidOwnerIdException invalidOwnerId) { /** * This shouldn't happen here because I was the one who gave the owner id to the database file * system, but anyway, if this happens, I can not continue. */ throw new CantCreateDatabaseException( CantCreateDatabaseException.DEFAULT_MESSAGE, invalidOwnerId, "", "There is a problem with the ownerId of the database."); } return database; }