001/* 002 * Copyright 2005-2007 The Kuali Foundation 003 * 004 * 005 * Licensed under the Educational Community License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.opensource.org/licenses/ecl2.php 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.kualigan.tools.ant.tasks; 018 019import java.sql.Connection; 020import java.util.List; 021import java.util.Vector; 022 023import org.apache.tools.ant.BuildException; 024import org.apache.tools.ant.DirectoryScanner; 025import org.apache.tools.ant.Task; 026import org.apache.tools.ant.types.FileSet; 027 028import static org.apache.tools.ant.Project.MSG_DEBUG; 029 030/** 031 * Shorthand form of an SVN Repository. Localizes information for credentials and url, and stores 032 * the information in an easy-to-reference id. 033 * 034 * 035 * @author $Author$ 036 * @version $Revision$ 037 */ 038public class RdbmsConfig extends Task { 039 private String id; 040 private String url; 041 private String schema; 042 private String username; 043 private String password; 044 private String driver; 045 private Connection connection; 046 047 public RdbmsConfig() { 048 } 049 050 /** 051 * Gets the value of url 052 * 053 * @return the value of url 054 */ 055 public final String getUrl() { 056 return this.url; 057 } 058 059 /** 060 * Sets the value of url 061 * 062 * @param argUrl Value to assign to this.url 063 */ 064 public final void setUrl(final String argUrl) { 065 this.url = argUrl; 066 } 067 068 069 /** 070 * Gets the value of Connection 071 * 072 * @return the value of Connection 073 */ 074 public final Connection getConnection() { 075 return this.connection; 076 } 077 078 /** 079 * Sets the value of connection 080 * 081 * @param argConnection Value to assign to this.connection 082 */ 083 public final void setConnection(final Connection argConnection) { 084 this.connection = argConnection; 085 } 086 087 /** 088 * Gets the value of id 089 * 090 * @return the value of id 091 */ 092 public final String getId() { 093 return this.id; 094 } 095 096 /** 097 * Sets the value of id 098 * 099 * @param argId Value to assign to this.id 100 */ 101 public final void setId(final String argId) { 102 this.id = argId; 103 } 104 105 /** 106 * Gets the value of username 107 * 108 * @return the value of username 109 */ 110 public final String getUsername() { 111 return this.username; 112 } 113 114 /** 115 * Sets the value of username 116 * 117 * @param argUsername Value to assign to this.username 118 */ 119 public final void setUsername(final String argUsername) { 120 this.username = argUsername; 121 } 122 123 /** 124 * Gets the value of password 125 * 126 * @return the value of password 127 */ 128 public final String getPassword() { 129 return this.password; 130 } 131 132 /** 133 * Sets the value of password 134 * 135 * @param argPassword Value to assign to this.password 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 * Gets the value of driver 147 * 148 * @return the value of driver 149 */ 150 public final String getDriver() { 151 return this.driver; 152 } 153 154 /** 155 * Sets the value of driver 156 * 157 * @param argDriver Value to assign to this.driver 158 */ 159 public final void setDriver(final String argDriver) { 160 this.driver = argDriver; 161 } 162 163 /** 164 * Gets the value of schema 165 * 166 * @return the value of schema 167 */ 168 public final String getSchema() { 169 return this.schema; 170 } 171 172 /** 173 * Sets the value of schema 174 * 175 * @param argSchema Value to assign to this.schema 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}