Merge pull request #555 from dataease/pr@dev@sqlserver

Merge branch 'dev' into pr@dev@sqlserver
This commit is contained in:
taojinlong 2021-08-09 12:46:50 +08:00 committed by GitHub
commit 004e2f72d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 930 additions and 604 deletions

View File

@ -0,0 +1,12 @@
package io.dataease.commons.constants;
public class DeTypeConstants {
public final static Integer DE_STRING = 0;
public final static Integer DE_TIME = 1;
public final static Integer DE_INT = 2;
public final static Integer DE_FLOAT = 3;
public final static Integer DE_BOOL = 4;
public final static Integer DE_Binary = 5;
}

View File

@ -68,7 +68,6 @@ public class SqlFilter implements Filter {
}
br.close();
} catch (IOException e) {
System.out.println("IOException: " + e);
}
return str;

View File

@ -32,7 +32,6 @@ public class LicenseController {
return ResultHolder.success(null);
}
F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.validateLicense();
System.out.println(new Gson().toJson(f2CLicenseResponse));
switch (f2CLicenseResponse.getStatus()) {
case no_record:
return ResultHolder.success(f2CLicenseResponse);

View File

@ -8,6 +8,7 @@ import lombok.Setter;
@Setter
public class SqlServerConfigration extends JdbcDTO {
private String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
private String schema;
public String getJdbc(){
return "jdbc:sqlserver://HOSTNAME:PORT;DatabaseName=DATABASE".replace("HOSTNAME", getHost()).replace("PORT", getPort().toString()).replace("DATABASE", getDataBase());

View File

@ -108,7 +108,9 @@ public class JdbcProvider extends DatasourceProvider {
int columType = metaData.getColumnType(j + 1);
switch (columType) {
case Types.DATE:
row[j] = rs.getDate(j + 1).toString();
if(rs.getDate(j + 1) != null){
row[j] = rs.getDate(j + 1).toString();
}
break;
default:
row[j] = rs.getString(j + 1);
@ -287,7 +289,7 @@ public class JdbcProvider extends DatasourceProvider {
}
tableFiled.setRemarks(remarks);
tableFiled.setFieldSize(Integer.valueOf(resultSet.getString("COLUMN_SIZE")));
String dbType = resultSet.getString("TYPE_NAME");
String dbType = resultSet.getString("TYPE_NAME").toUpperCase();
tableFiled.setFieldType(dbType);
if(dbType.equalsIgnoreCase("LONG")){tableFiled.setFieldSize(65533);}
if(StringUtils.isNotEmpty(dbType) && dbType.toLowerCase().contains("date") && tableFiled.getFieldSize() < 50 ){
@ -506,7 +508,9 @@ public class JdbcProvider extends DatasourceProvider {
return "show tables;";
case sqlServer:
SqlServerConfigration sqlServerConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), SqlServerConfigration.class);
return "SELECT TABLE_NAME FROM DATABASE.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE';".replace("DATABASE", sqlServerConfigration.getDataBase());
return "SELECT TABLE_NAME FROM DATABASE.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = 'DS_SCHEMA' ;"
.replace("DATABASE", sqlServerConfigration.getDataBase())
.replace("DS_SCHEMA", sqlServerConfigration.getSchema());
case oracle:
OracleConfigration oracleConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), OracleConfigration.class);
if(StringUtils.isEmpty(oracleConfigration.getSchema())){
@ -523,6 +527,8 @@ public class JdbcProvider extends DatasourceProvider {
switch (datasourceType) {
case oracle:
return "select * from all_users";
case sqlServer:
return "select name from sys.schemas;";
default:
return "show tables;";
}

View File

@ -1,6 +1,7 @@
package io.dataease.provider;
import io.dataease.base.domain.DatasetTableField;
import io.dataease.base.domain.Datasource;
import io.dataease.controller.request.chart.ChartExtFilterRequest;
import io.dataease.dto.chart.ChartCustomFilterDTO;
import io.dataease.dto.chart.ChartViewFieldDTO;
@ -12,21 +13,18 @@ import java.util.List;
* @Date 2021/5/17 2:42 下午
*/
public abstract class QueryProvider {
public abstract Integer transFieldType(String field);
public abstract String createQueryCountSQL(String table);
public abstract String createQueryCountSQLAsTmp(String sql);
public abstract String createSQLPreview(String sql, String orderBy);
public abstract String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup);
public abstract String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds);
public abstract String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup);
public abstract String createQuerySQLWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup);
public abstract String createQuerySQLWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds);
public abstract String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup);
public abstract String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds);
public abstract String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup);

View File

@ -2,6 +2,7 @@ package io.dataease.provider.doris;
import io.dataease.base.domain.DatasetTableField;
import io.dataease.base.domain.DatasetTableFieldExample;
import io.dataease.base.domain.Datasource;
import io.dataease.base.mapper.DatasetTableFieldMapper;
import io.dataease.controller.request.chart.ChartExtFilterRequest;
import io.dataease.dto.chart.ChartCustomFilterDTO;
@ -70,23 +71,13 @@ public class DorisQueryProvider extends QueryProvider {
}
}
@Override
public String createQueryCountSQL(String table) {
return MessageFormat.format("SELECT count(*) FROM {0}", table);
}
@Override
public String createQueryCountSQLAsTmp(String sql) {
return createQueryCountSQL(" (" + sql + ") AS tmp ");
}
@Override
public String createSQLPreview(String sql, String orderBy) {
return "SELECT * FROM (" + sql + ") AS tmp ORDER BY " + orderBy + " LIMIT 0,1000";
}
@Override
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup) {
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
SQLObj tableObj = SQLObj.builder()
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(DorisConstants.KEYWORD_TABLE, table))
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
@ -159,17 +150,17 @@ public class DorisQueryProvider extends QueryProvider {
@Override
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
return createQuerySQL("(" + sql + ")", fields, isGroup);
return createQuerySQL("(" + sql + ")", fields, isGroup, null);
}
@Override
public String createQuerySQLWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
return createQuerySQL(table, fields, isGroup) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
public String createQuerySQLWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
return createQuerySQL(table, fields, isGroup, null) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
}
@Override
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
return createQuerySQL(table, fields, isGroup) + " LIMIT 0," + limit;
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
return createQuerySQL(table, fields, isGroup, null) + " LIMIT 0," + limit;
}
@Override

View File

@ -2,6 +2,7 @@ package io.dataease.provider.mysql;
import io.dataease.base.domain.DatasetTableField;
import io.dataease.base.domain.DatasetTableFieldExample;
import io.dataease.base.domain.Datasource;
import io.dataease.base.mapper.DatasetTableFieldMapper;
import io.dataease.controller.request.chart.ChartExtFilterRequest;
import io.dataease.dto.chart.ChartCustomFilterDTO;
@ -70,23 +71,13 @@ public class MysqlQueryProvider extends QueryProvider {
}
}
@Override
public String createQueryCountSQL(String table) {
return MessageFormat.format("SELECT COUNT(*) FROM {0}", table);
}
@Override
public String createQueryCountSQLAsTmp(String sql) {
return createQueryCountSQL(" (" + sqlFix(sql) + ") AS tmp ");
}
@Override
public String createSQLPreview(String sql, String orderBy) {
return "SELECT * FROM (" + sqlFix(sql) + ") AS tmp ORDER BY null " + " LIMIT 0,1000";
}
@Override
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup) {
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
SQLObj tableObj = SQLObj.builder()
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MySQLConstants.KEYWORD_TABLE, table))
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
@ -150,17 +141,17 @@ public class MysqlQueryProvider extends QueryProvider {
@Override
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup);
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null);
}
@Override
public String createQuerySQLWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
return createQuerySQL(table, fields, isGroup) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
public String createQuerySQLWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
return createQuerySQL(table, fields, isGroup, null) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
}
@Override
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
return createQuerySQL(table, fields, isGroup) + " LIMIT 0," + limit;
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
return createQuerySQL(table, fields, isGroup, null) + " LIMIT 0," + limit;
}
@Override

View File

@ -2,6 +2,7 @@ package io.dataease.provider.oracle;
import io.dataease.base.domain.DatasetTableField;
import io.dataease.base.domain.DatasetTableFieldExample;
import io.dataease.base.domain.Datasource;
import io.dataease.base.mapper.DatasetTableFieldMapper;
import io.dataease.controller.request.chart.ChartExtFilterRequest;
import io.dataease.dto.chart.ChartCustomFilterDTO;
@ -82,23 +83,13 @@ public class OracleQueryProvider extends QueryProvider {
}
}
@Override
public String createQueryCountSQL(String table) {
return MessageFormat.format("SELECT COUNT(*) FROM {0}", table);
}
@Override
public String createQueryCountSQLAsTmp(String sql) {
return createQueryCountSQL(" (" + sqlFix(sql) + ") DE_TMP ");
}
@Override
public String createSQLPreview(String sql, String orderBy) {
return "SELECT * FROM (" + sqlFix(sql) + ") DE_TMP " + " WHERE rownum <= 1000";
}
@Override
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup) {
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
SQLObj tableObj = SQLObj.builder()
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(OracleConstants.KEYWORD_TABLE, table))
.tableAlias(String.format(OracleConstants.ALIAS_FIX, String.format(TABLE_ALIAS_PREFIX, 0)))
@ -179,19 +170,19 @@ public class OracleQueryProvider extends QueryProvider {
@Override
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup);
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null);
}
@Override
public String createQuerySQLWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
public String createQuerySQLWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
List<SQLObj> xFields = xFields(table, fields);
return MessageFormat.format("SELECT {0} FROM ( SELECT DE_TMP.*, rownum r FROM ( {1} ) DE_TMP WHERE rownum <= {2} ) WHERE r > {3} ",
sqlColumn(xFields), createQuerySQL(table, fields, isGroup), Integer.valueOf(page * realSize).toString(), Integer.valueOf((page - 1) * pageSize).toString());
sqlColumn(xFields), createQuerySQL(table, fields, isGroup, null), Integer.valueOf(page * realSize).toString(), Integer.valueOf((page - 1) * pageSize).toString());
}
@Override
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
return String.format("SELECT %s.* from %s WHERE rownum <= %s ", table, table, limit.toString());
}

View File

@ -0,0 +1,43 @@
package io.dataease.provider.sqlserver;
import io.dataease.provider.SQLConstants;
import static io.dataease.datasource.constants.DatasourceTypes.sqlServer;
/**
* @Author gin
* @Date 2021/7/8 7:22 下午
*/
public class SqlServerSQLConstants extends SQLConstants {
public static final String KEYWORD_TABLE = sqlServer.getKeywordPrefix() + "%s" + sqlServer.getKeywordSuffix();
public static final String KEYWORD_FIX = "%s." + sqlServer.getKeywordPrefix() + "%s" + sqlServer.getKeywordSuffix();
public static final String UNIX_TIMESTAMP = "CAST(DATEDIFF(ss,'1970-01-01 08:00:00', %s) as bigint ) * 1000 ";
public static final String DATE_FORMAT = "CONVERT(varchar(100), %s, %s)";
public static final String FROM_UNIXTIME = "convert(varchar, %s ,120)";
public static final String CONVERT = "CONVERT(%s, %s)";
public static final String LONG_TO_DATE = "DATEADD(second,%s,'1970-01-01 08:00:00')";
public static final String STRING_TO_DATE = "CONVERT(datetime, %s ,120)";
public static final String DEFAULT_INT_FORMAT = "DECIMAL(20,0)";
public static final String DEFAULT_FLOAT_FORMAT = "DECIMAL(20,2)";
public static final String WHERE_VALUE_NULL = "(NULL,'')";
public static final String WHERE_VALUE_VALUE = "'%s'";
public static final String AGG_COUNT = "COUNT(*)";
public static final String AGG_FIELD = "%s(%s)";
public static final String WHERE_BETWEEN = "'%s' AND '%s'";
public static final String BRACKETS = "(%s)";
}

View File

@ -377,7 +377,7 @@ public class DataSetTableService {
datasourceRequest.setDatasource(ds);
String table = dataTableInfoDTO.getTable();
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false));
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false, ds));
map.put("sql", datasourceRequest.getQuery());
try {
data.addAll(datasourceProvider.getData(datasourceRequest));
@ -386,7 +386,7 @@ public class DataSetTableService {
DEException.throwException(e.getMessage());
}
try {
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false));
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size());
} catch (Exception e) {
e.printStackTrace();
@ -403,7 +403,7 @@ public class DataSetTableService {
datasourceRequest.setDatasource(ds);
String table = DorisTableUtils.dorisName(dataSetTableRequest.getId());
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false));
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false, ds));
map.put("sql", datasourceRequest.getQuery());
try {
data.addAll(jdbcProvider.getData(datasourceRequest));
@ -412,7 +412,7 @@ public class DataSetTableService {
DEException.throwException(e.getMessage());
}
try {
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false));
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
} catch (Exception e) {
e.printStackTrace();
@ -458,7 +458,7 @@ public class DataSetTableService {
datasourceRequest.setDatasource(ds);
String table = DorisTableUtils.dorisName(dataSetTableRequest.getId());
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false));
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false, ds));
map.put("sql", datasourceRequest.getQuery());
try {
data.addAll(jdbcProvider.getData(datasourceRequest));
@ -467,7 +467,7 @@ public class DataSetTableService {
DEException.throwException(e.getMessage());
}
try {
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false));
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
} catch (Exception e) {
e.printStackTrace();
@ -485,7 +485,7 @@ public class DataSetTableService {
datasourceRequest.setDatasource(ds);
String table = DorisTableUtils.dorisName(dataSetTableRequest.getId());
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false));
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false, ds));
map.put("sql", datasourceRequest.getQuery());
try {
data.addAll(jdbcProvider.getData(datasourceRequest));
@ -494,7 +494,7 @@ public class DataSetTableService {
DEException.throwException(e.getMessage());
}
try {
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false));
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
} catch (Exception e) {
e.printStackTrace();
@ -537,7 +537,7 @@ public class DataSetTableService {
datasourceRequest.setDatasource(ds);
String table = DorisTableUtils.dorisName(dataSetTableRequest.getId());
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false));
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false, ds));
map.put("sql", datasourceRequest.getQuery());
try {
data.addAll(jdbcProvider.getData(datasourceRequest));
@ -547,7 +547,7 @@ public class DataSetTableService {
}
try {
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false));
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
} catch (Exception e) {
e.printStackTrace();

View File

@ -865,7 +865,7 @@ public class ExtractDataService {
textFileOutputMeta.setSeparator(separator);
textFileOutputMeta.setExtension(extention);
if (datasource.getType().equalsIgnoreCase(DatasourceTypes.oracle.name())) {
if (datasource.getType().equalsIgnoreCase(DatasourceTypes.oracle.name()) ) {
TextFileField[] outputFields = new TextFileField[datasetTableFields.size() + 1];
for(int i=0;i< datasetTableFields.size();i++){
TextFileField textFileField = new TextFileField();
@ -878,6 +878,20 @@ public class ExtractDataService {
textFileField.setType("String");
outputFields[datasetTableFields.size()] = textFileField;
textFileOutputMeta.setOutputFields(outputFields);
}else if (datasource.getType().equalsIgnoreCase(DatasourceTypes.sqlServer.name())){
TextFileField[] outputFields = new TextFileField[datasetTableFields.size() + 1];
for(int i=0;i< datasetTableFields.size();i++){
TextFileField textFileField = new TextFileField();
textFileField.setName(datasetTableFields.get(i).getDataeaseName());
textFileField.setType("String");
outputFields[i] = textFileField;
}
TextFileField textFileField = new TextFileField();
textFileField.setName("dataease_uuid");
textFileField.setType("String");
outputFields[datasetTableFields.size()] = textFileField;
textFileOutputMeta.setOutputFields(outputFields);
}else {
textFileOutputMeta.setOutputFields(new TextFileField[0]);
@ -891,6 +905,14 @@ public class ExtractDataService {
private StepMeta udjc(List<DatasetTableField> datasetTableFields, DatasourceTypes datasourceType) {
String needToChangeColumnType = "";
String handleBinaryTypeCode = "";
for (DatasetTableField datasetTableField : datasetTableFields) {
if(datasetTableField.getDeExtractType() == 5){
handleBinaryTypeCode = handleBinaryTypeCode + "\n" + this.handleBinaryType.replace("FEILD", datasetTableField.getDataeaseName());
}
}
UserDefinedJavaClassMeta userDefinedJavaClassMeta = new UserDefinedJavaClassMeta();
List<UserDefinedJavaClassMeta.FieldInfo> fields = new ArrayList<>();
UserDefinedJavaClassMeta.FieldInfo fieldInfo = new UserDefinedJavaClassMeta.FieldInfo("dataease_uuid", ValueMetaInterface.TYPE_STRING, -1, -1);
@ -906,11 +928,15 @@ public class ExtractDataService {
} else {
Column_Fields = String.join(",", datasetTableFields.stream().map(DatasetTableField::getDataeaseName).collect(Collectors.toList()));
}
if (datasourceType.equals(DatasourceTypes.excel)) {
tmp_code = tmp_code.replace("handleExcelIntColumn", handleExcelIntColumn).replace("Column_Fields", Column_Fields);
} else {
tmp_code = tmp_code.replace("handleExcelIntColumn", "").replace("Column_Fields", Column_Fields);
}
tmp_code = tmp_code.replace("handleBinaryType", handleBinaryTypeCode);
UserDefinedJavaClassDef userDefinedJavaClassDef = new UserDefinedJavaClassDef(UserDefinedJavaClassDef.ClassType.TRANSFORM_CLASS, "Processor", tmp_code);
userDefinedJavaClassDef.setActive(true);
@ -993,6 +1019,12 @@ public class ExtractDataService {
}
}
private static String handleBinaryType = " \t\tif(\"FEILD\".equalsIgnoreCase(filed)){\n" +
" get(Fields.Out, filed).setValue(r, \"\");\n" +
" get(Fields.Out, filed).getValueMeta().setType(2);\n" +
" \t}";
private static String alterColumnTypeCode = " if(\"FILED\".equalsIgnoreCase(filed)){\n" +
"\t if(tmp != null && tmp.equalsIgnoreCase(\"Y\")){\n" +
" get(Fields.Out, filed).setValue(r, 1);\n" +
@ -1049,6 +1081,7 @@ public class ExtractDataService {
" String tmp = get(Fields.In, filed).getString(r);\n" +
"handleWraps \n" +
"alterColumnTypeCode \n" +
"handleBinaryType \n" +
"handleExcelIntColumn \n" +
" str = str + tmp;\n" +
" }\n" +

View File

@ -67,7 +67,7 @@ public class DirectFieldService implements DataSetFieldService {
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "db")) {
datasourceRequest.setTable(dataTableInfoDTO.getTable());
datasourceRequest.setQuery(qp.createQuerySQL(dataTableInfoDTO.getTable(), Collections.singletonList(field), true));
datasourceRequest.setQuery(qp.createQuerySQL(dataTableInfoDTO.getTable(), Collections.singletonList(field), true, ds));
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql")) {
datasourceRequest.setQuery(qp.createQuerySQLAsTmp(dataTableInfoDTO.getSql(), Collections.singletonList(field), true));
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "custom")) {
@ -85,7 +85,7 @@ public class DirectFieldService implements DataSetFieldService {
tableName = "ds_" + datasetTable.getId().replaceAll("-", "_");
datasourceRequest.setTable(tableName);
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
datasourceRequest.setQuery(qp.createQuerySQL(tableName, Collections.singletonList(field), true));
datasourceRequest.setQuery(qp.createQuerySQL(tableName, Collections.singletonList(field), true, null));
}
try {

View File

@ -63,6 +63,23 @@
</el-select>
</el-form-item>
<el-form-item v-if="form.type=='sqlServer'">
<el-button icon="el-icon-plus" size="mini" @click="getSchema()">
{{ $t('datasource.get_schema') }}
</el-button>
</el-form-item>
<el-form-item v-if="form.type=='sqlServer'" :label="$t('datasource.schema')">
<el-select filterable v-model="form.configuration.schema" :placeholder="$t('datasource.please_choose_schema')" class="select-width">
<el-option
v-for="item in schemas"
:key="item"
:label="item"
:value="item"
/>
</el-select>
</el-form-item>
</el-form>
<div v-if="canEdit" slot="footer" class="dialog-footer">
<el-button v-if="formType==='add'?true: hasDataPermission('manage',params.privileges)" @click="validaDatasource">{{ $t('commons.validate') }}</el-button>
@ -105,7 +122,9 @@ export default {
'configuration.host': [{ required: true, message: this.$t('datasource.please_input_host'), trigger: 'change' }],
'configuration.port': [{ required: true, message: this.$t('datasource.please_input_port'), trigger: 'change' }]
},
allTypes: [{ name: 'mysql', label: 'MySQL', type: 'jdbc' }, { name: 'oracle', label: 'Oracle', type: 'jdbc' }],
allTypes: [{ name: 'mysql', label: 'MySQL', type: 'jdbc' },
{ name: 'oracle', label: 'Oracle', type: 'jdbc' },
{ name: 'sqlServer', label: 'SQLSERVER', type: 'jdbc' }],
schemas: [],
canEdit: false,
originConfiguration: {}