package org.hzhub.workflow.workflow;

import org.hzhub.workflow.entity.WorkflowComponent;
import org.hzhub.workflow.entity.WorkflowNode;
import org.hzhub.workflow.workflow.node.AbstractWfNode;
import org.hzhub.workflow.workflow.node.EndNode;
import org.hzhub.workflow.workflow.node.humanFeedBack.HumanFeedbackNode;
import org.hzhub.workflow.workflow.node.answer.LLMAnswerNode;
import org.hzhub.workflow.workflow.node.httpRequest.HttpRequestNode;
import org.hzhub.workflow.workflow.node.image.ImageNode;
import org.hzhub.workflow.workflow.node.keywordExtractor.KeywordExtractorNode;
import org.hzhub.workflow.workflow.node.knowledgeRetrieval.KnowledgeRetrievalNode;
import org.hzhub.workflow.workflow.node.mailSend.MailSendNode;
import org.hzhub.workflow.workflow.node.start.StartNode;
import org.hzhub.workflow.workflow.node.switcher.SwitcherNode;

public class WfNodeFactory {
    public static AbstractWfNode create(WorkflowComponent wfComponent, WorkflowNode nodeDefinition,
                                        WfState wfState, WfNodeState nodeState) {
        AbstractWfNode wfNode = null;
        switch (WfComponentNameEnum.getByName(wfComponent.getName())) {
            case START -> wfNode = new StartNode(wfComponent, nodeDefinition, wfState, nodeState);
            case LLM_ANSWER -> wfNode = new LLMAnswerNode(wfComponent, nodeDefinition, wfState, nodeState);
            case KEYWORD_EXTRACTOR -> wfNode = new KeywordExtractorNode(wfComponent, nodeDefinition, wfState, nodeState);
            case TONGYI_WANX -> wfNode = new ImageNode(wfComponent, nodeDefinition, wfState, nodeState);
            case KNOWLEDGE_RETRIEVER -> wfNode = new KnowledgeRetrievalNode(wfComponent, nodeDefinition, wfState, nodeState);
            case END -> wfNode = new EndNode(wfComponent, nodeDefinition, wfState, nodeState);
            case MAIL_SEND -> wfNode = new MailSendNode(wfComponent, nodeDefinition, wfState, nodeState);
            case HTTP_REQUEST -> wfNode = new HttpRequestNode(wfComponent, nodeDefinition, wfState, nodeState);
            case SWITCHER -> wfNode = new SwitcherNode(wfComponent, nodeDefinition, wfState, nodeState);
            case HUMAN_FEEDBACK -> wfNode = new HumanFeedbackNode(wfComponent, nodeDefinition, wfState, nodeState);
            default -> {
            }
        }
        return wfNode;
    }
}
