forked from github/dataease
feat: kettle 未运行时,禁用抽取数据
This commit is contained in:
parent
1eb4d7f24b
commit
08f0cd24cb
@ -4,6 +4,7 @@ import io.dataease.base.domain.DatasetGroup;
|
||||
import io.dataease.controller.request.dataset.DataSetGroupRequest;
|
||||
import io.dataease.dto.dataset.DataSetGroupDTO;
|
||||
import io.dataease.service.dataset.DataSetGroupService;
|
||||
import io.dataease.service.dataset.ExtractDataService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -18,7 +19,8 @@ import java.util.List;
|
||||
public class DataSetGroupController {
|
||||
@Resource
|
||||
private DataSetGroupService dataSetGroupService;
|
||||
|
||||
@Resource
|
||||
private ExtractDataService extractDataService;
|
||||
@PostMapping("/save")
|
||||
public DataSetGroupDTO save(@RequestBody DatasetGroup datasetGroup) {
|
||||
return dataSetGroupService.save(datasetGroup);
|
||||
@ -38,4 +40,9 @@ public class DataSetGroupController {
|
||||
public DatasetGroup getScene(@PathVariable String id) {
|
||||
return dataSetGroupService.getScene(id);
|
||||
}
|
||||
|
||||
@PostMapping("/isKettleRunning")
|
||||
public boolean isKettleRunning(){
|
||||
return extractDataService.isKettleRunning();
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,15 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.pentaho.di.cluster.SlaveServer;
|
||||
import org.pentaho.di.core.database.DatabaseMeta;
|
||||
import org.pentaho.di.core.row.ValueMetaInterface;
|
||||
import org.pentaho.di.core.util.HttpClientManager;
|
||||
import org.pentaho.di.core.util.Utils;
|
||||
import org.pentaho.di.job.Job;
|
||||
import org.pentaho.di.job.JobExecutionConfiguration;
|
||||
import org.pentaho.di.job.JobHopMeta;
|
||||
@ -54,7 +60,10 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.naming.AuthenticationException;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@ -529,6 +538,31 @@ public class ExtractDataService {
|
||||
return userDefinedJavaClassStep;
|
||||
}
|
||||
|
||||
public boolean isKettleRunning(){
|
||||
try {
|
||||
if (InetAddress.getByName(carte).isReachable(1000)) {
|
||||
HttpClient httpClient;
|
||||
HttpGet getMethod = new HttpGet( "http://" + carte + ":" + port);
|
||||
HttpClientManager.HttpClientBuilderFacade clientBuilder = HttpClientManager.getInstance().createBuilder();
|
||||
clientBuilder.setConnectionTimeout(1);
|
||||
clientBuilder.setCredentials(user, passwd);
|
||||
httpClient = clientBuilder.build();
|
||||
HttpResponse httpResponse = httpClient.execute( getMethod );
|
||||
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
||||
if ( statusCode != -1 ) {
|
||||
if ( statusCode == HttpStatus.SC_UNAUTHORIZED ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}catch (Exception e){
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String code = "import org.pentaho.di.core.row.ValueMetaInterface;\n" +
|
||||
"import java.util.List;\n" +
|
||||
"import java.io.File;\n" +
|
||||
|
@ -119,4 +119,12 @@ export function fieldValues(fieldId) {
|
||||
})
|
||||
}
|
||||
|
||||
export function isKettleRunning() {
|
||||
return request({
|
||||
url: '/dataset/group/isKettleRunning',
|
||||
method: 'post',
|
||||
loading: true
|
||||
})
|
||||
}
|
||||
|
||||
export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree }
|
||||
|
@ -811,7 +811,8 @@ export default {
|
||||
target_table: '被关联表',
|
||||
target_field: '被关联字段',
|
||||
union_relation: '关联关系',
|
||||
pls_setting_union_success: '请正确设置关联关系'
|
||||
pls_setting_union_success: '请正确设置关联关系',
|
||||
invalid_dataset:'Kettle未运行,无效数据集'
|
||||
},
|
||||
datasource: {
|
||||
datasource: '数据源',
|
||||
|
@ -28,8 +28,8 @@
|
||||
</el-form-item>
|
||||
<el-form-item class="form-item">
|
||||
<el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini">
|
||||
<el-option :label="$t('dataset.direct_connect')" value="0" />
|
||||
<el-option :label="$t('dataset.sync_data')" value="1" />
|
||||
<el-option :label="$t('dataset.direct_connect')" value="0" />
|
||||
<el-option :label="$t('dataset.sync_data')" value="1" :disabled="!isKettleRunning"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item class="form-item" style="float: right;">
|
||||
@ -66,6 +66,10 @@ export default {
|
||||
param: {
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
isKettleRunning: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
@ -33,7 +33,7 @@
|
||||
<el-form-item class="form-item">
|
||||
<el-select v-model="mode" filterable :placeholder="$t('dataset.connect_mode')" size="mini">
|
||||
<el-option :label="$t('dataset.direct_connect')" value="0" />
|
||||
<el-option :label="$t('dataset.sync_data')" value="1" />
|
||||
<el-option :label="$t('dataset.sync_data')" value="1" :disabled="!isKettleRunning" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@ -121,6 +121,10 @@ export default {
|
||||
param: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
isKettleRunning: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
@ -103,12 +103,13 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { post } from '@/api/dataset/dataset'
|
||||
import {isKettleRunning, post} from '@/api/dataset/dataset'
|
||||
|
||||
export default {
|
||||
name: 'DatasetGroupSelector',
|
||||
data() {
|
||||
return {
|
||||
isKettleRunning: false,
|
||||
sceneMode: false,
|
||||
search: '',
|
||||
data: [],
|
||||
@ -132,10 +133,6 @@ export default {
|
||||
},
|
||||
computed: {},
|
||||
watch: {
|
||||
// search(val){
|
||||
// this.groupForm.name = val;
|
||||
// this.tree(this.groupForm);
|
||||
// }
|
||||
search(val) {
|
||||
if (val && val !== '') {
|
||||
this.tableData = JSON.parse(JSON.stringify(this.tables.filter(ele => { return ele.name.includes(val) })))
|
||||
@ -152,7 +149,15 @@ export default {
|
||||
this.tree(this.groupForm)
|
||||
this.tableTree()
|
||||
},
|
||||
created(){
|
||||
this.kettleRunning()
|
||||
},
|
||||
methods: {
|
||||
kettleRunning(){
|
||||
isKettleRunning().then(res => {
|
||||
this.isKettleRunning = res.data
|
||||
})
|
||||
},
|
||||
close() {
|
||||
this.editGroup = false
|
||||
this.groupForm = {
|
||||
@ -186,14 +191,17 @@ export default {
|
||||
sceneId: this.currGroup.id
|
||||
}).then(response => {
|
||||
this.tables = response.data
|
||||
for (let i = 0; i < this.tables.length; i++) {
|
||||
if(this.tables[i].mode===1 && this.isKettleRunning === false){
|
||||
this.$set(this.tables[i],"disabled",true)
|
||||
}
|
||||
}
|
||||
this.tableData = JSON.parse(JSON.stringify(this.tables))
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
nodeClick(data, node) {
|
||||
// console.log(data);
|
||||
// console.log(node);
|
||||
if (data.type === 'scene') {
|
||||
this.sceneMode = true
|
||||
this.currGroup = data
|
||||
@ -215,7 +223,14 @@ export default {
|
||||
},
|
||||
|
||||
sceneClick(data, node) {
|
||||
// console.log(data);
|
||||
if(data.disabled){
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: this.$t('dataset.invalid_dataset'),
|
||||
showClose: true
|
||||
})
|
||||
return
|
||||
}
|
||||
this.$emit('getTable', data)
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +242,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree } from '@/api/dataset/dataset'
|
||||
import { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree, isKettleRunning} from '@/api/dataset/dataset'
|
||||
|
||||
export default {
|
||||
name: 'Group',
|
||||
@ -288,16 +288,11 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
sceneData: function() {
|
||||
console.log(this.$store.state.dataset.sceneData + ' do post')
|
||||
this.tableTree()
|
||||
return this.$store.state.dataset.sceneData
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// search(val){
|
||||
// this.groupForm.name = val;
|
||||
// this.tree(this.groupForm);
|
||||
// }
|
||||
search(val) {
|
||||
if (val && val !== '') {
|
||||
this.tableData = JSON.parse(JSON.stringify(this.tables.filter(ele => { return ele.name.includes(val) })))
|
||||
@ -310,9 +305,16 @@ export default {
|
||||
this.tree(this.groupForm)
|
||||
this.refresh()
|
||||
this.tableTree()
|
||||
// this.$router.push('/dataset');
|
||||
},
|
||||
created(){
|
||||
this.kettleRunning()
|
||||
},
|
||||
methods: {
|
||||
kettleRunning(){
|
||||
isKettleRunning().then(res => {
|
||||
this.isKettleRunning = res.data
|
||||
})
|
||||
},
|
||||
clickAdd(param) {
|
||||
// console.log(param);
|
||||
this.add(param.type)
|
||||
@ -552,7 +554,7 @@ export default {
|
||||
},
|
||||
|
||||
addData(name) {
|
||||
this.$emit('switchComponent', { name: name, param: this.currGroup })
|
||||
this.$emit('switchComponent', { name: name, param: this.currGroup, isKettleRunning: this.isKettleRunning})
|
||||
},
|
||||
|
||||
sceneClick(data, node) {
|
||||
|
Loading…
Reference in New Issue
Block a user