Search in sources :

Example 1 with DsFormField

use of com.dtstack.taier.dao.domain.DsFormField in project Taier by DTStack.

the class DsFormFieldService method findTemplateByTypeVersion.

/**
 * 根据数据库类型和版本查找表单模版
 * @param param
 * @return
 */
public DsFormTemplateVo findTemplateByTypeVersion(DsTypeVersionParam param) {
    DsFormTemplateVo returnVo = new DsFormTemplateVo();
    String typeVersion = param.getDataType();
    if (Strings.isNotBlank(param.getDataVersion())) {
        typeVersion = param.getDataType() + "-" + param.getDataVersion();
    }
    List<DsFormField> formFieldList = this.list(Wrappers.<DsFormField>query().eq("type_version", typeVersion).or().eq("type_version", COMMON));
    List<DsFormFieldVo> formFieldVos = new ArrayList<>();
    for (DsFormField dsFormField : formFieldList) {
        DsFormFieldVo dsFormFieldVo = new DsFormFieldVo();
        BeanUtils.copyProperties(dsFormField, dsFormFieldVo);
        if (StringUtils.isNotBlank(dsFormField.getOptions())) {
            List<Map> optionList = JSON.parseArray(dsFormField.getOptions(), Map.class);
            dsFormFieldVo.setOptions(optionList);
        }
        formFieldVos.add(dsFormFieldVo);
    }
    returnVo.setDataType(param.getDataType());
    returnVo.setDataVersion(param.getDataVersion());
    returnVo.setFromFieldVoList(formFieldVos);
    return returnVo;
}
Also used : DsFormFieldVo(com.dtstack.taier.develop.vo.datasource.DsFormFieldVo) ArrayList(java.util.ArrayList) DsFormTemplateVo(com.dtstack.taier.develop.vo.datasource.DsFormTemplateVo) Map(java.util.Map) DsFormField(com.dtstack.taier.dao.domain.DsFormField)

Example 2 with DsFormField

use of com.dtstack.taier.dao.domain.DsFormField in project Taier by DTStack.

the class DatasourceService method getDataSourceLinkInfo.

/**
 * 根据数据源版本获取对应的连接信息
 * @param dataType
 * @param dataVersion
 * @param dataJson
 * @return
 */
public String getDataSourceLinkInfo(String dataType, String dataVersion, JSONObject dataJson) {
    List<DsFormField> linkFieldList = formFieldService.findLinkFieldByTypeVersion(dataType, dataVersion);
    if (CollectionUtils.isEmpty(linkFieldList)) {
        return null;
    }
    JSONObject linkJson = new JSONObject();
    for (DsFormField dsFormField : linkFieldList) {
        String value = JsonUtils.getStrFromJson(dataJson, dsFormField.getName());
        if (Strings.isNotBlank(value)) {
            linkJson.put(dsFormField.getName(), value);
        }
    }
    return linkJson.toJSONString();
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) DsFormField(com.dtstack.taier.dao.domain.DsFormField)

Aggregations

DsFormField (com.dtstack.taier.dao.domain.DsFormField)2 JSONObject (com.alibaba.fastjson.JSONObject)1 DsFormFieldVo (com.dtstack.taier.develop.vo.datasource.DsFormFieldVo)1 DsFormTemplateVo (com.dtstack.taier.develop.vo.datasource.DsFormTemplateVo)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1