1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.rsmart.kuali.tools.ant.tasks;
18
19 import java.sql.Connection;
20 import java.util.List;
21 import java.util.Vector;
22
23 import org.apache.tools.ant.BuildException;
24 import org.apache.tools.ant.DirectoryScanner;
25 import org.apache.tools.ant.Task;
26 import org.apache.tools.ant.types.FileSet;
27
28 import static org.apache.tools.ant.Project.MSG_DEBUG;
29
30
31
32
33
34
35
36
37
38 public class RdbmsConfig extends Task {
39 private String id;
40 private String url;
41 private String schema;
42 private String username;
43 private String password;
44 private String driver;
45 private Connection connection;
46
47 public RdbmsConfig() {
48 }
49
50
51
52
53
54
55 public final String getUrl() {
56 return this.url;
57 }
58
59
60
61
62
63
64 public final void setUrl(final String argUrl) {
65 this.url = argUrl;
66 }
67
68
69
70
71
72
73
74 public final Connection getConnection() {
75 return this.connection;
76 }
77
78
79
80
81
82
83 public final void setConnection(final Connection argConnection) {
84 this.connection = argConnection;
85 }
86
87
88
89
90
91
92 public final String getId() {
93 return this.id;
94 }
95
96
97
98
99
100
101 public final void setId(final String argId) {
102 this.id = argId;
103 }
104
105
106
107
108
109
110 public final String getUsername() {
111 return this.username;
112 }
113
114
115
116
117
118
119 public final void setUsername(final String argUsername) {
120 this.username = argUsername;
121 }
122
123
124
125
126
127
128 public final String getPassword() {
129 return this.password;
130 }
131
132
133
134
135
136
137 public final void setPassword(final String argPassword) {
138 this.password = argPassword;
139 }
140
141 private String getReferenceId() {
142 return getProject().getName() + "." + getId();
143 }
144
145
146
147
148
149
150 public final String getDriver() {
151 return this.driver;
152 }
153
154
155
156
157
158
159 public final void setDriver(final String argDriver) {
160 this.driver = argDriver;
161 }
162
163
164
165
166
167
168 public final String getSchema() {
169 return this.schema;
170 }
171
172
173
174
175
176
177 public final void setSchema(final String argSchema) {
178 this.schema = argSchema;
179 }
180
181
182 public void execute() {
183 debug("Saving rdbms reference " + getReferenceId());
184 getProject().addReference(getReferenceId(), this);
185 getProject().setProperty("driver", getDriver());
186 getProject().setProperty("url", getUrl());
187 getProject().setProperty("username", getUsername());
188 getProject().setProperty("password", getPassword());
189 System.setProperty("jdbc.drivers", System.getProperty("jdbc.drivers") + ":" + getDriver());
190 }
191
192 private void debug(String msg) {
193 log(msg, MSG_DEBUG);
194 }
195 }