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/09/01 06:40:49 UTC

[GitHub] [dolphinscheduler] caishunfeng commented on a diff in pull request #11727: [feature][API]feature: add task type list and enable user to add task type to fav

caishunfeng commented on code in PR #11727:
URL: https://github.com/apache/dolphinscheduler/pull/11727#discussion_r960265080


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/FavController.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.FavDto;
+import org.apache.dolphinscheduler.api.enums.Status;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.FavService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+import static org.apache.dolphinscheduler.api.enums.Status.ADD_TASK_TYPE_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.DELETE_TASK_TYPE_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.LIST_TASK_TYPE_ERROR;
+
+/**
+ * fav controller
+ */
+@Api(tags = "FAV")

Review Comment:
   ```suggestion
   @Api(tags = "FAVOURITE")
   ```



##########
dolphinscheduler-api/src/main/resources/task-type-config.yaml:
##########
@@ -0,0 +1,28 @@
+task:
+  universal:
+    - 'SHELL'
+    - 'PYTHON'
+    - 'PROCEDURE'
+    - 'SQL'
+    - 'SPARK'
+    - 'FLINK'
+    - 'HTTP'
+    - 'MR'
+  cloud:
+    - 'EMR'
+  logic:
+    - 'SUB_PROCESS'
+    - 'DEPENDENT'
+    - 'CONDITIONS'
+    - 'SWITCH'
+    - 'NEXT_LOOP'
+    - 'SURVEIL'
+  di:
+    - 'SEATUNNEL'
+    - 'DATAX'
+    - 'SQOOP'
+  dq:
+    - 'DATA_QUALITY'
+  other:
+    - 'PIGEON'
+    - 'INFA'

Review Comment:
   no this task type in ds, please remove it.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/TaskTypeConfiguration.java:
##########
@@ -0,0 +1,45 @@
+package org.apache.dolphinscheduler.api.configuration;

Review Comment:
   license header.



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java:
##########
@@ -845,4 +845,14 @@ private Constants() {
     public static final String SECURITY_CONFIG_TYPE_PASSWORD = "PASSWORD";
 
     public static final String SECURITY_CONFIG_TYPE_LDAP = "LDAP";
+    /**
+     * Task Types
+     */
+    public static final String TYPE_UNIVERSAL = "universal";
+    public static final String TYPE_DI = "di";
+    public static final String TYPE_CLOUD = "cloud";
+    public static final String TYPE_LOGIC = "logic";
+    public static final String TYPE_DQ = "dq";

Review Comment:
   please use the full name or add comment.



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/config/YamlPropertySourceFactory.java:
##########
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+package org.apache.dolphinscheduler.common.config;
+
+import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
+import org.springframework.core.env.PropertiesPropertySource;
+import org.springframework.core.env.PropertySource;
+import org.springframework.core.io.support.EncodedResource;
+import org.springframework.core.io.support.PropertySourceFactory;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+public class YamlPropertySourceFactory implements PropertySourceFactory {
+
+    @Override
+    public PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException {
+        Properties propertiesFromYaml = loadYamlIntoProperties(resource);
+        String sourceName = name != null ? name : resource.getResource().getFilename();
+        return new PropertiesPropertySource(sourceName, propertiesFromYaml);
+    }
+
+    private Properties loadYamlIntoProperties(EncodedResource resource) throws FileNotFoundException {
+        try {
+            YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
+            factory.setResources(resource.getResource());
+            factory.afterPropertiesSet();
+            return factory.getObject();
+        } catch (IllegalStateException e) {
+            Throwable cause = e.getCause();
+            if (cause instanceof FileNotFoundException) {
+                throw (FileNotFoundException) e.getCause();
+            }
+            throw e;

Review Comment:
   It's better to throw a custom exception



##########
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql:
##########
@@ -1955,16 +1955,30 @@ CREATE TABLE t_ds_alert_send_status (
 -- Table structure for t_ds_cluster
 -- ----------------------------
 DROP TABLE IF EXISTS `t_ds_cluster`;
-CREATE TABLE `t_ds_cluster` (
-  `id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
-  `code` bigint(20)  DEFAULT NULL COMMENT 'encoding',
-  `name` varchar(100) NOT NULL COMMENT 'cluster name',
-  `config` text NULL DEFAULT NULL COMMENT 'this config contains many cluster variables config',
-  `description` text NULL DEFAULT NULL COMMENT 'the details',
-  `operator` int(11) DEFAULT NULL COMMENT 'operator user id',
-  `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
-  `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-  PRIMARY KEY (`id`),
-  UNIQUE KEY `cluster_name_unique` (`name`),
-  UNIQUE KEY `cluster_code_unique` (`code`)
+CREATE TABLE `t_ds_cluster`(
+                               `id`          bigint(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
+                               `code`        bigint(20) DEFAULT NULL COMMENT 'encoding',
+                               `name`        varchar(100) NOT NULL COMMENT 'cluster name',
+                               `config`      text NULL DEFAULT NULL COMMENT 'this config contains many cluster variables config',
+                               `description` text NULL DEFAULT NULL COMMENT 'the details',
+                               `operator`    int(11) DEFAULT NULL COMMENT 'operator user id',
+                               `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
+                               `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+                               PRIMARY KEY (`id`),
+                               UNIQUE KEY `cluster_name_unique` (`name`),
+                               UNIQUE KEY `cluster_code_unique` (`code`)
 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Table structure for t_ds_fav
+-- ----------------------------
+DROP TABLE IF EXISTS `t_ds_fav`;
+CREATE TABLE `t_ds_fav`

Review Comment:
   please add table comment



##########
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Fav.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+package org.apache.dolphinscheduler.dao.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@NoArgsConstructor
+@Getter
+@Setter
+@AllArgsConstructor
+@TableName("t_ds_fav")

Review Comment:
   ```suggestion
   @TableName("t_ds_favourite_task")
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/FavController.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.FavDto;
+import org.apache.dolphinscheduler.api.enums.Status;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.FavService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+import static org.apache.dolphinscheduler.api.enums.Status.ADD_TASK_TYPE_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.DELETE_TASK_TYPE_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.LIST_TASK_TYPE_ERROR;
+
+/**
+ * fav controller
+ */
+@Api(tags = "FAV")
+@RestController
+@RequestMapping("/fav")

Review Comment:
   ```suggestion
   @RequestMapping("/favourite")
   ```



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java:
##########
@@ -845,4 +845,14 @@ private Constants() {
     public static final String SECURITY_CONFIG_TYPE_PASSWORD = "PASSWORD";
 
     public static final String SECURITY_CONFIG_TYPE_LDAP = "LDAP";
+    /**
+     * Task Types
+     */
+    public static final String TYPE_UNIVERSAL = "universal";
+    public static final String TYPE_DI = "di";

Review Comment:
   please use the full name or add comment.



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