use of com.dtstack.taier.dao.domain.ComponentConfig in project Taier by DTStack.
the class ComponentConfigUtils method convertClientTemplateToConfig.
public static ComponentConfig convertClientTemplateToConfig(ClientTemplate clientTemplate) {
ComponentConfig componentConfig = new ComponentConfig();
BeanUtils.copyProperties(clientTemplate, componentConfig);
if (clientTemplate.getValue() instanceof List) {
componentConfig.setValue(JSONArray.toJSONString(clientTemplate.getValue()));
} else {
componentConfig.setValue(null == clientTemplate.getValue() ? "" : String.valueOf(clientTemplate.getValue()));
}
if (null != componentConfig.getValue()) {
componentConfig.setValue(componentConfig.getValue().trim());
}
if (isOtherControl.test(componentConfig.getKey())) {
componentConfig.setType(EFrontType.OTHER.name());
} else if (EFrontType.PASSWORD.name().equalsIgnoreCase(componentConfig.getKey()) && StringUtils.isBlank(componentConfig.getDependencyKey())) {
// key password的控件转换为加密显示
componentConfig.setType(EFrontType.PASSWORD.name());
} else {
componentConfig.setType(Optional.ofNullable(clientTemplate.getType()).orElse("").toUpperCase());
}
return componentConfig;
}
use of com.dtstack.taier.dao.domain.ComponentConfig in project Taier by DTStack.
the class ComponentConfigUtils method deepToBuildConfigMap.
private static Map<String, Object> deepToBuildConfigMap(Map<String, List<ComponentConfig>> dependencyMapping, Integer maxDeep, String key) {
if (maxDeep <= 0) {
return new HashMap<>(0);
}
List<ComponentConfig> dependValueConfig = dependencyMapping.get(key);
if (!CollectionUtils.isEmpty(dependValueConfig)) {
maxDeep = --maxDeep;
Map<String, Object> keyValuesConfigMaps = new HashMap<>();
Map<String, Object> oneToMoreConfigMaps = new HashMap<>();
for (ComponentConfig componentConfig : dependValueConfig) {
// INPUT为单选
if (EFrontType.INPUT.name().equalsIgnoreCase(componentConfig.getType()) || EFrontType.SELECT.name().equalsIgnoreCase(componentConfig.getType())) {
// key-value 一对一
keyValuesConfigMaps.put(componentConfig.getKey(), componentConfig.getValue());
} else {
Map<String, Object> sonConfigMap = deepToBuildConfigMap(dependencyMapping, maxDeep, key + dependencySeparator + componentConfig.getKey());
if (!CollectionUtils.isEmpty(sonConfigMap)) {
// key-value 一对多
oneToMoreConfigMaps.put(componentConfig.getKey(), sonConfigMap);
} else {
// type类型为空
keyValuesConfigMaps.put(componentConfig.getKey(), componentConfig.getValue());
}
}
}
if (!CollectionUtils.isEmpty(oneToMoreConfigMaps)) {
keyValuesConfigMaps.put(key, oneToMoreConfigMaps);
}
return keyValuesConfigMaps;
}
return new HashMap<>(0);
}
Aggregations