org.mybatis.generator.api.dom.xml.XmlElement Java Examples

The following examples show how to use org.mybatis.generator.api.dom.xml.XmlElement. 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: SelectiveEnhancedPlugin.java    From mybatis-generator-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * updateByExampleSelective
 * 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
 * @param element
 * @param introspectedTable
 * @return
 */
@Override
public boolean sqlMapUpdateByExampleSelectiveElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
    // 清空
    XmlElement answer = new XmlElement("update");
    answer.addAttribute(new Attribute("id", introspectedTable.getUpdateByExampleSelectiveStatementId()));
    answer.addAttribute(new Attribute("parameterType", "map"));

    commentGenerator.addComment(answer);

    StringBuilder sb = new StringBuilder();
    sb.append("update ");
    sb.append(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));

    // selective
    answer.addElement(new TextElement("SET"));
    answer.addElement(this.generateSetsSelective(ListUtilities.removeGeneratedAlwaysColumns(introspectedTable.getAllColumns())));

    answer.addElement(XmlElementGeneratorTools.getUpdateByExampleIncludeElement(introspectedTable));

    XmlElementTools.replaceXmlElement(element, answer);

    return super.sqlMapUpdateByExampleSelectiveElementGenerated(element, introspectedTable);
}
 
Example #2
Source File: SelectiveEnhancedPlugin.java    From mybatis-generator-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * upsertSelective xml
 * @param element
 * @param columns
 * @param insertColumnsEle
 * @param insertValuesEle
 * @param setsEle
 * @param introspectedTable
 * @return
 */
@Override
public boolean sqlMapUpsertSelectiveElementGenerated(XmlElement element, List<IntrospectedColumn> columns, XmlElement insertColumnsEle, XmlElement insertValuesEle, XmlElement setsEle, IntrospectedTable introspectedTable) {
    // parameterType
    XmlElementTools.replaceAttribute(element, new Attribute("parameterType", "map"));
    // mybatis 3.5.0 之后对keyProperty处理有变更
    element.getAttributes().removeIf(attribute -> {
        String name = attribute.getName();
        return name.equals("useGeneratedKeys") || name.equals("keyProperty") || name.equals("keyColumn");
    });
    XmlElementGeneratorTools.useGeneratedKeys(element, introspectedTable, "record.");


    // 替换insert column
    XmlElementTools.replaceXmlElement(insertColumnsEle, this.generateInsertColumnSelective(columns));

    // 替换insert values
    XmlElementTools.replaceXmlElement(insertValuesEle, this.generateInsertValuesSelective(columns));

    // 替换update set
    XmlElementTools.replaceXmlElement(setsEle, this.generateSetsSelective(columns));

    return true;
}
 
Example #3
Source File: LimitPlugin.java    From mybatis-generator-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * 生成limit节点
 * @param element
 */
private void generateLimitElementWithExample(XmlElement element) {
    XmlElement ifLimitNotNullElement = new XmlElement("if");
    ifLimitNotNullElement.addAttribute(new Attribute("test", "example != null and example.rows != null"));

    XmlElement ifOffsetNotNullElement = new XmlElement("if");
    ifOffsetNotNullElement.addAttribute(new Attribute("test", "example.offset != null"));
    ifOffsetNotNullElement.addElement(new TextElement("limit ${example.offset}, ${example.rows}"));
    ifLimitNotNullElement.addElement(ifOffsetNotNullElement);

    XmlElement ifOffsetNullElement = new XmlElement("if");
    ifOffsetNullElement.addAttribute(new Attribute("test", "example.offset == null"));
    ifOffsetNullElement.addElement(new TextElement("limit ${example.rows}"));
    ifLimitNotNullElement.addElement(ifOffsetNullElement);

    element.addElement(ifLimitNotNullElement);
}
 
Example #4
Source File: DeleteByExampleElementGenerator.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
@Override
public void addElements(XmlElement parentElement) {
    XmlElement answer = new XmlElement("delete");

    String fqjt = introspectedTable.getExampleType();

    answer.addAttribute(new Attribute(
            "id", introspectedTable.getDeleteByExampleStatementId()));
    answer.addAttribute(new Attribute("parameterType", fqjt));

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();
    sb.append("delete from ");
    sb.append(introspectedTable
            .getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));
    answer.addElement(getExampleIncludeElement());

    if (context.getPlugins().sqlMapDeleteByExampleElementGenerated(
            answer, introspectedTable)) {
        parentElement.addElement(answer);
    }
}
 
Example #5
Source File: AbstractXmbgPlugin.java    From dolphin with Apache License 2.0 6 votes vote down vote up
protected void generateWhereConditions(String fieldPrefix, String columnPrefix, boolean ifNullCheck, List<IntrospectedColumn> columns, XmlElement parent) {
  XmlElement trimElement = new XmlElement("trim");
  trimElement.addAttribute(new Attribute("suffixOverrides", ","));

  StringBuilder sb = new StringBuilder();
  for (IntrospectedColumn introspectedColumn : columns) {
    sb.setLength(0);
    sb.append((columnPrefix == null ? "" : columnPrefix) + MyBatis3FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn));
    sb.append(" = ");
    sb.append(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, fieldPrefix));
    sb.append(",");

    doIfNullCheck(fieldPrefix, ifNullCheck, trimElement, sb, introspectedColumn);
  }

  XmlElement where = new XmlElement("where");
  where.addElement(trimElement);
  parent.addElement(where);
}
 
Example #6
Source File: CountByExampleElementGenerator.java    From mybatis-generator-plus with Apache License 2.0 6 votes vote down vote up
@Override
public void addElements(XmlElement parentElement) {
    XmlElement answer = new XmlElement("select"); //$NON-NLS-1$

    String fqjt = introspectedTable.getExampleType();

    answer.addAttribute(new Attribute(
            "id", introspectedTable.getCountByExampleStatementId())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("parameterType", fqjt)); //$NON-NLS-1$
    answer.addAttribute(new Attribute("resultType", "java.lang.Integer")); //$NON-NLS-1$ //$NON-NLS-2$

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();
    sb.append("select count(*) from "); //$NON-NLS-1$
    sb.append(introspectedTable
            .getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));
    answer.addElement(getExampleIncludeElement());

    if (context.getPlugins().sqlMapCountByExampleElementGenerated(
            answer, introspectedTable)) {
        parentElement.addElement(answer);
    }
}
 
Example #7
Source File: AbstractXmbgPlugin.java    From dolphin with Apache License 2.0 6 votes vote down vote up
protected void generateParameterForSet(String fieldPrefix, boolean ifNullCheck, List<IntrospectedColumn> columns, XmlElement dynamicElement) {
  XmlElement trimElement = new XmlElement("trim");
  trimElement.addAttribute(new Attribute("suffixOverrides", ","));

  StringBuilder sb = new StringBuilder();
  for (IntrospectedColumn introspectedColumn : columns) {
    sb.setLength(0);
    sb.append(MyBatis3FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn));
    sb.append(" = ");
    sb.append(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, fieldPrefix));
    sb.append(',');

    doIfNullCheck(fieldPrefix, ifNullCheck, trimElement, sb, introspectedColumn);
  }

  dynamicElement.addElement(trimElement);
}
 
Example #8
Source File: SqlMapGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
protected XmlElement getSqlMapElement() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.12", table.toString())); //$NON-NLS-1$
    XmlElement answer = new XmlElement("sqlMap"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$
            introspectedTable.getIbatis2SqlMapNamespace()));

    context.getCommentGenerator().addRootComment(answer);

    addResultMapWithoutBLOBsElement(answer);
    addResultMapWithBLOBsElement(answer);
    addExampleWhereClauseElement(answer);
    addBaseColumnListElement(answer);
    addBlobColumnListElement(answer);
    addSelectByExampleWithBLOBsElement(answer);
    addSelectByExampleWithoutBLOBsElement(answer);
    addSelectByPrimaryKeyElement(answer);
    addDeleteByPrimaryKeyElement(answer);
    addDeleteByExampleElement(answer);
    addInsertElement(answer);
    addInsertSelectiveElement(answer);
    addCountByExampleElement(answer);
    addUpdateByExampleSelectiveElement(answer);
    addUpdateByExampleWithBLOBsElement(answer);
    addUpdateByExampleWithoutBLOBsElement(answer);
    addUpdateByPrimaryKeySelectiveElement(answer);
    addUpdateByPrimaryKeyWithBLOBsElement(answer);
    addUpdateByPrimaryKeyWithoutBLOBsElement(answer);

    return answer;
}
 
Example #9
Source File: AbstractXmlElementGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
protected XmlElement getBaseColumnListElement() {
    XmlElement answer = new XmlElement("include"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("refid", //$NON-NLS-1$
            introspectedTable.getIbatis2SqlMapNamespace()
                    + "." + introspectedTable.getBaseColumnListId())); //$NON-NLS-1$
    return answer;
}
 
Example #10
Source File: SqlMapGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
protected void addUpdateByPrimaryKeyWithBLOBsElement(
        XmlElement parentElement) {
    if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithBLOBs()) {
        AbstractXmlElementGenerator elementGenerator = new UpdateByPrimaryKeyWithBLOBsElementGenerator();
        initializeAndExecuteGenerator(elementGenerator, parentElement);
    }
}
 
Example #11
Source File: RenameExampleClassAndMethodsPluginTest.java    From mybatis-generator-plugins with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void shouldRemoveIdColumnsFromUpdateStatements() throws Exception {
	RenameExampleClassAndMethodsPlugin plugin = spy(this.plugin);

	IntrospectedColumn column = new IntrospectedColumn();
	column.setActualColumnName("actual_name");
	column.setJavaProperty("someProperty");
	column.setJdbcTypeName("DOUBLE");

	List<IntrospectedColumn> columns = new ArrayList<>();
	columns.add(column);

	// Given
	willDoNothing().given(plugin).removeIdColumns(anyListOf(String.class), any(Element.class),
			any(XmlElement.class), anyInt());
	given(introspectedTable.getPrimaryKeyColumns()).willReturn(columns);
	given(tableConfiguration.getAlias()).willReturn("alias");

	// When
	plugin.removeIdColumns(introspectedTable, element);

	// Then
	ArgumentCaptor<List> updatesCaptor = ArgumentCaptor.forClass(List.class);

	verify(plugin, times(1)).removeIdColumns(updatesCaptor.capture(), eq(element),
			isNull(XmlElement.class), eq(-1));

	List<String> updates = updatesCaptor.getValue();
	assertThat(updates).hasSameSizeAs(columns);
	String update = updates.get(0);
	assertThat(update).isEqualTo("alias.actual_name = #{record.someProperty,jdbcType=DOUBLE},");
}
 
Example #12
Source File: RowBoundsPlugin.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
@Override
public boolean sqlMapSelectByExampleWithoutBLOBsElementGenerated(
        XmlElement element, IntrospectedTable introspectedTable) {
    if (introspectedTable.getTargetRuntime() == TargetRuntime.MYBATIS3) {
        copyAndSaveElement(element, introspectedTable.getFullyQualifiedTable());
    }
    return true;
}
 
Example #13
Source File: PluginAggregator.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
public boolean sqlMapCountByExampleElementGenerated(XmlElement element,
        IntrospectedTable table) {
    boolean rc = true;

    for (Plugin plugin : plugins) {
        if (!plugin.sqlMapCountByExampleElementGenerated(element, table)) {
            rc = false;
            break;
        }
    }

    return rc;
}
 
Example #14
Source File: XMLMapperGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
protected XmlElement getSqlMapElement() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.12", table.toString())); //$NON-NLS-1$
    XmlElement answer = new XmlElement("mapper"); //$NON-NLS-1$
    String namespace = introspectedTable.getMyBatis3SqlMapNamespace();
    answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$
            namespace));

    context.getCommentGenerator().addRootComment(answer);

    addResultMapWithoutBLOBsElement(answer);
    addResultMapWithBLOBsElement(answer);
    addExampleWhereClauseElement(answer);
    addMyBatis3UpdateByExampleWhereClauseElement(answer);
    addBaseColumnListElement(answer);
    addBlobColumnListElement(answer);
    addSelectByExampleWithBLOBsElement(answer);
    addSelectByExampleWithoutBLOBsElement(answer);
    addSelectByPrimaryKeyElement(answer);
    addDeleteByPrimaryKeyElement(answer);
    addDeleteByExampleElement(answer);
    addInsertElement(answer);
    addInsertSelectiveElement(answer);
    addCountByExampleElement(answer);
    addUpdateByExampleSelectiveElement(answer);
    addUpdateByExampleWithBLOBsElement(answer);
    addUpdateByExampleWithoutBLOBsElement(answer);
    addUpdateByPrimaryKeySelectiveElement(answer);
    addUpdateByPrimaryKeyWithBLOBsElement(answer);
    addUpdateByPrimaryKeyWithoutBLOBsElement(answer);

    return answer;
}
 
Example #15
Source File: MysqlPaginationPlugin.java    From server-boilerplate with MIT License 5 votes vote down vote up
@Override
public boolean sqlMapSelectByExampleWithBLOBsElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
    XmlElement isNotNullElement = new XmlElement("if");
    isNotNullElement.addAttribute(new Attribute("test", "limitStart != null and limitStart>=0"));
    isNotNullElement.addElement(new TextElement(
            "limit #{limitStart} , #{limitEnd}"));
    element.addElement(isNotNullElement);
    return super.sqlMapSelectByExampleWithBLOBsElementGenerated(element,
            introspectedTable);
}
 
Example #16
Source File: AliasResultMapWithoutBLOBsElementGenerator.java    From maven-archetype with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * addElements: 在当前的parentElement元素中添加别名ReulstMap列元素. <br/>
 *
 * @author Hongbin Yuan			父元素,新的elements将作为子元素添加到该元素
 * @param parentElement
 * @param introspectedTable		当前表的信息
 * @since JDK 1.6
 */
public void addElements(XmlElement parentElement,IntrospectedTable introspectedTable) {
	XmlElement answer = new XmlElement("resultMap"); //$NON-NLS-1$
	
	introspectedTable.getContext().getCommentGenerator().addComment(answer);
	
	answer.addAttribute(new Attribute("id", resultMapId));
	String returnType = null;
	if (isSimple) {
		returnType = introspectedTable.getBaseRecordType();
	} else {
		if (introspectedTable.getRules().generateBaseRecordClass()) {
			returnType = introspectedTable.getBaseRecordType();
		} else {
			returnType = introspectedTable.getPrimaryKeyType();
		}
	}
	answer.addAttribute(new Attribute("type", //$NON-NLS-1$
			returnType));

	if (introspectedTable.isConstructorBased()) {
		addResultMapConstructorElements(answer,introspectedTable);
	} else {
		addResultMapElements(answer,introspectedTable);
	}
	
	parentElement.addElement(answer);
}
 
Example #17
Source File: IgnoredColumn.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
/**
 * To xml element.
 *
 * @return the xml element
 */
public XmlElement toXmlElement() {
    XmlElement xmlElement = new XmlElement("ignoreColumn"); //$NON-NLS-1$
    xmlElement.addAttribute(new Attribute("column", columnName)); //$NON-NLS-1$

    if (stringHasValue(configuredDelimitedColumnName)) {
        xmlElement.addAttribute(new Attribute(
                "delimitedColumnName", configuredDelimitedColumnName)); //$NON-NLS-1$
    }

    return xmlElement;
}
 
Example #18
Source File: RowBoundsPlugin.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
public boolean sqlMapSelectByExampleWithoutBLOBsElementGenerated(
        XmlElement element, IntrospectedTable introspectedTable) {
    if (introspectedTable.getTargetRuntime() == TargetRuntime.MYBATIS3) {
        copyAndSaveElement(element, introspectedTable.getFullyQualifiedTable());
    }
    return true;
}
 
Example #19
Source File: SimpleXMLMapperGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
protected void addResultMapElement(XmlElement parentElement) {
    if (introspectedTable.getRules().generateBaseResultMap()) {
        AbstractXmlElementGenerator elementGenerator = new ResultMapWithoutBLOBsElementGenerator(
                true);
        initializeAndExecuteGenerator(elementGenerator, parentElement);
    }
}
 
Example #20
Source File: AbstractXmbgPlugin.java    From dolphin with Apache License 2.0 5 votes vote down vote up
protected XmlElement wrapIfNullCheckForJavaProperty(String fieldPrefix, Element content, IntrospectedColumn introspectedColumn) {
  StringBuilder sb = new StringBuilder();
  XmlElement isNotNullElement = new XmlElement("if");
  sb.setLength(0);
  sb.append(introspectedColumn.getJavaProperty(fieldPrefix));
  sb.append(" != null");
  isNotNullElement.addAttribute(new Attribute("test", sb.toString()));
  isNotNullElement.addElement(content);
  return isNotNullElement;
}
 
Example #21
Source File: PluginConfiguration.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
public XmlElement toXmlElement() {
    XmlElement answer = new XmlElement("plugin"); //$NON-NLS-1$
    if (getConfigurationType() != null) {
        answer.addAttribute(new Attribute("type", getConfigurationType())); //$NON-NLS-1$
    }

    addPropertyXmlElements(answer);

    return answer;
}
 
Example #22
Source File: PluginAggregator.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
public boolean sqlMapSelectByExampleWithoutBLOBsElementGenerated(
        XmlElement element, IntrospectedTable introspectedTable) {
    boolean rc = true;

    for (Plugin plugin : plugins) {
        if (!plugin.sqlMapSelectByExampleWithoutBLOBsElementGenerated(
                element, introspectedTable)) {
            rc = false;
            break;
        }
    }

    return rc;
}
 
Example #23
Source File: CreateSubPackagePlugin.java    From mybatis-generator-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Rename the element attribute.
 *
 * @param element
 *            the element
 * @param attributeName
 *            the attribute name
 * @return true
 */
boolean renameElementAttribute(XmlElement element, String attributeName) {
	for (int i = 0; i < element.getAttributes().size(); i++) {
		Attribute attribute = element.getAttributes().get(i);
		if (attributeName.equals(attribute.getName())) {
			element.getAttributes().set(i, modelProperties.renameAttribute(element.getAttributes().get(i)));
			element.getAttributes().set(i, mapperProperties.renameAttribute(element.getAttributes().get(i)));
		}
	}

	return true;
}
 
Example #24
Source File: ResultMapWithBLOBsElementGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
@Override
public void addElements(XmlElement parentElement) {
    XmlElement answer = new XmlElement("resultMap"); //$NON-NLS-1$

    answer.addAttribute(new Attribute("id", //$NON-NLS-1$
            introspectedTable.getResultMapWithBLOBsId()));

    String returnType;
    if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
        returnType = introspectedTable.getRecordWithBLOBsType();
    } else {
        // table has BLOBs, but no BLOB class - BLOB fields must be
        // in the base class
        returnType = introspectedTable.getBaseRecordType();
    }

    answer.addAttribute(new Attribute("type", //$NON-NLS-1$
            returnType));

    if (!introspectedTable.isConstructorBased()) {
        answer.addAttribute(new Attribute("extends", //$NON-NLS-1$
            introspectedTable.getBaseResultMapId()));
    }

    context.getCommentGenerator().addComment(answer);

    if (introspectedTable.isConstructorBased()) {
        addResultMapConstructorElements(answer);
    } else {
        addResultMapElements(answer);
    }

    if (context.getPlugins()
            .sqlMapResultMapWithBLOBsElementGenerated(answer,
                    introspectedTable)) {
        parentElement.addElement(answer);
    }
}
 
Example #25
Source File: PluginAggregator.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
public boolean sqlMapDeleteByPrimaryKeyElementGenerated(XmlElement element,
        IntrospectedTable table) {
    boolean rc = true;

    for (Plugin plugin : plugins) {
        if (!plugin
                .sqlMapDeleteByPrimaryKeyElementGenerated(element, table)) {
            rc = false;
            break;
        }
    }

    return rc;
}
 
Example #26
Source File: XMLMapperGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
protected void addUpdateByPrimaryKeyWithBLOBsElement(
        XmlElement parentElement) {
    if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithBLOBs()) {
        AbstractXmlElementGenerator elementGenerator = new UpdateByPrimaryKeyWithBLOBsElementGenerator();
        initializeAndExecuteGenerator(elementGenerator, parentElement);
    }
}
 
Example #27
Source File: PluginAggregator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
public boolean sqlMapCountByExampleElementGenerated(XmlElement element, IntrospectedTable table) {
	boolean rc = true;

	for (Plugin plugin : plugins) {
		if (!plugin.sqlMapCountByExampleElementGenerated(element, table)) {
			rc = false;
			break;
		}
	}

	return rc;
}
 
Example #28
Source File: HookAggregator.java    From mybatis-generator-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public XmlElement generateIncrementSet(IntrospectedColumn introspectedColumn, String prefix, boolean hasComma) {
    if (this.getPlugins(IIncrementPluginHook.class).isEmpty()) {
        return null;
    } else {
        return this.getPlugins(IIncrementPluginHook.class).get(0).generateIncrementSet(introspectedColumn, prefix, hasComma);
    }
}
 
Example #29
Source File: RenameExampleClassAndMethodsPlugin.java    From mybatis-generator-plugins with Apache License 2.0 5 votes vote down vote up
boolean renameElement(XmlElement element) {
	for (int i = 0; i < element.getAttributes().size(); i++) {
		Attribute attribute = element.getAttributes().get(i);
		if (XML_ID_ATTRIBUTE.equals(attribute.getName())) {
			String oldValue = attribute.getValue();
			Matcher matcher = classMethodPattern.matcher(oldValue);
			String newValue = matcher.replaceAll(classMethodReplaceString);
			Attribute newAtt = new Attribute(attribute.getName(), newValue);
			element.getAttributes().set(i, newAtt);
		}
	}

	return true;
}
 
Example #30
Source File: MySqlPaginationPlugin.java    From dolphin with Apache License 2.0 5 votes vote down vote up
@Override
public boolean sqlMapSelectByExampleWithoutBLOBsElementGenerated(
		XmlElement element, IntrospectedTable introspectedTable) {

	XmlElement isNotNullElement = new XmlElement("if"); 
	isNotNullElement.addAttribute(new Attribute("test", "limit != null and limit>=0 and offset != null"));
	isNotNullElement.addElement(new TextElement("limit #{offset} , #{limit}"));

	element.addElement(isNotNullElement);
	return true;
}