| 1 | |
package org.kuali.core.db.torque; |
| 2 | |
|
| 3 | |
import java.sql.Connection; |
| 4 | |
import java.sql.SQLException; |
| 5 | |
import java.util.List; |
| 6 | |
|
| 7 | |
import org.apache.commons.beanutils.BeanUtils; |
| 8 | |
import org.apache.commons.lang.StringUtils; |
| 9 | |
import org.apache.tools.ant.Task; |
| 10 | |
import org.apache.torque.engine.platform.Platform; |
| 11 | |
import org.kuali.db.ConnectionHandler; |
| 12 | |
import org.kuali.db.Credentials; |
| 13 | |
|
| 14 | 0 | public class DumpTask extends Task { |
| 15 | |
|
| 16 | 0 | Utils utils = new Utils(); |
| 17 | |
|
| 18 | 0 | ConnectionHandler connectionHandler = new ConnectionHandler(); |
| 19 | |
|
| 20 | |
boolean antCompatibilityMode; |
| 21 | |
|
| 22 | |
protected void showConfiguration() { |
| 23 | 0 | log("Schema: " + schema); |
| 24 | 0 | log("Artifact Id: " + artifactId); |
| 25 | 0 | log("Database Vendor: " + getTargetDatabase()); |
| 26 | 0 | if (getEncoding() == null) { |
| 27 | 0 | log("Encoding: " + System.getProperty("file.encoding")); |
| 28 | |
} else { |
| 29 | 0 | log("Encoding: " + getEncoding()); |
| 30 | |
} |
| 31 | 0 | } |
| 32 | |
|
| 33 | |
protected void updateConfiguration(Platform platform) { |
| 34 | 0 | if (StringUtils.isEmpty(schema)) { |
| 35 | 0 | schema = platform.getSchemaName(artifactId); |
| 36 | |
} |
| 37 | 0 | if (StringUtils.isEmpty(username)) { |
| 38 | 0 | username = schema; |
| 39 | |
} |
| 40 | 0 | if (StringUtils.isEmpty(password)) { |
| 41 | 0 | password = schema; |
| 42 | |
} |
| 43 | 0 | } |
| 44 | |
|
| 45 | |
protected Connection getConnection() throws SQLException { |
| 46 | |
try { |
| 47 | 0 | BeanUtils.copyProperties(connectionHandler, this); |
| 48 | 0 | } catch (Exception e) { |
| 49 | 0 | throw new SQLException("Error copying properties", e); |
| 50 | 0 | } |
| 51 | 0 | Credentials credentials = new Credentials(username, password); |
| 52 | 0 | connectionHandler.setCredentials(credentials); |
| 53 | 0 | return connectionHandler.getConnection(); |
| 54 | |
} |
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
String artifactId; |
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
String encoding; |
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
List<String> includePatterns; |
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
List<String> excludePatterns; |
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
String comment; |
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
String url; |
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
String driver; |
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
String username; |
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
String password; |
| 100 | |
|
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
String schema; |
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
String targetDatabase; |
| 110 | |
|
| 111 | |
public String getEncoding() { |
| 112 | 0 | return encoding; |
| 113 | |
} |
| 114 | |
|
| 115 | |
public void setEncoding(String encoding) { |
| 116 | 0 | this.encoding = encoding; |
| 117 | 0 | } |
| 118 | |
|
| 119 | |
public List<String> getIncludePatterns() { |
| 120 | 0 | return includePatterns; |
| 121 | |
} |
| 122 | |
|
| 123 | |
public void setIncludePatterns(List<String> includePatterns) { |
| 124 | 0 | this.includePatterns = includePatterns; |
| 125 | 0 | } |
| 126 | |
|
| 127 | |
public List<String> getExcludePatterns() { |
| 128 | 0 | return excludePatterns; |
| 129 | |
} |
| 130 | |
|
| 131 | |
public void setExcludePatterns(List<String> excludePatterns) { |
| 132 | 0 | this.excludePatterns = excludePatterns; |
| 133 | 0 | } |
| 134 | |
|
| 135 | |
public String getComment() { |
| 136 | 0 | return comment; |
| 137 | |
} |
| 138 | |
|
| 139 | |
public void setComment(String comment) { |
| 140 | 0 | this.comment = comment; |
| 141 | 0 | } |
| 142 | |
|
| 143 | |
public String getUrl() { |
| 144 | 0 | return url; |
| 145 | |
} |
| 146 | |
|
| 147 | |
public void setUrl(String url) { |
| 148 | 0 | this.url = url; |
| 149 | 0 | } |
| 150 | |
|
| 151 | |
public String getDriver() { |
| 152 | 0 | return driver; |
| 153 | |
} |
| 154 | |
|
| 155 | |
public void setDriver(String driver) { |
| 156 | 0 | this.driver = driver; |
| 157 | 0 | } |
| 158 | |
|
| 159 | |
public String getUsername() { |
| 160 | 0 | return username; |
| 161 | |
} |
| 162 | |
|
| 163 | |
public void setUsername(String username) { |
| 164 | 0 | this.username = username; |
| 165 | 0 | } |
| 166 | |
|
| 167 | |
public String getPassword() { |
| 168 | 0 | return password; |
| 169 | |
} |
| 170 | |
|
| 171 | |
public void setPassword(String password) { |
| 172 | 0 | this.password = password; |
| 173 | 0 | } |
| 174 | |
|
| 175 | |
public String getSchema() { |
| 176 | 0 | return schema; |
| 177 | |
} |
| 178 | |
|
| 179 | |
public void setSchema(String schema) { |
| 180 | 0 | this.schema = schema; |
| 181 | 0 | } |
| 182 | |
|
| 183 | |
public String getTargetDatabase() { |
| 184 | 0 | return targetDatabase; |
| 185 | |
} |
| 186 | |
|
| 187 | |
public void setTargetDatabase(String targetDatabase) { |
| 188 | 0 | this.targetDatabase = targetDatabase; |
| 189 | 0 | } |
| 190 | |
|
| 191 | |
public ConnectionHandler getConnectionHandler() { |
| 192 | 0 | return connectionHandler; |
| 193 | |
} |
| 194 | |
|
| 195 | |
public void setConnectionHandler(ConnectionHandler connectionHandler) { |
| 196 | 0 | this.connectionHandler = connectionHandler; |
| 197 | 0 | } |
| 198 | |
|
| 199 | |
public String getArtifactId() { |
| 200 | 0 | return artifactId; |
| 201 | |
} |
| 202 | |
|
| 203 | |
public void setArtifactId(String artifactId) { |
| 204 | 0 | this.artifactId = artifactId; |
| 205 | 0 | } |
| 206 | |
|
| 207 | |
public boolean isAntCompatibilityMode() { |
| 208 | 0 | return antCompatibilityMode; |
| 209 | |
} |
| 210 | |
|
| 211 | |
public void setAntCompatibilityMode(boolean antCompatibilityMode) { |
| 212 | 0 | this.antCompatibilityMode = antCompatibilityMode; |
| 213 | 0 | } |
| 214 | |
|
| 215 | |
} |