You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/07/06 06:09:13 UTC

[GitHub] [dolphinscheduler] Amy0104 commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Amy0104 commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r914440124


##########
dolphinscheduler-ui/src/locales/zh_CN/project.ts:
##########
@@ -284,6 +284,10 @@ export default {
     online: '已上线'
   },
   node: {
+    is_module_path: '模块路劲',
+    run_type: '运行类型',
+    jvm_args: '虚拟机参数',
+    jvm_args_tips: '请输入虚拟机参数',

Review Comment:
   It is better to keep these keys the same position as en_US.



##########
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java-task-main-jar.ts:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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 { computed, ref, onMounted, watch } from 'vue'
+import { useI18n } from 'vue-i18n'
+import { queryResourceByProgramType } from '@/service/modules/resources'
+import { useTaskNodeStore } from '@/store/project/task-node'
+import utils from '@/utils'
+import type { IJsonItem, ProgramType, IMainJar } from '../types'
+
+export function useJavaTaskMainJar(model: { [field: string]: any }): IJsonItem {
+  const { t } = useI18n()
+  const mainJarOptions = ref([] as IMainJar[])
+  const taskStore = useTaskNodeStore()
+
+  const mainJarSpan = computed(() => (model.runType === 'JAVA' ? 0 : 24))
+  const getMainJars = async (programType: ProgramType) => {
+    const storeMainJar = taskStore.getMainJar(programType)
+    if (storeMainJar) {
+      mainJarOptions.value = storeMainJar
+      return
+    }
+    const res = await queryResourceByProgramType({
+      type: 'FILE',
+      programType
+    })
+    utils.removeUselessChildren(res)
+    mainJarOptions.value = res || []
+    taskStore.updateMainJar(programType, res)
+  }
+
+  onMounted(() => {
+    getMainJars(model.programType)
+  })
+
+  watch(
+    () => model.programType,
+    (value) => {
+        getMainJars(value)
+    }
+  )
+
+  return {
+    type: 'tree-select',
+    field: 'mainJar',
+    name: t('project.node.main_package'),
+    span: mainJarSpan,
+    props: {
+      cascade: true,
+      showPath: true,
+      checkStrategy: 'child',
+      placeholder: t('project.node.main_package_tips'),
+      keyField: 'id',
+      labelField: 'fullName'
+    },
+    validate: {
+      trigger: ['input', 'blur'],
+      required: true,
+      validator(validate: any, value: string) {
+        if (!value) {
+          return new Error(t('project.node.main_package_tips'))
+        }
+      }
+    },
+    options: mainJarOptions
+  }
+}

Review Comment:
   It seems that this hook is not used at all.



##########
dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts:
##########
@@ -35,6 +35,19 @@ export function formatParams(data: INodeData): {
   if (data.taskType === 'SUB_PROCESS') {
     taskParams.processDefinitionCode = data.processDefinitionCode
   }
+
+  if(data.taskType === 'JAVA'){
+    taskParams.runType = data.runType
+    taskParams.mainArgs = data.mainArgs
+    taskParams.jvmArgs = data.jvmArgs
+    taskParams.isModulePath = data.isModulePath
+    if(data.runType === 'JAR'){
+      if (data.mainJar) {
+        taskParams.mainJar = { id: data.mainJar }
+      }
+    }

Review Comment:
   it is better to change the two conditions into one parallel condition.



##########
dolphinscheduler-ui/src/locales/en_US/project.ts:
##########
@@ -126,7 +126,6 @@ export default {
     switch_version: 'Switch To This Version',
     confirm_switch_version: 'Confirm Switch To This Version?',
     current_version: 'Current Version',
-    run_type: 'Run Type',

Review Comment:
   The 'run_type' can not be removed, because it is used in workflow instance column.



##########
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java.ts:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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 { computed } from 'vue'
+import { useI18n } from 'vue-i18n'
+import { useCustomParams, useResources ,useMainJar} from '.'
+import type { IJsonItem } from '../types'
+
+export function useJava(model: { [field: string]: any }): IJsonItem[] {
+  const { t } = useI18n()
+  const rawScriptSpan = computed(() => (model.runType === 'JAR' ? 0 : 24))
+  return [
+    {
+        type: 'select',
+        field: 'runType',
+        span: 12,
+        name: t('project.node.run_type'),
+        options: RUN_TYPES,
+        props: {
+          'on-update:value': () => {
+            // if(model.runType=='JAR'){
+            //     model.rawScript=''
+            // }else{
+            //     model.mainJar = null
+            //     model.rawScript=''
+            // }
+          }

Review Comment:
   It is better to remove the comment code.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org