Search in sources :

Example 1 with ModelType

use of org.mybatis.generator.config.ModelType in project generator by mybatis.

the class IbatorConfigurationParser method parseIbatorContext.

private void parseIbatorContext(Configuration configuration, Node node) {
    Properties attributes = parseAttributes(node);
    //$NON-NLS-1$
    String defaultModelType = attributes.getProperty("defaultModelType");
    //$NON-NLS-1$
    String targetRuntime = attributes.getProperty("targetRuntime");
    String introspectedColumnImpl = attributes.getProperty(//$NON-NLS-1$
    "introspectedColumnImpl");
    //$NON-NLS-1$
    String id = attributes.getProperty("id");
    ModelType mt = defaultModelType == null ? null : ModelType.getModelType(defaultModelType);
    Context context = new Context(mt);
    context.setId(id);
    if (stringHasValue(introspectedColumnImpl)) {
        context.setIntrospectedColumnImpl(introspectedColumnImpl);
    }
    if (stringHasValue(targetRuntime)) {
        context.setTargetRuntime(targetRuntime);
    }
    configuration.addContext(context);
    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(context, childNode);
        } else if ("ibatorPlugin".equals(childNode.getNodeName())) {
            //$NON-NLS-1$
            parseIbatorPlugin(context, childNode);
        } else if ("commentGenerator".equals(childNode.getNodeName())) {
            //$NON-NLS-1$
            parseCommentGenerator(context, childNode);
        } else if ("jdbcConnection".equals(childNode.getNodeName())) {
            //$NON-NLS-1$
            parseJdbcConnection(context, childNode);
        } else if ("javaModelGenerator".equals(childNode.getNodeName())) {
            //$NON-NLS-1$
            parseJavaModelGenerator(context, childNode);
        } else if ("javaTypeResolver".equals(childNode.getNodeName())) {
            //$NON-NLS-1$
            parseJavaTypeResolver(context, childNode);
        } else if ("sqlMapGenerator".equals(childNode.getNodeName())) {
            //$NON-NLS-1$
            parseSqlMapGenerator(context, childNode);
        } else if ("daoGenerator".equals(childNode.getNodeName())) {
            //$NON-NLS-1$
            parseDaoGenerator(context, childNode);
        } else if ("table".equals(childNode.getNodeName())) {
            //$NON-NLS-1$
            parseTable(context, childNode);
        }
    }
}
Also used : Context(org.mybatis.generator.config.Context) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ModelType(org.mybatis.generator.config.ModelType) Properties(java.util.Properties)

Example 2 with ModelType

use of org.mybatis.generator.config.ModelType in project generator by mybatis.

the class MyBatisGeneratorConfigurationParser method parseContext.

private void parseContext(Configuration configuration, Node node) {
    Properties attributes = parseAttributes(node);
    // $NON-NLS-1$
    String defaultModelType = attributes.getProperty("defaultModelType");
    // $NON-NLS-1$
    String targetRuntime = attributes.getProperty("targetRuntime");
    String introspectedColumnImpl = attributes.getProperty(// $NON-NLS-1$
    "introspectedColumnImpl");
    // $NON-NLS-1$
    String id = attributes.getProperty("id");
    ModelType mt = defaultModelType == null ? null : ModelType.getModelType(defaultModelType);
    Context context = new Context(mt);
    context.setId(id);
    if (stringHasValue(introspectedColumnImpl)) {
        context.setIntrospectedColumnImpl(introspectedColumnImpl);
    }
    if (stringHasValue(targetRuntime)) {
        context.setTargetRuntime(targetRuntime);
    }
    configuration.addContext(context);
    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(context, childNode);
        } else if ("plugin".equals(childNode.getNodeName())) {
            // $NON-NLS-1$
            parsePlugin(context, childNode);
        } else if ("commentGenerator".equals(childNode.getNodeName())) {
            // $NON-NLS-1$
            parseCommentGenerator(context, childNode);
        } else if ("jdbcConnection".equals(childNode.getNodeName())) {
            // $NON-NLS-1$
            parseJdbcConnection(context, childNode);
        } else if ("connectionFactory".equals(childNode.getNodeName())) {
            // $NON-NLS-1$
            parseConnectionFactory(context, childNode);
        } else if ("javaModelGenerator".equals(childNode.getNodeName())) {
            // $NON-NLS-1$
            parseJavaModelGenerator(context, childNode);
        } else if ("javaTypeResolver".equals(childNode.getNodeName())) {
            // $NON-NLS-1$
            parseJavaTypeResolver(context, childNode);
        } else if ("sqlMapGenerator".equals(childNode.getNodeName())) {
            // $NON-NLS-1$
            parseSqlMapGenerator(context, childNode);
        } else if ("javaClientGenerator".equals(childNode.getNodeName())) {
            // $NON-NLS-1$
            parseJavaClientGenerator(context, childNode);
        } else if ("table".equals(childNode.getNodeName())) {
            // $NON-NLS-1$
            parseTable(context, childNode);
        }
    }
}
Also used : Context(org.mybatis.generator.config.Context) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ModelType(org.mybatis.generator.config.ModelType) Messages.getString(org.mybatis.generator.internal.util.messages.Messages.getString) Properties(java.util.Properties)

Aggregations

Properties (java.util.Properties)2 Context (org.mybatis.generator.config.Context)2 ModelType (org.mybatis.generator.config.ModelType)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 Messages.getString (org.mybatis.generator.internal.util.messages.Messages.getString)1