-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientLauncher.java
More file actions
69 lines (59 loc) · 2.58 KB
/
Copy pathClientLauncher.java
File metadata and controls
69 lines (59 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package example.client;
import com.reforms.orm.OrmDao;
import example.client.IClientFilterParamsDao.ClientFilter;
import test.H2DataSource;
public class ClientLauncher {
public static void main(String[] args) {
// loadClients();
// saveClient();
// filterClients("ovy", null);
// filterClients("ovy", ClientState.ACTIVE);
// filterClients(null, ClientState.ACTIVE);
loadClientsFil();
}
private static void loadClientsFil() {
System.out.println("load clients begining");
try (H2DataSource h2ds = new H2DataSource("example.client")) {
h2ds.invoke("client.sql", ClientLauncher.class);
IClientDao cliensDao = OrmDao.createDao(h2ds, IClientDao.class);
System.out.println(cliensDao.loadClients());
}
System.out.println("load clients ok");
}
private static void loadClients() {
System.out.println("load clients begining");
try (H2DataSource h2ds = new H2DataSource("example.client")) {
h2ds.invoke("client.sql", ClientLauncher.class);
IClientDao cliensDao = OrmDao.createDao(h2ds, IClientDao.class);
System.out.println(cliensDao.loadAllClients());
}
System.out.println("load clients ok");
}
private static void saveClient() {
System.out.println("save begining");
try (H2DataSource h2ds = new H2DataSource("example.client")) {
h2ds.invoke("client.sql", ClientLauncher.class);
IClientDao cliensDao = OrmDao.createDao(h2ds, IClientDao.class);
Client client = new Client();
client.setId(2);
client.setName("John Visky");
client.setState(ClientState.ACTIVE);
cliensDao.saveClient(client);
}
System.out.println("save ok");
}
private static void filterClients(String name, ClientState state) {
System.out.println("filtering clients begining");
try (H2DataSource h2ds = new H2DataSource("example.client")) {
h2ds.invoke("client.sql", ClientLauncher.class);
IClientFilterParamsDao cliensDao = OrmDao.createDao(h2ds, IClientFilterParamsDao.class);
System.out.println(cliensDao.filterClientsRequired(new ClientFilter(name, state)));
}
System.out.println("filtering clients ok");
}
private static H2DataSource resolveConnection() {
//return ... code here to resolve your connection or connection hodler instance
// in my case its new H2DataSource("example.client")
return new H2DataSource("example.client");
}
}