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