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/08/15 02:23: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_r945387424


##########
dolphinscheduler-ui/src/views/projects/task/constants/task-type.ts:
##########
@@ -47,6 +48,9 @@ export type TaskType =
 export type TaskExecuteType = 'STREAM' | 'BATCH'
 
 export const TASK_TYPES_MAP = {
+  JAVA: {
+    alias: 'JAVA'
+  },

Review Comment:
   Does it have a document, if not, you need to set helperLinkDisable to true.



##########
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java.ts:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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 ,useJavaTaskMainJar} 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,
+        value: model.runType
+      },
+      {
+          type: 'switch',
+          field: 'isModulePath',
+          span: 24,
+          name: t('project.node.is_module_path'),
+          value: model.isModulePath
+      },
+      {
+        type: 'input',
+        field: 'mainArgs',
+        name: t('project.node.main_arguments'),
+        props: {
+          type: 'textarea',
+          placeholder: t('project.node.main_arguments_tips')
+        }
+      },
+      {
+        type: 'input',
+        field: 'jvmArgs',
+        name: t('project.node.jvm_args'),
+        props: {
+          type: 'textarea',
+          placeholder: t('project.node.jvm_args_tips')
+        }
+      },
+      useJavaTaskMainJar(model),
+    {
+      type: 'editor',
+      field: 'rawScript',
+      span: rawScriptSpan,
+      name: t('project.node.script'),
+      validate: {
+        trigger: ['input', 'trigger'],
+        required: true,
+        message: t('project.node.script_tips')

Review Comment:
   Does it have a language? The default language of the editor is shell.



##########
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 already has a useMainJar hook, so it don't need to create a new one.



-- 
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