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; }