Exemplo n.º 1
1
  protected void calculateJavaClientAttributes() {
    if (context.getJavaClientGeneratorConfiguration() == null) {
      return;
    }

    StringBuilder sb = new StringBuilder();
    sb.append(calculateJavaClientImplementationPackage());
    sb.append('.');
    sb.append(fullyQualifiedTable.getDomainObjectName());
    sb.append("DAOImpl"); // $NON-NLS-1$
    setDAOImplementationType(sb.toString());

    sb.setLength(0);
    sb.append(calculateJavaClientInterfacePackage());
    sb.append('.');
    sb.append(fullyQualifiedTable.getDomainObjectName());
    sb.append("DAO"); // $NON-NLS-1$
    setDAOInterfaceType(sb.toString());

    sb.setLength(0);
    sb.append(calculateJavaClientInterfacePackage());
    sb.append('.');
    sb.append(fullyQualifiedTable.getDomainObjectName());
    sb.append("Mapper"); // $NON-NLS-1$
    setMyBatis3JavaMapperType(sb.toString());

    sb.setLength(0);
    sb.append(calculateJavaClientInterfacePackage());
    sb.append('.');
    sb.append(fullyQualifiedTable.getDomainObjectName());
    sb.append("SqlProvider"); // $NON-NLS-1$
    setMyBatis3SqlProviderType(sb.toString());
  }
Exemplo n.º 2
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.mybatis.generator.api.PluginAdapter#setContext(org.mybatis.generator
  * .config.Context)
  */
 @Override
 public void setContext(Context context) {
   CommentGeneratorConfiguration cgc = new CommentGeneratorConfiguration();
   cgc.addProperty("suppressAllComments", "true");
   context.setCommentGeneratorConfiguration(cgc);
   // GeneratedXmlFile
   super.setContext(context);
 }
Exemplo n.º 3
0
  protected String calculateExtjsAppName() {
    ExtjsGeneratorConfiguration config = context.getExtjsGeneratorConfiguration();
    StringBuilder sb = new StringBuilder();
    if (null != config) {
      sb.append(config.getAppName());
    }

    return sb.toString();
  }
Exemplo n.º 4
0
  protected String calculateJavaModelPackage() {
    JavaModelGeneratorConfiguration config = context.getJavaModelGeneratorConfiguration();

    StringBuilder sb = new StringBuilder();
    sb.append(config.getTargetPackage());
    sb.append(fullyQualifiedTable.getSubPackage(isSubPackagesEnabled(config)));

    return sb.toString();
  }
Exemplo n.º 5
0
  protected String calculateIbatis2SqlMapPackage() {
    SqlMapGeneratorConfiguration config = context.getSqlMapGeneratorConfiguration();

    StringBuilder sb = new StringBuilder(config.getTargetPackage());
    if (StringUtility.isTrue(config.getProperty(PropertyRegistry.ANY_ENABLE_SUB_PACKAGES))) {
      sb.append(fullyQualifiedTable.getSubPackage());
    }
    return sb.toString();
  }
Exemplo n.º 6
0
  public boolean isImmutable() {
    Properties properties;

    if (tableConfiguration.getProperties().containsKey(PropertyRegistry.ANY_IMMUTABLE)) {
      properties = tableConfiguration.getProperties();
    } else {
      properties = context.getJavaModelGeneratorConfiguration().getProperties();
    }

    return isTrue(properties.getProperty(PropertyRegistry.ANY_IMMUTABLE));
  }
Exemplo n.º 7
0
  protected String calculateSqlMapPackage() {
    StringBuilder sb = new StringBuilder();
    SqlMapGeneratorConfiguration config = context.getSqlMapGeneratorConfiguration();

    // config can be null if the Java client does not require XML
    if (config != null) {
      sb.append(config.getTargetPackage());
      sb.append(fullyQualifiedTable.getSubPackage(isSubPackagesEnabled(config)));
    }

    return sb.toString();
  }
Exemplo n.º 8
0
  protected String calculateJavaClientInterfacePackage() {
    JavaClientGeneratorConfiguration config = context.getJavaClientGeneratorConfiguration();
    if (config == null) {
      return null;
    }

    StringBuilder sb = new StringBuilder();
    sb.append(config.getTargetPackage());

    sb.append(fullyQualifiedTable.getSubPackage(isSubPackagesEnabled(config)));

    return sb.toString();
  }
Exemplo n.º 9
0
  protected String calculateJavaClientInterfacePackage() {
    JavaClientGeneratorConfiguration config = context.getJavaClientGeneratorConfiguration();
    if (config == null) {
      return null;
    }

    StringBuilder sb = new StringBuilder();
    sb.append(config.getTargetPackage());
    if (StringUtility.isTrue(config.getProperty(PropertyRegistry.ANY_ENABLE_SUB_PACKAGES))) {
      sb.append(fullyQualifiedTable.getSubPackage());
    }

    return sb.toString();
  }
Exemplo n.º 10
0
  public boolean isConstructorBased() {
    if (isImmutable()) {
      return true;
    }

    Properties properties;

    if (tableConfiguration.getProperties().containsKey(PropertyRegistry.ANY_CONSTRUCTOR_BASED)) {
      properties = tableConfiguration.getProperties();
    } else {
      properties = context.getJavaModelGeneratorConfiguration().getProperties();
    }

    return isTrue(properties.getProperty(PropertyRegistry.ANY_CONSTRUCTOR_BASED));
  }
Exemplo n.º 11
0
  public void initialize() {
    calculateJavaClientAttributes();
    calculateModelAttributes();
    calculateXmlAttributes();

    if (tableConfiguration.getModelType() == ModelType.HIERARCHICAL) {
      rules = new HierarchicalModelRules(this);
    } else if (tableConfiguration.getModelType() == ModelType.FLAT) {
      rules = new FlatModelRules(this);
    } else {
      rules = new ConditionalModelRules(this);
    }

    context.getPlugins().initialized(this);
  }