Skip to content

Commit

Permalink
Merge pull request WeBankFinTech#148 from Davidhua1996/dev-1.0.0
Browse files Browse the repository at this point in the history
LGTM
  • Loading branch information
FinalTarget authored Feb 7, 2022
2 parents d35e354 + d698a92 commit de18cfe
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.webank.wedatasphere.exchangis.datasource.core.ui;

public interface ElementUI {
public interface ElementUI<T> {
String TEXTAREA = "TEXTAREA";
String INPUT = "INPUT";
String OPTION = "OPTION";
Expand All @@ -14,8 +14,8 @@ public interface ElementUI {

Integer getSort();

String getValue();
T getValue();

String getDefaultValue();
T getDefaultValue();

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@

public class ExchangisDataSourceParamsUI {

private List<ElementUI> sources = Collections.emptyList();
private List<ElementUI<?>> sources = Collections.emptyList();

private List<ElementUI> sinks = Collections.emptyList();
private List<ElementUI<?>> sinks = Collections.emptyList();

public List<ElementUI> getSources() {
public List<ElementUI<?>> getSources() {
return sources;
}

public void setSources(List<ElementUI> sources) {
public void setSources(List<ElementUI<?>> sources) {
this.sources = sources;
}

public List<ElementUI> getSinks() {
public List<ElementUI<?>> getSinks() {
return sinks;
}

public void setSinks(List<ElementUI> sinks) {
public void setSinks(List<ElementUI<?>> sinks) {
this.sinks = sinks;
}

public void addSourceUI(ElementUI ui) {
public void addSourceUI(ElementUI<?> ui) {
this.sources.add(ui);
}

public void addSinkUI(ElementUI ui) {
public void addSinkUI(ElementUI<?> ui) {
this.sinks.add(ui);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.webank.wedatasphere.exchangis.datasource.core.ui;

public class InputElementUI implements ElementUI {
public class InputElementUI implements ElementUI<String> {
private String key;
private String field;
private String label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.Collection;

public class OptionElementUI implements ElementUI {
public class OptionElementUI implements ElementUI<String> {
private String key;
private String field;
private String label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class DefaultDataSourceUIViewer implements ExchangisDataSourceUIViewer {
private final ExchangisDataSourceParamsUI params;
// private final ExchangisDataSourceTransformsUI transforms;
private final ExchangisJobTransformsContent transforms;
private final List<ElementUI> settings;
private final List<ElementUI<?>> settings;

public DefaultDataSourceUIViewer(String subJobName, ExchangisDataSourceIdsUI dataSourceIds, ExchangisDataSourceParamsUI params, ExchangisJobTransformsContent transforms, List<ElementUI> settings) {
public DefaultDataSourceUIViewer(String subJobName, ExchangisDataSourceIdsUI dataSourceIds, ExchangisDataSourceParamsUI params, ExchangisJobTransformsContent transforms, List<ElementUI<?>> settings) {
this.subJobName = subJobName;
this.dataSourceIds = dataSourceIds;
this.params = params;
Expand Down Expand Up @@ -46,7 +46,7 @@ public ExchangisJobTransformsContent getTransforms() {
}

@Override
public List<ElementUI> getSettings() {
public List<ElementUI<?>> getSettings() {
return this.settings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ public interface ExchangisDataSourceUIViewer {

ExchangisJobTransformsContent getTransforms();

List<ElementUI> getSettings();
List<ElementUI<?>> getSettings();
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static class ExchangisJobParamsItem {
private String configName;

@JsonProperty("config_value")
private String configValue;
private Object configValue;

private Integer sort;

Expand All @@ -53,11 +53,11 @@ public void setConfigName(String configName) {
this.configName = configName;
}

public String getConfigValue() {
public Object getConfigValue() {
return configValue;
}

public void setConfigValue(String configValue) {
public void setConfigValue(Object configValue) {
this.configValue = configValue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ protected ExchangisDataSourceParamsUI buildDataSourceParamsUI(ExchangisJobInfoCo
String type = source.getType();
ExchangisDataSource exchangisSourceDataSource = this.context.getExchangisDataSource(type);
if (null != exchangisSourceDataSource) {
sourceParamConfigs = exchangisSourceDataSource.getDataSourceParamConfigs().stream().filter(i -> i.getConfigDirection().equals(content.getEngine() + "-SOURCE")).collect(Collectors.toList());
sourceParamConfigs = exchangisSourceDataSource.getDataSourceParamConfigs().stream().filter(
i -> i.getConfigDirection().equals(content.getEngine() + "-SOURCE") || "SOURCE".equalsIgnoreCase(i.getConfigDirection())).collect(Collectors.toList());
}
}

Expand All @@ -161,7 +162,8 @@ protected ExchangisDataSourceParamsUI buildDataSourceParamsUI(ExchangisJobInfoCo
String type = sink.getType();
ExchangisDataSource exchangisSinkDataSource = this.context.getExchangisDataSource(type);
if (null != exchangisSinkDataSource) {
sinkParamConfigs = exchangisSinkDataSource.getDataSourceParamConfigs().stream().filter(i -> i.getConfigDirection().equals(content.getEngine() + "-SINK")).collect(Collectors.toList());
sinkParamConfigs = exchangisSinkDataSource.getDataSourceParamConfigs().stream().filter(i ->
i.getConfigDirection().equals(content.getEngine() + "-SINK") || "SINK".equalsIgnoreCase(i.getConfigDirection())).collect(Collectors.toList());
}
}
}
Expand All @@ -175,8 +177,8 @@ protected ExchangisDataSourceParamsUI buildDataSourceParamsUI(ExchangisJobInfoCo
sinkParamsItems = params.getSinks();
}

List<ElementUI> jobDataSourceParamsUI1 = buildDataSourceParamsFilledValueUI(sourceParamConfigs, sourceParamsItems);
List<ElementUI> jobDataSourceParamsUI2 = buildDataSourceParamsFilledValueUI(sinkParamConfigs, sinkParamsItems);
List<ElementUI<?>> jobDataSourceParamsUI1 = buildDataSourceParamsFilledValueUI(sourceParamConfigs, sourceParamsItems);
List<ElementUI<?>> jobDataSourceParamsUI2 = buildDataSourceParamsFilledValueUI(sinkParamConfigs, sinkParamsItems);
ExchangisDataSourceParamsUI paramsUI = new ExchangisDataSourceParamsUI();
paramsUI.setSources(jobDataSourceParamsUI1);
paramsUI.setSinks(jobDataSourceParamsUI2);
Expand All @@ -196,13 +198,13 @@ protected ExchangisDataSourceUIViewer buildAllUI(HttpServletRequest request, Exc

// ExchangisDataSourceTransformsUI dataSourceTransFormsUI = ExchangisDataSourceUIViewBuilder.getDataSourceTransFormsUI(transforms);

List<ElementUI> jobDataSourceSettingsUI = this.buildJobSettingsUI(job.getEngineType(), content);
List<ElementUI<?>> jobDataSourceSettingsUI = this.buildJobSettingsUI(job.getEngineType(), content);

return new DefaultDataSourceUIViewer(content.getSubJobName(), dataSourceIdsUI, paramsUI, transforms, jobDataSourceSettingsUI);
}


protected List<ElementUI> buildJobSettingsUI(String jobEngineType) {
protected List<ElementUI<?>> buildJobSettingsUI(String jobEngineType) {
if (Strings.isNullOrEmpty(jobEngineType)) {
return Collections.emptyList();
}
Expand All @@ -214,7 +216,7 @@ protected List<ElementUI> buildJobSettingsUI(String jobEngineType) {
return buildDataSourceParamsFilledValueUI(settingParamConfigs, null);
}

protected List<ElementUI> buildJobSettingsUI(String jobEngineType, ExchangisJobInfoContent content) {
protected List<ElementUI<?>> buildJobSettingsUI(String jobEngineType, ExchangisJobInfoContent content) {
if (Strings.isNullOrEmpty(jobEngineType)) {
return Collections.emptyList();
}
Expand All @@ -227,19 +229,19 @@ protected List<ElementUI> buildJobSettingsUI(String jobEngineType, ExchangisJobI
return buildDataSourceParamsFilledValueUI(settingParamConfigs, settings);
}

protected List<ElementUI> buildDataSourceParamsUI(List<ExchangisJobParamConfig> paramConfigs) {
List<ElementUI> uis = new ArrayList<>();
protected List<ElementUI<?>> buildDataSourceParamsUI(List<ExchangisJobParamConfig> paramConfigs) {
List<ElementUI<?>> uis = new ArrayList<>();
if (!Objects.isNull(paramConfigs) && !paramConfigs.isEmpty()) {
for (ExchangisJobParamConfig cfg : paramConfigs) {
ElementUI ui = fillElementUIValue(cfg, "");
ElementUI<?> ui = fillElementUIValue(cfg, "");
uis.add(ui);
}
}
return uis;
}

protected List<ElementUI> buildDataSourceParamsFilledValueUI(List<ExchangisJobParamConfig> paramConfigs, List<ExchangisJobParamsContent.ExchangisJobParamsItem> paramsList) {
List<ElementUI> uis = new ArrayList<>();
protected List<ElementUI<?>> buildDataSourceParamsFilledValueUI(List<ExchangisJobParamConfig> paramConfigs, List<ExchangisJobParamsContent.ExchangisJobParamsItem> paramsList) {
List<ElementUI<?>> uis = new ArrayList<>();
if (!Objects.isNull(paramConfigs) && !paramConfigs.isEmpty()) {
for (ExchangisJobParamConfig cfg : paramConfigs) {
if (Objects.isNull(paramsList) || paramsList.isEmpty()) {
Expand All @@ -248,10 +250,10 @@ protected List<ElementUI> buildDataSourceParamsFilledValueUI(List<ExchangisJobPa
}
ExchangisJobParamsContent.ExchangisJobParamsItem selectedParamItem = getJobParamsItem(cfg.getConfigKey(), paramsList);
if (Objects.isNull(selectedParamItem)) {
ElementUI ui = fillElementUIValue(cfg, "");
ElementUI<?> ui = fillElementUIValue(cfg, "");
uis.add(ui);
} else {
ElementUI ui = fillElementUIValue(cfg, selectedParamItem.getConfigValue());
ElementUI<?> ui = fillElementUIValue(cfg, selectedParamItem.getConfigValue());
uis.add(ui);
}
}
Expand All @@ -268,13 +270,13 @@ private ExchangisJobParamsContent.ExchangisJobParamsItem getJobParamsItem(String
return null;
}

private ElementUI fillElementUIValue(ExchangisJobParamConfig config, String value) {
private ElementUI<?> fillElementUIValue(ExchangisJobParamConfig config, Object value) {
String uiType = config.getUiType();
switch (uiType) {
case ElementUI.OPTION:
return fillOptionElementUIValue(config, value);
return fillOptionElementUIValue(config, String.valueOf(value));
case ElementUI.INPUT:
return fillInputElementUIValue(config, value);
return fillInputElementUIValue(config, String.valueOf(value));
default:
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public interface DataSourceUIGetter {
List<ExchangisDataSourceUIViewer> getJobDataSourceUIs(HttpServletRequest request, Long jobId);

// 在新建 Job 的时候,右侧需要根据选择的数据源类型来获取参数设置项
List<ElementUI> getDataSourceParamsUI(String dsType, String dir);
List<ElementUI<?>> getDataSourceParamsUI(String dsType, String dir);

// 在新建 Job 的时候,右侧需要根据选择的引擎类型来获取参数设置项
List<ElementUI> getJobEngineSettingsUI(String engineType);
List<ElementUI<?>> getJobEngineSettingsUI(String engineType);

}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public List<ExchangisDataSourceUIViewer> getJobDataSourceUIs(HttpServletRequest

// 根据数据源类型获取参数
@Override
public List<ElementUI> getDataSourceParamsUI(String dsType, String engineAndDirection) {
public List<ElementUI<?>> getDataSourceParamsUI(String dsType, String engineAndDirection) {

ExchangisDataSource exchangisDataSource = this.context.getExchangisDataSource(dsType);
List<ExchangisJobParamConfig> paramConfigs = exchangisDataSource.getDataSourceParamConfigs();
Expand All @@ -108,7 +108,7 @@ public List<ElementUI> getDataSourceParamsUI(String dsType, String engineAndDire
}

@Override
public List<ElementUI> getJobEngineSettingsUI(String engineType) {
public List<ElementUI<?>> getJobEngineSettingsUI(String engineType) {
return this.buildJobSettingsUI(engineType);
}

Expand Down Expand Up @@ -521,7 +521,7 @@ public Message getJobDataSourceSettingsUI(Long jobId, String jobName) throws Exc

for (ExchangisJobInfoContent content : contents) {
if (content.getSubJobName().equalsIgnoreCase(jobName)) {
List<ElementUI> uis = this.buildJobSettingsUI(job.getEngineType(), content);
List<ElementUI<?>> uis = this.buildJobSettingsUI(job.getEngineType(), content);
return Message.ok().data("uis", uis);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public ExchangisJobVO updateJobConfig(ExchangisJobContentDTO exchangisJobContent
public ExchangisJobVO updateJobContent(ExchangisJobContentDTO exchangisJobContentDTO, Long id)
throws ExchangisJobServerException, ExchangisDataSourceException;

public List<ElementUI> getSpeedLimitSettings(Long id, String taskName);
public List<ElementUI<?>> getSpeedLimitSettings(Long id, String taskName);

public void setSpeedLimitSettings(Long id, String taskName, ExchangisTaskSpeedLimitVO settings);
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ public boolean hasExecuteJobAuthority(String jobExecutionId, String userName) {
* @return
*/
public boolean hasExecuteJobAuthority(LaunchedExchangisJobEntity launchedExchangisJob, String userName){
return Objects.nonNull(launchedExchangisJob) && launchedExchangisJob.getExecuteUser().equals(userName);
// return Objects.nonNull(launchedExchangisJob) && launchedExchangisJob.getExecuteUser().equals(userName);
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ public ExchangisJobVO updateJobContent(ExchangisJobContentDTO exchangisJobConten
}

@Override
public List<ElementUI> getSpeedLimitSettings(Long id, String taskName) {
public List<ElementUI<?>> getSpeedLimitSettings(Long id, String taskName) {
ExchangisJobVO exchangisJob = exchangisJobService.getById(id);
Map<String, String> values = new HashMap<>();
Map<String, Object> values = new HashMap<>();
if (null != exchangisJob && null != exchangisJob.getContent() && !"".equals(exchangisJob.getContent())) {
List<ExchangisJobInfoContent> o = LabelUtils.Jackson.fromJson(exchangisJob.getContent(), List.class, ExchangisJobInfoContent.class);
o.forEach(task -> {
Expand All @@ -293,16 +293,16 @@ public List<ElementUI> getSpeedLimitSettings(Long id, String taskName) {
});
}

List<ElementUI> jobEngineSettingsUI = this.exchangisDataSourceService.getJobEngineSettingsUI(exchangisJob.getEngineType());
List<ElementUI<?>> jobEngineSettingsUI = this.exchangisDataSourceService.getJobEngineSettingsUI(exchangisJob.getEngineType());
jobEngineSettingsUI.forEach(s -> {
if (values.containsKey(s.getField())) {
if (s instanceof InputElementUI) {
InputElementUI e = (InputElementUI) s;
e.setValue(values.get(s.getField()));
e.setValue(String.valueOf(values.get(s.getField())));
}
if (s instanceof OptionElementUI) {
OptionElementUI e = (OptionElementUI) s;
e.setValue(values.get(s.getField()));
e.setValue(String.valueOf(values.get(s.getField())));
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public Message executeJob(HttpServletRequest request, @PathVariable("id") Long i

@RequestMapping( value = "{id}/speedlimit/{task_name}/params/ui", method = RequestMethod.GET)
public Message getSpeedLimitSettings(@PathVariable("id") Long id, @PathVariable("task_name") String taskName) {
List<ElementUI> speedLimitSettings = this.exchangisJobService.getSpeedLimitSettings(id, taskName);
List<ElementUI<?>> speedLimitSettings = this.exchangisJobService.getSpeedLimitSettings(id, taskName);
return Message.ok().data("ui", speedLimitSettings);
}

Expand Down

0 comments on commit de18cfe

Please sign in to comment.