Package org.mybatis.generator.api.dom.xml

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


  public int hashCode() {
    return columnName.hashCode();
  }

  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;
  }
View Full Code Here


  @Override
  public List<GeneratedXmlFile> contextGenerateAdditionalXmlFiles() {
    Document document = new Document(XmlConstants.MYBATIS3_MAPPER_CONFIG_PUBLIC_ID,
        XmlConstants.MYBATIS3_MAPPER_CONFIG_SYSTEM_ID);

    XmlElement root = new XmlElement("configuration"); //$NON-NLS-1$
    document.setRootElement(root);

    root.addElement(new TextElement("<!--")); //$NON-NLS-1$
    root.addElement(new TextElement("  This file is generated by MyBatis Generator.")); //$NON-NLS-1$
    root.addElement(new TextElement(
        "  This file is the shell of a Mapper Config file - in many cases you will need to add")); //$NON-NLS-1$
    root.addElement(new TextElement("    to this file before it is usable by MyBatis.")); //$NON-NLS-1$

    StringBuilder sb = new StringBuilder();
    sb.append("  This file was generated on "); //$NON-NLS-1$
    sb.append(new Date());
    sb.append('.');
    root.addElement(new TextElement(sb.toString()));

    root.addElement(new TextElement("-->")); //$NON-NLS-1$

    XmlElement mappers = new XmlElement("mappers"); //$NON-NLS-1$
    root.addElement(mappers);

    XmlElement mapper;
    for (String mapperFile : mapperFiles) {
      mapper = new XmlElement("mapper"); //$NON-NLS-1$
      mapper.addAttribute(new Attribute("resource", mapperFile)); //$NON-NLS-1$
      mappers.addElement(mapper);
    }

    GeneratedXmlFile gxf = new GeneratedXmlFile(document, properties.getProperty("fileName", "MapperConfig.xml"), //$NON-NLS-1$ //$NON-NLS-2$
        properties.getProperty("targetPackage"), //$NON-NLS-1$
View Full Code Here

  @Override
  public List<GeneratedXmlFile> contextGenerateAdditionalXmlFiles() {
    Document document = new Document(XmlConstants.IBATIS2_SQL_MAP_CONFIG_PUBLIC_ID,
        XmlConstants.IBATIS2_SQL_MAP_CONFIG_SYSTEM_ID);

    XmlElement root = new XmlElement("sqlMapConfig"); //$NON-NLS-1$
    document.setRootElement(root);

    root.addElement(new TextElement("<!--")); //$NON-NLS-1$
    root.addElement(new TextElement("  This file is generated by MyBatis Generator.")); //$NON-NLS-1$
    root.addElement(new TextElement(
        "  This file is the shell of an SqlMapConfig file - in many cases you will need to add")); //$NON-NLS-1$
    root.addElement(new TextElement("    to this file before it is usable by iBATIS.")); //$NON-NLS-1$

    StringBuilder sb = new StringBuilder();
    sb.append("  This file was generated on "); //$NON-NLS-1$
    sb.append(new Date());
    sb.append('.');
    root.addElement(new TextElement(sb.toString()));

    root.addElement(new TextElement("-->")); //$NON-NLS-1$

    XmlElement settings = new XmlElement("settings"); //$NON-NLS-1$
    settings.addAttribute(new Attribute("useStatementNamespaces", "true")); //$NON-NLS-1$ //$NON-NLS-2$
    root.addElement(settings);

    XmlElement sqlMap;
    for (String sqlMapFile : sqlMapFiles) {
      sqlMap = new XmlElement("sqlMap"); //$NON-NLS-1$
      sqlMap.addAttribute(new Attribute("resource", sqlMapFile)); //$NON-NLS-1$
      root.addElement(sqlMap);
    }

    GeneratedXmlFile gxf = new GeneratedXmlFile(document, properties.getProperty("fileName", "SqlMapConfig.xml"), //$NON-NLS-1$ //$NON-NLS-2$
        properties.getProperty("targetPackage"), //$NON-NLS-1$
View Full Code Here

  }

  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.getMyBatis3JavaMapperType();
    if (namespace == null) {
      // TODO - this is wierd for mybatis3
      namespace = introspectedTable.getIbatis2SqlMapNamespace();
    }
    answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$
        namespace));

    context.getCommentGenerator().addRootComment(answer);

    addResultMapWithoutBLOBsElement(answer);
View Full Code Here

   * <code>validate</code> method to check validity of this context.
   *
   * @return the XML representation of this context
   */
  public XmlElement toXmlElement() {
    XmlElement xmlElement = new XmlElement("context"); //$NON-NLS-1$

    if (defaultModelType != ModelType.CONDITIONAL) {
      xmlElement.addAttribute(new Attribute("defaultModelType", defaultModelType.getModelType())); //$NON-NLS-1$
    }

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

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

    addPropertyXmlElements(xmlElement);

    if (commentGeneratorConfiguration != null) {
      xmlElement.addElement(commentGeneratorConfiguration.toXmlElement());
    }

    if (jdbcConnectionConfiguration != null) {
      xmlElement.addElement(jdbcConnectionConfiguration.toXmlElement());
    }

    if (javaTypeResolverConfiguration != null) {
      xmlElement.addElement(javaTypeResolverConfiguration.toXmlElement());
    }

    if (javaModelGeneratorConfiguration != null) {
      xmlElement.addElement(javaModelGeneratorConfiguration.toXmlElement());
    }

    if (sqlMapGeneratorConfiguration != null) {
      xmlElement.addElement(sqlMapGeneratorConfiguration.toXmlElement());
    }

    if (javaClientGeneratorConfiguration != null) {
      xmlElement.addElement(javaClientGeneratorConfiguration.toXmlElement());
    }

    for (TableConfiguration tableConfiguration : tableConfigurations) {
      xmlElement.addElement(tableConfiguration.toXmlElement());
    }

    return xmlElement;
  }
View Full Code Here

  public void setWildcardEscapingEnabled(boolean wildcardEscapingEnabled) {
    this.wildcardEscapingEnabled = wildcardEscapingEnabled;
  }

  public XmlElement toXmlElement() {
    XmlElement xmlElement = new XmlElement("table"); //$NON-NLS-1$
    xmlElement.addAttribute(new Attribute("tableName", tableName)); //$NON-NLS-1$

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

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

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

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

    if (!insertStatementEnabled) {
      xmlElement.addAttribute(new Attribute("enableInsert", "false")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (!selectByPrimaryKeyStatementEnabled) {
      xmlElement.addAttribute(new Attribute("enableSelectByPrimaryKey", "false")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (!selectByExampleStatementEnabled) {
      xmlElement.addAttribute(new Attribute("enableSelectByExample", "false")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (!updateByPrimaryKeyStatementEnabled) {
      xmlElement.addAttribute(new Attribute("enableUpdateByPrimaryKey", "false")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (!deleteByPrimaryKeyStatementEnabled) {
      xmlElement.addAttribute(new Attribute("enableDeleteByPrimaryKey", "false")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (!deleteByExampleStatementEnabled) {
      xmlElement.addAttribute(new Attribute("enableDeleteByExample", "false")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (!countByExampleStatementEnabled) {
      xmlElement.addAttribute(new Attribute("enableCountByExample", "false")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (!updateByExampleStatementEnabled) {
      xmlElement.addAttribute(new Attribute("enableUpdateByExample", "false")); //$NON-NLS-1$ //$NON-NLS-2$
    }

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

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

    if (configuredModelType != null) {
      xmlElement.addAttribute(new Attribute("modelType", configuredModelType)); //$NON-NLS-1$
    }

    if (wildcardEscapingEnabled) {
      xmlElement.addAttribute(new Attribute("escapeWildcards", "true")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (isAllColumnDelimitingEnabled) {
      xmlElement.addAttribute(new Attribute("delimitAllColumns", "true")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (delimitIdentifiers) {
      xmlElement.addAttribute(new Attribute("delimitIdentifiers", "true")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    addPropertyXmlElements(xmlElement);

    if (generatedKey != null) {
      xmlElement.addElement(generatedKey.toXmlElement());
    }

    if (columnRenamingRule != null) {
      xmlElement.addElement(columnRenamingRule.toXmlElement());
    }

    if (ignoredColumns.size() > 0) {
      for (IgnoredColumn ignoredColumn : ignoredColumns.keySet()) {
        xmlElement.addElement(ignoredColumn.toXmlElement());
      }
    }

    if (columnOverrides.size() > 0) {
      for (ColumnOverride columnOverride : columnOverrides) {
        xmlElement.addElement(columnOverride.toXmlElement());
      }
    }

    return xmlElement;
  }
View Full Code Here

  public void setTargetPackage(String targetPackage) {
    this.targetPackage = targetPackage;
  }

  public XmlElement toXmlElement() {
    XmlElement answer = new XmlElement("sqlMapGenerator"); //$NON-NLS-1$

    if (targetPackage != null) {
      answer.addAttribute(new Attribute("targetPackage", targetPackage)); //$NON-NLS-1$
    }

    if (targetProject != null) {
      answer.addAttribute(new Attribute("targetProject", targetProject)); //$NON-NLS-1$
    }

    addPropertyXmlElements(answer);

    return answer;
View Full Code Here

     */
  public CommentGeneratorConfiguration() {
  }

  public XmlElement toXmlElement() {
    XmlElement answer = new XmlElement("commentGenerator"); //$NON-NLS-1$
    if (getConfigurationType() != null) {
      answer.addAttribute(new Attribute("type", getConfigurationType())); //$NON-NLS-1$
    }

    addPropertyXmlElements(answer);

    return answer;
View Full Code Here

  public void setTargetPackage(String targetPackage) {
    this.targetPackage = targetPackage;
  }

  public XmlElement toXmlElement() {
    XmlElement answer = new XmlElement("javaModelGenerator"); //$NON-NLS-1$

    if (targetPackage != null) {
      answer.addAttribute(new Attribute("targetPackage", targetPackage)); //$NON-NLS-1$
    }

    if (targetProject != null) {
      answer.addAttribute(new Attribute("targetProject", targetProject)); //$NON-NLS-1$
    }

    addPropertyXmlElements(answer);

    return answer;
View Full Code Here

  protected void addPropertyXmlElements(XmlElement xmlElement) {
    Enumeration<?> enumeration = properties.propertyNames();
    while (enumeration.hasMoreElements()) {
      String propertyName = (String) enumeration.nextElement();

      XmlElement propertyElement = new XmlElement("property"); //$NON-NLS-1$
      propertyElement.addAttribute(new Attribute("name", propertyName)); //$NON-NLS-1$
      propertyElement.addAttribute(new Attribute("value", properties.getProperty(propertyName))); //$NON-NLS-1$
      xmlElement.addElement(propertyElement);
    }
  }
View Full Code Here

TOP

Related Classes of org.mybatis.generator.api.dom.xml.XmlElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.