package nccloud.web.hrwa.waruleex.action.formula.factory;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import nc.hr.utils.ResHelper;
import nc.vo.hr.datasource.HrDatasourceType;
import nc.vo.hr.func.FunctionVO;
import nc.vo.pub.BusinessException;
import nc.vo.wa.formula.WaFormulaXmlHelper;
import nc.vo.wa.pub.WaLoginContext;
import nccloud.web.hr.formula.HRFormulaType4Web;
import nccloud.web.hr.formula.itf.AbstractVariableFactory;
import nccloud.web.hr.formula.itf.IVariableFactory;
import nccloud.web.hr.formula.variable.IHrVaribleItemCreator;
import nccloud.web.hr.formula.variable.PsndocHrVariableCreator;
import nccloud.web.hr.formula.variable.PsnjobHrVariableCreator;
import nccloud.web.hrwa.classitem.action.formula.pub.WaDatasourceManager;
import nccloud.web.hrwa.waruleex.action.formula.variable.WaRuleExVariableCreator;

/**
 * 薪资发放项目公式项创建工厂
 * @author YuCheng
 */
public class WaRuleExFormulaTypeFactory extends AbstractVariableFactory{
	
	private WaLoginContext context = null;
	
	public WaRuleExFormulaTypeFactory(WaLoginContext context) {
		this.context = context;
	}
	

	@Override
	protected HrDatasourceType[] getDataSourceTypes() throws BusinessException {
		// 取所有配置的数据源 /hr/wa/otherdatasource/wa_otherdatasource.xml
		return WaDatasourceManager.getAllDsType();
	}

	@Override
	protected FunctionVO[] getFunctions(HrDatasourceType dsType) {
		if("WAORTHER".equals(dsType.getProductcode())){
			//薪资
			return null;
		}
		return WaFormulaXmlHelper.getFunctionVOByGroup(dsType.getProductcode());
	}

	@Override
	protected List<HRFormulaType4Web> getTableList() {
		List<HRFormulaType4Web>  tableList = new ArrayList<HRFormulaType4Web>();
        //只安装薪资不安装员工信息，需要在公式设置的项目一栏加入“人员类别”、“所在部门”
		tableList.add(new HRFormulaType4Web(IVariableFactory.WA_ITEM_DES, ResHelper.getString("6013commonbasic", "06013commonbasic0016")/* @res"公共薪资项目" */));
		tableList.add(new HRFormulaType4Web(IVariableFactory.HI_PSNJOB, ResHelper.getString("601315common", "0601315common0016")/* @res "人员工作信息" */));
		tableList.add(new HRFormulaType4Web(IVariableFactory.BD_PSNDOC, ResHelper.getString("601315common", "0601315common0015")/* @res"人员基本信息" */));
		tableList.add(new HRFormulaType4Web(IVariableFactory.WA_PRMLV, IVariableFactory.GRADENAME/* @res"薪资标准设置" */+IVariableFactory.WA_PRMLV_DES/*@res "<级别>"*/));
		tableList.add(new HRFormulaType4Web(IVariableFactory.WA_SECLV, IVariableFactory.GRADENAME/* @res"薪资标准设置" */+IVariableFactory.WA_SECLV_DES/*@res "<档别>"*/));
		return tableList;
	}

	@Override
	protected Map<String, IHrVaribleItemCreator> getItemCreatorMap() {
		
		Map<String, IHrVaribleItemCreator> itemCreatorMap = new HashMap<String, IHrVaribleItemCreator>();
		itemCreatorMap.put(IVariableFactory.WA_ITEM_DES, new WaRuleExVariableCreator(context));
		itemCreatorMap.put(IVariableFactory.HI_PSNJOB, new PsnjobHrVariableCreator());
		itemCreatorMap.put(IVariableFactory.BD_PSNDOC, new PsndocHrVariableCreator());
		itemCreatorMap.put(IVariableFactory.WA_PRMLV, new WaRuleExVariableCreator(context));
		itemCreatorMap.put(IVariableFactory.WA_SECLV, new WaRuleExVariableCreator(context));
		
		//itemCreatorMap.put(IVariableFactory.WA_PRMLV, new WaPrmlvHrVariableCreator());
		//itemCreatorMap.put(IVariableFactory.WA_SECLV, new WaSeclvHrVariableCreator());
		return itemCreatorMap;
	}

}
