123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670 |
- //
- // 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, com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo> entityInfoMap = null;
- private Map<String, ICoreBase> entityICoreBase = null;
- private String mainEntityFullName = null;
- private String mainEntityShortName = null;
- private boolean multiImport;
- private com.kingdee.shr.base.syssetting.app.io.fileImport.BaseRowInfo currentRow = null;
- private String currentBillid = null;
- public DynamicModelHelper(String scheme, Context ctx, Map<String, com.kingdee.shr.base.syssetting.app.io.fileImport.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 com.kingdee.shr.base.syssetting.app.io.fileImport.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, com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo>> iter = columnMap.entrySet().iterator();
- this.multiImport = true;
- com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo columnInfo = null;
- ArrayList temp = new ArrayList();
- while(iter.hasNext()) {
- columnInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo)((Entry)iter.next()).getValue();
- if (!this.handleColumnInfo(columnInfo)) {
- temp.add(columnInfo);
- }
- }
- Iterator tempIter = temp.iterator();
- while(tempIter.hasNext()) {
- columnInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo)tempIter.next();
- this.handleColumnInfo(columnInfo);
- }
- }
- }
- private boolean handleColumnInfo(com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo columnInfo) throws EASBizException, BOSException {
- return this.handleColumnInfo(columnInfo, true);
- }
- public void setCurrentBillid(String billId) {
- this.currentBillid = billId;
- }
- private boolean handleColumnInfo(com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo columnInfo, boolean convertColumn) throws EASBizException, BOSException {
- String shortName = this.getEntityShortNameByPropName(columnInfo.getPropName());
- com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo importEntityInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.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 com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo convertColumnInfo(com.kingdee.shr.base.syssetting.app.io.fileImport.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();
- com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo tempColumnInfo = new com.kingdee.shr.base.syssetting.app.io.fileImport.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 com.kingdee.shr.base.syssetting.app.io.fileImport.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;
- }
- }
- com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo entityInfo = new com.kingdee.shr.base.syssetting.app.io.fileImport.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(com.kingdee.shr.base.syssetting.app.io.fileImport.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 com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "get_api_instance_error", this.ctx), var5);
- }
- }
- return coreBase;
- }
- public DynamicModelInfo convertRowToDynamicModel(com.kingdee.shr.base.syssetting.app.io.fileImport.BaseRowInfo row) throws com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException {
- this.currentRow = row;
- return this.convertRowToDynamicModel();
- }
- public DynamicModelInfo convertRowToDynamicModel() {
- if (this.currentRow == null) {
- throw new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "row_data_isempty", this.ctx));
- } else {
- com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo mainEntityInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo)this.entityInfoMap.get(this.mainEntityShortName);
- CoreBaseInfo mainCoreBaseInfo = this.loadMainEntityInfo(mainEntityInfo);
- if (mainCoreBaseInfo == null) {
- throw new com.kingdee.shr.base.syssetting.app.io.fileImport.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, com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo>> iter = this.entityInfoMap.entrySet().iterator();
- com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo entityInfo = null;
- while(iter.hasNext()) {
- entityInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.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, com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo>> iter = this.entityInfoMap.entrySet().iterator();
- com.kingdee.shr.base.syssetting.app.io.fileImport.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 com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(emsg);
- }
- return;
- }
- entityInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.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, com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo>> iter = this.entityInfoMap.entrySet().iterator();
- com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo entityInfo = null;
- IObjectValue coreBase = null;
- com.kingdee.shr.base.syssetting.app.io.fileImport.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 = (com.kingdee.shr.base.syssetting.app.io.fileImport.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<com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo> columnInfoList = entityInfo.getImportColumn();
- boolean isPersonEntity = this.isPersonEntity(entityInfo.getEntityFullName());
- int i = 0;
- for(int size = columnInfoList.size(); i < size; ++i) {
- tempColumnInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.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 (com.kingdee.shr.base.syssetting.app.io.fileImport.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(com.kingdee.shr.base.syssetting.app.io.fileImport.ImportEntityInfo entityInfo) {
- FilterInfo filter = null;
- SelectorItemCollection coll = this.getLoadSelectorColl(entityInfo.getImportColumn());
- if (coll.size() == 0) {
- return null;
- } else {
- List<com.kingdee.shr.base.syssetting.app.io.fileImport.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 com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(MessageFormat.format(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "load_entity_fails_mult", this.ctx), entityInfo.entityAliasName));
- }
- } catch (BOSException var9) {
- throw new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(MessageFormat.format(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "load_existing_entity_fails", this.ctx), entityInfo.entityAliasName), var9);
- }
- }
- }
- }
- private CoreBaseInfo loadMainEntityInfo(com.kingdee.shr.base.syssetting.app.io.fileImport.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 com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(var13.getMessage(), var13);
- } catch (BOSException var14) {
- throw new com.kingdee.shr.base.syssetting.app.io.fileImport.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 com.kingdee.shr.base.syssetting.app.io.fileImport.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 com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "load_mult_entity", this.ctx, new Object[]{entityInfo.getEntityAliasName()}));
- }
- }
- } catch (BOSException var15) {
- throw new com.kingdee.shr.base.syssetting.app.io.fileImport.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<com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo> keyColumn) {
- com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo columnInfo = null;
- int i = 0;
- for(int size = keyColumn.size(); i < size; ++i) {
- columnInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.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<com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo> columnList) {
- com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo columnInfo = null;
- SelectorItemCollection coll = new SelectorItemCollection();
- int i = 0;
- for(int size = columnList.size(); i < size; ++i) {
- columnInfo = (com.kingdee.shr.base.syssetting.app.io.fileImport.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) {
- com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException importException = new com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException(SHRWebResource.getString("com.kingdee.shr.base.syssetting.CommonserviceResource", "creat_object_fails", this.ctx), var10);
- throw importException;
- }
- }
- }
|