[fix][API]fix task types sequence (#11775)

* fix task types sequence

* fix mapper table name t_ds_fav_task

* fix sequence
This commit is contained in:
Tq 2022-09-05 20:29:03 +08:00 committed by GitHub
parent 3c86e52075
commit 4283cfd7a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 16 deletions

View File

@ -17,19 +17,22 @@
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 java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
import lombok.Getter;
import lombok.Setter;
@Component
@EnableConfigurationProperties
@ -39,18 +42,21 @@ import java.util.Set;
@Setter
public class TaskTypeConfiguration {
private static final Logger logger = LoggerFactory.getLogger(TaskTypeConfiguration.class);
private List<String> universal;
private List<String> cloud;
private List<String> logic;
private List<String> dataIntegration;
private List<String> dataQuality;
private List<String> other;
private List<String> machineLearning;
public Set<FavTaskDto> getDefaultTaskTypes() {
Set<FavTaskDto> defaultTaskTypes = new HashSet<>();
private static final List<FavTaskDto> defaultTaskTypes = new ArrayList<>();
public List<FavTaskDto> getDefaultTaskTypes() {
if (defaultTaskTypes.size() <= 0) {
printDefaultTypes();
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)));
@ -60,7 +66,24 @@ public class TaskTypeConfiguration {
other.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_OTHER)));
}
List<FavTaskDto> result = new ArrayList<>();
defaultTaskTypes.forEach(e -> {
try {
result.add((FavTaskDto) e.clone());
} catch (CloneNotSupportedException ex) {
throw new RuntimeException(ex);
}
});
return result;
}
return defaultTaskTypes;
public void printDefaultTypes() {
logger.info("support default universal task types: {}", universal);
logger.info("support default cloud task types: {}", cloud);
logger.info("support default logic task types: {}", logic);
logger.info("support default dataIntegration task types: {}", dataIntegration);
logger.info("support default dataQuality task types: {}", dataQuality);
logger.info("support default machineLearning task types: {}", machineLearning);
logger.info("support default other task types: {}", other);
}
}

View File

@ -26,7 +26,7 @@ import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
public class FavTaskDto {
public class FavTaskDto implements Cloneable {
private String taskName;
private boolean isCollection;
@ -46,4 +46,9 @@ public class FavTaskDto {
public int hashCode() {
return super.hashCode();
}
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}

View File

@ -40,17 +40,15 @@ public class FavTaskServiceImpl extends BaseServiceImpl implements FavTaskServic
@Override
public List<FavTaskDto> getFavTaskList(User loginUser) {
List<FavTaskDto> result = new ArrayList<>();
Set<String> userFavTaskTypes = favMapper.getUserFavTaskTypes(loginUser.getId());
Set<FavTaskDto> defaultTaskTypes = taskTypeConfiguration.getDefaultTaskTypes();
List<FavTaskDto> defaultTaskTypes = taskTypeConfiguration.getDefaultTaskTypes();
defaultTaskTypes.forEach(e -> {
if (userFavTaskTypes.contains(e.getTaskName())) {
e.setCollection(true);
}
result.add(e);
});
return result;
return defaultTaskTypes;
}
@Override

View File

@ -21,13 +21,13 @@
<select id="getUserFavTaskTypes" resultType="string">
select task_name
from t_ds_fav
from t_ds_fav_task
where user_id = #{userId}
</select>
<delete id="deleteUserFavTask">
delete
from t_ds_fav
from t_ds_fav_task
where user_id = #{userId}
and task_name = #{taskName}
</delete>