Search in sources :

Example 6 with DatabaseCategory

use of com.ctrip.platform.dal.daogen.enums.DatabaseCategory in project dal by ctripcorp.

the class CSharpDataPreparerOfSqlBuilderProcessor method buildExtraSqlBuilderHost.

private CSharpTableHost buildExtraSqlBuilderHost(CodeGenContext codeGenCtx, GenTaskBySqlBuilder sqlBuilder) throws Exception {
    GenTaskByTableViewSp tableViewSp = new GenTaskByTableViewSp();
    tableViewSp.setCud_by_sp(false);
    tableViewSp.setPagination(false);
    tableViewSp.setAllInOneName(sqlBuilder.getAllInOneName());
    tableViewSp.setDatabaseSetName(sqlBuilder.getDatabaseSetName());
    tableViewSp.setPrefix("");
    tableViewSp.setSuffix("");
    DatabaseCategory dbCategory = DatabaseCategory.SqlServer;
    String dbType = DbUtils.getDbType(sqlBuilder.getAllInOneName());
    if (dbType != null && !dbType.equalsIgnoreCase("Microsoft SQL Server")) {
        dbCategory = DatabaseCategory.MySql;
    }
    List<StoredProcedure> allSpNames = DbUtils.getAllSpNames(sqlBuilder.getAllInOneName());
    return buildTableHost(codeGenCtx, tableViewSp, sqlBuilder.getTable_name(), dbCategory, allSpNames);
}
Also used : DatabaseCategory(com.ctrip.platform.dal.daogen.enums.DatabaseCategory) StoredProcedure(com.ctrip.platform.dal.daogen.domain.StoredProcedure) GenTaskByTableViewSp(com.ctrip.platform.dal.daogen.entity.GenTaskByTableViewSp)

Example 7 with DatabaseCategory

use of com.ctrip.platform.dal.daogen.enums.DatabaseCategory in project dal by ctripcorp.

the class AbstractCSharpDataPreparer method getDatabaseCategory.

protected DatabaseCategory getDatabaseCategory(String dbName) throws Exception {
    DatabaseCategory dbCategory = DatabaseCategory.SqlServer;
    String dbType = DbUtils.getDbType(dbName);
    if (null != dbType && !dbType.equalsIgnoreCase("Microsoft SQL Server")) {
        dbCategory = DatabaseCategory.MySql;
    }
    return dbCategory;
}
Also used : DatabaseCategory(com.ctrip.platform.dal.daogen.enums.DatabaseCategory)

Example 8 with DatabaseCategory

use of com.ctrip.platform.dal.daogen.enums.DatabaseCategory in project dal by ctripcorp.

the class AbstractJavaDataPreparer method getDatabaseCategory.

protected DatabaseCategory getDatabaseCategory(String allInOneName) throws Exception {
    DatabaseCategory dbCategory = DatabaseCategory.SqlServer;
    String dbType = DbUtils.getDbType(allInOneName);
    if (null != dbType && !dbType.equalsIgnoreCase("Microsoft SQL Server")) {
        dbCategory = DatabaseCategory.MySql;
    }
    return dbCategory;
}
Also used : DatabaseCategory(com.ctrip.platform.dal.daogen.enums.DatabaseCategory)

Example 9 with DatabaseCategory

use of com.ctrip.platform.dal.daogen.enums.DatabaseCategory in project dal by ctripcorp.

the class CSharpDataPreparerOfFreeSqlProcessor method buildFreeSqlPojoHost.

private CSharpFreeSqlPojoHost buildFreeSqlPojoHost(CSharpCodeGenContext codeGenCtx, GenTaskByFreeSql task) throws Exception {
    CSharpFreeSqlPojoHost freeSqlHost = new CSharpFreeSqlPojoHost();
    List<CSharpParameterHost> pHosts = new ArrayList<>();
    DatabaseCategory dbCategory = DatabaseCategory.SqlServer;
    String dbType = DbUtils.getDbType(task.getAllInOneName());
    if (dbType != null && !dbType.equalsIgnoreCase("Microsoft SQL Server")) {
        dbCategory = DatabaseCategory.MySql;
    }
    List<AbstractParameterHost> list = DbUtils.testAQuerySql(task.getAllInOneName(), task.getSql_content(), task.getParameters(), new CsharpGivenSqlResultSetExtractor(dbCategory));
    for (AbstractParameterHost _ahost : list) {
        pHosts.add((CSharpParameterHost) _ahost);
    }
    freeSqlHost.setColumns(pHosts);
    freeSqlHost.setTableName("");
    String className = task.getPojo_name();
    if (className.equalsIgnoreCase("简单类型")) {
        freeSqlHost.setClassName(task.getMethod_name().substring(0, 1).toUpperCase() + task.getMethod_name().substring(1));
    } else {
        freeSqlHost.setClassName(CommonUtils.normalizeVariable(WordUtils.capitalize(task.getPojo_name())));
    }
    freeSqlHost.setNameSpace(codeGenCtx.getNamespace());
    return freeSqlHost;
}
Also used : AbstractParameterHost(com.ctrip.platform.dal.daogen.host.AbstractParameterHost) DatabaseCategory(com.ctrip.platform.dal.daogen.enums.DatabaseCategory)

Example 10 with DatabaseCategory

use of com.ctrip.platform.dal.daogen.enums.DatabaseCategory in project dal by ctripcorp.

the class GenTaskBySqlBuilderResource method getTableColumnSqlType.

/**
     * @param set_name
     * @param table_name
     * @return <column alias, sqltype>
     */
private Map<String, Integer> getTableColumnSqlType(String set_name, String table_name) throws Exception {
    DatabaseSetEntry databaseSetEntry = SpringBeanGetter.getDaoOfDatabaseSet().getMasterDatabaseSetEntryByDatabaseSetName(set_name);
    String dbName = databaseSetEntry.getConnectionString();
    DatabaseCategory dbCategory = DbUtils.getDatabaseCategory(dbName);
    List<AbstractParameterHost> paramsHost = DbUtils.getAllColumnNames(dbName, table_name, new JavaColumnNameResultSetExtractor(dbName, table_name, dbCategory));
    Map<String, Integer> map = new HashMap<>();
    if (paramsHost != null) {
        for (int i = 0; i < paramsHost.size(); i++) {
            JavaParameterHost paramHost = (JavaParameterHost) paramsHost.get(i);
            map.put(paramHost.getAlias().toLowerCase(), paramHost.getSqlType());
        }
    }
    return map;
}
Also used : AbstractParameterHost(com.ctrip.platform.dal.daogen.host.AbstractParameterHost) DatabaseCategory(com.ctrip.platform.dal.daogen.enums.DatabaseCategory) JavaColumnNameResultSetExtractor(com.ctrip.platform.dal.daogen.host.java.JavaColumnNameResultSetExtractor) HashMap(java.util.HashMap) JavaParameterHost(com.ctrip.platform.dal.daogen.host.java.JavaParameterHost)

Aggregations

DatabaseCategory (com.ctrip.platform.dal.daogen.enums.DatabaseCategory)11 GenTaskByTableViewSp (com.ctrip.platform.dal.daogen.entity.GenTaskByTableViewSp)4 Status (com.ctrip.platform.dal.daogen.domain.Status)2 GenTaskBySqlBuilder (com.ctrip.platform.dal.daogen.entity.GenTaskBySqlBuilder)2 Progress (com.ctrip.platform.dal.daogen.entity.Progress)2 AbstractParameterHost (com.ctrip.platform.dal.daogen.host.AbstractParameterHost)2 Callable (java.util.concurrent.Callable)2 StoredProcedure (com.ctrip.platform.dal.daogen.domain.StoredProcedure)1 CSharpCodeGenContext (com.ctrip.platform.dal.daogen.generator.csharp.CSharpCodeGenContext)1 JavaCodeGenContext (com.ctrip.platform.dal.daogen.generator.java.JavaCodeGenContext)1 JavaColumnNameResultSetExtractor (com.ctrip.platform.dal.daogen.host.java.JavaColumnNameResultSetExtractor)1 JavaParameterHost (com.ctrip.platform.dal.daogen.host.java.JavaParameterHost)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 HashMap (java.util.HashMap)1