author | František Kučera <franta-hg@frantovo.cz> |
Fri, 27 Dec 2013 16:54:10 +0100 | |
branch | v_0 |
changeset 79 | e19a13ed19a9 |
parent 75 | 43aa4625ab7e |
child 89 | 98d18e9a357b |
permissions | -rw-r--r-- |
16
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
1 |
/** |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
2 |
* SQL-DK |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
3 |
* Copyright © 2013 František Kučera (frantovo.cz) |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
4 |
* |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
7 |
* the Free Software Foundation, either version 3 of the License, or |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
8 |
* (at your option) any later version. |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
9 |
* |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
13 |
* GNU General Public License for more details. |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
14 |
* |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
17 |
*/ |
14 | 18 |
package info.globalcode.sql.dk; |
19 |
||
67
10c9b9e54622
option --list-formatters – list configured and built-in formatters
František Kučera <franta-hg@frantovo.cz>
parents:
66
diff
changeset
|
20 |
import info.globalcode.sql.dk.configuration.Configuration; |
65
f05be87239ad
option --test-connection – tests connection to given database
František Kučera <franta-hg@frantovo.cz>
parents:
26
diff
changeset
|
21 |
import info.globalcode.sql.dk.configuration.ConfigurationException; |
26
4ec8e5534eb9
configuration basics
František Kučera <franta-hg@frantovo.cz>
parents:
20
diff
changeset
|
22 |
import info.globalcode.sql.dk.configuration.ConfigurationProvider; |
65
f05be87239ad
option --test-connection – tests connection to given database
František Kučera <franta-hg@frantovo.cz>
parents:
26
diff
changeset
|
23 |
import info.globalcode.sql.dk.configuration.DatabaseDefinition; |
67
10c9b9e54622
option --list-formatters – list configured and built-in formatters
František Kučera <franta-hg@frantovo.cz>
parents:
66
diff
changeset
|
24 |
import info.globalcode.sql.dk.configuration.FormatterDefinition; |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
25 |
import info.globalcode.sql.dk.formatting.ColumnsHeader; |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
26 |
import info.globalcode.sql.dk.formatting.Formatter; |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
27 |
import info.globalcode.sql.dk.formatting.FormatterContext; |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
28 |
import info.globalcode.sql.dk.formatting.FormatterException; |
17
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
29 |
import java.io.BufferedReader; |
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
30 |
import java.io.InputStreamReader; |
14 | 31 |
import java.io.PrintStream; |
65
f05be87239ad
option --test-connection – tests connection to given database
František Kučera <franta-hg@frantovo.cz>
parents:
26
diff
changeset
|
32 |
import java.sql.SQLException; |
70
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
33 |
import java.util.ArrayList; |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
34 |
import java.util.EnumSet; |
66
6e28893eaada
option --list-databases list configured databases
František Kučera <franta-hg@frantovo.cz>
parents:
65
diff
changeset
|
35 |
import java.util.List; |
17
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
36 |
import java.util.logging.Level; |
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
37 |
import java.util.logging.Logger; |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
38 |
import javax.sql.rowset.RowSetMetaDataImpl; |
14 | 39 |
|
40 |
/** |
|
41 |
* Displays info like help, version etc. |
|
42 |
* |
|
43 |
* @author Ing. František Kučera (frantovo.cz) |
|
44 |
*/ |
|
45 |
public class InfoLister { |
|
46 |
||
17
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
47 |
private static final Logger log = Logger.getLogger(InfoLister.class.getName()); |
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
48 |
private PrintStream out; |
20
e225bdcd260e
refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
49 |
private ConfigurationProvider configurationProvider; |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
50 |
private CLIOptions options; |
70
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
51 |
private Formatter formatter; |
17
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
52 |
|
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
53 |
public InfoLister(PrintStream out, ConfigurationProvider configurationProvider, CLIOptions options) { |
17
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
54 |
this.out = out; |
20
e225bdcd260e
refactor, configuration
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
55 |
this.configurationProvider = configurationProvider; |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
56 |
this.options = options; |
17
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
57 |
} |
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
58 |
|
70
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
59 |
public void showInfo() throws ConfigurationException, FormatterException { |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
60 |
EnumSet<InfoType> commands = options.getShowInfo(); |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
61 |
|
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
62 |
for (InfoType infoType : commands) { |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
63 |
switch (infoType) { |
74
a8444f6a54f3
allow multiple databases connection test in --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
73
diff
changeset
|
64 |
// only these need formatted output |
70
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
65 |
case CONNECTION: |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
66 |
case DATABASES: |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
67 |
case FORMATTERS: |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
68 |
case TYPES: |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
69 |
formatter = getFormatter(); |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
70 |
formatter.writeStartDatabase(new DatabaseDefinition()); |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
71 |
} |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
72 |
} |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
73 |
|
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
74 |
for (InfoType infoType : commands) { |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
75 |
infoType.showInfo(this); |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
76 |
} |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
77 |
|
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
78 |
if (formatter != null) { |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
79 |
formatter.writeEndDatabase(); |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
80 |
} |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
81 |
} |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
82 |
|
72
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
83 |
private void listFormatters() throws ConfigurationException, FormatterException { |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
84 |
ColumnsHeader header = constructHeader( |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
85 |
new HeaderField("name", SQLType.VARCHAR), |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
86 |
new HeaderField("built_in", SQLType.BOOLEAN), |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
87 |
new HeaderField("default", SQLType.BOOLEAN), |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
88 |
new HeaderField("class_name", SQLType.VARCHAR)); |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
89 |
List<Object[]> data = new ArrayList<>(); |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
90 |
|
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
91 |
String defaultFormatter = configurationProvider.getConfiguration().getDefaultFormatter(); |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
92 |
defaultFormatter = defaultFormatter == null ? Configuration.DEFAULT_FORMATTER : defaultFormatter; |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
93 |
|
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
94 |
for (FormatterDefinition fd : configurationProvider.getConfiguration().getBuildInFormatters()) { |
72
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
95 |
data.add(new Object[]{fd.getName(), true, defaultFormatter.equals(fd.getName()), fd.getClassName()}); |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
96 |
} |
72
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
97 |
|
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
98 |
for (FormatterDefinition fd : configurationProvider.getConfiguration().getFormatters()) { |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
99 |
data.add(new Object[]{fd.getName(), false, defaultFormatter.equals(fd.getName()), fd.getClassName()}); |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
100 |
} |
72
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
101 |
|
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
102 |
printTable(formatter, header, data); |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
103 |
|
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
104 |
|
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
105 |
} |
67
10c9b9e54622
option --list-formatters – list configured and built-in formatters
František Kučera <franta-hg@frantovo.cz>
parents:
66
diff
changeset
|
106 |
|
70
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
107 |
public void listTypes() throws FormatterException, ConfigurationException { |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
108 |
ColumnsHeader header = constructHeader(new HeaderField("name", SQLType.VARCHAR), new HeaderField("code", SQLType.INTEGER)); |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
109 |
List<Object[]> data = new ArrayList<>(); |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
110 |
for (SQLType sqlType : SQLType.values()) { |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
111 |
data.add(new Object[]{sqlType.name(), sqlType.getCode()}); |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
112 |
} |
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
113 |
printTable(formatter, header, data); |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
114 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
115 |
|
72
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
116 |
public void listDatabases() throws ConfigurationException, FormatterException { |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
117 |
ColumnsHeader header = constructHeader( |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
118 |
new HeaderField("database_name", SQLType.VARCHAR), |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
119 |
new HeaderField("user_name", SQLType.VARCHAR), |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
120 |
new HeaderField("database_url", SQLType.VARCHAR)); |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
121 |
List<Object[]> data = new ArrayList<>(); |
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
122 |
|
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
123 |
final List<DatabaseDefinition> configuredDatabases = configurationProvider.getConfiguration().getDatabases(); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
124 |
if (configuredDatabases.isEmpty()) { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
125 |
log.log(Level.WARNING, "No databases are configured."); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
126 |
} else { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
127 |
for (DatabaseDefinition dd : configuredDatabases) { |
72
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
128 |
data.add(new Object[]{dd.getName(), dd.getUserName(), dd.getUrl()}); |
14 | 129 |
} |
130 |
} |
|
72
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
131 |
|
fc9fc1f26b88
formatted output for: --list-formatters --list-databases
František Kučera <franta-hg@frantovo.cz>
parents:
70
diff
changeset
|
132 |
printTable(formatter, header, data); |
14 | 133 |
} |
17
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
134 |
|
73
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
135 |
public void testConnection() throws FormatterException, ConfigurationException { |
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
136 |
ColumnsHeader header = constructHeader( |
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
137 |
new HeaderField("database_name", SQLType.VARCHAR), |
74
a8444f6a54f3
allow multiple databases connection test in --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
73
diff
changeset
|
138 |
new HeaderField("configured", SQLType.BOOLEAN), |
a8444f6a54f3
allow multiple databases connection test in --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
73
diff
changeset
|
139 |
new HeaderField("connected", SQLType.BOOLEAN)); |
73
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
140 |
List<Object[]> data = new ArrayList<>(); |
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
141 |
|
74
a8444f6a54f3
allow multiple databases connection test in --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
73
diff
changeset
|
142 |
for (String dbName : options.getDatabaseNameToTest()) { |
a8444f6a54f3
allow multiple databases connection test in --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
73
diff
changeset
|
143 |
data.add(testConnection(dbName)); |
a8444f6a54f3
allow multiple databases connection test in --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
73
diff
changeset
|
144 |
} |
73
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
145 |
|
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
146 |
printTable(formatter, header, data); |
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
147 |
} |
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
148 |
|
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
149 |
public Object[] testConnection(String dbName) { |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
150 |
log.log(Level.FINE, "Testing connection to database: {0}", dbName); |
73
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
151 |
|
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
152 |
boolean succesfullyConnected = false; |
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
153 |
boolean succesfullyConfigured = false; |
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
154 |
|
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
155 |
try { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
156 |
DatabaseDefinition dd = configurationProvider.getConfiguration().getDatabase(dbName); |
75
43aa4625ab7e
throw ConfigurationException instead of returning null, if database or formatter of given name is not configured
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
157 |
log.log(Level.FINE, "Database definition was loaded from configuration"); |
43aa4625ab7e
throw ConfigurationException instead of returning null, if database or formatter of given name is not configured
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
158 |
succesfullyConfigured = true; |
43aa4625ab7e
throw ConfigurationException instead of returning null, if database or formatter of given name is not configured
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
159 |
try (DatabaseConnection dc = dd.connect()) { |
43aa4625ab7e
throw ConfigurationException instead of returning null, if database or formatter of given name is not configured
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
160 |
succesfullyConnected = dc.test(); |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
161 |
} |
75
43aa4625ab7e
throw ConfigurationException instead of returning null, if database or formatter of given name is not configured
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
162 |
log.log(Level.FINE, "Database connection test was successful"); |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
163 |
} catch (ConfigurationException | SQLException e) { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
164 |
log.log(Level.SEVERE, "Error during testing connection", e); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
165 |
} |
73
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
166 |
|
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
167 |
return new Object[]{dbName, succesfullyConfigured, succesfullyConnected}; |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
168 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
169 |
|
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
170 |
public void printResource(String fileName) { |
18
7900bb1666f6
version info: option --version
František Kučera <franta-hg@frantovo.cz>
parents:
17
diff
changeset
|
171 |
try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(fileName)))) { |
17
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
172 |
while (true) { |
18
7900bb1666f6
version info: option --version
František Kučera <franta-hg@frantovo.cz>
parents:
17
diff
changeset
|
173 |
String line = reader.readLine(); |
17
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
174 |
if (line == null) { |
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
175 |
break; |
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
176 |
} else { |
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
177 |
println(line); |
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
178 |
} |
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
179 |
} |
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
180 |
} catch (Exception e) { |
18
7900bb1666f6
version info: option --version
František Kučera <franta-hg@frantovo.cz>
parents:
17
diff
changeset
|
181 |
log.log(Level.SEVERE, "Unable to print this info. Please see our website for it: " + Constants.WEBSITE, e); |
17
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
182 |
} |
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
183 |
} |
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
184 |
|
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
185 |
private void println(String line) { |
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
186 |
out.println(line); |
d8ab8aece6f2
license option: --license
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
187 |
} |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
188 |
|
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
189 |
private void printTable(Formatter formatter, ColumnsHeader header, List<Object[]> data) throws ConfigurationException, FormatterException { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
190 |
formatter.writeStartResultSet(); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
191 |
formatter.writeColumnsHeader(header); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
192 |
|
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
193 |
for (Object[] row : data) { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
194 |
formatter.writeStartRow(); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
195 |
for (Object cell : row) { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
196 |
formatter.writeColumnValue(cell); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
197 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
198 |
formatter.writeEndRow(); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
199 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
200 |
|
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
201 |
formatter.writeEndResultSet(); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
202 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
203 |
|
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
204 |
private Formatter getFormatter() throws ConfigurationException, FormatterException { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
205 |
FormatterDefinition fd = configurationProvider.getConfiguration().getFormatter(options.getFormatterName()); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
206 |
FormatterContext context = new FormatterContext(out); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
207 |
return fd.getInstance(context); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
208 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
209 |
|
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
210 |
private ColumnsHeader constructHeader(HeaderField... fields) throws FormatterException { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
211 |
try { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
212 |
RowSetMetaDataImpl metaData = new RowSetMetaDataImpl(); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
213 |
metaData.setColumnCount(fields.length); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
214 |
|
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
215 |
for (int i = 0; i < fields.length; i++) { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
216 |
HeaderField hf = fields[i]; |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
217 |
int sqlIndex = i + 1; |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
218 |
metaData.setColumnName(sqlIndex, hf.name); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
219 |
metaData.setColumnLabel(sqlIndex, hf.name); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
220 |
metaData.setColumnType(sqlIndex, hf.type.getCode()); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
221 |
metaData.setColumnTypeName(sqlIndex, hf.type.name()); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
222 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
223 |
|
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
224 |
return new ColumnsHeader(metaData); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
225 |
} catch (SQLException e) { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
226 |
throw new FormatterException("Error while constructing table headers", e); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
227 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
228 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
229 |
|
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
230 |
private static class HeaderField { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
231 |
|
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
232 |
String name; |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
233 |
SQLType type; |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
234 |
|
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
235 |
public HeaderField(String name, SQLType type) { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
236 |
this.name = name; |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
237 |
this.type = type; |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
238 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
239 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
240 |
|
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
241 |
public enum InfoType { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
242 |
|
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
243 |
HELP { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
244 |
@Override |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
245 |
public void showInfo(InfoLister infoLister) { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
246 |
infoLister.printResource(Constants.HELP_FILE); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
247 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
248 |
}, |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
249 |
VERSION { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
250 |
@Override |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
251 |
public void showInfo(InfoLister infoLister) { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
252 |
infoLister.printResource(Constants.VERSION_FILE); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
253 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
254 |
}, |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
255 |
LICENSE { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
256 |
@Override |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
257 |
public void showInfo(InfoLister infoLister) { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
258 |
infoLister.printResource(Constants.LICENSE_FILE); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
259 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
260 |
}, |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
261 |
FORMATTERS { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
262 |
@Override |
70
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
263 |
public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException { |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
264 |
infoLister.listFormatters(); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
265 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
266 |
}, |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
267 |
TYPES { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
268 |
@Override |
70
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
269 |
public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException { |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
270 |
infoLister.listTypes(); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
271 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
272 |
}, |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
273 |
DATABASES { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
274 |
@Override |
70
02c8eaa425e8
use formatter also for printing info! --list-types
František Kučera <franta-hg@frantovo.cz>
parents:
69
diff
changeset
|
275 |
public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException { |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
276 |
infoLister.listDatabases(); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
277 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
278 |
}, |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
279 |
CONNECTION { |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
280 |
@Override |
73
d32fd50d3c2c
formatted output for: --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
72
diff
changeset
|
281 |
public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException { |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
282 |
infoLister.testConnection(); |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
283 |
} |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
284 |
}; |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
285 |
|
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
286 |
public abstract void showInfo(InfoLister infoLister) throws ConfigurationException, FormatterException; |
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
67
diff
changeset
|
287 |
} |
14 | 288 |
} |