From b3cc8a55b9c77f4d7b3198a6c8e7725eb8f4ffd2 Mon Sep 17 00:00:00 2001 From: Tq Date: Fri, 2 Sep 2022 11:40:23 +0800 Subject: [PATCH] [feature][API]feature: add task type list and enable user to add task type to fav (#11727) * feature: add task type list and enable user to add task type to fav * make DependentExecute.java variable protected * add standalone server fileSet --- .../configuration/TaskTypeConfiguration.java | 66 +++++++++++ .../api/controller/FavTaskController.java | 108 ++++++++++++++++++ .../dolphinscheduler/api/dto/FavTaskDto.java | 49 ++++++++ .../dolphinscheduler/api/enums/Status.java | 7 +- .../api/service/FavTaskService.java | 32 ++++++ .../api/service/impl/FavTaskServiceImpl.java | 66 +++++++++++ .../src/main/resources/task-type-config.yaml | 57 +++++++++ .../dolphinscheduler/common/Constants.java | 10 ++ .../config/YamlPropertySourceFactory.java | 44 +++++++ .../dolphinscheduler/dao/entity/FavTask.java | 40 +++++++ .../dao/mapper/FavTaskMapper.java | 34 ++++++ .../dao/mapper/FavTaskMapper.xml | 34 ++++++ .../resources/sql/dolphinscheduler_h2.sql | 14 ++- .../resources/sql/dolphinscheduler_mysql.sql | 38 ++++-- .../sql/dolphinscheduler_postgresql.sql | 37 ++++-- .../dolphinscheduler-standalone-server.xml | 7 ++ 16 files changed, 616 insertions(+), 27 deletions(-) create mode 100644 dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/TaskTypeConfiguration.java create mode 100644 dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/FavTaskController.java create mode 100644 dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/FavTaskDto.java create mode 100644 dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/FavTaskService.java create mode 100644 dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/FavTaskServiceImpl.java create mode 100644 dolphinscheduler-api/src/main/resources/task-type-config.yaml create mode 100644 dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/config/YamlPropertySourceFactory.java create mode 100644 dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/FavTask.java create mode 100644 dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/FavTaskMapper.java create mode 100644 dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/FavTaskMapper.xml diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/TaskTypeConfiguration.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/TaskTypeConfiguration.java new file mode 100644 index 0000000000..448f2d55b5 --- /dev/null +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/TaskTypeConfiguration.java @@ -0,0 +1,66 @@ +/* + * 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.configuration; + +import lombok.Getter; +import lombok.Setter; +import org.apache.dolphinscheduler.api.dto.FavTaskDto; +import org.apache.dolphinscheduler.common.Constants; +import org.apache.dolphinscheduler.common.config.YamlPropertySourceFactory; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Component; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +@Component +@EnableConfigurationProperties +@PropertySource(value = {"classpath:task-type-config.yaml"}, factory = YamlPropertySourceFactory.class) +@ConfigurationProperties(prefix = "task") +@Getter +@Setter +public class TaskTypeConfiguration { + + private List universal; + private List cloud; + private List logic; + private List dataIntegration; + private List dataQuality; + private List other; + + private List machineLearning; + + public Set getDefaultTaskTypes() { + Set defaultTaskTypes = new HashSet<>(); + if (defaultTaskTypes.size() <= 0) { + universal.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_UNIVERSAL))); + cloud.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_CLOUD))); + logic.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_LOGIC))); + dataIntegration.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_DATA_INTEGRATION))); + dataQuality.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_DATA_QUALITY))); + machineLearning.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_MACHINE_LEARNING))); + other.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_OTHER))); + + } + + return defaultTaskTypes; + } +} diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/FavTaskController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/FavTaskController.java new file mode 100644 index 0000000000..98d38373f3 --- /dev/null +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/FavTaskController.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.FavTaskDto; +import org.apache.dolphinscheduler.api.enums.Status; +import org.apache.dolphinscheduler.api.exceptions.ApiException; +import org.apache.dolphinscheduler.api.service.FavTaskService; +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 = "FAVOURITE") +@RestController +@RequestMapping("/favourite") +public class FavTaskController extends BaseController { + + @Resource + private FavTaskService favTaskService; + + /** + * get task type list + * + * @param loginUser login user + * @return task type list + */ + @ApiOperation(value = "listTaskType", notes = "LIST_TASK_TYPE") + @GetMapping(value = "/taskTypes") + @ResponseStatus(HttpStatus.OK) + @ApiException(LIST_TASK_TYPE_ERROR) + @AccessLogAnnotation(ignoreRequestArgs = "loginUser") + public Result listTaskType(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) { + List favTaskList = favTaskService.getFavTaskList(loginUser); + return success(Status.SUCCESS.getMsg(), favTaskList); + } + + /** + * delete task fav + * + * @param loginUser login user + * @return + */ + @ApiOperation(value = "deleteTaskType", notes = "DELETE_TASK_TYPE") + @DeleteMapping(value = "/{taskName}") + @ResponseStatus(HttpStatus.OK) + @ApiException(DELETE_TASK_TYPE_ERROR) + @AccessLogAnnotation(ignoreRequestArgs = "loginUser") + public Result deleteFavTask(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @PathVariable("taskName") String taskName) { + boolean b = favTaskService.deleteFavTask(loginUser, taskName); + return success(b); + } + + /** + * add task fav + * + * @param loginUser login user + * @return + */ + @ApiOperation(value = "addTaskType", notes = "ADD_TASK_TYPE") + @PostMapping(value = "/{taskName}") + @ResponseStatus(HttpStatus.OK) + @ApiException(ADD_TASK_TYPE_ERROR) + @AccessLogAnnotation(ignoreRequestArgs = "loginUser") + public Result addFavTask(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @PathVariable("taskName") String taskName) { + int i = favTaskService.addFavTask(loginUser, taskName); + return success(i > 0); + } +} diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/FavTaskDto.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/FavTaskDto.java new file mode 100644 index 0000000000..91e107b5ad --- /dev/null +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/FavTaskDto.java @@ -0,0 +1,49 @@ +/* + * 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.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@NoArgsConstructor +@Getter +@Setter +@AllArgsConstructor +public class FavTaskDto { + + private String taskName; + private boolean isCollection; + private String taskType; + + @Override + public boolean equals(Object obj) { + if (obj instanceof FavTaskDto) { + FavTaskDto favDto = (FavTaskDto) obj; + return this.taskName.equals(favDto.getTaskName()); + + } + return super.equals(obj); + } + + @Override + public int hashCode() { + return super.hashCode(); + } +} diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java index dea5e79285..a34ca157d9 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java @@ -17,11 +17,11 @@ package org.apache.dolphinscheduler.api.enums; +import org.springframework.context.i18n.LocaleContextHolder; + import java.util.Locale; import java.util.Optional; -import org.springframework.context.i18n.LocaleContextHolder; - /** * status enum // todo #4855 One category one interval */ @@ -222,6 +222,9 @@ public enum Status { TASK_WITH_DEPENDENT_ERROR(10195, "task used in other tasks", "删除被其他任务引用"), TASK_SAVEPOINT_ERROR(10196, "task savepoint error", "任务实例savepoint错误"), TASK_STOP_ERROR(10197, "task stop error", "任务实例停止错误"), + LIST_TASK_TYPE_ERROR(10200, "list task type error", "查询任务类型列表错误"), + DELETE_TASK_TYPE_ERROR(10200, "delete task type error", "删除任务类型错误"), + ADD_TASK_TYPE_ERROR(10200, "add task type error", "添加任务类型错误"), UDF_FUNCTION_NOT_EXIST(20001, "UDF function not found", "UDF函数不存在"), UDF_FUNCTION_EXISTS(20002, "UDF function already exists", "UDF函数已存在"), diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/FavTaskService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/FavTaskService.java new file mode 100644 index 0000000000..a6c24fdac8 --- /dev/null +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/FavTaskService.java @@ -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. + */ + +package org.apache.dolphinscheduler.api.service; + +import org.apache.dolphinscheduler.api.dto.FavTaskDto; +import org.apache.dolphinscheduler.dao.entity.User; + +import java.util.List; + +public interface FavTaskService { + + List getFavTaskList(User loginUser); + + boolean deleteFavTask(User loginUser, String taskName); + + int addFavTask(User loginUser, String taskName); +} diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/FavTaskServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/FavTaskServiceImpl.java new file mode 100644 index 0000000000..fb13d548fb --- /dev/null +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/FavTaskServiceImpl.java @@ -0,0 +1,66 @@ +/* + * 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.service.impl; + +import org.apache.dolphinscheduler.api.configuration.TaskTypeConfiguration; +import org.apache.dolphinscheduler.api.dto.FavTaskDto; +import org.apache.dolphinscheduler.api.service.FavTaskService; +import org.apache.dolphinscheduler.dao.entity.FavTask; +import org.apache.dolphinscheduler.dao.entity.User; +import org.apache.dolphinscheduler.dao.mapper.FavTaskMapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +@Service +public class FavTaskServiceImpl extends BaseServiceImpl implements FavTaskService { + + @Resource + private TaskTypeConfiguration taskTypeConfiguration; + @Resource + private FavTaskMapper favMapper; + + @Override + public List getFavTaskList(User loginUser) { + List result = new ArrayList<>(); + Set userFavTaskTypes = favMapper.getUserFavTaskTypes(loginUser.getId()); + + Set defaultTaskTypes = taskTypeConfiguration.getDefaultTaskTypes(); + defaultTaskTypes.forEach(e -> { + if (userFavTaskTypes.contains(e.getTaskName())) { + e.setCollection(true); + } + result.add(e); + }); + return result; + } + + @Override + public boolean deleteFavTask(User loginUser, String taskName) { + return favMapper.deleteUserFavTask(loginUser.getId(), taskName); + } + + @Override + public int addFavTask(User loginUser, String taskName) { + favMapper.deleteUserFavTask(loginUser.getId(), taskName); + return favMapper.insert(new FavTask(null, taskName, loginUser.getId())); + } +} diff --git a/dolphinscheduler-api/src/main/resources/task-type-config.yaml b/dolphinscheduler-api/src/main/resources/task-type-config.yaml new file mode 100644 index 0000000000..0172b261a7 --- /dev/null +++ b/dolphinscheduler-api/src/main/resources/task-type-config.yaml @@ -0,0 +1,57 @@ +# +# 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. +# + +task: + universal: + - 'SHELL' + - 'PYTHON' + - 'PROCEDURE' + - 'SQL' + - 'SPARK' + - 'FLINK' + - 'HTTP' + - 'MR' + - 'DINKY' + - 'FLINK_STREAM' + - 'HIVECLI' + cloud: + - 'EMR' + - 'K8S' + logic: + - 'SUB_PROCESS' + - 'DEPENDENT' + - 'CONDITIONS' + - 'SWITCH' + - 'NEXT_LOOP' + - 'SURVEIL' + dataIntegration: + - 'SEATUNNEL' + - 'DATAX' + - 'SQOOP' + dataQuality: + - 'DATA_QUALITY' + machineLearning: + - 'JUPYTER' + - 'MLFLOW' + - 'OPENMLDB' + - 'DVC' + - 'SAGEMAKER' + - 'PYTORCH' + other: + - 'PIGEON' + - 'ZEPPELIN' + - 'CHUNJUN' \ No newline at end of file diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java index 6350761205..055eb54a96 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java @@ -845,4 +845,14 @@ public final class 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_DATA_INTEGRATION = "DataIntegration"; + public static final String TYPE_CLOUD = "Cloud"; + public static final String TYPE_LOGIC = "Logic"; + public static final String TYPE_DATA_QUALITY = "DataQuality"; + public static final String TYPE_OTHER = "Other"; + public static final String TYPE_MACHINE_LEARNING = "MachineLearning"; } diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/config/YamlPropertySourceFactory.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/config/YamlPropertySourceFactory.java new file mode 100644 index 0000000000..8c9bd2fe74 --- /dev/null +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/config/YamlPropertySourceFactory.java @@ -0,0 +1,44 @@ +/* + * 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.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) { + YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); + factory.setResources(resource.getResource()); + factory.afterPropertiesSet(); + return factory.getObject(); + } +} diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/FavTask.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/FavTask.java new file mode 100644 index 0000000000..3f2f858964 --- /dev/null +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/FavTask.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_task") +public class FavTask { + + @TableId(value = "id", type = IdType.AUTO) + private Long id; + private String taskName; + private int userId; + +} diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/FavTaskMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/FavTaskMapper.java new file mode 100644 index 0000000000..0c102ce263 --- /dev/null +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/FavTaskMapper.java @@ -0,0 +1,34 @@ +/* + * 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.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.dolphinscheduler.dao.entity.FavTask; +import org.apache.ibatis.annotations.Param; + +import java.util.Set; + +/** + * fav mapper interface + */ +public interface FavTaskMapper extends BaseMapper { + + Set getUserFavTaskTypes(@Param("userId") int userId); + + boolean deleteUserFavTask(@Param("userId") int userId, @Param("taskName") String taskName); +} diff --git a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/FavTaskMapper.xml b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/FavTaskMapper.xml new file mode 100644 index 0000000000..c5da1bf7a9 --- /dev/null +++ b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/FavTaskMapper.xml @@ -0,0 +1,34 @@ + + + + + + + + + + delete + from t_ds_fav + where user_id = #{userId} + and task_name = #{taskName} + + diff --git a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql index be90dda167..0c22fe9269 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql @@ -1992,5 +1992,17 @@ CREATE TABLE t_ds_cluster ); INSERT INTO `t_ds_cluster` -(`id`,`code`,`name`,`config`,`description`,`operator`,`create_time`,`update_time`) +(`id`, `code`, `name`, `config`, `description`, `operator`, `create_time`, `update_time`) VALUES (100, 0, 'ds_null_k8s', '{"k8s":"ds_null_k8s"}', 'test', 1, '2021-03-03 11:31:24.0', '2021-03-03 11:31:24.0'); + +-- +-- Table structure for t_ds_fav +-- +DROP TABLE IF EXISTS t_ds_fav CASCADE; +CREATE TABLE t_ds_fav +( + id bigint(20) NOT NULL AUTO_INCREMENT, + task_name varchar(64) NOT NULL, + user_id int NOT NULL, + PRIMARY KEY (id) +); diff --git a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql index c877fb6fef..3ff21b1c6a 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql +++ b/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_task +-- ---------------------------- +DROP TABLE IF EXISTS `t_ds_fav_task`; +CREATE TABLE `t_ds_fav_task` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'favorite task id', + `task_name` varchar(64) NOT NULL COMMENT 'favorite task name', + `user_id` int NOT NULL COMMENT 'user id', + PRIMARY KEY (`id`) +) ENGINE = InnoDB + AUTO_INCREMENT = 1 + DEFAULT CHARSET = utf8; diff --git a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql index 2c50e1d7de..481b3e3e1e 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql @@ -1937,16 +1937,29 @@ CREATE TABLE t_ds_alert_send_status ( -- DROP TABLE IF EXISTS t_ds_cluster; -CREATE TABLE t_ds_cluster ( - id serial NOT NULL, - code bigint NOT NULL, - name varchar(100) DEFAULT NULL, - config text DEFAULT NULL, - description text, - operator int DEFAULT NULL, - create_time timestamp DEFAULT NULL, - update_time timestamp DEFAULT NULL, - PRIMARY KEY (id), - CONSTRAINT cluster_name_unique UNIQUE (name), - CONSTRAINT cluster_code_unique UNIQUE (code) +CREATE TABLE t_ds_cluster( + id serial NOT NULL, + code bigint NOT NULL, + name varchar(100) DEFAULT NULL, + config text DEFAULT NULL, + description text, + operator int DEFAULT NULL, + create_time timestamp DEFAULT NULL, + update_time timestamp DEFAULT NULL, + PRIMARY KEY (id), + CONSTRAINT cluster_name_unique UNIQUE (name), + CONSTRAINT cluster_code_unique UNIQUE (code) +); + +-- +-- Table structure for t_ds_fav +-- + +DROP TABLE IF EXISTS t_ds_fav; +CREATE TABLE t_ds_fav +( + id serial NOT NULL, + task_name varchar(64) NOT NULL, + user_id int NOT NULL, + PRIMARY KEY (id) ); diff --git a/dolphinscheduler-standalone-server/src/main/assembly/dolphinscheduler-standalone-server.xml b/dolphinscheduler-standalone-server/src/main/assembly/dolphinscheduler-standalone-server.xml index 3857cf75fe..14a38289f8 100644 --- a/dolphinscheduler-standalone-server/src/main/assembly/dolphinscheduler-standalone-server.xml +++ b/dolphinscheduler-standalone-server/src/main/assembly/dolphinscheduler-standalone-server.xml @@ -86,6 +86,13 @@ conf + + ${basedir}/../dolphinscheduler-api/src/main/resources + + task-type-config.yaml + + conf + ${basedir}/../dolphinscheduler-ui/dist ./ui