Java Code Examples for org.mybatis.generator.api.IntrospectedTable#getTableConfigurationProperty()

The following examples show how to use org.mybatis.generator.api.IntrospectedTable#getTableConfigurationProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IncrementsPlugin.java    From mybatis-generator-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
 * @param introspectedTable
 */
@Override
public void initialized(IntrospectedTable introspectedTable) {
    super.initialized(introspectedTable);
    this.incColumns = new ArrayList<>();
    this.incEnum = null;
    this.incEnumBuilder = null;

    String incrementsColumns = introspectedTable.getTableConfigurationProperty(IncrementsPlugin.PRO_INCREMENTS_COLUMNS);
    if (StringUtility.stringHasValue(incrementsColumns)) {
        // 切分
        String[] incrementsColumnsStrs = incrementsColumns.split(",");
        for (String incrementsColumnsStr : incrementsColumnsStrs) {
            IntrospectedColumn column = IntrospectedTableTools.safeGetColumn(introspectedTable, incrementsColumnsStr);
            if (column == null) {
                warnings.add("itfsw:插件" + IncrementsPlugin.class.getTypeName() + "插件没有找到column为" + incrementsColumnsStr.trim() + "的字段!");
            } else {
                incColumns.add(column);
            }
        }
    }
}
 
Example 2
Source File: IncrementPlugin.java    From mybatis-generator-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
 * @param introspectedTable
 */
@Override
public void initialized(IntrospectedTable introspectedTable) {
    super.initialized(introspectedTable);
    this.incColumns = new ArrayList<>();

    String incrementColumns = introspectedTable.getTableConfigurationProperty(PRO_INCREMENT_COLUMNS);
    if (StringUtility.stringHasValue(incrementColumns)) {
        // 切分
        String[] incrementsColumnsStrs = incrementColumns.split(",");
        for (String incrementsColumnsStr : incrementsColumnsStrs) {
            IntrospectedColumn column = IntrospectedTableTools.safeGetColumn(introspectedTable, incrementsColumnsStr);
            if (column == null) {
                warnings.add("itfsw:插件" + IncrementPlugin.class.getTypeName() + "插件没有找到column为" + incrementsColumnsStr.trim() + "的字段!");
            } else {
                incColumns.add(column);
            }
        }
    }
}
 
Example 3
Source File: TablePrefixPlugin.java    From mybatis-generator-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化阶段
 * 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
 * @param introspectedTable
 * @return
 */
@Override
public void initialized(IntrospectedTable introspectedTable) {
    // 1. 首先获取全局配置
    this.prefix = getProperties().getProperty(PRO_PREFIX);
    // 2. 获取每个table 具体的
    if (introspectedTable.getTableConfigurationProperty(PRO_PREFIX) != null) {
        this.prefix = introspectedTable.getTableConfigurationProperty(PRO_PREFIX);
    }
    // 3. 判断是否配置了前缀
    // !!! TableRenamePlugin 插件的 tableOverride 优先级最高
    if (this.prefix != null && introspectedTable.getTableConfigurationProperty(TableRenamePlugin.PRO_TABLE_OVERRIDE) == null) {
        String domainObjectName = introspectedTable.getFullyQualifiedTable().getDomainObjectName();
        domainObjectName = prefix + domainObjectName;
        try {
            IntrospectedTableTools.setDomainObjectName(introspectedTable, getContext(), domainObjectName);
        } catch (Exception e) {
            logger.error("itfsw:插件" + this.getClass().getTypeName() + "使用prefix替换时异常!", e);
        }
    }
    super.initialized(introspectedTable);
}
 
Example 4
Source File: CachePlugin.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
private void addAttributeIfExists(XmlElement element, IntrospectedTable introspectedTable,
        CacheProperty cacheProperty) {
    String property = introspectedTable.getTableConfigurationProperty(cacheProperty.getPropertyName());
    if (property == null) {
        property = properties.getProperty(cacheProperty.getPropertyName());
    }

    if (StringUtility.stringHasValue(property)) {
        element.addAttribute(new Attribute(cacheProperty.getAttributeName(), property));
    }
}
 
Example 5
Source File: SelectPageKeyPlugin.java    From hui-mybatis-generator-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * 判断参数generate.pagination.是否生成
 */
private boolean isGeneratePagination(IntrospectedTable introspectedTable) {
    String is_generate_pagination = introspectedTable.getTableConfigurationProperty(IS_GEN_PAGINATION);
    if (StringUtility.stringHasValue(is_generate_pagination)) {
        return Boolean.valueOf(is_generate_pagination);
    } else {
        return false;
    }
}
 
Example 6
Source File: OptimisticLockerPlugin.java    From mybatis-generator-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void initialized(IntrospectedTable introspectedTable) {
    super.initialized(introspectedTable);
    sqlMaps.put(introspectedTable, new ArrayList<>());

    // 读取并验证版本列
    String versionColumn = introspectedTable.getTableConfigurationProperty(PRO_VERSION_COLUMN);
    if (versionColumn != null) {
        this.versionColumn = introspectedTable.getColumn(versionColumn);
        if (this.versionColumn == null) {
            warnings.add("itfsw(乐观锁插件):表" + introspectedTable.getFullyQualifiedTable() + "配置的版本列(" + introspectedTable.getTableConfigurationProperty(PRO_VERSION_COLUMN) + ")没有找到!");
        }
    } else {
        this.versionColumn = null;
    }

    // 自定义nextVersion
    // 首先获取全局配置
    Properties properties = getProperties();
    String customizedNextVersion = properties.getProperty(PRO_CUSTOMIZED_NEXT_VERSION);
    // 获取表单独配置,如果有则覆盖全局配置
    if (introspectedTable.getTableConfigurationProperty(PRO_CUSTOMIZED_NEXT_VERSION) != null) {
        customizedNextVersion = introspectedTable.getTableConfigurationProperty(PRO_CUSTOMIZED_NEXT_VERSION);
    }
    if (StringUtility.stringHasValue(customizedNextVersion) && StringUtility.isTrue(customizedNextVersion)) {
        this.customizedNextVersion = true;
    } else {
        this.customizedNextVersion = false;
    }

    super.initialized(introspectedTable);
}
 
Example 7
Source File: CachePlugin.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
private void addAttributeIfExists(XmlElement element, IntrospectedTable introspectedTable,
        CacheProperty cacheProperty) {
    String property = introspectedTable.getTableConfigurationProperty(cacheProperty.getPropertyName());
    if (property == null) {
        property = properties.getProperty(cacheProperty.getPropertyName());
    }
    
    if (StringUtility.stringHasValue(property)) {
        element.addAttribute(new Attribute(cacheProperty.getAttributeName(), property));
    }
}
 
Example 8
Source File: CachePlugin.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
private void addAttributeIfExists(XmlElement element, IntrospectedTable introspectedTable,
        CacheProperty cacheProperty) {
    String property = introspectedTable.getTableConfigurationProperty(cacheProperty.getPropertyName());
    if (property == null) {
        property = properties.getProperty(cacheProperty.getPropertyName());
    }
    
    if (StringUtility.stringHasValue(property)) {
        element.addAttribute(new Attribute(cacheProperty.getAttributeName(), property));
    }
}
 
Example 9
Source File: DAOPlugin.java    From maven-archetype with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * contextGenerateAdditionalJavaFiles:. <br/>
 *
 * @author Hongbin Yuan
 * @param introspectedTable
 * @return
 * @see PluginAdapter#contextGenerateAdditionalJavaFiles(IntrospectedTable)
 */
@Override
public List<GeneratedJavaFile> contextGenerateAdditionalJavaFiles(
		IntrospectedTable introspectedTable) {
	CommentGenerator commentGenerator = context.getCommentGenerator();

	// 设置文件类型,DAO文件,java 接口文件
	String  javaMapperName = introspectedTable.getMyBatis3JavaMapperType();
	String typeNameProp = this.getProperties().getProperty("typeName");
	if(typeNameProp == null || "".equals(typeNameProp.trim())){
		typeNameProp = typeName;
	}
	javaMapperName = javaMapperName.replaceAll("Mapper$",typeNameProp);
	
       FullyQualifiedJavaType type = new FullyQualifiedJavaType(javaMapperName);
	Interface interfaze = new Interface(type);
       interfaze.setVisibility(JavaVisibility.PUBLIC);
       commentGenerator.addJavaFileComment(interfaze);

       String rootInterface = introspectedTable
           .getTableConfigurationProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
       if (!stringHasValue(rootInterface)) {
           rootInterface = context.getJavaClientGeneratorConfiguration()
               .getProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
       }

       if (stringHasValue(rootInterface)) {
           FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(
                   rootInterface);
           interfaze.addSuperInterface(fqjt);
           interfaze.addImportedType(fqjt);
       }
	
       GeneratedJavaFile gjf = new GeneratedJavaFile(interfaze,
		context.getJavaClientGeneratorConfiguration().getTargetProject(),
           context.getProperty(PropertyRegistry.CONTEXT_JAVA_FILE_ENCODING),
           context.getJavaFormatter());
       List<GeneratedJavaFile>  gifList = new ArrayList<GeneratedJavaFile>();
       
       gifList.add(gjf);
       
	return gifList;
}