
package com.kingdee.eas.custom.compensation.web;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.operamasks.faces.annotation.Inject;
import org.operamasks.faces.annotation.ManagedBean;
import org.operamasks.faces.annotation.ManagedBeanScope;
import com.kingdee.bos.metadata.IMetaDataPK;
import com.kingdee.bos.metadata.MetaDataPK;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.bos.waf.annotation.IBOSBizCtrl;
import com.kingdee.bos.waf.util.OperateState;
import com.kingdee.bos.waf.winlet.edit.EditBean;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.framework.ICoreBase;
import org.operamasks.faces.annotation.Accessible;
import org.operamasks.faces.component.form.impl.*;
import com.kingdee.bos.waf.action.AbstractWebAction;
import javax.faces.event.AbortProcessingException;
import javax.faces.context.FacesContext;
import org.operamasks.faces.component.action.ActionEvent;
import org.operamasks.faces.annotation.Action;
import com.kingdee.bos.waf.winlet.BaseBean;
import com.kingdee.bos.metadata.entity.SelectorItemInfo;

import com.kingdee.eas.custom.compensation.ISubmitShemeTemplate;
import com.kingdee.eas.custom.compensation.SubmitShemeTemplateInfo;
import com.kingdee.eas.custom.compensation.SubmitShemeTemplateEntryInfo;
import com.kingdee.eas.custom.compensation.SubmitShemeTemplateEntryCollection;

public abstract class AbstractSubmitShemeTemplateEditUIBean extends com.kingdee.bos.waf.winlet.edit.EditBean {

	@IBOSBizCtrl
	protected com.kingdee.eas.custom.compensation.ISubmitShemeTemplate service;

	@Inject("custom.compensation.SubmitShemeTemplateEntryBean")
	protected SubmitShemeTemplateEntryBean submitShemeTemplateEntryBean;
	public AbstractSubmitShemeTemplateEditUIBean() {
		super();
	}

	
	
	@Override
	public void createNewModel() {
		model = new SubmitShemeTemplateInfo();
	}

	@Override
	public void pageOnload() {
		super.pageOnload();
		
		SubmitShemeTemplateEntryCollection entryCol_0 = ((SubmitShemeTemplateInfo) model).getEntry();

		List<CoreBaseInfo> listModel_0 = new LinkedList<CoreBaseInfo>();
		if (entryCol_0 != null)
		{
			for (int i = 0, n = entryCol_0.size(); i < n; i++) {
				listModel_0.add(entryCol_0.get(i));
			}
	
			submitShemeTemplateEntryBean.setListModel(listModel_0);
		}

		
	}

	@Override
	public void saveModel() {
		updateModel();
		super.saveModel();
	}

	@Override
	public void submitModel() {
		updateModel();
		super.submitModel();
	}


	protected void updateModel() {
		
		if (submitShemeTemplateEntryBean == null)
			submitShemeTemplateEntryBean = (SubmitShemeTemplateEntryBean) com.kingdee.bos.waf.util.BeanUtil
					.getBean("custom.compensation.SubmitShemeTemplateEntryBean");

		submitShemeTemplateEntryBean.updataModel();
		List<CoreBaseInfo> entryModel_0 = submitShemeTemplateEntryBean.getListModel();
		((SubmitShemeTemplateInfo) model).getEntry().clear();
		if (entryModel_0 != null) {
			for (CoreBaseInfo entryInfo : entryModel_0) {
				((SubmitShemeTemplateInfo) model).getEntry().add(
						(SubmitShemeTemplateEntryInfo) entryInfo);
			}
		}

	}
	
	
	//entry
	public void submitShemeTemplateEntryBean_apendRow(){
		submitShemeTemplateEntryBean.appendRow();
	}
	public void submitShemeTemplateEntryBean_removeRow(){
		submitShemeTemplateEntryBean.removeRow();
	}
		

	@Override
	protected ICoreBase getBizInterface() {
		return service;
	}
	
	@Override
	public IMetaDataPK getMetaDataPK() {
		return new MetaDataPK("com.kingdee.eas.custom.compensation.web.SubmitShemeTemplateEditUI");
	}
	
	@Override
	protected String getEntryPKName() {
	
		return "entry.id";
	
	}

	@Override
	public SelectorItemCollection getSelectors() {
		SelectorItemCollection sic = super.getSelectors();
        sic.add(new SelectorItemInfo("Entry.id"));
        sic.add(new SelectorItemInfo("Entry.seq"));
        sic.add(new SelectorItemInfo("entry.column"));
        sic.add(new SelectorItemInfo("entry.alias"));
        sic.add(new SelectorItemInfo("entry.templateField"));
        sic.add(new SelectorItemInfo("entry.state"));
        sic.add(new SelectorItemInfo("entry.sorttype"));
        sic.add(new SelectorItemInfo("name"));
        sic.add(new SelectorItemInfo("number"));
        sic.add(new SelectorItemInfo("description"));
        sic.add(new SelectorItemInfo("simpleName"));
        sic.add(new SelectorItemInfo("calSubmitScheme.*"));
        sic.add(new SelectorItemInfo("state"));
        sic.add(new SelectorItemInfo("hrOrgUnit.*"));
        sic.add(new SelectorItemInfo("selectItemCol"));
        sic.add(new SelectorItemInfo("billProperties"));
        sic.add(new SelectorItemInfo("entryProperties"));
        sic.add(new SelectorItemInfo("schemeItems"));
	
		return sic;
	}			
    	protected String getTDTemplateName() {
	    	return "/bim/custom/compensation/SubmitShemeTemplate";
		}
	    protected com.kingdee.bos.metadata.IMetaDataPK getTDQueryPK() {
	    	return new com.kingdee.bos.metadata.MetaDataPK("com.kingdee.eas.custom.compensation.app.SubmitShemeTemplateQuery");
	    }

}
