public static void createOrDropTable(CgFormHeadEntity table, Session session)
     throws IOException, TemplateException, HibernateException, SQLException, DBException {
   Template t;
   t =
       getConfig("/org/jeecgframework/web/cgform/engine/hibernate")
           .getTemplate("tableTemplate.ftl");
   Writer out = new StringWriter();
   // 模板对于数字超过1000,会自动格式为1,,000(禁止转换)
   t.setNumberFormat("0.#####################");
   t.process(getRootMap(table, DbTableUtil.getDataType(session)), out);
   String xml = out.toString();
   logger.info(xml);
   createTable(xml, table, session);
 }
Ejemplo n.º 2
0
  /**
   * Sets the settings of the {@link Template} which are not yet set in the {@link Template} and are
   * set in this {@link TemplateConfigurer}, leaves the other settings as is. A setting is said to
   * be set in a {@link TemplateConfigurer} or {@link Template} if it was explicitly set via a
   * setter method on that object, as opposed to be inherited from the {@link Configuration}.
   *
   * <p>Note that the {@code encoding} setting of the {@link Template} counts as unset if it's
   * {@code null}, even if {@code null} was set via {@link Template#setEncoding(String)}.
   *
   * @throws IllegalStateException If the parent configuration wasn't yet set.
   */
  public void configure(Template template) {
    checkParentConfigurationSet();
    Configuration cfg = getParentConfiguration();
    if (template.getConfiguration() != cfg) {
      // This is actually not a problem right now, but for future BC we enforce this.
      throw new IllegalArgumentException(
          "The argument Template doesn't belong to the same Configuration as the TemplateConfigurer");
    }

    if (isAPIBuiltinEnabledSet() && !template.isAPIBuiltinEnabledSet()) {
      template.setAPIBuiltinEnabled(isAPIBuiltinEnabled());
    }
    if (isArithmeticEngineSet() && !template.isArithmeticEngineSet()) {
      template.setArithmeticEngine(getArithmeticEngine());
    }
    if (isAutoFlushSet() && !template.isAutoFlushSet()) {
      template.setAutoFlush(getAutoFlush());
    }
    if (isBooleanFormatSet() && !template.isBooleanFormatSet()) {
      template.setBooleanFormat(getBooleanFormat());
    }
    if (isClassicCompatibleSet() && !template.isClassicCompatibleSet()) {
      template.setClassicCompatibleAsInt(getClassicCompatibleAsInt());
    }
    if (isDateFormatSet() && !template.isDateFormatSet()) {
      template.setDateFormat(getDateFormat());
    }
    if (isDateTimeFormatSet() && !template.isDateTimeFormatSet()) {
      template.setDateTimeFormat(getDateTimeFormat());
    }
    if (isEncodingSet() && template.getEncoding() == null) {
      template.setEncoding(getEncoding());
    }
    if (isLocaleSet() && !template.isLocaleSet()) {
      template.setLocale(getLocale());
    }
    if (isLogTemplateExceptionsSet() && !template.isLogTemplateExceptionsSet()) {
      template.setLogTemplateExceptions(getLogTemplateExceptions());
    }
    if (isNewBuiltinClassResolverSet() && !template.isNewBuiltinClassResolverSet()) {
      template.setNewBuiltinClassResolver(getNewBuiltinClassResolver());
    }
    if (isNumberFormatSet() && !template.isNumberFormatSet()) {
      template.setNumberFormat(getNumberFormat());
    }
    if (isObjectWrapperSet() && !template.isObjectWrapperSet()) {
      template.setObjectWrapper(getObjectWrapper());
    }
    if (isOutputEncodingSet() && !template.isOutputEncodingSet()) {
      template.setOutputEncoding(getOutputEncoding());
    }
    if (isShowErrorTipsSet() && !template.isShowErrorTipsSet()) {
      template.setShowErrorTips(getShowErrorTips());
    }
    if (isSQLDateAndTimeTimeZoneSet() && !template.isSQLDateAndTimeTimeZoneSet()) {
      template.setSQLDateAndTimeTimeZone(getSQLDateAndTimeTimeZone());
    }
    if (isTemplateExceptionHandlerSet() && !template.isTemplateExceptionHandlerSet()) {
      template.setTemplateExceptionHandler(getTemplateExceptionHandler());
    }
    if (isTimeFormatSet() && !template.isTimeFormatSet()) {
      template.setTimeFormat(getTimeFormat());
    }
    if (isTimeZoneSet() && !template.isTimeZoneSet()) {
      template.setTimeZone(getTimeZone());
    }
    if (isURLEscapingCharsetSet() && !template.isURLEscapingCharsetSet()) {
      template.setURLEscapingCharset(getURLEscapingCharset());
    }

    copyDirectCustomAttributes(template, false);
  }