@Override public List<DeveloperDatabaseTableRecord> getDatabaseTableContent( DeveloperObjectFactory developerObjectFactory, DeveloperDatabase developerDatabase, DeveloperDatabaseTable developerDatabaseTable) { Database database; try { database = this.pluginDatabaseSystem.openDatabase( pluginId, AssetIssuingTransactionDatabaseConstants.DIGITAL_ASSET_TRANSACTION_DATABASE); return AssetIssuingTransactionDeveloperDatabaseFactory.getDatabaseTableContent( developerObjectFactory, database, developerDatabaseTable); } catch (CantOpenDatabaseException cantOpenDatabaseException) { /** The database exists but cannot be open. I can not handle this situation. */ FermatException e = new CantDeliverDatabaseException( "Cannot open the database", cantOpenDatabaseException, "DeveloperDatabase: " + developerDatabase.getName(), ""); this.errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_ASSET_ISSUING_TRANSACTION, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); } catch (DatabaseNotFoundException databaseNotFoundException) { FermatException e = new CantDeliverDatabaseException( "Database does not exists", databaseNotFoundException, "DeveloperDatabase: " + developerDatabase.getName(), ""); this.errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_ASSET_ISSUING_TRANSACTION, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); } catch (Exception exception) { FermatException e = new CantDeliverDatabaseException( "Unexpected Exception", FermatException.wrapException(exception), "DeveloperDatabase: " + developerDatabase.getName(), ""); this.errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_ASSET_ISSUING_TRANSACTION, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); } // If we are here the database could not be opened, so we return an empty list return new ArrayList<>(); }
@Override public List<DeveloperDatabaseTableRecord> getDatabaseTableContent( DeveloperObjectFactory developerObjectFactory, DeveloperDatabase developerDatabase, DeveloperDatabaseTable developerDatabaseTable) { Database database; try { database = this.pluginDatabaseSystem.openDatabase( pluginId, PublisherIdentityDatabaseConstants.PUBLISHER_DB_NAME); return PublisherIdentityDeveloperDataBaseFactory.getDatabaseTableContent( developerObjectFactory, database, developerDatabaseTable); } catch (CantOpenDatabaseException cantOpenDatabaseException) { /** The database exists but cannot be open. I can not handle this situation. */ FermatException e = new CantDeliverDatabaseException( "I can't open database", cantOpenDatabaseException, "WalletId: " + developerDatabase.getName(), ""); this.errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_WPD_PUBLISHER_IDENTITY, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); } catch (DatabaseNotFoundException databaseNotFoundException) { FermatException e = new CantDeliverDatabaseException( "Database does not exists", databaseNotFoundException, "WalletId: " + developerDatabase.getName(), ""); this.errorManager.reportUnexpectedPluginException( Plugins.BITDUBAI_WPD_PUBLISHER_IDENTITY, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); } // If we are here the database could not be opened, so we return an empry list return new ArrayList<>(); }
public final List<DeveloperDatabaseTableRecord> getDatabaseTableContent( final DeveloperObjectFactory developerObjectFactory, final DeveloperDatabase developerDatabase, final DeveloperDatabaseTable developerDatabaseTable) { try { initializeDatabase(developerDatabase.getId()); final List<DeveloperDatabaseTableRecord> returnedRecords = new ArrayList<>(); final DatabaseTable selectedTable = database.getTable(developerDatabaseTable.getName()); try { selectedTable.loadToMemory(); } catch (CantLoadTableToMemoryException cantLoadTableToMemory) { return returnedRecords; } final List<DatabaseTableRecord> records = selectedTable.getRecords(); List<String> developerRow; for (DatabaseTableRecord row : records) { developerRow = new ArrayList<>(); for (DatabaseRecord field : row.getValues()) developerRow.add(field.getValue()); returnedRecords.add( developerObjectFactory.getNewDeveloperDatabaseTableRecord(developerRow)); } return returnedRecords; } catch (Exception e) { System.err.println(e.toString()); return new ArrayList<>(); } }
public List<DeveloperDatabaseTable> getDatabaseTableList( final DeveloperObjectFactory developerObjectFactory, final DeveloperDatabase developerDatabase) { List<DeveloperDatabaseTable> tables = new ArrayList<>(); switch (developerDatabase.getId()) { case FanActorNetworkServiceDatabaseConstants.FAN_ACTOR_NETWORK_SERVICE_DATABASE_NAME: /** Table Connection News columns. */ List<String> connectionNewsColumns = new ArrayList<>(); connectionNewsColumns.add( FanActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_REQUEST_ID_COLUMN_NAME); connectionNewsColumns.add( FanActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_SENDER_PUBLIC_KEY_COLUMN_NAME); connectionNewsColumns.add( FanActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_SENDER_ACTOR_TYPE_COLUMN_NAME); connectionNewsColumns.add( FanActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_SENDER_ALIAS_COLUMN_NAME); connectionNewsColumns.add( FanActorNetworkServiceDatabaseConstants .CONNECTION_NEWS_DESTINATION_PUBLIC_KEY_COLUMN_NAME); connectionNewsColumns.add( FanActorNetworkServiceDatabaseConstants .CONNECTION_NEWS_DESTINATION_ACTOR_TYPE_COLUMN_NAME); connectionNewsColumns.add( FanActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_REQUEST_TYPE_COLUMN_NAME); connectionNewsColumns.add( FanActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_REQUEST_STATE_COLUMN_NAME); connectionNewsColumns.add( FanActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_REQUEST_ACTION_COLUMN_NAME); connectionNewsColumns.add( FanActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_REQUEST_SENT_COUNT_COLUMN_NAME); connectionNewsColumns.add( FanActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_SENT_TIME_COLUMN_NAME); /** Table Connection News addition. */ DeveloperDatabaseTable connectionNewsTable = developerObjectFactory.getNewDeveloperDatabaseTable( FanActorNetworkServiceDatabaseConstants.CONNECTION_NEWS_TABLE_NAME, connectionNewsColumns); tables.add(connectionNewsTable); break; case CommunicationNetworkServiceDatabaseConstants.DATA_BASE_NAME: /** Table incoming messages columns. */ List<String> incomingMessagesColumns = new ArrayList<>(); incomingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_ID_COLUMN_NAME); incomingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_SENDER_ID_COLUMN_NAME); incomingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_RECEIVER_ID_COLUMN_NAME); incomingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_TYPE_COLUMN_NAME); incomingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants .INCOMING_MESSAGES_SHIPPING_TIMESTAMP_COLUMN_NAME); incomingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants .INCOMING_MESSAGES_DELIVERY_TIMESTAMP_COLUMN_NAME); incomingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_STATUS_COLUMN_NAME); incomingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants .INCOMING_MESSAGES_TEXT_CONTENT_COLUMN_NAME); /** Table incoming messages addition. */ DeveloperDatabaseTable incomingMessagesTable = developerObjectFactory.getNewDeveloperDatabaseTable( CommunicationNetworkServiceDatabaseConstants.INCOMING_MESSAGES_TABLE_NAME, incomingMessagesColumns); tables.add(incomingMessagesTable); /** Table outgoing messages columns. */ List<String> outgoingMessagesColumns = new ArrayList<>(); outgoingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_ID_COLUMN_NAME); outgoingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_SENDER_ID_COLUMN_NAME); outgoingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_SENDER_TYPE_COLUMN_NAME); outgoingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants .OUTGOING_MESSAGES_SENDER_NS_TYPE_COLUMN_NAME); outgoingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_RECEIVER_ID_COLUMN_NAME); outgoingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants .OUTGOING_MESSAGES_RECEIVER_TYPE_COLUMN_NAME); outgoingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants .OUTGOING_MESSAGES_RECEIVER_NS_TYPE_COLUMN_NAME); outgoingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_TYPE_COLUMN_NAME); outgoingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants .OUTGOING_MESSAGES_SHIPPING_TIMESTAMP_COLUMN_NAME); outgoingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants .OUTGOING_MESSAGES_DELIVERY_TIMESTAMP_COLUMN_NAME); outgoingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_FAIL_COUNT_COLUMN_NAME); outgoingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_STATUS_COLUMN_NAME); outgoingMessagesColumns.add( CommunicationNetworkServiceDatabaseConstants .OUTGOING_MESSAGES_TEXT_CONTENT_COLUMN_NAME); /** Table outgoing messages addition. */ DeveloperDatabaseTable outgoingMessagesTable = developerObjectFactory.getNewDeveloperDatabaseTable( CommunicationNetworkServiceDatabaseConstants.OUTGOING_MESSAGES_TABLE_NAME, outgoingMessagesColumns); tables.add(outgoingMessagesTable); break; } return tables; }