/**
 * 
 */
package org.springblade.etl.enums;

import org.springblade.etl.connector.base.SeatunnelConnector;
import org.springblade.etl.connector.sink.*;
import org.springblade.etl.connector.source.PlatomixCubeSource;
import org.springblade.etl.connector.source.PlatomixFtpFileSource;
import org.springblade.etl.connector.source.PlatomixHttpSource;
import org.springblade.etl.connector.source.PlatomixJdbcSource;
import org.springblade.etl.connector.source.PlatomixKafkaSource;
import org.springblade.etl.connector.source.PlatomixLocalFileSource;
import org.springblade.etl.connector.source.PlatomixMysqlCdcSource;
import org.springblade.etl.connector.transform.PlatomixColumnAddTransform;
import org.springblade.etl.connector.transform.PlatomixColumnMergeTransform;
import org.springblade.etl.connector.transform.PlatomixColumnSelectTransform;
import org.springblade.etl.connector.transform.PlatomixConditionTransform;
import org.springblade.etl.connector.transform.PlatomixDistinctTransform;
import org.springblade.etl.connector.transform.PlatomixNullReplaceTransform;
import org.springblade.etl.connector.transform.PlatomixPrimaryKeyAddTransform;
import org.springblade.etl.connector.transform.PlatomixReplaceTransform;
import org.springblade.etl.connector.transform.PlatomixRowStackTransform;
import org.springblade.etl.connector.transform.PlatomixScriptJavaTransform;
import org.springblade.etl.connector.transform.PlatomixTypeConversionTransform;

import com.baomidou.mybatisplus.annotation.EnumValue;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author wookvn
 *
 */
@Getter
@AllArgsConstructor
public enum ConnectorType {

	//source
	SOURCE_JDBC(1, "connector-jdbc", "Jdbc", PluginType.SOURCE, PlatomixJdbcSource.class),
	SOURCE_CUBE(2, "connector-jdbc", "Jdbc", PluginType.SOURCE, PlatomixCubeSource.class),
	SOURCE_MYSQL_CDC(3, "connector-cdc-mysql", "MySQL-CDC", PluginType.SOURCE, PlatomixMysqlCdcSource.class),
	SOURCE_KAFKA(4, "connector-kafka", "Kafka", PluginType.SOURCE, PlatomixKafkaSource.class),
	SOURCE_LOCALFILE(5, "connector-file-sftp", "SftpFile", PluginType.SOURCE, PlatomixLocalFileSource.class),
	SOURCE_FTPFILE(6, "connector-file-ftp", "FtpFile", PluginType.SOURCE, PlatomixFtpFileSource.class),
	SOURCE_SFTPFILE(7, "connector-file-sftp", "SftpFile", PluginType.SOURCE, PlatomixFtpFileSource.class),
	SOURCE_HTTP(8, "connector-http-base", "Http", PluginType.SOURCE, PlatomixHttpSource.class),
	
	//transform
	TRANSFORM_REPLACE(50, "", "ReplaceRegular", PluginType.TRANSFORM, PlatomixReplaceTransform.class),
	TRANSFORM_CONDITION(51, "", "FieldCondition", PluginType.TRANSFORM, PlatomixConditionTransform.class),
	TRANSFORM_COLUMMERGE(52, "", "ColMerge", PluginType.TRANSFORM, PlatomixColumnMergeTransform.class),
	TRANSFORM_COLUMADD(53, "", "ColAdd", PluginType.TRANSFORM, PlatomixColumnAddTransform.class),
	TRANSFORM_TYPECONVERSION(54, "", "TypeConversion", PluginType.TRANSFORM, PlatomixTypeConversionTransform.class),
	TRANSFORM_NULLREPLACE(55, "", "ReplaceNull", PluginType.TRANSFORM, PlatomixNullReplaceTransform.class),
	TRANSFORM_DISTINCT(56, "", "Distinct", PluginType.TRANSFORM, PlatomixDistinctTransform.class),
	TRANSFORM_PRIMAYKEY_ADD(57, "", "PrimaryAdd", PluginType.TRANSFORM, PlatomixPrimaryKeyAddTransform.class),
	TRANSFORM_COLUMNSELECT(58, "", "FieldSelect", PluginType.TRANSFORM, PlatomixColumnSelectTransform.class),
	TRANSFORM_ROWSTACK(59, "", "RowStack", PluginType.TRANSFORM, PlatomixRowStackTransform.class),
	TRANSFORM_SCRIPT_JAVA(60, "", "ScriptJava", PluginType.TRANSFORM, PlatomixScriptJavaTransform.class),
	
	//sink
	SINK_JDBC(100, "connector-jdbc", "Jdbc", PluginType.SINK, PlatomixJdbcSink.class),
	SINK_CLICKHOUSE(101, "connector-clickhouse", "Clickhouse", PluginType.SINK, PlatomixClickhouseSink.class),
	SINK_FTPFILE(102, "connector-file-ftp", "FtpFile", PluginType.SINK, PlatomixFtpSink.class),
	SINK_SFTPFILE(103, "connector-file-sftp", "SftpFile", PluginType.SINK, PlatomixFtpSink.class),
	SINK_MONGO(104, "connector-mongodb", "MongoDB", PluginType.SINK, PlatomixMongoSink.class),

	//预览sink
	SINK_PREVIEW(999, "connector-preview", "Preview", PluginType.SINK, PlatomixPreviewSink.class),
	
	;
	
	@EnumValue
	private Integer value;
	private String jarPrefix;
	private String pluginName;
	private PluginType pluginType;
	private Class<? extends SeatunnelConnector<?>> clazz;
	
	/**
	 * 是否流
	 * @return
	 */
	public boolean isStreaming() {
		return this == ConnectorType.SOURCE_KAFKA || this == ConnectorType.SOURCE_MYSQL_CDC;
	}
	/**
	 * 是否文件
	 * @return
	 */
	public boolean isFile() {
		return this == ConnectorType.SOURCE_SFTPFILE || this == ConnectorType.SOURCE_FTPFILE 
				|| this == ConnectorType.SOURCE_LOCALFILE || this == ConnectorType.SINK_FTPFILE
				|| this == ConnectorType.SINK_SFTPFILE;
	}
}
