View Javadoc

1   package org.apache.torque.mojo;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  
24  import org.apache.commons.configuration.PropertiesConfiguration;
25  import org.apache.maven.plugin.MojoExecutionException;
26  import org.apache.tools.ant.types.FileSet;
27  import org.kuali.core.db.torque.KualiTorqueSQLTask;
28  
29  /**
30   * Generates SQL from schema.xml files
31   */
32  public abstract class SqlMojoBase extends DataModelTaskMojo {
33  
34  	/**
35  	 * Creates a new SQLMojo object.
36  	 */
37  	public SqlMojoBase() {
38  		setAntTask(new KualiTorqueSQLTask());
39  	}
40  
41  	/**
42  	 * Returns the context properties for the Texen task.
43  	 * 
44  	 * @return The PropertiesConfiguration containing all context properties, not null.
45  	 */
46  	protected PropertiesConfiguration getMojoContextProperties() {
47  		PropertiesConfiguration configuration = new PropertiesConfiguration();
48  		configuration.addProperty(TARGET_DATABASE_CONTEXT_PROPERTY, super.getTargetDatabase());
49  		return configuration;
50  	}
51  
52  	/**
53  	 * Returns the path to the control template.
54  	 * 
55  	 * @return "sql/base/Control.vm"
56  	 */
57  	protected String getControlTemplate() {
58  		return "sql/base/Control.vm";
59  	}
60  
61  	/**
62  	 * Configures the Texen task wrapped by this mojo
63  	 */
64  	protected void configureTask() throws MojoExecutionException {
65  		super.configureTask();
66  
67  		KualiTorqueSQLTask task = (KualiTorqueSQLTask) super.getGeneratorTask();
68  
69  		if (getSuffix() != null) {
70  			getLog().debug("Adding suffix: " + getSuffix());
71  			task.setSuffix(getSuffix());
72  		}
73  		FileSet fileSet = getAntFileSet(new File(getSchemaDir()), getSchemaIncludes(), getSchemaExcludes());
74  		task.addFileset(fileSet);
75  	}
76  
77  }