
package com.kingdee.eas.custom.handover.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.handover.IWorkHandover;
import com.kingdee.eas.custom.handover.WorkHandoverInfo;
import com.kingdee.eas.custom.handover.WorkHandoverEntryInfo;
import com.kingdee.eas.custom.handover.WorkHandoverEntryCollection;

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

	@IBOSBizCtrl
	protected com.kingdee.eas.custom.handover.IWorkHandover service;

	@Inject("custom.handover.WorkHandoverEntryBean")
	protected WorkHandoverEntryBean workHandoverEntryBean;
	public AbstractWorkHandoverEditUIBean() {
		super();
	}

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

	@Override
	public void pageOnload() {
		super.pageOnload();
		
		WorkHandoverEntryCollection entryCol_0 = ((WorkHandoverInfo) model).getEntrys();

		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));
			}
	
			workHandoverEntryBean.setListModel(listModel_0);
		}

		
	}

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

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


	protected void updateModel() {
		
		if (workHandoverEntryBean == null)
			workHandoverEntryBean = (WorkHandoverEntryBean) com.kingdee.bos.waf.util.BeanUtil
					.getBean("custom.handover.WorkHandoverEntryBean");

		workHandoverEntryBean.updataModel();
		List<CoreBaseInfo> entryModel_0 = workHandoverEntryBean.getListModel();
		((WorkHandoverInfo) model).getEntrys().clear();
		if (entryModel_0 != null) {
			for (CoreBaseInfo entryInfo : entryModel_0) {
				((WorkHandoverInfo) model).getEntrys().add(
						(WorkHandoverEntryInfo) entryInfo);
			}
		}

	}
	
	
	//entry
	public void workHandoverEntryBean_apendRow(){
		workHandoverEntryBean.appendRow();
	}
	public void workHandoverEntryBean_removeRow(){
		workHandoverEntryBean.removeRow();
	}
		

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

	@Override
	public SelectorItemCollection getSelectors() {
		SelectorItemCollection sic = super.getSelectors();
        sic.add(new SelectorItemInfo("number"));
        sic.add(new SelectorItemInfo("bizDate"));
        sic.add(new SelectorItemInfo("handler.*"));
        sic.add(new SelectorItemInfo("description"));
        sic.add(new SelectorItemInfo("auditor.*"));
        sic.add(new SelectorItemInfo("entrys.id"));
        sic.add(new SelectorItemInfo("entrys.person.*"));
        sic.add(new SelectorItemInfo("entrys.workReceiver2.*"));
        sic.add(new SelectorItemInfo("entrys.workReceiver1.*"));
        sic.add(new SelectorItemInfo("entrys.workReceiver3.*"));
        sic.add(new SelectorItemInfo("entrys.approverHandover.*"));
        sic.add(new SelectorItemInfo("entrys.handoverChecklist"));
        sic.add(new SelectorItemInfo("entrys.paperFileList"));
        sic.add(new SelectorItemInfo("entrys.digitalFileList"));
        sic.add(new SelectorItemInfo("entrys.workHourFilling"));
        sic.add(new SelectorItemInfo("entrys.warehouseItems"));
        sic.add(new SelectorItemInfo("entrys.adminItemsHandover"));
        sic.add(new SelectorItemInfo("entrys.utilities"));
        sic.add(new SelectorItemInfo("entrys.bonus"));
        sic.add(new SelectorItemInfo("entrys.penalty"));
        sic.add(new SelectorItemInfo("entrys.salary"));
        sic.add(new SelectorItemInfo("entrys.loan"));
        sic.add(new SelectorItemInfo("entrys.expense"));
        sic.add(new SelectorItemInfo("entrys.other"));
        sic.add(new SelectorItemInfo("entrys.mealSettlement"));
        sic.add(new SelectorItemInfo("entrys.adminOrg.*"));
        sic.add(new SelectorItemInfo("entrys.resignBizBillEntryId"));
        sic.add(new SelectorItemInfo("entrys.resignYear"));
        sic.add(new SelectorItemInfo("entrys.resignMonth"));
        sic.add(new SelectorItemInfo("entrys.resignDay"));
        sic.add(new SelectorItemInfo("entrys.resignBizBill.*"));
	
		return sic;
	}			
    	protected String getTDTemplateName() {
	    	return "/bim/custom/handover/WorkHandover";
		}
	    protected com.kingdee.bos.metadata.IMetaDataPK getTDQueryPK() {
	    	return new com.kingdee.bos.metadata.MetaDataPK("com.kingdee.eas.custom.handover.app.WorkHandoverQuery");
	    }

}
