Search in sources :

Example 6 with ComponentConfig

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;
}
Also used : ComponentConfig(com.dtstack.taier.dao.domain.ComponentConfig)

Example 7 with 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);
}
Also used : ComponentConfig(com.dtstack.taier.dao.domain.ComponentConfig) JSONObject(com.alibaba.fastjson.JSONObject)

Aggregations

ComponentConfig (com.dtstack.taier.dao.domain.ComponentConfig)7 JSONObject (com.alibaba.fastjson.JSONObject)4 ClientTemplate (com.dtstack.taier.scheduler.impl.pojo.ClientTemplate)4 JSONArray (com.alibaba.fastjson.JSONArray)2 EComponentType (com.dtstack.taier.common.enums.EComponentType)2 EFrontType (com.dtstack.taier.common.enums.EFrontType)2 java.util (java.util)2 Predicate (java.util.function.Predicate)2 Collectors (java.util.stream.Collectors)2 MapUtils (org.apache.commons.collections.MapUtils)2 BooleanUtils (org.apache.commons.lang3.BooleanUtils)2 StringUtils (org.apache.commons.lang3.StringUtils)2 BeanUtils (org.springframework.beans.BeanUtils)2 CollectionUtils (org.springframework.util.CollectionUtils)2 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)1 Component (com.dtstack.taier.dao.domain.Component)1 ComponentVO (com.dtstack.taier.scheduler.vo.ComponentVO)1 IComponentVO (com.dtstack.taier.scheduler.vo.IComponentVO)1