| 1 | | | |
| 2 | | | |
| 3 | | | |
| 4 | | | |
| 5 | | | |
| 6 | | | |
| 7 | | | |
| 8 | | | |
| 9 | | | |
| 10 | | | |
| 11 | | | |
| 12 | | | |
| 13 | | | |
| 14 | | | |
| 15 | | | |
| 16 | | | |
| 17 | | | |
| 18 | | | |
| 19 | | | |
| 20 | | | |
| 21 | | | |
| 22 | | | |
| 23 | | | |
| 24 | | | |
| 25 | | | |
| 26 | | | |
| 27 | | | |
| 28 | | | |
| 29 | | | |
| 30 | | | |
| 31 | | | |
| 32 | | | |
| 33 | | | package org.jcoderz.phoenix.cmpgen2; |
| 34 | | | |
| 35 | | | import java.io.File; |
| 36 | | | import java.io.FileInputStream; |
| 37 | | | import java.io.FileWriter; |
| 38 | | | import java.io.IOException; |
| 39 | | | import java.io.StringReader; |
| 40 | | | import java.io.StringWriter; |
| 41 | | | import java.util.Iterator; |
| 42 | | | import java.util.List; |
| 43 | | | import java.util.Properties; |
| 44 | | | import java.util.Set; |
| 45 | | | import java.util.StringTokenizer; |
| 46 | | | import java.util.TreeSet; |
| 47 | | | import java.util.logging.Level; |
| 48 | | | import java.util.logging.Logger; |
| 49 | | | |
| 50 | | | import org.apache.velocity.Template; |
| 51 | | | import org.apache.velocity.VelocityContext; |
| 52 | | | import org.apache.velocity.app.Velocity; |
| 53 | | | import org.apache.velocity.runtime.RuntimeConstants; |
| 54 | | | import org.jcoderz.commons.util.IoUtil; |
| 55 | | | import org.jcoderz.phoenix.sqlparser.ColumnSpec; |
| 56 | | | import org.jcoderz.phoenix.sqlparser.CreateTableStatement; |
| 57 | | | import org.jcoderz.phoenix.sqlparser.SqlParser; |
| 58 | | | import org.jcoderz.phoenix.sqlparser.SqlScanner; |
| 59 | | | import org.jcoderz.phoenix.sqlparser.SqlStatement; |
| 60 | | | |
| 61 | | | |
| 62 | | | |
| 63 | | | |
| 64 | | | @author |
| 65 | | | |
| 66 | | | public class CmpGenerator |
| 67 | | | { |
| 68 | | | |
| 69 | 0 | | private static final String CLASSNAME = CmpGenerator.class.getName(); |
| 70 | | | |
| 71 | 0 | | private static final Logger logger = Logger.getLogger(CLASSNAME); |
| 72 | | | |
| 73 | | | private static final String ARRAY_MAGIC = "[]"; |
| 74 | 0 | | private static final int ARRAY_MAGIC_LENGTH = ARRAY_MAGIC.length(); |
| 75 | | | |
| 76 | | | private final String mOutputBaseDirectory; |
| 77 | | | private final String mPackagePrefix; |
| 78 | | | private final String mDataSource; |
| 79 | | | private File mOutputDirectory; |
| 80 | | | private final String mTemplateDir; |
| 81 | | | private final boolean mOverwrite; |
| 82 | | | |
| 83 | | | |
| 84 | | | |
| 85 | | | |
| 86 | | | @param |
| 87 | | | @param |
| 88 | | | @param |
| 89 | | | |
| 90 | | | public CmpGenerator (String outputDir, String pkgPrefix, String dataSource, |
| 91 | | (1)(2) | String templateDir, boolean overwrite) |
| 92 | 0 | | { |
| 93 | 0 | | mOutputBaseDirectory = outputDir; |
| 94 | 0 | | mPackagePrefix = pkgPrefix; |
| 95 | 0 | | mDataSource = dataSource; |
| 96 | 0 | | mTemplateDir = templateDir; |
| 97 | 0 | | mOverwrite = overwrite; |
| 98 | 0 | | } |
| 99 | | | |
| 100 | | | private static void usage (String errorText) |
| 101 | | | { |
| 102 | 0 | | if (errorText != null) |
| 103 | | | { |
| 104 | 0 | | System.err.println(errorText); |
| 105 | | | } |
| 106 | 0 | | System.err.println("Usage: CmpGenerator "); |
| 107 | 0 | | System.err.println( |
| 108 | | | " -i <inputfile> Input SQL file"); |
| 109 | 0 | | System.err.println(" -d <outputdir> Base output directory"); |
| 110 | 0 | | System.err.println( |
| 111 | | | " Package subdirs will be created here"); |
| 112 | 0 | | System.err.println( |
| 113 | | | " -p <package> Package of generated classes"); |
| 114 | 0 | | System.err.println(" Defaults to 'org.jcoderz'"); |
| 115 | 0 | | System.err.println( |
| 116 | | | " -ds <datasource> JNDI lookup name of bean's datasource"); |
| 117 | 0 | | System.err.println( |
| 118 | | | " -t <templatedir> Directory where bean " |
| 119 | | | + "templates can be found"); |
| 120 | 0 | | System.err.println(" -o Overwrite existing files"); |
| 121 | 0 | (3) | System.exit(1); |
| 122 | 0 | | } |
| 123 | | | |
| 124 | | | |
| 125 | | | |
| 126 | | | @param |
| 127 | | | |
| 128 | | | public static void main (String[] args) |
| 129 | | (4)(5) | throws Exception |
| 130 | | | { |
| 131 | 0 | | String outputDir = "."; |
| 132 | 0 | | String pkgPrefix = "org.jcoderz"; |
| 133 | 0 | | String dataSource = "jdbc/default"; |
| 134 | 0 | | String inputFile = null; |
| 135 | 0 | | String templateDir = null; |
| 136 | | | |
| 137 | 0 | | boolean overwrite = false; |
| 138 | | | |
| 139 | 0 | | String currentArg = null; |
| 140 | | | |
| 141 | | | try |
| 142 | | | { |
| 143 | 0 | | for (int i = 0; i < args.length; i++) |
| 144 | | | { |
| 145 | 0 | | currentArg = args[i]; |
| 146 | 0 | (6)(7) | if (currentArg.equals("-d")) |
| 147 | | | { |
| 148 | 0 | | outputDir = args[++i]; |
| 149 | | | } |
| 150 | 0 | (8)(9) | else if (currentArg.equals("-i")) |
| 151 | | | { |
| 152 | 0 | | inputFile = args[++i]; |
| 153 | | | } |
| 154 | 0 | (10)(11) | else if (currentArg.equals("-p")) |
| 155 | | | { |
| 156 | 0 | | pkgPrefix = args[++i]; |
| 157 | | | } |
| 158 | 0 | (12)(13) | else if (currentArg.equals("-ds")) |
| 159 | | | { |
| 160 | 0 | | dataSource = args[++i]; |
| 161 | | | } |
| 162 | 0 | (14)(15) | else if (currentArg.equals("-t")) |
| 163 | | | { |
| 164 | 0 | | templateDir = args[++i]; |
| 165 | | | } |
| 166 | 0 | (16)(17) | else if (currentArg.equals("-o")) |
| 167 | | | { |
| 168 | 0 | | overwrite = true; |
| 169 | | | } |
| 170 | | | else |
| 171 | | | { |
| 172 | 0 | | usage("Unknown command line option " + currentArg); |
| 173 | | | } |
| 174 | | | } |
| 175 | | | } |
| 176 | 0 | | catch (ArrayIndexOutOfBoundsException e) |
| 177 | | | { |
| 178 | 0 | | usage("Command line option '" + currentArg + "' requires an option"); |
| 179 | 0 | | } |
| 180 | | | |
| 181 | 0 | | if (inputFile == null || templateDir == null) |
| 182 | | | { |
| 183 | 0 | | usage("Mandatory parameter missing"); |
| 184 | | | } |
| 185 | | | |
| 186 | 0 | | final CmpGenerator generator = |
| 187 | | | new CmpGenerator( |
| 188 | | | outputDir, pkgPrefix, dataSource, templateDir, overwrite); |
| 189 | 0 | | generator.generateCmpBeans(inputFile); |
| 190 | 0 | | } |
| 191 | | | |
| 192 | | | |
| 193 | | | |
| 194 | | | |
| 195 | | | @param |
| 196 | | | |
| 197 | | | public final void generateCmpBeans (String inputFile) |
| 198 | | (18)(19) | throws Exception |
| 199 | | | { |
| 200 | 0 | | final String methodName = "generateCmpBeans(String)"; |
| 201 | 0 | | if (logger.isLoggable(Level.FINER)) |
| 202 | | | { |
| 203 | 0 | | logger.entering(CLASSNAME, methodName, new Object[] {inputFile}); |
| 204 | | | } |
| 205 | | | |
| 206 | | | try |
| 207 | | | { |
| 208 | 0 | | setUp(); |
| 209 | | | |
| 210 | 0 | | final FileInputStream fin = new FileInputStream(inputFile); |
| 211 | 0 | | final SqlScanner sqlScanner = new SqlScanner(fin); |
| 212 | 0 | | final SqlParser sqlParser = new SqlParser(sqlScanner); |
| 213 | 0 | | final List sqlStatements = sqlParser.parse(); |
| 214 | 0 | | for (final Iterator it = sqlStatements.iterator(); it.hasNext();) |
| 215 | | | { |
| 216 | 0 | | final SqlStatement statement = (SqlStatement) it.next(); |
| 217 | 0 | | if (statement instanceof CreateTableStatement) |
| 218 | | | { |
| 219 | | | |
| 220 | | | |
| 221 | 0 | | generateCmpBean((CreateTableStatement) statement); |
| 222 | | | } |
| 223 | | | else |
| 224 | | | { |
| 225 | 0 | | logger.info("Skipping statement " + statement); |
| 226 | | | } |
| 227 | 0 | | } |
| 228 | | | } |
| 229 | 0 | | catch (Exception x) |
| 230 | | | { |
| 231 | 0 | | logger.log(Level.SEVERE, "Error during CMP generation", x); |
| 232 | 0 | | throw x; |
| 233 | 0 | | } |
| 234 | | | |
| 235 | 0 | | if (logger.isLoggable(Level.FINER)) |
| 236 | | | { |
| 237 | 0 | | logger.exiting(CLASSNAME, methodName); |
| 238 | | | } |
| 239 | 0 | | } |
| 240 | | | |
| 241 | | (20) | public String sqlNameToJavaName (String sqlName) |
| 242 | | | { |
| 243 | 0 | | final StringReader rdr = new StringReader(sqlName); |
| 244 | | | int c; |
| 245 | 0 | | boolean capitalizeNext = true; |
| 246 | 0 | | final StringBuffer result = new StringBuffer(); |
| 247 | | | try |
| 248 | | | { |
| 249 | 0 | | while ((c = rdr.read()) != -1) |
| 250 | | | { |
| 251 | 0 | | final char chr = (char) c; |
| 252 | 0 | | switch (chr) |
| 253 | | | { |
| 254 | | | case '_': |
| 255 | 0 | | capitalizeNext = true; |
| 256 | 0 | | break; |
| 257 | | | default: |
| 258 | 0 | | if (capitalizeNext) |
| 259 | | | { |
| 260 | 0 | | result.append(Character.toUpperCase(chr)); |
| 261 | 0 | | capitalizeNext = false; |
| 262 | | | } |
| 263 | | | else |
| 264 | | | { |
| 265 | 0 | | result.append(chr); |
| 266 | | | } |
| 267 | | | break; |
| 268 | | | } |
| 269 | 0 | | } |
| 270 | | | } |
| 271 | 0 | | catch (IOException e) |
| 272 | | | { |
| 273 | 0 | (21) | throw new RuntimeException("Huh???", e); |
| 274 | 0 | | } |
| 275 | 0 | | return result.toString(); |
| 276 | | | } |
| 277 | | | |
| 278 | | | |
| 279 | | | |
| 280 | | | |
| 281 | | | |
| 282 | | | @param |
| 283 | | | @return |
| 284 | | | |
| 285 | | | public String capitalize (String s) |
| 286 | | | { |
| 287 | | | final String str; |
| 288 | 0 | | if (s.endsWith(ARRAY_MAGIC)) |
| 289 | | | { |
| 290 | 0 | | str = s.substring(0, s.length() - ARRAY_MAGIC_LENGTH) + "Array"; |
| 291 | | | } |
| 292 | | | else |
| 293 | | | { |
| 294 | 0 | | str = s; |
| 295 | | | } |
| 296 | 0 | | final char c = str.charAt(0); |
| 297 | | | final String result; |
| 298 | 0 | | if (Character.isUpperCase(c)) |
| 299 | | | { |
| 300 | 0 | | result = str; |
| 301 | | | } |
| 302 | | | else |
| 303 | | | { |
| 304 | 0 | | result = String.valueOf(Character.toUpperCase(c)) + str.substring(1); |
| 305 | | | } |
| 306 | 0 | | return result; |
| 307 | | | } |
| 308 | | | |
| 309 | | (22) | public String getUnqualifiedJavaType (ColumnSpec column) |
| 310 | | | throws CmpGeneratorException |
| 311 | | | { |
| 312 | 0 | | final String result = TypeMapping.getJavaType(column, false); |
| 313 | 0 | | if (result == null) |
| 314 | | | { |
| 315 | 0 | | throw new RuntimeException("TypeMapping returned null for " + column); |
| 316 | | | } |
| 317 | 0 | | return result; |
| 318 | | | } |
| 319 | | | |
| 320 | | (23) | public String getQualifiedJavaType (ColumnSpec column) |
| 321 | | | throws CmpGeneratorException |
| 322 | | | { |
| 323 | 0 | | return TypeMapping.getJavaType(column, true); |
| 324 | | | } |
| 325 | | | |
| 326 | | (24) | public String unqualifyType (String type) |
| 327 | | | { |
| 328 | 0 | | return TypeMapping.unqualifyType(type); |
| 329 | | | } |
| 330 | | | |
| 331 | | | private void generateCmpBean (CreateTableStatement stmt) |
| 332 | | (25) | throws Exception |
| 333 | | | { |
| 334 | 0 | | if (! hasPrimaryKey(stmt)) |
| 335 | | | { |
| 336 | 0 | | logger.info("*** No PK Field available for " |
| 337 | | | + stmt.getTableName() + ", skipping bean creation"); |
| 338 | 0 | | return; |
| 339 | | | } |
| 340 | | | |
| 341 | 0 | | String baseName = stmt.getBeanName() + "Entity"; |
| 342 | 0 | (26) | if (baseName == null) |
| 343 | | | { |
| 344 | 0 | | baseName = sqlNameToJavaName(stmt.getTableName()); |
| 345 | | | } |
| 346 | 0 | | logger.info("*** Start creation of bean " + baseName); |
| 347 | | | |
| 348 | 0 | | final String valueInterface = mergeTemplate( |
| 349 | | | getVelocityContext(stmt, baseName), "GenerateValue.vtl"); |
| 350 | 0 | | final File valueIfOutputFile = new File(mOutputDirectory, |
| 351 | | | baseName + "Value.java"); |
| 352 | 0 | | writeFile(valueIfOutputFile, valueInterface); |
| 353 | | | |
| 354 | 0 | | final String valueImpl = mergeTemplate( |
| 355 | | | getVelocityContext(stmt, baseName), "GenerateValueImpl.vtl"); |
| 356 | 0 | | final File valueImplOutputFile = new File(mOutputDirectory, |
| 357 | | | baseName + "ValueImpl.java"); |
| 358 | 0 | | writeFile(valueImplOutputFile, valueImpl); |
| 359 | | | |
| 360 | 0 | | final String bean = mergeTemplate( |
| 361 | | | getVelocityContext(stmt, baseName), "GenerateBean.vtl"); |
| 362 | 0 | | final File beanOutputFile = new File(mOutputDirectory, |
| 363 | | | baseName + "Bean.java"); |
| 364 | 0 | | writeFile(beanOutputFile, bean); |
| 365 | | | |
| 366 | 0 | | if (checkIfHelperRequired(stmt)) |
| 367 | | | { |
| 368 | 0 | | final String helper = mergeTemplate( |
| 369 | | | getVelocityContext(stmt, baseName), "GenerateHelper.vtl"); |
| 370 | 0 | | final File helperOutputFile = new File(mOutputDirectory, |
| 371 | | | baseName + "TypeConverter.java"); |
| 372 | 0 | | writeFile(helperOutputFile, helper); |
| 373 | | | } |
| 374 | 0 | | } |
| 375 | | | |
| 376 | | | private String mergeTemplate (VelocityContext ctx, String templateFile) |
| 377 | | (27) | throws Exception |
| 378 | | | { |
| 379 | 0 | (28) | final StringWriter sw = new StringWriter(); |
| 380 | 0 | | final Template template = Velocity.getTemplate(templateFile); |
| 381 | 0 | | template.merge(ctx, sw); |
| 382 | 0 | | return sw.getBuffer().toString(); |
| 383 | | | } |
| 384 | | | |
| 385 | | | private void writeFile (File outputFile, final String data) |
| 386 | | | throws IOException |
| 387 | | | { |
| 388 | 0 | | if (outputFile.exists() && !mOverwrite) |
| 389 | | | { |
| 390 | 0 | | throw new RuntimeException( |
| 391 | | | "Output file " + outputFile + " already exists"); |
| 392 | | | } |
| 393 | 0 | | final FileWriter fout = new FileWriter(outputFile); |
| 394 | | | try |
| 395 | | | { |
| 396 | 0 | | fout.write(data); |
| 397 | | | } |
| 398 | | | finally |
| 399 | | | { |
| 400 | 0 | | IoUtil.close(fout); |
| 401 | 0 | | } |
| 402 | 0 | | logger.info("Wrote file " + outputFile + " successfully"); |
| 403 | 0 | | } |
| 404 | | | |
| 405 | | | |
| 406 | | | @param |
| 407 | | | @param |
| 408 | | | @return |
| 409 | | | @throws |
| 410 | | | |
| 411 | | | private VelocityContext getVelocityContext (CreateTableStatement stmt, |
| 412 | | | String baseName) |
| 413 | | (29) | throws Exception |
| 414 | | | { |
| 415 | 0 | | final Properties velocityProps = new Properties(); |
| 416 | 0 | | velocityProps.put(RuntimeConstants.RESOURCE_LOADER, "file"); |
| 417 | 0 | | velocityProps.put("file.resource.loader.class", |
| 418 | | | "org.apache.velocity.runtime.resource.loader.FileResourceLoader"); |
| 419 | 0 | | velocityProps.put(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, |
| 420 | | | mTemplateDir); |
| 421 | 0 | | velocityProps.put(RuntimeConstants.VM_LIBRARY, "macros.vm"); |
| 422 | | | |
| 423 | 0 | | velocityProps.put(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, |
| 424 | | | logger.isLoggable(Level.FINER) |
| 425 | | | ? "org.apache.velocity.runtime.log.SimpleLog4JLogSystem" |
| 426 | | | : "org.apache.velocity.runtime.log.NullLogSystem"); |
| 427 | 0 | | Velocity.init(velocityProps); |
| 428 | 0 | | final VelocityContext ctx = new VelocityContext(); |
| 429 | 0 | | ctx.put("stmt", stmt); |
| 430 | 0 | | ctx.put("baseName", baseName); |
| 431 | 0 | | ctx.put("package", mPackagePrefix); |
| 432 | 0 | | ctx.put("datasource", mDataSource); |
| 433 | 0 | | ctx.put("cmpgen", this); |
| 434 | 0 | | return ctx; |
| 435 | | | } |
| 436 | | | |
| 437 | | | |
| 438 | | | |
| 439 | | | @throws |
| 440 | | | |
| 441 | | | private void setUp () throws CmpGeneratorException |
| 442 | | | { |
| 443 | 0 | | File outputDir = new File(mOutputBaseDirectory); |
| 444 | 0 | | if (!outputDir.exists()) |
| 445 | | | { |
| 446 | 0 | | throw new CmpGeneratorException("Output directory does not exist"); |
| 447 | | | } |
| 448 | 0 | | if (!outputDir.isDirectory()) |
| 449 | | | { |
| 450 | 0 | | throw new CmpGeneratorException( |
| 451 | | | mOutputBaseDirectory + " is not a directory"); |
| 452 | | | } |
| 453 | | | |
| 454 | 0 | | final StringTokenizer tok = new StringTokenizer(mPackagePrefix, "."); |
| 455 | | | |
| 456 | 0 | | while (tok.hasMoreTokens()) |
| 457 | | | { |
| 458 | 0 | | outputDir = new File(outputDir, tok.nextToken()); |
| 459 | | | } |
| 460 | 0 | | logger.finer("Generating package subdirectories for " + outputDir); |
| 461 | 0 | (30) | outputDir.mkdirs(); |
| 462 | 0 | | mOutputDirectory = outputDir; |
| 463 | 0 | | } |
| 464 | | | |
| 465 | | | |
| 466 | | | private boolean hasPrimaryKey (CreateTableStatement statement) |
| 467 | | | { |
| 468 | 0 | | boolean hasPrimaryKey = false; |
| 469 | 0 | | for (final Iterator it = statement.getColumns().iterator(); |
| 470 | 0 | | it.hasNext(); ) |
| 471 | | | { |
| 472 | 0 | | final ColumnSpec column = (ColumnSpec) it.next(); |
| 473 | 0 | | if (column.isPrimaryKey()) |
| 474 | | | { |
| 475 | 0 | | hasPrimaryKey = true; |
| 476 | 0 | | break; |
| 477 | | | } |
| 478 | 0 | | } |
| 479 | 0 | | return hasPrimaryKey; |
| 480 | | | } |
| 481 | | | |
| 482 | | | |
| 483 | | | |
| 484 | | | |
| 485 | | | |
| 486 | | | |
| 487 | | | |
| 488 | | | @param |
| 489 | | | @return |
| 490 | | | |
| 491 | | | public boolean checkIfHelperRequired (CreateTableStatement statement) |
| 492 | | | { |
| 493 | 0 | | boolean needHelper = false; |
| 494 | | | |
| 495 | 0 | | for (final Iterator it = statement.getColumns().iterator(); |
| 496 | 0 | | it.hasNext(); ) |
| 497 | | | { |
| 498 | 0 | | final ColumnSpec column = (ColumnSpec) it.next(); |
| 499 | 0 | | if (column.getJavaType() != null) |
| 500 | | | { |
| 501 | 0 | | if (column.getStoreMethod() != null) |
| 502 | | | { |
| 503 | 0 | | needHelper = true; |
| 504 | 0 | | break; |
| 505 | | | } |
| 506 | | | } |
| 507 | 0 | | } |
| 508 | 0 | | return needHelper; |
| 509 | | | } |
| 510 | | | |
| 511 | | (31) | public String getVersion () |
| 512 | | | { |
| 513 | 0 | | return "$Revision: 1.9 $"; |
| 514 | | | } |
| 515 | | | |
| 516 | | (32) | public Set buildBeanImportList (CreateTableStatement statement) |
| 517 | | | throws CmpGeneratorException |
| 518 | | | { |
| 519 | 0 | | final Set beanImportList = new TreeSet(); |
| 520 | 0 | | for (final Iterator it = statement.getColumns().iterator(); |
| 521 | 0 | | it.hasNext(); ) |
| 522 | | | { |
| 523 | 0 | | final ColumnSpec column = (ColumnSpec) it.next(); |
| 524 | 0 | | final String javaType = TypeMapping.getJavaType(column, true); |
| 525 | 0 | | if (javaType != null |
| 526 | | | && !javaType.startsWith("java.lang") |
| 527 | | | && !TypeMapping.isPrimitiveType(javaType)) |
| 528 | | | { |
| 529 | 0 | | beanImportList.add(javaType); |
| 530 | | | } |
| 531 | 0 | | } |
| 532 | | | |
| 533 | 0 | | beanImportList.add("org.jcoderz.commons.types.Period"); |
| 534 | 0 | | beanImportList.add("javax.ejb.CreateException"); |
| 535 | 0 | | return beanImportList; |
| 536 | | | } |
| 537 | | | |
| 538 | | (33) | public Set buildHelperImportList (CreateTableStatement statement) |
| 539 | | | throws CmpGeneratorException |
| 540 | | | { |
| 541 | 0 | | final Set helperImportList = new TreeSet(); |
| 542 | 0 | | for (final Iterator it = statement.getColumns().iterator(); |
| 543 | 0 | | it.hasNext(); ) |
| 544 | | | { |
| 545 | 0 | | final ColumnSpec column = (ColumnSpec) it.next(); |
| 546 | 0 | | final String javaType = TypeMapping.getJavaType(column, true); |
| 547 | 0 | (34) | if (javaType != null |
| 548 | | | && !javaType.equals("java.sql.Date") |
| 549 | | | |
| 550 | | | |
| 551 | | | && !javaType.startsWith("java.lang") |
| 552 | | | && !TypeMapping.isPrimitiveType(javaType)) |
| 553 | | | { |
| 554 | 0 | | helperImportList.add(javaType); |
| 555 | | | } |
| 556 | 0 | | final String complexType = column.getJavaType(); |
| 557 | 0 | | if (complexType != null |
| 558 | | | && !complexType.startsWith("java.lang") |
| 559 | | | && !TypeMapping.isPrimitiveType(complexType)) |
| 560 | | | { |
| 561 | 0 | | helperImportList.add(complexType); |
| 562 | | | } |
| 563 | 0 | | } |
| 564 | | | |
| 565 | | | |
| 566 | 0 | | helperImportList.add("org.jcoderz.commons.InconsistentDatabaseException"); |
| 567 | 0 | | helperImportList.add("org.jcoderz.commons.types.Date"); |
| 568 | 0 | | helperImportList.add("org.jcoderz.commons.types.Period"); |
| 569 | 0 | | helperImportList.add("org.jcoderz.commons.util.Assert"); |
| 570 | | | |
| 571 | 0 | | return helperImportList; |
| 572 | | | } |
| 573 | | | |
| 574 | | | {@inheritDoc} |
| 575 | | | public String toString () |
| 576 | | | { |
| 577 | 0 | | return "[Phoenix CmpGenerator " + getVersion() + "]"; |
| 578 | | | } |
| 579 | | | |
| 580 | | (35) | public boolean isPrimitiveType (String type) |
| 581 | | | { |
| 582 | 0 | | return TypeMapping.isPrimitiveType(type); |
| 583 | | | } |
| 584 | | | } |