| 1 |
|
package org.apache.torque.mojo; |
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
import java.io.File; |
| 23 |
|
import java.lang.reflect.InvocationTargetException; |
| 24 |
|
import java.sql.Connection; |
| 25 |
|
import java.sql.SQLException; |
| 26 |
|
import java.util.Collection; |
| 27 |
|
import java.util.Map; |
| 28 |
|
import java.util.Properties; |
| 29 |
|
import java.util.Vector; |
| 30 |
|
|
| 31 |
|
import org.apache.commons.beanutils.BeanUtils; |
| 32 |
|
import org.apache.commons.lang.StringUtils; |
| 33 |
|
import org.apache.maven.plugin.MojoExecutionException; |
| 34 |
|
import org.apache.maven.settings.Server; |
| 35 |
|
import org.apache.maven.shared.filtering.MavenFileFilter; |
| 36 |
|
import org.apache.torque.engine.platform.Platform; |
| 37 |
|
import org.apache.torque.engine.platform.PlatformFactory; |
| 38 |
|
import org.apache.torque.util.JdbcConfigurer; |
| 39 |
|
import org.apache.torque.util.MojoDatabaseListener; |
| 40 |
|
import org.kuali.core.db.torque.PropertyHandlingException; |
| 41 |
|
import org.kuali.core.db.torque.Utils; |
| 42 |
|
import org.kuali.db.ConnectionHandler; |
| 43 |
|
import org.kuali.db.Credentials; |
| 44 |
|
import org.kuali.db.JDBCUtils; |
| 45 |
|
import org.kuali.db.SQLExecutor; |
| 46 |
|
import org.kuali.db.Transaction; |
| 47 |
|
|
| 48 |
|
import static org.apache.commons.lang.StringUtils.*; |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
|
|
|
| 0% |
Uncovered Elements: 275 (275) |
Complexity: 97 |
Complexity Density: 0.58 |
|
| 53 |
|
public abstract class AbstractSQLExecutorMojo extends BaseMojo { |
| 54 |
|
Utils utils = new Utils(); |
| 55 |
|
JDBCUtils jdbcUtils; |
| 56 |
|
ConnectionHandler connectionHandler; |
| 57 |
|
Platform platform; |
| 58 |
|
|
| 59 |
|
public static final String DRIVER_INFO_PROPERTIES_USER = "user"; |
| 60 |
|
public static final String DRIVER_INFO_PROPERTIES_PASSWORD = "password"; |
| 61 |
|
|
| 62 |
|
|
| 63 |
|
@link |
| 64 |
|
|
| 65 |
|
public static final String FILE_SORTING_ASC = "ascending"; |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
@link |
| 69 |
|
|
| 70 |
|
public static final String FILE_SORTING_DSC = "descending"; |
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
String targetDatabase; |
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
String username; |
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
String password; |
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
boolean enableAnonymousPassword; |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
boolean enableAnonymousUsername; |
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
String driverProperties; |
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
boolean showPassword; |
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
String settingsKey; |
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
|
| 140 |
|
boolean skipOnConnectionError; |
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
|
String sqlCommand = ""; |
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
File[] srcFiles; |
| 155 |
|
|
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
|
| 162 |
|
String url; |
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
|
| 169 |
|
|
| 170 |
|
|
| 171 |
|
|
| 172 |
|
String driver; |
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
boolean autocommit; |
| 181 |
|
|
| 182 |
|
|
| 183 |
|
|
| 184 |
|
|
| 185 |
|
|
| 186 |
|
|
| 187 |
|
String onError = SQLExecutor.ON_ERROR_ABORT; |
| 188 |
|
|
| 189 |
|
|
| 190 |
|
|
| 191 |
|
|
| 192 |
|
|
| 193 |
|
|
| 194 |
|
|
| 195 |
|
|
| 196 |
|
String delimiter = "/"; |
| 197 |
|
|
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
|
| 202 |
|
|
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
|
|
| 207 |
|
String delimiterType = DelimiterType.ROW; |
| 208 |
|
|
| 209 |
|
|
| 210 |
|
|
| 211 |
|
|
| 212 |
|
|
| 213 |
|
|
| 214 |
|
boolean keepFormat = true; |
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
|
boolean showheaders = true; |
| 222 |
|
|
| 223 |
|
|
| 224 |
|
|
| 225 |
|
|
| 226 |
|
|
| 227 |
|
|
| 228 |
|
boolean append = false; |
| 229 |
|
|
| 230 |
|
|
| 231 |
|
|
| 232 |
|
|
| 233 |
|
|
| 234 |
|
|
| 235 |
|
|
| 236 |
|
boolean escapeProcessing = true; |
| 237 |
|
|
| 238 |
|
|
| 239 |
|
|
| 240 |
|
|
| 241 |
|
|
| 242 |
|
|
| 243 |
|
int successfulStatements = 0; |
| 244 |
|
|
| 245 |
|
|
| 246 |
|
|
| 247 |
|
|
| 248 |
|
int totalStatements = 0; |
| 249 |
|
|
| 250 |
|
|
| 251 |
|
|
| 252 |
|
|
| 253 |
|
Connection conn = null; |
| 254 |
|
|
| 255 |
|
|
| 256 |
|
|
| 257 |
|
|
| 258 |
|
Vector<Transaction> transactions = new Vector<Transaction>(); |
| 259 |
|
|
| 260 |
|
|
| 261 |
|
|
| 262 |
|
|
| 263 |
|
MavenFileFilter fileFilter; |
| 264 |
|
|
| 265 |
|
|
| 266 |
|
|
| 267 |
|
|
| 268 |
|
Credentials credentials; |
| 269 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 270 |
0
|
protected void configureTransactions() throws MojoExecutionException {... |
| 271 |
|
|
| 272 |
|
} |
| 273 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 274 |
0
|
protected Properties getContextProperties() {... |
| 275 |
0
|
Properties properties = new Properties(); |
| 276 |
0
|
Map<String, String> environment = System.getenv(); |
| 277 |
0
|
for (String key : environment.keySet()) { |
| 278 |
0
|
properties.put("env." + key, environment.get(key)); |
| 279 |
|
} |
| 280 |
0
|
properties.putAll(getProject().getProperties()); |
| 281 |
0
|
properties.putAll(System.getProperties()); |
| 282 |
0
|
return properties; |
| 283 |
|
} |
| 284 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 285 |
0
|
protected Credentials getNewCredentials() {... |
| 286 |
0
|
Credentials credentials = new Credentials(); |
| 287 |
0
|
credentials.setUsername(getUsername()); |
| 288 |
0
|
credentials.setPassword(getPassword()); |
| 289 |
0
|
return credentials; |
| 290 |
|
} |
| 291 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 292 |
0
|
protected ConnectionHandler getNewConnectionHandler() throws MojoExecutionException {... |
| 293 |
0
|
ConnectionHandler connectionHandler = new ConnectionHandler(); |
| 294 |
0
|
try { |
| 295 |
0
|
BeanUtils.copyProperties(connectionHandler, this); |
| 296 |
0
|
return connectionHandler; |
| 297 |
|
} catch (Exception e) { |
| 298 |
0
|
throw new MojoExecutionException("Error establishing connection", e); |
| 299 |
|
} |
| 300 |
|
} |
| 301 |
|
|
| 302 |
|
|
| 303 |
|
|
| 304 |
|
|
| 305 |
|
@throws |
| 306 |
|
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 4 |
Complexity Density: 0.22 |
|
| 307 |
0
|
public void executeMojo() throws MojoExecutionException {... |
| 308 |
0
|
jdbcUtils = new JDBCUtils(); |
| 309 |
0
|
updateConfiguration(); |
| 310 |
0
|
Credentials credentials = getNewCredentials(); |
| 311 |
0
|
updateCredentials(credentials); |
| 312 |
0
|
validateCredentials(credentials); |
| 313 |
0
|
setCredentials(credentials); |
| 314 |
0
|
validateConfiguration(); |
| 315 |
|
|
| 316 |
0
|
connectionHandler = getNewConnectionHandler(); |
| 317 |
0
|
conn = getConnection(); |
| 318 |
|
|
| 319 |
0
|
if (connectionHandler.isConnectionError() && skipOnConnectionError) { |
| 320 |
|
|
| 321 |
|
|
| 322 |
0
|
return; |
| 323 |
|
} |
| 324 |
|
|
| 325 |
|
|
| 326 |
0
|
configureTransactions(); |
| 327 |
|
|
| 328 |
|
|
| 329 |
0
|
successfulStatements = 0; |
| 330 |
0
|
totalStatements = 0; |
| 331 |
|
|
| 332 |
|
|
| 333 |
0
|
SQLExecutor executor = getSqlExecutor(); |
| 334 |
|
|
| 335 |
0
|
try { |
| 336 |
0
|
executor.execute(); |
| 337 |
|
} catch (SQLException e) { |
| 338 |
0
|
throw new MojoExecutionException("Error executing SQL", e); |
| 339 |
|
} |
| 340 |
|
} |
| 341 |
|
|
| 342 |
|
|
| 343 |
|
|
| 344 |
|
|
| 345 |
|
@param |
| 346 |
|
|
| 347 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 348 |
0
|
public void addText(String sql) {... |
| 349 |
0
|
this.sqlCommand += sql; |
| 350 |
|
} |
| 351 |
|
|
| 352 |
|
|
| 353 |
|
|
| 354 |
|
|
| 355 |
|
@param |
| 356 |
|
|
| 357 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 358 |
0
|
public void setDelimiter(String delimiter) {... |
| 359 |
0
|
this.delimiter = delimiter; |
| 360 |
|
} |
| 361 |
|
|
| 362 |
|
|
| 363 |
|
|
| 364 |
|
|
| 365 |
|
@param |
| 366 |
|
|
| 367 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 368 |
0
|
public void setDelimiterType(String delimiterType) {... |
| 369 |
0
|
this.delimiterType = delimiterType; |
| 370 |
|
} |
| 371 |
|
|
| 372 |
|
|
| 373 |
|
|
| 374 |
|
|
| 375 |
|
@param |
| 376 |
|
|
| 377 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 378 |
0
|
public void setShowheaders(boolean showheaders) {... |
| 379 |
0
|
this.showheaders = showheaders; |
| 380 |
|
} |
| 381 |
|
|
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
|
@param |
| 386 |
|
|
| 387 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 388 |
0
|
public void setAppend(boolean append) {... |
| 389 |
0
|
this.append = append; |
| 390 |
|
} |
| 391 |
|
|
| 392 |
|
|
| 393 |
|
|
| 394 |
|
|
| 395 |
|
@param |
| 396 |
|
|
| 397 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 398 |
0
|
public void setKeepFormat(boolean keepformat) {... |
| 399 |
0
|
this.keepFormat = keepformat; |
| 400 |
|
} |
| 401 |
|
|
| 402 |
|
|
| 403 |
|
|
| 404 |
|
|
| 405 |
|
@param |
| 406 |
|
|
| 407 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 408 |
0
|
public void setEscapeProcessing(boolean enable) {... |
| 409 |
0
|
escapeProcessing = enable; |
| 410 |
|
} |
| 411 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 412 |
0
|
protected SQLExecutor getSqlExecutor() throws MojoExecutionException {... |
| 413 |
0
|
try { |
| 414 |
0
|
SQLExecutor executor = new SQLExecutor(); |
| 415 |
0
|
BeanUtils.copyProperties(executor, this); |
| 416 |
0
|
executor.addListener(new MojoDatabaseListener(getLog())); |
| 417 |
0
|
return executor; |
| 418 |
|
} catch (InvocationTargetException e) { |
| 419 |
0
|
throw new MojoExecutionException("Error copying properties from the mojo to the SQL executor", e); |
| 420 |
|
} catch (IllegalAccessException e) { |
| 421 |
0
|
throw new MojoExecutionException("Error copying properties from the mojo to the SQL executor", e); |
| 422 |
|
} |
| 423 |
|
} |
| 424 |
|
|
| 425 |
|
|
| 426 |
|
|
| 427 |
|
|
| 428 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 429 |
0
|
protected void updateConfiguration() throws MojoExecutionException {... |
| 430 |
0
|
try { |
| 431 |
0
|
new JdbcConfigurer().updateConfiguration(this); |
| 432 |
|
} catch (PropertyHandlingException e) { |
| 433 |
0
|
throw new MojoExecutionException("Error handling properties", e); |
| 434 |
|
} |
| 435 |
0
|
platform = PlatformFactory.getPlatformFor(targetDatabase); |
| 436 |
|
} |
| 437 |
|
|
| 438 |
|
|
| 439 |
|
|
| 440 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 441 |
0
|
protected void validateConfiguration() throws MojoExecutionException {... |
| 442 |
0
|
new JdbcConfigurer().validateConfiguration(this); |
| 443 |
|
} |
| 444 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 445 |
0
|
protected void validateCredentials(Credentials credentials, boolean anonymousAccessAllowed, String validationFailureMessage) throws MojoExecutionException {... |
| 446 |
0
|
if (anonymousAccessAllowed) { |
| 447 |
|
|
| 448 |
0
|
return; |
| 449 |
|
} |
| 450 |
0
|
String username = credentials.getUsername(); |
| 451 |
0
|
String password = credentials.getPassword(); |
| 452 |
0
|
if (!isEmpty(username) && !isEmpty(password)) { |
| 453 |
|
|
| 454 |
0
|
return; |
| 455 |
|
} |
| 456 |
0
|
throw new MojoExecutionException(validationFailureMessage); |
| 457 |
|
} |
| 458 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
|
| 459 |
0
|
protected void validateCredentials(Credentials credentials) throws MojoExecutionException {... |
| 460 |
|
|
| 461 |
0
|
StringBuffer sb = new StringBuffer(); |
| 462 |
0
|
sb.append("\n\n"); |
| 463 |
0
|
sb.append("Username and password must be specified.\n"); |
| 464 |
0
|
sb.append("Specify them in the plugin configuration or as a system property.\n"); |
| 465 |
0
|
sb.append("\n"); |
| 466 |
0
|
sb.append("For example:\n"); |
| 467 |
0
|
sb.append("-Dusername=myuser\n"); |
| 468 |
0
|
sb.append("-Dpassword=mypassword\n"); |
| 469 |
0
|
sb.append("\n."); |
| 470 |
0
|
validateCredentials(credentials, enableAnonymousUsername && enableAnonymousPassword, sb.toString()); |
| 471 |
|
} |
| 472 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 473 |
0
|
protected boolean isNullOrEmpty(Collection<?> c) {... |
| 474 |
0
|
if (c == null) { |
| 475 |
0
|
return true; |
| 476 |
|
} |
| 477 |
0
|
if (c.size() == 0) { |
| 478 |
0
|
return true; |
| 479 |
|
} |
| 480 |
0
|
return false; |
| 481 |
|
} |
| 482 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 483 |
0
|
protected String convertNullToEmpty(String s) {... |
| 484 |
0
|
if (s == null) { |
| 485 |
0
|
return ""; |
| 486 |
|
} else { |
| 487 |
0
|
return s; |
| 488 |
|
} |
| 489 |
|
} |
| 490 |
|
|
| 491 |
|
|
| 492 |
|
|
| 493 |
|
|
| 494 |
|
@throws |
| 495 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 496 |
0
|
protected void updateCredentials(Credentials credentials) {... |
| 497 |
0
|
Server server = getServerFromSettingsKey(); |
| 498 |
0
|
String username = getUpdatedUsername(server, credentials.getUsername()); |
| 499 |
0
|
String password = getUpdatedPassword(server, credentials.getPassword()); |
| 500 |
0
|
credentials.setUsername(convertNullToEmpty(username)); |
| 501 |
0
|
credentials.setPassword(convertNullToEmpty(password)); |
| 502 |
|
} |
| 503 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 504 |
0
|
protected Server getServerFromSettingsKey() {... |
| 505 |
0
|
Server server = getSettings().getServer(getSettingsKey()); |
| 506 |
0
|
if (server == null) { |
| 507 |
|
|
| 508 |
0
|
return getSettings().getServer("impex." + getUrl()); |
| 509 |
|
} else { |
| 510 |
0
|
return null; |
| 511 |
|
} |
| 512 |
|
} |
| 513 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 514 |
0
|
protected String getUpdatedPassword(Server server, String password) {... |
| 515 |
|
|
| 516 |
0
|
if (!isEmpty(password)) { |
| 517 |
0
|
return password; |
| 518 |
|
} |
| 519 |
0
|
if (server != null) { |
| 520 |
|
|
| 521 |
0
|
getLog().info("Located a password in settings.xml under the server id '" + server.getId() + "' Password: " + getDisplayPassword(server.getPassword())); |
| 522 |
0
|
return server.getPassword(); |
| 523 |
|
} |
| 524 |
0
|
getLog().info("Using default password generated from the artifact id"); |
| 525 |
0
|
return platform.getSchemaName(getProject().getArtifactId()); |
| 526 |
|
} |
| 527 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 528 |
0
|
protected String getDisplayPassword(String password) {... |
| 529 |
0
|
if (isShowPassword()) { |
| 530 |
0
|
return password; |
| 531 |
|
} else { |
| 532 |
0
|
return StringUtils.repeat("*", password.length()); |
| 533 |
|
} |
| 534 |
|
} |
| 535 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 536 |
0
|
protected String getUpdatedUsername(Server server, String username) {... |
| 537 |
|
|
| 538 |
0
|
if (!isEmpty(username)) { |
| 539 |
0
|
return username; |
| 540 |
|
} |
| 541 |
0
|
if (server != null) { |
| 542 |
|
|
| 543 |
0
|
getLog().info("Located a username in settings.xml under the server id '" + server.getId() + "' Username: " + server.getUsername()); |
| 544 |
0
|
return server.getUsername(); |
| 545 |
|
} |
| 546 |
0
|
getLog().info("Using default username generated from the artifact id"); |
| 547 |
0
|
return platform.getSchemaName(getProject().getArtifactId()); |
| 548 |
|
} |
| 549 |
|
|
| 550 |
|
|
| 551 |
|
|
| 552 |
|
|
| 553 |
|
|
| 554 |
|
|
| 555 |
|
@return |
| 556 |
|
@throws |
| 557 |
|
|
| 558 |
|
@throws |
| 559 |
|
|
| 560 |
|
|
| 561 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 562 |
0
|
protected Connection getConnection() throws MojoExecutionException {... |
| 563 |
0
|
try { |
| 564 |
0
|
return connectionHandler.getConnection(); |
| 565 |
|
} catch (Exception e) { |
| 566 |
0
|
throw new MojoExecutionException("Error establishing connection", e); |
| 567 |
|
} |
| 568 |
|
} |
| 569 |
|
|
| 570 |
|
|
| 571 |
|
|
| 572 |
|
|
| 573 |
|
@return |
| 574 |
|
@throws |
| 575 |
|
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
| 576 |
0
|
protected Properties getDriverProperties() throws MojoExecutionException {... |
| 577 |
0
|
Properties properties = new Properties(); |
| 578 |
|
|
| 579 |
0
|
if (isEmpty(this.driverProperties)) { |
| 580 |
0
|
return properties; |
| 581 |
|
} |
| 582 |
|
|
| 583 |
0
|
String[] tokens = split(this.driverProperties, ","); |
| 584 |
0
|
for (int i = 0; i < tokens.length; ++i) { |
| 585 |
0
|
String[] keyValueTokens = split(tokens[i].trim(), "="); |
| 586 |
0
|
if (keyValueTokens.length != 2) { |
| 587 |
0
|
throw new MojoExecutionException("Invalid JDBC Driver properties: " + this.driverProperties); |
| 588 |
|
} |
| 589 |
0
|
properties.setProperty(keyValueTokens[0], keyValueTokens[1]); |
| 590 |
|
} |
| 591 |
0
|
return properties; |
| 592 |
|
} |
| 593 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 594 |
0
|
public String getUsername() {... |
| 595 |
0
|
return this.username; |
| 596 |
|
} |
| 597 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 598 |
0
|
public void setUsername(String username) {... |
| 599 |
0
|
this.username = username; |
| 600 |
|
} |
| 601 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 602 |
0
|
public String getPassword() {... |
| 603 |
0
|
return this.password; |
| 604 |
|
} |
| 605 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 606 |
0
|
public void setPassword(String password) {... |
| 607 |
0
|
this.password = password; |
| 608 |
|
} |
| 609 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 610 |
0
|
public String getUrl() {... |
| 611 |
0
|
return this.url; |
| 612 |
|
} |
| 613 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 614 |
0
|
public void setUrl(String url) {... |
| 615 |
0
|
this.url = url; |
| 616 |
|
} |
| 617 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 618 |
0
|
public String getDriver() {... |
| 619 |
0
|
return this.driver; |
| 620 |
|
} |
| 621 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 622 |
0
|
public void setDriver(String driver) {... |
| 623 |
0
|
this.driver = driver; |
| 624 |
|
} |
| 625 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 626 |
0
|
public void setAutocommit(boolean autocommit) {... |
| 627 |
0
|
this.autocommit = autocommit; |
| 628 |
|
} |
| 629 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 630 |
0
|
public File[] getSrcFiles() {... |
| 631 |
0
|
return this.srcFiles; |
| 632 |
|
} |
| 633 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 634 |
0
|
public void setSrcFiles(File[] files) {... |
| 635 |
0
|
this.srcFiles = files; |
| 636 |
|
} |
| 637 |
|
|
| 638 |
|
|
| 639 |
|
|
| 640 |
|
|
| 641 |
|
@return |
| 642 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 643 |
0
|
public int getSuccessfulStatements() {... |
| 644 |
0
|
return successfulStatements; |
| 645 |
|
} |
| 646 |
|
|
| 647 |
|
|
| 648 |
|
|
| 649 |
|
|
| 650 |
|
@return |
| 651 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 652 |
0
|
public int getTotalStatements() {... |
| 653 |
0
|
return totalStatements; |
| 654 |
|
} |
| 655 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 656 |
0
|
public String getOnError() {... |
| 657 |
0
|
return this.onError; |
| 658 |
|
} |
| 659 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 660 |
0
|
public void setOnError(String action) {... |
| 661 |
0
|
if (SQLExecutor.ON_ERROR_ABORT.equalsIgnoreCase(action)) { |
| 662 |
0
|
this.onError = SQLExecutor.ON_ERROR_ABORT; |
| 663 |
0
|
} else if (SQLExecutor.ON_ERROR_CONTINUE.equalsIgnoreCase(action)) { |
| 664 |
0
|
this.onError = SQLExecutor.ON_ERROR_CONTINUE; |
| 665 |
0
|
} else if (SQLExecutor.ON_ERROR_ABORT_AFTER.equalsIgnoreCase(action)) { |
| 666 |
0
|
this.onError = SQLExecutor.ON_ERROR_ABORT_AFTER; |
| 667 |
|
} else { |
| 668 |
0
|
throw new IllegalArgumentException(action + " is not a valid value for onError, only '" + SQLExecutor.ON_ERROR_ABORT + "', '" + SQLExecutor.ON_ERROR_ABORT_AFTER + "', or '" + SQLExecutor.ON_ERROR_CONTINUE + "'."); |
| 669 |
|
} |
| 670 |
|
} |
| 671 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 672 |
0
|
public void setSettingsKey(String key) {... |
| 673 |
0
|
this.settingsKey = key; |
| 674 |
|
} |
| 675 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 676 |
0
|
public void setDriverProperties(String driverProperties) {... |
| 677 |
0
|
this.driverProperties = driverProperties; |
| 678 |
|
} |
| 679 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 680 |
0
|
public String getSqlCommand() {... |
| 681 |
0
|
return sqlCommand; |
| 682 |
|
} |
| 683 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 684 |
0
|
public void setSqlCommand(String sqlCommand) {... |
| 685 |
0
|
this.sqlCommand = sqlCommand; |
| 686 |
|
} |
| 687 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 688 |
0
|
public Vector<Transaction> getTransactions() {... |
| 689 |
0
|
return transactions; |
| 690 |
|
} |
| 691 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 692 |
0
|
public void setTransactions(Vector<Transaction> transactions) {... |
| 693 |
0
|
this.transactions = transactions; |
| 694 |
|
} |
| 695 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 696 |
0
|
public void setFileFilter(MavenFileFilter filter) {... |
| 697 |
0
|
this.fileFilter = filter; |
| 698 |
|
} |
| 699 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 700 |
0
|
public String getTargetDatabase() {... |
| 701 |
0
|
return targetDatabase; |
| 702 |
|
} |
| 703 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 704 |
0
|
public void setTargetDatabase(String targetDatabase) {... |
| 705 |
0
|
this.targetDatabase = targetDatabase; |
| 706 |
|
} |
| 707 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 708 |
0
|
public Connection getConn() {... |
| 709 |
0
|
return conn; |
| 710 |
|
} |
| 711 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 712 |
0
|
public void setConn(Connection conn) {... |
| 713 |
0
|
this.conn = conn; |
| 714 |
|
} |
| 715 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 716 |
0
|
public String getDelimiter() {... |
| 717 |
0
|
return delimiter; |
| 718 |
|
} |
| 719 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 720 |
0
|
public String getDelimiterType() {... |
| 721 |
0
|
return delimiterType; |
| 722 |
|
} |
| 723 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 724 |
0
|
public boolean isKeepFormat() {... |
| 725 |
0
|
return keepFormat; |
| 726 |
|
} |
| 727 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 728 |
0
|
public boolean isShowheaders() {... |
| 729 |
0
|
return showheaders; |
| 730 |
|
} |
| 731 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 732 |
0
|
public boolean isAppend() {... |
| 733 |
0
|
return append; |
| 734 |
|
} |
| 735 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 736 |
0
|
public boolean isEscapeProcessing() {... |
| 737 |
0
|
return escapeProcessing; |
| 738 |
|
} |
| 739 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 740 |
0
|
public boolean isSkipOnConnectionError() {... |
| 741 |
0
|
return skipOnConnectionError; |
| 742 |
|
} |
| 743 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 744 |
0
|
public void setSkipOnConnectionError(boolean skipOnConnectionError) {... |
| 745 |
0
|
this.skipOnConnectionError = skipOnConnectionError; |
| 746 |
|
} |
| 747 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 748 |
0
|
public MavenFileFilter getFileFilter() {... |
| 749 |
0
|
return fileFilter; |
| 750 |
|
} |
| 751 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 752 |
0
|
public boolean isShowPassword() {... |
| 753 |
0
|
return showPassword; |
| 754 |
|
} |
| 755 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 756 |
0
|
public void setShowPassword(boolean showPassword) {... |
| 757 |
0
|
this.showPassword = showPassword; |
| 758 |
|
} |
| 759 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 760 |
0
|
public boolean isEnableAnonymousPassword() {... |
| 761 |
0
|
return enableAnonymousPassword; |
| 762 |
|
} |
| 763 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 764 |
0
|
public void setEnableAnonymousPassword(boolean enableAnonymousPassword) {... |
| 765 |
0
|
this.enableAnonymousPassword = enableAnonymousPassword; |
| 766 |
|
} |
| 767 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 768 |
0
|
public String getSettingsKey() {... |
| 769 |
0
|
return settingsKey; |
| 770 |
|
} |
| 771 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 772 |
0
|
public boolean isAutocommit() {... |
| 773 |
0
|
return autocommit; |
| 774 |
|
} |
| 775 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 776 |
0
|
public void setSuccessfulStatements(int successfulStatements) {... |
| 777 |
0
|
this.successfulStatements = successfulStatements; |
| 778 |
|
} |
| 779 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 780 |
0
|
public void setTotalStatements(int totalStatements) {... |
| 781 |
0
|
this.totalStatements = totalStatements; |
| 782 |
|
} |
| 783 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 784 |
0
|
public void setCredentials(Credentials credentials) {... |
| 785 |
0
|
this.credentials = credentials; |
| 786 |
|
} |
| 787 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 788 |
0
|
public Credentials getCredentials() {... |
| 789 |
0
|
return credentials; |
| 790 |
|
} |
| 791 |
|
|
| 792 |
|
} |