26
26
import com .dqops .cli .output .OutputFormatService ;
27
27
import com .dqops .cli .terminal .FileWriter ;
28
28
import com .dqops .cli .terminal .TablesawDatasetTableModel ;
29
+ import com .dqops .cli .terminal .TerminalFactory ;
29
30
import com .dqops .cli .terminal .TerminalTableWritter ;
30
- import com .dqops .cli .terminal .TerminalWriter ;
31
31
import com .dqops .execution .checks .CheckExecutionErrorSummary ;
32
32
import com .dqops .execution .checks .CheckExecutionSummary ;
33
33
import com .dqops .execution .checks .progress .CheckExecutionProgressListener ;
51
51
@ Scope (ConfigurableBeanFactory .SCOPE_PROTOTYPE )
52
52
@ CommandLine .Command (name = "run" , header = "Run data quality checks that match a given condition" , description = "Run data quality checks on your dataset that match a given condition. The command output is a table with the results that provides insight into the data quality." )
53
53
public class CheckRunCliCommand extends BaseCommand implements ICommand , ITableNameCommand {
54
- private TerminalWriter terminalWriter ;
54
+ private TerminalFactory terminalFactory ;
55
55
private TerminalTableWritter terminalTableWritter ;
56
56
private CheckCliService checkService ;
57
57
private CheckExecutionProgressListenerProvider checkExecutionProgressListenerProvider ;
@@ -64,19 +64,18 @@ public CheckRunCliCommand() {
64
64
65
65
/**
66
66
* Dependency injection constructor.
67
- * @param terminalWriter Terminal writer.
68
67
* @param checkService Check implementation service.
69
68
* @param jsonSerializer Json serializer.
70
69
*/
71
70
@ Autowired
72
- public CheckRunCliCommand (TerminalWriter terminalWriter ,
71
+ public CheckRunCliCommand (TerminalFactory terminalFactory ,
73
72
TerminalTableWritter terminalTableWritter ,
74
73
CheckCliService checkService ,
75
74
CheckExecutionProgressListenerProvider checkExecutionProgressListenerProvider ,
76
75
JsonSerializer jsonSerializer ,
77
76
OutputFormatService outputFormatService ,
78
77
FileWriter fileWriter ) {
79
- this .terminalWriter = terminalWriter ;
78
+ this .terminalFactory = terminalFactory ;
80
79
this .terminalTableWritter = terminalTableWritter ;
81
80
this .checkService = checkService ;
82
81
this .checkExecutionProgressListenerProvider = checkExecutionProgressListenerProvider ;
@@ -388,33 +387,33 @@ public Integer call() throws Exception {
388
387
CheckExecutionSummary checkExecutionSummary = this .checkService .runChecks (filters , this .timeWindowFilterParameters , progressListener , this .dummyRun );
389
388
390
389
if (checkExecutionSummary .getTotalChecksExecutedCount () == 0 ) {
391
- this .terminalWriter .writeLine ("No checks with these filters were found." );
390
+ this .terminalFactory . getWriter () .writeLine ("No checks with these filters were found." );
392
391
return 0 ;
393
392
}
394
393
395
394
if (this .mode != CheckRunReportingMode .silent ) {
396
395
TablesawDatasetTableModel tablesawDatasetTableModel = new TablesawDatasetTableModel (checkExecutionSummary .getSummaryTable ());
397
- this .terminalWriter .writeLine ("Check evaluation summary per table:" );
396
+ this .terminalFactory . getWriter () .writeLine ("Check evaluation summary per table:" );
398
397
switch (this .getOutputFormat ()) {
399
398
case CSV : {
400
399
String csvContent = this .outputFormatService .tableToCsv (tablesawDatasetTableModel );
401
400
if (this .isWriteToFile ()) {
402
401
CliOperationStatus cliOperationStatus = this .fileWriter .writeStringToFile (csvContent );
403
- this .terminalWriter .writeLine (cliOperationStatus .getMessage ());
402
+ this .terminalFactory . getWriter () .writeLine (cliOperationStatus .getMessage ());
404
403
}
405
404
else {
406
- this .terminalWriter .write (csvContent );
405
+ this .terminalFactory . getWriter () .write (csvContent );
407
406
}
408
407
break ;
409
408
}
410
409
case JSON : {
411
410
String jsonContent = this .outputFormatService .tableToJson (tablesawDatasetTableModel );
412
411
if (this .isWriteToFile ()) {
413
412
CliOperationStatus cliOperationStatus = this .fileWriter .writeStringToFile (jsonContent );
414
- this .terminalWriter .writeLine (cliOperationStatus .getMessage ());
413
+ this .terminalFactory . getWriter () .writeLine (cliOperationStatus .getMessage ());
415
414
}
416
415
else {
417
- this .terminalWriter .write (jsonContent );
416
+ this .terminalFactory . getWriter () .write (jsonContent );
418
417
}
419
418
break ;
420
419
}
@@ -423,9 +422,9 @@ public Integer call() throws Exception {
423
422
TableBuilder tableBuilder = new TableBuilder (tablesawDatasetTableModel );
424
423
tableBuilder .addInnerBorder (BorderStyle .oldschool );
425
424
tableBuilder .addHeaderBorder (BorderStyle .oldschool );
426
- String renderedTable = tableBuilder .build ().render (this .terminalWriter .getTerminalWidth () - 1 );
425
+ String renderedTable = tableBuilder .build ().render (this .terminalFactory . getWriter () .getTerminalWidth () - 1 );
427
426
CliOperationStatus cliOperationStatus = this .fileWriter .writeStringToFile (renderedTable );
428
- this .terminalWriter .writeLine (cliOperationStatus .getMessage ());
427
+ this .terminalFactory . getWriter () .writeLine (cliOperationStatus .getMessage ());
429
428
}
430
429
else {
431
430
this .terminalTableWritter .writeTable (tablesawDatasetTableModel , true );
@@ -437,9 +436,9 @@ public Integer call() throws Exception {
437
436
CheckExecutionErrorSummary checkExecutionErrorSummary = checkExecutionSummary .getCheckExecutionErrorSummary ();
438
437
if (checkExecutionErrorSummary != null ) {
439
438
if (this .mode == CheckRunReportingMode .debug ) {
440
- this .terminalWriter .writeLine (checkExecutionErrorSummary .getDebugMessage ());
439
+ this .terminalFactory . getWriter () .writeLine (checkExecutionErrorSummary .getDebugMessage ());
441
440
} else {
442
- this .terminalWriter .writeLine (checkExecutionErrorSummary .getSummaryMessage ());
441
+ this .terminalFactory . getWriter () .writeLine (checkExecutionErrorSummary .getSummaryMessage ());
443
442
}
444
443
}
445
444
}
0 commit comments