diff --git a/business-entity-engine-api/pom.xml b/business-entity-engine-api/pom.xml
index 0b5f5a65e4c822e72648abb091ddeba099f5328f..0a796e0259752be827002dcc579ac157fd4f07b3 100644
--- a/business-entity-engine-api/pom.xml
+++ b/business-entity-engine-api/pom.xml
@@ -25,11 +25,14 @@
0.1.1-SNAPSHOT
- business-entity-engine
+ bef-engine
com.inspur.edp
0.1.1-SNAPSHOT
+ 4.0.0
+ com.inspur.edp
+ bef-engine-api
@@ -61,7 +64,7 @@
com.inspur.edp
cef-designtime-api
- 0.2.18
+ 0.2.26
com.inspur.edp
@@ -73,8 +76,47 @@
bef-bizentity
0.2.17
+
+ com.inspur.edp
+ bef-spi
+ 0.2.51
+ compile
+
+
+ com.inspur.edp
+ cef-spi
+ 0.2.82
+ compile
+
+
+ io.iec.edp
+ caf-boot-starter-context
+ 0.3.9
+ compile
+
+
+ io.iec.edp
+ caf-context-api
+ 1.0.0-rc.1
+ compile
+
-
+
+ business-entity-engine-api
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ 8
+
+
+
+ maven-jar-plugin
+
+
+
diff --git a/business-entity-engine-api/src/main/java/com/inspur/edp/bef/engine/entity/propertyinfobuilder/cef/AssoPropInfoBuilder.java b/business-entity-engine-api/src/main/java/com/inspur/edp/bef/engine/entity/propertyinfobuilder/cef/AssoPropInfoBuilder.java
index 82b5946727abcc3691239d711fd072970aef1ab5..30c48a8b067fd6eb2f5257b6bf5c9fbe77c35810 100644
--- a/business-entity-engine-api/src/main/java/com/inspur/edp/bef/engine/entity/propertyinfobuilder/cef/AssoPropInfoBuilder.java
+++ b/business-entity-engine-api/src/main/java/com/inspur/edp/bef/engine/entity/propertyinfobuilder/cef/AssoPropInfoBuilder.java
@@ -35,7 +35,7 @@ import org.springframework.util.StringUtils;
public class AssoPropInfoBuilder extends BasePropertyInfoBuilder {
public AssoPropInfoBuilder(IGspCommonField field,
- CefPropInfoGenerator propInfoGenerator) {
+ CefPropInfoGenerator propInfoGenerator) {
super(field, propInfoGenerator);
}
@@ -54,16 +54,16 @@ public class AssoPropInfoBuilder extends BasePropertyInfoBuilder {
GspAssociation asso = getAssociation();
if(asso == null || StringUtils.isEmpty(asso.getRefModelID())) {
throw new RuntimeException(String
- .format("节点[%s]上字段[%s]的关联信息不存在, 请修改", field.getBelongObject().getCode(),
- field.getLabelID()));
+ .format("节点[%s]上字段[%s]的关联信息不存在, 请修改", field.getBelongObject().getCode(),
+ field.getLabelID()));
}
GspBusinessEntity refEntity = getRefEntity(asso.getRefModelID());
if(refEntity == null) {
throw new RuntimeException(String
- .format("节点[%s]上的字段[%s]关联的ID,名称分别为[%s],[%s]的业务实体元数据获取不到(调用接口为com.inspur.edp.lcm.metadata.api.service.MetadataRTService.getMetadata(MetadataCustomizationFilter)),"
- + "请联系被关联业务实体的开发人员检查是否正确部署, 通常正确部署后gspmdrtcontent表中应存在此元数据相关信息",
- field.getBelongObject().getCode(),
- field.getLabelID(), asso.getRefModelID(), asso.getRefModelName()));
+ .format("节点[%s]上的字段[%s]关联的ID,名称分别为[%s],[%s]的业务实体元数据获取不到(调用接口为com.inspur.edp.lcm.metadata.api.service.MetadataRTService.getMetadata(MetadataCustomizationFilter)),"
+ + "请联系被关联业务实体的开发人员检查是否正确部署, 通常正确部署后gspmdrtcontent表中应存在此元数据相关信息",
+ field.getBelongObject().getCode(),
+ field.getLabelID(), asso.getRefModelID(), asso.getRefModelName()));
}
return getAssoPropertyInfo(field,getAssociation(), refEntity, propInfoGenerator);
}
@@ -72,17 +72,35 @@ public class AssoPropInfoBuilder extends BasePropertyInfoBuilder {
AssociationInfo associationInfo = new AssociationInfo();
associationInfo.setConfig(refEntity.getGeneratedConfigID());
associationInfo
- .setNodeCode(refEntity.findObjectById(association.getRefObjectID()).getCode());
+ .setNodeCode(getObjectByAssociation(association, refEntity).getCode());
associationInfo.setMainCode(refEntity.getMainObject().getCode());
setEnableState(associationInfo,association);
setAssoKeys(associationInfo,field,association,refEntity);
- setRefProperties(associationInfo,association,propInfoGenerator,refEntity.findObjectById(association.getRefObjectID()),refEntity);
+ setRefProperties(associationInfo,association,propInfoGenerator,
+ getObjectByAssociation(association, refEntity),refEntity);
associationInfo.setKeepAssoPropertyForExpression(association.isKeepAssoPropertyForExpression());
EngineAssoPropertyInfo assocationPropertyInfo = new EngineAssoPropertyInfo(associationInfo,association);
return assocationPropertyInfo;
}
+ private static IGspCommonObject getObjectByAssociation(GspAssociation association,
+ GspBusinessEntity refEntity) {
+ IGspCommonObject result = null;
+ if(!StringUtils.isEmpty(association.getRefObjectID())) {
+ result = refEntity.findObjectById(association.getRefObjectID());
+ }
+ if(result == null && !StringUtils.isEmpty(association.getRefObjectCode())) {
+ result = refEntity.findObjectByCode(association.getRefObjectCode());
+ }
+ if(result==null){
+ throw new RuntimeException(String
+ .format("关联模型[%1$s]上未获取到ID为[%2$s],编号为[%3$s]的节点对象,请检查确认元数据是否修改或是否正确部署", refEntity.getCode(),
+ association.getRefModelID(), association.getRefModelCode()));
+ }
+ return result;
+ }
+
private static void setRefProperties(AssociationInfo associationInfo, GspAssociation association, CefPropInfoGenerator propInfoGenerator, IGspCommonObject objectById, GspBusinessEntity refEntity) {
for(IGspCommonField refField:association.getRefElementCollection())
{
@@ -105,7 +123,7 @@ public class AssoPropInfoBuilder extends BasePropertyInfoBuilder {
}
else
- associationInfo.setPrivateTargetColumn(field.getLabelID());
+ associationInfo.setPrivateTargetColumn(field.getLabelID());
}
private static void setPrivateSourceColumn(AssociationInfo associationInfo,GspAssociation association,GspBusinessEntity refEntity) {
@@ -113,25 +131,25 @@ public class AssoPropInfoBuilder extends BasePropertyInfoBuilder {
for(GspAssociationKey key: association.getKeyCollection()){
sourceElementId = key.getSourceElement();
}
- IGspCommonObject commonObject=refEntity.findObjectById(association.getRefObjectID());
+ IGspCommonObject commonObject= getObjectByAssociation(association, refEntity);
if(commonObject==null){
throw new RuntimeException(String
- .format("关联模型[%1$s]上未获取到ID为[%2$s],编号为[%3$s]的节点对象,请检查确认元数据是否修改或是否正确部署", refEntity.getCode(),
- association.getRefModelID(), association.getRefModelCode()));
+ .format("关联模型[%1$s]上未获取到ID为[%2$s],编号为[%3$s]的节点对象,请检查确认元数据是否修改或是否正确部署", refEntity.getCode(),
+ association.getRefModelID(), association.getRefModelCode()));
}
IGspCommonField sourceElement =commonObject.findElement(sourceElementId);
if(sourceElement==null){
throw new RuntimeException(String
- .format("节点对象[%1$s]上未获取到ID为[%2$s]的字段,请检查确认元数据是否修改或是否正确部署", commonObject.getCode(),
- sourceElementId));
+ .format("节点对象[%1$s]上未获取到ID为[%2$s]的字段,请检查确认元数据是否修改或是否正确部署", commonObject.getCode(),
+ sourceElementId));
}
associationInfo.setPrivateSourceColumn(sourceElement.getLabelID());
}
private static void setEnableState(AssociationInfo associationInfo,GspAssociation association) {
associationInfo.setEnableState(association.getForeignKeyConstraintType() == ForeignKeyConstraintType.Forbid
- ? AssociationEnableState.Disabled
- : AssociationEnableState.Enabled);
+ ? AssociationEnableState.Disabled
+ : AssociationEnableState.Enabled);
}
}
diff --git a/business-entity-engine-api/src/main/java/com/inspur/edp/bef/engine/entity/propertyinfobuilder/cef/BasePropertyInfoBuilder.java b/business-entity-engine-api/src/main/java/com/inspur/edp/bef/engine/entity/propertyinfobuilder/cef/BasePropertyInfoBuilder.java
index a0f843e0568307714b5ab3fbacb68397b55121fa..36b737ff38295532cd8a129f57562b39a87fc316 100644
--- a/business-entity-engine-api/src/main/java/com/inspur/edp/bef/engine/entity/propertyinfobuilder/cef/BasePropertyInfoBuilder.java
+++ b/business-entity-engine-api/src/main/java/com/inspur/edp/bef/engine/entity/propertyinfobuilder/cef/BasePropertyInfoBuilder.java
@@ -49,8 +49,9 @@ public class BasePropertyInfoBuilder {
if (field.getDefaultValue() == null || field.getDefaultValue() == "")
return null;
DefaultValueType defaultValueType = DefaultValueType.Value;
- if (field.getDefaultValueType() == ElementDefaultVauleType.Expression)
- defaultValueType = DefaultValueType.Expression;
+ if (field.getDefaultValueType() == ElementDefaultVauleType.Expression){
+ return new PropertyDefaultValue(field.getDefaultValue(), "", DefaultValueType.Expression);
+ }
return PropertyDefaultValue.createDefaultValue(field.getDefaultValue(),
ElementDataTypeConvertor.convertFieldTypeFromDevType(field), defaultValueType);
}
diff --git a/business-entity-engine-api/src/main/java/com/inspur/edp/bef/engine/entity/propertyinfobuilder/cef/SimpleEnumUdtPropInfoBuilder.java b/business-entity-engine-api/src/main/java/com/inspur/edp/bef/engine/entity/propertyinfobuilder/cef/SimpleEnumUdtPropInfoBuilder.java
index 81b1ab6e8f6b076bc770c43431699a874858fdb2..234ab345e126f535f1d505ec6e29af81cf29b560 100644
--- a/business-entity-engine-api/src/main/java/com/inspur/edp/bef/engine/entity/propertyinfobuilder/cef/SimpleEnumUdtPropInfoBuilder.java
+++ b/business-entity-engine-api/src/main/java/com/inspur/edp/bef/engine/entity/propertyinfobuilder/cef/SimpleEnumUdtPropInfoBuilder.java
@@ -43,10 +43,10 @@ public class SimpleEnumUdtPropInfoBuilder extends SimpleUdtPropInfoBuilder {
EngineEnumPropertyInfo enumPropertyInfo = new EngineEnumPropertyInfo();
for (GspEnumValue enumValue : field.getContainEnumValues()) {
enumPropertyInfo
- .addEnumValueInfo(enumValue.getI18nResourceInfoPrefix() + ".Name", enumValue.getValue(),
- enumValue.getName(),
- enumValue.getStringIndex() == null ? "" : enumValue.getStringIndex(),
- enumValue.getIndex());
+ .addEnumValueInfo(enumValue.getI18nResourceInfoPrefix() + ".DisplayValue", enumValue.getValue(),
+ enumValue.getName(),
+ enumValue.getStringIndex() == null ? "" : enumValue.getStringIndex(),
+ enumValue.getIndex());
}
return enumPropertyInfo;
}
diff --git a/business-entity-engine-repository/pom.xml b/business-entity-engine-repository/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..008b20f318072d3c737133f3681c82cd2a9162a9
--- /dev/null
+++ b/business-entity-engine-repository/pom.xml
@@ -0,0 +1,120 @@
+
+
+
+
+
+ bef-engine
+ com.inspur.edp
+ 0.1.1-SNAPSHOT
+
+ 4.0.0
+
+ business-entity-engine-repository
+
+
+
+ com.inspur.edp
+ cef-api
+ ${cef.version}
+
+
+ com.inspur.edp
+ cef-spi
+ ${cef.version}
+
+
+ com.inspur.edp
+ cef-repository
+ ${cef.version}
+
+
+ io.iec.edp
+ caf-boot-commons-utils
+ 0.2.2
+
+
+ com.inspur.edp
+ bef-api
+ ${bef.version}
+
+
+ com.inspur.edp
+ bef-engine-core
+ ${project.version}
+ compile
+
+
+ org.eclipse.core
+ resources
+ 3.3.0-v20070604
+
+
+ com.inspur.edp
+ lcm-metadata-cache
+ 0.1.30
+
+
+ io.iec.edp
+ caf-database-object-api
+ 0.2.10
+
+
+ com.inspur.edp
+ metadata-rtcustomization-api
+ 0.1.24
+
+
+ com.inspur.edp
+ bef-engine-api
+ ${project.version}
+
+
+ com.inspur.edp
+ cef-designtime-api
+ 0.2.26
+
+
+ com.inspur.edp
+ runtime-customize-core
+ 0.1.3
+
+
+ com.inspur.edp
+ bef-bizentity
+ 0.2.17
+
+
+
+
+ business-entity-engine-repository
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ 8
+
+
+
+ maven-jar-plugin
+
+
+
+
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefBaseAdaptor.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefBaseAdaptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..df23cc22a0de72845d9aba4395cb1b5c67cc2ec4
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefBaseAdaptor.java
@@ -0,0 +1,964 @@
+/*
+ * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.adaptor;
+
+import com.inspur.edp.bef.api.BefRtBeanUtil;
+import com.inspur.edp.bef.bizentity.GspBizEntityElement;
+import com.inspur.edp.bef.bizentity.GspBizEntityObject;
+import com.inspur.edp.bef.bizentity.GspBusinessEntity;
+import com.inspur.edp.bef.engine.core.be.EngineBEManager;
+import com.inspur.edp.bef.engine.entity.BeModelResInfo;
+import com.inspur.edp.bef.engine.entity.EngineChildData;
+import com.inspur.edp.bef.engine.entity.EngineRootData;
+import com.inspur.edp.bef.engine.repository.typetransprocesser.EnumEngineIntProcesser;
+import com.inspur.edp.bef.engine.repository.typetransprocesser.EnumEngineVarcharProcesser;
+import com.inspur.edp.bef.engine.repository.typetransprocesser.VarcharIntTransProcesser;
+import com.inspur.edp.bef.engine.repository.util.ReadUtils;
+import com.inspur.edp.cef.api.repository.GspDbDataType;
+import com.inspur.edp.cef.api.repository.IRootRepository;
+import com.inspur.edp.cef.api.repository.ITypeTransProcesser;
+import com.inspur.edp.cef.api.repository.readerWriter.ICefReader;
+import com.inspur.edp.cef.designtime.api.IGspCommonField;
+import com.inspur.edp.cef.designtime.api.element.*;
+import com.inspur.edp.cef.designtime.api.entity.GspCommonField;
+import com.inspur.edp.cef.entity.condition.FilterCondition;
+import com.inspur.edp.cef.entity.condition.SortCondition;
+import com.inspur.edp.cef.entity.entity.ICefData;
+import com.inspur.edp.cef.entity.entity.IEntityData;
+import com.inspur.edp.cef.repository.adaptor.EntityRelationalAdaptor;
+import com.inspur.edp.cef.repository.adaptor.KeyWordsManager;
+import com.inspur.edp.cef.repository.assembler.LogicDeleteInfo;
+import com.inspur.edp.cef.repository.dac.EntityDac;
+import com.inspur.edp.cef.repository.dbcolumninfo.DbColumnInfo;
+import com.inspur.edp.cef.repository.sqlgenerator.BaseSqlGenerator;
+import com.inspur.edp.cef.repository.typetransprocesser.*;
+import com.inspur.edp.cef.repository.utils.StringUtil;
+import com.inspur.edp.cef.repository.utils.TenantUtil;
+import com.inspur.edp.cef.spi.entity.resourceInfo.builinImpls.CefEntityResInfoImpl;
+import com.inspur.edp.commonmodel.engine.api.common.CMEngineUtil;
+import com.inspur.edp.commonmodel.engine.api.data.AssociationInfo;
+import com.inspur.edp.das.commonmodel.IGspCommonElement;
+import com.inspur.edp.das.commonmodel.IGspCommonModel;
+import com.inspur.edp.das.commonmodel.IGspCommonObject;
+import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
+import com.inspur.edp.udt.designtime.api.entity.ComplexDataTypeDef;
+import com.inspur.edp.udt.designtime.api.entity.SimpleDataTypeDef;
+import com.inspur.edp.udt.designtime.api.entity.UnifiedDataTypeDef;
+import com.inspur.edp.udt.designtime.api.entity.dbInfo.ColumnMapType;
+import io.iec.edp.caf.databaseobject.api.entity.DataType;
+import io.iec.edp.caf.databaseobject.api.entity.DatabaseObjectColumn;
+import io.iec.edp.caf.databaseobject.api.entity.DatabaseObjectTableCore;
+import java.util.ArrayList;
+import java.util.HashMap;
+import lombok.var;
+import org.springframework.util.StringUtils;
+
+public abstract class BefBaseAdaptor extends EntityRelationalAdaptor {
+
+ private GspBizEntityObject bizEntityObject;
+ private HashMap propIndexMappingDict;
+ private String tableAlias;
+ private String deleteSql;
+ private String modifySql;
+ private String retrieveBatchSql;
+ private String retrieveSql;
+ private String insertSql;
+ private boolean isChildAdaptor;
+ private BaseSqlGenerator sqlGenerator;
+ // private DatabaseObjectTable dbo;
+ private DatabaseObjectTableCore dbo;
+ private EntityDac entityDac;
+ private IGspCommonElement parentIdEle;
+
+ protected abstract BaseSqlGenerator getSqlGenerator();
+ public BefBaseAdaptor(GspBizEntityObject bizEntityObject)
+ {
+ this(bizEntityObject,null);
+ }
+
+ public BefBaseAdaptor(GspBizEntityObject bizEntityObject, EntityDac entityDac) {
+ super(false);
+ this.bizEntityObject = bizEntityObject;
+ dbo = (DatabaseObjectTableCore) BefRtBeanUtil.getDboRtService().getDatabaseObject(bizEntityObject.getRefObjectName());
+ this.entityDac = entityDac;
+ if (dbo == null) {
+ throw new RuntimeException(String
+ .format("模型[%s]上的节点[%s]对应的dbo没有获取到,请检查dbo是否成功部署到正确的数据库中,dboId为:%s",
+ bizEntityObject.getBelongModel().getName(), bizEntityObject.getName(),
+ bizEntityObject.getRefObjectName()));
+ }
+ isChildAdaptor = bizEntityObject.getParentObject() != null;
+ tableAlias = getWrappedAlias(bizEntityObject.getCode());
+ if (isChildAdaptor) {
+ String parentIdEleId = bizEntityObject.getKeys().get(0).getSourceElement();
+ parentIdEle = bizEntityObject.findElement(parentIdEleId);
+ }
+ initAssociations();
+ initColumns();
+ sqlGenerator = getSqlGenerator();
+ }
+
+ //兼容处理IDP年度表
+ private String getWrappedAlias(String alias){
+ alias = alias.trim();
+ alias = alias.replace("$", "");
+ return alias;
+ }
+
+ public CefEntityResInfoImpl getEntityResInfo() {
+ //变量缓存?
+ return (CefEntityResInfoImpl) EngineBEManager.getCefModelResourceInfo(bizEntityObject.getBelongModel()).getCustomResource(bizEntityObject.getCode());
+ }
+
+ @Override
+ public LogicDeleteInfo getLogicDeleteInfo(){
+ LogicDeleteInfo logicDeleteInfo = new LogicDeleteInfo(false, "IsDelete");
+ if(this.bizEntityObject.getLogicDeleteControlInfo() != null && this.bizEntityObject.getLogicDeleteControlInfo().getEnableLogicDelete()){
+ logicDeleteInfo.setEnableLogicDelete(true);
+ for(IGspCommonField gspCommonField: bizEntityObject.getContainElements()){
+ if(gspCommonField.getID().equals(bizEntityObject.getLogicDeleteControlInfo().getLogicDeleteControlElementId()))
+ {
+ logicDeleteInfo.setLabelId(gspCommonField.getLabelID());
+ break;
+ }
+ }
+ }
+ return logicDeleteInfo;
+ }
+
+ @Override
+ protected String getDboID() {
+ return bizEntityObject.getRefObjectName();
+ }
+
+ //region PropertyColumn
+ @Override
+ protected boolean hasPropColumnMappping() {
+ return propIndexMappingDict != null;
+ }
+
+ @Override
+ protected HashMap getPropertyColumnMapping() {
+ return propIndexMappingDict;
+ }
+
+ @Override
+ protected void setPropertyColumnMapping(HashMap mappingDict) {
+ propIndexMappingDict = mappingDict;
+ }
+ //endregion
+
+ //region InitColumns
+ @Override
+ protected void initColumns() {
+ for (var element : bizEntityObject.getContainElements()) {
+ if (element.getObjectType() == GspElementObjectType.DynamicProp) {
+ continue;
+ }
+ if(element.getIsVirtual()){
+ initColumn((IGspCommonElement) element, (IGspCommonElement) element, null);
+ continue;
+ }
+ if (element.getIsUdt()) {
+ initUdtColumn((IGspCommonElement) element);
+ } else {
+ var column = dbo.getColumnById(((IGspCommonElement) element).getColumnID());
+ if (column == null) {
+ throw new RuntimeException(
+ "通过io.iec.edp.caf.databaseobject.api.entity.DatabaseObjectTableCore.getColumnById()方法在code为["
+ + dbo.getCode() + "]的dbo中找不到columnid为[" + ((IGspCommonElement) element)
+ .getColumnID() + "]的dbo列, BE字段编号为[" + element.getCode() + "]BE元数据ID编号分别为["
+ + this.bizEntityObject.getBelongModel().getId()+"][" + this.bizEntityObject.getBelongModel().getCode()
+ + "],请检查BE元数据和DBO是否均已正确部署,BE元数据部署后保存在gspmdrtcontent或gspmdcustomcontent表中,DBO部署后保存在gspdatabaseobject表中. ");
+ }
+ initColumn((IGspCommonElement) element, (IGspCommonElement) element, column);
+ }
+ }
+ }
+
+ private void initUdtColumn(IGspCommonElement element) {
+ if (element.getChildElements().size() == 1) {
+ var column = dbo.getColumnById(element.getColumnID());
+ if (column == null) {
+ throw new RuntimeException("dbo["+dbo.getCode()+"]中找不到字段[" + element.getLabelID() + "]对应的列,columnid:" + element.getColumnID());
+ }
+ initColumn(element, element, column);
+
+ return;
+ }
+
+ UnifiedDataTypeDef unifiedDataTypeDef= null;
+
+ for (var childElement : element.getChildElements()) {
+
+ var childEle =
+ (IGspCommonElement) ((childElement instanceof IGspCommonElement) ? childElement : null);
+
+ var column = dbo.getColumnById(childEle.getColumnID());
+ if (column == null) {
+ throw new RuntimeException("dbo中找不到" + childEle.getLabelID() + "对应的列");
+ }
+ if(unifiedDataTypeDef==null)
+ unifiedDataTypeDef=(UnifiedDataTypeDef) CMEngineUtil.getMetadata(element.getUdtID()).getContent();
+ ComplexDataTypeDef complexDataTypeDef= (ComplexDataTypeDef) unifiedDataTypeDef;
+ String refedUdtElementID = element.getMappingRelation().getMappingInfo(childEle.getID());
+ IGspCommonField refedElement = complexDataTypeDef.findElement(refedUdtElementID);
+ if(childEle.getObjectType()!=refedElement.getObjectType())
+ {
+ childEle.setObjectType(refedElement.getObjectType());
+ childEle.setEnumIndexType(refedElement.getEnumIndexType());
+ childEle.setContainEnumValues(refedElement.getContainEnumValues());
+ }
+ // TODO 暂时没法只根据element判断是否是ChildElement
+ childEle.setIsUdt(true);
+
+ initColumn(childEle, element, column);
+ }
+
+ }
+
+ private void initColumn(IGspCommonElement element, IGspCommonElement belongElement, DatabaseObjectColumn dboColumn) {
+ GspDbDataType dataType = GspDbDataType.VarChar;
+ DbColumnInfo dbColumnInfo = new DbColumnInfo();
+ dbColumnInfo.setColumnName(element.getLabelID());
+ boolean isAssociateRefElement = false;
+ //init方法的都是基础字段
+ if(element.getIsVirtual()){
+ dbColumnInfo.setDbColumnName("");
+ dbColumnInfo.setVirtual(true);
+ dataType = getVirtualDbType(element);
+ }
+ else {
+ dataType = transDataType(dboColumn.getDataType());
+ dbColumnInfo.setDbColumnName(isAssociateRefElement ? "" : dboColumn.getCode());
+ }
+
+ dbColumnInfo.setColumnType(dataType);
+ dbColumnInfo.setLength(element.getLength());
+ dbColumnInfo.setPrecision(element.getPrecision());
+ dbColumnInfo.setDefaultValue(null);
+ dbColumnInfo.setIsPrimaryKey(isPrimaryKey(element));
+ dbColumnInfo.setIsAssociateRefElement(isAssociateRefElement);
+ dbColumnInfo.setIsMultiLang(element.getIsMultiLanguage());
+ dbColumnInfo.setIsParentId(isParentColumn(element));
+ dbColumnInfo.setIsUdtElement(element.getIsUdt());
+ dbColumnInfo.setIsAssociation(element.getObjectType() == GspElementObjectType.Association);
+ dbColumnInfo.setIsEnum(element.getObjectType() == GspElementObjectType.Enum);
+ dbColumnInfo.setBelongElementLabel(belongElement == null ? "" : belongElement.getLabelID());
+ dbColumnInfo.setTypeTransProcesser(getTypeProcesser(dataType, element, (dboColumn == null) ? 0 : dboColumn.getLength()));
+ if(element instanceof GspCommonField){
+ GspCommonField gspCommonField = (GspCommonField) element;
+ if(gspCommonField.getSelectFieldRepoConfig() != null && !com.inspur.edp.cef.spi.jsonser.base.StringUtils.isNullOrEmpty(gspCommonField.getSelectFieldRepoConfig().getConfigClassImpl())){
+ dbColumnInfo.setFieldReposExtendConfigId(gspCommonField.getSelectFieldRepoConfig().getConfigId());
+ }
+ }
+
+ super.getContainColumns().add(dbColumnInfo);
+ }
+
+ private GspDbDataType getVirtualDbType(IGspCommonElement element){
+ GspDbDataType dbDataType = GspDbDataType.VarChar;
+ switch (element.getMDataType()){
+ case String:
+ dbDataType = GspDbDataType.VarChar;
+ break;
+ case Integer:
+ dbDataType = GspDbDataType.Int;
+ break;
+ case Decimal:
+ dbDataType = GspDbDataType.Decimal;
+ break;
+ case Boolean:
+ dbDataType = GspDbDataType.Char;
+ break;
+ case Date:
+ dbDataType = GspDbDataType.Date;
+ break;
+ case DateTime:
+ dbDataType = GspDbDataType.DateTime;
+ break;
+ case Text:
+ dbDataType = GspDbDataType.Clob;
+ break;
+ case Binary:
+ dbDataType = GspDbDataType.Blob;
+ break;
+ }
+ return dbDataType;
+ }
+
+ private GspDbDataType transDataType(DataType dataType) {
+ GspDbDataType dbDataType = GspDbDataType.VarChar;
+ switch (dataType) {
+ case Char:
+ dbDataType = GspDbDataType.Char;
+ break;
+ case Varchar:
+ dbDataType = GspDbDataType.VarChar;
+ break;
+ case Blob:
+ dbDataType = GspDbDataType.Blob;
+ break;
+ case DateTime:
+ dbDataType = GspDbDataType.DateTime;
+ break;
+ case TimeStamp:
+ dbDataType = GspDbDataType.DateTime;
+ break;
+ case Clob:
+ dbDataType = GspDbDataType.Clob;
+ break;
+ case Int:
+ case LongInt:
+ dbDataType = GspDbDataType.Int;
+ break;
+ case Decimal:
+ case Float:
+ dbDataType = GspDbDataType.Decimal;
+ break;
+ case NChar:
+ dbDataType = GspDbDataType.NChar;
+ break;
+ case NVarchar:
+ dbDataType = GspDbDataType.NVarChar;
+ break;
+ case NClob:
+ dbDataType = GspDbDataType.NClob;
+ break;
+ case Boolean:
+ dbDataType = GspDbDataType.Boolean;
+ break;
+ case Jsonb:
+ dbDataType = GspDbDataType.Jsonb;
+ break;
+ }
+ return dbDataType;
+ }
+
+ private ITypeTransProcesser getTypeProcesser(
+ GspDbDataType dbType, IGspCommonElement element,int length) {
+ if (element.getObjectType() == GspElementObjectType.Enum) {
+ switch (dbType) {
+ case Int:
+ return new EnumEngineIntProcesser((GspBizEntityElement) element);
+ case VarChar:
+ case NVarChar:
+ return new EnumEngineVarcharProcesser((GspBizEntityElement) element);
+ }
+ }
+// if(element.getObjectType() ==GspElementObjectType.Enum){
+// return VarcharTransProcesser.getInstacne();
+// }
+ switch (element.getMDataType()) {
+ case Boolean:
+ if (dbType == GspDbDataType.Int) {
+ return Bool2IntProcesser.getInstacne();
+ }
+ if (dbType == GspDbDataType.Char||dbType==GspDbDataType.VarChar) {
+ return Bool2CharProcesser.getInstacne();
+ }
+ if(dbType==GspDbDataType.Boolean)
+ return BoolTransProcesser.getInstacne();
+ break;
+ case Date:
+ if((dbType==GspDbDataType.Char||dbType==GspDbDataType.VarChar)&&length==8)
+ return DateTime2Char8Processer.getInstacne();
+ return DateTimeTransProcesser.getInstacne();
+ case DateTime:
+ return DateTimeTransProcesser.getInstacne();
+ case Decimal:
+ if (dbType == GspDbDataType.Decimal) {
+ return DecimalTransProcesser.getInstacne();
+ }
+ break;
+ case Integer:
+ if (dbType == GspDbDataType.Int) {
+ return IntTransProcesser.getInstacne();
+ }
+ break;
+ case String:
+ if(dbType==GspDbDataType.Int){
+ return VarcharIntTransProcesser.getInstacne();
+ }
+ return VarcharTransProcesser.getInstacne();
+ case Text:
+ return ClobTransProcesser.getInstacne();
+ case Binary:
+ return BinaryTransProcesser.getInstacne();
+ }
+
+ throw new RuntimeException(
+ "#GSPBefError#"
+ + "没有找到字段类型为"
+ + element.getMDataType().toString()
+ + ",数据库类型为"
+ + dbType.toString()
+ + "的转换器,字段标签:"+element.getLabelID()+",字段名称:"+element.getName()+", 所属be:"+element.getBelongObject().getBelongModel().getCode()
+ + "#GSPBefError#");
+ }
+
+ private boolean isPrimaryKey(IGspCommonElement element) {
+ return bizEntityObject.getIDElement().getID().equals(element.getID());
+ }
+
+ private boolean isParentColumn(IGspCommonElement element) {
+ if (isChildAdaptor) {
+ return parentIdEle.getID().equals(element.getID());
+ }
+ return false;
+ }
+ // endregion
+
+ //region Filter & Sort
+ @Override
+ protected ArrayList getDefaultFilterCondition() {
+ return null;
+ }
+
+ @Override
+ protected ArrayList getDefaultSortCondition() {
+ return null;
+ }
+
+ //endregion
+
+ @Override
+ public String getPrimaryKey() {
+ return dbo.getColumnById(bizEntityObject.getIDElement().getColumnID()).getCode();
+ }
+
+ @Override
+ public String getTableAlias() {
+ return tableAlias;
+ }
+
+ @Override
+ public void setTableAlias(String value) {
+ tableAlias = value;
+ }
+
+ @Override
+ protected String getConfigId() {
+ return bizEntityObject.getBelongModel().getGeneratedConfigID();
+ }
+
+ //region Delete
+ @Override
+ protected String innerGetDeleteSql() {
+ return getDeleteSqlStr();
+ }
+
+ @Override
+ protected String getDeleteSqlBatch() {
+ return getDeleteSqlStr();
+ }
+
+ private String getDeleteSqlStr() {
+ if (deleteSql == null)
+ deleteSql = String.format(sqlGenerator.getDeleteSql(), "@TableName@", tableAlias);
+ return deleteSql;
+ }
+
+ //endregion
+
+ // region Insert
+ @Override
+ protected String innerGetInsertSql() {
+ batchInsert = true;
+ if (insertSql == null)
+ initInsertSql();
+ return insertSql;
+ }
+
+ private void initInsertSql() {
+ String sql = sqlGenerator.getInsertSql();
+ buildInsertColumnsAndParams();
+ insertSql = String.format(sql, "@TableName@", insertColumns, insertParams);
+ }
+
+ private String insertColumns;
+ private String insertParams;
+
+ private void buildInsertColumnsAndParams() {
+ //跟之前一致,并且在当前实例上做缓存。
+ StringBuilder columnNames = new StringBuilder();
+ StringBuilder valueParamter = new StringBuilder();
+ for (DbColumnInfo columnInfo : getContainColumns()) {
+ if (columnInfo.getIsAssociateRefElement()) {
+ continue;
+ }
+ if(columnInfo.isVirtual()){
+ continue;
+ }
+ if (columnNames.toString() != null && "".equals(columnNames.toString()) == false) {
+ columnNames.append(", ");
+ valueParamter.append(", ");
+ }
+ if (columnInfo.getIsMultiLang()) {
+ columnNames.append(KeyWordsManager.getColumnAlias(getMultiLangColumnName(columnInfo.getDbColumnName())));
+ } else {
+ columnNames.append(KeyWordsManager.getColumnAlias(columnInfo.getDbColumnName()));
+ }
+ valueParamter.append("?");
+ }
+
+ if (TenantUtil.IsDiscriminator()) {
+ String tenantColName = TenantUtil.GetTenantColumnName();
+ columnNames.append(", ").append(tenantColName);
+ valueParamter.append(", ").append("?");
+ }
+
+ insertColumns = columnNames.toString();
+ insertParams = valueParamter.toString();
+ }
+
+ protected String getMultiLangColumnName(String columnName) {
+ //string currentLanguage = I18NUtils.getCurrentLanguage();
+ //return columnName + I18NUtils.getFieldSuffix(currentLanguage);
+ return columnName + "@Language@";
+ }
+
+ //endregion
+
+ //region Modify
+ @Override
+ protected String innerGetModifySql() {
+ if (modifySql == null) {
+ modifySql = String.format("Update %1$s Set", "@TableName@");
+ }
+ return modifySql;
+ }
+
+ //endregion
+
+ @Override
+ protected Object getPropertyChangeValue(String propertyName, Object propertyValue) {
+ for (var element : bizEntityObject.getContainElements()) {
+ if(element.getIsUdt()){
+ if(!element.getLabelID().equals(propertyName) && !containChildElementByLabelId(element, propertyName))
+ continue;
+ return ReadUtils.getUdtValue(bizEntityObject,propertyName,element.getLabelID(),propertyValue);
+ }
+ if (!element.getLabelID().equals(propertyName))
+ continue;
+ if (element.getObjectType() == GspElementObjectType.Association)
+ return ((AssociationInfo) propertyValue).getValue(element.getLabelID());
+// if (element.getObjectType() == GspElementObjectType.Enum)
+// return getEnumKey(element, (String) propertyValue);
+ if(element.getMDataType()==GspElementDataType.Date)
+ return this.getContainColumns().getItem(element.getLabelID()).
+ getTypeTransProcesser().transType(propertyValue);
+ return propertyValue;
+ }
+ throw new RuntimeException("未找到字段" + propertyName);
+ }
+
+ private Object getEnumKey(IGspCommonField element, String code) {
+ for (GspEnumValue enumValue : element.getContainEnumValues()) {
+ if (!enumValue.getValue().equals(code))
+ continue;
+ if (element.getEnumIndexType() == EnumIndexType.String)
+ return enumValue.getStringIndex();
+ return enumValue.getIndex();
+ }
+ throw new RuntimeException("字段" + element.getLabelID()
+ + "中没有索引编号为" + code + "的枚举项");
+ }
+
+ //region GetData
+ @Override
+ protected String getGetDataByIdsSql() {
+ if (retrieveBatchSql == null) {
+ retrieveBatchSql = String.format(sqlGenerator.getRetrieveBatchSql(), "%1$s", "%2$s", tableAlias + "." + getContainColumns().getPrimaryKey().getDbColumnName(), "%3$s");
+ }
+
+ return retrieveBatchSql;
+ }
+
+ @Override
+ protected String getGetDataByIdSql() {
+
+ if (retrieveSql == null) {
+ retrieveSql = String.format(
+ sqlGenerator.getRetrieveSql(),
+ "%1$s",
+ "%2$s",
+ tableAlias + "." + getContainColumns().getPrimaryKey().getDbColumnName(),
+ "%3$s");
+ }
+ return retrieveSql;
+ }
+
+ private String versionPropName;
+ @Override
+ protected String getVersionControlPropName() {
+ if(!bizEntityObject.getIsRootNode()){
+ return "";
+ }
+ if (versionPropName == null) {
+ String versionElementId = bizEntityObject.getBelongModel().getVersionContronInfo().getVersionControlElementId();
+ if (StringUtils.isEmpty(versionElementId)) {
+ versionPropName = "";
+ } else {
+ IGspCommonElement versionElement = bizEntityObject.findElement(versionElementId);
+ if (versionElement == null) {
+ throw new RuntimeException(
+ bizEntityObject.getBelongModel().getCode().concat("业务实体元数据结构错误,版本字段不存在:").concat(versionElementId));
+ }
+ versionPropName = versionElement.getLabelID();
+ }
+ }
+ return versionPropName;
+ }
+ //endregion
+
+ //region JoinTable
+ @Override
+ public String getParentJoin() {
+ if (!isChildAdaptor)
+ return null;
+ return getJoinTable();
+ }
+
+ private String getJoinTable() {
+// String parenTableName = "@ParentTableName@ " + bizEntityObject.getParentObject().getCode(); // getParentTableName();//{3}
+ String parentPrimaryKey = getParentTablePrimaryKey(); //{5}
+ if (parentPrimaryKey.equals("") || parentPrimaryKey == null) {
+ throw new RuntimeException("未找到父表主键字段,请检查配置");
+ }
+ String parentIdColumnName = getWrappedAlias(getTableAlias()) + "." + getParentIdColumnName();
+ String parentAlias = bizEntityObject.getParentObject().getCode();
+ parentAlias = parentAlias.trim();
+ parentAlias = parentAlias.replace("$", "");
+ String joinSql = sqlGenerator.getInnerJoinTableName().replace("@ParentTableAlias@",parentAlias)
+ .replace("@ParentID@", parentIdColumnName)
+ .replace("@PrimaryID@", parentPrimaryKey);
+ return joinSql;
+ }
+
+ /**
+ * 获取主表的关联字段
+ * 默认子表记录主表的主键,IDP支持记录非主键字段,这里要支持一下
+ * @return
+ */
+ private String getParentTablePrimaryKey() {
+ IGspCommonElement parentElement = null;
+ String parentElementId = bizEntityObject.getKeys().get(0).getTargetElement();
+ parentElement = bizEntityObject.getParentObject().findElement(parentElementId);
+
+ String alias = bizEntityObject.getParentObject().getCode();
+ alias = alias.trim();
+ alias = alias.replace("$", "");
+ if(parentElement == null){
+ parentElement = bizEntityObject.getParentObject().getIDElement();
+ if (parentElement == null)
+ throw new RuntimeException("对象" + alias + "中没有设置主键字段,请去元数据设计器中查看");
+ }
+
+
+ var parentDbo = (DatabaseObjectTableCore) BefRtBeanUtil.getDboRtService()
+ .getDatabaseObject(bizEntityObject.getParentObject().getRefObjectName());
+
+
+ var dbColumn = parentDbo.getColumnById(parentElement.getColumnID());
+ if (dbColumn == null)
+ throw new RuntimeException("DBO" + parentDbo.getCode() + "中没有找到Id为" + parentElement.getColumnID()
+ + "的字段,对应Be字段编号为" + parentElement.getCode());
+ return alias + "." + dbColumn.getCode();
+ }
+
+ /**
+ * 子表ParentID是否关联主表的主键字段
+ * @return
+ */
+ public boolean isAssoParentPrimaryKey(){
+ IGspCommonElement parentElement = null;
+ if(bizEntityObject.getParentObject() == null)
+ return false;
+ String parentElementId = bizEntityObject.getKeys().get(0).getTargetElement();
+ parentElement = bizEntityObject.getParentObject().findElement(parentElementId);
+
+ IGspCommonElement idElement = bizEntityObject.getParentObject().getIDElement();
+ if(parentElement != null && idElement != null && idElement.getID().equalsIgnoreCase(parentElement.getID())){
+ return true;
+ }
+ return false;
+ }
+
+ private String getParentIdColumnName() {
+ if (parentIdEle == null)
+ throw new RuntimeException("对象" + bizEntityObject.getCode() + "中没有设置ParentId字段,请去元数据设计器中查看");
+ var parentIdColumn = dbo.getColumnById(parentIdEle.getColumnID());
+ if (parentIdColumn == null)
+ throw new RuntimeException("DBO" + dbo.getCode() + "中没有找到Id为" + parentIdEle.getColumnID()
+ + "的字段,对应Be字段编号为" + parentIdEle.getCode());
+ return parentIdColumn.getCode();
+ }
+
+ @Override
+ protected String getJoinTableName() {
+ return getSqlGenerator().getJoinTableName();
+ }
+
+ //endregion
+
+ //region Value
+ @Override
+ public ICefData createInstance(ICefReader reader) {
+ IEntityData data = null;
+ if (isChildAdaptor)
+ data = new EngineChildData(bizEntityObject, getResInfo(bizEntityObject.getCode()));
+ else
+ data = new EngineRootData(bizEntityObject, getResInfo(bizEntityObject.getCode()));
+ for (var element : bizEntityObject.getContainElements()) {
+ if (element.getIsUdt())
+ ReadUtils.setUdtData(reader, false, data, (IGspCommonElement)element);
+ else if (element.getObjectType()== GspElementObjectType.DynamicProp){
+ continue;
+ } else {
+ var value = ReadUtils.getValue((IGspCommonElement) element, reader);
+ data.setValue(element.getLabelID(), value);
+ }
+ }
+ return data;
+ }
+
+ @Override
+ public final EntityDac getEntityDac() {
+ return entityDac;
+ }
+
+ private BeModelResInfo modelResInfo;
+ private CefEntityResInfoImpl getResInfo(String nodeCode){
+ if(modelResInfo == null) {
+ modelResInfo = EngineBEManager.createResInfo(bizEntityObject.getBelongModel());
+ }
+ return (CefEntityResInfoImpl) modelResInfo.getCustomResource(nodeCode);
+ }
+
+ @Override
+ public Object getPersistenceValue(String colName, ICefData data) {
+ for (var element : bizEntityObject.getContainElements()) {
+
+ //udt字段
+ if(element.getIsUdt()){
+ if(!element.getLabelID().equals(colName) && !containChildElementByLabelId(element, colName))
+ continue;
+ var udtData = data.getValue(element.getLabelID());
+ return ReadUtils.getUdtValue(bizEntityObject,colName,element.getLabelID(),udtData);
+ }
+
+ //非udt字段
+ if (!element.getLabelID().equals(colName))
+ continue;
+
+ return this.getContainColumns().getItem(element.getLabelID()).
+ getTypeTransProcesser().transType(data.getValue(element.getLabelID()));
+
+// return UdtManagerUtils.getUdtRepositoryFactory().createRepository("com.inspur.gs.scm.sd.salesorder.udt.belongdepartment.BelongDepartment").getPersistenceValue("BelongDepartment", ((IZUser) data).getDpet());
+ }
+
+ throw new RuntimeException("没有找到字段" + colName);
+ }
+
+ private static boolean containChildElementByLabelId(IGspCommonField element, String lableId) {
+ for (IGspCommonField childElement :
+ element.getChildElements()) {
+ if (childElement.getLabelID().equals(lableId))
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public HashMap getAssosPropDBMapping(String propName)//生成引用解析的时候 会用到。
+ {
+ for(IGspCommonField element : this.bizEntityObject.getContainElements()){
+ if(!element.getLabelID().equalsIgnoreCase(propName))
+ continue;
+ //如果是多值多列UDT
+ if (element.getIsUdt()){
+ UnifiedDataTypeDef udt = CMEngineUtil.getMetadataContent(element.getUdtID());
+ if (udt == null)
+ throw new RuntimeException("没有找到业务字段元数据:" + element.getUdtID());
+
+ if (udt instanceof ComplexDataTypeDef){
+ ComplexDataTypeDef complexUdt = (ComplexDataTypeDef)udt;
+ return getMultiUdtAssosPropDBMapping(complexUdt, element);
+ }
+ }
+ //todo 后续关联的也加上
+ break;
+ }
+ return new HashMap();
+ }
+
+ public HashMap getMultiUdtAssosPropDBMapping(ComplexDataTypeDef complexUdt, IGspCommonField item){
+ HashMap map = new HashMap();
+ if(complexUdt.getDbInfo().getMappingType() == ColumnMapType.SingleColumn)
+ return map;
+ for(IGspCommonField field : complexUdt.getContainElements()){
+ map.put(field.getLabelID(), item.getLabelID() + "_" + field.getLabelID());
+ }
+ return map;
+ }
+
+ @Override
+ public Object readProperty(String propertyName, ICefReader reader) {
+ for (var element : bizEntityObject.getContainElements()) {
+ if (!element.getLabelID().equals(propertyName))
+ continue;
+ if (element.getIsUdt()){
+ return ReadUtils.getUdtData(false, reader, (IGspCommonElement) element);
+ }
+ return ReadUtils.getValue((IGspCommonElement) element, reader);
+ }
+ return null;
+ }
+
+ //endregion
+
+ //region association
+ @Override
+ protected void initAssociations() {
+
+ for (IGspCommonField field : bizEntityObject.getContainElements()) {
+ if (field.getHasAssociation())
+ initEleAssociations(field);
+ }
+
+ }
+
+ private void initEleAssociations(IGspCommonField element) {
+ if (element.getChildAssociations() == null || element.getChildAssociations().size() < 1) {
+ return;
+ }
+ for (GspAssociation association : element.getChildAssociations()) {
+ initEleAssociation(association);
+ }
+
+ }
+
+ private void initEleAssociation(GspAssociation association) {
+ GspBusinessEntity refModel = CMEngineUtil.getMetadataContent(association.getRefModelID());
+ if (refModel == null) {
+ throw new RuntimeException(String
+ .format("节点[%s]的字段[%s]上的关联模型[%s]不存在", getTableAlias(), association.getBelongElement().getName(),
+ association.getRefModelID()));
+ }
+
+ IGspCommonField belongElement = association.getBelongElement();
+ String sourceId = getSourceElementId(association);
+ if (sourceId == null || "".equals(sourceId)) {
+ throw new RuntimeException("#GSPBefError#" + "关联字段【" + belongElement.getName() + "】缺少关联关系" + "#GSPBefError#");
+ }
+
+ IRootRepository refRepository = BefRtBeanUtil.getBefRepositoryFactory().createRepository(refModel.getGeneratedConfigID());
+ HashMap refColumns = new HashMap<>();
+
+
+ for (IGspCommonField refElement : association.getRefElementCollection()) {
+ IGspCommonElement targetElement = refModel.findElementById(refElement.getRefElementId());
+ if (targetElement == null) {
+ throw new RuntimeException("没有获取到关联带出字段的引用字段,当前实体:" + bizEntityObject.getCode() + ",关联实体:"
+ + refModel.getCode() + ",字段标签:" + refElement.getLabelID());
+ }
+ refColumns.put(refElement.getLabelID(), targetElement.getLabelID());
+ }
+
+ IGspCommonObject targetObject = null;
+ //这个If永远走不到啊。。。
+ if (StringUtils.isEmpty(association)) {
+ targetObject = refModel.getMainObject();
+ } else {
+ targetObject = getObjectByID(refModel, association.getRefObjectID());
+ }
+ if (targetObject == null) {
+ throw new RuntimeException("找不到实体节点");
+ }
+ IGspCommonElement sourceElement = targetObject.findElement(sourceId);
+
+ ArrayList conditionList = new ArrayList();
+ if(association.getAssoConditions() != null && association.getAssoConditions().size() >0){
+ for(AssoCondition condition :association.getAssoConditions()){
+ com.inspur.edp.cef.repository.assembler.AssoCondition condi = new com.inspur.edp.cef.repository.assembler.AssoCondition();
+ condi.setLeftNodeCode(condition.getLeftNodeCode());
+ condi.setLeftField(condition.getLeftField());
+ condi.setOperator(condition.getOperator());
+ condi.setRightNodeCode(condition.getRightNodeCode());
+ condi.setRightField(condition.getRightField());
+ condi.setValue(condition.getValue());
+ conditionList.add(condi);
+ }
+ }
+
+ ArrayList variables = new ArrayList<>();
+ if(association.getAssoVariables() != null && association.getAssoVariables().size() >0){
+
+ for(AssoVariable variable :association.getAssoVariables()){
+ com.inspur.edp.cef.entity.repository.AssoVariable assoVariable = new com.inspur.edp.cef.entity.repository.AssoVariable();
+ assoVariable.setVarCode(variable.getVarCode());
+ assoVariable.setVarValue(variable.getVarValue());
+ variables.add(assoVariable);
+ }
+ }
+
+ com.inspur.edp.cef.repository.assembler.AssociationInfo associationInfo = new com.inspur.edp.cef.repository.assembler.AssociationInfo();
+ associationInfo.setNodeCode(targetObject.getCode());
+ associationInfo.setSourceColumn( belongElement.getLabelID());
+ associationInfo.setTargetColumn(sourceElement.getLabelID());
+ associationInfo.setRefRepository(refRepository);
+ associationInfo.setRefColumns(refColumns);
+ associationInfo.setConfigId(refModel.getGeneratedConfigID());
+ associationInfo.setWhere(association.getWhere());
+ associationInfo.setAssoConditions(conditionList);
+ associationInfo.setAssoVariables(variables);
+ associationInfo.setRefTableAlias(association.getRefTableAlias());
+ super.getAssociationInfos().add(associationInfo);
+
+ }
+
+ private String getSourceElementId(GspAssociation association) {
+ IGspCommonField belongElement = association.getBelongElement();
+ for (GspAssociationKey associationKey : association.getKeyCollection()) {
+ if (associationKey.getTargetElement().equals(belongElement.getID())) {
+ return associationKey.getSourceElement();
+ }
+ }
+ return null;
+ }
+
+ private IGspCommonObject getObjectByID(IGspCommonModel model, String objectID) {
+ //TODO: getAllObjectList逻辑较复杂,再根据id查找性能稍差,大部分场景都是关联主表先临时优化
+ if(model.getMainObject().getID().equals(objectID)){
+ return model.getMainObject();
+ }
+ for (IGspCommonObject item : model.getAllObjectList()) {
+ if (objectID.equals(item.getID())) {
+ return item;
+ }
+ }
+ return null;
+ }
+
+ //endregion
+
+ @Override
+ protected String getNodeCode() {
+ return bizEntityObject.getCode();
+ }
+}
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefDB2Adaptor.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefDB2Adaptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..0edb63492b350cdddc29d1016af2105d581e78dd
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefDB2Adaptor.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright © OpenAtom Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.adaptor;
+
+import com.inspur.edp.bef.bizentity.GspBizEntityObject;
+import com.inspur.edp.cef.repository.dac.EntityDac;
+import com.inspur.edp.cef.repository.sqlgenerator.BaseSqlGenerator;
+import com.inspur.edp.cef.repository.sqlgenerator.OraSqlGenerator;
+
+public class BefDB2Adaptor extends BefBaseAdaptor {
+ public BefDB2Adaptor(GspBizEntityObject bizEntityObject, EntityDac entityDac) {
+ super(bizEntityObject,entityDac);
+ }
+
+ @Override
+ protected BaseSqlGenerator getSqlGenerator() {
+ return new OraSqlGenerator();
+ }
+}
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefDmAdaptor.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefDmAdaptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..2ca705b247c05e2b5f642a6f0d12500f6b925862
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefDmAdaptor.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright © OpenAtom Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.adaptor;
+
+import com.inspur.edp.bef.bizentity.GspBizEntityObject;
+import com.inspur.edp.cef.repository.dac.EntityDac;
+import com.inspur.edp.cef.repository.sqlgenerator.BaseSqlGenerator;
+import com.inspur.edp.cef.repository.sqlgenerator.OraSqlGenerator;
+
+public class BefDmAdaptor extends BefBaseAdaptor {
+ public BefDmAdaptor(GspBizEntityObject bizEntityObject, EntityDac entityDac) {
+ super(bizEntityObject,entityDac);
+ }
+
+ @Override
+ protected BaseSqlGenerator getSqlGenerator() {
+ return new OraSqlGenerator();
+ }
+}
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefHighGoAdaptor.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefHighGoAdaptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..fc0815caca8f6349a33b9f32c054f69ac6ad160e
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefHighGoAdaptor.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright © OpenAtom Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.adaptor;
+
+import com.inspur.edp.bef.bizentity.GspBizEntityObject;
+import com.inspur.edp.cef.repository.dac.EntityDac;
+import com.inspur.edp.cef.repository.sqlgenerator.BaseSqlGenerator;
+import com.inspur.edp.cef.repository.sqlgenerator.PgSqlGenerator;
+
+public class BefHighGoAdaptor extends BefBaseAdaptor {
+ public BefHighGoAdaptor(GspBizEntityObject bizEntityObject, EntityDac entityDac) {
+ super(bizEntityObject,entityDac);
+ }
+
+ @Override
+ protected BaseSqlGenerator getSqlGenerator() {
+ return new PgSqlGenerator();
+ }
+}
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefOraAdaptor.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefOraAdaptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..5d5587c0b44afc619ebe980bf4cbe5a45e3c0806
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefOraAdaptor.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright © OpenAtom Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.adaptor;
+
+import com.inspur.edp.bef.bizentity.GspBizEntityObject;
+import com.inspur.edp.cef.repository.dac.EntityDac;
+import com.inspur.edp.cef.repository.sqlgenerator.BaseSqlGenerator;
+import com.inspur.edp.cef.repository.sqlgenerator.OraSqlGenerator;
+
+public class BefOraAdaptor extends BefBaseAdaptor {
+ public BefOraAdaptor(GspBizEntityObject bizEntityObject, EntityDac entityDac) {
+ super(bizEntityObject,entityDac);
+ }
+
+ @Override
+ protected BaseSqlGenerator getSqlGenerator() {
+ return new OraSqlGenerator();
+ }
+}
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefPgAdaptor.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefPgAdaptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..45fd452520ccbd98fab64c36451d25e817e925d1
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefPgAdaptor.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright © OpenAtom Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.adaptor;
+
+import com.inspur.edp.bef.bizentity.GspBizEntityObject;
+import com.inspur.edp.cef.api.repository.DbParameter;
+import com.inspur.edp.cef.api.repository.GspDbDataType;
+import com.inspur.edp.cef.repository.dac.EntityDac;
+import com.inspur.edp.cef.repository.sqlgenerator.BaseSqlGenerator;
+import com.inspur.edp.cef.repository.sqlgenerator.PgSqlGenerator;
+
+import java.sql.SQLException;
+import java.util.List;
+
+public class BefPgAdaptor extends BefBaseAdaptor{
+
+ public BefPgAdaptor(GspBizEntityObject bizEntityObject, EntityDac entityDac) {
+ super(bizEntityObject,entityDac);
+ }
+
+ @Override
+ protected BaseSqlGenerator getSqlGenerator() {
+ return new PgSqlGenerator();
+ }
+
+ public void deleteByParent(String joinInfo, String filter, List dbPars) {
+ String idWithAlias = this.getTableAlias() + "." + this.getPrimaryKey();
+ if(getLogicDeleteInfo().isEnableLogicDelete()){
+ dbPars.add(buildParam(getLogicDeleteInfo().getLabelId(), GspDbDataType.Char, "1"));
+ executeSql(String.format("update %1$s set %2$s = ?%8$s WHERE %3$s IN ( SELECT %4$s FROM %5$s %6$s WHERE %7$s )"
+ , getTableName(), getLogicDeleteInfo().getLabelId(), idWithAlias, idWithAlias, getTableName(), joinInfo, filter, dbPars.size() - 1), dbPars);
+ }
+ else {
+ this.executeSql(String.format("%1$s Where %2$s In (Select %2$s From %3$s %4$s Where %5$s)", this.getDeleteSql(), idWithAlias, this.getTableName(), joinInfo, filter), dbPars);
+ }
+ }
+}
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefSqlsvrAdaptor.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefSqlsvrAdaptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..0576caa0767598b0e382d84f0c689ccada7c9949
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/adaptor/BefSqlsvrAdaptor.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright © OpenAtom Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.adaptor;
+
+import com.inspur.edp.bef.bizentity.GspBizEntityObject;
+import com.inspur.edp.cef.repository.dac.EntityDac;
+import com.inspur.edp.cef.repository.sqlgenerator.BaseSqlGenerator;
+import com.inspur.edp.cef.repository.sqlgenerator.SqlSvrSqlGenerator;
+
+public class BefSqlsvrAdaptor extends BefBaseAdaptor {
+ public BefSqlsvrAdaptor(GspBizEntityObject bizEntityObject, EntityDac entityDac) {
+ super(bizEntityObject,entityDac);
+ }
+
+ @Override
+ protected BaseSqlGenerator getSqlGenerator() {
+ return new SqlSvrSqlGenerator();
+ }
+}
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/dac/ChildObjectDac.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/dac/ChildObjectDac.java
new file mode 100644
index 0000000000000000000000000000000000000000..dfcdc43d92adcf84a8e67233c9afd12df4900a53
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/dac/ChildObjectDac.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright © OpenAtom Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.dac;
+
+import com.inspur.edp.bef.bizentity.GspBizEntityObject;
+import com.inspur.edp.bef.engine.repository.adaptor.*;
+import com.inspur.edp.cef.api.repository.adaptor.IEntityAdaptor;
+import com.inspur.edp.cef.repository.dac.ChildEntityDac;
+import com.inspur.edp.cef.repository.dac.EntityDac;
+import lombok.var;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ChildObjectDac extends ChildEntityDac {
+
+ private GspBizEntityObject bizEntityObject;
+ private ArrayList childDac;
+ private IEntityAdaptor adaptor;
+
+ public ChildObjectDac(EntityDac parentDac, GspBizEntityObject bizEntityObject) {
+ super(parentDac);
+ this.bizEntityObject = bizEntityObject;
+ }
+
+ @Override
+ protected List getChildDacList() {
+ if (childDac != null)
+ return childDac;
+ childDac = EngineDacUtils.getChildDacList(bizEntityObject,this);
+
+ return childDac;
+ }
+
+ @Override
+ public String getNodeCode() {
+ return bizEntityObject.getCode();
+ }
+
+ @Override
+ protected IEntityAdaptor innerGetAdaptor() {
+ if (adaptor == null) {
+ adaptor=EngineDacUtils.getAdaptor(getDbType(),bizEntityObject,this);
+
+ }
+ return adaptor;
+ }
+}
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/dac/EngineDacUtils.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/dac/EngineDacUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..a0fb5a82fd64db6fa34bc156149bf4f9c228a354
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/dac/EngineDacUtils.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright © OpenAtom Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.dac;
+
+import com.inspur.edp.bef.bizentity.GspBizEntityObject;
+import com.inspur.edp.bef.engine.repository.adaptor.*;
+import com.inspur.edp.cef.api.repository.GspDbType;
+import com.inspur.edp.cef.api.repository.adaptor.IEntityAdaptor;
+import com.inspur.edp.cef.repository.dac.ChildEntityDac;
+import com.inspur.edp.cef.repository.dac.EntityDac;
+import lombok.var;
+
+import java.util.ArrayList;
+
+ final class EngineDacUtils {
+ static ArrayList getChildDacList(GspBizEntityObject bizEntityObject, EntityDac parentDac)
+ {
+ ArrayList childDac = new ArrayList<>();
+
+ if (bizEntityObject.getContainChildObjects() == null || bizEntityObject.getContainChildObjects().size() < 1)
+ return childDac;
+
+ for (var childObj : bizEntityObject.getContainChildObjects()) {
+ if(childObj.getIsVirtual())
+ continue;
+ childDac.add(new ChildObjectDac(parentDac, (GspBizEntityObject)childObj));
+ }
+
+ return childDac;
+ }
+
+ static IEntityAdaptor getAdaptor(GspDbType dbType,GspBizEntityObject bizEntityObject, EntityDac entityDac)
+ {
+ switch (dbType) {
+ case PgSQL:
+ case OpenGauss:
+ return new BefPgAdaptor(bizEntityObject,entityDac);
+ case DM:
+ return new BefDmAdaptor(bizEntityObject,entityDac);
+ case SQLServer:
+ return new BefSqlsvrAdaptor(bizEntityObject,entityDac);
+ case Oracle:
+ return new BefOraAdaptor(bizEntityObject,entityDac);
+ case HighGo:
+ return new BefHighGoAdaptor(bizEntityObject,entityDac);
+ case DB2:
+ return new BefDB2Adaptor(bizEntityObject,entityDac);
+ default :
+ throw new java.lang.RuntimeException("暂不支持数据库类型:");
+ }
+ }
+}
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/dac/MainObjectDac.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/dac/MainObjectDac.java
new file mode 100644
index 0000000000000000000000000000000000000000..f2f67bb8b06b1d6c806242cc89710b4385d75c4d
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/dac/MainObjectDac.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright © OpenAtom Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.dac;
+
+import com.inspur.edp.bef.bizentity.GspBizEntityObject;
+import com.inspur.edp.bef.bizentity.GspBusinessEntity;
+import com.inspur.edp.bef.engine.repository.adaptor.*;
+import com.inspur.edp.cef.api.repository.adaptor.IEntityAdaptor;
+import com.inspur.edp.cef.entity.entity.IChildEntityData;
+import com.inspur.edp.cef.repository.dac.ChildEntityDac;
+import com.inspur.edp.cef.repository.dac.MainEntityDac;
+import lombok.var;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class MainObjectDac extends MainEntityDac {
+
+ private GspBusinessEntity be;
+ private GspBizEntityObject mainObj;
+ private IEntityAdaptor adaptor;
+ private ArrayList childDac;
+
+ public MainObjectDac(GspBusinessEntity be) {
+ this.be = be;
+ mainObj = be.getMainObject();
+ }
+
+ @Override
+ protected List getChildDacList() {
+ if (childDac != null)
+ return childDac;
+ if (childDac != null)
+ return childDac;
+ childDac = EngineDacUtils.getChildDacList(mainObj,this);
+
+ return childDac;
+ }
+
+ @Override
+ public String getNodeCode() {
+ return mainObj.getCode();
+ }
+
+ @Override
+ protected IEntityAdaptor innerGetAdaptor() {
+ if (adaptor == null) {
+ adaptor=EngineDacUtils.getAdaptor(getDbType(),mainObj,this);
+ }
+ return adaptor;
+ }
+
+ /**
+ * 解决IDP推送BE子表关联主表的非主键字段
+ * @param map
+ */
+ protected void handleChildParentId(String dataId, Map> map){
+ if(map == null || map.size() == 0)
+ return;
+ String oldKey = "";
+ for(Map.Entry> entry : map.entrySet()){
+ oldKey = entry.getKey();
+ break;
+ }
+ List childEntityDatas = map.get(oldKey);
+ map.clear();
+ map.put(dataId, childEntityDatas);
+ }
+}
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/repos/BefRepository.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/repos/BefRepository.java
new file mode 100644
index 0000000000000000000000000000000000000000..29866242a5f492c29dd724d97102de72794485bb
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/repos/BefRepository.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright © OpenAtom Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.repos;
+
+import com.inspur.edp.bef.bizentity.GspBusinessEntity;
+import com.inspur.edp.bef.engine.repository.dac.MainObjectDac;
+import com.inspur.edp.cef.repository.dac.MainEntityDac;
+import com.inspur.edp.cef.repository.repo.BaseRootRepository;
+import com.inspur.edp.cef.repository.repo.RepositoryExtendAttribute;
+
+@RepositoryExtendAttribute(com.inspur.edp.customize.repository.CustomizeExtendInfo.class)
+public class BefRepository extends BaseRootRepository {
+ private GspBusinessEntity be;
+
+ public BefRepository(GspBusinessEntity be) {
+ this.be = be;
+ }
+
+ public BefRepository(String metadataId) {
+ }
+
+ @Override
+ protected MainEntityDac getMainEntityDac() {
+ //这个地方如果缓存,考虑adaptor的缓存使用。。
+ MainEntityDac mainEntityDac = new MainObjectDac(be);
+ mainEntityDac.initRepoVariables(this.vars);
+ return mainEntityDac;
+ }
+}
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/typetransprocesser/EnumEngineIntProcesser.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/typetransprocesser/EnumEngineIntProcesser.java
new file mode 100644
index 0000000000000000000000000000000000000000..4deec0d8338a5d89dddd0d455f014cb53715e457
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/typetransprocesser/EnumEngineIntProcesser.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright © OpenAtom Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.typetransprocesser;
+
+import com.inspur.edp.bef.bizentity.GspBizEntityElement;
+import com.inspur.edp.cef.api.repository.ITypeTransProcesser;
+import com.inspur.edp.cef.designtime.api.element.ElementDefaultVauleType;
+import com.inspur.edp.cef.designtime.api.element.EnumIndexType;
+import com.inspur.edp.cef.designtime.api.element.GspEnumValue;
+import com.inspur.edp.cef.entity.condition.FilterCondition;
+import com.inspur.edp.cef.repository.utils.FilterUtil;
+import java.sql.Connection;
+
+public class EnumEngineIntProcesser implements ITypeTransProcesser {
+ private GspBizEntityElement element;
+ public EnumEngineIntProcesser(GspBizEntityElement element){
+ this.element=element;
+ }
+ @Override public Object transType(FilterCondition condition, Connection connection) {
+
+ return transType(FilterUtil.processStringValue(condition));
+ }
+
+ @Override public Object transType(Object o) {
+
+ if(o==null){
+ return null;
+ }else if(o instanceof String){
+ if("".equals(o))
+ return "";
+ return getIndex(element,(String) o);
+
+ } else if(o instanceof Integer){
+ return (Integer)o;
+ }else {
+ throw new RuntimeException("请输入正确的的枚举索引值或枚举编号值");
+ }
+ }
+
+ @Override public Object transType(Object o, boolean b) {
+ return transType(o);
+ }
+ private Integer getIndex(GspBizEntityElement element,String value){
+ for (GspEnumValue enumValue:element.getContainEnumValues()){
+
+ //判断传进去的参数是枚举索引值
+ String enumIndex=String.valueOf(enumValue.getIndex());
+ if(value.equals(enumIndex)) {
+ return enumValue.getIndex();
+ }
+ //判断传进来的参数是枚举编号
+ String enumCode=enumValue.getValue();
+ if(value.equals(enumCode)){
+ return enumValue.getIndex();
+ }
+ }
+ throw new RuntimeException("请输入正确的的枚举索引值或枚举编号值");
+ }
+}
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/typetransprocesser/EnumEngineVarcharProcesser.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/typetransprocesser/EnumEngineVarcharProcesser.java
new file mode 100644
index 0000000000000000000000000000000000000000..801045b8b41cb9d9d8e511eb9922744167103076
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/typetransprocesser/EnumEngineVarcharProcesser.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright © OpenAtom Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.typetransprocesser;
+
+import com.inspur.edp.bef.bizentity.GspBizEntityElement;
+import com.inspur.edp.cef.api.repository.ITypeTransProcesser;
+import com.inspur.edp.cef.designtime.api.element.EnumIndexType;
+import com.inspur.edp.cef.designtime.api.element.GspEnumValue;
+import com.inspur.edp.cef.entity.condition.FilterCondition;
+import com.inspur.edp.cef.repository.utils.FilterUtil;
+import java.sql.Connection;
+
+public class EnumEngineVarcharProcesser implements ITypeTransProcesser {
+ private GspBizEntityElement element;
+ public EnumEngineVarcharProcesser(GspBizEntityElement element){
+ this.element=element;
+ }
+ @Override public Object transType(FilterCondition condition, Connection connection) {
+ return transType(FilterUtil.processStringValue(condition));
+ }
+
+ @Override public Object transType(Object o) {
+ if(o==null){
+ return null;
+ }else if(o instanceof String){
+ if("".equals(o))
+ return "";
+ return getIndex(element,(String) o);
+
+ } else if(o instanceof Integer){
+ return (Integer)o;
+ }else {
+ throw new RuntimeException("请输入正确的的枚举索引值或枚举编号值");
+ }
+ }
+
+ private Object getIndex(GspBizEntityElement element, String value) {
+ switch (element.getEnumIndexType()){
+ case Integer:
+ return getIntIndex(element,value);
+ case String:
+ return getStringIndex(element,value);
+ }
+ throw new RuntimeException(String.format(element.getLabelID() + "对应枚举索引类型不支持["+value+"]",element.getEnumIndexType().toString()));
+ }
+ private Integer getIntIndex(GspBizEntityElement element,String value){
+ for (GspEnumValue enumValue:element.getContainEnumValues()){
+
+ //判断传进去的参数是枚举索引值
+ String enumIndex=String.valueOf(enumValue.getIndex());
+ if(value.equals(enumIndex)) {
+ return enumValue.getIndex();
+ }
+ //判断传进来的参数是枚举编号
+ String enumCode=enumValue.getValue();
+ if(value.equals(enumCode)){
+ return enumValue.getIndex();
+ }
+ }
+ throw new RuntimeException(element.getLabelID()+ "对应的枚举项["+ value+ "]不正确,请输入正确的的枚举索引值或枚举编号值");
+ }
+ private String getStringIndex(GspBizEntityElement element,String value){
+ for (GspEnumValue enumValue:element.getContainEnumValues()){
+
+ //判断传进去的参数是枚举索引值
+ String enumIndex=enumValue.getStringIndex();
+ if(value.equals(enumIndex)) {
+ return enumValue.getStringIndex();
+ }
+ //判断传进来的参数是枚举编号
+ String enumCode = enumValue.getValue();
+ if (value.equals(enumCode)) {
+ return enumValue.getStringIndex();
+ }
+ }
+ throw new RuntimeException(element.getLabelID()+ "对应的枚举项["+ value+ "]不正确,请输入正确的的枚举索引值或枚举编号值");
+ }
+ @Override public Object transType(Object o, boolean b) {
+ return transType(o);
+ }
+}
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/typetransprocesser/VarcharIntTransProcesser.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/typetransprocesser/VarcharIntTransProcesser.java
new file mode 100644
index 0000000000000000000000000000000000000000..c1684066255b6145b8fa49eb5d626ffa9416306f
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/typetransprocesser/VarcharIntTransProcesser.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright © OpenAtom Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.typetransprocesser;
+
+import com.inspur.edp.cef.api.repository.ITypeTransProcesser;
+import com.inspur.edp.cef.entity.condition.FilterCondition;
+import java.sql.Connection;
+
+public class VarcharIntTransProcesser implements ITypeTransProcesser {
+ private static volatile VarcharIntTransProcesser instance;
+
+ public static VarcharIntTransProcesser getInstacne() {
+ if (instance == null) {
+ instance = new VarcharIntTransProcesser();
+ }
+
+ return instance;
+ }
+
+ public VarcharIntTransProcesser(){
+
+ }
+ @Override public Object transType(FilterCondition condition, Connection connection) {
+ return Integer.parseInt(condition.getValue());
+ }
+
+ @Override public Object transType(Object value) {
+ return this.transType(value,true);
+ }
+
+ @Override
+ public Object transType(Object value, boolean isNull) {
+
+ if (value==null || "".equals(value)){
+ return null;
+ }
+ if (value instanceof Integer || value.getClass() == int.class) {
+ return value.toString();
+ }
+
+ if(value instanceof String){
+ return Integer.valueOf(value.toString());
+ }
+ return value;
+ }
+}
diff --git a/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/util/ReadUtils.java b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/util/ReadUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..880793d4f7d5b9426c14ebee9e80c1ad1618449a
--- /dev/null
+++ b/business-entity-engine-repository/src/main/java/com/inspur/edp/bef/engine/repository/util/ReadUtils.java
@@ -0,0 +1,586 @@
+/*
+ * Copyright © OpenAtom Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.inspur.edp.bef.engine.repository.util;
+
+import com.inspur.edp.bef.bizentity.GspBizEntityObject;
+import com.inspur.edp.bef.bizentity.GspBusinessEntity;
+import com.inspur.edp.bef.bizentity.common.BefDtBeanUtil;
+import com.inspur.edp.bef.engine.entity.AssociationInfo;
+import com.inspur.edp.cef.api.repository.INestedRepository;
+import com.inspur.edp.cef.api.repository.readerWriter.ICefReader;
+import com.inspur.edp.cef.designtime.api.IGspCommonField;
+import com.inspur.edp.cef.designtime.api.element.EnumIndexType;
+import com.inspur.edp.cef.designtime.api.element.GspAssociation;
+import com.inspur.edp.cef.designtime.api.element.GspElementObjectType;
+import com.inspur.edp.cef.designtime.api.element.GspEnumValue;
+import com.inspur.edp.cef.entity.changeset.ValueObjModifyChangeDetail;
+import com.inspur.edp.cef.entity.entity.EntityDataPropertyValueUtils;
+import com.inspur.edp.cef.entity.entity.ICefData;
+import com.inspur.edp.cef.entity.entity.IEntityData;
+import com.inspur.edp.cef.repository.adaptor.EntityRelationalAdaptor;
+import com.inspur.edp.cef.repository.readerwriter.CefMappingReader;
+import com.inspur.edp.commonmodel.engine.api.common.CMEngineUtil;
+import com.inspur.edp.das.commonmodel.IGspCommonElement;
+import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
+import com.inspur.edp.udt.api.UdtManagerUtils;
+import com.inspur.edp.udt.designtime.api.entity.ComplexDataTypeDef;
+import com.inspur.edp.udt.designtime.api.entity.SimpleDataTypeDef;
+import com.inspur.edp.udt.designtime.api.entity.UnifiedDataTypeDef;
+import com.inspur.edp.udt.designtime.api.entity.dbInfo.ColumnMapType;
+import io.iec.edp.caf.commons.utils.SpringBeanUtils;
+import lombok.var;
+import org.eclipse.core.internal.utils.Convert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigDecimal;
+import java.sql.Clob;
+import java.sql.SQLException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+public class ReadUtils {
+ protected static Logger logger = LoggerFactory.getLogger(ReadUtils.class);
+ //region 非udt字段赋值
+ public static Object getValue(IGspCommonElement element, ICefReader reader) {
+ if (element.getObjectType() == GspElementObjectType.Association)
+ return getAssoValue(element, reader);
+ Object value = reader.readValue(element.getLabelID());
+ if (element.getObjectType() == GspElementObjectType.Enum)
+ return getEnumValue(element, value);
+ switch (element.getMDataType()) {
+ case String:
+ return getStringValue(element, value);
+ case Integer:
+ return getIntValue(element, value);
+ case Decimal:
+ return getDecimalValue(element, value);
+ case Boolean:
+ return getBoolValue(element, value);
+ case Date:
+ case DateTime:
+ return getDateValue(element, value);
+ case Text:
+ return getTextValue(element, value);
+ case Binary:
+ return getBinaryValue(element, value);
+ }
+
+ throw new RuntimeException("字段[" + element.getLabelID() + "]没有合适的读取方法,数据类型:" + element.getMDataType());
+ }
+
+ public static Object getValue(String prefix, IGspCommonElement element, ICefReader reader) {
+ if (element.getObjectType() == GspElementObjectType.Association)
+ return getAssoValue(element, reader);
+ Object value = reader.readValue(prefix +"_" + element.getCode());
+ if (element.getObjectType() == GspElementObjectType.Enum)
+ return getEnumValue(element, value);
+ switch (element.getMDataType()) {
+ case String:
+ return getStringValue(element, value);
+ case Integer:
+ return getIntValue(element, value);
+ case Decimal:
+ return getDecimalValue(element, value);
+ case Boolean:
+ return getBoolValue(element, value);
+ case Date:
+ case DateTime:
+ return getDateValue(element, value);
+ case Text:
+ return getTextValue(element, value);
+ case Binary:
+ return getBinaryValue(element, value);
+ }
+
+ throw new RuntimeException("字段" + element.getLabelID() + "没有合适的读取方法" + element.getMDataType());
+ }
+
+ private static Object getEnumValue(IGspCommonElement element, Object value) {
+ if (element.getContainEnumValues() == null)
+ throw new RuntimeException("字段" + element.getLabelID() + "设置为枚举类型,但未添加枚举项");
+ GspEnumValue defaultEnumValue = null;
+ HashMap stringIndexEnumValue = new HashMap<>();
+ HashMap intIndexEnumValue = new HashMap<>();
+ for (GspEnumValue enumValue : element.getContainEnumValues()) {
+ if (enumValue.getIsDefaultEnum())
+ defaultEnumValue = enumValue;
+ if (element.getEnumIndexType() == EnumIndexType.String)
+ stringIndexEnumValue.put(enumValue.getStringIndex(), enumValue);
+ else
+ intIndexEnumValue.put(enumValue.getIndex(), enumValue);
+ }
+
+ if (value == null ||"".equals(value.toString().trim())) {
+ return null;
+ }
+
+ String indexValue = null;
+ GspEnumValue enumInfo = null;
+ if (element.getEnumIndexType() == EnumIndexType.String) {
+ String index = getStringValue(element, value);
+ enumInfo = stringIndexEnumValue.get(index);
+ indexValue = index;
+ } else {
+ int index = getIntValue(element, value);
+ enumInfo = intIndexEnumValue.get(index);
+ indexValue = String.valueOf(index);
+ }
+
+ //element.getContainEnumValues().get(index);
+ if (enumInfo == null)
+ throw new RuntimeException("字段" + element.getLabelID()
+ + "中没有索引值为" + indexValue + "的枚举项");
+ return enumInfo.getValue();
+ }
+
+ private static Object getAssoValue(IGspCommonElement element, ICefReader reader) {
+ if(element.getIsRefElement()){
+ GspBusinessEntity gspBusinessEntity = CMEngineUtil.getMetadataContent(element.getParentAssociation().getRefModelID());
+ GspBizEntityObject gspBizEntityObject = gspBusinessEntity.getNode(element.getParentAssociation().getRefObjectCode());
+ for(IGspCommonField gspCommonField: gspBizEntityObject.getContainElements()){
+ if(gspCommonField.getID().equals(element.getRefElementId())){
+ var association = gspCommonField.getChildAssociations().get(0);
+ if (association == null)
+ throw new RuntimeException("字段" + element.getLabelID() + "设置的关联是空");
+ AssociationInfo info = new AssociationInfo(association);
+ //递归拼字段
+ info.setValue(gspCommonField.getLabelID(), getStringValue(element, getStringValue(element, reader.readValue(element.getLabelID()))));
+ if (association.getRefElementCollection() == null || association.getRefElementCollection().size() < 1)
+ return info;
+
+ for (var refElement : association.getRefElementCollection()) {
+ if(refElement.getIsUdt()){
+ info.setValue(refElement.getLabelID(), ReadUtils.getUdtData(element, true, reader, (IGspCommonElement)refElement));
+ }
+ else {
+ info.setValue(refElement.getLabelID(),
+ getValue(element.getLabelID(), (IGspCommonElement) refElement,
+ reader));
+ }
+ }
+ return info;
+ }
+ }
+ }
+ var association = element.getChildAssociations().get(0);
+
+ if (association == null)
+ throw new RuntimeException("字段" + element.getLabelID() + "设置的关联是空");
+ AssociationInfo info = new AssociationInfo(association);
+ info.setValue(element.getLabelID(), getStringValue(element, getStringValue(element, reader.readValue(element.getLabelID()))));
+ if (association.getRefElementCollection() == null || association.getRefElementCollection().size() < 1)
+ return info;
+
+ for (var refElement : association.getRefElementCollection()) {
+ if(refElement.getIsUdt()){
+ info.setValue(refElement.getLabelID(), ReadUtils.getUdtData(true, reader, (IGspCommonElement)refElement));
+ }
+ else {
+ info.setValue(refElement.getLabelID(), getValue((IGspCommonElement) refElement, reader));
+ }
+ }
+
+ //TODO 关联后续处理
+ return info;
+ }
+
+ private static String getStringValue(IGspCommonElement element, Object value) {
+ if (value == null)
+ return EntityDataPropertyValueUtils.getStringPropertyDefaultValue();
+ else if(value.toString().toLowerCase().contains("oracle.sql.clob")){
+ return getClobValue(element, value);
+ }
+ return value.toString();
+ }
+
+ private static Integer getIntValue(IGspCommonElement element, Object value) {
+ if (value == null)
+ return null;
+ try {
+ return Integer.valueOf(value.toString());
+ }
+ catch (Exception ex){
+ throw new RuntimeException("字段["+element.getLabelID()+"]转换为Integer类型失败,值为["+value.toString()+"]");
+ }
+ }
+
+ private static BigDecimal getDecimalValue(IGspCommonElement element, Object value) {
+ if (value == null)
+ return null;
+ if(value instanceof BigDecimal)
+ return (BigDecimal) value;
+ try {
+ return new BigDecimal(value.toString());
+ }
+ catch (Exception ex){
+ throw new RuntimeException("字段["+element.getLabelID()+"]转换为BigDecimal类型失败,值为["+value.toString()+"]");
+ }
+ }
+
+ private static Boolean getBoolValue(IGspCommonElement element, Object value) {
+ if (value == null)
+ return null;
+ switch (value.toString().toLowerCase()) {
+ case "0":
+ case "false":
+ return false;
+ case "1":
+ case "true":
+ return true;
+ default:{
+ logger.error("字段[code=" + element.getLabelID() + ",elementid="+element.getID()+ " belogobjectid=" +element.getBelongObject().getID()+ " belongobjectname=" + element.getBelongObject().getName() + " beid=" + element.getBelongObject().getBelongModel().getID() + " ]转换为boolean类型失败,值为" + value);
+ throw new RuntimeException("字段[code=" + element.getLabelID() + " ]转换为boolean类型失败,值为" + value);
+ }
+ }
+// return getBoolean(value.toString());
+ }
+
+ private static SimpleDateFormat sdfForYYYYMMDD = new SimpleDateFormat("yyyyMMdd");
+ private static Date getDateValue(IGspCommonElement element, Object value) {
+ if (value == null)
+ return EntityDataPropertyValueUtils.getDateTimePropertyDefaultValue();
+ try {
+ if(value instanceof String&&((String)value).length()==8) {
+ return sdfForYYYYMMDD.parse((String) value);
+ }
+ return (Date) value;
+ }
+ catch (Exception ex){
+ logger.error("字段[code=" + element.getLabelID() + ",elementid="+element.getID()+ " belogobjectid=" +element.getBelongObject().getID()+ " belongobjectname=" + element.getBelongObject().getName() + " beid=" + element.getBelongObject().getBelongModel().getID() + " ]转换为Date类型失败,值为["+value.toString()+"]");
+ throw new RuntimeException("字段["+element.getLabelID()+"]转换为Date类型失败,值为["+value.toString()+"]");
+ }
+ }
+
+ private static String getTextValue(IGspCommonElement element, Object value) {
+ if (value == null)
+ return EntityDataPropertyValueUtils.getStringPropertyDefaultValue();
+ return getClobValue(value);
+ }
+
+ private static byte[] getBinaryValue(IGspCommonElement element, Object value) {
+ if (value == null)
+ return EntityDataPropertyValueUtils.getBinaryPropertyDefaultValue();
+ //TODO: 这个地方为啥不走getDbProcessor().getBlobValue
+ if(value instanceof byte[])
+ return (byte[])value;
+ return Convert.toUTF8(value.toString());
+
+ }
+
+
+ private static boolean getBoolean(String value) {
+ switch (value) {
+ case "0":
+ return false;
+ case "1":
+ return true;
+ default:
+ throw new RuntimeException("不正确的布尔值:" + value);
+ }
+ }
+
+ private static String getClobValue(Object obj) {
+ if (obj instanceof String) {
+ return obj.toString();
+ } else {
+ try {
+ return obj == null ? EntityDataPropertyValueUtils.getStringPropertyDefaultValue() : ((Clob) obj).getSubString(1L, (int) ((Clob) obj).length());
+ } catch (Exception e) {
+ throw new RuntimeException("解析备注类型数据:" + obj + "失败");
+ }
+ }
+ }
+
+ private static String getClobValue(IGspCommonElement element, Object obj) {
+ if (obj instanceof String) {
+ return obj.toString();
+ } else {
+ try {
+ return obj == null ? EntityDataPropertyValueUtils.getStringPropertyDefaultValue() : ((Clob) obj).getSubString(1L, (int) ((Clob) obj).length());
+ } catch (Exception e) {
+ throw new RuntimeException("字段["+element.getLabelID()+"]转换为Clob类型失败,值为" + obj);
+ }
+ }
+ }
+
+ //endregion
+
+ //region udt字段賦值
+
+ public static void setUdtData(ICefReader reader, IEntityData data, IGspCommonElement element) {
+ Object value = getUdtData(reader, element);
+ data.setValue(element.getLabelID(), value);
+ }
+
+ public static void setUdtData(ICefReader reader, boolean isAssoRef, IEntityData data, IGspCommonElement element) {
+ Object value = getUdtData(isAssoRef, reader, element);
+ data.setValue(element.getLabelID(), value);
+ }
+
+ public static Object getUdtData(ICefReader reader, IGspCommonElement element){
+ return getUdtData(true, reader, element);
+ }
+
+ public static Object getUdtData(boolean isAssoRef, ICefReader reader, IGspCommonElement element){
+ UnifiedDataTypeDef udt = CMEngineUtil.getMetadataContent(element.getUdtID());
+ if (udt == null)
+ throw new RuntimeException("没有找到业务字段["+element.getLabelID()+"]对应的UDT元数据:" + element.getUdtID());
+ Object value = udt instanceof SimpleDataTypeDef ? setSimpleUdtData(null, reader, element,
+ (SimpleDataTypeDef) udt) : setComplexUdtData( reader,isAssoRef, element, (ComplexDataTypeDef) udt);
+ return value;
+ }
+
+ public static Object getUdtData(IGspCommonElement assoElment, boolean isAssoRef, ICefReader reader, IGspCommonElement element){
+ UnifiedDataTypeDef udt = CMEngineUtil.getMetadataContent(element.getUdtID());
+ if (udt == null)
+ throw new RuntimeException("没有找到业务字段["+element.getLabelID()+"]对应的UDT元数据:" + element.getUdtID());
+ Object value = udt instanceof SimpleDataTypeDef ? setSimpleUdtData(assoElment, reader, element,
+ (SimpleDataTypeDef) udt) : setComplexUdtData( reader,isAssoRef, element, (ComplexDataTypeDef) udt);
+ return value;
+ }
+
+ private static Object setSimpleUdtData(IGspCommonElement assoElement, ICefReader reader, IGspCommonElement element, SimpleDataTypeDef udt) {
+ LinkedHashMap map = new LinkedHashMap();
+ switch (udt.getObjectType()) {
+ case None:
+ case Enum:{
+ if(assoElement != null && assoElement.getIsRefElement() && assoElement.getParentAssociation() != null && assoElement.getParentAssociation().getBelongElement() != null){//处理关联-带出关联-带出UDT字段的场景
+ IGspCommonField parentElement = assoElement.getParentAssociation().getBelongElement();
+ map.put(udt.getCode(), parentElement.getLabelID() + "_" + element.getLabelID());
+ }
+ else {
+ map.put(udt.getCode(), element.getLabelID());
+ }
+ break;
+ }
+ case Association:
+ addAssUdtMapping(map, element, udt);
+ break;
+ default:
+ break;
+ }
+
+ return getUdtData(map, reader, udt);
+ }
+
+ private static void addAssUdtMapping(LinkedHashMap mapping, IGspCommonElement element, SimpleDataTypeDef udt) {
+ if(element.getChildAssociations() != null && element.getChildAssociations().size() > 0){
+ var fieldAssociation = element.getChildAssociations().get(0);
+ var udtAssociation = udt.getChildAssociations().get(0);
+ mapping.put(udt.getCode(), element.getLabelID());
+ for (var item : fieldAssociation.getRefElementCollection()) {
+ if (!item.getIsFromAssoUdt()) {
+ continue;
+ }
+ IGspCommonField udtRefField =
+ getElementByRefElementID(udtAssociation, item.getRefElementId(), item.getLabelID(), udt);
+ mapping.put(udtRefField.getLabelID(), item.getLabelID());
+ //todo 暂时隐藏,跟其他模块一块提交
+ if(udtRefField.getIsUdt()){
+ //判断是否多值UDT 或者继续?
+ UnifiedDataTypeDef glUdt = CMEngineUtil.getMetadataContent(udtRefField.getUdtID());
+ if(glUdt instanceof ComplexDataTypeDef){
+ ComplexDataTypeDef complexDataTypeDef = (ComplexDataTypeDef)glUdt;
+ if(complexDataTypeDef.getDbInfo().getMappingType() == ColumnMapType.MultiColumns){
+ for(IGspCommonField udtField : complexDataTypeDef.getContainElements()){
+ mapping.put(udtRefField.getLabelID() + "_" + udtField.getLabelID(), item.getLabelID() + "_" + udtField.getLabelID());
+ }
+ }
+ }
+ }
+ }
+ }
+ else {//关联udt
+ mapping.put(udt.getCode(), element.getLabelID());
+ for(IGspCommonField udtField: udt.getChildAssociations().get(0).getRefElementCollection()){
+ mapping.put(udtField.getLabelID(), element.getLabelID() + "_" + udtField.getLabelID());
+ }
+ }
+ }
+
+ private static IGspCommonField getElementByRefElementID(
+ GspAssociation udtAssociation,
+ String refElementID,
+ String labelId,
+ SimpleDataTypeDef udt) {
+ for (var item : udtAssociation.getRefElementCollection()) {
+ if (refElementID.equals(item.getRefElementId())) {
+ return item;
+ }
+ }
+ throw new RuntimeException(
+ "找不到UDT[" + udt.getCode() + "]关联字段" + refElementID + "----" + labelId);
+ }
+
+ private static Object setComplexUdtData(ICefReader reader, boolean isAssoRef, IGspCommonElement element, ComplexDataTypeDef udt) {
+ LinkedHashMap map = null;
+ switch (udt.getDbInfo().getMappingType()) {
+ case MultiColumns:
+ map = getMultiColumnsUdtMap(reader, isAssoRef, element, udt);
+ break;
+ case SingleColumn:
+ map = getSingleColumnUdtMap(reader, element, udt);
+ break;
+ }
+
+ return getUdtData(map, reader, udt);
+ }
+
+ private static Object getUdtData(
+ LinkedHashMap map,
+ ICefReader reader,
+ UnifiedDataTypeDef udt) {
+ CefMappingReader mappingReader = new CefMappingReader(map, reader);
+ INestedRepository u1Repos = UdtManagerUtils.getUdtRepositoryFactory().createRepository(udt.getUdtType());
+ return u1Repos.readData(mappingReader);
+ }
+
+ private static LinkedHashMap getSingleColumnUdtMap(ICefReader reader, IGspCommonElement element, ComplexDataTypeDef udt) {
+ LinkedHashMap map = new LinkedHashMap<>();
+ map.put(udt.getCode(), element.getLabelID());
+ return map;
+ }
+
+ /**
+ *
+ * @param reader
+ * @param isAssoRef 是否关联带出
+ * @param element
+ * @param udt
+ * @return
+ */
+ private static LinkedHashMap getMultiColumnsUdtMap(ICefReader reader, boolean isAssoRef, IGspCommonElement element, ComplexDataTypeDef udt) {
+ LinkedHashMap map = new LinkedHashMap<>();
+ for (IGspCommonField childElement : element.getChildElements()) {
+ String udtElementId = element.getMappingRelation().getMappingInfo(childElement.getID());
+ IGspCommonField udtElement = udt.findElement(udtElementId);
+ //labeldId与Code不一致,说明是带出的 或者应该用ContainElements来判断
+ //这个判断不准确
+ if(isAssoRef){
+ //储粮存在手动修改 labelid和code不一致的情况(非带出多值UDT)
+ if(childElement.getLabelID().equalsIgnoreCase(childElement.getCode())){
+ map.put(udtElement.getLabelID(), childElement.getLabelID());
+ }
+ else {
+ map.put(udtElement.getLabelID(), childElement.getLabelID() + "_" + childElement.getCode());
+ }
+ }
+ else {
+ map.put(udtElement.getLabelID(), childElement.getLabelID());
+ }
+
+ }
+ return map;
+ }
+
+ //endregion
+
+ //region udt字段新增
+ public static Object getUdtValue(GspBizEntityObject beObject, String labelId, String belongEleLabelId, Object udtData){
+
+ var elementDic = beObject.getAllElementDic();
+ if(!elementDic.containsKey(belongEleLabelId))
+ return null;
+ var parentElement = elementDic.get(belongEleLabelId);
+// var udtData = entityData.getValue(belongEleLabelId);
+ UnifiedDataTypeDef udt = CMEngineUtil.getMetadataContent(parentElement.getUdtID());
+ if (udt == null)
+ throw new RuntimeException("没有找到业务字段元数据:" + parentElement.getUdtID());
+
+ if (udt instanceof SimpleDataTypeDef)
+ return getUdtChangeValue(udtData, udt.getUdtType(), udt.getCode());
+ else{
+ ComplexDataTypeDef complexUdt = (ComplexDataTypeDef)udt;
+ switch (complexUdt.getDbInfo().getMappingType()) {
+ case MultiColumns:
+ IGspCommonField udtElement =getUdtElement(parentElement, complexUdt, labelId);
+ return getUdtChangeValue(udtData, udt.getUdtType(), udtElement.getLabelID());
+ case SingleColumn:
+ return getUdtChangeValue(udtData, udt.getUdtType(), udt.getCode());
+ }
+ }
+ return null;
+ }
+
+ public static IGspCommonField getUdtElement(IGspCommonField element, ComplexDataTypeDef udt,String columnName){
+ IGspCommonField childElement = findChildElementByLabelId(element, columnName);
+ String udtElementId = element.getMappingRelation().getMappingInfo(childElement.getID());
+ IGspCommonField udtElement = udt.findElement(udtElementId);
+ if (udtElement == null)
+ throw new RuntimeException("udt[" + udt.getCode() + "]中为找到id为" + udtElementId + "的字段");
+
+ return udtElement;
+ }
+
+ private static IGspCommonField findChildElementByLabelId(IGspCommonField element, String lableId) {
+ for (IGspCommonField childElement :
+ element.getChildElements()) {
+ if (childElement.getLabelID().equals(lableId))
+ return childElement;
+ }
+ throw new RuntimeException("未找到字段" + lableId);
+ }
+
+ public static Object getUdtChangeValue(Object propertyValue, String configId, String propName) {
+ if (propertyValue instanceof ValueObjModifyChangeDetail) {
+ propertyValue = ((ValueObjModifyChangeDetail) propertyValue).getData();
+ }
+ if (!(propertyValue instanceof ICefData)) {
+ return propertyValue;
+ }
+ return UdtManagerUtils.getUdtRepositoryFactory().createRepository(configId).getPersistenceValue(propName, (ICefData) propertyValue);
+
+ }
+ //endregion
+
+ //region udt字段更新
+
+// public static Object getUdtModifyValue(GspBizEntityObject beObject, String labelId, String belongEleLabelId, Object udtChange){
+//
+// var elementDic = beObject.getAllElementDic();
+// if(!elementDic.containsKey(belongEleLabelId))
+// return null;
+// var parentElement = elementDic.get(belongEleLabelId);
+//// var udtData = entityData.getValue(belongEleLabelId);
+//
+// GspMetadata udtMetadata = getCustomizationRtService().getMetadata(parentElement.getUdtID());
+// if (udtMetadata == null)
+// throw new RuntimeException("没有找到业务字段元数据:" + parentElement.getUdtID());
+// UnifiedDataTypeDef udt = (UnifiedDataTypeDef) udtMetadata.getContent();
+//
+// if (udt instanceof SimpleDataTypeDef)
+// return getUdtChangeValue(udtData, udt.getUdtType(), udt.getCode());
+// else{
+// ComplexDataTypeDef complexUdt = (ComplexDataTypeDef)udt;
+// switch (complexUdt.getDbInfo().getMappingType()) {
+// case MultiColumns:
+// IGspCommonField udtElement =getUdtElement(parentElement, complexUdt, labelId);
+// return getUdtChangeValue(udtData, udt.getUdtType(), udtElement.getLabelID());
+// case SingleColumn:
+// return getUdtChangeValue(udtData, udt.getUdtType(), udt.getCode());
+// }
+// }
+// return null;
+// }
+
+
+ //endregion
+
+}
diff --git a/common-entity-engine-api/pom.xml b/common-entity-engine-api/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ba8a9978264ac35b4772eaab95663c8b299b963c
--- /dev/null
+++ b/common-entity-engine-api/pom.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+ cef-engine
+ com.inspur.edp
+ 0.1.0-SNAPSHOT
+
+ 4.0.0
+
+ common-entity-engine-api
+
+
+
+ com.inspur.edp
+ cef-entity
+ ${cef.version}
+
+
+ com.inspur.edp
+ cef-spi
+ 0.2.31
+
+
+ com.inspur.edp
+ cef-designtime-api
+ 0.1.8-SNAPSHOT
+
+
+ com.inspur.edp
+ das-commonmodel
+ 0.1.10
+
+
+ io.iec.edp
+ caf-boot-commons-utils
+
+
+
diff --git a/common-entity-engine-core/pom.xml b/common-entity-engine-core/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..434114db91ded4e3da98217816bc51ab48fbffec
--- /dev/null
+++ b/common-entity-engine-core/pom.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+ cef-engine
+ com.inspur.edp
+ 0.1.0-SNAPSHOT
+
+ 4.0.0
+
+ common-entity-engine-core
+
+
+ com.inspur.edp
+ das-commonmodel
+ 0.1.2
+
+
+ com.inspur.edp
+ cef-engine-api
+ ${project.version}
+
+
+ com.inspur.edp
+ cef-spi
+ ${cef.version}
+
+
+ com.inspur.edp
+ cef-core
+ ${cef.version}
+
+
+ com.inspur.edp
+ metadata-rtcustomization-api
+ 0.1.28
+
+
+ com.inspur.edp
+ cef-designtime-api
+ 0.2.23
+
+
+ com.inspur.edp
+ udt-designtime-api
+ 0.1.3
+
+
+ com.inspur.edp
+ cef-variable-core
+ 0.1.5
+
+
+
+
diff --git a/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/common/CefDataTypeUtil.java b/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/common/CefDataTypeUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..a60aa92f8208f423f9b54072295a7419951e21d4
--- /dev/null
+++ b/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/common/CefDataTypeUtil.java
@@ -0,0 +1,156 @@
+/*
+ *
+ * * Copyright © OpenAtom Foundation.
+ * *
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ *
+ */
+
+package com.inspur.edp.cef.engine.core.common;
+
+import com.inspur.edp.cef.designtime.api.IGspCommonDataType;
+import com.inspur.edp.cef.designtime.api.IGspCommonField;
+import com.inspur.edp.cef.designtime.api.util.MetadataUtil;
+import com.inspur.edp.cef.entity.entity.ICefData;
+import com.inspur.edp.cef.entity.entity.IValueObjData;
+
+import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
+import com.inspur.edp.metadata.rtcustomization.api.CustomizationRtService;
+import com.inspur.edp.udt.designtime.api.entity.UnifiedDataTypeDef;
+import io.iec.edp.caf.commons.utils.SpringBeanUtils;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+
+public class CefDataTypeUtil {
+
+ public static IGspCommonField checkElementExists(IGspCommonDataType node, String labelId,
+ Predicate elementPredicate) {
+ Objects.requireNonNull(labelId, "labelId");
+
+ IGspCommonField element = findElement(node, labelId);
+ if (element == null || (elementPredicate != null && !elementPredicate.test(element))) {
+ throwElementNotFound(node, labelId);
+ }
+ return (IGspCommonField) element;
+ }
+
+ public static boolean isElementExist(IGspCommonDataType node, String labelId,
+ Predicate elementPredicate) {
+ IGspCommonField element = findElement(node, labelId);
+ return element != null && (elementPredicate == null || elementPredicate.test(element));
+ }
+
+ private static IGspCommonField findElement(IGspCommonDataType node, String labelId) {
+ return (IGspCommonField) node.getContainElements().getByLabelId(labelId);
+ }
+
+ public static IGspCommonField checkElementValue(IGspCommonDataType node, String labelId,
+ Object value, Predicate elementPredicate) {
+ IGspCommonField element = checkElementExists(node, labelId, elementPredicate);
+
+ if (element.getIsUdt()) {
+ if (value != null && !(value instanceof IValueObjData)) {
+ throwInvalidPropertyValue(node, element, value);
+ }
+ }
+// else if (element.getObjectType() == GspElementObjectType.Association) {
+// if (value != null) {
+// if (value instanceof AssociationInfo) {
+// GspAssociation association = element.getChildAssociations().get(0);
+// ((AssociationInfo) value).setAssociation(association);
+// for (Map.Entry key : ((AssociationInfo) value).getValues()
+// .entrySet()) {
+// checkRefElementExists(association, key.getKey());
+// //TODO:check key.getValue()
+// }
+// } else {
+// throwInvalidPropertyValue(node, element, value);
+// }
+// }
+// }
+ return element;
+ //TODO: check enum/normal
+ }
+
+ private static void throwInvalidPropertyValue(IGspCommonDataType node, IGspCommonField element,
+ Object value) {
+ throw new RuntimeException(
+ (value != null ? value.getClass() : "null") + " is not valid for" + node
+ .getCode() + "." + element.getLabelID());
+ }
+
+// public static IGspCommonField checkRefElementExists(
+// GspAssociation association, String labelId) {
+// if (association.getBelongElement().getLabelID().equalsIgnoreCase(labelId)) {
+// return (IGspCommonField) association.getBelongElement();
+// }
+// IGspCommonField field =
+// (IGspCommonField)
+// association.getRefElementCollection().stream()
+// .filter(item -> item.getLabelID().equalsIgnoreCase(labelId))
+// .findFirst()
+// .orElse(null);
+// if (field == null) {
+// throwRefElementNotFound(association, labelId);
+// }
+// return field;
+// }
+
+ public static HashMap cloneForValues(HashMap source)
+ throws CloneNotSupportedException {
+ if (source == null) {
+ return null;
+ }
+ HashMap result = new HashMap<>(source.size());
+ for (Map.Entry pair : source.entrySet()) {
+ Object value = null;
+ if (pair.getValue() == null) {
+ value = null;
+// } else if (pair.getValue() instanceof AssociationInfo) {
+// value = ((AssociationInfo) pair.getValue()).clone();
+ } else if (pair.getValue() instanceof ICefData) {
+ value = ((ICefData) pair.getValue()).copySelf();
+ } else {
+ value = pair.getValue();
+ }
+ result.put(pair.getKey(), (TValue) value);
+ }
+ return result;
+ }
+
+ public static Stream streamElements(IGspCommonDataType node,
+ Predicate predicate) {
+ Stream rez = node.getContainElements().stream();
+ if (predicate != null) {
+ rez = rez.filter(predicate);
+ }
+ return rez;
+ }
+
+ public static String getUdtConfigId(String udtId, String udtPackgeName) {
+ GspMetadata udtMetadata = MetadataUtil.getCustomRTMetadata(udtId);
+ UnifiedDataTypeDef udtContent = (UnifiedDataTypeDef) (udtMetadata != null ? udtMetadata
+ .getContent() : null);
+ if (udtContent == null) {
+ throw new RuntimeException("udt元数据不存在" + udtId);
+ }
+ return udtContent.getUdtType();
+ }
+
+ public static void throwElementNotFound(IGspCommonDataType node, String labelId) {
+ throw new RuntimeException("找不到字段" + node.getCode() + "." + labelId);
+ }
+}
diff --git a/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/data/EngineValueObjAccessor.java b/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/data/EngineValueObjAccessor.java
new file mode 100644
index 0000000000000000000000000000000000000000..3141bd9de1f358ea950fa251e4744880be1192b4
--- /dev/null
+++ b/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/data/EngineValueObjAccessor.java
@@ -0,0 +1,182 @@
+/*
+ *
+ * * Copyright © OpenAtom Foundation.
+ * *
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ *
+ */
+
+package com.inspur.edp.cef.engine.core.data;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.inspur.edp.cef.designtime.api.IGspCommonDataType;
+import com.inspur.edp.cef.designtime.api.IGspCommonField;
+import com.inspur.edp.cef.engine.core.common.CefDataTypeUtil;
+import com.inspur.edp.cef.entity.accessor.base.AccessorBase;
+import com.inspur.edp.cef.entity.accessor.base.AccessorComparer;
+import com.inspur.edp.cef.entity.accessor.base.IAccessor;
+import com.inspur.edp.cef.entity.accessor.dataType.ValueObjAccessor;
+import com.inspur.edp.cef.entity.changeset.IChangeDetail;
+import com.inspur.edp.cef.entity.changeset.ModifyChangeDetail;
+import com.inspur.edp.cef.entity.changeset.ValueObjModifyChangeDetail;
+import com.inspur.edp.cef.entity.entity.ICefData;
+import com.inspur.edp.cef.entity.entity.IValueObjData;
+import com.inspur.edp.udt.api.UdtManagerUtils;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Predicate;
+import lombok.var;
+
+public class EngineValueObjAccessor extends
+ com.inspur.edp.cef.core.data.ValueObjAccessor {
+
+ private final IGspCommonDataType node;
+ protected Map nestedValues;
+
+ public EngineValueObjAccessor(IGspCommonDataType node, IValueObjData inner) {
+ super(inner);
+ this.node = node;
+ initialize();
+ }
+
+ @JsonIgnore
+ protected IGspCommonDataType getDataType(){
+ return node;
+ }
+
+ @Override
+ public boolean getIsReadonly() {
+ return false;
+ }
+
+ @Override
+ protected void acceptChangeCore(IChangeDetail change) {
+ super.acceptChangeCore(change);
+ ValueObjModifyChangeDetail var =
+ change instanceof ValueObjModifyChangeDetail ? (ValueObjModifyChangeDetail) change : null;
+ if (var == null) {
+ throw new RuntimeException();
+ }
+ for (Map.Entry propertyChange : var.getPropertyChanges().entrySet()) {
+ if (!CefDataTypeUtil.isElementExist(node, propertyChange.getKey(), getElementPredicate())) {
+ continue;
+ }
+ if (propertyChange.getValue() instanceof ValueObjModifyChangeDetail) {
+ ((IAccessor) getValue(propertyChange.getKey()))
+ .acceptChange((ValueObjModifyChangeDetail) propertyChange.getValue());
+ } else {
+ getInnerData().setValue(propertyChange.getKey(), propertyChange.getValue());
+ }
+ }
+ }
+
+ @Override
+ public Object innerGetValue(String labeldId) {
+ Objects.requireNonNull(labeldId, "labeldId");
+
+ var element = CefDataTypeUtil.checkElementExists(node, labeldId, getElementPredicate());
+ if (element.getIsUdt()) {
+ return nestedValues.get(element.getLabelID());
+ } else {
+ return getInnerData().getValue(element.getLabelID());
+ }
+ }
+
+ @Override
+ public void innerSetValue(String labelId, Object value) {
+ Objects.requireNonNull(labelId, "labelId");
+
+ var element = CefDataTypeUtil.checkElementExists(node, labelId, getElementPredicate());
+ if (element.getIsUdt()) {
+ throw new UnsupportedOperationException();
+ }
+
+ Object orgValue = getInnerData().getValue(element.getLabelID());
+ super.raisePropertyChanging(element.getLabelID(), value, orgValue);
+ if (!AccessorComparer.equals(orgValue, value)) {
+ super.tryCopy();
+ getInnerData().setValue(element.getLabelID(), value);
+ }
+ }
+
+ @Override
+ protected AccessorBase createNewObject() {
+ return new EngineValueObjAccessor(node, null);
+ }
+
+ @Override
+ public void copyCore(com.inspur.edp.cef.entity.accessor.base.AccessorBase accessor) {
+ EngineValueObjAccessor result = (EngineValueObjAccessor) accessor;
+ if (nestedValues != null) {
+ result.nestedValues = new HashMap<>(nestedValues.size());
+ nestedValues.entrySet().forEach(pair -> {
+ var nestedValue = (ValueObjAccessor) ((ICefData) pair.getValue()).copy();
+ nestedValue.setBelongBuffer(result);
+ result.nestedValues.put(pair.getKey(), nestedValue);
+ });
+ }
+ }
+
+ @Override
+ public ICefData innerCopySelf() {
+ ICefData result = (ICefData) super.copySelf();
+ if (nestedValues != null) {
+ nestedValues.entrySet().forEach(pair -> {
+ result.setValue(pair.getKey(), ((ICefData) pair.getValue()).copySelf());
+ });
+ }
+ return result;
+ }
+
+ private void initialize() {
+ initializeNested();
+ }
+
+ @Override
+ protected void onInnerDataChange() {
+ super.onInnerDataChange();
+ initializeNested();
+ }
+
+ protected void initializeNested() {
+ nestedValues = null;
+ if (getInnerData() == null) {
+ return;
+ }
+
+ nestedValues = new HashMap<>();
+ CefDataTypeUtil.streamElements(node, getElementPredicate()).filter(item -> item.getIsUdt())
+ .forEach(item -> {
+ String configId = CefDataTypeUtil.getUdtConfigId(item.getUdtID(), item.getUdtPkgName());
+ ValueObjAccessor udtValue = (ValueObjAccessor) UdtManagerUtils.getUdtFactory()
+ .createManager(configId)
+ .getAccessorCreator()
+ .createAccessor((ICefData) getInnerData().getValue(item.getLabelID()));
+ udtValue.setBelongBuffer(this);
+ udtValue.setPropName(item.getLabelID());
+ nestedValues.put(item.getLabelID(), udtValue);
+ });
+ }
+
+ //#region virtual
+ private Predicate getElementPredicate() {
+ return null;
+ }
+
+ private Predicate getNodePredicate() {
+ return null;
+ }
+ //#endregion
+}
diff --git a/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/data/EngineValueObjData.java b/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/data/EngineValueObjData.java
new file mode 100644
index 0000000000000000000000000000000000000000..c850cca7e8363e1e7b3f36983b25a305f7dcd444
--- /dev/null
+++ b/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/data/EngineValueObjData.java
@@ -0,0 +1,126 @@
+/*
+ *
+ * * Copyright © OpenAtom Foundation.
+ * *
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ *
+ */
+
+package com.inspur.edp.cef.engine.core.data;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.inspur.edp.cef.designtime.api.IGspCommonDataType;
+import com.inspur.edp.cef.designtime.api.IGspCommonField;
+import com.inspur.edp.cef.engine.core.common.CefDataTypeUtil;
+import com.inspur.edp.cef.entity.entity.ICefData;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Objects;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class EngineValueObjData extends
+ com.inspur.edp.cef.core.data.ValueObjDataBase implements Cloneable {
+
+ private final IGspCommonDataType node;
+ private HashMap values;
+
+ public EngineValueObjData(IGspCommonDataType node) {
+ Objects.requireNonNull(node, "node");
+ this.node = node;
+ }
+
+ @JsonIgnore
+ protected IGspCommonDataType getDataType(){
+ return node;
+ }
+
+ @Override
+ public Object innerGetValue(String labelId) {
+ IGspCommonField element = CefDataTypeUtil
+ .checkElementExists(node, labelId, getElementPredicate());
+ if (!element.getIsRefElement()) {
+ return getValues().get(labelId);
+ } else {
+ //TODO: udt上的关联暂不支持
+ throw new RuntimeException("暂不支持关联字段");
+// String parentLabelId = element.getParentAssociation().getBelongElement().getLabelID();
+// Object parentValue = getValues().get(parentLabelId);
+// if (parentValue == null) {
+// return null;
+// } else {
+// return ((AssociationInfo) parentValue).getValue(labelId);
+// }
+ }
+ }
+
+ private HashMap getValues() {
+ if (values == null) {
+ values = new HashMap<>(node.getContainElements().size());
+ }
+ return values;
+ }
+
+ @Override
+ public ICefData innerCopySelf() {
+ try {
+ EngineValueObjData result = (EngineValueObjData) this.clone();
+ //result.values = CefDataTypeUtil.cloneForValues(this.values);
+ return result;
+ } catch (CloneNotSupportedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public ICefData innerCopy() {
+ try {
+ EngineValueObjData result = (EngineValueObjData) this.clone();
+ return result;
+ } catch (CloneNotSupportedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private List propertyNames;
+ @Override
+ public List innerGetPropertyNames() {
+ if(propertyNames == null) {
+ Stream stream = node.getContainElements().stream();
+ if (getElementPredicate() != null) {
+ stream = stream.filter(getElementPredicate());
+ }
+ propertyNames = stream.map(item -> item.getLabelID()).collect(Collectors.toList());
+ }
+ return propertyNames;
+ }
+
+ @Override
+ public void innerSetValue(String s, Object o) {
+ CefDataTypeUtil.checkElementValue(node, s, o, getElementPredicate());
+ getValues().put(s, o);
+ }
+
+ //#region virtual
+ //TODO: 不需要支持运行时定制
+ private Predicate getElementPredicate() {
+ return null;
+ }
+
+ private Predicate getNodePredicate() {
+ return null;
+ }
+ //#endregion
+}
diff --git a/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/data/EngineValueObjReadonlyAccessor.java b/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/data/EngineValueObjReadonlyAccessor.java
new file mode 100644
index 0000000000000000000000000000000000000000..a9116692607015d4d6ca6f2232a2bb31145170eb
--- /dev/null
+++ b/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/data/EngineValueObjReadonlyAccessor.java
@@ -0,0 +1,153 @@
+/*
+ *
+ * * Copyright © OpenAtom Foundation.
+ * *
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ *
+ */
+
+package com.inspur.edp.cef.engine.core.data;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.inspur.edp.cef.designtime.api.IGspCommonDataType;
+import com.inspur.edp.cef.designtime.api.IGspCommonField;
+import com.inspur.edp.cef.engine.core.common.CefDataTypeUtil;
+import com.inspur.edp.cef.entity.accessor.base.AccessorBase;
+import com.inspur.edp.cef.entity.accessor.base.ReadonlyDataException;
+import com.inspur.edp.cef.entity.accessor.dataType.ValueObjAccessor;
+import com.inspur.edp.cef.entity.changeset.IChangeDetail;
+import com.inspur.edp.cef.entity.entity.ICefData;
+import com.inspur.edp.cef.entity.entity.IValueObjData;
+import com.inspur.edp.udt.api.UdtManagerUtils;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import lombok.var;
+
+public class EngineValueObjReadonlyAccessor extends
+ com.inspur.edp.cef.core.data.ValueObjAccessor {
+
+ private final IGspCommonDataType node;
+ private Map nestedValues;
+
+ public EngineValueObjReadonlyAccessor(IGspCommonDataType node, IValueObjData inner) {
+ super(inner);
+ this.node = node;
+ initialize();
+ }
+
+ @JsonIgnore
+ protected IGspCommonDataType getDataType(){
+ return node;
+ }
+
+ @Override
+ public boolean getIsReadonly() {
+ return true;
+ }
+
+ @Override
+ protected void acceptChangeCore(IChangeDetail iChangeDetail) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Object innerGetValue(String labelId) {
+ Objects.requireNonNull(labelId, "labelId");
+
+ var element = CefDataTypeUtil.checkElementExists(node, labelId, getElementPredicate());
+ if (element.getIsUdt()) {
+ return nestedValues.get(element.getLabelID());
+ } else {
+ return getInnerData().getValue(labelId);
+ }
+ }
+
+ @Override
+ public void innerSetValue(String s, Object o) {
+ throw new ReadonlyDataException();
+ }
+
+ @Override
+ protected AccessorBase createNewObject() {
+ return new EngineValueObjReadonlyAccessor(node, null);
+ }
+
+ @Override
+ public void copyCore(com.inspur.edp.cef.entity.accessor.base.AccessorBase accessor) {
+ EngineValueObjReadonlyAccessor result = (EngineValueObjReadonlyAccessor) accessor;
+ if (nestedValues != null) {
+ result.nestedValues = new HashMap<>(nestedValues.size());
+ nestedValues.entrySet().forEach(pair -> {
+ var nestedValue = (ValueObjAccessor) ((ICefData) pair.getValue()).copy();
+ nestedValue.setBelongBuffer(result);
+ result.nestedValues.put(pair.getKey(), nestedValue);
+ });
+ }
+ }
+
+ @Override
+ public ICefData innerCopySelf() {
+ ICefData result = (ICefData) super.copySelf();
+ if (nestedValues != null) {
+ nestedValues.entrySet().forEach(pair -> {
+ result.setValue(pair.getKey(), ((ICefData) pair.getValue()).copySelf());
+ });
+ }
+ return result;
+ }
+
+ @Override
+ protected void onInnerDataChange() {
+ super.onInnerDataChange();
+ initializeNested();
+ }
+
+ private void initialize() {
+ initializeNested();
+ }
+
+ private void initializeNested() {
+ if (getInnerData() == null) {
+ return;
+ }
+
+ nestedValues = new HashMap<>();
+ CefDataTypeUtil.streamElements(node, getElementPredicate()).filter(item -> item.getIsUdt())
+ .forEach(item -> {
+ String configId = CefDataTypeUtil.getUdtConfigId(item.getUdtID(), item.getUdtPkgName());
+ ValueObjAccessor udtValue = (ValueObjAccessor) UdtManagerUtils.getUdtFactory()
+ .createManager(configId)
+ .getAccessorCreator()
+ .createReadonlyAccessor((ICefData) getInnerData().getValue(item.getLabelID()));
+ udtValue.setBelongBuffer(this);
+ udtValue.setPropName(item.getLabelID());
+ nestedValues.put(item.getLabelID(), udtValue);
+ });
+ }
+
+ //#region virtual
+ private Predicate getElementPredicate() {
+ return null;
+ }
+
+ private Predicate getNodePredicate() {
+ return null;
+ }
+ //#endregion
+}
diff --git a/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/data/serializer/EngineSerializerItem.java b/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/data/serializer/EngineSerializerItem.java
new file mode 100644
index 0000000000000000000000000000000000000000..91f47760301a4e9fd6c3ec0e9545ec7023f383d2
--- /dev/null
+++ b/common-entity-engine-core/src/main/java/com/inspur/edp/cef/engine/core/data/serializer/EngineSerializerItem.java
@@ -0,0 +1,366 @@
+/*
+ *
+ * * Copyright © OpenAtom Foundation.
+ * *
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ *
+ */
+
+package com.inspur.edp.cef.engine.core.data.serializer;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.inspur.edp.cef.api.RefObject;
+import com.inspur.edp.cef.designtime.api.IGspCommonDataType;
+import com.inspur.edp.cef.designtime.api.IGspCommonField;
+import com.inspur.edp.cef.engine.core.common.CefDataTypeUtil;
+import com.inspur.edp.cef.entity.entity.IValueObjData;
+import com.inspur.edp.cef.spi.jsonser.valueobj.AbstractValueObjSerializer;
+import java.util.Date;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+import lombok.var;
+
+public class EngineSerializerItem extends AbstractValueObjSerializer {
+
+ private IGspCommonDataType node;
+
+ public EngineSerializerItem(IGspCommonDataType node) {
+ this();
+ this.node = node;
+ }
+
+ private EngineSerializerItem() {
+ }
+
+ protected IGspCommonDataType getDataType() {
+ return node;
+ }
+
+// private Object readAssociation(
+// GspAssociation asso, JsonParser reader, DeserializationContext serializer) {
+// if (reader.getCurrentToken() == JsonToken.VALUE_NULL) {
+// return null;
+// }
+// AssociationInfo info = createAssociationInfo(asso);
+// try {
+// reader.nextToken();
+// while (reader.getCurrentToken() == JsonToken.FIELD_NAME) {
+// String propertyName = reader.getValueAsString();
+// reader.nextToken();
+// if (asso.getBelongElement().getLabelID().equalsIgnoreCase(propertyName)) {
+// info.setValue(asso.getBelongElement().getLabelID(), readString(reader));
+// } else {
+// IGspCommonField element = CefDataTypeUtil.checkRefElementExists(asso, propertyName);
+// info.setValue(element.getLabelID(), readElementInfo(element, reader, serializer));
+// }
+// reader.nextToken();
+// }
+//// reader.nextToken();
+// return info;
+// } catch (IOException e) {
+// throw new RuntimeException(e);
+// }
+// }
+//
+// protected AssociationInfo createAssociationInfo(GspAssociation association) {
+// return new AssociationInfo(association);
+// }
+
+// private void writeAssociation(
+// GspAssociation asso,
+// String propName,
+// AssociationInfo assoValue,
+// JsonGenerator writer,
+// SerializerProvider serializer) {
+// try {
+// writer.writeFieldName(StringUtils.toCamelCase(propName));
+// if (assoValue == null) {
+// writer.writeNull();
+// } else {
+// writer.writeStartObject();
+// writeString(writer, assoValue.getValue(asso.getBelongElement().getLabelID()),
+// asso.getBelongElement().getLabelID(), serializer);
+// for (IGspCommonField refElement : asso.getRefElementCollection()) {
+// writeElementInfo(
+// refElement, assoValue.getValue(refElement.getLabelID()), writer, serializer);
+// }
+// writer.writeEndObject();
+// }
+// } catch (IOException e) {
+// throw new RuntimeException(e);
+// }
+// }
+
+ @Override
+ public void writeEntityBasicInfo(JsonGenerator writer, IValueObjData data,
+ SerializerProvider serializer) {
+ getElements().forEach(
+ element -> {
+ Object value = data.getValue(element.getLabelID());
+ if (value instanceof Date) {
+ this.writeDateTime(writer, value, element.getLabelID(), serializer);
+ } else {
+ this.writeAssociation(writer, value, element.getLabelID(), serializer);
+ }
+ });
+ }
+
+ private void writeElementInfo(
+ IGspCommonField element, Object value, JsonGenerator writer, SerializerProvider serializer) {
+ switch (element.getObjectType()) {
+ case None:
+ writeNormalElementInfo(element, value, writer, serializer);
+ break;
+// case Association:
+// writeAssociationElementInfo(element, value, writer, serializer);
+// break;
+ case Enum:
+ writeEnumElementInfo(element, value, writer, serializer);
+ break;
+ default:
+ throw new RuntimeException(
+ "不支持序列化此字段类型" + element.getLabelID() + "." + element.getObjectType());
+ }
+ }
+
+ private void writeEnumElementInfo(
+ IGspCommonField element, Object value, JsonGenerator writer, SerializerProvider serializer) {
+ writeString(writer, value, element.getLabelID(), serializer);
+ }
+
+// private void writeAssociationElementInfo(
+// IGspCommonField element, Object value, JsonGenerator writer, SerializerProvider serializer) {
+// // writeAssociation(writer, value, element.getLabelID(), serializer);
+// GspAssociation asso = element.getChildAssociations().get(0);
+// writeAssociation(asso, element.getLabelID(), (AssociationInfo) value, writer, serializer);
+// }
+
+ private void writeNormalElementInfo(
+ IGspCommonField element, Object value, JsonGenerator writer, SerializerProvider serializer) {
+ switch (element.getMDataType()) {
+ case String:
+ case Text:
+ writeString(writer, value, element.getLabelID(), serializer);
+ break;
+ case Integer:
+ writeInt(writer, value, element.getLabelID(), serializer);
+ break;
+ case Decimal:
+ writeDecimal(writer, value, element.getLabelID(), serializer);
+ break;
+ case Boolean:
+ writeBool(writer, value, element.getLabelID(), serializer);
+ break;
+ case Date:
+ case DateTime:
+ writeDateTime(writer, value, element.getLabelID(), serializer);
+ break;
+ case Binary:
+ writeBytes(writer, value, element.getLabelID(), serializer);
+ break;
+ default:
+ throw new RuntimeException(
+ "无法识别的MDataType" + element.getLabelID() + "." + element.getMDataType());
+ }
+ }
+
+ @Override
+ public boolean readEntityBasicInfo(JsonParser reader, DeserializationContext serializer,
+ IValueObjData data, String propertyName) {
+ IGspCommonField element = getElements()
+ .filter(item -> item.getLabelID().equalsIgnoreCase(propertyName))
+ .findFirst().orElse(null);
+ if (element == null) {
+ return false;
+ }
+ data.setValue(element.getLabelID(), readElementInfo(element, reader, serializer));
+ return true;
+ }
+
+ private Object readElementInfo(IGspCommonField element, JsonParser reader,
+ DeserializationContext serializer) {
+ if (element.getIsUdt()) {
+ return readUdtElementInfo(element, reader, serializer);
+ }
+
+ switch (element.getObjectType()) {
+ case None:
+ return readNormalElementInfo(element, reader, serializer);
+// case Association:
+// return readAssociationElementInfo(element, reader, serializer);
+ case Enum:
+ return readEnumElementInfo(element, reader, serializer);
+ default:
+ throw new RuntimeException(
+ "不支持序列化此字段类型" + element.getLabelID() + "." + element.getObjectType());
+ }
+ }
+
+ private Object readUdtElementInfo(IGspCommonField element, JsonParser reader,
+ DeserializationContext serializer) {
+ var udtConfigId = CefDataTypeUtil.getUdtConfigId(element.getUdtID(), element.getUdtPkgName());
+ return readNestedValue(udtConfigId, reader, serializer);
+ }
+
+ private Object readEnumElementInfo(
+ IGspCommonField element, JsonParser reader, DeserializationContext serializer) {
+ return readString(reader);
+ }
+
+// private Object readAssociationElementInfo(
+// IGspCommonField element, JsonParser reader, DeserializationContext serializer) {
+// return readAssociation(element.getChildAssociations().get(0), reader, serializer);
+// }
+
+ private Object readNormalElementInfo(
+ IGspCommonField element, JsonParser reader, DeserializationContext serializer) {
+ switch (element.getMDataType()) {
+ case String:
+ case Text:
+ return readString(reader);
+ case Integer:
+ return readInt(reader);
+ case Decimal:
+ return readDecimal(reader);
+ case Boolean:
+ return readBool(reader);
+ case Date:
+ case DateTime:
+ return readDateTime(reader);
+ case Binary:
+ return readBytes(reader);
+ default:
+ throw new RuntimeException(
+ "无法识别的MDataType" + element.getLabelID() + "." + element.getMDataType());
+ }
+ }
+
+ @Override
+ public boolean writeModifyPropertyJson(
+ JsonGenerator writer, String propertyName, Object value, SerializerProvider serializer) {
+ //变更集的序列化, 0227与大家讨论后一致决定, 在序列化基类中对于seritem不处理的属性执行默认序列化, 所以此处
+ //可以直接return false交由序列化基类处理.
+ return false;
+ }
+
+ @Override
+ public Object readModifyPropertyValue(
+ JsonParser reader,
+ DeserializationContext serializer,
+ RefObject propertyName,
+ RefObject hasRead) {
+ var element = getElements()
+ .filter(item -> item.getLabelID().equalsIgnoreCase(propertyName.argvalue)).findFirst();
+ if (!element.isPresent()) {
+ hasRead.argvalue = false;
+ return null;
+ }
+ hasRead.argvalue = true;
+ propertyName.argvalue = element.get().getLabelID();
+ return readModifyByElement(reader, serializer, element.get());
+ }
+
+ private Stream getElements() {
+ Stream rez = node.getContainElements().stream();
+ if (getElementPredicate() != null) {
+ rez = rez.filter(getElementPredicate());
+ }
+ return rez;
+ }
+
+ private Object readModifyByElement(JsonParser reader,
+ DeserializationContext serializer, IGspCommonField element) {
+ if (element.getIsUdt()) {
+ var udtConfigId = CefDataTypeUtil.getUdtConfigId(element.getUdtID(), element.getUdtPkgName());
+ return readNestedChange(udtConfigId, reader, serializer);
+ }
+ switch (element.getObjectType()) {
+ case None:
+ return readNormalElement(reader, element);
+// case Association:
+// return readAssociation(reader, element);
+ case Enum:
+ return readEnumElement(reader, element);
+ default:
+ throw new RuntimeException("暂不支持的字段类型:" + element.getLabelID());
+ }
+ }
+
+ private Object readEnumElement(JsonParser reader, IGspCommonField element) {
+ return readString(reader);
+ }
+
+ private Object readNormalElement(JsonParser reader, IGspCommonField element) {
+ switch (element.getMDataType()) {
+ case String:
+ case Text:
+ return readString(reader);
+ case Integer:
+ return readInt(reader);
+ case Decimal:
+ return readDecimal(reader);
+ case Boolean:
+ return readBool(reader);
+ case Date:
+ case DateTime:
+ return readDateTime(reader);
+ case Binary:
+ return readBytes(reader);
+ default:
+ throw new RuntimeException(
+ "无法识别的MDataType" + element.getLabelID() + "." + element.getMDataType());
+ }
+ }
+
+// private AssociationInfo readAssociation(JsonParser reader, IGspCommonField element) {
+// Objects.requireNonNull(element.getChildAssociations().get(0),
+// element.getLabelID() + ".getChildAssociations().get(0)");
+//
+// if (reader.getCurrentToken() == JsonToken.VALUE_NULL) {
+// return null;
+// }
+// if (reader.getCurrentToken() != JsonToken.START_OBJECT) {
+// throw new RuntimeException("Association must start with ObjectToken");
+// }
+// try {
+// reader.nextToken();
+// AssociationInfo rez = new AssociationInfo(element.getChildAssociations().get(0));
+//
+// while (reader.getCurrentToken() != JsonToken.END_OBJECT) {
+// String propertyName = reader.getValueAsString();
+// reader.nextToken();
+//
+// IGspCommonField refEle = element.getLabelID().equalsIgnoreCase(propertyName) ? element
+// : element.getChildAssociations().get(0)
+// .getRefElementCollection().stream()
+// .filter(item -> item.getLabelID().equalsIgnoreCase(propertyName)).findFirst()
+// .orElse(null);
+// if (refEle == null) {
+// throw new RuntimeException("带出字段不存在" + element.getLabelID() + "." + propertyName);
+// }
+// rez.setValue(refEle.getLabelID(), readNormalElement(reader, refEle));
+// reader.nextToken();
+// }
+// return rez;
+// } catch (IOException e) {
+// throw new RuntimeException(e);
+// }
+// }
+
+ protected Predicate getElementPredicate() {
+ return null;
+ }
+}