@Test public void testGetDisplayerSettings() { expectedDataSetUUID = DATASOURCE_UUID + SEPARATOR + SCHEMA + SEPARATOR + TABLE; DataSetLookup expectedLookup = new DataSetLookup(); expectedLookup.setDataSetUUID(expectedDataSetUUID); DataSet expectedSet = mock(DataSet.class); List<DataColumn> dataColumns = new ArrayList<>(); for (int i = 0; i < COLUMNS_COUNT; i++) { DataColumn dataColumn = mock(DataColumn.class); when(dataColumn.getId()).thenReturn(DATA_COLUMN + String.valueOf(i)); dataColumns.add(dataColumn); } when(expectedSet.getColumns()).thenReturn(dataColumns); when(dataSetManager.lookupDataSet(expectedLookup)).thenReturn(expectedSet); DisplayerSettings settings = dataManagementService.getDisplayerSettings(DATASOURCE_UUID, SCHEMA, TABLE); verify(dataSetDefRegistry, times(1)).registerDataSetDef(dataSetDefCaptor.capture()); verifyDataSetDef(dataSetDefCaptor.getValue()); verifySettings(settings); }
@Override public DisplayerSettings getDisplayerSettings(String dataSourceUuid, String schema, String table) { checkNotNull("dataSourceUuid", dataSourceUuid); checkNotNull("table", table); try { DataSourceDeploymentInfo deploymentInfo = dataSourceRuntimeManager.getDataSourceDeploymentInfo(dataSourceUuid); DataSetDef dataSetDef = DataSetDefBuilder.newBuilder() .dataSetUuid(buildDataSetUuid(dataSourceUuid, schema, table)) .dataSetName(buildDataSetName(schema, table)) .dataSourceUuid(deploymentInfo.getUuid()) .schema(schema) .table(buildDataSetTableName(dataSourceUuid, table)) .isPublic(false) .build(); dataSetDefRegistry.registerDataSetDef(dataSetDef); DataSetLookup lookup = new DataSetLookup(); lookup.setDataSetUUID(dataSetDef.getUUID()); DataSet dataSet = dataSetManager.lookupDataSet(lookup); TableDisplayerSettingsBuilder settingsBuilder = DisplayerSettingsFactory.newTableSettings() .dataset(dataSetDef.getUUID()) .title(table) .titleVisible(true) .tablePageSize(20) .tableOrderEnabled(true); List<DataColumn> columns = dataSet.getColumns(); for (DataColumn column : columns) { settingsBuilder.column(column.getId()); } int tableWith = columns.size() * COLUMN_WIDTH; settingsBuilder.tableWidth(tableWith); settingsBuilder.renderer(DefaultRenderer.UUID); return settingsBuilder.buildSettings(); } catch (Exception e) { throw new GenericPortableException(e.getMessage()); } }
DataManagementServiceImpl implements DataManagementService { @Override public DisplayerSettings getDisplayerSettings(String dataSourceUuid, String schema, String table) { checkNotNull("dataSourceUuid", dataSourceUuid); checkNotNull("table", table); try { DataSourceDeploymentInfo deploymentInfo = dataSourceRuntimeManager.getDataSourceDeploymentInfo(dataSourceUuid); DataSetDef dataSetDef = DataSetDefBuilder.newBuilder() .dataSetUuid(buildDataSetUuid(dataSourceUuid, schema, table)) .dataSetName(buildDataSetName(schema, table)) .dataSourceUuid(deploymentInfo.getUuid()) .schema(schema) .table(buildDataSetTableName(dataSourceUuid, table)) .isPublic(false) .build(); dataSetDefRegistry.registerDataSetDef(dataSetDef); DataSetLookup lookup = new DataSetLookup(); lookup.setDataSetUUID(dataSetDef.getUUID()); DataSet dataSet = dataSetManager.lookupDataSet(lookup); TableDisplayerSettingsBuilder settingsBuilder = DisplayerSettingsFactory.newTableSettings() .dataset(dataSetDef.getUUID()) .title(table) .titleVisible(true) .tablePageSize(20) .tableOrderEnabled(true); List<DataColumn> columns = dataSet.getColumns(); for (DataColumn column : columns) { settingsBuilder.column(column.getId()); } int tableWith = columns.size() * COLUMN_WIDTH; settingsBuilder.tableWidth(tableWith); settingsBuilder.renderer(DefaultRenderer.UUID); return settingsBuilder.buildSettings(); } catch (Exception e) { throw new GenericPortableException(e.getMessage()); } } }
DataManagementServiceImpl implements DataManagementService { @Override public DisplayerSettings getDisplayerSettings(String dataSourceUuid, String schema, String table) { checkNotNull("dataSourceUuid", dataSourceUuid); checkNotNull("table", table); try { DataSourceDeploymentInfo deploymentInfo = dataSourceRuntimeManager.getDataSourceDeploymentInfo(dataSourceUuid); DataSetDef dataSetDef = DataSetDefBuilder.newBuilder() .dataSetUuid(buildDataSetUuid(dataSourceUuid, schema, table)) .dataSetName(buildDataSetName(schema, table)) .dataSourceUuid(deploymentInfo.getUuid()) .schema(schema) .table(buildDataSetTableName(dataSourceUuid, table)) .isPublic(false) .build(); dataSetDefRegistry.registerDataSetDef(dataSetDef); DataSetLookup lookup = new DataSetLookup(); lookup.setDataSetUUID(dataSetDef.getUUID()); DataSet dataSet = dataSetManager.lookupDataSet(lookup); TableDisplayerSettingsBuilder settingsBuilder = DisplayerSettingsFactory.newTableSettings() .dataset(dataSetDef.getUUID()) .title(table) .titleVisible(true) .tablePageSize(20) .tableOrderEnabled(true); List<DataColumn> columns = dataSet.getColumns(); for (DataColumn column : columns) { settingsBuilder.column(column.getId()); } int tableWith = columns.size() * COLUMN_WIDTH; settingsBuilder.tableWidth(tableWith); settingsBuilder.renderer(DefaultRenderer.UUID); return settingsBuilder.buildSettings(); } catch (Exception e) { throw new GenericPortableException(e.getMessage()); } } @Inject  DataManagementServiceImpl(DataSourceRuntimeManager dataSourceRuntimeManager,
                                     DatabaseMetadataService databaseMetadataService,
                                     DataSetDefRegistry dataSetDefRegistry,
                                     DataSetManager dataSetManager); }
DataManagementServiceImpl implements DataManagementService { @Override public DisplayerSettings getDisplayerSettings(String dataSourceUuid, String schema, String table) { checkNotNull("dataSourceUuid", dataSourceUuid); checkNotNull("table", table); try { DataSourceDeploymentInfo deploymentInfo = dataSourceRuntimeManager.getDataSourceDeploymentInfo(dataSourceUuid); DataSetDef dataSetDef = DataSetDefBuilder.newBuilder() .dataSetUuid(buildDataSetUuid(dataSourceUuid, schema, table)) .dataSetName(buildDataSetName(schema, table)) .dataSourceUuid(deploymentInfo.getUuid()) .schema(schema) .table(buildDataSetTableName(dataSourceUuid, table)) .isPublic(false) .build(); dataSetDefRegistry.registerDataSetDef(dataSetDef); DataSetLookup lookup = new DataSetLookup(); lookup.setDataSetUUID(dataSetDef.getUUID()); DataSet dataSet = dataSetManager.lookupDataSet(lookup); TableDisplayerSettingsBuilder settingsBuilder = DisplayerSettingsFactory.newTableSettings() .dataset(dataSetDef.getUUID()) .title(table) .titleVisible(true) .tablePageSize(20) .tableOrderEnabled(true); List<DataColumn> columns = dataSet.getColumns(); for (DataColumn column : columns) { settingsBuilder.column(column.getId()); } int tableWith = columns.size() * COLUMN_WIDTH; settingsBuilder.tableWidth(tableWith); settingsBuilder.renderer(DefaultRenderer.UUID); return settingsBuilder.buildSettings(); } catch (Exception e) { throw new GenericPortableException(e.getMessage()); } } @Inject  DataManagementServiceImpl(DataSourceRuntimeManager dataSourceRuntimeManager,
                                     DatabaseMetadataService databaseMetadataService,
                                     DataSetDefRegistry dataSetDefRegistry,
                                     DataSetManager dataSetManager); @Override DisplayerSettings getDisplayerSettings(String dataSourceUuid,
                                                  String schema,
                                                  String table); }
DataManagementServiceImpl implements DataManagementService { @Override public DisplayerSettings getDisplayerSettings(String dataSourceUuid, String schema, String table) { checkNotNull("dataSourceUuid", dataSourceUuid); checkNotNull("table", table); try { DataSourceDeploymentInfo deploymentInfo = dataSourceRuntimeManager.getDataSourceDeploymentInfo(dataSourceUuid); DataSetDef dataSetDef = DataSetDefBuilder.newBuilder() .dataSetUuid(buildDataSetUuid(dataSourceUuid, schema, table)) .dataSetName(buildDataSetName(schema, table)) .dataSourceUuid(deploymentInfo.getUuid()) .schema(schema) .table(buildDataSetTableName(dataSourceUuid, table)) .isPublic(false) .build(); dataSetDefRegistry.registerDataSetDef(dataSetDef); DataSetLookup lookup = new DataSetLookup(); lookup.setDataSetUUID(dataSetDef.getUUID()); DataSet dataSet = dataSetManager.lookupDataSet(lookup); TableDisplayerSettingsBuilder settingsBuilder = DisplayerSettingsFactory.newTableSettings() .dataset(dataSetDef.getUUID()) .title(table) .titleVisible(true) .tablePageSize(20) .tableOrderEnabled(true); List<DataColumn> columns = dataSet.getColumns(); for (DataColumn column : columns) { settingsBuilder.column(column.getId()); } int tableWith = columns.size() * COLUMN_WIDTH; settingsBuilder.tableWidth(tableWith); settingsBuilder.renderer(DefaultRenderer.UUID); return settingsBuilder.buildSettings(); } catch (Exception e) { throw new GenericPortableException(e.getMessage()); } } @Inject  DataManagementServiceImpl(DataSourceRuntimeManager dataSourceRuntimeManager,
                                     DatabaseMetadataService databaseMetadataService,
                                     DataSetDefRegistry dataSetDefRegistry,
                                     DataSetManager dataSetManager); @Override DisplayerSettings getDisplayerSettings(String dataSourceUuid,
                                                  String schema,
                                                  String table);  }