From e33c403eb5996275f6b95a7016955da79062bbcc Mon Sep 17 00:00:00 2001 From: sunhongfei01 Date: Wed, 7 Jan 2026 16:15:38 +0800 Subject: [PATCH 1/4] =?UTF-8?q?refactor(vom):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E6=A8=A1=E5=9E=8B=E6=89=A9=E5=B1=95=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=99=A8=E5=AE=9E=E7=8E=B0=E5=85=83=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新依赖 - 重构元数据合并逻辑,优化变更集处理和映射关系更新 - 指定VO抽取器扩展版本为1 - 重写VO扩展同步方法。不实现同层变更抽取;合并变更集SPI中检查扩展变更集版本若低于抽取器版本则重新抽取;合并时使用变更集与上层同步后元数据继续宁合并得到新扩展元数据。 --- pom.xml | 14 +- .../increment/ViewModelExtHandler.java | 226 ++++++++++-------- .../viewmodel/common/ViewModelMapping.java | 21 +- .../increment/extract/ViewModelExtractor.java | 39 ++- 4 files changed, 182 insertions(+), 118 deletions(-) diff --git a/pom.xml b/pom.xml index a21edf4..96f9fb5 100644 --- a/pom.xml +++ b/pom.xml @@ -63,9 +63,9 @@ 0.1.3 0.1.0 0.1.9 - 0.2.0 + 0.2.2-SNAPSHOT 0.2.0-rc.6 - 0.2.0 + 0.3.0-rc.4 0.2.0-rc.4 0.1.0 0.1.17 @@ -271,16 +271,6 @@ - - - gsp-snapshots-repo - https://repos.iec.io/repository/maven-gsp-snapshots/ - - - gsp-releases-repo - https://repos.iec.io/repository/maven-gsp-releases/ - - gsp-releases-repo diff --git a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/increment/ViewModelExtHandler.java b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/increment/ViewModelExtHandler.java index bcf7435..0031fd7 100644 --- a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/increment/ViewModelExtHandler.java +++ b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/increment/ViewModelExtHandler.java @@ -1,14 +1,26 @@ +/* + * 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.formserver.vmmanager.increment; -import com.inspur.edp.cef.designtime.api.element.increment.GspCommonFieldIncrement; -import com.inspur.edp.cef.designtime.api.element.increment.ModifyFieldIncrement; -import com.inspur.edp.cef.designtime.api.entity.increment.CommonEntityIncrement; -import com.inspur.edp.cef.designtime.api.entity.increment.ModifyEntityIncrement; -import com.inspur.edp.cef.designtime.api.increment.IncrementType; -import com.inspur.edp.cef.designtime.api.increment.property.PropertyIncrement; -import com.inspur.edp.das.commonmodel.entity.GspCommonModel; +import com.inspur.edp.das.commonmodel.IGspCommonObject; import com.inspur.edp.das.commonmodel.entity.increment.CommonModelIncrement; import com.inspur.edp.formserver.viewmodel.GspViewModel; +import com.inspur.edp.formserver.viewmodel.GspViewObject; +import com.inspur.edp.formserver.viewmodel.common.ViewModelMapping; import com.inspur.edp.formserver.viewmodel.controlrule.rule.VoControlRule; import com.inspur.edp.formserver.viewmodel.controlrule.rule.convert.VoControlRuleConvertor; import com.inspur.edp.formserver.viewmodel.controlrule.ruledefine.VoControlRuleDef; @@ -19,21 +31,39 @@ import com.inspur.edp.formserver.viewmodel.increment.merger.ViewModelMerger; import com.inspur.edp.formserver.vmmanager.exception.VoManagerErrorCodes; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; import com.inspur.edp.metadata.rtcustomization.api.AbstractCustomizedContent; +import com.inspur.edp.metadata.rtcustomization.api.CustomizationService; +import com.inspur.edp.metadata.rtcustomization.api.entity.MetadataQueryParam; +import com.inspur.edp.metadata.rtcustomization.api.entity.MetadataScopeEnum; import com.inspur.edp.metadata.rtcustomization.spi.CustomizationExtHandler; import com.inspur.edp.metadata.rtcustomization.spi.args.ChangeMergeArgs; import com.inspur.edp.metadata.rtcustomization.spi.args.Compare4SameLevelArgs; import com.inspur.edp.metadata.rtcustomization.spi.args.ExtContentArgs; import com.inspur.edp.metadata.rtcustomization.spi.args.MetadataMergeArgs; +import io.iec.edp.caf.commons.utils.SpringBeanUtils; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; -import java.util.HashMap; -import java.util.Map; - +@Slf4j public class ViewModelExtHandler implements CustomizationExtHandler { - public static final String ContainEnumValues = "ContainEnumValues"; + + private static CustomizationService customizationService = null; + private static CustomizationService getCustomizationService() { + if (customizationService == null) { + customizationService = SpringBeanUtils.getBean(CustomizationService.class); + } + return customizationService; + } @Override public AbstractCustomizedContent getExtContent(ExtContentArgs args) { GspMetadata oldMetadata = args.getBasicMetadata(); + + // 重新获取数据库中元数据,为了获取更新前且linkBe后的VO + MetadataQueryParam param = new MetadataQueryParam(); + param.setMetadataId(oldMetadata.getHeader().getId()); + param.setMetadataScopeEnum(MetadataScopeEnum.CUSTOMIZING); + oldMetadata = getCustomizationService().getGspMetadata(param); + GspMetadata newMetadata = args.getExtMetadata(); if (oldMetadata == null) throw new ViewModelException(VoManagerErrorCodes.GSP_VIEWOBJECT_MANAGER_0029, null); @@ -52,113 +82,119 @@ public class ViewModelExtHandler implements CustomizationExtHandler { @Override public GspMetadata merge(MetadataMergeArgs args) { - - GspMetadata extendMetadata = args.getExtendMetadata(); - AbstractCustomizedContent baseIncrement = args.getCustomizedContent(); - GspMetadata metadata = (GspMetadata) extendMetadata.clone(); - if (metadata == null) - throw new ViewModelException(VoManagerErrorCodes.GSP_VIEWOBJECT_MANAGER_0031, null); + // 获取上层扩展(或基础)更新后的元数据 + GspMetadata mergedMetadata = args.getMergedMetadata(); + // 克隆后对其合并变更集作为同步后元数据内容 + GspViewModel clone = ((GspViewModel) mergedMetadata.getContent()).clone(); + // 构造合并工具类 ViewModelMerger merger = new ViewModelMerger(true); -// GspViewModel extendVo = (GspViewModel)metadata.getContent(); - GspViewModel extendVo = ((GspViewModel) extendMetadata.getContent()).clone(); + // 构造合并规则类 VoControlRuleDef def = new VoControlRuleDef(); VoControlRule rule = new VoControlRule(); GspMetadata baseVoMetadata = args.getRootMetadata(); - VoControlRuleConvertor.convert2ControlRule(def, rule, (GspViewModel) baseVoMetadata.getContent()); - ViewModelIncrement extendIncrement = null; -// ViewModelIncrement extendIncrement = (ViewModelIncrement)service.getChangeset(metadata.getHeader().getId() ,null, null); - GspViewModel mergedVo = (GspViewModel) merger.merge(extendVo, (GspCommonModel) args.getRootMetadata().getContent(), extendIncrement == null ? new ViewModelIncrement() : extendIncrement, (ViewModelIncrement) baseIncrement, rule, def); - metadata.setContent(mergedVo); - - return metadata; - } - - @Override - public AbstractCustomizedContent getExtContent4SameLevel(Compare4SameLevelArgs args) { - GspMetadata oldMetadata = args.getOldMetadata(); - GspMetadata newMetadata = args.getMetadata(); - if (oldMetadata == null) - throw new ViewModelException(VoManagerErrorCodes.GSP_VIEWOBJECT_MANAGER_0029, null); - if (newMetadata == null) - throw new ViewModelException(VoManagerErrorCodes.GSP_VIEWOBJECT_MANAGER_0030, null); + // 获取原定制元数据与原上层元数据的变更集。 + AbstractCustomizedContent changeToParent = args.getCustomizedContent(); + // 变更集与更新后的上层元数据合并得到同步后扩展元数据 + GspViewModel merge = (GspViewModel)merger.merge(clone, (GspViewModel)baseVoMetadata.getContent(), + new ViewModelIncrement(), (ViewModelIncrement)changeToParent, + rule, def); - ViewModelExtractor extractor = new ViewModelExtractor(!oldMetadata.isExtended()); - GspViewModel oldVo = (GspViewModel) oldMetadata.getContent(); - GspViewModel newVo = (GspViewModel) newMetadata.getContent(); + // 待同步扩展元数据 + GspMetadata extendMetadata = args.getExtendMetadata(); + // 克隆元数据,作为同步后的元数据 + GspMetadata metadata = (GspMetadata) extendMetadata.clone(); + // 异常场景,不应出现 + if (metadata == null) { + throw new ViewModelException(VoManagerErrorCodes.GSP_VIEWOBJECT_MANAGER_0031, null); + } - VoControlRuleDef def = new VoControlRuleDef(); - VoControlRule rule = new VoControlRule(); - VoControlRuleConvertor.convert2ControlRule(def, rule, oldVo); + GspViewModel extendVo = (GspViewModel) extendMetadata.getContent(); - return extractor.extract(oldVo, newVo, rule, def); + // 将同步后的元数据 基本属性同步为扩展元数据属性。 + merge.setID(extendVo.getID()); + merge.setName(extendVo.getName()); + merge.setCode(extendVo.getCode()); + // 更新映射关系,修改对应BEID + refreshMapping(merge, extendVo.getMapping().clone()); + metadata.setContent(merge); + return metadata; } - //region changeMerge - @Override - public AbstractCustomizedContent changeMerge(ChangeMergeArgs changeMergeArgs) { - CommonModelIncrement parentChange = (CommonModelIncrement) changeMergeArgs.getParentChage(); - CommonModelIncrement extendChange = (CommonModelIncrement) changeMergeArgs.getChangeToParent(); - - if (extendChange == null) - return parentChange; - mergeChangeProperties(parentChange.getChangeProperties(), extendChange.getChangeProperties()); - - if (extendChange.getMainEntityIncrement() != null && parentChange.getMainEntityIncrement() != null) - mergeObjectIncrement(parentChange.getMainEntityIncrement(), extendChange.getMainEntityIncrement()); - - return parentChange; + /** + * 刷新视图模型映射BE + * @param viewModel 待刷新数据的视图模型 + * @param extendMapping 刷新目标映射 + */ + private void refreshMapping(GspViewModel viewModel, ViewModelMapping extendMapping) { + // 虚拟对象无映射be + if (viewModel.getIsVirtual() || extendMapping == null) { + return; + } + // 获取当前视图模型对应的BEId,仅将映射此BE的节点刷新为目标映射 BE + String basicBeId = viewModel.getMapping().getTargetMetadataId(); + // 刷新当前模型映射 + viewModel.getMapping().setTargetMetadataId(extendMapping.getTargetMetadataId()); + viewModel.getMapping().setTargetMetadataPkgName(extendMapping.getTargetMetadataPkgName()); + // 刷新对象映射 + refreshMapping(viewModel.getMainObject(), basicBeId, extendMapping); } - - private void mergeObjectIncrement(ModifyEntityIncrement parentIncrement, ModifyEntityIncrement extendIncrement) { - - mergeChangeProperties(parentIncrement.getChangeProperties(), extendIncrement.getChangeProperties()); - - for (Map.Entry childPair : parentIncrement.getChildEntitis().entrySet()) { - if (childPair.getValue().getIncrementType() != IncrementType.Modify) - continue; - if (extendIncrement.getChildEntitis().containsKey(childPair.getKey())) { - CommonEntityIncrement entityIncrement = extendIncrement.getChildEntitis().get(childPair.getKey()); - if (entityIncrement.getIncrementType() != IncrementType.Modify) - continue; - mergeObjectIncrement((ModifyEntityIncrement) childPair.getValue(), (ModifyEntityIncrement) entityIncrement); - } + /** + * 递归刷新所有视图对象的映射 + * @param viewObject 待刷新视图对象 + * @param basicBeId 当视图对象映射的BEId为当前指定的BEId时,刷新为目标映射 + * @param extendMapping 刷新目标映射 + */ + private void refreshMapping(GspViewObject viewObject, String basicBeId, ViewModelMapping extendMapping) { + // 虚拟对象无映射be + if (viewObject == null || viewObject.getIsVirtual()) { + return; } - - for (Map.Entry elePair : parentIncrement.getFields().entrySet()) { - GspCommonFieldIncrement fieldIncrement = elePair.getValue(); - if (fieldIncrement.getIncrementType() != IncrementType.Modify) - continue; - HashMap extendFields = extendIncrement.getFields(); - if (extendFields.containsKey(elePair.getKey())) { - GspCommonFieldIncrement gspCommonFieldIncrement = extendFields.get(elePair.getKey()); - if (gspCommonFieldIncrement.getIncrementType() != IncrementType.Modify) - continue; - mergeElementIncrement((ModifyFieldIncrement) fieldIncrement, (ModifyFieldIncrement) gspCommonFieldIncrement); + // 当前对象映射为指定BEId时,刷新目标映射 + if (viewObject.getMapping() != null && StringUtils.equals(viewObject.getMapping().getTargetMetadataId(), basicBeId)) { + // 刷新对象映射 + viewObject.getMapping().setTargetMetadataId(extendMapping.getTargetMetadataId()); + // 递归刷新子节点 + for (IGspCommonObject containChildObject : viewObject.getContainChildObjects()) { + refreshMapping((GspViewObject) containChildObject, basicBeId, extendMapping); } } - } - private void mergeElementIncrement(ModifyFieldIncrement parentIncrement, ModifyFieldIncrement extendIncrement) { - mergeChangeProperties(parentIncrement.getChangeProperties(), extendIncrement.getChangeProperties()); + @Override + public AbstractCustomizedContent getExtContent4SameLevel(Compare4SameLevelArgs args) { + // 无用,若为null会跳过后续同步 + return new ViewModelIncrement(); } - private void mergeChangeProperties(HashMap parentChanges, HashMap extendChanges) { - for (Map.Entry changePair : extendChanges.entrySet()) { - if (parentChanges.containsKey(changePair.getKey())) { - // TODO: 2023/8/21 由于枚举之前抽取增量,增量合并时,会将新的增量和已经存在的增量合并,会将新的变更移除,此处暂不处理枚举的增量 - if (ContainEnumValues.equals(changePair.getKey())) - continue; - parentChanges.remove(changePair.getKey()); - } + @Override + public AbstractCustomizedContent changeMerge(ChangeMergeArgs changeMergeArgs) { + CommonModelIncrement changeToParent = (CommonModelIncrement) changeMergeArgs.getChangeToParent(); + ViewModelExtractor extractor = new ViewModelExtractor(); + // 获取更新前的本次维度元数据 + GspMetadata currentMetadata = changeMergeArgs.getCurrentMetadata(); + + int res = changeToParent == null? 3 : extractor.compareTo(changeToParent.getVersion()); + + if (res == 0) { + return changeToParent; + } else if (res < 0) { + log.warn("同步元数据[{}]时记录的变更集版本[{}]高于当前应用,升级应用补丁", currentMetadata.getHeader().getId(), changeToParent.getVersion()); + return changeToParent; + } else { + log.error("同步元数据[{}]时记录的变更集版本[{}]低于当前应用,升级应用补丁", + currentMetadata.getHeader().getId(), + changeToParent == null? null : changeToParent.getVersion()); + // 获取更新后的上层元数据 + GspMetadata parentMetadata = changeMergeArgs.getParentMetadata(); + + return getExtContent(new ExtContentArgs(parentMetadata, currentMetadata, null)); + } } - //endregion - } diff --git a/view-object-model/src/main/java/com/inspur/edp/formserver/viewmodel/common/ViewModelMapping.java b/view-object-model/src/main/java/com/inspur/edp/formserver/viewmodel/common/ViewModelMapping.java index 75a388b..2b9935a 100644 --- a/view-object-model/src/main/java/com/inspur/edp/formserver/viewmodel/common/ViewModelMapping.java +++ b/view-object-model/src/main/java/com/inspur/edp/formserver/viewmodel/common/ViewModelMapping.java @@ -1,3 +1,19 @@ +/* + * 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.formserver.viewmodel.common; import java.io.Serializable; @@ -106,10 +122,9 @@ public class ViewModelMapping implements Cloneable, Serializable { * * 2 */ - public Object clone() { + public ViewModelMapping clone() { try { - ViewModelMapping mapping = (ViewModelMapping) super.clone(); - return mapping; + return (ViewModelMapping) super.clone(); } catch (CloneNotSupportedException e) { return null; } diff --git a/view-object-model/src/main/java/com/inspur/edp/formserver/viewmodel/increment/extract/ViewModelExtractor.java b/view-object-model/src/main/java/com/inspur/edp/formserver/viewmodel/increment/extract/ViewModelExtractor.java index a2b5582..baf6bfa 100644 --- a/view-object-model/src/main/java/com/inspur/edp/formserver/viewmodel/increment/extract/ViewModelExtractor.java +++ b/view-object-model/src/main/java/com/inspur/edp/formserver/viewmodel/increment/extract/ViewModelExtractor.java @@ -1,3 +1,19 @@ +/* + * 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.formserver.viewmodel.increment.extract; import com.inspur.edp.das.commonmodel.controlrule.CmControlRule; @@ -15,6 +31,12 @@ import lombok.var; public class ViewModelExtractor extends CommonModelExtractor { + /** + * 当前抽取器版本,抽取结果集中记录其对应的抽取器版本 + * 当抽取器逻辑变动较大,无法向下兼容时需增加版本号。 + */ + private static final short currentVersion = 1; + public ViewModelExtractor() { super(); } @@ -23,6 +45,15 @@ public class ViewModelExtractor extends CommonModelExtractor { super(includeAll); } + /** + * 重写抽取器版本获取方法 + * @return 抽取器扩展版本 + */ + @Override + protected short getExtendVersion () { + return currentVersion; + } + @Override protected void extractExtendInfo(CommonModelIncrement increment, GspCommonModel oldModel, GspCommonModel newModel, CmControlRule rule, CmControlRuleDef def) { extractViewModelInfo(increment, (GspViewModel) oldModel, (GspViewModel) newModel, rule, def); @@ -72,14 +103,6 @@ public class ViewModelExtractor extends CommonModelExtractor { increment.getValueHelpConfigs().put(newHelpConfig.getElementId(), helpConfigIncrement); } -// for (var oldChildObj : oldHelpConfigs) { -// if (updateObjs.contains(oldChildObj.getID())) -// continue; -// CmEntityControlRule childObjRule = (CmEntityControlRule)rule.getChildRules().get(CommonModelNames.ChildObject).get(oldChildObj.getID()); -// var childIncrement = extractor.extractorIncrement((GspCommonDataType) oldChildObj, null, childObjRule, def); -// increment.getChildEntitis().put(oldChildObj.getID(), childIncrement); -// } - } //region merge Action -- Gitee From a030fa271d582301013b4e508893ec15368bee07 Mon Sep 17 00:00:00 2001 From: sunhongfei01 Date: Thu, 15 Jan 2026 16:25:50 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix(view-model):=20=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 运行时定制保存时由元数据框架实现vo获取后事件linkBE,SPI中不再考量 - 重新构造变更集时,需要在数据库中重新获取同步前元数据 --- .../vmmanager/increment/ViewModelExtHandler.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/increment/ViewModelExtHandler.java b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/increment/ViewModelExtHandler.java index 0031fd7..7c089cc 100644 --- a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/increment/ViewModelExtHandler.java +++ b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/increment/ViewModelExtHandler.java @@ -57,13 +57,6 @@ public class ViewModelExtHandler implements CustomizationExtHandler { @Override public AbstractCustomizedContent getExtContent(ExtContentArgs args) { GspMetadata oldMetadata = args.getBasicMetadata(); - - // 重新获取数据库中元数据,为了获取更新前且linkBe后的VO - MetadataQueryParam param = new MetadataQueryParam(); - param.setMetadataId(oldMetadata.getHeader().getId()); - param.setMetadataScopeEnum(MetadataScopeEnum.CUSTOMIZING); - oldMetadata = getCustomizationService().getGspMetadata(param); - GspMetadata newMetadata = args.getExtMetadata(); if (oldMetadata == null) throw new ViewModelException(VoManagerErrorCodes.GSP_VIEWOBJECT_MANAGER_0029, null); @@ -192,7 +185,13 @@ public class ViewModelExtHandler implements CustomizationExtHandler { // 获取更新后的上层元数据 GspMetadata parentMetadata = changeMergeArgs.getParentMetadata(); - return getExtContent(new ExtContentArgs(parentMetadata, currentMetadata, null)); + // 重新获取数据库中元数据,为了获取更新前且linkBe后的VO + MetadataQueryParam param = new MetadataQueryParam(); + param.setMetadataId(parentMetadata.getHeader().getId()); + param.setMetadataScopeEnum(MetadataScopeEnum.CUSTOMIZING); + parentMetadata = getCustomizationService().getGspMetadata(param); + + return getExtContent(new ExtContentArgs(parentMetadata, currentMetadata, changeMergeArgs.getRootMetadata())); } } -- Gitee From 227fd0aee5241635b4f8a7e42b125fa03f0e3f1f Mon Sep 17 00:00:00 2001 From: sunhongfei01 Date: Fri, 6 Feb 2026 13:47:23 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat(vmmanager):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E6=A8=A1=E5=9E=8B=E6=89=A9=E5=B1=95=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增setExtMergerVersion方法存储扩展同步元数据的引擎版本 - 同步定制元数据后为其扩展属性赋值当前版本属性 --- .../increment/ViewModelExtHandler.java | 7 ++ .../vmmanager/util/VoExtendProperties.java | 103 ++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/util/VoExtendProperties.java diff --git a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/increment/ViewModelExtHandler.java b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/increment/ViewModelExtHandler.java index 7c089cc..98df41f 100644 --- a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/increment/ViewModelExtHandler.java +++ b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/increment/ViewModelExtHandler.java @@ -29,6 +29,7 @@ import com.inspur.edp.formserver.viewmodel.increment.ViewModelIncrement; import com.inspur.edp.formserver.viewmodel.increment.extract.ViewModelExtractor; import com.inspur.edp.formserver.viewmodel.increment.merger.ViewModelMerger; import com.inspur.edp.formserver.vmmanager.exception.VoManagerErrorCodes; +import com.inspur.edp.formserver.vmmanager.util.VoExtendProperties; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; import com.inspur.edp.metadata.rtcustomization.api.AbstractCustomizedContent; import com.inspur.edp.metadata.rtcustomization.api.CustomizationService; @@ -113,6 +114,12 @@ public class ViewModelExtHandler implements CustomizationExtHandler { merge.setCode(extendVo.getCode()); // 更新映射关系,修改对应BEID refreshMapping(merge, extendVo.getMapping().clone()); + + // 扩展同步元数据扩展属性中记录引擎版本 + VoExtendProperties voExtendProperties = VoExtendProperties.of(metadata); + voExtendProperties.setExtMergerVersion(new ViewModelExtractor().getVersion()); + metadata.setExtendProperty(voExtendProperties.toJson()); + metadata.setContent(merge); return metadata; } diff --git a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/util/VoExtendProperties.java b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/util/VoExtendProperties.java new file mode 100644 index 0000000..7aa5f11 --- /dev/null +++ b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/util/VoExtendProperties.java @@ -0,0 +1,103 @@ +/* + * 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.formserver.vmmanager.util; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * 视图模型元数据扩展属性 + *

+ * 记录在元数据表extendProperty中 + * + * @author sunhongfei01 + * @since 2026-02-06 + */ +@Getter +@Setter +@Slf4j +public class VoExtendProperties { + // 扩展同步版本。仅在当前元数据为扩展元数据时存在,标识当前扩展元数据创建和同步时引擎版本。 + private String extMergerVersion; + + /** + * 从元数据中读取扩展属性并转换格式 + * @param metadata 元数据 + * @return 视图模型扩展属性,若转换失败则返回空实体 + */ + @Nonnull + public static VoExtendProperties of(GspMetadata metadata) { + if (log.isDebugEnabled()) { + log.debug("从元数据中读取扩展属性并转换格式。"); + } + if (metadata == null || StringUtils.isEmpty(metadata.getExtendProperty())) { + if (log.isDebugEnabled()) { + log.debug("元数据为空。"); + } + return new VoExtendProperties(); + } + + if (log.isDebugEnabled()) { + log.debug("从元数据中读取扩展属性并转换格式,元数据ID[{}]。", + metadata.getHeader() == null? "null" : metadata.getHeader().getId()); + } + return VoExtendProperties.of(metadata.getExtendProperty()); + } + + /** + * 视图模型扩展属性反序列化 + * @param metadataExtendProperty 扩展属性字符串 + * @return 视图模型扩展属性, 若反序列化失败则返回空实体 + */ + @Nonnull + public static VoExtendProperties of(String metadataExtendProperty) { + if (log.isDebugEnabled()) { + log.debug("业务实体扩展属性反序列化[{}]。", metadataExtendProperty); + } + if (StringUtils.isNotEmpty(metadataExtendProperty)) { + try { + return new ObjectMapper().readValue(metadataExtendProperty, VoExtendProperties.class); + } catch (JsonProcessingException e) { + log.error("VoExtendProperties 反序列化失败。[{}]", metadataExtendProperty, e); + } + } + + return new VoExtendProperties(); + } + + /** + * 业务实体扩展属性序列化 + * @return 扩展属性字符串,若序列化失败则返回null + */ + @Nullable + public String toJson() { + try { + return new ObjectMapper().writeValueAsString(this); + } catch (JsonProcessingException e) { + log.error("VoExtendProperties 序列化失败。", e); + return null; + } + } +} -- Gitee From dc209d8fda5a34da69015fa8100c1903f305fb45 Mon Sep 17 00:00:00 2001 From: sunhongfei01 Date: Fri, 6 Feb 2026 13:48:18 +0800 Subject: [PATCH 4/4] =?UTF-8?q?chore(mvn):=20=E6=9B=B4=E6=96=B0=20Maven=20?= =?UTF-8?q?wrapper=20=E9=85=8D=E7=BD=AE=E4=BB=A5=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=8D=8E=E4=B8=BA=E4=BA=91=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 distributionUrl 更改为华为云镜像地址 - 将 wrapperUrl 更改为华为云镜像地址 --- .mvn/wrapper/maven-wrapper.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 1228567..e86438f 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # limitations under the License. # -distributionUrl=https://repos.iec.io/repository/maven-public/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip -wrapperUrl=https://repos.iec.io/repository/maven-public/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +distributionUrl=https://repo.huaweicloud.com/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.zip +wrapperUrl=https://repo.huaweicloud.com/repository/maven/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar \ No newline at end of file -- Gitee