Package org.apache.velocity

Examples of org.apache.velocity.VelocityContext


        catch (EngineException ee)
        {
            throw new BuildException(ee);
        }

        context = new VelocityContext();

        // Place our set of data models into the context along
        // with the names of the databases as a convenience for now.
        context.put("dataModels", dataModels);
        context.put("databaseNames", databaseNames);
View Full Code Here


    this.viewDir = FileUtils.getFileFromPackage(targetDir, config.getViewPackageName());
  }

  private File createDatabaseClass(DBDatabase db) {
    File file = new File(baseDir, config.getDbClassName() + ".java");
    VelocityContext context = new VelocityContext();
    // TODO fall back to getPackageName() is the other names are not set
    context.put("parser", writerService);
    context.put("tableClassSuffix", config.getTableClassSuffix());
    context.put("basePackageName", config.getPackageName());
    context.put("dbClassName", config.getDbClassName());
    context.put("tablePackageName", config.getTablePackageName());
    context.put("viewPackageName", config.getViewPackageName());
    context.put("database", db);
    context.put("nestTables", config.isNestTables());
    context.put("baseTableClassName", config.getTableBaseName());
    context.put("nestViews", config.isNestViews());
    context.put("templateFolder", config.getTemplateFolder());
    context.put("baseViewClassName", config.getViewBaseName());
    context.put("preserveRelationNames", config.isPreserveRelationNames());

    writeFile(file, DATABASE_TEMPLATE, context);
    return file;
  }
View Full Code Here

    return file;
  }

  private File createBaseTableClass(DBDatabase db) {
    File file = new File(tableDir, config.getTableBaseName() + ".java");
    VelocityContext context = new VelocityContext();
    context.put("tablePackageName", config.getTablePackageName());
    context.put("baseTableClassName", config.getTableBaseName());
    writeFile(file, BASE_TABLE_TEMPLATE, context);
    return file;
  }
View Full Code Here

  }

  private File createTableClass(DBDatabase db, DBTable table) {
    File file = new File(tableDir, writerService.getTableClassName(table.getName())
        + ".java");
    VelocityContext context = new VelocityContext();
    context.put("parser", writerService);
    context.put("basePackageName", config.getPackageName());
    context.put("tablePackageName", config.getTablePackageName());
    context.put("baseTableClassName", config.getTableBaseName());
    context.put("dbClassName", config.getDbClassName());
    context.put("nestTables", config.isNestTables());
    context.put("table", table);
    writeFile(file, TABLE_TEMPLATE, context);
    return file;
  }
View Full Code Here

    return file;
  }
 
  private File createBaseViewClass(DBDatabase db) {
    File file = new File(viewDir, config.getViewBaseName() + ".java");
    VelocityContext context = new VelocityContext();
    context.put("viewPackageName", config.getViewPackageName());
    context.put("baseViewClassName", config.getViewBaseName());
    writeFile(file, BASE_VIEW_TEMPLATE, context);
    return file;
  }
View Full Code Here

  }

  private File createViewClass(DBDatabase db, DBView view) {
    File file = new File(viewDir, writerService.getViewClassName(view.getName())
        + ".java");
    VelocityContext context = new VelocityContext();
    context.put("parser", writerService);
    context.put("basePackageName", config.getPackageName());
    context.put("viewPackageName", config.getViewPackageName());
    context.put("baseViewClassName", config.getViewBaseName());
    context.put("dbClassName", config.getDbClassName());
    context.put("nestViews", config.isNestViews());
    context.put("view", view);
    writeFile(file, VIEW_TEMPLATE, context);
    return file;
  }
View Full Code Here

    return file;
  }

  private File createBaseRecordClass(DBDatabase db) {
    File file = new File(recordDir, config.getRecordBaseName() + ".java");
    VelocityContext context = new VelocityContext();
    context.put("baseRecordClassName", config.getRecordBaseName());
    context.put("basePackageName", config.getPackageName());
    context.put("tablePackageName", config.getTablePackageName());
    context.put("recordPackageName", config.getRecordPackageName());
    context.put("baseTableClassName", config.getTableBaseName());
    writeFile(file, BASE_RECORD_TEMPLATE, context);
    return file;
  }
View Full Code Here

    return file;
  }

  private File createRecordClass(DBDatabase db, DBTable table) {
    File file = new File(recordDir, writerService.getRecordClassName(table.getName()) + ".java");
    VelocityContext context = new VelocityContext();
    context.put("parser", writerService);
    context.put("basePackageName", config.getPackageName());
    // If the tables shall be nested within the database classe, their include path for the records needs to be changed
    if (config.isNestTables())
      context.put("tablePackageName", config.getPackageName() + "." + config.getDbClassName());
    else
      context.put("tablePackageName", config.getTablePackageName());
    context.put("recordPackageName", config.getRecordPackageName());
    context.put("baseRecordClassName", config.getRecordBaseName());
    context.put("dbClassName", config.getDbClassName());
    context
        .put("createRecordProperties", config
            .isCreateRecordProperties());

    context.put("table", table);
    writeFile(file, RECORD_TEMPLATE, context);
    return file;
  }
View Full Code Here

      File thisOutputDirectory,
      File thisDoNotReplaceDirectory, String[] excludes,
      String packageDirectory, String key, String value) throws MojoExecutionException {
    String outputName = templateName.replaceFirst("\\.java\\.t$",
        ".java");
    Context vc = new VelocityContext();
    if (key != null) {
      String keyCap = key.toUpperCase().charAt(0) + key.substring(1);
      outputName = outputName.replaceAll("KeyType", keyCap);
      vc.put("keyType", key);
      vc.put("keyTypeCap", keyCap);
      vc.put("keyObjectType", typeToObjectTypeMap.get(key));
      boolean floating = "float".equals(key) || "double".equals(key);
      vc.put("keyTypeFloating", floating ? "true" : "false");
    }
    if (value != null) {
      String valueCap = value.toUpperCase().charAt(0) + value.substring(1);
      outputName = outputName.replaceAll("ValueType", valueCap);
      vc.put("valueType", value);
      vc.put("valueTypeCap", valueCap);
      vc.put("valueObjectType", typeToObjectTypeMap.get(value));
      boolean floating = "float".equals(value) || "double".equals(value);
      vc.put("valueTypeFloating", floating ? "true" : "false");

    }
    File outputFile = new File(thisOutputDirectory, outputName);
    if (thisDoNotReplaceDirectory != null) {
      File dnrf = new File(thisDoNotReplaceDirectory, outputName);
View Full Code Here

      File thisOutputDirectory,
      File thisDoNotReplaceDirectory, String[] excludes,
      String packageDirectory, String key, String value) throws MojoExecutionException {
    String outputName = templateName.replaceFirst("\\.java\\.t$",
        ".java");
    Context vc = new VelocityContext();
    if (key != null) {
      String keyCap = key.toUpperCase().charAt(0) + key.substring(1);
      outputName = outputName.replaceAll("KeyType", keyCap);
      vc.put("keyType", key);
      vc.put("keyTypeCap", keyCap);
      vc.put("keyObjectType", typeToObjectTypeMap.get(key));
      boolean floating = "float".equals(key) || "double".equals(key);
      vc.put("keyTypeFloating", floating ? "true" : "false");
    }
    if (value != null) {
      String valueCap = value.toUpperCase().charAt(0) + value.substring(1);
      outputName = outputName.replaceAll("ValueType", valueCap);
      vc.put("valueType", value);
      vc.put("valueTypeCap", valueCap);
      vc.put("valueObjectType", typeToObjectTypeMap.get(value));
      boolean floating = "float".equals(value) || "double".equals(value);
      vc.put("valueTypeFloating", floating ? "true" : "false");

    }
    File outputFile = new File(thisOutputDirectory, outputName);
    if (thisDoNotReplaceDirectory != null) {
      File dnrf = new File(thisDoNotReplaceDirectory, outputName);
View Full Code Here

TOP

Related Classes of org.apache.velocity.VelocityContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.