View Javadoc

1   /*
2    * Copyright 2005-2007 The Kuali Foundation
3    *
4    *
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    *
9    * http://www.opensource.org/licenses/ecl2.php
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
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   * Shorthand form of an SVN Repository. Localizes information for credentials and url, and stores
32   * the information in an easy-to-reference id.
33   *
34   *
35   * @author $Author$
36   * @version $Revision$
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       * Gets the value of url
52       *
53       * @return the value of url
54       */
55      public final String getUrl() {
56          return this.url;
57      }
58      
59      /**
60       * Sets the value of url
61       *
62       * @param argUrl Value to assign to this.url
63       */
64      public final void setUrl(final String argUrl) {
65          this.url = argUrl;
66      }
67  
68      
69      /**
70       * Gets the value of Connection
71       *
72       * @return the value of Connection
73       */
74      public final Connection getConnection() {
75          return this.connection;
76      }
77      
78      /**
79       * Sets the value of connection
80       *
81       * @param argConnection Value to assign to this.connection
82       */
83      public final void setConnection(final Connection argConnection) {
84          this.connection = argConnection;
85      }
86  
87      /**
88       * Gets the value of id
89       *
90       * @return the value of id
91       */
92      public final String getId() {
93          return this.id;
94      }
95      
96      /**
97       * Sets the value of id
98       *
99       * @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 }