//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.kingdee.shr.base.syssetting.app.io.fileImport;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.BOSObjectFactory;
import com.kingdee.bos.Context;
import com.kingdee.bos.ICommonBOSType;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.metadata.IMetaDataLoader;
import com.kingdee.bos.metadata.MetaDataLoaderFactory;
import com.kingdee.bos.metadata.MetaDataPK;
import com.kingdee.bos.metadata.entity.EntityObjectInfo;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.bos.metadata.entity.SelectorItemInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.ep.CoreBillBaseCustomInfo;
import com.kingdee.eas.ep.DataBaseCustomInfo;
import com.kingdee.eas.framework.CoreBaseCollection;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.framework.ICoreBase;
import com.kingdee.eas.hr.base.app.filter.StructureConfigConvertHelper;
import com.kingdee.eas.hr.emp.PersonCredentialsTypeInfo;
import com.kingdee.shr.base.syssetting.BaseItemCustomInfo;
import com.kingdee.shr.base.syssetting.ml.SHRWebResource;
import com.kingdee.shr.base.syssetting.util.LocaleUtils;
import com.kingdee.shr.base.syssetting.web.dynamic.model.DynamicModelInfo;
import com.kingdee.shr.baseconfig.QueryConfigFieldInfo;
import com.kingdee.shr.baseconfig.StructureConfigFilterColumnCollection;
import com.kingdee.shr.baseconfig.StructureConfigFilterColumnInfo;
import com.kingdee.shr.baseconfig.StructureConfigInfo;
import com.kingdee.shr.shrimport.SHRImportTypeEnum;
import com.kingdee.util.StringUtils;
import com.kingdee.util.enums.Enum;
import com.kingdee.util.enums.IntEnum;
import com.kingdee.util.enums.StringEnum;
import java.lang.reflect.Constructor;
import java.sql.Timestamp;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.log4j.Logger;

public class DynamicModelHelper {
	private Context ctx = null;
	private String scheme = null;
	private SHRImportTypeEnum importTypeEnum = null;
	private static Logger logger = Logger.getLogger(DynamicModelHelper.class);
	private Map<String, String> importPropNameAndEntityPropMap = null;
	private Map<String, ImportEntityInfo> entityInfoMap = null;
	private Map<String, ICoreBase> entityICoreBase = null;
	private String mainEntityFullName = null;
	private String mainEntityShortName = null;
	private boolean multiImport;
	private BaseRowInfo currentRow = null;
	private String currentBillid = null;

	public DynamicModelHelper(String scheme, Context ctx, Map<String, BaseColumnInfo> columnMap, SHRImportTypeEnum importType) throws BOSException, EASBizException {
		this.ctx = ctx;
		this.scheme = scheme;
		this.importPropNameAndEntityPropMap = new HashMap();
		this.importTypeEnum = importType;
		StructureConfigInfo main = StructureConfigConvertHelper.getMain(this.ctx, this.scheme);
		if (main == null) {
			throw new ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "unable_get_primary_entity", this.ctx));
		} else {
			this.mainEntityFullName = main.getEntityName();
			this.entityInfoMap = new HashMap();
			Iterator<Entry<String, BaseColumnInfo>> iter = columnMap.entrySet().iterator();
			this.multiImport = true;
			BaseColumnInfo columnInfo = null;
			ArrayList temp = new ArrayList();

			while(iter.hasNext()) {
				columnInfo = (BaseColumnInfo)((Entry)iter.next()).getValue();
				if (!this.handleColumnInfo(columnInfo)) {
					temp.add(columnInfo);
				}
			}

			Iterator tempIter = temp.iterator();

			while(tempIter.hasNext()) {
				columnInfo = (BaseColumnInfo)tempIter.next();
				this.handleColumnInfo(columnInfo);
			}

		}
	}

	private boolean handleColumnInfo(BaseColumnInfo columnInfo) throws EASBizException, BOSException {
		return this.handleColumnInfo(columnInfo, true);
	}

	public void setCurrentBillid(String billId) {
		this.currentBillid = billId;
	}

	private boolean handleColumnInfo(BaseColumnInfo columnInfo, boolean convertColumn) throws EASBizException, BOSException {
		String shortName = this.getEntityShortNameByPropName(columnInfo.getPropName());
		ImportEntityInfo importEntityInfo = (ImportEntityInfo)this.entityInfoMap.get(shortName);
		if (importEntityInfo == null) {
			if (convertColumn) {
				columnInfo = this.convertColumnInfo(columnInfo);
				return this.handleColumnInfo(columnInfo, false);
			}

			importEntityInfo = this.getImportEntityInfo(columnInfo.getPropName());
			if (importEntityInfo == null) {
				return false;
			}

			this.entityInfoMap.put(shortName, importEntityInfo);
			if (importEntityInfo.getEntityFullName().equals(this.mainEntityFullName)) {
				this.mainEntityShortName = shortName;
				importEntityInfo.setMainEntity(true);
			}

			if (this.multiImport && !importEntityInfo.isMainEntity() && !importEntityInfo.isMultiRow()) {
				this.multiImport = false;
			}
		}

		importEntityInfo.addImportColumn(columnInfo);
		return true;
	}

	private BaseColumnInfo convertColumnInfo(BaseColumnInfo columnInfo) throws BOSException {
		String propName = columnInfo.getPropName();
		if (logger.isDebugEnabled()) {
			logger.debug("debugxg1" + propName);
		}

		QueryConfigFieldInfo fieldInfo = StructureConfigConvertHelper.getQueryFieldByKey(this.ctx, this.scheme, propName);
		if (fieldInfo == null) {
			return columnInfo;
		} else {
			StructureConfigInfo configInfo = fieldInfo.getFactField().getStructureConfig();
			if (!configInfo.isBaseData()) {
				return columnInfo;
			} else {
				StructureConfigInfo parentConfigInfo = configInfo.getParent();
				if (parentConfigInfo.isBaseData()) {
					return columnInfo;
				} else {
					if (logger.isDebugEnabled()) {
						logger.debug("debugxg2" + propName);
					}

					configInfo = StructureConfigConvertHelper.getStructureConfigByID(this.ctx, configInfo.getId().toString(), this.scheme);
					String tempRelationName = this.getRelationName(configInfo);
					if (logger.isDebugEnabled()) {
						logger.debug("debugxg3" + parentConfigInfo.getId() + "|" + parentConfigInfo.getName());
					}

					String parentShortName = parentConfigInfo.getClientNumber().toUpperCase();
					BaseColumnInfo tempColumnInfo = new BaseColumnInfo(parentShortName + "." + tempRelationName, columnInfo.getName(), columnInfo.isNecessary(), 0, (String)null);
					tempColumnInfo.setColumnIndex(columnInfo.getColumnIndex());
					return tempColumnInfo;
				}
			}
		}
	}

	private String getEntityShortNameByPropName(String propName) {
		String[] strs = propName.split("\\.");
		return strs.length > 0 ? strs[0].toUpperCase() : propName.toUpperCase();
	}

	private ImportEntityInfo getImportEntityInfo(String propName) throws BOSException, EASBizException {
		QueryConfigFieldInfo fieldInfo = StructureConfigConvertHelper.getQueryFieldByKey(this.ctx, this.scheme, propName);
		StructureConfigInfo configInfo = null;
		String tempRelationName;
		if (fieldInfo == null) {
			String[] split = propName.split("\\.");
			tempRelationName = "";
			if (split.length > 0) {
				tempRelationName = split[0];
			}

			configInfo = StructureConfigConvertHelper.getStructureConfigByNumber(this.ctx, tempRelationName, this.scheme);
			if (configInfo == null) {
				return null;
			}
		}

		ImportEntityInfo entityInfo = new ImportEntityInfo();
		if (configInfo == null) {
			configInfo = fieldInfo.getFactField().getStructureConfig();
			configInfo = StructureConfigConvertHelper.getStructureConfigByID(this.ctx, configInfo.getId().toString(), configInfo.getScheme().getNumber());
		}

		entityInfo.setEntityAliasName(configInfo.getAlias());
		entityInfo.setConfigInfo(configInfo);
		entityInfo.setEntityFullName(configInfo.getEntityName());
		entityInfo.setMultiRow(configInfo.isMultiRow());
		if (configInfo.isMultiRow() && configInfo.isSupportSingleView()) {
			entityInfo.setSingleShowCondition(configInfo.getSingleCondition());
		}

		entityInfo.setSingleFields(configInfo.getSingleFields());
		if (configInfo.getParent() != null) {
			tempRelationName = this.getRelationName(configInfo);
			entityInfo.setRelationName(tempRelationName);
		}

		return entityInfo;
	}

	private String getRelationName(StructureConfigInfo configInfo) {
		String tempRelationName = null;
		StructureConfigFilterColumnCollection filterColumnList = configInfo.getFilterColumn();
		int i = 0;

		for(int size = filterColumnList.size(); i < size; ++i) {
			StructureConfigFilterColumnInfo filterColumn = filterColumnList.get(i);
			if (filterColumn.getParentColumn() != null && "id".equalsIgnoreCase(filterColumn.getClientColumn())) {
				tempRelationName = filterColumn.getParentColumn();
				break;
			}

			if (filterColumn.getParentColumn() != null && "id".equalsIgnoreCase(filterColumn.getParentColumn())) {
				tempRelationName = filterColumn.getClientColumn();
				break;
			}

			if (filterColumn.getParentColumn() != null && "person".equalsIgnoreCase(filterColumn.getParentColumn()) && "person".equalsIgnoreCase(filterColumn.getClientColumn())) {
				return filterColumn.getParentColumn();
			}
		}

		return tempRelationName;
	}

	public void setRow(BaseRowInfo row) {
		this.currentRow = row;
	}

	public ICoreBase getEntityInterface(String entityName) {
		if (this.entityICoreBase == null) {
			this.entityICoreBase = new HashMap();
		}

		ICoreBase coreBase = (ICoreBase)this.entityICoreBase.get(entityName);
		if (coreBase == null) {
			MetaDataPK entityPK = MetaDataPK.create(entityName);

			try {
				coreBase = (ICoreBase)BOSObjectFactory.createCommonBOSObject(this.ctx, entityPK);
				this.entityICoreBase.put(entityName, coreBase);
			} catch (BOSException var5) {
				throw new ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "get_api_instance_error", this.ctx), var5);
			}
		}

		return coreBase;
	}

	public DynamicModelInfo convertRowToDynamicModel(BaseRowInfo row) throws ImportException {
		this.currentRow = row;
		return this.convertRowToDynamicModel();
	}

	public DynamicModelInfo convertRowToDynamicModel() {
		if (this.currentRow == null) {
			throw new ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "row_data_isempty", this.ctx));
		} else {
			ImportEntityInfo mainEntityInfo = (ImportEntityInfo)this.entityInfoMap.get(this.mainEntityShortName);
			CoreBaseInfo mainCoreBaseInfo = this.loadMainEntityInfo(mainEntityInfo);
			if (mainCoreBaseInfo == null) {
				throw new ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "entity_not_found", this.ctx));
			} else {
				this.currentBillid = mainCoreBaseInfo.getId().toString();
				DynamicModelInfo dyModelInfo = new DynamicModelInfo();
				HashMap<String, IObjectValue> valueMap = new HashMap();
				HashMap<String, Boolean> hasData = new HashMap();
				valueMap.put(mainEntityInfo.getEntityFullName(), mainCoreBaseInfo);
				hasData.put(mainEntityInfo.getEntityFullName(), true);
				dyModelInfo.setValueMap(valueMap);
				Iterator<Entry<String, ImportEntityInfo>> iter = this.entityInfoMap.entrySet().iterator();
				ImportEntityInfo entityInfo = null;

				while(iter.hasNext()) {
					entityInfo = (ImportEntityInfo)((Entry)iter.next()).getValue();
					if (!valueMap.containsKey(entityInfo.getEntityFullName())) {
						CoreBaseInfo baseInfo = this.loadEntityInfo(entityInfo);
						// start xiaoxin 员工证件信息新增导入时,不根据证件类型做唯一校验更新数据，进入新增操作
						if(baseInfo instanceof PersonCredentialsTypeInfo && importTypeEnum.getValue()==10){
							baseInfo = null;
						}
						// end xiaoxin
						if (baseInfo == null) {
							SelectorItemCollection coll = this.getLoadSelectorColl(entityInfo.getImportColumn());
							if (coll.size() == 0) {
								hasData.put(entityInfo.getEntityFullName(), false);
							}
						} else {
							valueMap.put(entityInfo.getEntityFullName(), baseInfo);
							hasData.put(entityInfo.getEntityFullName(), true);
						}
					}
				}

				this.verifyOrCreateBlankBaseInfo(dyModelInfo, hasData);
				this.assignInfoSaveValue(dyModelInfo, hasData);
				this.currentBillid = null;
				return dyModelInfo;
			}
		}
	}

	private void verifyOrCreateBlankBaseInfo(DynamicModelInfo dyModelInfo, HashMap<String, Boolean> hasData) {
		HashMap<String, IObjectValue> valueMap = dyModelInfo.getValueMap();
		StringBuffer errorMsg = new StringBuffer();
		Iterator<Entry<String, ImportEntityInfo>> iter = this.entityInfoMap.entrySet().iterator();
		ImportEntityInfo entityInfo = null;
		IObjectValue baseInfo = null;
		String tempEntityFullName = null;

		while(true) {
			String emsg;
			do {
				do {
					if (!iter.hasNext()) {
						emsg = errorMsg.toString();
						if (!StringUtils.isEmpty(emsg)) {
							throw new ImportException(emsg);
						}

						return;
					}

					entityInfo = (ImportEntityInfo)((Entry)iter.next()).getValue();
				} while(entityInfo.isMainEntity());

				tempEntityFullName = entityInfo.getEntityFullName();
			} while(hasData.get(tempEntityFullName) != null && !(Boolean)hasData.get(tempEntityFullName));

			baseInfo = (IObjectValue)valueMap.get(tempEntityFullName);
			switch(this.importTypeEnum.getValue()) {
				case 10:
					if (baseInfo == null) {
						baseInfo = this.createInfo(tempEntityFullName);
						valueMap.put(tempEntityFullName, baseInfo);
					} else {
						// start xiaoxin 员工证件信息导入时不根据证件类型做唯一校验
						if(!(baseInfo instanceof PersonCredentialsTypeInfo)){
							emsg = MessageFormat.format(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "add_fails_already_exist", this.ctx), entityInfo.getEntityAliasName());
							errorMsg.append(emsg);
						}
//						emsg = MessageFormat.format(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "add_fails_already_exist", this.ctx), entityInfo.getEntityAliasName());
//						errorMsg.append(emsg);
						// end xioaxin
					}
					break;
				case 20:
					if (baseInfo == null) {
						emsg = MessageFormat.format(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "cover_fails_not_load", this.ctx), entityInfo.getEntityAliasName());
						errorMsg.append(emsg);
					} else {
						CoreBaseInfo coreBaseInfo = this.createInfo(tempEntityFullName);
						coreBaseInfo.setId(((CoreBaseInfo)baseInfo).getId());
						valueMap.put(tempEntityFullName, coreBaseInfo);
					}
					break;
				case 30:
					if (baseInfo == null) {
						emsg = MessageFormat.format(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "update_fails_not_load", this.ctx), entityInfo.getEntityAliasName());
						errorMsg.append(emsg);
					}
					break;
				case 40:
					if (baseInfo == null) {
						baseInfo = this.createInfo(tempEntityFullName);
						valueMap.put(tempEntityFullName, baseInfo);
					}
			}
		}
	}

	private void assignInfoSaveValue(DynamicModelInfo dyModelInfo, HashMap<String, Boolean> hasData) {
		HashMap<String, IObjectValue> tempObjMap = dyModelInfo.getValueMap();
		LinkedHashMap<String, IObjectValue> saveModelMap = new LinkedHashMap();
		Iterator<Entry<String, ImportEntityInfo>> iter = this.entityInfoMap.entrySet().iterator();
		ImportEntityInfo entityInfo = null;
		IObjectValue coreBase = null;
		BaseColumnInfo tempColumnInfo = null;
		Object tempValue = null;
		boolean hasUpdate = this.importTypeEnum.getValue() == 40 || this.importTypeEnum.getValue() == 30;

		while(true) {
			Boolean has;
			do {
				if (!iter.hasNext()) {
					if (tempObjMap.containsKey(this.mainEntityFullName)) {
						saveModelMap.put(this.mainEntityFullName, tempObjMap.get(this.mainEntityFullName));
						tempObjMap.remove(this.mainEntityFullName);
					}

					saveModelMap.putAll(tempObjMap);
					dyModelInfo.setSaveModelMap(saveModelMap);
					return;
				}

				entityInfo = (ImportEntityInfo)((Entry)iter.next()).getValue();
				has = (Boolean)hasData.get(entityInfo.getEntityFullName());
			} while(has != null && !has);

			coreBase = (IObjectValue)tempObjMap.get(entityInfo.getEntityFullName());
			boolean tempBoolean = hasUpdate && coreBase.get(coreBase.getPKField()) != null;
			List<BaseColumnInfo> columnInfoList = entityInfo.getImportColumn();
			boolean isPersonEntity = this.isPersonEntity(entityInfo.getEntityFullName());
			int i = 0;

			for(int size = columnInfoList.size(); i < size; ++i) {
				tempColumnInfo = (BaseColumnInfo)columnInfoList.get(i);
				if (!isPersonEntity || !"person.name".equals(tempColumnInfo.getPropName()) && !"person.number".equals(tempColumnInfo.getPropName())) {
					String valString;
					if (tempBoolean) {
						valString = this.currentRow.getValueOfStringByIndex(tempColumnInfo.getColumnIndex());
						if (StringUtils.isEmpty(valString)) {
							continue;
						}

						if (ValueCovertUtils.UPDATE_BLANK_FLAG.equals(valString)) {
							tempValue = null;
						}
					}

					tempValue = this.currentRow.getValueOfObjectByIndex(tempColumnInfo.getColumnIndex());
					valString = this.getEntityPropName(tempColumnInfo.getPropName());
					coreBase.put(valString, tempValue);
					if (1 == tempColumnInfo.getDataType()) {
						coreBase.put(valString + "_" + LocaleUtils.locale_l1.getDisplayName(), tempValue);
						coreBase.put(valString + "_" + LocaleUtils.locale_l2.getDisplayName(), tempValue);
						coreBase.put(valString + "_" + LocaleUtils.locale_l3.getDisplayName(), tempValue);
					}
				}
			}

			String tempRelate = entityInfo.getRelationName();
			if (!StringUtils.isEmpty(tempRelate)) {
				IObjectValue mainValue = (IObjectValue)tempObjMap.get(this.mainEntityFullName);
				if (mainValue != null) {
					coreBase.put(tempRelate, mainValue);
				}
			}
		}
	}

	private CoreBaseInfo loadEntityInfo(ImportEntityInfo entityInfo) {
		FilterInfo filter = null;
		SelectorItemCollection coll = this.getLoadSelectorColl(entityInfo.getImportColumn());
		if (coll.size() == 0) {
			return null;
		} else {
			List<BaseColumnInfo> keyColumn = entityInfo.getKeyColumn();
			if (keyColumn != null && keyColumn.size() > 0) {
				filter = new FilterInfo();
				this.getLoadFilterInfo(filter, keyColumn);
			}

			if (!StringUtils.isEmpty(entityInfo.getRelationName())) {
				if (filter == null) {
					filter = new FilterInfo();
				}

				filter.getFilterItems().add(new FilterItemInfo(entityInfo.getRelationName(), this.currentBillid));
			}

			if (filter == null) {
				return null;
			} else {
				EntityViewInfo view = new EntityViewInfo();
				view.setFilter(filter);

				try {
					ICoreBase iCoreBase = this.getEntityInterface(entityInfo.getEntityFullName());
					CoreBaseCollection coreBaseColl = iCoreBase.getCollection(view);
					int size = coreBaseColl.size();
					if (size == 0) {
						return null;
					} else if (size == 1) {
						return coreBaseColl.get(0);
					} else {
						throw new ImportException(MessageFormat.format(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "load_entity_fails_mult", this.ctx), entityInfo.entityAliasName));
					}
				} catch (BOSException var9) {
					throw new ImportException(MessageFormat.format(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "load_existing_entity_fails", this.ctx), entityInfo.entityAliasName), var9);
				}
			}
		}
	}

	private CoreBaseInfo loadMainEntityInfo(ImportEntityInfo entityInfo) {
		if (!StringUtils.isEmpty(this.currentBillid)) {
			try {
				ICoreBase iCoreBase = this.getEntityInterface(entityInfo.getEntityFullName());
				CoreBaseInfo coreBase = iCoreBase.getValue(new ObjectUuidPK(this.currentBillid));
				return coreBase;
			} catch (EASBizException var13) {
				throw new ImportException(var13.getMessage(), var13);
			} catch (BOSException var14) {
				throw new ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "load_existing_entity_error", this.ctx), var14);
			}
		} else {
			FilterInfo filter = null;
			if (this.isPersonEntity(entityInfo.getEntityFullName())) {
				filter = new FilterInfo();
				String number = this.currentRow.getValueOfString("person.number");
				String name = this.currentRow.getValueOfString("person.name");
				if (!StringUtils.isEmpty(name)) {
					filter.getFilterItems().add(new FilterItemInfo(this.getEntityPropName("person.name"), name));
				}

				if (!StringUtils.isEmpty(number)) {
					filter.getFilterItems().add(new FilterItemInfo(this.getEntityPropName("person.number"), number));
				}

				EntityViewInfo view = new EntityViewInfo();
				view.setFilter(filter);

				try {
					ICoreBase iCoreBase = this.getEntityInterface(entityInfo.getEntityFullName());
					CoreBaseCollection coreBaseColl = iCoreBase.getCollection(view);
					int size = coreBaseColl.size();
					if (size == 0) {
						throw new ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "unable_load_entity", this.ctx, new Object[]{entityInfo.getEntityAliasName()}));
					} else if (size == 1) {
						return coreBaseColl.get(0);
					} else {
						CoreBaseInfo base = null;
						int count = 0;

						for(int i = 0; i < size; ++i) {
							CoreBaseInfo baseInfo = coreBaseColl.get(i);
							if ((StringUtils.isEmpty(name) || name.equals(baseInfo.getString("name"))) && (StringUtils.isEmpty(number) || number.equals(baseInfo.getString("number")))) {
								base = baseInfo;
								++count;
							}
						}

						if (count == 1) {
							return base;
						} else {
							throw new ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "load_mult_entity", this.ctx, new Object[]{entityInfo.getEntityAliasName()}));
						}
					}
				} catch (BOSException var15) {
					throw new ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "load_existing_entity_fails", this.ctx, new Object[]{entityInfo.getEntityAliasName()}), var15);
				}
			} else {
				return this.loadEntityInfo(entityInfo);
			}
		}
	}

	private boolean isPersonEntity(String entityFullName) {
		return "com.kingdee.eas.basedata.person.app.Person".equals(entityFullName);
	}

	private FilterInfo getLoadFilterInfo(FilterInfo filter, List<BaseColumnInfo> keyColumn) {
		BaseColumnInfo columnInfo = null;
		int i = 0;

		for(int size = keyColumn.size(); i < size; ++i) {
			columnInfo = (BaseColumnInfo)keyColumn.get(i);
			String key = columnInfo.getPropName();
			String entityPropName = this.getEntityPropName(key);
			Object value = this.currentRow.getValueOfObjectByIndex(columnInfo.getColumnIndex());
			if (value instanceof String) {
				filter.getFilterItems().add(new FilterItemInfo(entityPropName, value));
			} else if (value instanceof Timestamp) {
				filter.getFilterItems().add(new FilterItemInfo(entityPropName, value));
			} else if (value instanceof Date) {
				filter.getFilterItems().add(new FilterItemInfo(entityPropName, value));
			} else if (value instanceof Enum) {
				if (value instanceof StringEnum) {
					StringEnum en = (StringEnum)value;
					filter.getFilterItems().add(new FilterItemInfo(entityPropName, en.getValue()));
				} else if (value instanceof IntEnum) {
					IntEnum en = (IntEnum)value;
					filter.getFilterItems().add(new FilterItemInfo(entityPropName, en.getValue()));
				}
			} else if (value instanceof CoreBaseInfo) {
				CoreBaseInfo coreBaseInfo = (CoreBaseInfo)value;
				filter.getFilterItems().add(new FilterItemInfo(entityPropName, coreBaseInfo.getId()));
			} else {
				filter.getFilterItems().add(new FilterItemInfo(entityPropName, value));
			}
		}

		return filter;
	}

	private SelectorItemCollection getLoadSelectorColl(List<BaseColumnInfo> columnList) {
		BaseColumnInfo columnInfo = null;
		SelectorItemCollection coll = new SelectorItemCollection();
		int i = 0;

		for(int size = columnList.size(); i < size; ++i) {
			columnInfo = (BaseColumnInfo)columnList.get(i);
			String key = columnInfo.getPropName();
			String entityPropName = this.getEntityPropName(key);
			String value = this.currentRow.getValueOfStringByIndex(columnInfo.getColumnIndex());
			if (!StringUtils.isEmpty(value)) {
				coll.add(new SelectorItemInfo(entityPropName));
			}
		}

		return coll;
	}

	private String getEntityPropName(String importPropName) {
		String entityPropName = (String)this.importPropNameAndEntityPropMap.get(importPropName);
		if (entityPropName == null) {
			String[] strs = importPropName.split("\\.");
			if (strs.length > 1) {
				entityPropName = strs[1];
			}

			this.importPropNameAndEntityPropMap.put(importPropName, entityPropName);
		}

		return entityPropName;
	}

	private CoreBaseInfo createInfo(String entityFullName) {
		IMetaDataLoader loader = MetaDataLoaderFactory.getMetaDataLoader(this.ctx);
		MetaDataPK metaDataPK = MetaDataPK.create(entityFullName);
		EntityObjectInfo eoInfo = loader.getEntity(metaDataPK);
		String valueClassName = eoInfo.getObjectValueClass();
		CoreBaseInfo info = null;

		try {
			Class<?> c = Class.forName(valueClassName);
			Constructor<?> cst = c.getConstructor();
			info = (CoreBaseInfo)cst.newInstance();
			if (info instanceof DataBaseCustomInfo) {
				((DataBaseCustomInfo)info).setBOSType(eoInfo.getType());
			} else if (info instanceof BaseItemCustomInfo) {
				((BaseItemCustomInfo)info).setBOSType(eoInfo.getType());
			} else if (info instanceof CoreBillBaseCustomInfo) {
				((CoreBillBaseCustomInfo)info).setBOSType(eoInfo.getType());
			} else if (eoInfo.isDynamic() && info instanceof ICommonBOSType) {
				ICommonBOSType commonObject = (ICommonBOSType)info;
				commonObject.setBOSType(eoInfo.getType());
				commonObject.setPK(metaDataPK);
			}

			return info;
		} catch (Exception var10) {
			ImportException importException = new ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "creat_object_fails", this.ctx), var10);
			throw importException;
		}
	}
}
