package net.wicp.tams.app.duckula.controller.config.constant;

import net.wicp.tams.common.apiext.IOUtil;
import net.wicp.tams.common.constant.dic.intf.IEnumCombobox;

/**
 * checkpoint的实现方式
 * 
 * @author andy.zhou
 *
 */
public enum DevOpsType implements IEnumCombobox {

	flink("flink流计算", "oss://lc-bigdata/flink", "oss://lc-bigdata/flink/init/frontcheck.sh",
			"oss://lc-bigdata/doris/%s/check_system.sh", "v12", "oss://lc-bigdata/flink/init.tar",
			new String[] { "oss://lc-bigdata/flink/init/ssh_free.sh" }),

	doris("大数据存储", "oss://lc-bigdata/doris", "oss://lc-bigdata/doris/check_system.sh", "", "",
			"oss://lc-bigdata/doris/check_system.sh", new String[] {}),

	dmep("dmep数据平台", "oss://lc-bigdata/dmep", "", "", "", "oss://lc-bigdata/doris/check_system.sh", new String[] {});

	private final String desc;
	private final String checkurl;
	private final String baseurl;// 根路径，要跟据它来截取相对路径
	private final String installurlFormat;
	private final String lastversion;
	private final String[] otherparams;// 其它文件 ，如flink需要在check后要做免密
	private final String checkDownFile;// OSS要下载的文件

	public String getCheckDownFile() {
		return checkDownFile;
	}

	// 服务器上相对文件地址
	public String getRelaPath(String url) {
		return url.replace(this.baseurl, "/" + this.name());
	}

	public String getRelaPathCheck() {
		return getRelaPath(this.checkurl);
	}

	// 服务器上真实的目录地址
	public String getRemoteDirCheckDir() {
		String fileName = this.checkurl.substring(this.checkurl.lastIndexOf("/") + 1);
		String replace = getRelaPathCheck().replace(fileName, "");
		String retstr = IOUtil.mergeFolderAndFilePath("~/", replace);
		return retstr;
	}

	public String[] getOtherparams() {
		return otherparams;
	}

	public String getCheckurl() {
		return checkurl;
	}

	public String getLastversion() {
		return lastversion;
	}

	public String getInstallurl() {
		return String.format(this.installurlFormat, lastversion);
	}

	private DevOpsType(String desc, String baseurl, String checkurl, String installurlFormat, String lastversion,
			String checkDownFile, String[] otherparams) {
		this.desc = desc;
		this.baseurl = baseurl;
		this.checkurl = checkurl;
		this.installurlFormat = installurlFormat;
		this.lastversion = lastversion;
		this.checkDownFile = checkDownFile;
		this.otherparams = otherparams;
	}

	public String getDesc() {
		return desc;
	}

	public String getName() {
		return this.name();
	}

	@Override
	public String getDesc_zh() {
		return this.desc;
	}

	@Override
	public String getDesc_en() {
		return this.name();
	}
}
