diff --git a/pom.xml b/pom.xml
index d9f87fe994c6d7bcc9a45b526b2e325fbbcc539c..0cfcc4bd304070c8e41da9f73845ab98dc198302 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,6 +60,7 @@
form-process
web-formmetadata-relycheck
+ web-metadata-replication-core
diff --git a/web-metadata-replication-core/pom.xml b/web-metadata-replication-core/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..971192533aa05c5209d32782c11c4e9ec8dfd7a2
--- /dev/null
+++ b/web-metadata-replication-core/pom.xml
@@ -0,0 +1,166 @@
+
+
+ 4.0.0
+
+ com.inspur.edp
+ web
+ 1.0.2-SNAPSHOT
+
+
+ web-metadata-replication-core
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+ io.iec.edp
+ caf-application-context-api
+
+
+ com.inspur.edp
+ metadata-service-dev-api
+
+
+
+ com.inspur.edp
+ metadata-service-api
+ ${version.metadata}
+
+
+ com.inspur.edp
+ metadata-service-spi
+
+
+ io.iec.edp
+ caf-i18n-framework-api
+
+
+ io.iec.edp
+ caf-i18n-api
+
+
+ com.inspur.edp
+ i18n-resource-api
+
+
+ com.inspur.edp
+ lcm-metadata-api
+
+
+
+
+ com.inspur.edp
+ metadata-common
+
+
+ com.inspur.edp
+ lcm-metadata-api
+
+
+
+
+ com.inspur.edp
+ web-jitengine-common
+
+
+ com.inspur.edp
+ cdp-sgf-api
+
+
+ com.inspur.edp
+ web-jitengine-formmetadata
+
+
+ com.inspur.edp
+ web-pageflow-metadata
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+
+
+
+ io.iec.edp
+ caf-framework-licservice-api
+
+
+ com.inspur.edp
+ web-tsfile-api
+
+
+ com.inspur.edp
+ lcm-metadata-api
+
+
+
+
+ io.iec.edp
+ caf-boot-starter-context
+ compile
+
+
+
+
+
+
+
+ io.iec.edp
+ caf-boot-core-context
+ compile
+
+
+ com.inspur.edp
+ view-object-api
+ 0.1.3
+
+
+ com.inspur.edp
+ view-object-model
+
+
+ com.inspur.edp
+ view-object-manager
+
+
+ com.inspur.edp
+ wf-bizprocess-api
+ 0.3.2
+
+
+ com.inspur.edp
+ lcm-metadata-api
+
+
+
+
+ com.inspur.edp
+ runtime-customize-api
+
+
+ com.inspur.edp
+ lcm-metadata-api
+
+
+
+
+ com.inspur.edp
+ runtime-customize-form
+
+
+ com.inspur.edp
+ lcm-replication-api
+ 1.0.0-rc.3
+
+
+ com.inspur.edp
+ lcm-replication-spi
+ 1.0.0-rc.3
+
+
+
+
diff --git a/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/config/WebReplicationConfiguration.java b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/config/WebReplicationConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..4bfcd0efb301864e9fb2619cf8cfda131a2617b5
--- /dev/null
+++ b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/config/WebReplicationConfiguration.java
@@ -0,0 +1,44 @@
+package com.inspur.edp.web.appcopy.config;
+
+
+import com.inspur.edp.lcm.replication.spi.MetadataCopySpi;
+import com.inspur.edp.lcm.replication.spi.MetadataReferenceCollectSpi;
+import com.inspur.edp.web.appcopy.formmetadata.FormMetadataCopyImpl;
+import com.inspur.edp.web.appcopy.formmetadata.FormMetadataReferenceCollect;
+import com.inspur.edp.web.appcopy.formmetadata.MobileFormMetadataCopyImpl;
+import com.inspur.edp.web.appcopy.pageflowmetadata.MobilePageFlowCopyImpl;
+import com.inspur.edp.web.appcopy.pageflowmetadata.PageFlowCopyImpl;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration("com.inspur.edp.web.appcopy.config.WebReplicationConfiguration")
+public class WebReplicationConfiguration {
+
+
+ @Bean
+ public MetadataCopySpi getPageFlowMetadataCopySpi() {
+ return new PageFlowCopyImpl();
+ }
+
+ @Bean
+ public MetadataCopySpi getMobilePageFlowMetadataCopySpi() {
+ return new MobilePageFlowCopyImpl();
+ }
+
+
+ @Bean
+ public MetadataCopySpi getFormMetadataCopy() {
+ return new FormMetadataCopyImpl();
+ }
+
+ @Bean
+ public MetadataCopySpi getMobileFormMetadataCopy() {
+ return new MobileFormMetadataCopyImpl();
+ }
+
+ @Bean
+ public MetadataReferenceCollectSpi getFormMetadataReferenceCollect() {
+ return new FormMetadataReferenceCollect();
+ }
+}
+
diff --git a/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/formmetadata/FormCopyCommonUtility.java b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/formmetadata/FormCopyCommonUtility.java
new file mode 100644
index 0000000000000000000000000000000000000000..20dc824c6b78f1c360f1888ca005e1bacf0d5497
--- /dev/null
+++ b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/formmetadata/FormCopyCommonUtility.java
@@ -0,0 +1,988 @@
+package com.inspur.edp.web.appcopy.formmetadata;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.inspur.edp.formserver.viewmodel.GspViewModel;
+import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
+import com.inspur.edp.lcm.metadata.api.entity.MetadataDto;
+import com.inspur.edp.lcm.metadata.common.MetadataDtoConverter;
+import com.inspur.edp.lcm.replication.api.context.ReplicationServiceContext;
+import com.inspur.edp.lcm.replication.api.entity.ReplicationParam;
+import com.inspur.edp.sgf.api.entity.SgMetadata;
+import com.inspur.edp.web.common.customexception.WebCustomException;
+import com.inspur.edp.web.common.logger.WebLogger;
+import com.inspur.edp.web.common.utility.StringUtility;
+import com.inspur.edp.web.formmetadata.metadata.FormMetadataContent;
+import io.iec.edp.caf.common.JSONSerializer;
+
+import java.nio.file.Paths;
+import java.util.*;
+
+public class FormCopyCommonUtility {
+
+ public static void updateFormContent(ReplicationParam replicationParam, GspMetadata formMetadata,
+ ReplicationServiceContext replicationServiceContext) {
+ FormMetadataContent formMetadataContent = (FormMetadataContent) formMetadata.getContent();
+ updateProjectNameAndMetadataId(formMetadataContent, replicationParam, replicationServiceContext);
+ updateFormByEapi(formMetadataContent, replicationServiceContext);
+ updateFormByVo(formMetadataContent, replicationServiceContext, replicationParam);
+ updateFormByStateMachines(formMetadataContent, replicationServiceContext);
+ updateFormByExternalComponents(formMetadataContent, replicationServiceContext, replicationParam);
+ updateFormOptions(formMetadataContent, replicationServiceContext);
+ updateFormControllerCommandParam(formMetadataContent, replicationServiceContext);
+ updateComponentHelpId(formMetadataContent, replicationServiceContext, replicationParam);
+ updateCommunications(formMetadataContent, replicationServiceContext);
+ updateActionsNode(formMetadataContent, replicationServiceContext);
+ FormMetadataContent updateParamFormMdContent = updateDataIEOrWFCommand(formMetadataContent, replicationServiceContext);
+ FormMetadataContent formMdContent = updateFormByWebCommands(updateParamFormMdContent, replicationServiceContext, replicationParam);
+ updateQoInfo(formMdContent, replicationServiceContext, replicationParam, formMetadata);
+ formMetadata.setContent(formMdContent);
+ }
+
+ private static void updateCommunications(FormMetadataContent formMetadataContent, ReplicationServiceContext replicationServiceContext) {
+ JsonNode module = formMetadataContent.getModule();
+ if (module == null || module.isMissingNode() || module.isNull()) {
+ return;
+ }
+ JsonNode communications = module.get("communications");
+ if (isNullOrEmptyNode(communications)) {
+ return;
+ }
+ communications.forEach(communication -> {
+ if (!isNullOrEmptyNode(communication.at("/source/formId")) &&
+ !StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(communication.at("/source/formId").asText()))) {
+ ObjectNode source = (ObjectNode) communication.get("source");
+ source.put("formId", replicationServiceContext.findNewUUID(source.get("formId").asText()));
+ }
+ if (!isNullOrEmptyNode(communication.at("/target/formId")) &&
+ !StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(communication.at("/target/formId").asText()))) {
+ ObjectNode target = (ObjectNode) communication.get("target");
+ target.put("formId", replicationServiceContext.findNewUUID(target.get("formId").asText()));
+ }
+ });
+
+ }
+
+ private static void updateQoInfo(FormMetadataContent formMdContent, ReplicationServiceContext replicationServiceContext, ReplicationParam replicationParam, GspMetadata formMetadata) {
+ JsonNode module = formMdContent.getModule();
+ if (module == null || module.isMissingNode() || module.isNull()) {
+ return;
+ }
+ JsonNode qoInfo = module.get("qdpInfo");
+ if (isNullOrEmptyNode(qoInfo) || isNullOrEmptyNode(qoInfo.get("qoMetadata"))) {
+ return;
+ }
+ JsonNode qoMetadata = qoInfo.get("qoMetadata");
+ List newQoMetadataDtoList = new ArrayList<>();
+ qoMetadata.forEach(qo -> {
+ if (isNullOrEmptyNode(qo.get("id")) || StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(qo.get("id").asText()))) {
+ return;
+ }
+ GspMetadata newQoMetadata = replicationServiceContext.findCopiedGspMetadata(qo.get("id").asText());
+ if (newQoMetadata != null) {
+ MetadataDto dto = MetadataDtoConverter.asDto(newQoMetadata);
+ dto.setId(replicationServiceContext.findNewUUID(qo.get("id").asText()));
+ newQoMetadataDtoList.add(dto);
+ }
+ });
+ try {
+ if (!newQoMetadataDtoList.isEmpty()) {
+ List metadataJsonList = new ArrayList<>();
+ ObjectMapper mapper = new ObjectMapper();
+ for (MetadataDto metadataDto : newQoMetadataDtoList) {
+ String content = metadataDto.getContent();
+ JsonNode jsonNode = mapper.readTree(content);
+ JsonNode dtoJson = mapper.readTree(mapper.writeValueAsString(metadataDto));
+ ObjectNode dtoObjectJson = (ObjectNode) dtoJson;
+ dtoObjectJson.put("content", jsonNode);
+ metadataJsonList.add(dtoObjectJson);
+ }
+ String newDtoListStr = mapper.writeValueAsString(metadataJsonList);
+ ((ObjectNode) qoInfo).set("qoMetadata", mapper.readTree(newDtoListStr));
+ }
+
+ replaceAllQoInfo(replicationServiceContext, module, replicationParam, formMetadata, formMdContent);
+
+
+ } catch (Exception e) {
+ throw new WebCustomException(e);
+ }
+ }
+
+ private static void replaceAllQoInfo(ReplicationServiceContext context, JsonNode node, ReplicationParam replicationParam, GspMetadata formMetadata, FormMetadataContent formMdContent) {
+ if (isNullOrEmptyNode(node)) {
+ return;
+ }
+ try {
+ // 处理对象节点({...})
+ if (node.isObject()) {
+ ObjectNode objectNode = (ObjectNode) node; // 转为可变的 ObjectNode
+ updateQdpFrameWorkProperty(objectNode, context, replicationParam, formMetadata, formMdContent);
+ Iterator> fields = objectNode.fields();
+
+ while (fields.hasNext()) {
+ Map.Entry field = fields.next();
+
+ // 递归遍历子节点
+ replaceAllQoInfo(context, field.getValue(), replicationParam, formMetadata, formMdContent);
+ }
+ }
+ // 处理数组节点([...])
+ else if (node.isArray()) {
+ for (JsonNode item : node) {
+ replaceAllQoInfo(context, item, replicationParam, formMetadata, formMdContent);
+ }
+ }
+ // 基本类型节点,无需处理
+ } catch (Exception e) {
+ throw new WebCustomException(e);
+
+ }
+
+ }
+
+ private static void updateQdpFrameWorkProperty(ObjectNode objectNode, ReplicationServiceContext context, ReplicationParam replicationParam, GspMetadata formMetadata, FormMetadataContent formMdContent) {
+ if (isNullOrEmptyNode(objectNode) || isNullOrEmptyNode(objectNode.get("type")) || !"QdpFramework".equals(objectNode.get("type").asText())) {
+ return;
+ }
+ updateQdpInformation(objectNode, context, replicationParam, formMetadata, formMdContent);
+
+
+ if (isNullOrEmptyNode(objectNode.get("contents"))) {
+ updateQdpSchema(formMdContent, replicationParam, formMetadata);
+ return;
+ }
+ objectNode.get("contents").forEach(content -> updateQdpInformation((ObjectNode) content, context, replicationParam, formMetadata, formMdContent));
+ updateQdpSchema(formMdContent, replicationParam, formMetadata);
+ }
+
+ private static void updateQdpSchema(FormMetadataContent formMdContent, ReplicationParam replicationParam, GspMetadata formMetadata) {
+ JsonNode schema = formMdContent.getSchema();
+ if (isNullOrEmptyNode(schema)) {
+ return;
+ }
+ schema.forEach(node -> {
+ if (isNullOrEmptyNode(node.get("eapiId")) && !isNullOrEmptyNode(node.get("sourceUri"))) {
+ ((ObjectNode) node).put("sourceUri", assemblyRouter(replicationParam, node.get("sourceUri").asText(), formMetadata, 3));
+ }
+ });
+ }
+
+ private static void updateQdpInformation(ObjectNode objectNode, ReplicationServiceContext context, ReplicationParam replicationParam, GspMetadata formMetadata, FormMetadataContent formMdContent) {
+ if (!isNullOrEmptyNode(objectNode.get("qoManagerCode")) &&
+ !StringUtility.isNullOrEmpty(objectNode.get("qoManagerCode").asText()) &&
+ !StringUtility.isNullOrEmpty(context.findNewUUID(objectNode.get("qoManagerCode").asText()))) {
+ objectNode.put("qoManagerCode", context.findNewUUID(objectNode.get("qoManagerCode").asText()));
+ }
+ if (!isNullOrEmptyNode(objectNode.get("qoId")) &&
+ !StringUtility.isNullOrEmpty(objectNode.get("qoId").asText()) &&
+ !StringUtility.isNullOrEmpty(context.findNewUUID(objectNode.get("qoId").asText()))) {
+ objectNode.put("qoId", context.findNewUUID(objectNode.get("qoId").asText()));
+ }
+ if (!isNullOrEmptyNode(objectNode.get("queryRelativeUrl")) &&
+ !StringUtility.isNullOrEmpty(objectNode.get("queryRelativeUrl").asText())) {
+ String router = assemblyRouter(replicationParam, objectNode.get("queryRelativeUrl").asText(), formMetadata,4);
+ objectNode.put("queryRelativeUrl", "/" + router + "/service/");
+ }
+ if (!isNullOrEmptyNode(objectNode.get("voId")) &&
+ !StringUtility.isNullOrEmpty(objectNode.get("voId").asText())) {
+
+ JsonNode schema = formMdContent.getSchema();
+ if (isNullOrEmptyNode(schema) ||
+ isNullOrEmptyNode(schema.get(0)) ||
+ isNullOrEmptyNode(schema.get(0).get("id")) ||
+ !context.getOldUUID2NewUUIDMap().containsValue(schema.get(0).get("id").asText())) {
+ return;
+ }
+ String oldUUID = "";
+ for (Map.Entry stringStringEntry : context.getOldUUID2NewUUIDMap().entrySet()) {
+ if (Objects.equals(stringStringEntry.getValue(), schema.get(0).get("id").asText())) {
+ oldUUID = stringStringEntry.getKey();
+ break;// 找到匹配的value,返回对应的key
+ }
+ }
+ if (StringUtility.isNullOrEmpty(oldUUID)) {
+ return;
+ }
+ GspMetadata voMetadata = context.findCopiedGspMetadata(oldUUID);
+ GspViewModel voContent = (GspViewModel) voMetadata.getContent();
+ objectNode.put("voId", voContent.getGeneratingAssembly() + "." + voContent.getCode());
+ }
+ }
+
+ private static String assemblyRouter(ReplicationParam replicationParam, String oldRouter, GspMetadata formMetadata, int i) {
+ String targetSU = replicationParam.getTargetSU();
+ String oldSu = getProperty(oldRouter, i);
+
+ return targetSU.toLowerCase().equals(oldSu) ? "api/" + replicationParam.getTargetAppDomain().toLowerCase() + "/" +
+ replicationParam.getTargetSU().toLowerCase() + "/v1.0/" + replicationParam.getTargetBizObjCode().toLowerCase() + "-" + formMetadata.getHeader().getCode().toLowerCase() + "_frm" :
+ "api/" + replicationParam.getTargetAppDomain().toLowerCase() + "/" +
+ replicationParam.getTargetSU().toLowerCase() + "/v1.0/" + formMetadata.getHeader().getCode().toLowerCase() + "_frm";
+
+ }
+
+ private static FormMetadataContent updateDataIEOrWFCommand(FormMetadataContent formMetadataContent, ReplicationServiceContext replicationServiceContext) {
+ String contentsStr = JSONSerializer.serialize(formMetadataContent);
+ ArrayNode viewModels = (ArrayNode) formMetadataContent.getModule().at("/viewmodels");
+ for (int i = 0; i < viewModels.size(); i++) {
+ JsonNode vm = viewModels.get(i);
+ if (vm.get("commands") != null) {
+ ArrayNode commands = (ArrayNode) vm.get("commands");
+ if (!commands.isEmpty()) {
+ for (int j = 0; j < commands.size(); j++) {
+ JsonNode cmd = commands.get(j);
+ if (cmd.get("params") != null) {
+ ArrayNode submitAndSaveParams = (ArrayNode) cmd.get("params");
+ for (int k = 0; k < submitAndSaveParams.size(); k++) {
+ JsonNode item = submitAndSaveParams.get(k);
+ //流程分类
+ if (item.get("name") != null && "bizDefKey".equals(item.get("name").asText())) {
+ if (item.get("value") != null) {
+ String oldVal = item.get("value").asText();
+ String newVal = getNewConfigData("gspwfflowform", "id", oldVal, replicationServiceContext);
+ contentsStr = contentsStr.replace(oldVal, newVal);
+
+ }
+ }
+ //导入导出
+ if (item.get("name") != null && "ruleID".equals(item.get("name").asText())) {
+ if (item.get("value") != null) {
+ String oldVal = item.get("value").asText();
+ String newVal = getNewConfigData("gspdataierulemanage", "id", oldVal, replicationServiceContext);
+ contentsStr = contentsStr.replace(oldVal, newVal);
+ }
+ }
+
+ }
+ }
+ }
+ }
+ }
+ }
+ return JSONSerializer.deserialize(contentsStr, FormMetadataContent.class);
+
+ }
+
+ private static void updateComponentHelpId(FormMetadataContent formMetadataContent,
+ ReplicationServiceContext replicationServiceContext,
+ ReplicationParam replicationParam) {
+
+ if (isNullOrEmptyNode(formMetadataContent.getModule()) || isNullOrEmptyNode(formMetadataContent.getModule().get("components"))) {
+ return;
+ }
+ JsonNode components = formMetadataContent.getModule().get("components");
+ replaceHelpId(components, replicationServiceContext);
+ }
+
+ private static void updateActionsNode(FormMetadataContent formMetadataContent, ReplicationServiceContext replicationServiceContext) {
+ JsonNode module = formMetadataContent.getModule();
+ if (isNullOrEmptyNode(module) || isNullOrEmptyNode(module.get("actions"))) {
+ return;
+ }
+ ArrayNode actions = (ArrayNode) module.get("actions");
+ actions.forEach(action -> {
+ if (!isNullOrEmptyNode(action.get("sourceComponent"))) {
+ action.get("sourceComponent").forEach(comp -> {
+ if (!isNullOrEmptyNode(comp.get("map"))) {
+ comp.get("map").forEach(map -> {
+ if (!isNullOrEmptyNode(map.get("command"))) {
+ map.get("command").forEach(command -> {
+ recognizeUpdateControllerCommand(command, replicationServiceContext);
+ });
+ }
+ });
+ }
+ });
+ }
+ });
+ }
+
+ private static void updateFormOptions(FormMetadataContent formMetadataContent, ReplicationServiceContext replicationServiceContext) {
+ JsonNode contents = formMetadataContent.getContents();
+ if (isNullOrEmptyNode(contents) || isNullOrEmptyNode(contents.get("options"))) {
+ return;
+ }
+ JsonNode options = contents.get("options");
+ if (!isNullOrEmptyNode(options.get("mobileMetadataId")) &&
+ !StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(options.get("mobileMetadataId").asText()))) {
+ ObjectNode optionsNode = (ObjectNode) options;
+ optionsNode.put("mobileMetadataId", replicationServiceContext.findNewUUID(options.get("mobileMetadataId").asText()));
+ }
+ if (!isNullOrEmptyNode(options.get("pcMetadataId")) &&
+ !StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(options.get("pcMetadataId").asText()))) {
+ ObjectNode optionsNode = (ObjectNode) options;
+ optionsNode.put("pcMetadataId", replicationServiceContext.findNewUUID(options.get("pcMetadataId").asText()));
+ }
+ if (!isNullOrEmptyNode(options.at("/vueMetadata/id")) &&
+ !StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(options.at("/vueMetadata/id").asText()))) {
+ ObjectNode vueMetadata = (ObjectNode) options.get("vueMetadata");
+ vueMetadata.put("id", replicationServiceContext.findNewUUID(vueMetadata.get("id").asText()));
+ }
+ }
+
+ private static void updateFormByExternalComponents(FormMetadataContent formMetadataContent, ReplicationServiceContext replicationServiceContext, ReplicationParam replicationParam) {
+ JsonNode module = formMetadataContent.getModule();
+ if (module == null) {
+ return;
+ }
+ JsonNode externalComponents = module.at("/externalComponents");
+ if (isNullOrEmptyNode(externalComponents)) {
+ return;
+ }
+ ArrayNode externalComponentsArray = (ArrayNode) externalComponents;
+ externalComponentsArray.forEach(externalComponent -> {
+ updateFormByExternalComponent(externalComponent, replicationServiceContext, replicationParam);
+ });
+
+ }
+
+ private static void updateFormByExternalComponent(JsonNode externalComponent, ReplicationServiceContext replicationServiceContext, ReplicationParam replicationParam) {
+ if (isNullOrEmptyNode(externalComponent) || isNullOrEmptyNode(externalComponent.get("uri"))) {
+ return;
+ }
+ String formId = externalComponent.get("uri").asText();
+ ObjectNode extComponent = (ObjectNode) externalComponent;
+ extComponent.put("uri", StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(formId)) ?
+ formId : replicationServiceContext.findNewUUID(formId));
+ GspMetadata copiedGspMetadata = replicationServiceContext.findCopiedGspMetadata(formId);
+ if (copiedGspMetadata == null) {
+ return;
+ }
+ if (!isNullOrEmptyNode(extComponent.at("/nameSpace"))) {
+ extComponent.put("nameSpace", copiedGspMetadata.getHeader().getNameSpace());
+ }
+ if (!isNullOrEmptyNode(extComponent.at("/fileName"))) {
+ extComponent.put("fileName", copiedGspMetadata.getHeader().getFileName());
+ }
+ if (!isNullOrEmptyNode(extComponent.at("/filePath"))) {
+ extComponent.put("filePath", StringUtility.isNullOrEmpty(extComponent.get("filePath").asText()) ? null : buildNewRelativePath(replicationParam, replicationServiceContext, extComponent.get("filePath").asText()));
+ }
+ if (!isNullOrEmptyNode(extComponent.at("/projectName"))) {
+ extComponent.put("projectName", replicationServiceContext.getProjectNameMap() != null &&
+ !replicationServiceContext.getProjectNameMap().isEmpty() &&
+ !StringUtility.isNullOrEmpty(replicationServiceContext.getProjectNameMap().get(extComponent.at("/projectName").asText())) ?
+ replicationServiceContext.getProjectNameMap().get(extComponent.at("/projectName").asText()).toLowerCase() : "bo-" + replicationParam.getTargetBizObjCode().toLowerCase() + "-front");
+ }
+ if (!isNullOrEmptyNode(extComponent.at("/serviceUnitPath"))) {
+ extComponent.put("serviceUnitPath", replicationParam.getTargetAppDomain().toLowerCase() + "/" + replicationParam.getTargetSU().toLowerCase());
+ }
+ if (!isNullOrEmptyNode(extComponent.at("/name"))) {
+ extComponent.put("name", copiedGspMetadata.getHeader().getName());
+ }
+ if (!isNullOrEmptyNode(extComponent.at("/code"))) {
+ extComponent.put("code", copiedGspMetadata.getHeader().getCode());
+ }
+ }
+
+ private static FormMetadataContent updateFormByWebCommands(FormMetadataContent formMetadataContent, ReplicationServiceContext replicationServiceContext, ReplicationParam replicationParam) {
+ JsonNode module = formMetadataContent.getModule();
+ if (module == null) {
+ return formMetadataContent;
+ }
+ JsonNode webCommandsNode = module.at("/webcmds");
+ if (webCommandsNode == null || webCommandsNode.isNull() || webCommandsNode.isMissingNode()) {
+ return formMetadataContent;
+ }
+ ArrayNode webCommandsArray = (ArrayNode) webCommandsNode;
+ Map oldNewCmdIdMap = new HashMap<>();
+ for (JsonNode jsonCmdNode : webCommandsArray) {
+ if (isNullOrEmptyNode(jsonCmdNode)) {
+ continue;
+ }
+ String webCmdId = jsonCmdNode.at("/id").asText();
+ ObjectNode cmdNode = (ObjectNode) jsonCmdNode;
+
+ cmdNode.put("id", StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(webCmdId)) ? webCmdId : replicationServiceContext.findNewUUID(webCmdId));
+ if (replicationServiceContext.findCopiedGspMetadata(webCmdId) == null) {
+ continue;
+ }
+ GspMetadata copiedGspMetadata = replicationServiceContext.findCopiedGspMetadata(webCmdId);
+
+ if (!isNullOrEmptyNode(cmdNode.at("/nameSpace"))) {
+ cmdNode.put("nameSpace", copiedGspMetadata.getHeader().getNameSpace());
+ }
+ if (!isNullOrEmptyNode(cmdNode.at("/path"))) {
+ cmdNode.put("path", StringUtility.isNullOrEmpty(cmdNode.get("path").asText()) ? null : buildNewRelativePath(replicationParam, replicationServiceContext, cmdNode.get("path").asText()));
+ }
+ if (!isNullOrEmptyNode(cmdNode.at("/name"))) {
+ cmdNode.put("name", copiedGspMetadata.getHeader().getFileName());
+ }
+ if (!isNullOrEmptyNode(cmdNode.at("/code"))) {
+ cmdNode.put("code", copiedGspMetadata.getHeader().getCode());
+ }
+ oldNewCmdIdMap.put(webCmdId, replicationServiceContext.findNewUUID(webCmdId));
+ }
+ //全局替换
+ if (!oldNewCmdIdMap.isEmpty()) {
+ String contentStr = JSONSerializer.serialize(formMetadataContent);
+ for (Map.Entry entry : oldNewCmdIdMap.entrySet()) {
+ contentStr.replace(entry.getKey(), entry.getValue());
+ }
+ return JSONSerializer.deserialize(contentStr, FormMetadataContent.class);
+ }
+ return formMetadataContent;
+
+ }
+
+ private static void updateFormByStateMachines(FormMetadataContent formMetadataContent, ReplicationServiceContext replicationServiceContext) {
+ JsonNode module = formMetadataContent.getModule();
+ if (module == null) {
+ return;
+ }
+ JsonNode stateMachines = module.at("/stateMachines");
+ if (isNullOrEmptyNode(stateMachines)) {
+ return;
+ }
+ ArrayNode stateMachinesArray = (ArrayNode) stateMachines;
+ for (JsonNode stateMachine : stateMachinesArray) {
+ if (isNullOrEmptyNode(stateMachine.at("/uri"))) {
+ continue;
+ }
+ String smId = stateMachine.at("/uri").asText();
+ ObjectNode smObjectNode = (ObjectNode) stateMachine;
+ smObjectNode.put("uri", StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(smId)) ?
+ smId : replicationServiceContext.findNewUUID(smId));
+ GspMetadata copiedSmMetadata = replicationServiceContext.findCopiedGspMetadata(smId);
+ if (copiedSmMetadata == null) {
+ continue;
+ }
+ if (!isNullOrEmptyNode(smObjectNode.at("/nameSpace"))) {
+ smObjectNode.put("nameSpace", copiedSmMetadata.getHeader().getNameSpace());
+ }
+ if (!isNullOrEmptyNode(smObjectNode.at("/id"))) {
+ smObjectNode.put("id", copiedSmMetadata.getHeader().getCode());
+ }
+ if (!isNullOrEmptyNode(smObjectNode.at("/name"))) {
+ smObjectNode.put("name", copiedSmMetadata.getHeader().getName());
+ }
+ }
+ }
+
+ private static void updateProjectNameAndMetadataId(FormMetadataContent formMetadataContent,
+ ReplicationParam replicationParam,
+ ReplicationServiceContext replicationServiceContext) {
+ if (!StringUtility.isNullOrEmpty(formMetadataContent.getId()) &&
+ !StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(formMetadataContent.getId()))) {
+ formMetadataContent.setId(replicationServiceContext.findNewUUID(formMetadataContent.getId()));
+ }
+ JsonNode module = formMetadataContent.getModule();
+ if (module == null || module.isMissingNode() || module.isNull()) {
+ return;
+ }
+ String targetBizObjCode = replicationParam.getTargetBizObjCode();
+ if (StringUtility.isNullOrEmpty(targetBizObjCode)) {
+ return;
+ }
+ ObjectNode objectContent = (ObjectNode) module;
+ if (!isNullOrEmptyNode(objectContent.at("/projectName"))) {
+ String project = objectContent.at("/projectName").asText();
+
+ objectContent.put("projectName", replicationServiceContext.getProjectNameMap() != null &&
+ !replicationServiceContext.getProjectNameMap().isEmpty() &&
+ !StringUtility.isNullOrEmpty(replicationServiceContext.getProjectNameMap().get(project)) ?
+ replicationServiceContext.getProjectNameMap().get(project).toLowerCase() : "bo-" + replicationParam.getTargetBizObjCode().toLowerCase() + "-front");
+ }
+ if (!isNullOrEmptyNode(objectContent.at("/metadataId")) &&
+ !StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(objectContent.get("metadataId").asText()))) {
+ objectContent.put("metadataId", replicationServiceContext.findNewUUID(objectContent.get("metadataId").asText()));
+ }
+ }
+
+ private static void updateFormByVo(FormMetadataContent formMetadataContent, ReplicationServiceContext replicationServiceContext, ReplicationParam replicationParam) {
+ JsonNode schema = formMetadataContent.getSchema();
+ if (isNullOrEmptyNode(schema)) {
+ return;
+ }
+ ArrayNode schemaArray = (ArrayNode) schema;
+ schemaArray.forEach(schemaNode -> {
+ if (schemaNode != null && schemaNode.get("id") != null) {
+ ObjectNode objectSchemaNode = (ObjectNode) schemaNode;
+ GspMetadata voMetadata = replicationServiceContext.findCopiedGspMetadata(schemaNode.get("id").asText());
+ if (voMetadata != null) {
+ if (!isNullOrEmptyNode(objectSchemaNode.at("/voPath"))) {
+ objectSchemaNode.put("voPath", StringUtility.isNullOrEmpty(voMetadata.getRelativePath()) ? null : buildNewRelativePath(replicationParam, replicationServiceContext, voMetadata.getRelativePath()));
+ }
+ if (!isNullOrEmptyNode(objectSchemaNode.at("/voNameSpace"))) {
+ objectSchemaNode.put("voNameSpace", voMetadata.getHeader().getNameSpace());
+ }
+ if (!StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(schemaNode.get("id").asText()))) {
+ objectSchemaNode.put("id", replicationServiceContext.findNewUUID(schemaNode.get("id").asText()));
+ }
+ }
+ }
+
+ });
+
+ }
+
+ private static void updateFormControllerCommandParam(FormMetadataContent formMetadataContent, ReplicationServiceContext replicationServiceContext) {
+ ArrayNode viewModels = (ArrayNode) formMetadataContent.getModule().at("/viewmodels");
+ for (int i = 0; i < viewModels.size(); i++) {
+ JsonNode vm = viewModels.get(i);
+ if (vm.get("commands") != null) {
+ ArrayNode commands = (ArrayNode) vm.get("commands");
+ if (!commands.isEmpty()) {
+ for (int j = 0; j < commands.size(); j++) {
+ JsonNode cmd = commands.get(j);
+ recognizeUpdateControllerCommand(cmd, replicationServiceContext);
+ }
+ }
+ }
+ }
+ }
+
+
+ private static void recognizeUpdateControllerCommand(JsonNode cmd, ReplicationServiceContext replicationServiceContext) {
+ if (isListControllerCommand(cmd)) {
+ updateListAppCommand(cmd);
+ updateListFuncCommand(cmd);
+ updateListRtcCommand(cmd, replicationServiceContext);
+ }
+ if (isPrintCommand(cmd)) {
+ updatePrintCommand(cmd, replicationServiceContext);
+ }
+ if (isAdvancedListCardControllerCommand(cmd)) {
+ updateAdvancedListCardControllerCommand(cmd, replicationServiceContext);
+ }
+ if (isCardControllerCommand(cmd)) {
+ updateCardControllerCommand(cmd, replicationServiceContext);
+ }
+ if (isBatchEditCommand(cmd)) {
+ updateBatchEditCommand(cmd, replicationServiceContext);
+ }
+ if (isDoubleListControllerCommand(cmd)) {
+ updateDoubleListControllerCommand(cmd, replicationServiceContext);
+ }
+ if (isPopControllerCommand(cmd)) {
+ updatePopControllerCommand(cmd, replicationServiceContext);
+ }
+ if (isTreeListControllerCommand(cmd)) {
+ updateTreeListControllerCommand(cmd, replicationServiceContext);
+ }
+ }
+
+ private static void updateListAppCommand(JsonNode item) {
+ if (isNullOrEmptyNode(item.get("params"))) {
+ return;
+ }
+ ArrayNode params = (ArrayNode) item.get("params");
+ params.forEach(paramNode -> {
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "appId".equals(paramNode.get("name").asText())) {
+ ((ObjectNode) paramNode).put("value", "");
+ }
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "appEntrance".equals(paramNode.get("name").asText())) {
+ ((ObjectNode) paramNode).put("value", "");
+ }
+ });
+ }
+
+ private static void updateListRtcCommand(JsonNode item, ReplicationServiceContext context) {
+ if (isNullOrEmptyNode(item.get("params"))) {
+ return;
+ }
+ ArrayNode params = (ArrayNode) item.get("params");
+ params.forEach(paramNode -> {
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "funcId".equals(paramNode.get("name").asText())) {
+ ((ObjectNode) paramNode).put("value", "");
+ }
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "metadataId".equals(paramNode.get("name").asText())) {
+ if (!isNullOrEmptyNode(paramNode.get("value")) && !StringUtility.isNullOrEmpty(context.findNewUUID(paramNode.get("value").asText()))) {
+ ((ObjectNode) paramNode).put("value", context.findNewUUID(paramNode.get("value").asText()));
+ }
+ }
+ });
+ }
+
+ private static boolean isListControllerCommand(JsonNode item) {
+ return item.get("cmpId") != null && "70b4abd4-9f2c-4b7c-90e9-6ac6f4b74c72".equals(item.get("cmpId").asText());
+ }
+
+ private static boolean isCardControllerCommand(JsonNode item) {
+ return item.get("cmpId") != null && "8172a979-2c80-4637-ace7-b13074d3f393".equals(item.get("cmpId").asText());
+ }
+
+ private static void updateCardControllerCommand(JsonNode item, ReplicationServiceContext context) {
+ if (isNullOrEmptyNode(item.get("params"))) {
+ return;
+ }
+ ArrayNode params = (ArrayNode) item.get("params");
+ params.forEach(paramNode -> {
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "helpId".equals(paramNode.get("name").asText())) {
+ if (!isNullOrEmptyNode(paramNode.get("value")) && !StringUtility.isNullOrEmpty(context.findNewUUID(paramNode.get("value").asText()))) {
+ ((ObjectNode) paramNode).put("value", context.findNewUUID(paramNode.get("value").asText()));
+ }
+ }
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "funcOrAppId".equals(paramNode.get("name").asText())) {
+ ((ObjectNode) paramNode).put("value", "");
+ }
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "appEntrance".equals(paramNode.get("name").asText())) {
+ ((ObjectNode) paramNode).put("value", "");
+ }
+ });
+ }
+
+
+ private static boolean isAdvancedListCardControllerCommand(JsonNode item) {
+ return item.get("cmpId") != null && "45be24f9-c1f7-44f7-b447-fe2ada458a61".equals(item.get("cmpId").asText());
+ }
+
+ private static void updateAdvancedListCardControllerCommand(JsonNode item, ReplicationServiceContext context) {
+ if (isNullOrEmptyNode(item.get("params"))) {
+ return;
+ }
+ ArrayNode params = (ArrayNode) item.get("params");
+ params.forEach(paramNode -> {
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "helpId".equals(paramNode.get("name").asText())) {
+ if (!isNullOrEmptyNode(paramNode.get("value")) && !StringUtility.isNullOrEmpty(context.findNewUUID(paramNode.get("value").asText()))) {
+ ((ObjectNode) paramNode).put("value", context.findNewUUID(paramNode.get("value").asText()));
+ }
+ }
+ });
+ }
+
+ private static boolean isPrintCommand(JsonNode item) {
+ return item.get("cmpId") != null && "e353b4e9-e073-4e18-b9f7-ec4cc8ac72b1".equals(item.get("cmpId").asText());
+ }
+
+ private static void updatePrintCommand(JsonNode item, ReplicationServiceContext context) {
+ if (isNullOrEmptyNode(item.get("params"))) {
+ return;
+ }
+ ArrayNode params = (ArrayNode) item.get("params");
+ params.forEach(paramNode -> {
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "beMetaId".equals(paramNode.get("name").asText())) {
+ if (!isNullOrEmptyNode(paramNode.get("value")) && !StringUtility.isNullOrEmpty(context.findNewUUID(paramNode.get("value").asText()))) {
+ ((ObjectNode) paramNode).put("value", context.findNewUUID(paramNode.get("value").asText()));
+ }
+ }
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "billCategoryId".equals(paramNode.get("name").asText())) {
+ if (!isNullOrEmptyNode(paramNode.get("value")) &&
+ !StringUtility.isNullOrEmpty(getNewConfigData("bfbfconfigdefine", "id", paramNode.get("value").asText(), context))) {
+ ((ObjectNode) paramNode).put("value", getNewConfigData("bfbfconfigdefine", "id", paramNode.get("value").asText(), context));
+ }
+ }
+ });
+ }
+
+ private static void updateListFuncCommand(JsonNode item) {
+ if (isNullOrEmptyNode(item.get("params"))) {
+ return;
+ }
+ ArrayNode params = (ArrayNode) item.get("params");
+ params.forEach(paramNode -> {
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "url".equals(paramNode.get("name").asText())) {
+ ((ObjectNode) paramNode).put("value", "");
+ }
+ });
+ }
+
+ private static void updateFormByEapi(FormMetadataContent formMetadataContent, ReplicationServiceContext replicationServiceContext) {
+ JsonNode schema = formMetadataContent.getSchema();
+ if (isNullOrEmptyNode(schema)) {
+ return;
+ }
+ ArrayNode schemaArray = (ArrayNode) schema;
+ schemaArray.forEach(schemaNode -> {
+ if (schemaNode != null && schemaNode.get("eapiId") != null) {
+ String eapiId = schemaNode.get("eapiId").asText();
+ if (!StringUtility.isNullOrEmpty(eapiId)) {
+ GspMetadata newEapiMetadata = replicationServiceContext.findCopiedGspMetadata(eapiId);
+ if (newEapiMetadata != null) {
+ updateFormByEapi(schemaNode, newEapiMetadata, replicationServiceContext);
+ }
+ }
+ }
+ });
+ }
+
+
+ private static String getNewConfigData(String tableName, String columnName, String oldValue, ReplicationServiceContext replicationServiceContext) {
+ String result = "";
+ if (!StringUtility.isNullOrEmpty(tableName) && !StringUtility.isNullOrEmpty(columnName) && !StringUtility.isNullOrEmpty(oldValue)) {
+ String key = tableName + "_" + columnName + "_" + oldValue;
+ result = replicationServiceContext.findConfigDataNewValue(key);
+ if (StringUtility.isNullOrEmpty(result)) {
+ WebLogger.Instance.info("com.inspur.edp.web.formmetadata.formcopy.FormMetadataCopyImpl,key值为:" + key);
+ result = oldValue;
+ }
+ }
+ return result;
+ }
+
+ private static void updateFormByEapi(JsonNode schema, GspMetadata eapiMetadata, ReplicationServiceContext replicationServiceContext) {
+ SgMetadata eapiMdContent = (SgMetadata) eapiMetadata.getContent();
+ // 表单上回写eapi id和url
+ ObjectNode schemaNode = (ObjectNode) schema;
+ schemaNode.put("eapiId", StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(schemaNode.get("eapiId").asText())) ?
+ schemaNode.get("eapiId").asText() : replicationServiceContext.findNewUUID(schemaNode.get("eapiId").asText()));
+ String sourceUri = eapiMdContent.getRouter();
+ if (sourceUri.startsWith("/")) {
+ sourceUri = sourceUri.substring(1);
+ }
+ if (!isNullOrEmptyNode(schemaNode.at("/sourceUri"))) {
+ schemaNode.put("sourceUri", sourceUri);
+ }
+ if (!isNullOrEmptyNode(schemaNode.at("/eapiCode"))) {
+ schemaNode.put("eapiCode", eapiMdContent.getCode());
+ }
+ if (!isNullOrEmptyNode(schemaNode.at("/eapiName"))) {
+ schemaNode.put("eapiName", eapiMdContent.getName());
+ }
+ if (!isNullOrEmptyNode(schemaNode.at("/eapiNameSpace"))) {
+ schemaNode.put("eapiNameSpace", eapiMetadata.getHeader().getNameSpace());
+ }
+ }
+
+ //同LCM给的规则保持一致,
+ private static String buildNewRelativePath(ReplicationParam replicationParam, ReplicationServiceContext context, String oldRelativePath) {
+ if (StringUtility.isNullOrEmpty(oldRelativePath)) {
+ return null;
+ }
+ // 获取新值
+ String newAppDomain = replicationParam.getTargetAppDomain();
+ String newServiceUnit = replicationParam.getTargetSU();
+ String newBoCode = replicationParam.getTargetBizObjCode();
+ String projectName = getProjectName(oldRelativePath);
+ if (StringUtility.isNullOrEmpty(projectName)) {
+ return null;
+ }
+ String result = Paths.get(newAppDomain,
+ newServiceUnit,
+ newBoCode,
+ context.getProjectNameMap() != null &&
+ !context.getProjectNameMap().isEmpty() &&
+ !StringUtility.isNullOrEmpty(context.getProjectNameMap().get(projectName)) ?
+ context.getProjectNameMap().get(projectName).toLowerCase() : "bo-" + replicationParam.getTargetBizObjCode().toLowerCase() + "-front",
+ getSecondLastProperty(oldRelativePath),
+ getFinalProperty(oldRelativePath)
+ ).toString().replace("\\", "/");
+ return result;
+
+ }
+
+ public static String getProjectName(String oldRelativePath) {
+ // 1. 空值校验:避免NPE
+ if (StringUtility.isNullOrEmpty(oldRelativePath)) {
+ return null; // 或抛业务异常,根据实际需求调整
+ }
+
+ // 2. 分割路径 + 过滤空元素(处理连续/、首尾/的情况)
+ String[] pathSegments = oldRelativePath.split("/");
+ List validSegments = new ArrayList<>();
+ for (String segment : pathSegments) {
+ if (!StringUtility.isNullOrEmpty(segment)) { // 过滤空字符串/纯空格
+ validSegments.add(segment);
+ }
+ }
+
+ // 3. 数组长度校验:避免IndexOutOfBoundsException
+ if (validSegments.size() < 3) {
+ return null; // 路径层级不足,返回null/抛异常/返回默认值
+ }
+
+ // 4. 取倒数第三个元素
+ return validSegments.get(validSegments.size() - 3);
+ }
+
+ public static String getFinalProperty(String key) {
+ if (StringUtility.isNullOrEmpty(key)) {
+ return key;
+ }
+ String[] splitString = key.split("/");
+ if (splitString.length < 1) {
+ return key;
+ }
+ return splitString[splitString.length - 1];
+ }
+
+ public static String getSecondLastProperty(String key) {
+ if (StringUtility.isNullOrEmpty(key)) {
+ return key;
+ }
+ String[] splitString = key.split("/");
+ if (splitString.length < 2) {
+ return key;
+ }
+ return splitString[splitString.length - 2];
+
+ }
+
+ public static String getProperty(String key, int length) {
+ if (StringUtility.isNullOrEmpty(key)) {
+ return key;
+ }
+ String[] splitString = key.split("/");
+ if (splitString.length < length) {
+ return key;
+ }
+ return splitString[length - 1];
+
+ }
+
+
+ private static String buildNewRelativePath(ReplicationParam replicationParam, String oldRelativePath) {
+
+ // 获取新值
+ String newAppDomain = replicationParam.getTargetAppDomain();
+ String newServiceUnit = replicationParam.getTargetSU();
+ String newBoCode = replicationParam.getTargetBizObjCode();
+
+ String result = Paths.get(newAppDomain,
+ newServiceUnit,
+ newBoCode,
+ "bo-" + newBoCode.toLowerCase() + "-front",
+ "metadata",
+ "components"
+ ).toString().replace("\\", "/");
+
+
+ return result;
+
+
+ }
+
+ public static boolean isNullOrEmptyNode(JsonNode node) {
+ return node == null ||
+ node.isNull() ||
+ node.isArray() && node.isEmpty() ||
+ node.isObject() && node.isEmpty() ||
+ StringUtility.isNullOrEmpty(node.toString());
+ }
+
+ /**
+ * 提取JSON字符串中所有helpId的值
+ *
+ * @param rootNode 目标JSON字符串
+ * @return 所有helpId的值列表
+ */
+ public static void replaceHelpId(JsonNode rootNode, ReplicationServiceContext context) {
+ ;
+ // 递归遍历节点
+ traverseJsonNodeToUpdateHelpId(rootNode, context);
+ }
+
+ /**
+ * 递归遍历Jackson的JsonNode,替换helpId
+ *
+ * @param node 当前遍历的节点
+ * @param context 替换上下文
+ */
+ private static void traverseJsonNodeToUpdateHelpId(JsonNode node, ReplicationServiceContext context) {
+ if (isNullOrEmptyNode(node)) {
+ return;
+ }
+ try {
+ // 处理对象节点({...})
+ if (node.isObject()) {
+ ObjectNode objectNode = (ObjectNode) node; // 转为可变的 ObjectNode
+ Iterator> fields = objectNode.fields();
+
+ while (fields.hasNext()) {
+ Map.Entry field = fields.next();
+ String key = field.getKey();
+ JsonNode value = field.getValue();
+ // 匹配helpId键,收集值
+ if ("helpId".equals(key) &&
+ !StringUtility.isNullOrEmpty(value.asText()) &&
+ !StringUtility.isNullOrEmpty(context.findNewUUID(value.asText()))) {
+ objectNode.put(key, context.findNewUUID(value.asText()));
+ }
+ // 递归遍历子节点
+ traverseJsonNodeToUpdateHelpId(value, context);
+ }
+ }
+ // 处理数组节点([...])
+ else if (node.isArray()) {
+ for (JsonNode item : node) {
+ traverseJsonNodeToUpdateHelpId(item, context);
+ }
+ }
+ // 基本类型节点,无需处理
+ } catch (Exception e) {
+ throw new WebCustomException(e);
+
+ }
+ }
+
+
+ private static boolean isBatchEditCommand(JsonNode item) {
+ return item.get("cmpId") != null && "43f68561-eae4-4495-b318-d629615523f8".equals(item.get("cmpId").asText());
+ }
+
+ private static void updateBatchEditCommand(JsonNode item, ReplicationServiceContext context) {
+ if (isNullOrEmptyNode(item.get("params"))) {
+ return;
+ }
+ ArrayNode params = (ArrayNode) item.get("params");
+ params.forEach(paramNode -> {
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "helpId".equals(paramNode.get("name").asText())) {
+ if (!isNullOrEmptyNode(paramNode.get("value")) && !StringUtility.isNullOrEmpty(context.findNewUUID(paramNode.get("value").asText()))) {
+ ((ObjectNode) paramNode).put("value", context.findNewUUID(paramNode.get("value").asText()));
+ }
+ }
+ });
+ }
+
+ private static boolean isDoubleListControllerCommand(JsonNode item) {
+ return item.get("cmpId") != null && "26436aa8-88a7-4aee-bf0b-9843c1e8afbf".equals(item.get("cmpId").asText());
+ }
+
+ private static void updateDoubleListControllerCommand(JsonNode item, ReplicationServiceContext context) {
+ if (isNullOrEmptyNode(item.get("params"))) {
+ return;
+ }
+ ArrayNode params = (ArrayNode) item.get("params");
+ params.forEach(paramNode -> {
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "url".equals(paramNode.get("name").asText())) {
+ if (!isNullOrEmptyNode(paramNode.get("value")) && !StringUtility.isNullOrEmpty(paramNode.get("value").asText())) {
+ ((ObjectNode) paramNode).put("value", "");
+ }
+ }
+ });
+ }
+
+ private static boolean isPopControllerCommand(JsonNode item) {
+ return item.get("cmpId") != null && "8d21e69c-70b3-44f6-88b5-fd6a8d3ce11b".equals(item.get("cmpId").asText());
+ }
+
+ private static void updatePopControllerCommand(JsonNode item, ReplicationServiceContext context) {
+ if (isNullOrEmptyNode(item.get("params"))) {
+ return;
+ }
+ ArrayNode params = (ArrayNode) item.get("params");
+ params.forEach(paramNode -> {
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "funcOrAppId".equals(paramNode.get("name").asText())) {
+ if (!isNullOrEmptyNode(paramNode.get("value")) && !StringUtility.isNullOrEmpty(paramNode.get("value").asText())) {
+ ((ObjectNode) paramNode).put("value", "");
+ }
+ }
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "appEntrance".equals(paramNode.get("name").asText())) {
+ if (!isNullOrEmptyNode(paramNode.get("value")) && !StringUtility.isNullOrEmpty(paramNode.get("value").asText())) {
+ ((ObjectNode) paramNode).put("value", "");
+ }
+ }
+ });
+ }
+
+ private static boolean isTreeListControllerCommand(JsonNode item) {
+ return item.get("cmpId") != null && "d7de1993-d500-44fd-9922-43c78d477aa3".equals(item.get("cmpId").asText());
+ }
+
+ private static void updateTreeListControllerCommand(JsonNode item, ReplicationServiceContext context) {
+ if (isNullOrEmptyNode(item.get("params"))) {
+ return;
+ }
+ ArrayNode params = (ArrayNode) item.get("params");
+ params.forEach(paramNode -> {
+ if (!isNullOrEmptyNode(paramNode.get("name")) && "url".equals(paramNode.get("name").asText())) {
+ if (!isNullOrEmptyNode(paramNode.get("value")) && !StringUtility.isNullOrEmpty(paramNode.get("value").asText())) {
+ ((ObjectNode) paramNode).put("value", "");
+ }
+ }
+ });
+ }
+
+
+}
diff --git a/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/formmetadata/FormMetadataCopyImpl.java b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/formmetadata/FormMetadataCopyImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..7fa7cec145159d336bb40ac5ba1d6ba5ed93b9d4
--- /dev/null
+++ b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/formmetadata/FormMetadataCopyImpl.java
@@ -0,0 +1,33 @@
+package com.inspur.edp.web.appcopy.formmetadata;
+
+import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
+import com.inspur.edp.lcm.replication.api.context.ReplicationServiceContext;
+import com.inspur.edp.lcm.replication.api.entity.ReplicationParam;
+import com.inspur.edp.lcm.replication.api.entity.ReplicationTypeEnum;
+import com.inspur.edp.lcm.replication.spi.MetadataCopySpi;
+import com.inspur.edp.web.common.utility.StringUtility;
+
+
+public class FormMetadataCopyImpl implements MetadataCopySpi {
+
+ @Override
+ public void metadataCopy(ReplicationParam replicationParam, GspMetadata formMetadata, ReplicationServiceContext replicationServiceContext) {
+
+ String type = formMetadata.getHeader().getType();
+ if (StringUtility.isNullOrEmpty(type) || !"Form".equals(type) ) {
+ return;
+ }
+ FormCopyCommonUtility.updateFormContent(replicationParam, formMetadata, replicationServiceContext);
+ }
+
+ @Override
+ public String getMdType() {
+ return "Form";
+ }
+
+ @Override
+ public ReplicationTypeEnum getReplicationTypeEnum() {
+ return ReplicationTypeEnum.COMMON_APP_COPY;
+ }
+
+}
diff --git a/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/formmetadata/FormMetadataReferenceCollect.java b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/formmetadata/FormMetadataReferenceCollect.java
new file mode 100644
index 0000000000000000000000000000000000000000..84f9f2c56ac61c360ac6a6e1b801f3dbdfd89734
--- /dev/null
+++ b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/formmetadata/FormMetadataReferenceCollect.java
@@ -0,0 +1,258 @@
+package com.inspur.edp.web.appcopy.formmetadata;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
+import com.inspur.edp.lcm.metadata.api.entity.MetadataHeader;
+import com.inspur.edp.lcm.metadata.api.entity.MetadataReference;
+import com.inspur.edp.lcm.replication.api.entity.ReplicationTypeEnum;
+import com.inspur.edp.lcm.replication.spi.MetadataReferenceCollectSpi;
+import com.inspur.edp.web.common.utility.StringUtility;
+import com.inspur.edp.web.formmetadata.metadata.FormMetadataContent;
+
+import java.util.*;
+
+public class FormMetadataReferenceCollect implements MetadataReferenceCollectSpi {
+
+
+ @Override
+ public List collect(GspMetadata formMetadata) {
+ if (formMetadata == null ||
+ formMetadata.getHeader() == null ||
+ !("Form".equals(formMetadata.getHeader().getType()) ||
+ "MobileForm".equals(formMetadata.getHeader().getType()))) {
+ return Collections.emptyList();
+ }
+ List formMdReferences = new ArrayList<>(formMetadata.getRefs());
+ FormMetadataContent formMdContent = (FormMetadataContent) formMetadata.getContent();
+ JsonNode module = formMdContent.getModule();
+ if (isNullOrEmptyNode(module)) {
+ return formMdReferences;
+ }
+ //获取vo和eapi
+ JsonNode schema = formMdContent.getSchema();
+ if (!isNullOrEmptyNode(schema)) {
+ getReferenceBySchema((ArrayNode) schema, formMdReferences);
+ }
+ JsonNode stateMachines = formMdContent.getModule().get("stateMachines");
+ //获取状态机
+ if (!isNullOrEmptyNode(stateMachines)) {
+ getReferenceByStateMachines((ArrayNode) stateMachines, formMdReferences);
+ }
+ //获取构件元数据依赖
+ JsonNode webCmds = formMdContent.getModule().get("webcmds");
+ if (!isNullOrEmptyNode(webCmds)) {
+ getReferenceByWebCmd((ArrayNode) webCmds, formMdReferences);
+ }
+ //获取组合表单
+ JsonNode externalComponents = formMdContent.getModule().get("externalComponents");
+ if (!isNullOrEmptyNode(externalComponents)) {
+ getReferenceByExternalComponent((ArrayNode) externalComponents, formMdReferences);
+ }
+ //获取帮助依赖
+ JsonNode components = formMdContent.getModule().get("components");
+ if (!isNullOrEmptyNode(components)) {
+ extractHelpIds(components, formMdReferences);
+ }
+ //获取qo元数据依赖
+ JsonNode qdpInfo = formMdContent.getModule().get("qdpInfo");
+ if (!isNullOrEmptyNode(qdpInfo)) {
+ extractQueryInfoRefs(qdpInfo, formMdReferences);
+ }
+
+ return formMdReferences;
+ }
+
+ private void extractQueryInfoRefs(JsonNode qdpInfo, List formMdReferences) {
+ JsonNode qoMetadata = qdpInfo.get("qoMetadata");
+ if (isNullOrEmptyNode(qoMetadata)) {
+ return;
+ }
+ qoMetadata.forEach(qo -> {
+ JsonNode idNode = qo.get("id");
+ if (isNullOrEmptyNode(idNode)) {
+ return;
+ }
+ if (formMdReferences.stream().noneMatch(item -> idNode.asText().equals(item.getDependentMetadata().getId()))) {
+ MetadataReference ref = new MetadataReference();
+ MetadataHeader dependentMetadata = new MetadataHeader();
+ dependentMetadata.setId(idNode.asText());
+ dependentMetadata.setType("QueryObject");
+ ref.setDependentMetadata(dependentMetadata);
+ formMdReferences.add(ref);
+ }
+ });
+ }
+
+ private void getReferenceByExternalComponent(ArrayNode externalComponent, List formMdReferences) {
+ externalComponent.forEach(cmp -> {
+ getReferenceByExternalForm(cmp, formMdReferences);
+ });
+ }
+
+ private void getReferenceByExternalForm(JsonNode cmp, List formMdReferences) {
+ JsonNode uri = cmp.get("uri");
+ if (isNullOrEmptyNode(uri)) {
+ return;
+ }
+
+ if (formMdReferences.stream().noneMatch(item -> uri.asText().equals(item.getDependentMetadata().getId()))) {
+ MetadataReference ref = new MetadataReference();
+ MetadataHeader dependentMetadata = new MetadataHeader();
+ dependentMetadata.setId(uri.asText());
+ ref.setDependentMetadata(dependentMetadata);
+ formMdReferences.add(ref);
+ }
+ }
+
+ private void getReferenceByWebCmd(ArrayNode webCmds, List formMdReferences) {
+ webCmds.forEach(webCmd -> {
+ getReferenceByWebCmdNode(webCmd, formMdReferences);
+ });
+ }
+
+ private void getReferenceByWebCmdNode(JsonNode webCmd, List formMdReferences) {
+ if (isNullOrEmptyNode(webCmd.get("id"))) {
+ return;
+ }
+
+ if (formMdReferences.stream().noneMatch(item -> webCmd.get("id").asText().equals(item.getDependentMetadata().getId()))) {
+ MetadataReference cmdReference = new MetadataReference();
+ MetadataHeader dependentMetadata = new MetadataHeader();
+ dependentMetadata.setId(webCmd.get("id").asText());
+ dependentMetadata.setType("WebCommand");
+ cmdReference.setDependentMetadata(dependentMetadata);
+ formMdReferences.add(cmdReference);
+ }
+
+ }
+
+ private void getReferenceByStateMachines(ArrayNode stateMachines, List formMdReferences) {
+ stateMachines.forEach(stateMachineNode -> {
+ getReferenceBySM(stateMachineNode, formMdReferences);
+ });
+ }
+
+ private void getReferenceBySM(JsonNode stateMachineNode, List formMdReferences) {
+ if (isNullOrEmptyNode(stateMachineNode.get("uri"))) {
+ return;
+ }
+ String smId = stateMachineNode.get("uri").textValue();
+
+ if (formMdReferences.stream().noneMatch(item -> smId.equals(item.getDependentMetadata().getId()))) {
+ MetadataReference smReference = new MetadataReference();
+ MetadataHeader dependentMetadata = new MetadataHeader();
+ dependentMetadata.setId(smId);
+ dependentMetadata.setType("StateMachine");
+ smReference.setDependentMetadata(dependentMetadata);
+ formMdReferences.add(smReference);
+ }
+ }
+
+ private void getReferenceBySchema(ArrayNode schema, List formMdReferences) {
+ schema.forEach(schemaNode -> {
+ getReferenceByEapi(schemaNode, formMdReferences);
+ getReferenceByVo(schemaNode, formMdReferences);
+ });
+ }
+
+ private void getReferenceByVo(JsonNode node, List formMdReferences) {
+ if (isNullOrEmptyNode(node.get("id"))) {
+ return;
+ }
+ String voId = node.get("id").asText();
+ if (formMdReferences.stream().noneMatch(item -> voId.equals(item.getDependentMetadata().getId()))) {
+ MetadataReference voReference = new MetadataReference();
+ MetadataHeader dependentMetadata = new MetadataHeader();
+ dependentMetadata.setId(voId);
+ dependentMetadata.setType("GSPViewModel");
+ voReference.setDependentMetadata(dependentMetadata);
+ formMdReferences.add(voReference);
+ }
+ }
+
+ private void getReferenceByEapi(JsonNode schemaNode, List formMdReferences) {
+ if (isNullOrEmptyNode(schemaNode.get("eapiId"))) {
+ return;
+ }
+ String eapiId = schemaNode.get("eapiId").asText();
+ if (formMdReferences.stream().noneMatch(item -> eapiId.equals(item.getDependentMetadata().getId()))) {
+ MetadataReference eapiReference = new MetadataReference();
+ MetadataHeader dependentMetadata = new MetadataHeader();
+ dependentMetadata.setId(eapiId);
+ dependentMetadata.setType("ExternalApi");
+ eapiReference.setDependentMetadata(dependentMetadata);
+ formMdReferences.add(eapiReference);
+ }
+ }
+
+ @Override
+ public ReplicationTypeEnum getReplicationTypeEnum() {
+ return ReplicationTypeEnum.COMMON_APP_COPY;
+ }
+
+ public static boolean isNullOrEmptyNode(JsonNode node) {
+ return node == null ||
+ node.isNull() ||
+ node.isArray() && node.isEmpty() ||
+ node.isObject() && node.isEmpty() ||
+ StringUtility.isNullOrEmpty(node.toString());
+ }
+
+ /**
+ * 提取JSON字符串中所有helpId的值
+ *
+ * @param rootNode 目标JSON字符串
+ * @param formMdReferences
+ * @return 所有helpId的值列表
+ */
+ public static void extractHelpIds(JsonNode rootNode, List formMdReferences) {
+ List helpIdList = new ArrayList<>();
+ // 递归遍历节点
+ traverseJsonNode(rootNode, helpIdList);
+ helpIdList.forEach(helpId -> {
+ if (!StringUtility.isNullOrEmpty(helpId) &&
+ formMdReferences.stream().noneMatch(item -> helpId.equals(item.getDependentMetadata().getId()))) {
+ MetadataReference helpReference = new MetadataReference();
+ MetadataHeader dependentMetadata = new MetadataHeader();
+ dependentMetadata.setId(helpId);
+ helpReference.setDependentMetadata(dependentMetadata);
+ formMdReferences.add(helpReference);
+ }
+ });
+ }
+
+ /**
+ * 递归遍历Jackson的JsonNode,提取helpId
+ *
+ * @param node 当前遍历的节点
+ * @param helpIdList 收集helpId的列表
+ */
+ private static void traverseJsonNode(JsonNode node, List helpIdList) {
+ if (isNullOrEmptyNode(node)) {
+ return;
+ }
+ // 处理对象节点({...})
+ if (node.isObject()) {
+ Iterator> fields = node.fields();
+ while (fields.hasNext()) {
+ Map.Entry field = fields.next();
+ String key = field.getKey();
+ JsonNode value = field.getValue();
+ // 匹配helpId键,收集值
+ if ("helpId".equals(key)) {
+ helpIdList.add(value.isNull() ? null : value.asText());
+ }
+ // 递归遍历子节点
+ traverseJsonNode(value, helpIdList);
+ }
+ }
+ // 处理数组节点([...])
+ else if (node.isArray()) {
+ for (JsonNode item : node) {
+ traverseJsonNode(item, helpIdList);
+ }
+ }
+ // 基本类型节点,无需处理
+ }
+}
diff --git a/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/formmetadata/MobileFormMetadataCopyImpl.java b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/formmetadata/MobileFormMetadataCopyImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..eadc4001f82225fd28747da5cdef9b25bb3dea3a
--- /dev/null
+++ b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/formmetadata/MobileFormMetadataCopyImpl.java
@@ -0,0 +1,30 @@
+package com.inspur.edp.web.appcopy.formmetadata;
+
+import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
+import com.inspur.edp.lcm.replication.api.context.ReplicationServiceContext;
+import com.inspur.edp.lcm.replication.api.entity.ReplicationParam;
+import com.inspur.edp.lcm.replication.api.entity.ReplicationTypeEnum;
+import com.inspur.edp.lcm.replication.spi.MetadataCopySpi;
+import com.inspur.edp.web.common.utility.StringUtility;
+
+public class MobileFormMetadataCopyImpl implements MetadataCopySpi {
+ @Override
+ public void metadataCopy(ReplicationParam replicationParam, GspMetadata formMetadata, ReplicationServiceContext replicationServiceContext) {
+ String type = formMetadata.getHeader().getType();
+ if (StringUtility.isNullOrEmpty(type) || !"MobileForm".equals(type) ) {
+ return;
+ }
+ FormCopyCommonUtility.updateFormContent(replicationParam, formMetadata, replicationServiceContext);
+
+ }
+
+ @Override
+ public String getMdType() {
+ return "MobileForm";
+ }
+
+ @Override
+ public ReplicationTypeEnum getReplicationTypeEnum() {
+ return ReplicationTypeEnum.COMMON_APP_COPY;
+ }
+}
diff --git a/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/pageflowmetadata/MobilePageFlowCopyImpl.java b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/pageflowmetadata/MobilePageFlowCopyImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..eed9f94b984260fd625969ecafa9f27ce45296b6
--- /dev/null
+++ b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/pageflowmetadata/MobilePageFlowCopyImpl.java
@@ -0,0 +1,28 @@
+package com.inspur.edp.web.appcopy.pageflowmetadata;
+
+import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
+import com.inspur.edp.lcm.replication.api.context.ReplicationServiceContext;
+import com.inspur.edp.lcm.replication.api.entity.ReplicationParam;
+import com.inspur.edp.lcm.replication.api.entity.ReplicationTypeEnum;
+import com.inspur.edp.lcm.replication.spi.MetadataCopySpi;
+
+public class MobilePageFlowCopyImpl implements MetadataCopySpi {
+
+ @Override
+ public void metadataCopy(ReplicationParam replicationParam, GspMetadata gspMetadata, ReplicationServiceContext replicationServiceContext) {
+ if (gspMetadata == null || gspMetadata.getHeader() == null || !"MobilePageFlowMetadata".equals(gspMetadata.getHeader().getType())) {
+ return;
+ }
+ PageFlowCopyCommonUtility.updatePageFlowContent(replicationParam, gspMetadata, replicationServiceContext);
+ }
+
+ @Override
+ public String getMdType() {
+ return "MobilePageFlowMetadata";
+ }
+
+ @Override
+ public ReplicationTypeEnum getReplicationTypeEnum() {
+ return ReplicationTypeEnum.COMMON_APP_COPY;
+ }
+}
diff --git a/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/pageflowmetadata/PageFlowCopyCommonUtility.java b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/pageflowmetadata/PageFlowCopyCommonUtility.java
new file mode 100644
index 0000000000000000000000000000000000000000..c89931d1d45ec47dc685ddb1786252b5c3578220
--- /dev/null
+++ b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/pageflowmetadata/PageFlowCopyCommonUtility.java
@@ -0,0 +1,138 @@
+package com.inspur.edp.web.appcopy.pageflowmetadata;
+
+import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
+import com.inspur.edp.lcm.replication.api.context.ReplicationServiceContext;
+import com.inspur.edp.lcm.replication.api.entity.ReplicationParam;
+import com.inspur.edp.web.common.utility.StringUtility;
+import com.inspur.edp.web.pageflow.metadata.entity.Page;
+import com.inspur.edp.web.pageflow.metadata.entity.PageFlowMetadataEntity;
+import com.inspur.edp.web.pageflow.metadata.entity.Project;
+
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+public class PageFlowCopyCommonUtility {
+
+ public static void updatePageFlowContent(ReplicationParam replicationParam, GspMetadata pfMetadata,
+ ReplicationServiceContext replicationServiceContext) {
+
+ PageFlowMetadataEntity pageFlowContent = (PageFlowMetadataEntity) pfMetadata.getContent();
+ if (pageFlowContent == null) {
+ return;
+ }
+ //发布信息删了;
+ pageFlowContent.setPublishes(new ArrayList<>());
+ //替换id
+ if (!StringUtility.isNullOrEmpty(pageFlowContent.getId()) &&
+ !StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(pageFlowContent.getId()))) {
+ pageFlowContent.setId(replicationServiceContext.findNewUUID(pageFlowContent.getId()));
+ }
+ //替换project
+ Project project = new Project();
+ project.setName(pageFlowContent.getProject() != null &&
+ !StringUtility.isNullOrEmpty(pageFlowContent.getProject().getName()) &&
+ replicationServiceContext.getProjectNameMap() != null &&
+ !replicationServiceContext.getProjectNameMap().isEmpty() &&
+ !StringUtility.isNullOrEmpty(replicationServiceContext.getProjectNameMap().get(pageFlowContent.getProject().getName())) ?
+ replicationServiceContext.getProjectNameMap().get(pageFlowContent.getProject().getName()).toLowerCase() : "bo-" + replicationParam.getTargetBizObjCode().toLowerCase() + "-front");
+ pageFlowContent.setProject(project);
+ //清空应用信息
+ pageFlowContent.setEntry(null);
+ pageFlowContent.setRoutes(null);
+ pageFlowContent.setAppName(null);
+ pageFlowContent.setAppCode(null);
+
+ if (pageFlowContent.hasEmptyPage()) {
+ pfMetadata.setContent(pageFlowContent);
+ return;
+ }
+ for (Page page : pageFlowContent.getPages()) {
+ updatePage(replicationParam, replicationServiceContext, page);
+ }
+ pfMetadata.setContent(pageFlowContent);
+ }
+
+ private static void updatePage(ReplicationParam replicationParam, ReplicationServiceContext replicationServiceContext, Page page) {
+ if (!StringUtility.isNullOrEmpty(page.getId()) && !StringUtility.isNullOrEmpty(replicationServiceContext.findNewUUID(page.getId()))) {
+ page.setId(replicationServiceContext.findNewUUID(page.getId()));
+ }
+ if (!StringUtility.isNullOrEmpty(page.getRelativePath())) {
+ page.setRelativePath(buildNewRelativePath(replicationParam, replicationServiceContext, page.getRelativePath()));
+ }
+ }
+
+ //同LCM给的规则保持一致,
+ private static String buildNewRelativePath(ReplicationParam replicationParam, ReplicationServiceContext context, String oldRelativePath) {
+ if (StringUtility.isNullOrEmpty(oldRelativePath)) {
+ return null;
+ }
+ // 获取新值
+ String newAppDomain = replicationParam.getTargetAppDomain();
+ String newServiceUnit = replicationParam.getTargetSU();
+ String newBoCode = replicationParam.getTargetBizObjCode();
+ String projectName = getProjectName(oldRelativePath);
+ if (StringUtility.isNullOrEmpty(projectName)) {
+ return null;
+ }
+ String result = Paths.get(newAppDomain,
+ newServiceUnit,
+ newBoCode,
+ context.getProjectNameMap() != null &&
+ !context.getProjectNameMap().isEmpty() &&
+ !StringUtility.isNullOrEmpty(context.getProjectNameMap().get(projectName)) ?
+ context.getProjectNameMap().get(projectName).toLowerCase() : "bo-" + replicationParam.getTargetBizObjCode().toLowerCase() + "-front",
+ getSecondLastProperty(oldRelativePath),
+ getFinalProperty(oldRelativePath)
+ ).toString().replace("\\", "/");
+ return result;
+
+ }
+
+ public static String getProjectName(String oldRelativePath) {
+ // 1. 空值校验:避免NPE
+ if (StringUtility.isNullOrEmpty(oldRelativePath)) {
+ return null; // 或抛业务异常,根据实际需求调整
+ }
+
+ // 2. 分割路径 + 过滤空元素(处理连续/、首尾/的情况)
+ String[] pathSegments = oldRelativePath.split("/");
+ List validSegments = new ArrayList<>();
+ for (String segment : pathSegments) {
+ if (!StringUtility.isNullOrEmpty(segment)) { // 过滤空字符串/纯空格
+ validSegments.add(segment);
+ }
+ }
+
+ // 3. 数组长度校验:避免IndexOutOfBoundsException
+ if (validSegments.size() < 3) {
+ return null; // 路径层级不足,返回null/抛异常/返回默认值
+ }
+
+ // 4. 取倒数第三个元素
+ return validSegments.get(validSegments.size() - 3);
+ }
+
+ public static String getFinalProperty(String key) {
+ if (StringUtility.isNullOrEmpty(key)) {
+ return key;
+ }
+ String[] splitString = key.split("/");
+ if (splitString.length < 1) {
+ return key;
+ }
+ return splitString[splitString.length - 1];
+ }
+
+ public static String getSecondLastProperty(String key) {
+ if (StringUtility.isNullOrEmpty(key)) {
+ return key;
+ }
+ String[] splitString = key.split("/");
+ if (splitString.length < 2) {
+ return key;
+ }
+ return splitString[splitString.length - 2];
+
+ }
+}
diff --git a/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/pageflowmetadata/PageFlowCopyImpl.java b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/pageflowmetadata/PageFlowCopyImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..3a4176f6b9b4402d866a8f72d8e59a4a715a6eba
--- /dev/null
+++ b/web-metadata-replication-core/src/main/java/com/inspur/edp/web/appcopy/pageflowmetadata/PageFlowCopyImpl.java
@@ -0,0 +1,27 @@
+package com.inspur.edp.web.appcopy.pageflowmetadata;
+
+import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
+import com.inspur.edp.lcm.replication.api.context.ReplicationServiceContext;
+import com.inspur.edp.lcm.replication.api.entity.ReplicationParam;
+import com.inspur.edp.lcm.replication.api.entity.ReplicationTypeEnum;
+import com.inspur.edp.lcm.replication.spi.MetadataCopySpi;
+
+public class PageFlowCopyImpl implements MetadataCopySpi {
+ @Override
+ public void metadataCopy(ReplicationParam replicationParam, GspMetadata gspMetadata, ReplicationServiceContext replicationServiceContext) {
+ if (gspMetadata == null || gspMetadata.getHeader() == null || !"PageFlowMetadata".equals(gspMetadata.getHeader().getType())) {
+ return;
+ }
+ PageFlowCopyCommonUtility.updatePageFlowContent(replicationParam, gspMetadata, replicationServiceContext);
+ }
+
+ @Override
+ public String getMdType() {
+ return "PageFlowMetadata";
+ }
+
+ @Override
+ public ReplicationTypeEnum getReplicationTypeEnum() {
+ return ReplicationTypeEnum.COMMON_APP_COPY;
+ }
+}
diff --git a/web-metadata-replication-core/src/main/resources/META-INF/spring.factories b/web-metadata-replication-core/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000000000000000000000000000000000000..13863b80b3ac5119eee340af61c311b283ce5095
--- /dev/null
+++ b/web-metadata-replication-core/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,2 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+com.inspur.edp.web.appcopy.config.WebReplicationConfiguration