1 package xdoclet.modules.ojb; 2 3 17 18 import org.apache.commons.logging.Log; 19 import xdoclet.XDocletException; 20 import xdoclet.XmlSubTask; 21 import xdoclet.util.LogUtil; 22 import xdoclet.util.Translator; 23 24 31 public class TorqueSubTask extends XmlSubTask 32 { 33 private static String TORQUE_TEMPLATE_FILE = "resources/torque_xml.xdt"; 34 private static String TORQUE_DEFAULT_FILE_NAME = "project-schema.xml"; 35 36 37 private boolean _isVerbose = false; 38 39 private String _databaseName; 40 41 private String _dtdUrl = "http://jakarta.apache.org/turbine/dtd/database.dtd"; 42 43 private boolean _isGeneratingForeignkeys = true; 44 45 46 49 public TorqueSubTask() 50 { 51 setTemplateURL(getClass().getResource(TORQUE_TEMPLATE_FILE)); 52 setDestinationFile(TORQUE_DEFAULT_FILE_NAME); 53 setSubTaskName("torqueschema"); 54 } 55 56 61 public boolean getVerbose() 62 { 63 return _isVerbose; 64 } 65 66 71 public void setVerbose(boolean beVerbose) 72 { 73 _isVerbose = beVerbose; 74 } 75 76 81 public void setDtdUrl(String url) 82 { 83 _dtdUrl = url; 84 } 85 86 91 public String getDtdUrl() 92 { 93 return _dtdUrl; 94 } 95 96 101 public String getDatabaseName() 102 { 103 return _databaseName; 104 } 105 106 111 public void setDatabaseName(String databaseName) 112 { 113 _databaseName = databaseName; 114 } 115 116 121 public void setGenerateForeignkeys(boolean generateForeignkeys) 122 { 123 _isGeneratingForeignkeys = generateForeignkeys; 124 } 125 126 131 public boolean getGenerateForeignkeys() 132 { 133 return _isGeneratingForeignkeys; 134 } 135 136 141 public void validateOptions() throws XDocletException 142 { 143 if ((_databaseName == null) || (_databaseName.length() == 0)) { 144 throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class, 145 XDocletModulesOjbMessages.DATABASENAME_IS_REQUIRED)); 146 } 147 } 148 149 154 public void execute() throws XDocletException 155 { 156 startProcess(); 157 } 158 159 public void startProcess() throws XDocletException 160 { 161 Log log = LogUtil.getLog(TorqueSubTask.class, "startProcess"); 162 163 if (log.isDebugEnabled()) { 164 log.debug("destDir.toString()=" + getDestDir()); 165 log.debug("getTemplateURL()=" + getTemplateURL()); 166 log.debug("getDestinationfile()=" + getDestinationFile()); 167 log.debug("getOfType()=" + getOfType()); 168 log.debug("getExtent()=" + getExtent()); 169 log.debug("getHavingClassTag()=" + getHavingClassTag()); 170 } 171 172 startProcessForAll(); 173 } 174 175 180 protected void engineStarted() throws XDocletException 181 { 182 System.out.println("Generating torque schema ("+getDestinationFile()+")"); 183 } 184 } 185 | Popular Tags |