org.mybatis.generator.config.ColumnRenamingRule Java Examples

The following examples show how to use org.mybatis.generator.config.ColumnRenamingRule. 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: MyBatisGeneratorConfigurationParser.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
private void parseColumnRenamingRule(TableConfiguration tc, Node node) {
    Properties attributes = parseAttributes(node);
    String searchString = attributes.getProperty("searchString");
    String replaceString = attributes.getProperty("replaceString");

    ColumnRenamingRule crr = new ColumnRenamingRule();

    crr.setSearchString(searchString);

    if (stringHasValue(replaceString)) {
        crr.setReplaceString(replaceString);
    }

    tc.setColumnRenamingRule(crr);
}
 
Example #2
Source File: TableRenameConfigurationPlugin.java    From mybatis-generator-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * column rename
 * @param columns
 * @param rule
 * @param tc
 */
private void renameColumns(List<IntrospectedColumn> columns, ColumnRenamingRule rule, TableConfiguration tc) {
    Pattern pattern = Pattern.compile(rule.getSearchString());
    String replaceString = rule.getReplaceString();
    replaceString = replaceString == null ? "" : replaceString;

    for (IntrospectedColumn introspectedColumn : columns) {
        String calculatedColumnName;
        if (pattern == null) {
            calculatedColumnName = introspectedColumn.getActualColumnName();
        } else {
            Matcher matcher = pattern.matcher(introspectedColumn.getActualColumnName());
            calculatedColumnName = matcher.replaceAll(replaceString);
        }

        if (isTrue(tc.getProperty(PropertyRegistry.TABLE_USE_ACTUAL_COLUMN_NAMES))) {
            introspectedColumn.setJavaProperty(getValidPropertyName(calculatedColumnName));
        } else if (isTrue(tc.getProperty(PropertyRegistry.TABLE_USE_COMPOUND_PROPERTY_NAMES))) {
            StringBuilder sb = new StringBuilder();
            sb.append(calculatedColumnName);
            sb.append('_');
            sb.append(getCamelCaseString(introspectedColumn.getRemarks(), true));
            introspectedColumn.setJavaProperty(getValidPropertyName(sb.toString()));
        } else {
            introspectedColumn.setJavaProperty(getCamelCaseString(calculatedColumnName, false));
        }
    }
}
 
Example #3
Source File: IbatorConfigurationParser.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
private void parseColumnRenamingRule(TableConfiguration tc, Node node) {
    Properties attributes = parseAttributes(node);
    String searchString = attributes.getProperty("searchString"); //$NON-NLS-1$
    String replaceString = attributes.getProperty("replaceString"); //$NON-NLS-1$

    ColumnRenamingRule crr = new ColumnRenamingRule();

    crr.setSearchString(searchString);

    if (stringHasValue(replaceString)) {
        crr.setReplaceString(replaceString);
    }

    tc.setColumnRenamingRule(crr);
}
 
Example #4
Source File: MyBatisGeneratorConfigurationParser.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
private void parseColumnRenamingRule(TableConfiguration tc, Node node) {
    Properties attributes = parseAttributes(node);
    String searchString = attributes.getProperty("searchString"); //$NON-NLS-1$
    String replaceString = attributes.getProperty("replaceString"); //$NON-NLS-1$

    ColumnRenamingRule crr = new ColumnRenamingRule();

    crr.setSearchString(searchString);

    if (stringHasValue(replaceString)) {
        crr.setReplaceString(replaceString);
    }

    tc.setColumnRenamingRule(crr);
}
 
Example #5
Source File: IbatorConfigurationParser.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
private void parseColumnRenamingRule(TableConfiguration tc, Node node) {
    Properties attributes = parseAttributes(node);
    String searchString = attributes.getProperty("searchString"); //$NON-NLS-1$
    String replaceString = attributes.getProperty("replaceString"); //$NON-NLS-1$

    ColumnRenamingRule crr = new ColumnRenamingRule();

    crr.setSearchString(searchString);

    if (stringHasValue(replaceString)) {
        crr.setReplaceString(replaceString);
    }

    tc.setColumnRenamingRule(crr);
}
 
Example #6
Source File: MyBatisGeneratorConfigurationParser.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
private void parseColumnRenamingRule(TableConfiguration tc, Node node) {
    Properties attributes = parseAttributes(node);
    String searchString = attributes.getProperty("searchString"); //$NON-NLS-1$
    String replaceString = attributes.getProperty("replaceString"); //$NON-NLS-1$

    ColumnRenamingRule crr = new ColumnRenamingRule();

    crr.setSearchString(searchString);

    if (stringHasValue(replaceString)) {
        crr.setReplaceString(replaceString);
    }

    tc.setColumnRenamingRule(crr);
}