package org.springblade.plugin.workflow.core.config;

import org.flowable.spring.SpringProcessEngineConfiguration;
import org.flowable.spring.boot.EngineConfigurationConfigurer;
import org.springblade.plugin.workflow.core.factory.WfActivityBehaviorFactory;
import org.springblade.plugin.workflow.core.function.WfVariableDateGreaterThanExpressionFunction;
import org.springblade.plugin.workflow.core.function.WfVariableDateGreaterThanOrEqualExpressionFunction;
import org.springblade.plugin.workflow.core.function.WfVariableDateLessThanExpressionFunction;
import org.springblade.plugin.workflow.core.function.WfVariableDateLessThanOrEqualExpressionFunction;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * flowable配置
 *
 * @author ssc
 */
@Configuration
public class WfProcessEngineConfig implements EngineConfigurationConfigurer<SpringProcessEngineConfiguration> {

	@Override
	public void configure(SpringProcessEngineConfiguration springProcessEngineConfiguration) {
		// 设置节点人员托管
		springProcessEngineConfiguration.setActivityBehaviorFactory(new WfActivityBehaviorFactory());

		// 设置自定义函数
		springProcessEngineConfiguration.setCustomFlowableFunctionDelegates(List.of(
			new WfVariableDateGreaterThanExpressionFunction(),
			new WfVariableDateGreaterThanOrEqualExpressionFunction(),
			new WfVariableDateLessThanExpressionFunction(),
			new WfVariableDateLessThanOrEqualExpressionFunction()
		));
	}
}
