提交 a1e0bf91 authored 作者: wangjiahao's avatar wangjiahao

Merge remote-tracking branch 'origin/v1.8' into v1.8

...@@ -12,13 +12,14 @@ public class MongodbConfiguration extends JdbcConfiguration { ...@@ -12,13 +12,14 @@ public class MongodbConfiguration extends JdbcConfiguration {
private String connectionType; private String connectionType;
private String extraParams = "rebuildschema=true"; private String extraParams = "rebuildschema=true";
public String getJdbc() { public String getJdbc(String dsId) {
if(StringUtils.isEmpty(extraParams.trim())){ if(StringUtils.isEmpty(extraParams.trim()) && StringUtils.isEmpty(dsId)){
return "jdbc:mongodb://HOSTNAME:PORT/DATABASE" return "jdbc:mongodb://HOSTNAME:PORT/DATABASE"
.replace("HOSTNAME", getHost().trim()) .replace("HOSTNAME", getHost().trim())
.replace("PORT", getPort().toString().trim()) .replace("PORT", getPort().toString().trim())
.replace("DATABASE", getDataBase().trim()); .replace("DATABASE", getDataBase().trim());
}else { }else {
this.extraParams = StringUtils.isEmpty(dsId) ? getExtraParams().trim() : getExtraParams().trim() + "&schema=" + dsId +".xml";
return "jdbc:mongodb://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS" return "jdbc:mongodb://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS"
.replace("HOSTNAME", getHost().trim()) .replace("HOSTNAME", getHost().trim())
.replace("PORT", getPort().toString().trim()) .replace("PORT", getPort().toString().trim())
......
...@@ -99,11 +99,18 @@ public class EsProvider extends DatasourceProvider { ...@@ -99,11 +99,18 @@ public class EsProvider extends DatasourceProvider {
@Override @Override
public List<TableField> getTableFileds(DatasourceRequest datasourceRequest) throws Exception { public List<TableField> getTableFileds(DatasourceRequest datasourceRequest) throws Exception {
QueryProvider qp = ProviderFactory.getQueryProvider(datasourceRequest.getDatasource().getType()); datasourceRequest.setQuery("desc " + datasourceRequest.getTable());
datasourceRequest.setQuery(qp.convertTableToSql(datasourceRequest.getTable(), datasourceRequest.getDatasource())); List<TableField> tableFields = new ArrayList<>();
return fetchResultField(datasourceRequest); try {
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "?format=json");
tableFields = fetchResultField4Table(response);
} catch (Exception e) {
DataEaseException.throwException(e);
}
return tableFields;
} }
private List<String[]> fetchResult(String response) throws Exception { private List<String[]> fetchResult(String response) throws Exception {
EsReponse esReponse = new Gson().fromJson(response, EsReponse.class); EsReponse esReponse = new Gson().fromJson(response, EsReponse.class);
return fetchResult(esReponse); return fetchResult(esReponse);
...@@ -166,6 +173,26 @@ public class EsProvider extends DatasourceProvider { ...@@ -166,6 +173,26 @@ public class EsProvider extends DatasourceProvider {
return fieldList; return fieldList;
} }
private List<TableField> fetchResultField4Table(String response) throws Exception {
List<TableField> fieldList = new ArrayList<>();
EsReponse esReponse = new Gson().fromJson(response, EsReponse.class);
if (esReponse.getError() != null) {
throw new Exception(esReponse.getError().getReason());
}
for (String[] row : esReponse.getRows()) {
if(!row[1].equalsIgnoreCase("STRUCT")){
TableField field = new TableField();
field.setFieldName(row[0]);
field.setRemarks(row[0]);
field.setFieldType(row[2]);
field.setFieldSize(EsQueryProvider.transFieldTypeSize(row[2]));
fieldList.add(field);
}
}
return fieldList;
}
@Override @Override
public Map<String, List> fetchResultAndField(DatasourceRequest datasourceRequest) throws Exception { public Map<String, List> fetchResultAndField(DatasourceRequest datasourceRequest) throws Exception {
Map<String, List> result = new HashMap<>(); Map<String, List> result = new HashMap<>();
......
...@@ -403,6 +403,9 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -403,6 +403,9 @@ public class JdbcProvider extends DatasourceProvider {
} }
private Connection getConnectionFromPool(DatasourceRequest datasourceRequest) throws Exception { private Connection getConnectionFromPool(DatasourceRequest datasourceRequest) throws Exception {
if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.mongo.name())){
return getConnection(datasourceRequest);
}
DruidDataSource dataSource = jdbcConnection.get(datasourceRequest.getDatasource().getId()); DruidDataSource dataSource = jdbcConnection.get(datasourceRequest.getDatasource().getId());
if (dataSource == null) { if (dataSource == null) {
handleDatasource(datasourceRequest, "add"); handleDatasource(datasourceRequest, "add");
...@@ -464,7 +467,7 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -464,7 +467,7 @@ public class JdbcProvider extends DatasourceProvider {
username = mongodbConfiguration.getUsername(); username = mongodbConfiguration.getUsername();
password = mongodbConfiguration.getPassword(); password = mongodbConfiguration.getPassword();
driver = mongodbConfiguration.getDriver(); driver = mongodbConfiguration.getDriver();
jdbcurl = mongodbConfiguration.getJdbc(); jdbcurl = mongodbConfiguration.getJdbc(datasourceRequest.getDatasource().getId());
break; break;
case redshift: case redshift:
RedshiftConfigration redshiftConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), RedshiftConfigration.class); RedshiftConfigration redshiftConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), RedshiftConfigration.class);
...@@ -563,7 +566,7 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -563,7 +566,7 @@ public class JdbcProvider extends DatasourceProvider {
case mongo: case mongo:
MongodbConfiguration mongodbConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), MongodbConfiguration.class); MongodbConfiguration mongodbConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), MongodbConfiguration.class);
dataSource.setDriverClassName(mongodbConfiguration.getDriver()); dataSource.setDriverClassName(mongodbConfiguration.getDriver());
dataSource.setUrl(mongodbConfiguration.getJdbc()); dataSource.setUrl(mongodbConfiguration.getJdbc(datasourceRequest.getDatasource().getId()));
jdbcConfiguration = mongodbConfiguration; jdbcConfiguration = mongodbConfiguration;
break; break;
case redshift: case redshift:
......
...@@ -1629,7 +1629,7 @@ public class DataSetTableService { ...@@ -1629,7 +1629,7 @@ public class DataSetTableService {
datasetTableField.setDeExtractType(transFieldType(filed.getFieldType())); datasetTableField.setDeExtractType(transFieldType(filed.getFieldType()));
} else { } else {
Integer fieldType = qp.transFieldType(filed.getFieldType()); Integer fieldType = qp.transFieldType(filed.getFieldType());
datasetTableField.setDeType(fieldType == 4 ? 2 : fieldType); datasetTableField.setDeType(fieldType == 4 ? 2 : (fieldType == 6 ? 0 : fieldType));
datasetTableField.setDeExtractType(fieldType); datasetTableField.setDeExtractType(fieldType);
} }
datasetTableField.setSize(filed.getFieldSize()); datasetTableField.setSize(filed.getFieldSize());
...@@ -1637,7 +1637,7 @@ public class DataSetTableService { ...@@ -1637,7 +1637,7 @@ public class DataSetTableService {
datasetTableField.setColumnIndex(i); datasetTableField.setColumnIndex(i);
datasetTableField.setLastSyncTime(syncTime); datasetTableField.setLastSyncTime(syncTime);
datasetTableField.setExtField(0); datasetTableField.setExtField(0);
datasetTableField.setGroupType(datasetTableField.getDeType() < 2 ? "d" : "q"); datasetTableField.setGroupType((datasetTableField.getDeType() < 2 || datasetTableField.getDeType() == 6) ? "d" : "q");
} }
dataSetTableFieldsService.save(datasetTableField); dataSetTableFieldsService.save(datasetTableField);
} }
......
...@@ -1952,13 +1952,17 @@ export default { ...@@ -1952,13 +1952,17 @@ export default {
} }
} }
}, },
dragMoveDuplicate(list, e) { dragMoveDuplicate(list, e, mode) {
const that = this if (mode === 'ds') {
const dup = list.filter(function(m) {
return m.id === that.moveId
})
if (dup && dup.length > 1) {
list.splice(e.newDraggableIndex, 1) list.splice(e.newDraggableIndex, 1)
} else {
const that = this
const dup = list.filter(function(m) {
return m.id === that.moveId
})
if (dup && dup.length > 1) {
list.splice(e.newDraggableIndex, 1)
}
} }
}, },
addXaxis(e) { addXaxis(e) {
...@@ -1998,13 +2002,11 @@ export default { ...@@ -1998,13 +2002,11 @@ export default {
this.calcData(true) this.calcData(true)
}, },
moveToDimension(e) { moveToDimension(e) {
this.dragCheckType(this.dimensionData, 'd') this.dragMoveDuplicate(this.dimensionData, e, 'ds')
this.dragMoveDuplicate(this.dimensionData, e)
this.calcData(true) this.calcData(true)
}, },
moveToQuota(e) { moveToQuota(e) {
this.dragCheckType(this.quotaData, 'q') this.dragMoveDuplicate(this.quotaData, e, 'ds')
this.dragMoveDuplicate(this.quotaData, e)
this.calcData(true) this.calcData(true)
}, },
addCustomFilter(e) { addCustomFilter(e) {
......
...@@ -72,8 +72,8 @@ ...@@ -72,8 +72,8 @@
</el-option> </el-option>
</el-select> </el-select>
<span style="margin-left: 8px;"> <span style="margin-left: 8px;">
<span v-if="scope.row.deType === 0"> <span v-if="scope.row.deType === 0 || scope.row.deType === 6">
<svg-icon v-if="scope.row.deType === 0" icon-class="field_text" class="field-icon-text" /> <svg-icon v-if="scope.row.deType === 0 || scope.row.deType === 6" icon-class="field_text" class="field-icon-text" />
<span class="field-class">{{ $t('dataset.text') }}</span> <span class="field-class">{{ $t('dataset.text') }}</span>
</span> </span>
<span v-if="scope.row.deType === 1"> <span v-if="scope.row.deType === 1">
...@@ -95,8 +95,8 @@ ...@@ -95,8 +95,8 @@
<el-table-column property="deExtractType" :label="$t('dataset.origin_field_type')" width="100"> <el-table-column property="deExtractType" :label="$t('dataset.origin_field_type')" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="scope.row.extField === 0"> <span v-if="scope.row.extField === 0">
<span v-if="scope.row.deExtractType === 0"> <span v-if="scope.row.deExtractType === 0 || scope.row.deExtractType === 6">
<svg-icon v-if="scope.row.deExtractType === 0" icon-class="field_text" class="field-icon-text" /> <svg-icon v-if="scope.row.deExtractType === 0 || scope.row.deExtractType === 6" icon-class="field_text" class="field-icon-text" />
<span class="field-class">{{ $t('dataset.text') }}</span> <span class="field-class">{{ $t('dataset.text') }}</span>
</span> </span>
<span v-if="scope.row.deExtractType === 1"> <span v-if="scope.row.deExtractType === 1">
......
...@@ -253,7 +253,7 @@ ...@@ -253,7 +253,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-collapse v-if="form.configuration.dataSourceType=='jdbc' && form.type !== 'api'"> <el-collapse v-if="form.configuration.dataSourceType=='jdbc' && form.type !== 'api' && form.type !== 'mongo'">
<el-collapse-item :title="$t('datasource.priority')" name="1"> <el-collapse-item :title="$t('datasource.priority')" name="1">
<el-form-item :label="$t('datasource.initial_pool_size')" prop="configuration.initialPoolSize"> <el-form-item :label="$t('datasource.initial_pool_size')" prop="configuration.initialPoolSize">
<el-input v-model="form.configuration.initialPoolSize" autocomplete="off" type="number" min="0" <el-input v-model="form.configuration.initialPoolSize" autocomplete="off" type="number" min="0"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论