Amy0104
3 years ago
committed by
GitHub
22 changed files with 1636 additions and 299 deletions
@ -0,0 +1,192 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
import { Ref } from 'vue' |
||||
import { useI18n } from 'vue-i18n' |
||||
import type { IJsonItem } from '../types' |
||||
|
||||
export function useCustomParams({ |
||||
model, |
||||
field, |
||||
isSimple, |
||||
name = 'custom_parameters', |
||||
span = 24 |
||||
}: { |
||||
model: { [field: string]: any } |
||||
field: string |
||||
isSimple: boolean |
||||
name?: string |
||||
span?: Ref | number |
||||
}): IJsonItem[] { |
||||
const { t } = useI18n() |
||||
|
||||
if (isSimple) { |
||||
return [ |
||||
{ |
||||
type: 'custom-parameters', |
||||
field: field, |
||||
name: t(`project.node.${name}`), |
||||
span, |
||||
children: [ |
||||
{ |
||||
type: 'input', |
||||
field: 'prop', |
||||
span: 10, |
||||
props: { |
||||
placeholder: t('project.node.prop_tips'), |
||||
maxLength: 256 |
||||
}, |
||||
validate: { |
||||
trigger: ['input', 'blur'], |
||||
required: true, |
||||
validator(validate: any, value: string) { |
||||
if (!value) { |
||||
return new Error(t('project.node.prop_tips')) |
||||
} |
||||
|
||||
const sameItems = model.localParams.filter( |
||||
(item: { prop: string }) => item.prop === value |
||||
) |
||||
|
||||
if (sameItems.length > 1) { |
||||
return new Error(t('project.node.prop_repeat')) |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'value', |
||||
span: 10, |
||||
props: { |
||||
placeholder: t('project.node.value_tips'), |
||||
maxLength: 256 |
||||
} |
||||
} |
||||
] |
||||
} |
||||
] |
||||
} else { |
||||
return [ |
||||
{ |
||||
type: 'custom-parameters', |
||||
field: field, |
||||
name: t(`project.node.${name}`), |
||||
span, |
||||
children: [ |
||||
{ |
||||
type: 'input', |
||||
field: 'prop', |
||||
span: 6, |
||||
props: { |
||||
placeholder: t('project.node.prop_tips'), |
||||
maxLength: 256 |
||||
}, |
||||
validate: { |
||||
trigger: ['input', 'blur'], |
||||
required: true, |
||||
validator(validate: any, value: string) { |
||||
if (!value) { |
||||
return new Error(t('project.node.prop_tips')) |
||||
} |
||||
|
||||
const sameItems = model.localParams.filter( |
||||
(item: { prop: string }) => item.prop === value |
||||
) |
||||
|
||||
if (sameItems.length > 1) { |
||||
return new Error(t('project.node.prop_repeat')) |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
type: 'select', |
||||
field: 'direct', |
||||
span: 4, |
||||
options: DIRECT_LIST, |
||||
value: 'IN' |
||||
}, |
||||
{ |
||||
type: 'select', |
||||
field: 'type', |
||||
span: 6, |
||||
options: TYPE_LIST, |
||||
value: 'VARCHAR' |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'value', |
||||
span: 6, |
||||
props: { |
||||
placeholder: t('project.node.value_tips'), |
||||
maxLength: 256 |
||||
} |
||||
} |
||||
] |
||||
} |
||||
] |
||||
} |
||||
} |
||||
export const TYPE_LIST = [ |
||||
{ |
||||
value: 'VARCHAR', |
||||
label: 'VARCHAR' |
||||
}, |
||||
{ |
||||
value: 'INTEGER', |
||||
label: 'INTEGER' |
||||
}, |
||||
{ |
||||
value: 'LONG', |
||||
label: 'LONG' |
||||
}, |
||||
{ |
||||
value: 'FLOAT', |
||||
label: 'FLOAT' |
||||
}, |
||||
{ |
||||
value: 'DOUBLE', |
||||
label: 'DOUBLE' |
||||
}, |
||||
{ |
||||
value: 'DATE', |
||||
label: 'DATE' |
||||
}, |
||||
{ |
||||
value: 'TIME', |
||||
label: 'TIME' |
||||
}, |
||||
{ |
||||
value: 'TIMESTAMP', |
||||
label: 'TIMESTAMP' |
||||
}, |
||||
{ |
||||
value: 'BOOLEAN', |
||||
label: 'BOOLEAN' |
||||
} |
||||
] |
||||
|
||||
export const DIRECT_LIST = [ |
||||
{ |
||||
value: 'IN', |
||||
label: 'IN' |
||||
}, |
||||
{ |
||||
value: 'OUT', |
||||
label: 'OUT' |
||||
} |
||||
] |
@ -0,0 +1,85 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
import { onMounted, ref, unref, Ref } from 'vue' |
||||
import { queryDataSourceList } from '@/service/modules/data-source' |
||||
import { useI18n } from 'vue-i18n' |
||||
import type { IJsonItem, IDataBase } from '../types' |
||||
|
||||
export function useDatasource( |
||||
model: { [field: string]: any }, |
||||
span: Ref, |
||||
fieldType: string, |
||||
fieldDatasource: string |
||||
): IJsonItem[] { |
||||
const { t } = useI18n() |
||||
const dataSourceList = ref([]) |
||||
const loading = ref(false) |
||||
|
||||
const getDataSource = async (type: IDataBase) => { |
||||
if (loading.value) return |
||||
loading.value = true |
||||
try { |
||||
const result = await queryDataSourceList({ type }) |
||||
dataSourceList.value = result.map( |
||||
(item: { name: string; id: number }) => ({ |
||||
label: item.name, |
||||
value: item.id |
||||
}) |
||||
) |
||||
loading.value = false |
||||
} catch (err) { |
||||
loading.value = false |
||||
} |
||||
} |
||||
onMounted(() => { |
||||
getDataSource('MYSQL') |
||||
}) |
||||
|
||||
return [ |
||||
{ |
||||
type: 'select', |
||||
field: fieldType, |
||||
name: t('project.node.datasource'), |
||||
span: span, |
||||
options: [{ label: 'MYSQL', value: 'MYSQL' }], |
||||
validate: { |
||||
required: unref(span) !== 0 |
||||
} |
||||
}, |
||||
{ |
||||
type: 'select', |
||||
field: fieldDatasource, |
||||
name: ' ', |
||||
span: span, |
||||
props: { |
||||
placeholder: t('project.node.datasource_tips'), |
||||
filterable: true, |
||||
loading |
||||
}, |
||||
options: dataSourceList, |
||||
validate: { |
||||
trigger: ['blur', 'input'], |
||||
validator(validate, value) { |
||||
if (!value) { |
||||
return new Error(t('project.node.datasource_tips')) |
||||
} |
||||
} |
||||
} |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,282 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
import { ref, h, watch, computed, unref } from 'vue' |
||||
import { useI18n } from 'vue-i18n' |
||||
import { useDatasource } from './use-sqoop-datasource' |
||||
import { useCustomParams } from '.' |
||||
import styles from '../index.module.scss' |
||||
import type { IJsonItem, IOption, ModelType } from '../types' |
||||
|
||||
export function useSourceType(model: { [field: string]: any }): IJsonItem[] { |
||||
const { t } = useI18n() |
||||
const unCustomSpan = computed(() => (model.isCustomTask ? 0 : 24)) |
||||
const tableSpan = computed(() => |
||||
model.sourceType === 'MYSQL' && model.srcQueryType === '0' ? 24 : 0 |
||||
) |
||||
const editorSpan = computed(() => |
||||
model.sourceType === 'MYSQL' && model.srcQueryType === '1' ? 24 : 0 |
||||
) |
||||
const columnSpan = computed(() => |
||||
model.sourceType === 'MYSQL' && model.srcColumnType === '1' ? 24 : 0 |
||||
) |
||||
const mysqlSpan = computed(() => (model.sourceType === 'MYSQL' ? 24 : 0)) |
||||
const hiveSpan = computed(() => (model.sourceType === 'HIVE' ? 24 : 0)) |
||||
const hdfsSpan = computed(() => (model.sourceType === 'HDFS' ? 24 : 0)) |
||||
const datasourceSpan = computed(() => (model.sourceType === 'MYSQL' ? 12 : 0)) |
||||
|
||||
const sourceTypes = ref([ |
||||
{ |
||||
label: 'MYSQL', |
||||
value: 'MYSQL' |
||||
} |
||||
] as IOption[]) |
||||
|
||||
const getSourceTypesByModelType = (modelType: ModelType): IOption[] => { |
||||
switch (modelType) { |
||||
case 'import': |
||||
return [ |
||||
{ |
||||
label: 'MYSQL', |
||||
value: 'MYSQL' |
||||
} |
||||
] |
||||
case 'export': |
||||
return [ |
||||
{ |
||||
label: 'HDFS', |
||||
value: 'HDFS' |
||||
}, |
||||
{ |
||||
label: 'HIVE', |
||||
value: 'HIVE' |
||||
} |
||||
] |
||||
default: |
||||
return [ |
||||
{ |
||||
label: 'MYSQL', |
||||
value: 'MYSQL' |
||||
}, |
||||
{ |
||||
label: 'HDFS', |
||||
value: 'HDFS' |
||||
}, |
||||
{ |
||||
label: 'HIVE', |
||||
value: 'HIVE' |
||||
} |
||||
] |
||||
} |
||||
} |
||||
|
||||
watch( |
||||
() => model.modelType, |
||||
(modelType: ModelType) => { |
||||
getSourceTypesByModelType(modelType) |
||||
} |
||||
) |
||||
|
||||
return [ |
||||
{ |
||||
type: 'custom', |
||||
field: 'custom-title', |
||||
span: unCustomSpan, |
||||
widget: h( |
||||
'div', |
||||
{ class: styles['field-title'] }, |
||||
t('project.node.data_source') |
||||
) |
||||
}, |
||||
{ |
||||
type: 'select', |
||||
field: 'sourceType', |
||||
name: t('project.node.type'), |
||||
span: unCustomSpan, |
||||
options: sourceTypes |
||||
}, |
||||
...useDatasource( |
||||
model, |
||||
datasourceSpan, |
||||
'sourceMysqlType', |
||||
'sourceMysqlDatasource' |
||||
), |
||||
{ |
||||
type: 'radio', |
||||
field: 'srcQueryType', |
||||
name: t('project.node.model_type'), |
||||
span: mysqlSpan, |
||||
options: [ |
||||
{ |
||||
label: t('project.node.form'), |
||||
value: '0' |
||||
}, |
||||
{ |
||||
label: 'SQL', |
||||
value: '1' |
||||
} |
||||
] |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'srcTable', |
||||
name: t('project.node.table'), |
||||
span: tableSpan, |
||||
props: { |
||||
placeholder: t('project.node.table_tips') |
||||
}, |
||||
validate: { |
||||
trigger: ['input', 'blur'], |
||||
required: !!unref(tableSpan), |
||||
validator(validate, value) { |
||||
if (!!unref(tableSpan) && !value) { |
||||
return new Error(t('project.node.table_tips')) |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
type: 'radio', |
||||
field: 'srcColumnType', |
||||
name: t('project.node.column_type'), |
||||
span: tableSpan, |
||||
options: [ |
||||
{ label: t('project.node.all_columns'), value: '0' }, |
||||
{ label: t('project.node.some_columns'), value: '1' } |
||||
] |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'srcColumns', |
||||
name: t('project.node.column'), |
||||
span: columnSpan, |
||||
props: { |
||||
placeholder: t('project.node.column_tips') |
||||
}, |
||||
validate: { |
||||
trigger: ['input', 'blur'], |
||||
required: !!unref(columnSpan), |
||||
validator(validate, value) { |
||||
if (!!unref(columnSpan) && !value) { |
||||
return new Error(t('project.node.column_tips')) |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'sourceHiveDatabase', |
||||
name: t('project.node.database'), |
||||
span: hiveSpan, |
||||
props: { |
||||
placeholder: t('project.node.database_tips') |
||||
}, |
||||
validate: { |
||||
trigger: ['blur', 'input'], |
||||
required: !!unref(hiveSpan), |
||||
validator(validate, value) { |
||||
if (!!unref(hiveSpan) && !value) { |
||||
return new Error(t('project.node.database_tips')) |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'sourceHiveTable', |
||||
name: t('project.node.table'), |
||||
span: hiveSpan, |
||||
props: { |
||||
placeholder: t('project.node.hive_table_tips') |
||||
}, |
||||
validate: { |
||||
trigger: ['blur', 'input'], |
||||
required: !!unref(hiveSpan), |
||||
validator(validate, value) { |
||||
if (!!unref(hiveSpan) && !value) { |
||||
return new Error(t('project.node.hive_table_tips')) |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'sourceHivePartitionKey', |
||||
name: t('project.node.hive_partition_keys'), |
||||
span: hiveSpan, |
||||
props: { |
||||
placeholder: t('project.node.hive_partition_keys_tips') |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'sourceHivePartitionValue', |
||||
name: t('project.node.hive_partition_values'), |
||||
span: hiveSpan, |
||||
props: { |
||||
placeholder: t('project.node.hive_partition_values_tips') |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'sourceHdfsExportDir', |
||||
name: t('project.node.export_dir'), |
||||
span: hdfsSpan, |
||||
props: { |
||||
placeholder: t('project.node.export_dir_tips') |
||||
}, |
||||
validate: { |
||||
trigger: ['blur', 'input'], |
||||
required: !!unref(hdfsSpan), |
||||
validator(validate, value) { |
||||
if (!!unref(hdfsSpan) && !value) { |
||||
return new Error(t('project.node.export_dir_tips')) |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
type: 'editor', |
||||
field: 'sourceMysqlSrcQuerySql', |
||||
name: t('project.node.sql_statement'), |
||||
span: editorSpan, |
||||
validate: { |
||||
trigger: ['blur', 'input'], |
||||
required: !!unref(editorSpan), |
||||
validator(validate, value) { |
||||
if (!!unref(editorSpan) && !value) { |
||||
return new Error(t('project.node.sql_statement_tips')) |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
...useCustomParams({ |
||||
model, |
||||
field: 'mapColumnHive', |
||||
name: 'map_column_hive', |
||||
isSimple: true, |
||||
span: editorSpan |
||||
}), |
||||
...useCustomParams({ |
||||
model, |
||||
field: 'mapColumnJava', |
||||
name: 'map_column_java', |
||||
isSimple: true, |
||||
span: editorSpan |
||||
}) |
||||
] |
||||
} |
@ -0,0 +1,384 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
import { ref, h, watch, computed, unref } from 'vue' |
||||
import { useI18n } from 'vue-i18n' |
||||
import { useDatasource } from './use-sqoop-datasource' |
||||
import styles from '../index.module.scss' |
||||
import type { IJsonItem, IOption, SourceType } from '../types' |
||||
|
||||
export function useTargetType(model: { [field: string]: any }): IJsonItem[] { |
||||
const { t } = useI18n() |
||||
const unCustomSpan = computed(() => (model.isCustomTask ? 0 : 24)) |
||||
const hiveSpan = computed(() => (model.targetType === 'HIVE' ? 24 : 0)) |
||||
const hdfsSpan = computed(() => (model.targetType === 'HDFS' ? 24 : 0)) |
||||
const mysqlSpan = computed(() => (model.targetType === 'MYSQL' ? 24 : 0)) |
||||
const dataSourceSpan = computed(() => (model.targetType === 'MYSQL' ? 12 : 0)) |
||||
const updateSpan = computed(() => |
||||
model.targetType === 'MYSQL' && model.isUpdate ? 24 : 0 |
||||
) |
||||
|
||||
const targetTypes = ref([ |
||||
{ |
||||
label: 'HIVE', |
||||
value: 'HIVE' |
||||
}, |
||||
{ |
||||
label: 'HDFS', |
||||
value: 'HDFS' |
||||
} |
||||
] as IOption[]) |
||||
|
||||
const getTargetTypesBySourceType = ( |
||||
sourceType: SourceType, |
||||
srcQueryType: string |
||||
): IOption[] => { |
||||
switch (sourceType) { |
||||
case 'MYSQL': |
||||
if (srcQueryType === '1') { |
||||
return [ |
||||
{ |
||||
label: 'HDFS', |
||||
value: 'HDFS' |
||||
} |
||||
] |
||||
} |
||||
return [ |
||||
{ |
||||
label: 'HDFS', |
||||
value: 'HDFS' |
||||
}, |
||||
{ |
||||
label: 'HIVE', |
||||
value: 'HIVE' |
||||
} |
||||
] |
||||
case 'HDFS': |
||||
case 'HIVE': |
||||
return [ |
||||
{ |
||||
label: 'MYSQL', |
||||
value: 'MYSQL' |
||||
} |
||||
] |
||||
default: |
||||
return [ |
||||
{ |
||||
label: 'HDFS', |
||||
value: 'HDFS' |
||||
}, |
||||
{ |
||||
label: 'HIVE', |
||||
value: 'HIVE' |
||||
} |
||||
] |
||||
} |
||||
} |
||||
|
||||
watch( |
||||
() => [model.sourceType, model.srcQueryType], |
||||
([sourceType, srcQueryType]) => { |
||||
console.log(sourceType, srcQueryType) |
||||
getTargetTypesBySourceType(sourceType, srcQueryType) |
||||
} |
||||
) |
||||
|
||||
return [ |
||||
{ |
||||
type: 'custom', |
||||
field: 'custom-title', |
||||
span: unCustomSpan, |
||||
widget: h( |
||||
'div', |
||||
{ class: styles['field-title'] }, |
||||
t('project.node.data_target') |
||||
) |
||||
}, |
||||
{ |
||||
type: 'select', |
||||
field: 'targetType', |
||||
name: t('project.node.type'), |
||||
span: unCustomSpan, |
||||
options: targetTypes |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'targetHiveDatabase', |
||||
name: t('project.node.database'), |
||||
span: hiveSpan, |
||||
props: { |
||||
placeholder: t('project.node.database_tips') |
||||
}, |
||||
validate: { |
||||
trigger: ['blur', 'input'], |
||||
required: !!unref(hiveSpan), |
||||
validator(validate, value) { |
||||
if (!!unref(hiveSpan) && !value) { |
||||
return new Error(t('project.node.database_tips')) |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'targetHiveTable', |
||||
name: t('project.node.database'), |
||||
span: hiveSpan, |
||||
props: { |
||||
placeholder: t('project.node.table') |
||||
}, |
||||
validate: { |
||||
trigger: ['blur', 'input'], |
||||
required: !!unref(hiveSpan), |
||||
validator(rule, value) { |
||||
if (!!unref(hiveSpan) && !value) { |
||||
return new Error(t('project.node.hive_table_tips')) |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
type: 'switch', |
||||
field: 'targetHiveCreateTable', |
||||
span: hiveSpan, |
||||
name: t('project.node.create_hive_table') |
||||
}, |
||||
{ |
||||
type: 'switch', |
||||
field: 'targetHiveDropDelimiter', |
||||
span: hiveSpan, |
||||
name: t('project.node.drop_delimiter') |
||||
}, |
||||
{ |
||||
type: 'switch', |
||||
field: 'targetHiveOverWrite', |
||||
span: hiveSpan, |
||||
name: t('project.node.over_write_src') |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'targetHiveTargetDir', |
||||
name: t('project.node.hive_target_dir'), |
||||
span: hiveSpan, |
||||
props: { |
||||
placeholder: t('project.node.hive_target_dir_tips') |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'targetHiveReplaceDelimiter', |
||||
name: t('project.node.replace_delimiter'), |
||||
span: hiveSpan, |
||||
props: { |
||||
placeholder: t('project.node.replace_delimiter_tips') |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'targetHivePartitionKey', |
||||
name: t('project.node.hive_partition_keys'), |
||||
span: hiveSpan, |
||||
props: { |
||||
placeholder: t('project.node.hive_partition_keys_tips') |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'targetHivePartitionValue', |
||||
name: t('project.node.hive_partition_values'), |
||||
span: hiveSpan, |
||||
props: { |
||||
placeholder: t('project.node.hive_partition_values_tips') |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'targetHdfsTargetPath', |
||||
name: t('project.node.target_dir'), |
||||
span: hdfsSpan, |
||||
props: { |
||||
placeholder: t('project.node.target_dir_tips') |
||||
}, |
||||
validate: { |
||||
trigger: ['blur', 'input'], |
||||
required: !!unref(hdfsSpan), |
||||
validator(rule, value) { |
||||
if (!!unref(hdfsSpan) && !value) { |
||||
return new Error(t('project.node.target_dir_tips')) |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
type: 'switch', |
||||
field: 'targetHdfsDeleteTargetDir', |
||||
name: t('project.node.delete_target_dir'), |
||||
span: hdfsSpan |
||||
}, |
||||
{ |
||||
type: 'radio', |
||||
field: 'targetHdfsCompressionCodec', |
||||
name: t('project.node.compression_codec'), |
||||
span: hdfsSpan, |
||||
options: COMPRESSIONCODECS |
||||
}, |
||||
{ |
||||
type: 'radio', |
||||
field: 'targetHdfsFileType', |
||||
name: t('project.node.file_type'), |
||||
span: hdfsSpan, |
||||
options: FILETYPES |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'targetHdfsFieldsTerminated', |
||||
name: t('project.node.fields_terminated'), |
||||
span: hdfsSpan, |
||||
props: { |
||||
placeholder: t('project.node.fields_terminated_tips') |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'targetHdfsLinesTerminated', |
||||
name: t('project.node.lines_terminated'), |
||||
span: hdfsSpan, |
||||
props: { |
||||
placeholder: t('project.node.lines_terminated_tips') |
||||
} |
||||
}, |
||||
...useDatasource( |
||||
model, |
||||
dataSourceSpan, |
||||
'targetMysqlType', |
||||
'targetMysqlDatasource' |
||||
), |
||||
{ |
||||
type: 'input', |
||||
field: 'targetMysqlTable', |
||||
name: t('project.node.table'), |
||||
span: mysqlSpan, |
||||
props: { |
||||
placeholder: t('project.node.hive_table_tips') |
||||
}, |
||||
validate: { |
||||
trigger: ['blur', 'input'], |
||||
required: !!unref(mysqlSpan), |
||||
validator(validate, value) { |
||||
if (!!unref(mysqlSpan) && !value) { |
||||
return new Error(t('project.node.table_tips')) |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'targetMysqlColumns', |
||||
name: t('project.node.column'), |
||||
span: mysqlSpan, |
||||
props: { |
||||
placeholder: t('project.node.column_tips') |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'targetMysqlFieldsTerminated', |
||||
name: t('project.node.fields_terminated'), |
||||
span: mysqlSpan, |
||||
props: { |
||||
placeholder: t('project.node.fields_terminated_tips') |
||||
} |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'targetMysqlLinesTerminated', |
||||
name: t('project.node.lines_terminated'), |
||||
span: mysqlSpan, |
||||
props: { |
||||
placeholder: t('project.node.lines_terminated_tips') |
||||
} |
||||
}, |
||||
{ |
||||
type: 'switch', |
||||
field: 'targetMysqlIsUpdate', |
||||
span: mysqlSpan, |
||||
name: t('project.node.is_update') |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'targetMysqlTargetUpdateKey', |
||||
name: t('project.node.update_key'), |
||||
span: updateSpan, |
||||
props: { |
||||
placeholder: t('project.node.update_key_tips') |
||||
} |
||||
}, |
||||
{ |
||||
type: 'radio', |
||||
field: 'targetMysqlUpdateMode', |
||||
name: t('project.node.update_mode'), |
||||
span: updateSpan, |
||||
options: [ |
||||
{ |
||||
label: t('project.node.only_update'), |
||||
value: 'updateonly' |
||||
}, |
||||
{ |
||||
label: t('project.node.allow_insert'), |
||||
value: 'allowinsert' |
||||
} |
||||
] |
||||
} |
||||
] |
||||
} |
||||
|
||||
const COMPRESSIONCODECS = [ |
||||
{ |
||||
label: 'snappy', |
||||
value: 'snappy' |
||||
}, |
||||
{ |
||||
label: 'lzo', |
||||
value: 'lzo' |
||||
}, |
||||
{ |
||||
label: 'gzip', |
||||
value: 'gzip' |
||||
}, |
||||
{ |
||||
label: 'no', |
||||
value: '' |
||||
} |
||||
] |
||||
const FILETYPES = [ |
||||
{ |
||||
label: 'avro', |
||||
value: '--as-avrodatafile' |
||||
}, |
||||
{ |
||||
label: 'sequence', |
||||
value: '--as-sequencefile' |
||||
}, |
||||
{ |
||||
label: 'text', |
||||
value: '--as-textfile' |
||||
}, |
||||
{ |
||||
label: 'parquet', |
||||
value: '--as-parquetfile' |
||||
} |
||||
] |
@ -0,0 +1,121 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
import { watch, computed, unref } from 'vue' |
||||
import { useI18n } from 'vue-i18n' |
||||
import { useCustomParams, useSourceType, useTargetType } from '.' |
||||
import type { IJsonItem, ModelType } from '../types' |
||||
|
||||
export function useSqoop(model: { [field: string]: any }): IJsonItem[] { |
||||
const { t } = useI18n() |
||||
const customSpan = computed(() => (model.isCustomTask ? 24 : 0)) |
||||
const unCustomSpan = computed(() => (model.isCustomTask ? 0 : 24)) |
||||
|
||||
watch( |
||||
() => model.srcQueryType, |
||||
() => {} |
||||
) |
||||
|
||||
return [ |
||||
{ |
||||
type: 'switch', |
||||
field: 'isCustomTask', |
||||
name: t('project.node.custom_job') |
||||
}, |
||||
{ |
||||
type: 'input', |
||||
field: 'jobName', |
||||
name: t('project.node.sqoop_job_name'), |
||||
span: unCustomSpan, |
||||
props: { |
||||
placeholder: t('project.node.sqoop_job_name_tips') |
||||
}, |
||||
validate: { |
||||
trigger: ['input', 'blur'], |
||||
required: !model.isCustomTask, |
||||
validator(validate, value) { |
||||
if (!model.isCustomTask && !value) { |
||||
return new Error(t('project.node.sqoop_job_name_tips')) |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
type: 'select', |
||||
field: 'modelType', |
||||
name: t('project.node.direct'), |
||||
span: unCustomSpan, |
||||
options: MODEL_TYPES |
||||
}, |
||||
...useCustomParams({ |
||||
model, |
||||
field: 'hadoopCustomParams', |
||||
name: 'hadoop_custom_params', |
||||
isSimple: true, |
||||
span: unCustomSpan |
||||
}), |
||||
...useCustomParams({ |
||||
model, |
||||
field: 'sqoopAdvancedParams', |
||||
name: 'sqoop_advanced_parameters', |
||||
isSimple: true, |
||||
span: unCustomSpan |
||||
}), |
||||
...useSourceType(model), |
||||
...useTargetType(model), |
||||
{ |
||||
type: 'input-number', |
||||
field: 'concurrency', |
||||
name: t('project.node.concurrency'), |
||||
span: unCustomSpan, |
||||
props: { |
||||
placeholder: t('project.node.concurrency_tips') |
||||
} |
||||
}, |
||||
{ |
||||
type: 'editor', |
||||
field: 'customShell', |
||||
name: t('project.node.custom_script'), |
||||
span: customSpan, |
||||
validate: { |
||||
trigger: ['input', 'trigger'], |
||||
required: !!unref(customSpan), |
||||
validator(rule, value) { |
||||
if (!!unref(customSpan) && !value) { |
||||
return new Error(t('project.node.custom_script')) |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
...useCustomParams({ |
||||
model, |
||||
field: 'localParams', |
||||
name: 'custom_parameters', |
||||
isSimple: true |
||||
}) |
||||
] |
||||
} |
||||
|
||||
const MODEL_TYPES = [ |
||||
{ |
||||
label: 'import', |
||||
value: 'import' |
||||
}, |
||||
{ |
||||
label: 'export', |
||||
value: 'export' |
||||
} |
||||
] as { label: ModelType; value: ModelType }[] |
@ -0,0 +1,32 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
.field-title { |
||||
font-weight: bold; |
||||
width: 100%; |
||||
|
||||
&::before { |
||||
content: ''; |
||||
display: inline-block; |
||||
vertical-align: -2px; |
||||
width: 4px; |
||||
height: 1em; |
||||
background-color: var(--n-color); |
||||
border-radius: 4px; |
||||
margin-right: 8px; |
||||
} |
||||
} |
@ -0,0 +1,101 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
import { reactive } from 'vue' |
||||
import * as Fields from '../fields/index' |
||||
import type { IJsonItem, INodeData, ITaskData } from '../types' |
||||
|
||||
export function useSqoop({ |
||||
projectCode, |
||||
from = 0, |
||||
readonly, |
||||
data |
||||
}: { |
||||
projectCode: number |
||||
from?: number |
||||
readonly?: boolean |
||||
data?: ITaskData |
||||
}) { |
||||
const model = reactive({ |
||||
taskType: 'SQOOP', |
||||
name: '', |
||||
flag: 'YES', |
||||
description: '', |
||||
timeoutFlag: false, |
||||
localParams: [], |
||||
environmentCode: null, |
||||
failRetryInterval: 1, |
||||
failRetryTimes: 0, |
||||
workerGroup: 'default', |
||||
delayTime: 0, |
||||
timeout: 30, |
||||
isCustomTask: false, |
||||
hadoopCustomParams: [], |
||||
sqoopAdvancedParams: [], |
||||
mapColumnHive: [], |
||||
mapColumnJava: [], |
||||
modelType: 'import', |
||||
sourceType: 'MYSQL', |
||||
srcQueryType: '1', |
||||
srcColumnType: '0', |
||||
targetType: 'HDFS', |
||||
sourceMysqlType: 'MYSQL', |
||||
targetHdfsDeleteTargetDir: true, |
||||
targetHdfsCompressionCodec: 'snappy', |
||||
targetHdfsFileType: '--as-avrodatafile', |
||||
targetMysqlType: 'MYSQL', |
||||
targetMysqlUpdateMode: 'allowinsert', |
||||
targetHiveCreateTable: false, |
||||
targetHiveDropDelimiter: false, |
||||
targetHiveOverWrite: true, |
||||
concurrency: 1 |
||||
} as INodeData) |
||||
|
||||
let extra: IJsonItem[] = [] |
||||
if (from === 1) { |
||||
extra = [ |
||||
Fields.useTaskType(model, readonly), |
||||
Fields.useProcessName({ |
||||
model, |
||||
projectCode, |
||||
isCreate: !data?.id, |
||||
from, |
||||
processName: data?.processName, |
||||
code: data?.code |
||||
}) |
||||
] |
||||
} |
||||
|
||||
return { |
||||
json: [ |
||||
Fields.useName(), |
||||
...extra, |
||||
Fields.useRunFlag(), |
||||
Fields.useDescription(), |
||||
Fields.useTaskPriority(), |
||||
Fields.useWorkerGroup(), |
||||
Fields.useEnvironmentName(model, !data?.id), |
||||
...Fields.useTaskGroup(model, projectCode), |
||||
...Fields.useFailed(), |
||||
Fields.useDelayTime(model), |
||||
...Fields.useTimeoutAlarm(model), |
||||
...Fields.useSqoop(model), |
||||
Fields.usePreTasks(model) |
||||
] as IJsonItem[], |
||||
model |
||||
} |
||||
} |
Loading…
Reference in new issue