org.mybatis.generator.config.SqlMapGeneratorConfiguration Java Examples

The following examples show how to use org.mybatis.generator.config.SqlMapGeneratorConfiguration. 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: IntrospectedTable.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
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.getSubPackageForClientOrSqlMap(isSubPackagesEnabled(config)));
        if (stringHasValue(tableConfiguration.getMapperName())) {
            String mapperName = tableConfiguration.getMapperName();
            int ind = mapperName.lastIndexOf('.');
            if (ind != -1) {
                sb.append('.').append(mapperName.substring(0, ind));
            }
        } else if (stringHasValue(fullyQualifiedTable.getDomainObjectSubPackage())) {
            sb.append('.').append(fullyQualifiedTable.getDomainObjectSubPackage());
        }
    }

    return sb.toString();
}
 
Example #2
Source File: MyBatisGeneratorConfigurationParser.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
protected void parseSqlMapGenerator(Context context, Node node) {
    SqlMapGeneratorConfiguration sqlMapGeneratorConfiguration = new SqlMapGeneratorConfiguration();

    context.setSqlMapGeneratorConfiguration(sqlMapGeneratorConfiguration);

    Properties attributes = parseAttributes(node);
    String targetPackage = attributes.getProperty("targetPackage");
    String targetProject = attributes.getProperty("targetProject");

    sqlMapGeneratorConfiguration.setTargetPackage(targetPackage);
    sqlMapGeneratorConfiguration.setTargetProject(targetProject);

    NodeList nodeList = node.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node childNode = nodeList.item(i);

        if (childNode.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        if ("property".equals(childNode.getNodeName())) {
            parseProperty(sqlMapGeneratorConfiguration, childNode);
        }
    }
}
 
Example #3
Source File: IntrospectedTable.java    From mybatis-generator-core-fix with Apache License 2.0 6 votes vote down vote up
/**
 * Calculate sql map package.
 *
 * @return the string
 */
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.getSubPackageForClientOrSqlMap(isSubPackagesEnabled(config)));
        if (stringHasValue(tableConfiguration.getMapperName())) {
            String mapperName = tableConfiguration.getMapperName();
            int ind = mapperName.lastIndexOf('.');
            if (ind != -1) {
                sb.append('.').append(mapperName.substring(0, ind));
            }
        }
    }

    return sb.toString();
}
 
Example #4
Source File: IbatorConfigurationParser.java    From mybatis-generator-core-fix with Apache License 2.0 6 votes vote down vote up
private void parseSqlMapGenerator(Context context, Node node) {
    SqlMapGeneratorConfiguration sqlMapGeneratorConfiguration = new SqlMapGeneratorConfiguration();

    context.setSqlMapGeneratorConfiguration(sqlMapGeneratorConfiguration);

    Properties attributes = parseAttributes(node);
    String targetPackage = attributes.getProperty("targetPackage"); //$NON-NLS-1$
    String targetProject = attributes.getProperty("targetProject"); //$NON-NLS-1$

    sqlMapGeneratorConfiguration.setTargetPackage(targetPackage);
    sqlMapGeneratorConfiguration.setTargetProject(targetProject);

    NodeList nodeList = node.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node childNode = nodeList.item(i);

        if (childNode.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseProperty(sqlMapGeneratorConfiguration, childNode);
        }
    }
}
 
Example #5
Source File: MyBatisGeneratorConfigurationParser.java    From mybatis-generator-core-fix with Apache License 2.0 6 votes vote down vote up
private void parseSqlMapGenerator(Context context, Node node) {
    SqlMapGeneratorConfiguration sqlMapGeneratorConfiguration = new SqlMapGeneratorConfiguration();

    context.setSqlMapGeneratorConfiguration(sqlMapGeneratorConfiguration);

    Properties attributes = parseAttributes(node);
    String targetPackage = attributes.getProperty("targetPackage"); //$NON-NLS-1$
    String targetProject = attributes.getProperty("targetProject"); //$NON-NLS-1$

    sqlMapGeneratorConfiguration.setTargetPackage(targetPackage);
    sqlMapGeneratorConfiguration.setTargetProject(targetProject);

    NodeList nodeList = node.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node childNode = nodeList.item(i);

        if (childNode.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseProperty(sqlMapGeneratorConfiguration, childNode);
        }
    }
}
 
Example #6
Source File: IbatorConfigurationParser.java    From mybatis-generator-plus with Apache License 2.0 6 votes vote down vote up
private void parseSqlMapGenerator(Context context, Node node) {
    SqlMapGeneratorConfiguration sqlMapGeneratorConfiguration = new SqlMapGeneratorConfiguration();

    context.setSqlMapGeneratorConfiguration(sqlMapGeneratorConfiguration);

    Properties attributes = parseAttributes(node);
    String targetPackage = attributes.getProperty("targetPackage"); //$NON-NLS-1$
    String targetProject = attributes.getProperty("targetProject"); //$NON-NLS-1$

    sqlMapGeneratorConfiguration.setTargetPackage(targetPackage);
    sqlMapGeneratorConfiguration.setTargetProject(targetProject);

    NodeList nodeList = node.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node childNode = nodeList.item(i);

        if (childNode.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseProperty(sqlMapGeneratorConfiguration, childNode);
        }
    }
}
 
Example #7
Source File: MyBatisGeneratorConfigurationParser.java    From mybatis-generator-plus with Apache License 2.0 6 votes vote down vote up
private void parseSqlMapGenerator(Context context, Node node) {
    SqlMapGeneratorConfiguration sqlMapGeneratorConfiguration = new SqlMapGeneratorConfiguration();

    context.setSqlMapGeneratorConfiguration(sqlMapGeneratorConfiguration);

    Properties attributes = parseAttributes(node);
    String targetPackage = attributes.getProperty("targetPackage"); //$NON-NLS-1$
    String targetProject = attributes.getProperty("targetProject"); //$NON-NLS-1$

    sqlMapGeneratorConfiguration.setTargetPackage(targetPackage);
    sqlMapGeneratorConfiguration.setTargetProject(targetProject);

    NodeList nodeList = node.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node childNode = nodeList.item(i);

        if (childNode.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseProperty(sqlMapGeneratorConfiguration, childNode);
        }
    }
}
 
Example #8
Source File: IntrospectedTable.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #9
Source File: ContentMergePlugin.java    From dolphin with Apache License 2.0 5 votes vote down vote up
@Override
public boolean sqlMapGenerated(GeneratedXmlFile sqlMap, IntrospectedTable introspectedTable) {
  SqlMapGeneratorConfiguration smgc = context.getSqlMapGeneratorConfiguration();
  try {
    Document document = (Document) FieldUtils.readDeclaredField(sqlMap, "document", true);
    File targetFile = getTargetFile(smgc.getTargetPackage(), sqlMap.getFileName());
    if (!targetFile.exists()) { // 第一次生成直接使用当前生成的文件
      return true;
    }
    visitAndMerge(document, targetFile);
  } catch (ShellException | IOException | IllegalAccessException | DocumentException e) {
    e.printStackTrace();
  }
  return true;
}
 
Example #10
Source File: XMLMergePlugin.java    From dolphin with Apache License 2.0 5 votes vote down vote up
@Override
public boolean sqlMapGenerated(GeneratedXmlFile sqlMap, IntrospectedTable introspectedTable) {
  SqlMapGeneratorConfiguration smgc = context.getSqlMapGeneratorConfiguration();
  try {
    Document document = (Document) FieldUtils.readDeclaredField(sqlMap, "document", true);
    File targetFile = getTargetFile(smgc.getTargetPackage(), sqlMap.getFileName());
    if (!targetFile.exists()) { // 第一次生成直接使用当前生成的文件
      return true;
    }
    visitAndMerge(document, targetFile);
  } catch (ShellException | IOException | IllegalAccessException | DocumentException e) {
    e.printStackTrace();
  }
  return true;
}