All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yomahub.liteflow.parser.sql.polling.impl.ChainReadPollTask Maven / Gradle / Ivy

There is a newer version: 2.12.4.2
Show newest version
package com.yomahub.liteflow.parser.sql.polling.impl;

import cn.hutool.core.util.StrUtil;
import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.parser.constant.ReadType;
import com.yomahub.liteflow.parser.sql.polling.AbstractSqlReadPollTask;
import com.yomahub.liteflow.parser.sql.read.SqlRead;
import com.yomahub.liteflow.parser.sql.read.vo.ChainVO;

import java.util.List;
import java.util.Map;
import java.util.function.Consumer;

/**
 * chain 读取任务
 *
 * @author tangkc
 * @author houxinyu
 * @since 2.11.1
 */
public class ChainReadPollTask extends AbstractSqlReadPollTask {

    public ChainReadPollTask(SqlRead read) {
        super(read);
    }

    @Override
    public void doSave(List saveElementList) {
        saveElementList.forEach(chainVO ->
                LiteFlowChainELBuilder.createChain().setChainId(chainVO.getChainId())
                .setRoute(chainVO.getRoute())
                .setNamespace(chainVO.getNamespace())
                .setEL(chainVO.getBody())
                .build());
    }

    @Override
    public void doDelete(List deleteElementId) {
        for (String id : deleteElementId) {
            FlowBus.removeChain(id);
        }
    }

    @Override
    protected String getKey(ChainVO chainVO) {
        return chainVO.getChainId();
    }

    @Override
    protected String getValue(ChainVO chainVO) {
        return chainVO.getBody();
    }

    @Override
    protected String getExtValue(ChainVO chainVO) {
        return chainVO.getRoute();
    }

    @Override
    public ReadType type() {
        return ReadType.CHAIN;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy