diff --git a/appconfig/web-appconfig-core/src/main/java/com/inspur/edp/web/appconfig/core/service/GspAppConfigService.java b/appconfig/web-appconfig-core/src/main/java/com/inspur/edp/web/appconfig/core/service/GspAppConfigService.java index 1dd4cdd96b0e95a1faf287bc8167e5c3046aaba7..1c863d5994cdf538d94ad092448173f95ebaac9c 100644 --- a/appconfig/web-appconfig-core/src/main/java/com/inspur/edp/web/appconfig/core/service/GspAppConfigService.java +++ b/appconfig/web-appconfig-core/src/main/java/com/inspur/edp/web/appconfig/core/service/GspAppConfigService.java @@ -21,6 +21,7 @@ import com.inspur.edp.lcm.metadata.api.service.MetadataProjectService; import com.inspur.edp.web.appconfig.api.entity.GspAppConfig; import com.inspur.edp.web.appconfig.core.appconfig.AppConfigFileManager; import com.inspur.edp.web.appconfig.core.appconfig.AppConfigFilePathGenerator; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.entity.TerminalType; import com.inspur.edp.web.common.io.FileUtility; import com.inspur.edp.web.common.metadata.GspProjectUtility; @@ -126,7 +127,7 @@ public class GspAppConfigService { appConfig.setMobilePageFlowMetadataPath(pageFlowMetadataFullPath); break; default: - throw new CAFRuntimeException("", "Web_UpdateAppConfigFile", "未识别的终端类型,请联系管理员处理。当前终端类型是:" + terminalType, null); + throw new WebCustomException("未识别的终端类型,请联系管理员处理。当前终端类型是:" + terminalType); } modifyPageFlowMetadataPath(appConfig, pageFlowMetadataFullPath); diff --git a/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/service/ApprovalFormMetadataServiceImpl.java b/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/service/ApprovalFormMetadataServiceImpl.java index 5b5a10df3b962389a78230da24ea4962ffc5314e..d28bcddaeaa76a1b08cb7a7d012de2af95e2a968 100644 --- a/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/service/ApprovalFormMetadataServiceImpl.java +++ b/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/service/ApprovalFormMetadataServiceImpl.java @@ -32,6 +32,7 @@ import com.inspur.edp.web.approvalformat.api.service.ApprovalFormMetadataService import com.inspur.edp.web.approvalformat.core.util.ApprovalFormSchemaUtil; import com.inspur.edp.web.approvalformat.core.util.ApprovalFormUtil; import com.inspur.edp.web.approvalformat.core.util.ApprovalFormatPermission; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.utility.StringUtility; import com.inspur.edp.web.formmetadata.metadata.FormMetadataContent; import io.iec.edp.caf.commons.utils.SpringBeanUtils; @@ -117,7 +118,7 @@ public class ApprovalFormMetadataServiceImpl implements ApprovalFormMetadataServ FormSchema schema = ApprovalFormSchemaUtil.constructSchema(vm); return new ObjectMapper().writeValueAsString(schema); } catch (JsonProcessingException e) { - throw new RuntimeException("Schema序列化失败,id=" + voContent.get("ID")); + throw new WebCustomException("Schema序列化失败,id=" + voContent.get("ID")); } } } diff --git a/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/service/ApprovalFormatServiceImpl.java b/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/service/ApprovalFormatServiceImpl.java index 363e9edaffce6032466f70d56659c59ab3cad0fb..3968e5c2b84d052da46f8d70bf2af362d19f04a0 100644 --- a/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/service/ApprovalFormatServiceImpl.java +++ b/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/service/ApprovalFormatServiceImpl.java @@ -48,6 +48,7 @@ import com.inspur.edp.web.approvalformat.core.domain.converter.ApprovalFormatCon import com.inspur.edp.web.approvalformat.core.domain.entity.ApprovalFormatDO; import com.inspur.edp.web.approvalformat.core.domain.manager.ApprovalFormatManager; import com.inspur.edp.web.approvalformat.core.util.*; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.io.FileUtility; import com.inspur.edp.web.common.logger.WebLogger; import com.inspur.edp.web.common.utility.StringUtility; @@ -109,7 +110,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { public Map getEntityDataByBizEntityId(String dataId, String bizEntityId) { String targetServiceUnitCode = getServiceUnitCode(bizEntityId); if (targetServiceUnitCode == null || targetServiceUnitCode.isEmpty()) { - throw new RuntimeException("当前BE对应su的编号为空。当前BE的id是:" + bizEntityId); + throw new WebCustomException("当前BE对应su的编号为空。当前BE的id是:" + bizEntityId); } RpcClient client = SpringBeanUtils.getBean(RpcClient.class); LinkedHashMap parameterHashMap = new LinkedHashMap<>(); @@ -122,7 +123,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { parameterHashMap, null); } catch (Exception e) { - throw new RuntimeException("调用RPC服务发生异常。当前BE的id是:" + bizEntityId + ",获取到的su编号:" + targetServiceUnitCode, e); + throw new WebCustomException("调用RPC服务发生异常。当前BE的id是:" + bizEntityId + ",获取到的su编号:" + targetServiceUnitCode, e); } } @@ -158,7 +159,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { public List queryEntityData(String bizEntityId) { String targetServiceUnitCode = getServiceUnitCode(bizEntityId); if (targetServiceUnitCode == null || targetServiceUnitCode.isEmpty()) { - throw new RuntimeException("当前BE对应su的编号为空。当前BE的id是:" + bizEntityId); + throw new WebCustomException("当前BE对应su的编号为空。当前BE的id是:" + bizEntityId); } LinkedHashMap parameterHashMap = new LinkedHashMap<>(); @@ -172,7 +173,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { parameterHashMap, null); } catch (Exception e) { - throw new RuntimeException("调用RPC服务发生异常。当前BE的id是:" + bizEntityId + ",获取到的su编号:" + targetServiceUnitCode + e.getMessage(), e); + throw new WebCustomException("调用RPC服务发生异常。当前BE的id是:" + bizEntityId + ",获取到的su编号:" + targetServiceUnitCode + e.getMessage(), e); } } @@ -181,7 +182,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { String bizEntityId = queryStringMap.get("bizEntityId").asText(); String targetServiceUnitCode = getServiceUnitCode(bizEntityId); if (targetServiceUnitCode == null || targetServiceUnitCode.isEmpty()) { - throw new RuntimeException("当前BE对应su的编号为空。当前BE的id是:" + bizEntityId); + throw new WebCustomException("当前BE对应su的编号为空。当前BE的id是:" + bizEntityId); } LinkedHashMap parameterHashMap = new LinkedHashMap<>(); @@ -195,7 +196,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { parameterHashMap, null); } catch (Exception e) { - throw new RuntimeException("调用RPC服务发生异常。当前BE的id是:" + bizEntityId + ",获取到的su编号:" + targetServiceUnitCode + e.getMessage(), e); + throw new WebCustomException("调用RPC服务发生异常。当前BE的id是:" + bizEntityId + ",获取到的su编号:" + targetServiceUnitCode + e.getMessage(), e); } } @@ -207,7 +208,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { if (checkIfExistsByBillCategoryIdAndDimension(approvalFormatCreateRequestBody.getBillCategoryId(), approvalFormatCreateRequestBody.getDim1(), approvalFormatCreateRequestBody.getDim2())) { - throw new RuntimeException("不允许相同单据种类id下,存在两个维度定义相同的记录,请检查。"); + throw new WebCustomException("不允许相同单据种类id下,存在两个维度定义相同的记录,请检查。"); } @@ -216,7 +217,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { try { ApprovalFormUtil.saveCheck(approvalFormatCreateRequestBody, "Form"); } catch (Exception e) { - throw new RuntimeException("已存在格式编号为" + formatCode + "的审批格式,请更换格式编号后重试。"); + throw new WebCustomException("已存在格式编号为" + formatCode + "的审批格式,请更换格式编号后重试。", e); } //todo 改为vo创建后,新增一个方法执行vo创建格式 this.approvalFormMetadataService.createApprovalForm(approvalFormatCreateRequestBody); @@ -225,7 +226,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { } else { //不允许使用审批格式的VO创建新的审批格式 if (checkIfExistsByViewModelId(approvalFormatCreateRequestBody.getVoId())) { - throw new RuntimeException("当前视图对象已经创建过审批格式,不允许重复创建!"); + throw new WebCustomException("当前视图对象已经创建过审批格式,不允许重复创建!"); } //根据VO创建eapi元数据 ApprovalFormUtil.deployManualVOandEapi(approvalFormatCreateRequestBody, approvalFormatCreateRequestBody.getVoId(), ""); @@ -291,14 +292,14 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { try { this.deleteFilesGeneratedInPreviewApprovalFormat(approvalFormId); } catch (Exception e) { - throw new RuntimeException("删除移动审批相关文件失败。详细信息如下:" + e.getMessage()); + throw new WebCustomException("删除移动审批相关文件失败。详细信息如下:" + e.getMessage()); } //根据表单元数据获取Eapi的ID GspMetadata approvalFormMetaData = null; approvalFormMetaData = this.customizationService.getMetadata(approvalFormId); if (approvalFormMetaData == null) { - throw new RuntimeException("获取审批格式失败"); + throw new WebCustomException("获取审批格式失败"); } // 删除审批单据 this.customizationService.deleteGeneratedMetadata(approvalFormId); @@ -328,13 +329,13 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { @Override public ApprovalFormat updateApprovalFormat(ApprovalFormatUpdateRequestBody approvalFormatUpdateRequestBody) { if (!approvalFormatUpdateRequestBody.getApprovalFormatId().equals(approvalFormatUpdateRequestBody.getApprovalFormatInstance().getId())) { - throw new RuntimeException("待更新审批格式id与待更新内容中id不一致,请检查。"); + throw new WebCustomException("待更新审批格式id与待更新内容中id不一致,请检查。"); } ApprovalFormat approvalFormatInstance = approvalFormatUpdateRequestBody.getApprovalFormatInstance(); ApprovalFormat approvalFormatFromDatabase = this.approvalFormatManager.getApprovalFormatById(approvalFormatInstance.getId()); if (approvalFormatFromDatabase == null) { - throw new RuntimeException("待更新审批格式不存在,不能调用更新接口。请联系开发人员处理"); + throw new WebCustomException("待更新审批格式不存在,不能调用更新接口。请联系开发人员处理"); } if (ApprovalFormatUtil.isEqual(approvalFormatInstance, approvalFormatFromDatabase)) { return approvalFormatInstance; @@ -342,7 +343,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { ApprovalFormatDO approvalFormatDO = ApprovalFormatConverter.toDo(approvalFormatInstance); if (this.approvalFormatManager.checkIfExistsByBillCategoryIdAndDimension(approvalFormatDO)) { - throw new RuntimeException("不允许相同单据种类id下,存在两个维度定义相同的记录,请检查。"); + throw new WebCustomException("不允许相同单据种类id下,存在两个维度定义相同的记录,请检查。"); } return this.approvalFormatManager.save(approvalFormatDO); @@ -351,13 +352,13 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { @Override public ApprovalFormat updateApprovalFormatFormUrl(ApprovalFormatUpdateRequestBody approvalFormatUpdateRequestBody) { if (!approvalFormatUpdateRequestBody.getApprovalFormatId().equals(approvalFormatUpdateRequestBody.getApprovalFormatInstance().getId())) { - throw new RuntimeException("待更新审批格式id与待更新内容中id不一致,请检查。"); + throw new WebCustomException("待更新审批格式id与待更新内容中id不一致,请检查。"); } ApprovalFormat approvalFormatInstance = approvalFormatUpdateRequestBody.getApprovalFormatInstance(); ApprovalFormat approvalFormatFromDatabase = this.approvalFormatManager.getApprovalFormatById(approvalFormatInstance.getId()); if (approvalFormatFromDatabase == null) { - throw new RuntimeException("待更新审批格式不存在,不能调用更新接口。请联系开发人员处理"); + throw new WebCustomException("待更新审批格式不存在,不能调用更新接口。请联系开发人员处理"); } // 检测到未修改,直接返回 if (approvalFormatInstance.getApprovalFormPublishUri().equals(approvalFormatFromDatabase.getApprovalFormPublishUri())) { @@ -373,7 +374,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { public ApprovalFormat updateApprovalFormatDimension(ApprovalFormatDimensionUpdateRequestBody approvalFormatDimensionUpdateRequestBody) { ApprovalFormat approvalFormatFromDatabase = this.approvalFormatManager.getApprovalFormatById(approvalFormatDimensionUpdateRequestBody.getId()); if (approvalFormatFromDatabase == null) { - throw new RuntimeException("待更新审批格式不存在,不能调用更新接口。请联系开发人员处理"); + throw new WebCustomException("待更新审批格式不存在,不能调用更新接口。请联系开发人员处理"); } // 检测到未修改,直接返回 @@ -431,7 +432,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { return null; } if (approvalFormatCollection.size() > 1) { - throw new RuntimeException("表中存在重复数据,请联系开发人员处理。"); + throw new WebCustomException("表中存在重复数据,请联系开发人员处理。"); } return approvalFormatCollection.get(0); @@ -444,7 +445,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { return null; } if (approvalFormatCollection.size() > 1) { - throw new RuntimeException("表中存在重复数据,请联系开发人员处理。"); + throw new WebCustomException("表中存在重复数据,请联系开发人员处理。"); } return approvalFormatCollection.get(0); @@ -522,7 +523,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { for (ApprovalFormat approvalFormat : approvalFormatCollection) { String currentFormId = approvalFormat.getApprovalFormId(); if (formIdApprovalFormatMap.containsKey(currentFormId)) { - throw new RuntimeException("审批格式和审批单据的一对一映射被破坏,请联系开发人员处理。审批单据id是:" + approvalFormat.getApprovalFormId()); + throw new WebCustomException("审批格式和审批单据的一对一映射被破坏,请联系开发人员处理。审批单据id是:" + approvalFormat.getApprovalFormId()); } formIdApprovalFormatMap.put(currentFormId, approvalFormat); } @@ -542,7 +543,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { try { children = this.customizationService.getMetadataInfoRecusively(metadataHeader.getId(), metadataHeader.getCertId()); } catch (Exception e) { - throw new RuntimeException("getMetadataInfoRecusively Error."); + throw new WebCustomException("getMetadataInfoRecusively Error.", e); } if (children != null && children.size() > 0) { @@ -563,7 +564,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { return null; } if (approvalFormatCollection.size() > 1) { - throw new RuntimeException("表中存在重复数据,请联系开发人员处理。"); + throw new WebCustomException("表中存在重复数据,请联系开发人员处理。"); } return approvalFormatCollection.get(0); @@ -632,7 +633,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { */ private void deleteFilesGeneratedInPreviewApprovalFormat(String formId) throws Exception { if (formId == null || formId.isEmpty()) { - throw new Exception("删除移动审批相关文件失败,表单编号为空。"); + throw new WebCustomException("删除移动审批相关文件失败,表单编号为空。"); } GspMetadata gspMetadata = ApproveFormatPreviewUtil.getGspMetadataWithFormId(formId); @@ -653,7 +654,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { for (ApprovalFormat approvalFormat : approvalFormatCollection) { GspMetadata approvalForm = this.customizationService.getMetadata(approvalFormat.getApprovalFormId()); if (approvalForm == null) { - throw new RuntimeException("获取元数据失败。待获取元数据ID是:" + approvalFormat.getApprovalFormId()); + throw new WebCustomException("获取元数据失败。待获取元数据ID是:" + approvalFormat.getApprovalFormId()); } MetadataHeader approvalFormMetadataHeader = approvalForm.getHeader(); approvalFormat.setCode(approvalFormMetadataHeader.getCode()); @@ -693,7 +694,7 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { ApprovalFormatQueryResponseBody approvalFormatQueryResponseBody = ApprovalFormatUtil.convertToApprovalFormatQueryResponseBody(approvalFormat); GspMetadata approvalForm = this.customizationService.getMetadata(approvalFormatQueryResponseBody.getApprovalFormId()); if (approvalForm == null) { - throw new RuntimeException("获取元数据失败。待获取元数据ID是:" + approvalFormatQueryResponseBody.getApprovalFormId()); + throw new WebCustomException("获取元数据失败。待获取元数据ID是:" + approvalFormatQueryResponseBody.getApprovalFormId()); } MetadataHeader approvalFormMetadataHeader = approvalForm.getHeader(); approvalFormatQueryResponseBody.setCode(approvalFormMetadataHeader.getCode()); @@ -829,13 +830,13 @@ public class ApprovalFormatServiceImpl implements ApprovalFormatService { } catch (JsonProcessingException e) { WebLogger.Instance.error(e); - throw new RuntimeException(e); + throw new WebCustomException("getJsonNode出现错误", e); } } private boolean isCreatedByViewModel(ApprovalFormatCreateRequestBody approvalFormatCreateRequestBody) { if (approvalFormatCreateRequestBody == null) { - throw new RuntimeException("参数为空,请检查!"); + throw new WebCustomException("参数为空,请检查!"); } return StringUtility.isNullOrEmpty(approvalFormatCreateRequestBody.getBeId()); diff --git a/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/service/BusinessEntityServiceImpl.java b/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/service/BusinessEntityServiceImpl.java index ceb064e6846ef5864d180f12547e3fd9cfa9cca5..452da2ede58e9b5a60fade8c7f8d1707f5ac2b87 100644 --- a/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/service/BusinessEntityServiceImpl.java +++ b/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/service/BusinessEntityServiceImpl.java @@ -20,6 +20,7 @@ import com.inspur.edp.bef.bizentity.GspBusinessEntity; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; import com.inspur.edp.metadata.rtcustomization.api.CustomizationService; import com.inspur.edp.web.approvalformat.api.service.BusinessEntityService; +import com.inspur.edp.web.common.customexception.WebCustomException; import io.iec.edp.caf.commons.utils.SpringBeanUtils; /** @@ -34,7 +35,7 @@ public class BusinessEntityServiceImpl implements BusinessEntityService { public GspBusinessEntity getBusinessEntity(String bizEntityId) { GspMetadata bizEntityMetadata = this.customizationService.getMetadata(bizEntityId); if(bizEntityMetadata == null) { - throw new RuntimeException("The Metadata to search is null. The Searching Metadata ID is: " + bizEntityId); + throw new WebCustomException("The Metadata to search is null. The Searching Metadata ID is: " + bizEntityId); } return (GspBusinessEntity)bizEntityMetadata.getContent(); @@ -44,7 +45,7 @@ public class BusinessEntityServiceImpl implements BusinessEntityService { public GspMetadata getBusinessEntityMetadata(String bizEntityId) { GspMetadata bizEntityMetadata = this.customizationService.getMetadata(bizEntityId); if(bizEntityMetadata == null) { - throw new RuntimeException("The Metadata to search is null. The Searching Metadata ID is: " + bizEntityId); + throw new WebCustomException("The Metadata to search is null. The Searching Metadata ID is: " + bizEntityId); } return bizEntityMetadata; diff --git a/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/util/ApprovalFormUtil.java b/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/util/ApprovalFormUtil.java index c0dda73b0d2b67692583b946cccd5368a4583aa5..8cbdfdefe147ce1ffce814b49e78e89fec1db62b 100644 --- a/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/util/ApprovalFormUtil.java +++ b/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/util/ApprovalFormUtil.java @@ -29,6 +29,7 @@ import com.inspur.edp.lcm.metadata.common.Utils; import com.inspur.edp.metadata.businesstype.api.MdBizTypeMappingService; import com.inspur.edp.metadata.rtcustomization.api.CustomizationService; import com.inspur.edp.web.approvalformat.api.entity.ApprovalFormatCreateRequestBody; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.formmetadata.metadata.FormMetadataContent; import io.iec.edp.caf.commons.utils.SpringBeanUtils; import com.inspur.edp.formserver.viewmodel.extendinfo.entity.GspVoExtendInfo; @@ -143,7 +144,7 @@ public class ApprovalFormUtil { try { customizationService.saveCheck(metadata); } catch (Exception e) { - throw new RuntimeException("元数据namespace + code + type发生重复"); + throw new WebCustomException("元数据namespace + code + type发生重复", e); } } @@ -318,7 +319,7 @@ public class ApprovalFormUtil { try { return mapper.readValue(requestBody.getVoContent(), GspViewModel.class); } catch (JsonProcessingException e) { - throw new RuntimeException("创建" + metaDataType + "元数据失败"); + throw new WebCustomException("创建" + metaDataType + "元数据失败"); } default: return null; @@ -387,7 +388,7 @@ public class ApprovalFormUtil { GspMetadata RtEapiMetadata = eapiMetadataRtService.createRtEapi(voMetadataCopy); DeployEapiMetadataAndSyncToFormMetadata(request, RtEapiMetadata); } catch (Exception e) { - throw new RuntimeException("只支持使用手工创建且没有部署过Eapi的视图对象来创建审批格式!"); + throw new WebCustomException("只支持使用手工创建且没有部署过Eapi的视图对象来创建审批格式!", e); } } diff --git a/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/util/FieldUtil.java b/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/util/FieldUtil.java index d69e70bd72a5c6dbcbcd95577e3ae3a5d593cd10..f1a81bd63b38d6b8eb0d98d6ad6c5fd265b7ff4b 100644 --- a/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/util/FieldUtil.java +++ b/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/util/FieldUtil.java @@ -35,6 +35,7 @@ import com.inspur.edp.web.approvalformat.api.entity.schema.Field; import com.inspur.edp.web.approvalformat.api.entity.schema.SimpleField; import com.inspur.edp.web.approvalformat.api.entity.schema.editor.*; import com.inspur.edp.web.approvalformat.api.entity.schema.type.*; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.utility.StringUtility; import io.iec.edp.caf.commons.utils.SpringBeanUtils; @@ -218,7 +219,7 @@ public class FieldUtil { } } if(!(udtTypeDef instanceof SimpleDataTypeDef)&&!(udtTypeDef instanceof ComplexDataTypeDef)) { - throw new RuntimeException("Id为"+udtTypeDef.getId()+"的统一数据类型元数据为未识别的类型。"); + throw new WebCustomException("Id为"+udtTypeDef.getId()+"的统一数据类型元数据为未识别的类型。"); } ObjectType objectType = new ObjectType(typeName, displayTypeName, fields); @@ -233,7 +234,7 @@ public class FieldUtil { private static FieldType constructEntityFieldType(TypeBuildingContext elementContext, TypeBuildingContext parentContext) { GspAssociationCollection associations = elementContext.getAssociations(); if (associations == null || associations.size() == 0) { - throw new RuntimeException("字段" + elementContext.getParams().get("name") + "不包含关联实体信息。"); + throw new WebCustomException("字段" + elementContext.getParams().get("name") + "不包含关联实体信息。"); } TypeBuildingContext originalFieldContext = TypeBuildingContext.createSimpleTypeContextFromAssociation(elementContext, parentContext); Field originalField = constructField(originalFieldContext, parentContext); diff --git a/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/util/TypeBuildingContext.java b/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/util/TypeBuildingContext.java index 0565db3132dd65f3bf2a677c5774fbdc332bd215..a8f0cbccfde048702f946c6fa83b070a9ad4ec8c 100644 --- a/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/util/TypeBuildingContext.java +++ b/approval-format/web-approval-format-core/src/main/java/com/inspur/edp/web/approvalformat/core/util/TypeBuildingContext.java @@ -24,6 +24,7 @@ import com.inspur.edp.cef.designtime.api.element.GspElementObjectType; import com.inspur.edp.das.commonmodel.entity.GspCommonElement; import com.inspur.edp.udt.designtime.api.entity.SimpleDataTypeDef; import com.inspur.edp.udt.designtime.api.entity.element.UdtElement; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.utility.StringUtility; import lombok.Data; import org.springframework.util.StringUtils; @@ -183,7 +184,7 @@ public class TypeBuildingContext { public static TypeBuildingContext create(UdtElement udtTypeDef, TypeBuildingContext parentContext) { if (udtTypeDef.getIsUdt()) { if (StringUtility.isNullOrEmpty(udtTypeDef.getUdtID()) || StringUtility.isNullOrEmpty(udtTypeDef.getUdtID().trim())) { - throw new RuntimeException("标识为" + udtTypeDef.getId() + ",标签为" + udtTypeDef.getLabelID() + "的字段" + udtTypeDef.getName() + "被定义为'UnifiedDataType'字段,但是没有指定'UnifiedDataType'标识,请检查业务实体。"); + throw new WebCustomException("标识为" + udtTypeDef.getId() + ",标签为" + udtTypeDef.getLabelID() + "的字段" + udtTypeDef.getName() + "被定义为'UnifiedDataType'字段,但是没有指定'UnifiedDataType'标识,请检查业务实体。"); } } TypeBuildingContext typeBuildingContext = new TypeBuildingContext() { diff --git a/approval-format/web-approval-format-rpc/src/main/java/com/inspur/edp/web/approvalformat/rpc/service/deployapprovalformat/DeployApprovalFormatImpl.java b/approval-format/web-approval-format-rpc/src/main/java/com/inspur/edp/web/approvalformat/rpc/service/deployapprovalformat/DeployApprovalFormatImpl.java index a975a7f37c4639a531c4cf7425347d6a3c30b58a..3fda93181ecd1260b441029c4bdb2dc9127b6f98 100644 --- a/approval-format/web-approval-format-rpc/src/main/java/com/inspur/edp/web/approvalformat/rpc/service/deployapprovalformat/DeployApprovalFormatImpl.java +++ b/approval-format/web-approval-format-rpc/src/main/java/com/inspur/edp/web/approvalformat/rpc/service/deployapprovalformat/DeployApprovalFormatImpl.java @@ -17,6 +17,7 @@ package com.inspur.edp.web.approvalformat.rpc.service.deployapprovalformat; import com.fasterxml.jackson.databind.JsonNode; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.jitruntimebuild.scriptcache.api.entity.ScriptCacheResponse; import com.inspur.edp.web.jitruntimebuild.scriptcache.localserver.LocalServerVersionManager; import io.iec.edp.caf.commons.utils.SpringBeanUtils; @@ -42,10 +43,10 @@ public class DeployApprovalFormatImpl implements DeployApprovalFormat { result.put("flag", "true"); // 是否解析型 return result; } else { - throw new RuntimeException(scriptCacheResponse.getErrorMessage()); + throw new WebCustomException(scriptCacheResponse.getErrorMessage()); } } else { - throw new RuntimeException("beforeNavigate 参数转换失败"); + throw new WebCustomException("beforeNavigate 参数转换失败"); } } } diff --git a/form-process/web-form-process/pom.xml b/form-process/web-form-process/pom.xml index 18ba3de69aa879f6890ff969018a339d6e64c25b..f7b480b5da163a462f4a82a2098748bbab4f9e62 100644 --- a/form-process/web-form-process/pom.xml +++ b/form-process/web-form-process/pom.xml @@ -21,13 +21,13 @@ form-process com.inspur.edp - ${custom.version} + 0.1.9-SNAPSHOT 4.0.0 web-form-process jar - ${custom.version} + io.iec.edp @@ -37,13 +37,6 @@ com.inspur.edp lcm-metadata-api - 0.1.23 - - - com.inspur.edp - lcm-metadata-api - 0.1.23 - compile com.inspur.edp @@ -72,4 +65,4 @@ - \ No newline at end of file + diff --git a/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/config/NpmPackageConfiguration.java b/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/config/NpmPackageConfiguration.java index 5c8f785893079faa65d1728cd0e5ca1292e1e842..bfa61e790493d5de4ca80a01d7257510cd8cf4a2 100644 --- a/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/config/NpmPackageConfiguration.java +++ b/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/config/NpmPackageConfiguration.java @@ -27,7 +27,7 @@ import org.springframework.context.annotation.Configuration; /** * @author guozhiqi */ -@Configuration +@Configuration(proxyBeanMethods = false) public class NpmPackageConfiguration { @Bean public NpmPackageWebService npmPackageWebService() { diff --git a/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/config/NpmPackageInstallConfiguration.java b/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/config/NpmPackageInstallConfiguration.java index ea359d710f51517dc89bc105bcec3636bb8f808f..985722a1cf5194a54c8610f41e9b0e6d90188fee 100644 --- a/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/config/NpmPackageInstallConfiguration.java +++ b/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/config/NpmPackageInstallConfiguration.java @@ -24,7 +24,7 @@ import io.iec.edp.caf.rest.RESTEndpoint; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -@Configuration +@Configuration(proxyBeanMethods = false) public class NpmPackageInstallConfiguration { @Bean public NpmPackageInstallWebService npmPackageInstallWebService() { diff --git a/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/npminstall/NpmInstallManager.java b/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/npminstall/NpmInstallManager.java index bf2d00440fab19d57384d19af47492dca65a183b..5e9544f8cc4e7fb4307be0dc16853f1d7a3062d0 100644 --- a/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/npminstall/NpmInstallManager.java +++ b/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/npminstall/NpmInstallManager.java @@ -270,6 +270,7 @@ public class NpmInstallManager { FileUtility.deleteFile(lockFilePath); } } catch (Exception ignored) { + WebLogger.Instance.info("deleteLockFile failed " + ignored.getMessage()); } } diff --git a/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/npmsetting/NpmSettingConvertor.java b/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/npmsetting/NpmSettingConvertor.java index 1e87ecdc46052bbcc553deb455300ebc74b739be..ece0bda8ad70a1a1c6dd5391e86a978edb05cd6a 100644 --- a/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/npmsetting/NpmSettingConvertor.java +++ b/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/npmsetting/NpmSettingConvertor.java @@ -16,6 +16,7 @@ package com.inspur.edp.web.npmpackage.core.npmsetting; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.environment.ExecuteEnvironment; import com.inspur.edp.web.npmpackage.api.entity.NpmInstallParameter; import com.inspur.edp.web.npmpackage.api.entity.settings.NpmRepository; @@ -42,7 +43,7 @@ public class NpmSettingConvertor { } // 如果获取到的仓库实例为空 if (currentRepository == null) { - throw new RuntimeException("未获取到npm配置仓库实例"); + throw new WebCustomException("未获取到npm配置仓库实例"); } npmInstallParameter.setUserName(currentRepository.getUserName()); diff --git a/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/webservice/NpmPackageInstallWebServiceImpl.java b/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/webservice/NpmPackageInstallWebServiceImpl.java index 73efdcaa054f88cad1569b4eb74a8664acd3f541..552811acafb0b5094e48caba15ab12c46430b73f 100644 --- a/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/webservice/NpmPackageInstallWebServiceImpl.java +++ b/npmpackage/web-npmpackage-core/src/main/java/com/inspur/edp/web/npmpackage/core/webservice/NpmPackageInstallWebServiceImpl.java @@ -16,6 +16,7 @@ package com.inspur.edp.web.npmpackage.core.webservice; +import com.inspur.edp.web.common.logger.WebLogger; import com.inspur.edp.web.common.utility.CommonUtility; import com.inspur.edp.web.npmpackage.api.entity.NpmInstallParameter; import com.inspur.edp.web.npmpackage.api.entity.NpmPackageResponse; @@ -28,6 +29,8 @@ import com.inspur.edp.web.npmpackage.core.npmsetting.NpmSettingEncryptService; import com.inspur.edp.web.npmpackage.core.npmsetting.NpmSettingManager; import io.iec.edp.caf.commons.utils.SpringBeanUtils; +import java.util.Arrays; + /** * npm 包安装webservice * @@ -55,7 +58,7 @@ public class NpmPackageInstallWebServiceImpl implements NpmPackageInstallWebServ npmSettings.setLastUpdated(CommonUtility.getCurrentDateString()); NpmSettingManager.saveNpmSetting(npmSettings); } catch (Exception ignored) { - + WebLogger.Instance.info("npm install failed " + ignored.getMessage() + Arrays.toString(ignored.getStackTrace())); } return npmPackageResponse; diff --git a/pom.xml b/pom.xml index 5108f4575f74829bd12216053126c4d34b569593..f7e652abf2426d8b8f2a94b894fcd9151140dd5a 100644 --- a/pom.xml +++ b/pom.xml @@ -46,6 +46,9 @@ form-process metadata tsfile + + web-formmetadata-relycheck + @@ -131,6 +134,12 @@ ${custom.version} compile + + com.inspur.edp + web-formconfig-api + ${custom.version} + compile + com.inspur.edp web-jitengine-web-core @@ -356,7 +365,7 @@ com.inspur.edp lcm-metadata-spi - 0.1.37 + 0.1.40-SNAPSHOT compile @@ -456,11 +465,7 @@ bef-api 0.2.2 - - com.inspur.edp - udt-designtime-api - 0.1.7 - + com.inspur.edp bef-bizentity diff --git a/relycheck/noah-test/pom.xml b/relycheck/noah-test/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..b621822f0f5847f8b9ce313447b4ffd998b65025 --- /dev/null +++ b/relycheck/noah-test/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + com.inspur.edp + web + 0.1.9-SNAPSHOT + ../../pom.xml + + + noah-test + jar + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + true + test + + + + \ No newline at end of file diff --git a/relycheck/noah-test/src/main/java/com/noah/NoahApplication.java b/relycheck/noah-test/src/main/java/com/noah/NoahApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..907125863bcddb5086fa9764df6077d72fa64df5 --- /dev/null +++ b/relycheck/noah-test/src/main/java/com/noah/NoahApplication.java @@ -0,0 +1,36 @@ +package com.noah; + +import com.noah.config.NoahConfiguration; +import com.noah.service.MyBean; +import com.noah.service.YourBean; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; + +import java.util.Arrays; + +/** + * @author noah + * 2023/8/7 10:40 + */ +@SpringBootApplication +public class NoahApplication { + public static void main(String[] args) { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); + context.register(NoahConfiguration.class); + context.refresh(); + + System.out.println(context.getBean(YourBean.class)); + + System.out.println(context.getBean(MyBean.class)); + System.out.println(context.getBean(MyBean.class)); + + System.out.println(context.getBean(NoahConfiguration.class)); + System.out.println(context.getBean(NoahConfiguration.class).myBean()); + Arrays.stream(context.getBeanDefinitionNames()).forEach(t-> System.out.println(t)); + + context.close(); + + } +} diff --git a/relycheck/noah-test/src/main/java/com/noah/config/NoahConfiguration.java b/relycheck/noah-test/src/main/java/com/noah/config/NoahConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..3fd21b80787aa4f536501cc1aba092e6dfb33f30 --- /dev/null +++ b/relycheck/noah-test/src/main/java/com/noah/config/NoahConfiguration.java @@ -0,0 +1,26 @@ +package com.noah.config; + +import com.noah.service.MyBean; +import com.noah.service.YourBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author noah + * 2023/8/7 10:41 + */ +@Configuration(proxyBeanMethods = true) +public class NoahConfiguration { + + @Bean(name = "noahMyBean") + public MyBean myBean() { + return new MyBean(); + } + + @Bean(name = "noahYourBean") + public YourBean yourBean(MyBean myBean) { + // 直接调用 不会执行 bean 的生命周期 + return new YourBean(myBean); + } + +} diff --git a/relycheck/noah-test/src/main/java/com/noah/service/MyBean.java b/relycheck/noah-test/src/main/java/com/noah/service/MyBean.java new file mode 100644 index 0000000000000000000000000000000000000000..a87eca1c8e3006a66542541d6c92ea0ab011d98a --- /dev/null +++ b/relycheck/noah-test/src/main/java/com/noah/service/MyBean.java @@ -0,0 +1,14 @@ +package com.noah.service; + +import javax.annotation.PostConstruct; + +/** + * @author noah + * 2023/8/7 13:41 + */ +public class MyBean { + @PostConstruct + public void init() { + System.out.println("my bean init"); + } +} diff --git a/relycheck/noah-test/src/main/java/com/noah/service/YourBean.java b/relycheck/noah-test/src/main/java/com/noah/service/YourBean.java new file mode 100644 index 0000000000000000000000000000000000000000..869d5e8781c43b48ceb143906a9c89a1710f5ba2 --- /dev/null +++ b/relycheck/noah-test/src/main/java/com/noah/service/YourBean.java @@ -0,0 +1,21 @@ +package com.noah.service; + +import javax.annotation.PostConstruct; + +/** + * @author noah + * 2023/8/7 13:41 + */ +public class YourBean { + + private final MyBean myBean; + + public YourBean(MyBean myBean) { + this.myBean = myBean; + } + + @PostConstruct + public void init() { + System.out.println("your bean init"); + } +} diff --git a/relycheck/pom.xml b/relycheck/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..cc9b838991e74e2e9635f421c28d90292e904f2d --- /dev/null +++ b/relycheck/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + com.inspur.edp + web-jitengine-formmetadata + 0.1.9-SNAPSHOT + + + relycheck + pom + + web-formmetadata-relycheck + + diff --git a/runtime/runtime-core/src/main/java/com/inspur/edp/web/jitruntimebuild/core/config/JitBuildConfiguration.java b/runtime/runtime-core/src/main/java/com/inspur/edp/web/jitruntimebuild/core/config/JitBuildConfiguration.java index 46138c478f7711e6aaf42be3055130180ebda2ad..0d5fcfbec124fba2eac661b97ba71dd048cee9ac 100644 --- a/runtime/runtime-core/src/main/java/com/inspur/edp/web/jitruntimebuild/core/config/JitBuildConfiguration.java +++ b/runtime/runtime-core/src/main/java/com/inspur/edp/web/jitruntimebuild/core/config/JitBuildConfiguration.java @@ -30,7 +30,7 @@ import org.springframework.context.annotation.Configuration; public class JitBuildConfiguration { @Bean - public JitBuildService JitBuildService(){ + public JitBuildService jitBuildService(){ return new JitBuildServiceImp(); } diff --git a/runtime/runtime-core/src/main/java/com/inspur/edp/web/jitruntimebuild/core/formjsonfilegenerator/FrmJsonFileGenerator.java b/runtime/runtime-core/src/main/java/com/inspur/edp/web/jitruntimebuild/core/formjsonfilegenerator/FrmJsonFileGenerator.java index 85e809ac5f314c7b215ad4677ce0bc6e7d30cfec..eea73dc72a97432fb99b44c298be36024ee87a4b 100644 --- a/runtime/runtime-core/src/main/java/com/inspur/edp/web/jitruntimebuild/core/formjsonfilegenerator/FrmJsonFileGenerator.java +++ b/runtime/runtime-core/src/main/java/com/inspur/edp/web/jitruntimebuild/core/formjsonfilegenerator/FrmJsonFileGenerator.java @@ -256,7 +256,6 @@ public class FrmJsonFileGenerator extends AbstractFormJsonFileGenerator implemen return getterMetadataInfo; }, this.getExecuteEnvironment(), this.isUpgradeTool()); - String[] params = {externalVisualDom.getExternalComponentPath(), externalVisualDom.getJson().getModule().getCode()}; try { resolveFormMetadataWithVisualDom(formMetadata, externalVisualDom.getJson(), diff --git a/runtime/runtime-core/src/main/java/com/inspur/edp/web/jitruntimebuild/core/service/JitBuildServiceImp.java b/runtime/runtime-core/src/main/java/com/inspur/edp/web/jitruntimebuild/core/service/JitBuildServiceImp.java index e068453b7aa21b3bef82ea3d65ccdfa89e873c2b..e62646f061ccfe8b87ef6c8d8540f7de151c628f 100644 --- a/runtime/runtime-core/src/main/java/com/inspur/edp/web/jitruntimebuild/core/service/JitBuildServiceImp.java +++ b/runtime/runtime-core/src/main/java/com/inspur/edp/web/jitruntimebuild/core/service/JitBuildServiceImp.java @@ -80,7 +80,7 @@ public class JitBuildServiceImp implements JitBuildService { FileUtility.deleteFolder(sourceServicePath); WebLogger.Instance.info("delete service path ,the service path is " + sourceServicePath, CurrentClassName); } catch (Exception ignored) { - + WebLogger.Instance.info("delete service path failed ,the service path is " + sourceServicePath + " " + Arrays.toString(ignored.getStackTrace()), CurrentClassName); } // 生成具体的json文件 @@ -148,6 +148,7 @@ public class JitBuildServiceImp implements JitBuildService { /** * 构造对应的编译上下文参数 + * * @param buildParameter * @return */ diff --git a/scriptcache/runtime-scriptcache/libs/bef-engine-core-0.1.12.jar b/scriptcache/runtime-scriptcache/libs/bef-engine-core-0.1.12.jar new file mode 100644 index 0000000000000000000000000000000000000000..b9ed7c9fd5cb0b5745507634c10b4cb4c0138c21 Binary files /dev/null and b/scriptcache/runtime-scriptcache/libs/bef-engine-core-0.1.12.jar differ diff --git a/scriptcache/runtime-scriptcache/libs/bef-engine-core.jar b/scriptcache/runtime-scriptcache/libs/bef-engine-core.jar new file mode 100644 index 0000000000000000000000000000000000000000..bee5febb42a4f20c4eb3b549dc156e10fc7a0e08 Binary files /dev/null and b/scriptcache/runtime-scriptcache/libs/bef-engine-core.jar differ diff --git a/scriptcache/runtime-scriptcache/libs/bff-engine-core-0.1.4.jar b/scriptcache/runtime-scriptcache/libs/bff-engine-core-0.1.4.jar new file mode 100644 index 0000000000000000000000000000000000000000..fcfa913205a68e546519930ee7bdd3b8e794bcc5 Binary files /dev/null and b/scriptcache/runtime-scriptcache/libs/bff-engine-core-0.1.4.jar differ diff --git a/scriptcache/runtime-scriptcache/libs/bff-engine-core.jar b/scriptcache/runtime-scriptcache/libs/bff-engine-core.jar new file mode 100644 index 0000000000000000000000000000000000000000..9f9ff5151d6ec6b442634908cac6a19ebc8434e5 Binary files /dev/null and b/scriptcache/runtime-scriptcache/libs/bff-engine-core.jar differ diff --git a/scriptcache/runtime-scriptcache/libs/cdp-sgf-api.jar b/scriptcache/runtime-scriptcache/libs/cdp-sgf-api.jar new file mode 100644 index 0000000000000000000000000000000000000000..b16f77f06f1c0d8c5db62d2e93a2049626369dd9 Binary files /dev/null and b/scriptcache/runtime-scriptcache/libs/cdp-sgf-api.jar differ diff --git a/scriptcache/runtime-scriptcache/libs/lcm-metadata-api.jar b/scriptcache/runtime-scriptcache/libs/lcm-metadata-api.jar new file mode 100644 index 0000000000000000000000000000000000000000..0581143447cfe4937e206c2938317ecff6c32d22 Binary files /dev/null and b/scriptcache/runtime-scriptcache/libs/lcm-metadata-api.jar differ diff --git a/scriptcache/runtime-scriptcache/libs/task-api-0.3.11.jar b/scriptcache/runtime-scriptcache/libs/task-api-0.3.11.jar new file mode 100644 index 0000000000000000000000000000000000000000..30572addaa44da10029bb506fc617b386f7f8b6a Binary files /dev/null and b/scriptcache/runtime-scriptcache/libs/task-api-0.3.11.jar differ diff --git a/scriptcache/runtime-scriptcache/libs/web-jitengine-frontendproject-api.jar b/scriptcache/runtime-scriptcache/libs/web-jitengine-frontendproject-api.jar new file mode 100644 index 0000000000000000000000000000000000000000..1a1960bf13dd2ce499bed8ae6da7788839545c18 Binary files /dev/null and b/scriptcache/runtime-scriptcache/libs/web-jitengine-frontendproject-api.jar differ diff --git a/scriptcache/runtime-scriptcache/libs/web-jitengine-frontendproject.jar b/scriptcache/runtime-scriptcache/libs/web-jitengine-frontendproject.jar new file mode 100644 index 0000000000000000000000000000000000000000..a0428bb5f4a043d98b91b9a0c6b2f7f8593cc573 Binary files /dev/null and b/scriptcache/runtime-scriptcache/libs/web-jitengine-frontendproject.jar differ diff --git a/scriptcache/runtime-scriptcache/pom.xml b/scriptcache/runtime-scriptcache/pom.xml index 87c56c85b4c08eedccc19a615cc29e3689426242..b575ead5fa82c133bd6e7c6a3da7900b55b0d6fa 100644 --- a/scriptcache/runtime-scriptcache/pom.xml +++ b/scriptcache/runtime-scriptcache/pom.xml @@ -61,7 +61,7 @@ bef-engine-core 0.1.12 system - ${pom.basedir}/libs/bef-engine-core-0.1.12.jar + ${pom.basedir}/libs/bef-engine-core.jar com.inspur.edp diff --git a/scriptcache/runtime-scriptcache/src/main/java/com/inspur/edp/web/jitruntimebuild/scriptcache/config/ScriptCacheConfiguration.java b/scriptcache/runtime-scriptcache/src/main/java/com/inspur/edp/web/jitruntimebuild/scriptcache/config/ScriptCacheConfiguration.java index 4f5560a8801a3cb193353600727388d169fe9a68..98ddf0acf05e61d0f0be353d9be7390ee97d2c0c 100644 --- a/scriptcache/runtime-scriptcache/src/main/java/com/inspur/edp/web/jitruntimebuild/scriptcache/config/ScriptCacheConfiguration.java +++ b/scriptcache/runtime-scriptcache/src/main/java/com/inspur/edp/web/jitruntimebuild/scriptcache/config/ScriptCacheConfiguration.java @@ -35,7 +35,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -@Configuration +@Configuration(proxyBeanMethods = false) @EnableJpaRepositories("com.inspur.edp.web.jitruntimebuild.scriptcache.domain.repository") @EntityScan({"com.inspur.edp.web.jitruntimebuild.scriptcache.domain.entity"}) public class ScriptCacheConfiguration { @@ -76,7 +76,7 @@ public class ScriptCacheConfiguration { @Bean - public RESTEndpoint ScriptCacheWebServiceEndpoint(ScriptCacheWebServiceImpl webservice) { + public RESTEndpoint scriptCacheWebServiceEndpoint(ScriptCacheWebServiceImpl webservice) { return new RESTEndpoint("/runtime/jit/v1.0/scriptcache", webservice); } diff --git a/scriptcache/runtime-scriptcache/src/main/java/com/inspur/edp/web/jitruntimebuild/scriptcache/service/ScriptCacheServiceImpl.java b/scriptcache/runtime-scriptcache/src/main/java/com/inspur/edp/web/jitruntimebuild/scriptcache/service/ScriptCacheServiceImpl.java index 342b774e32c1dfe6aa184d62bfc94220810b9e6d..b98b3bbc028a4ac75743fc2502f207a099eab807 100644 --- a/scriptcache/runtime-scriptcache/src/main/java/com/inspur/edp/web/jitruntimebuild/scriptcache/service/ScriptCacheServiceImpl.java +++ b/scriptcache/runtime-scriptcache/src/main/java/com/inspur/edp/web/jitruntimebuild/scriptcache/service/ScriptCacheServiceImpl.java @@ -86,7 +86,7 @@ public class ScriptCacheServiceImpl implements ScriptCacheService { fileList.add(new File(filePath)); } - WebLogger.Instance.info("absoluteBaseDirectory:" + request.getAbsoluteBaseDirectory() + " 获取文件列表个数为:" + fileList.size()); + WebLogger.Instance.info("absoluteBaseDirectory:" + request.getAbsoluteBaseDirectory() + " 获取文件列表个数为:" + ListUtility.getLength(fileList)); // 如果存在文件列表 if (fileList != null && fileList.size() > 0) { FormProjectCache finalFormProjectCache = formProjectCache; @@ -96,7 +96,6 @@ public class ScriptCacheServiceImpl implements ScriptCacheService { pubishScript(t, request.getMetaDataId(), finalFormProjectCache, request); } }); - } // 保存元数据版本 diff --git a/toout.bat b/toout.bat index b217e9c7779aba9a9df60a9cc8ace9d3b12827df..fc96c05d9d55debfc37430042f68aa66e6666ee3 100644 --- a/toout.bat +++ b/toout.bat @@ -64,6 +64,8 @@ COPY .\web-npmpackage-core\target\web-npmpackage-core-%version%.jar .\out\server COPY .\web-formconfig-api\target\web-formconfig-api-%version%.jar .\out\server\platform\common\libs\web-formconfig-api.jar COPY .\web-formconfig-core\target\web-formconfig-core-%version%.jar .\out\server\platform\common\libs\web-formconfig-core.jar + +COPY .\web-formmetadata-relycheck\target\web-formmetadata-relycheck-%version%.jar .\out\server\platform\common\libs\web-formmetadata-relycheck.jar ::pause ::pause diff --git a/toout.sh b/toout.sh new file mode 100755 index 0000000000000000000000000000000000000000..f7c7caebadc079908be7f57f6871fc600d6d71ea --- /dev/null +++ b/toout.sh @@ -0,0 +1,63 @@ +version=$(sed -n 's/.*\([^<]*\)<\/custom.version>.*/\1/p' pom.xml) +echo $version +rm -rf out + +mkdir -p out/server/platform/dev/main/libs +mkdir -p out/server/platform/common/libs +mkdir -p out/server/platform/runtime/bcc/libs +cp web-appconfig-core/target/web-appconfig-core-$version.jar ./out/server/platform/common/libs/web-appconfig-core.jar +cp web-appconfig-manager/target/web-appconfig-manager-$version.jar ./out/server/platform/dev/main/libs/web-appconfig-manager.jar +cp web-appconfig-webapi/target/web-appconfig-webapi-$version.jar ./out/server/platform/dev/main/libs/web-appconfig-webapi.jar +cp web-common/target/web-common-$version.jar ./out/server/platform/common/libs/web-common.jar + +cp runtime-api/target/web-jitengine-runtimebuild-api-$version.jar ./out/server/platform/common/libs/web-jitengine-runtimebuild-api.jar +cp runtime-core/target/web-jitengine-runtimebuild-core-$version.jar ./out/server/platform/common/libs/web-jitengine-runtimebuild-core.jar + +cp runtime-scriptcache/target/web-jitengine-runtimebuild-scriptcache-$version.jar ./out/server/platform/common/libs/web-jitengine-runtimebuild-scriptcache.jar +cp runtime-scriptcache-api/target/web-jitengine-runtimebuild-scriptcache-api-$version.jar ./out/server/platform/common/libs/web-jitengine-runtimebuild-scriptcache-api.jar + +cp web-appconfig-core/target/web-appconfig-core-$version.jar ./out/server/platform/common/libs/web-appconfig-core.jar +cp web-appconfig-api/target/web-appconfig-api-$version.jar ./out/server/platform/common/libs/web-appconfig-api.jar + +cp web-common/target/web-jitengine-common-$version.jar ./out/server/platform/common/libs/web-jitengine-common.jar + + +cp web-form-jitengine/target/web-jitengine-$version.jar ./out/server/platform/common/libs/web-jitengine.jar + +cp web-form-metadata/target/web-jitengine-formmetadata-$version.jar ./out/server/platform/common/libs/web-jitengine-formmetadata.jar +cp web-form-metadata-api/target/web-jitengine-formmetadata-api-$version.jar ./out/server/platform/common/libs/web-jitengine-formmetadata-api.jar + +cp web-frontendproject/target/web-jitengine-frontendproject-$version.jar ./out/server/platform/common/libs/web-jitengine-frontendproject.jar +cp web-frontendproject-api/target/web-jitengine-frontendproject-api-$version.jar ./out/server/platform/common/libs/web-jitengine-frontendproject-api.jar + +cp web-designschema/target/web-designschema-$version.jar ./out/server/platform/common/libs/web-designschema.jar +cp web-designschema-api/target/web-designschema-api-$version.jar ./out/server/platform/common/libs/web-designschema-api.jar + +cp web-dynamic-form-api/target/web-dynamicform-api-$version.jar ./out/server/platform/common/libs/web-dynamicform-api.jar +cp web-dynamic-form-core/target/web-dynamicform-core-$version.jar ./out/server/platform/common/libs/web-dynamicform-core.jar + +cp web-pageflow-metadata/target/web-pageflow-metadata-$version.jar ./out/server/platform/common/libs/web-pageflow-metadata.jar +cp web-statemachine/target/web-statemachine-metadata-$version.jar ./out/server/platform/common/libs/web-statemachine-metadata.jar + +cp web-sourcecode-metadata/target/web-sourcecode-metadata-$version.jar ./out/server/platform/common/libs/web-sourcecode-metadata.jar + +cp web-tsfile-api/target/web-tsfile-api-$version.jar ./out/server/platform/common/libs/web-tsfile-api.jar +cp web-tsfile-core/target/web-tsfile-core-$version.jar ./out/server/platform/common/libs/web-tsfile-core.jar + +cp jitengine-web-api/target/web-jitengine-web-api-$version.jar ./out/server/platform/common/libs/web-jitengine-web-api.jar +cp jitengine-web-core/target/web-jitengine-web-core-$version.jar ./out/server/platform/common/libs/web-jitengine-web-core.jar + +cp web-approval-format-api/target/web-approval-format-api-$version.jar ./out/server/platform/runtime/bcc/libs/web-approval-format-api.jar +cp web-approval-format-core/target/web-approval-format-core-$version.jar ./out/server/platform/runtime/bcc/libs/web-approval-format-core.jar +cp web-approval-format-rpc/target/web-approval-format-rpc-$version.jar ./out/server/platform/common/libs/web-approval-format-rpc.jar + +cp web-npmpackage-api/target/web-npmpackage-api-$version.jar ./out/server/platform/common/libs/web-npmpackage-api.jar +cp web-npmpackage-core/target/web-npmpackage-core-$version.jar ./out/server/platform/common/libs/web-npmpackage-core.jar + +cp web-npmpackage-api/target/web-npmpackage-api-$version.jar ./out/server/platform/common/libs/web-npmpackage-api.jar +cp web-npmpackage-core/target/web-npmpackage-core-$version.jar ./out/server/platform/common/libs/web-npmpackage-core.jar + +cp web-formconfig-api/target/web-formconfig-api-$version.jar ./out/server/platform/common/libs/web-formconfig-api.jar +cp web-formconfig-core/target/web-formconfig-core-$version.jar ./out/server/platform/common/libs/web-formconfig-core.jar + +cp web-formmetadata-relycheck/target/web-formmetadata-relycheck-$version.jar ./out/server/platform/dev/main/libs/web-formmetadata-relycheck.jar diff --git a/web-common/src/main/java/com/inspur/edp/web/common/encrypt/EncryptUtility.java b/web-common/src/main/java/com/inspur/edp/web/common/encrypt/EncryptUtility.java index 3a2a12a4565392a620a70a32ace732cabbff7433..706184cbdcd0bbd2337d32eab10fa5c3791df0f5 100644 --- a/web-common/src/main/java/com/inspur/edp/web/common/encrypt/EncryptUtility.java +++ b/web-common/src/main/java/com/inspur/edp/web/common/encrypt/EncryptUtility.java @@ -16,6 +16,7 @@ package com.inspur.edp.web.common.encrypt; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.logger.WebLogger; import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; @@ -312,7 +313,7 @@ public class EncryptUtility { try { result = Base64.encode(res.getBytes(charset)); } catch (Exception e) { - throw new RuntimeException("编码失败:" + res, e); + throw new WebCustomException("编码失败:" + res, e); } return result; } @@ -330,7 +331,7 @@ public class EncryptUtility { try { return new String(Base64.decode(res), charset); } catch (Exception e) { - throw new RuntimeException("base64Decode失败", e); + throw new WebCustomException("base64Decode失败", e); } } diff --git a/web-common/src/main/java/com/inspur/edp/web/common/entity/TerminalType.java b/web-common/src/main/java/com/inspur/edp/web/common/entity/TerminalType.java index a7514b23468f59d0082918c82d55a8d22ee76cd2..6e64ac17352b672219173a86012df15ec4e0af52 100644 --- a/web-common/src/main/java/com/inspur/edp/web/common/entity/TerminalType.java +++ b/web-common/src/main/java/com/inspur/edp/web/common/entity/TerminalType.java @@ -435,7 +435,7 @@ public enum TerminalType { } else if (TerminalType.MOBILE.getMetadataType().equals(sourceMetadataType)) { return TerminalType.MOBILE; } else { - throw new RuntimeException("未知的数据类型转换成TerminalType,对应数据类型为:" + sourceMetadataType); + throw new WebCustomException("未知的数据类型转换成TerminalType,对应数据类型为:" + sourceMetadataType); } } diff --git a/web-common/src/main/java/com/inspur/edp/web/common/io/FileUtility.java b/web-common/src/main/java/com/inspur/edp/web/common/io/FileUtility.java index 02bd37dc70ab6ac7c6b602481cea2aaa27adcaa1..d57290c3432dc739be3fb9c678a032538ceb28ab 100644 --- a/web-common/src/main/java/com/inspur/edp/web/common/io/FileUtility.java +++ b/web-common/src/main/java/com/inspur/edp/web/common/io/FileUtility.java @@ -154,7 +154,7 @@ public class FileUtility { in.close(); } catch (IOException e) { WebLogger.Instance.error(e); - throw new RuntimeException("readAsString failed", e); + throw new WebCustomException("readAsString failed", e); } try { @@ -201,6 +201,7 @@ public class FileUtility { file.setWritable(true, false); file.setExecutable(true, false); } catch (Exception ex) { + WebLogger.Instance.info(ex.getMessage()); } } @@ -228,7 +229,7 @@ public class FileUtility { try { FileUtils.forceDelete(new File(directoryPath)); } catch (IOException e) { - throw new RuntimeException(e.getMessage(), e); + throw new WebCustomException(e.getMessage(), e); } } } @@ -774,7 +775,7 @@ public class FileUtility { String absolutePath = new File(currentPath).getAbsolutePath(); int index = absolutePath.indexOf(':'); if (index <= 0) { - throw new RuntimeException("Get Directory Root Failed When doing the GetPathVolume function"); + throw new WebCustomException("Get Directory Root Failed When doing the GetPathVolume function"); } absolutePathHead = absolutePath.substring(index - 1, 2); } else { diff --git a/web-common/src/main/java/com/inspur/edp/web/common/logger/WebLogger.java b/web-common/src/main/java/com/inspur/edp/web/common/logger/WebLogger.java index 5fd1045f71c20f7d32a0315efc31026b51538c65..3d14522c0a6a20ebe1406be9f4dd9883cbba1b2a 100644 --- a/web-common/src/main/java/com/inspur/edp/web/common/logger/WebLogger.java +++ b/web-common/src/main/java/com/inspur/edp/web/common/logger/WebLogger.java @@ -24,7 +24,8 @@ import java.util.Arrays; /** * web 统一的日志输出类 使用枚举的目的是为了保证绝对单例 - * @author noah + * + * @author noah */ public enum WebLogger { /** @@ -165,7 +166,7 @@ public enum WebLogger { if (StringUtility.isNullOrEmpty(customErrorMessage)) { this.error(ex, loggerName); } else { - this.error(customErrorMessage + ex.getMessage() + ex.getStackTrace(), loggerName); + this.error(customErrorMessage + ex.getMessage() + Arrays.toString(ex.getStackTrace()), loggerName); } } diff --git a/web-common/src/main/java/com/inspur/edp/web/common/metadata/MetadataUtility.java b/web-common/src/main/java/com/inspur/edp/web/common/metadata/MetadataUtility.java index c1dc4826dab47bd1fc0b071f3c31e51fefc2be84..970eba13c2cbc8a0c4057dbee765fd46bcb712c1 100644 --- a/web-common/src/main/java/com/inspur/edp/web/common/metadata/MetadataUtility.java +++ b/web-common/src/main/java/com/inspur/edp/web/common/metadata/MetadataUtility.java @@ -305,7 +305,7 @@ public final class MetadataUtility { try { commandMetadataContent = (WebCommandsMetadata) commandMetadata.getContent(); } catch (RuntimeException e) { - throw new WebCustomException("当前元数据非命令元数据。元数据id是:" + commandMetadata.getHeader().getId()); + throw new WebCustomException("当前元数据非命令元数据。元数据id是:" + commandMetadata.getHeader().getId(), e); } if (commandMetadataContent == null) { diff --git a/web-common/src/main/java/com/inspur/edp/web/common/serialize/SerializeUtility.java b/web-common/src/main/java/com/inspur/edp/web/common/serialize/SerializeUtility.java index 2823c0fc7d4eef9889482d82691a99753b54ae2c..5ebd3e15fd028b7a9872ccae6675cbd59894ab5e 100644 --- a/web-common/src/main/java/com/inspur/edp/web/common/serialize/SerializeUtility.java +++ b/web-common/src/main/java/com/inspur/edp/web/common/serialize/SerializeUtility.java @@ -21,6 +21,7 @@ import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.*; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.logger.WebLogger; import java.io.IOException; @@ -105,7 +106,7 @@ public class SerializeUtility { try { return defaultObjectMapper.readValue(contentString, valueTypeRef); } catch (JsonProcessingException e) { - throw new RuntimeException(e); + throw new WebCustomException("反序列化失败", e); } } @@ -267,7 +268,7 @@ public class SerializeUtility { return objectJsonNode; } catch (JsonProcessingException e) { WebLogger.Instance.error(e); - throw new RuntimeException(e); + throw new WebCustomException("readTree执行失败",e); } } diff --git a/web-common/src/main/java/com/inspur/edp/web/common/utility/CommandExecuteInterceptor.java b/web-common/src/main/java/com/inspur/edp/web/common/utility/CommandExecuteInterceptor.java index 2c1e3ffe0b13681df32f0465bb6692c7cd284b2e..bd27664974ea24f90e0b37aa628bf0ef17881356 100644 --- a/web-common/src/main/java/com/inspur/edp/web/common/utility/CommandExecuteInterceptor.java +++ b/web-common/src/main/java/com/inspur/edp/web/common/utility/CommandExecuteInterceptor.java @@ -151,7 +151,9 @@ public class CommandExecuteInterceptor extends Thread { } finally { try { this.inputStream.close(); - br.close(); + if (br != null) { + br.close(); + } } catch (IOException ex) { WebLogger.Instance.error(ex); } diff --git a/web-common/src/main/java/com/inspur/edp/web/common/utility/CommandLineUtility.java b/web-common/src/main/java/com/inspur/edp/web/common/utility/CommandLineUtility.java index eb0493f987157d1d4a0a1d5e7f5b6c00f00ea325..c9b7b890a68a109ad96ff9ac8b9105b2d44f8afe 100644 --- a/web-common/src/main/java/com/inspur/edp/web/common/utility/CommandLineUtility.java +++ b/web-common/src/main/java/com/inspur/edp/web/common/utility/CommandLineUtility.java @@ -16,6 +16,7 @@ package com.inspur.edp.web.common.utility; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.logger.WebLogger; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.SystemUtils; @@ -73,12 +74,12 @@ public class CommandLineUtility { // 如果出现编译错误 那么通过异常的方式将错误信息进行抛出 // 增加自定义异常抛出 进行特定异常捕获 if (!StringUtility.isNullOrEmpty(errorMessage)) { - throw new RuntimeException("jit command executed failed!" + errorMessage); + throw new WebCustomException("jit command executed failed!" + errorMessage); } // 如果存在输出异常 那么不再继续执行 if (!StringUtility.isNullOrEmpty(errorSB.toString())) { - throw new RuntimeException("jit command executed failed!" + errorSB); + throw new WebCustomException("jit command executed failed!" + errorSB); } return errorMessage; @@ -135,7 +136,7 @@ public class CommandLineUtility { process = Runtime.getRuntime().exec(new String[]{"/bin/sh", "-c", updateCommand}); } if (updateCommand == null) { - throw new RuntimeException("不支持的操作系统类型,请联系开发人员处理"); + throw new WebCustomException("不支持的操作系统类型,请联系开发人员处理"); } return process; } @@ -162,7 +163,7 @@ public class CommandLineUtility { return "/bin/bash"; } - throw new RuntimeException("未识别的操作系统系统。请联系开发人员处理。"); + throw new WebCustomException("未识别的操作系统系统。请联系开发人员处理。"); } } diff --git a/web-common/src/main/java/com/inspur/edp/web/common/utility/ListUtility.java b/web-common/src/main/java/com/inspur/edp/web/common/utility/ListUtility.java index 17366d210c1367bf58a0185b1c85f13045611a41..f27fe9627dc99d232f8b66fedb2376379bb1d805 100644 --- a/web-common/src/main/java/com/inspur/edp/web/common/utility/ListUtility.java +++ b/web-common/src/main/java/com/inspur/edp/web/common/utility/ListUtility.java @@ -16,6 +16,7 @@ package com.inspur.edp.web.common.utility; +import java.util.ArrayList; import java.util.List; /** @@ -44,4 +45,71 @@ public class ListUtility { public static boolean isNotEmpty(List sourceList) { return !isEmpty(sourceList); } + + /** + * 获取列表的长度 + * + * @param sourceList + * @return + */ + public static int getLength(List sourceList) { + if (isEmpty(sourceList)) { + return 0; + } + return sourceList.size(); + } + + /** + * 将目标集合添加至源集合中 + * + * @param sourceList 源集合 + * @param targetList 目标集合 + * @param + */ + public static List add(List sourceList, List targetList) { + // 如果目标集合为空 那么不进行任何操作 + if (isEmpty(targetList)) { + return sourceList; + } + if (sourceList == null) { + sourceList = new ArrayList<>(); + } + sourceList.addAll(targetList); + return sourceList; + } + + /** + * 添加具体项至集合列表中 + * + * @param sourceList 源集合 + * @param element + * @param + */ + public static void add(List sourceList, T element) { + if (element == null) { + return; + } + if (sourceList == null) { + sourceList = new ArrayList<>(); + } + sourceList.add(element); + } + + /** + * 判断一个element是否在集合中存在 + * + * @param sourceList + * @param element + * @param + * @return + */ + public static boolean contains(List sourceList, T element) { + if (sourceList == null || sourceList.isEmpty()) { + return false; + } + if (element == null) { + return false; + } + return sourceList.contains(element); + } } diff --git a/web-common/src/main/java/com/inspur/edp/web/common/utility/LoggerUtility.java b/web-common/src/main/java/com/inspur/edp/web/common/utility/LoggerUtility.java index 0a241048d5f33646e5fb98dc7d348a9779f96193..5a3dadd1efd29f0c096d0bac456571cd9e16b93c 100644 --- a/web-common/src/main/java/com/inspur/edp/web/common/utility/LoggerUtility.java +++ b/web-common/src/main/java/com/inspur/edp/web/common/utility/LoggerUtility.java @@ -60,16 +60,6 @@ public class LoggerUtility { public static void log(String message, LoggerLevelEnum level, boolean printToBrowser, boolean includeMessageHeader) { log(message, level, includeMessageHeader); - if (printToBrowser) { - try { - if (!StringUtility.isNullOrEmpty(message)) { - // 由于分su问题 在运行时不存在此jar包 因此移除该jar包调用 - // LoggerDisruptorQueue.publishEvent(message); - } - } catch (Exception ignored) { - - } - } } public static void logToBrowser(String message, LoggerLevelEnum level) { diff --git a/web-common/src/test/java/com/inspur/edp/web/common/utility/ListUtilityTest.java b/web-common/src/test/java/com/inspur/edp/web/common/utility/ListUtilityTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cf7189fad1d9e243c4b6360ce50b202db2a923ed --- /dev/null +++ b/web-common/src/test/java/com/inspur/edp/web/common/utility/ListUtilityTest.java @@ -0,0 +1,126 @@ +package com.inspur.edp.web.common.utility; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + + +public class ListUtilityTest { + + @Test + public void testIsEmpty_withEmptyList_shouldReturnTrue() { + List list = new ArrayList<>(); + boolean result = ListUtility.isEmpty(list); + Assert.assertTrue(result); + } + + @Test + public void testIsEmpty_withNonEmptyList_shouldReturnFalse() { + List list = new ArrayList<>(); + list.add(1); + boolean result = ListUtility.isEmpty(list); + Assert.assertFalse(result); + } + + @Test + public void testIsNotEmpty_withEmptyList_shouldReturnFalse() { + List list = new ArrayList<>(); + boolean result = ListUtility.isNotEmpty(list); + Assert.assertFalse(result); + } + + @Test + public void testIsNotEmpty_withNonEmptyList_shouldReturnTrue() { + List list = new ArrayList<>(); + list.add(1); + boolean result = ListUtility.isNotEmpty(list); + Assert.assertTrue(result); + } + + @Test + public void testGetLength_withEmptyList_shouldReturnZero() { + List list = new ArrayList<>(); + int result = ListUtility.getLength(list); + Assert.assertEquals(0, result); + } + + @Test + public void testGetLength_withNonEmptyList_shouldReturnSize() { + List list = new ArrayList<>(); + list.add(1); + list.add(2); + int result = ListUtility.getLength(list); + Assert.assertEquals(2, result); + } + + @Test + public void testAdd_withNullSourceList_shouldAddTargetListToEmptyList() { + List sourceList = null; + List targetList = new ArrayList<>(); + targetList.add(1); + targetList.add(2); + sourceList = ListUtility.add(sourceList, targetList); + Assert.assertEquals(targetList, sourceList); + } + + @Test + public void testAdd_withNonNullSourceList_shouldAddTargetListToSourceList() { + List sourceList = new ArrayList<>(); + sourceList.add(1); + List targetList = new ArrayList<>(); + targetList.add(2); + targetList.add(3); + ListUtility.add(sourceList, targetList); + List expectedList = new ArrayList<>(); + expectedList.add(1); + expectedList.add(2); + expectedList.add(3); + Assert.assertEquals(expectedList, sourceList); + } + + @Test + public void testAdd_withNullElement_shouldNotAddToSourceList() { + List sourceList = new ArrayList<>(); + sourceList.add(1); + ListUtility.add(sourceList, new ArrayList<>()); + Assert.assertEquals(1, sourceList.size()); + } + + @Test + public void testAdd_withNonNullElement_shouldAddToSourceList() { + List sourceList = new ArrayList<>(); + sourceList.add(1); + ListUtility.add(sourceList, 2); + List expectedList = new ArrayList<>(); + expectedList.add(1); + expectedList.add(2); + Assert.assertEquals(expectedList, sourceList); + } + + @Test + public void testContains_withEmptyList_shouldReturnFalse() { + List list = new ArrayList<>(); + boolean result = ListUtility.contains(list, 1); + Assert.assertFalse(result); + } + + @Test + public void testContains_withNonEmptyListAndElementNotPresent_shouldReturnFalse() { + List list = new ArrayList<>(); + list.add(1); + list.add(2); + boolean result = ListUtility.contains(list, 3); + Assert.assertFalse(result); + } + + @Test + public void testContains_withNonEmptyListAndElementPresent_shouldReturnTrue() { + List list = new ArrayList<>(); + list.add(1); + list.add(2); + boolean result = ListUtility.contains(list, 2); + Assert.assertTrue(result); + } +} \ No newline at end of file diff --git a/web-designschema/pom.xml b/web-designschema/pom.xml index f18e29a25a9af6460b355e646236ab782e424851..38daaec97f772271b48f07a7d0e3e642b6e6da2c 100644 --- a/web-designschema/pom.xml +++ b/web-designschema/pom.xml @@ -26,6 +26,7 @@ 4.0.0 web-designschema + jar @@ -54,7 +55,7 @@ com.inspur.edp udt-designtime-api - 0.1.7 + 0.1.8 system ${pom.basedir}/libs/com.inspur.edp.udt.designtime.api.jar @@ -68,7 +69,7 @@ com.inspur.edp - caf-cef-schema + caf-cef-customSchema 0.1.7 system ${pom.basedir}/libs/caf-cef-schema.jar @@ -84,12 +85,6 @@ 0.2.85 compile - - com.inspur.edp - cef-api - 0.2.32 - compile - diff --git a/web-designschema/src/main/java/com/inspur/edp/web/designschema/generator/FieldBuilder.java b/web-designschema/src/main/java/com/inspur/edp/web/designschema/generator/FieldBuilder.java index a80f7455469d3cd06cdb300e925275d5b8f0948b..77e758ef9a9608265194e2bf728bdf1ec40ad6fe 100644 --- a/web-designschema/src/main/java/com/inspur/edp/web/designschema/generator/FieldBuilder.java +++ b/web-designschema/src/main/java/com/inspur/edp/web/designschema/generator/FieldBuilder.java @@ -29,6 +29,7 @@ import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; import com.inspur.edp.udt.designtime.api.entity.SimpleDataTypeDef; import com.inspur.edp.udt.designtime.api.nocode.BusinessField; import com.inspur.edp.udt.designtime.api.nocode.IBusinessFieldService; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.environment.ExecuteEnvironment; import com.inspur.edp.web.common.metadata.MetadataGetterParameter; import com.inspur.edp.web.common.metadata.MetadataTypeEnum; @@ -42,7 +43,6 @@ import com.inspur.edp.web.designschema.elements.type.EntityType; import com.inspur.edp.web.designschema.elements.type.FieldType; import com.inspur.edp.web.designschema.elements.type.ObjectType; import com.inspur.edp.web.designschema.udtextensiondef.FormUdtExtension; -import io.iec.edp.caf.commons.exception.CAFRuntimeException; import io.iec.edp.caf.commons.utils.SpringBeanUtils; import org.springframework.util.StringUtils; @@ -645,7 +645,7 @@ public class FieldBuilder { refObject.argvalue = schemaField; return schemaField.getId(); default: - throw new CAFRuntimeException("NOCODE", "BizFieldError", "不支持的业务字段嵌套层次,请联系技术人员", null); + throw new WebCustomException("不支持的业务字段嵌套层次,请联系技术人员"); } } diff --git a/web-designschema/src/main/java/com/inspur/edp/web/designschema/generator/FieldTypeBuilder.java b/web-designschema/src/main/java/com/inspur/edp/web/designschema/generator/FieldTypeBuilder.java index 3f30d3a5dc3ac5f18e3e507aec6091dcb1cf41b3..17bda720f5b8115b7e147b3aa6aa156d20e13c14 100644 --- a/web-designschema/src/main/java/com/inspur/edp/web/designschema/generator/FieldTypeBuilder.java +++ b/web-designschema/src/main/java/com/inspur/edp/web/designschema/generator/FieldTypeBuilder.java @@ -27,6 +27,7 @@ import com.inspur.edp.udt.designtime.api.entity.SimpleDataTypeDef; import com.inspur.edp.udt.designtime.api.entity.UnifiedDataTypeDef; import com.inspur.edp.udt.designtime.api.nocode.BusinessField; import com.inspur.edp.udt.designtime.api.nocode.IBusinessFieldService; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.metadata.MetadataGetterParameter; import com.inspur.edp.web.common.metadata.MetadataTypeEnum; import com.inspur.edp.web.common.metadata.MetadataUtility; @@ -139,7 +140,7 @@ public class FieldTypeBuilder { private EntityType GenerateEntityFieldType(TypeBuildingContext context, TypeBuildingContext parentContext, String scene) { GspAssociationCollection associations = context.getAssociations(); if (associations == null || associations.size() == 0) { - throw new RuntimeException(String.format("字段'%1$s'不包含关联实体信息。", context.Get("Name", String.class))); + throw new WebCustomException(String.format("字段'%1$s'不包含关联实体信息。", context.Get("Name", String.class))); } TypeBuildingContext originalFieldContext = TypeBuildingContext.CreateSimpleTypeContextFromAssociation(context, parentContext); Field originalField = fieldBuilder.build(originalFieldContext, parentContext, scene); @@ -235,7 +236,7 @@ public class FieldTypeBuilder { typeMetadata = MetadataUtility.getInstance().getMetadataWithDesign(metadataGetterParameter); } if (typeMetadata == null) { - throw new RuntimeException(String.format("未获取到id为'%1$s'的统一数据类型(UDT)元数据。", uri)); + throw new WebCustomException(String.format("未获取到id为'%1$s'的统一数据类型(UDT)元数据。", uri)); } unifiedDataType = (UnifiedDataTypeDef) ((typeMetadata.getContent() instanceof UnifiedDataTypeDef) ? typeMetadata.getContent() : null); return unifiedDataType; diff --git a/web-designschema/src/main/java/com/inspur/edp/web/designschema/generator/TypeBuildingContext.java b/web-designschema/src/main/java/com/inspur/edp/web/designschema/generator/TypeBuildingContext.java index 0d344aded185a03888ffb0da84a4d5a947b8eaaa..67d9ca08557538a578df45ec1c0626f9f8560c69 100644 --- a/web-designschema/src/main/java/com/inspur/edp/web/designschema/generator/TypeBuildingContext.java +++ b/web-designschema/src/main/java/com/inspur/edp/web/designschema/generator/TypeBuildingContext.java @@ -30,6 +30,7 @@ import com.inspur.edp.udt.designtime.api.entity.SimpleDataTypeDef; import com.inspur.edp.udt.designtime.api.entity.UnifiedDataTypeDef; import com.inspur.edp.udt.designtime.api.nocode.BusinessField; import com.inspur.edp.udt.designtime.api.nocode.IBusinessFieldService; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.metadata.MetadataGetterParameter; import com.inspur.edp.web.common.metadata.MetadataTypeEnum; import com.inspur.edp.web.common.metadata.MetadataUtility; @@ -445,7 +446,7 @@ public class TypeBuildingContext { public static TypeBuildingContext CreateSimpleTypeContextFromAssociation(TypeBuildingContext context, TypeBuildingContext parent) { GspAssociationCollection associations = context.getAssociations(); if (associations == null || associations.size() == 0) { - throw new RuntimeException(String.format("字段'%1$s'不包含关联实体信息。", context.Get("Name", String.class))); + throw new WebCustomException(String.format("字段'%1$s'不包含关联实体信息。", context.Get("Name", String.class))); } String tempVar = context.Get("Label", String.class); @@ -486,7 +487,7 @@ public class TypeBuildingContext { private static void VerifyUnifiedDataType(IGspCommonField element) { if (element.getIsUdt()) { if (StringUtility.isNullOrEmpty(element.getUdtID().trim())) { - throw new RuntimeException(String.format("标识为'%1$s',标签为'%2$s'的字段'%3$s'被定义为'UnifiedDataType'字段,但是没有指定'UnifiedDataType'标识,请检查业务实体。", element.getID(), element.getLabelID(), element.getName())); + throw new WebCustomException(String.format("标识为'%1$s',标签为'%2$s'的字段'%3$s'被定义为'UnifiedDataType'字段,但是没有指定'UnifiedDataType'标识,请检查业务实体。", element.getID(), element.getLabelID(), element.getName())); } } } @@ -504,7 +505,7 @@ public class TypeBuildingContext { typeMetadata = MetadataUtility.getInstance().getMetadataWithDesign(metadataGetterParameter); } if (typeMetadata == null) { - throw new RuntimeException(String.format("未获取到id为'%1$s'的统一数据类型(UDT)元数据。", uri)); + throw new WebCustomException(String.format("未获取到id为'%1$s'的统一数据类型(UDT)元数据。", uri)); } unifiedDataType = (UnifiedDataTypeDef) ((typeMetadata.getContent() instanceof UnifiedDataTypeDef) ? typeMetadata.getContent() : null); this.setUnifiedDataTypeDefInstance(unifiedDataType); diff --git a/web-designschema/src/main/java/com/inspur/edp/web/designschema/synchronization/BaseDesignSchemaChangeHandler.java b/web-designschema/src/main/java/com/inspur/edp/web/designschema/synchronization/BaseDesignSchemaChangeHandler.java index dadb26cf402fa6b1fbf26398995a09b72e4a48fc..3606847269a53256a273744fd08b8e6b63c75d03 100644 --- a/web-designschema/src/main/java/com/inspur/edp/web/designschema/synchronization/BaseDesignSchemaChangeHandler.java +++ b/web-designschema/src/main/java/com/inspur/edp/web/designschema/synchronization/BaseDesignSchemaChangeHandler.java @@ -20,6 +20,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.inspur.edp.formserver.viewmodel.GspViewModel; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.serialize.SerializeUtility; import com.inspur.edp.web.designschema.elements.Schema; import com.inspur.edp.web.designschema.synchronization.helplinkconfig.VoMetadataHelpLinkConfigModifierBeforeSaving; @@ -63,7 +64,7 @@ public abstract class BaseDesignSchemaChangeHandler { } } } else { - throw new RuntimeException("表单DOM结构错误:未到module.schemas节点"); + throw new WebCustomException("表单DOM结构错误:未到module.schemas节点"); } } diff --git a/web-designschema/src/main/java/com/inspur/edp/web/designschema/synchronization/FormMetadataUpdate.java b/web-designschema/src/main/java/com/inspur/edp/web/designschema/synchronization/FormMetadataUpdate.java index a36539f7efdb3fd949632867442a6815b799939f..6939079887184bb13946199b342c9c4a5875040e 100644 --- a/web-designschema/src/main/java/com/inspur/edp/web/designschema/synchronization/FormMetadataUpdate.java +++ b/web-designschema/src/main/java/com/inspur/edp/web/designschema/synchronization/FormMetadataUpdate.java @@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.inspur.edp.formserver.viewmodel.GspViewModel; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; import com.inspur.edp.lcm.metadata.api.service.MetadataService; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.metadata.MetadataGetterParameter; import com.inspur.edp.web.common.metadata.MetadataTypeEnum; import com.inspur.edp.web.common.metadata.MetadataUtility; @@ -79,7 +80,7 @@ public class FormMetadataUpdate { } } } else { - throw new RuntimeException("表单DOM结构错误:未到module.schemas节点"); + throw new WebCustomException("表单DOM结构错误:未到module.schemas节点"); } } } diff --git a/web-designschema/src/test/java/com/inspur/edp/web/designschema/elements/FieldTest.java b/web-designschema/src/test/java/com/inspur/edp/web/designschema/elements/FieldTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b898906f3b703df783444cf5afc23886d699084e --- /dev/null +++ b/web-designschema/src/test/java/com/inspur/edp/web/designschema/elements/FieldTest.java @@ -0,0 +1,27 @@ +package com.inspur.edp.web.designschema.elements; + +import com.inspur.edp.web.common.serialize.SerializeUtility; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * @author noah + * 2023/7/31 19:35 + */ +public class FieldTest { + + @Test + public void testFieldSerializer() { + SimpleField simpleField = new SimpleField(); + simpleField.setDefaultValue("simplefield"); + + String serializedField = SerializeUtility.getInstance().serialize(simpleField); + + Field field = SerializeUtility.getInstance().deserialize(serializedField, Field.class); + if (field instanceof SimpleField) { + // + System.out.println("simple field"); + } + } +} \ No newline at end of file diff --git a/web-dynamic-form-core/src/main/java/com/inspur/edp/web/dynamicform/core/components/QuerySchemaField.java b/web-dynamic-form-core/src/main/java/com/inspur/edp/web/dynamicform/core/components/QuerySchemaField.java index c587daa2c22ecdb3e95a02848317488b0c9d333e..ac9207fb1eeec22fbdc226ef99e1d25444b2e3a7 100644 --- a/web-dynamic-form-core/src/main/java/com/inspur/edp/web/dynamicform/core/components/QuerySchemaField.java +++ b/web-dynamic-form-core/src/main/java/com/inspur/edp/web/dynamicform/core/components/QuerySchemaField.java @@ -17,6 +17,8 @@ package com.inspur.edp.web.dynamicform.core.components; import lombok.Data; +import lombok.Getter; +import lombok.Setter; import java.util.HashMap; @@ -74,7 +76,8 @@ public class QuerySchemaField { /** * single-number control */ - @Data + @Getter + @Setter public static class QuerySchemaSingleNumberFieldControl extends QuerySchemaFieldControl { { this.setControltype("single-number"); @@ -92,7 +95,8 @@ public class QuerySchemaField { /** * number field control */ - @Data + @Getter + @Setter public static class QuerySchemaNumberFieldControl extends QuerySchemaSingleNumberFieldControl { { this.setControltype("number"); @@ -102,7 +106,8 @@ public class QuerySchemaField { } } - @Data + @Getter + @Setter public static class QuerySchemaSingleDateFieldControl extends QuerySchemaFieldControl { private String format; @@ -113,7 +118,8 @@ public class QuerySchemaField { } } - @Data + @Getter + @Setter public static class QuerySchemaDateFieldControl extends QuerySchemaFieldControl { private boolean weekSelect; private String format; @@ -126,7 +132,8 @@ public class QuerySchemaField { } } - @Data + @Getter + @Setter public static class QuerySchemaDropdownFieldControl extends QuerySchemaFieldControl { private String valueType; private Object enumValues; diff --git a/web-form-jitengine/src/main/java/com/inspur/edp/web/jitengine/expressions/ModuleFormExpressionFieldItem.java b/web-form-jitengine/src/main/java/com/inspur/edp/web/jitengine/expressions/ModuleFormExpressionFieldItem.java index e867896de0d8edc1bd30c44b22641da840871c66..c4aaa21322b2592c43f509f5220eb1c801ca3222 100644 --- a/web-form-jitengine/src/main/java/com/inspur/edp/web/jitengine/expressions/ModuleFormExpressionFieldItem.java +++ b/web-form-jitengine/src/main/java/com/inspur/edp/web/jitengine/expressions/ModuleFormExpressionFieldItem.java @@ -18,6 +18,8 @@ package com.inspur.edp.web.jitengine.expressions; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; +import lombok.Getter; +import lombok.Setter; /** * description:表单表达式对应的字段定义 @@ -25,7 +27,8 @@ import lombok.Data; * @author Noah Guo * @date 2021/01/07 */ -@Data +@Getter +@Setter public class ModuleFormExpressionFieldItem extends ModuleFormExpressionItem { @JsonProperty("fieldId") private String fieldId; diff --git a/web-form-jitengine/src/main/java/com/inspur/edp/web/jitengine/expressions/parser/EntityExpressionParser.java b/web-form-jitengine/src/main/java/com/inspur/edp/web/jitengine/expressions/parser/EntityExpressionParser.java index f1b785384c93225fa057d65dd7e2f6388e4714e9..849b540c255281e71791f4ce39b7ea1e41e09608 100644 --- a/web-form-jitengine/src/main/java/com/inspur/edp/web/jitengine/expressions/parser/EntityExpressionParser.java +++ b/web-form-jitengine/src/main/java/com/inspur/edp/web/jitengine/expressions/parser/EntityExpressionParser.java @@ -66,8 +66,7 @@ public class EntityExpressionParser { Matcher matchedItemExpression = ExpressionSourceItemRegex(entityName, matchedExpressionValue); if (matchedItemExpression.find()) { String matchedItemExpressionValue = matchedItemExpression.group(); - if (!StringUtility.isNullOrEmpty(matchedItemExpressionValue) && - !StringUtility.isNullOrEmpty(matchedItemExpressionValue)) { + if (!StringUtility.isNullOrEmpty(matchedItemExpressionValue)) { String replacedMatchedValue = matchedItemExpressionValue .replace(entityName, "ENTITY~") .replace(".", "/") diff --git a/web-form-metadata/pom.xml b/web-form-metadata/pom.xml index 33eb20c50d761bb51ed0dfe78aec667259961a7f..86706e60b74db878bd51acfd79d218db20899f33 100644 --- a/web-form-metadata/pom.xml +++ b/web-form-metadata/pom.xml @@ -65,6 +65,10 @@ com.inspur.edp web-jitengine-formmetadata-api + + com.inspur.edp + web-designschema-api + org.junit.jupiter junit-jupiter-api diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/config/FormMetadataConfiguration.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/config/FormMetadataConfiguration.java index 6c25a189e75eb417f455c2b867655fe7c6553bf5..b5bc15b0b799c9ae8035d5982e66055c3067acf4 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/config/FormMetadataConfiguration.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/config/FormMetadataConfiguration.java @@ -24,12 +24,11 @@ import com.inspur.edp.web.formmetadata.service.FormMetadataRTService; import com.inspur.edp.web.formmetadata.service.FormMetadataService; import com.inspur.edp.web.formmetadata.service.FormRelateMetadataService; import com.inspur.edp.web.formmetadata.webservice.FormMetadataWebServiceImpl; -import io.iec.edp.caf.businessobject.api.service.DevBasicInfoService; import io.iec.edp.caf.rest.RESTEndpoint; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; @Configuration("com.inspur.edp.web.formmetadata.config.FormMetadataConfiguration") public class FormMetadataConfiguration { @@ -73,8 +72,11 @@ public class FormMetadataConfiguration { return new FormRelateMetadataService(); } + @Bean public FormResourceManager getFormResourceManager() { return new FormResourceManager(); } + + } diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/event/FormMetadataSaveEventListener.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/event/FormMetadataSaveEventListener.java index 7249b5893b26cd5151bed9af3174b6d1d548f795..f7f513c4d98b0b4b7adc09f462aac7f3c0a97b6c 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/event/FormMetadataSaveEventListener.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/event/FormMetadataSaveEventListener.java @@ -35,6 +35,7 @@ import io.iec.edp.caf.commons.utils.SpringBeanUtils; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.function.Consumer; @@ -255,7 +256,7 @@ public class FormMetadataSaveEventListener implements MetadataEventListener { try { FileUtility.deleteFile(tsFileNameAndPath); } catch (Exception ex) { - WebLogger.Instance.error(ex.getMessage() + ex.getStackTrace()); + WebLogger.Instance.error(ex.getMessage() + Arrays.toString(ex.getStackTrace())); } } } diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/event/WebCommandMetadataDelete.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/event/WebCommandMetadataDelete.java index bc758f7bd92ea7cc6dd3e7eda8c4afbb96effdf1..72b2683ceb545a88ac3b519549c50bcfd3980e5c 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/event/WebCommandMetadataDelete.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/event/WebCommandMetadataDelete.java @@ -21,6 +21,7 @@ import com.inspur.edp.cdp.web.component.metadata.define.WebComponentMetadata; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; import com.inspur.edp.lcm.metadata.api.entity.MetadataProject; import com.inspur.edp.web.command.component.metadata.*; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.logger.WebLogger; import com.inspur.edp.web.common.metadata.MetadataGetterParameter; import com.inspur.edp.web.common.metadata.MetadataTypeEnum; @@ -139,7 +140,7 @@ class WebCommandMetadataDelete { metadataGetterParameter.setTargetMetadataNotFoundMessage("获取WebComponent元数据为空,对应元数据id为:" + id); GspMetadata webComponentMetadata = MetadataUtility.getInstance().getMetadataWithDesign(metadataGetterParameter); if (webComponentMetadata == null) { - throw new RuntimeException("load webComponent metadata is null,the metaDataId is " + id); + throw new WebCustomException("load webComponent metadata is null,the metaDataId is " + id); } return (WebComponentMetadata) webComponentMetadata.getContent(); } diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/formresource/FormResourceManager.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/formresource/FormResourceManager.java index 35322de5fc965648a13f3039a8ecbbf660d57478..2980d5acf33381ab4efce9f4b96c8f92cb68caa1 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/formresource/FormResourceManager.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/formresource/FormResourceManager.java @@ -24,6 +24,7 @@ import com.inspur.edp.web.common.logger.WebLogger; import io.iec.edp.caf.commons.utils.SpringBeanUtils; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -55,7 +56,7 @@ public class FormResourceManager { } return resourceList; } catch (MetadataNotFoundException ex) { - WebLogger.Instance.warn(ex.getMessage() + ex.getStackTrace()); + WebLogger.Instance.warn(ex.getMessage() + Arrays.toString(ex.getStackTrace())); } catch (Exception ex) { // 排除掉找不到对应的资源文件的异常 String fileNotFoundException = "java.io.FileNotFoundException"; diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/i18n/component/ComponentUtility.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/i18n/component/ComponentUtility.java index 4fbd408c519ca7e4a1c8bc270f8de49d9dc8ca5c..ab199975f5e0321565f34f24ffd0ffe0730ad65c 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/i18n/component/ComponentUtility.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/i18n/component/ComponentUtility.java @@ -101,7 +101,7 @@ public class ComponentUtility { componentId = getName(component); } } - throw new WebCustomException(String.format("Get %1$s's key '%2$s''s Value Failed, Error stack is:", componentId, keyName)); + throw new WebCustomException(String.format("Get %1$s's key '%2$s''s Value Failed, Error stack is:", componentId, keyName), e); } } diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/i18n/component/strategy/i18nresourcestrategy/FileUploadPreviewI18nResourceStrategy.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/i18n/component/strategy/i18nresourcestrategy/FileUploadPreviewI18nResourceStrategy.java index 91d23411c78ca70872c6876f3c3c923f3e86cbf5..33a15d069a2cfbb8db7825a9d60341297a278328 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/i18n/component/strategy/i18nresourcestrategy/FileUploadPreviewI18nResourceStrategy.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/i18n/component/strategy/i18nresourcestrategy/FileUploadPreviewI18nResourceStrategy.java @@ -16,12 +16,15 @@ package com.inspur.edp.web.formmetadata.i18n.component.strategy.i18nresourcestrategy; +import com.fasterxml.jackson.databind.node.ArrayNode; import com.inspur.edp.lcm.metadata.api.entity.I18nResourceItem; import com.inspur.edp.lcm.metadata.api.entity.I18nResourceItemCollection; import com.inspur.edp.web.formmetadata.i18n.I18nResourceItemManager; import com.inspur.edp.web.formmetadata.i18n.component.ComponentUtility; +import com.inspur.edp.web.formmetadata.i18n.component.I18nResourceUtility; import com.inspur.edp.web.formmetadata.i18n.constant.I18nResourceConstant; +import java.util.ArrayList; import java.util.HashMap; /** @@ -50,6 +53,50 @@ public class FileUploadPreviewI18nResourceStrategy extends AbstractI18nResourceS if (previewDefaultNameI18nResourceItemCollection != null && previewDefaultNameI18nResourceItemCollection.size() > 0) { i18nResourceItemCollection.addRange(previewDefaultNameI18nResourceItemCollection); } + + String currentComponentId = ComponentUtility.getInstance().getId(currentComponent); + String currentComponentType = ComponentUtility.getInstance().getType(currentComponent); + ArrayList> cols = ComponentUtility.getInstance().getValue(currentComponent, "previewColumns"); + cols.forEach(field -> { + String bindingField = ComponentUtility.getInstance().getValue(field, "bindingField"); + String value = ComponentUtility.getInstance().getValue(field, "title"); + String baseId = currentComponentType + + I18nResourceConstant.SECOND_LEVEL_DELIMITER + currentComponentId + + I18nResourceConstant.SECOND_LEVEL_DELIMITER + bindingField; + String generatedComponentId = baseId + I18nResourceConstant.SECOND_LEVEL_DELIMITER + "title"; + I18nResourceItem i18nResourceItem = I18nResourceItemManager.createI18nResourceItem(i18nResourceItemBaseId, generatedComponentId, value, value); + i18nResourceItemCollection.add(i18nResourceItem); + + // 提取枚举值资源项 + ArrayList> enumValueCollection = ComponentUtility.getInstance().GetEnumData(field); + if (enumValueCollection.size() > 0) { + // 从enumData中提取多语资源项 + String enumDataAttributeName = ComponentUtility.getInstance().GetEnumDataName(currentComponent); + I18nResourceItemCollection enumDataI18nResourceItemCollection = I18nResourceUtility.GetInstance().ExtractEnumDataI18nResourceItemCollection(i18nResourceItemBaseId, baseId, enumValueCollection, enumDataAttributeName, "value", "name"); + if (enumDataI18nResourceItemCollection.size() > 0) { + i18nResourceItemCollection.addRange(enumDataI18nResourceItemCollection); + } + } + + // 提取布尔值资源项 + HashMap formatter = ComponentUtility.getInstance().getValue(field, "formatter"); + String formatterType = ComponentUtility.getInstance().getValue(formatter, "type"); + if ("boolean".equals(formatterType)) { + String baseKey = baseId + + I18nResourceConstant.SECOND_LEVEL_DELIMITER + + "formatter" + + I18nResourceConstant.SECOND_LEVEL_DELIMITER; + String trueTextVal = ComponentUtility.getInstance().getValue(formatter, "trueText"); + String trueTextKey = baseKey + "trueText"; + I18nResourceItem trueTextI18nItem = I18nResourceItemManager.createI18nResourceItem(i18nResourceItemBaseId, trueTextKey, trueTextVal, trueTextVal); + i18nResourceItemCollection.add(trueTextI18nItem); + + String falseTextVal = ComponentUtility.getInstance().getValue(formatter, "falseText"); + String falseTextKey = baseKey + "falseText"; + I18nResourceItem falseTextI18nItem = I18nResourceItemManager.createI18nResourceItem(i18nResourceItemBaseId, falseTextKey, falseTextVal, falseTextVal); + i18nResourceItemCollection.add(falseTextI18nItem); + } + }); return i18nResourceItemCollection; } diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/i18n/component/strategy/i18nresourcestrategy/ListFilterI18nResourceStrategy.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/i18n/component/strategy/i18nresourcestrategy/ListFilterI18nResourceStrategy.java index aeed0007118e2ed2167514624e34132c8c77fb9b..9f504288dd5d7fea53c8200b88178eae0dadfcde 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/i18n/component/strategy/i18nresourcestrategy/ListFilterI18nResourceStrategy.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/i18n/component/strategy/i18nresourcestrategy/ListFilterI18nResourceStrategy.java @@ -41,6 +41,14 @@ public class ListFilterI18nResourceStrategy extends AbstractI18nResourceStrategy i18nResourceItemCollection.addRange(fieldConfigsI18nResourceItemCollection); } + if (currentComponent.containsKey("clearSelectedText")) { + String curCompId = ComponentUtility.getInstance().getId(currentComponent); + String clearSelectedText = ComponentUtility.getInstance().getValue(currentComponent, "clearSelectedText"); + String currentComponentType = ComponentUtility.getInstance().getType(currentComponent); + String generatedComponentId = currentComponentType + "/" + curCompId + "/clearSelectedText"; + I18nResourceItem i18nResourceItem = I18nResourceItemManager.createI18nResourceItem(i18nResourceItemBaseId, generatedComponentId, clearSelectedText, clearSelectedText); + i18nResourceItemCollection.add(i18nResourceItem); + } return i18nResourceItemCollection; } diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadata/FormMetadataContent.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadata/FormMetadataContent.java index 560ff46a5479756e4346ce4c7a6c91b51016676e..817f1b05b76c6099292c68d30a65d6f273ce446a 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadata/FormMetadataContent.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadata/FormMetadataContent.java @@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.TextNode; import com.inspur.edp.lcm.metadata.api.AbstractMetadataContent; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.logger.WebLogger; import com.inspur.edp.web.common.serialize.SerializeUtility; @@ -46,12 +47,12 @@ public class FormMetadataContent extends AbstractMetadataContent { private JsonNode Contents; @JsonProperty("Contents") - public final JsonNode getContents() { + public final JsonNode getContents() { if (this.Contents != null && this.Contents instanceof TextNode) { try { this.Contents = SerializeUtility.getInstance().getDefaultObjectMapper().readTree(this.Contents.asText()); - }catch(Exception ex){ - throw new RuntimeException("表单元数据转换为JsonNode失败,对应元数据为:"+this.Contents.asText()); + } catch (Exception ex) { + throw new WebCustomException("表单元数据转换为JsonNode失败,对应元数据为:" + this.Contents.asText(), ex); } } return Contents; @@ -85,7 +86,7 @@ public class FormMetadataContent extends AbstractMetadataContent { formMetaDataContent.setContents(newContent); } catch (JsonProcessingException e) { WebLogger.Instance.error(e); - throw new RuntimeException("Form Content克隆失败, id=" + this.getId() + ", code=" + this.getCode() + ", name=" + this.getName()); + throw new WebCustomException("Form Content克隆失败, id=" + this.getId() + ", code=" + this.getCode() + ", name=" + this.getName(), e); } formMetaDataContent.setName(this.getName()); formMetaDataContent.setCode(this.getCode()); diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadataanalysis/CommandsAnalysis.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadataanalysis/CommandsAnalysis.java index a1f0ae6b26a762fe9b3e8ac87faa9d3735167707..baf29f18462fbf6d087d61c346e1aefc1c59e8ab 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadataanalysis/CommandsAnalysis.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadataanalysis/CommandsAnalysis.java @@ -310,14 +310,14 @@ public class CommandsAnalysis extends AbstractMetadataAnalysis { cmpMethodReferingItem.getComponentPath()); cmpMetadata = cmpManager.getComponentMetadata(metadataManagerParameter); if (cmpMetadata == null) { - throw new Exception("标识为'" + ((CmpMethodRefering) item).getComponentId() + "'的服务构件为null。"); + throw new WebCustomException("标识为'" + ((CmpMethodRefering) item).getComponentId() + "'的服务构件为null。"); } WebLogger.Instance.info("Get WebCommands By Id:" + cmpMetadata.getId(), this.getClass().getName()); WebComponentMetadataAndExtra webComponentMetadataAndExtra = WebComponentMetadataAndExtra.init(cmpMetadata, cmpMethodReferingItem.getComponentId(), cmpMethodReferingItem.getName(), cmpMethodReferingItem.getName(), cmpMethodReferingItem.getComponentPath()); cmpList.put(cmpMetadata.getId(), webComponentMetadataAndExtra); projectCmpList.put(cmpMetadata.getId(), webComponentMetadataAndExtra); } catch (Exception ex) { - throw new Exception("获取command元数据" + ((CmpMethodRefering) item).getComponentId() + "失败", ex); + throw new WebCustomException("获取command元数据" + ((CmpMethodRefering) item).getComponentId() + "失败", ex); } } else { WebComponentMetadataAndExtra webComponentMetadataAndExtra = projectCmpList.get(((CmpMethodRefering) item).getComponentId()); @@ -344,7 +344,7 @@ public class CommandsAnalysis extends AbstractMetadataAnalysis { HashMap serviceRef = new HashMap<>(); WebComponentMetadataAndExtra component = v; if (component == null) { - throw new RuntimeException("不存在标识为'" + k + "'的服务构件"); + throw new WebCustomException("不存在标识为'" + k + "'的服务构件"); } WebComponentMetadata webComponentMetadata = component.getWebComponentMetadata(); @@ -371,7 +371,7 @@ public class CommandsAnalysis extends AbstractMetadataAnalysis { HashMap serviceRef = new HashMap<>(); WebComponentMetadataAndExtra component = (WebComponentMetadataAndExtra) entry.getValue(); if (component == null) { - throw new RuntimeException("不存在标识为'" + entry.getKey() + "'的服务构件"); + throw new WebCustomException("不存在标识为'" + entry.getKey() + "'的服务构件"); } WebComponentMetadata webComponentMetadata = component.getWebComponentMetadata(); @@ -399,11 +399,11 @@ public class CommandsAnalysis extends AbstractMetadataAnalysis { for (HashMap serviceRef : serviceReferenceList) { if (serviceRef.containsKey("name") && serviceRef.containsKey("path")) { if (serviceRef.get("name") == null) { - throw new RuntimeException("标识为'{" + serviceRef.get("cmpId") + "'的服务构件name属性不允许为null。"); + throw new WebCustomException("标识为'{" + serviceRef.get("cmpId") + "'的服务构件name属性不允许为null。"); } if (serviceRef.get("path") == null) { - throw new RuntimeException("标识为'" + serviceRef.get("cmpId") + "'的服务构件path属性不允许为null。"); + throw new WebCustomException("标识为'" + serviceRef.get("cmpId") + "'的服务构件path属性不允许为null。"); } if (serviceRef.get("name").toString().equals(component.getClassName()) && diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadataanalysis/FormAnalysis.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadataanalysis/FormAnalysis.java index a2423444e0ca51b9b1390f0a17578d41dcbed2f2..1410011215aa2eb585007a336d5953ef43b4c97d 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadataanalysis/FormAnalysis.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadataanalysis/FormAnalysis.java @@ -16,6 +16,7 @@ package com.inspur.edp.web.formmetadata.metadataanalysis; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.environment.ExecuteEnvironment; import com.inspur.edp.web.common.io.FileUtility; import com.inspur.edp.web.common.serialize.SerializeUtility; @@ -122,7 +123,7 @@ public class FormAnalysis extends AbstractMetadataAnalysis { externalComponentPath), externalComponentCode.toLowerCase() + ".frm.json", formMetaDataStr); } else { - throw new RuntimeException("暂时无法处理frmJsonSavePath为空场景,请咨询开发人员该功能完成情况"); + throw new WebCustomException("暂时无法处理frmJsonSavePath为空场景,请咨询开发人员该功能完成情况"); } } } diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/ComponentMetadataManager.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/ComponentMetadataManager.java index a5313f6b8105c6c70aeeda6575b7d82d7559675c..7450855804031577f1afaf15f8107cfdd2b3ad54 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/ComponentMetadataManager.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/ComponentMetadataManager.java @@ -18,6 +18,7 @@ package com.inspur.edp.web.formmetadata.metadatamanager; import com.inspur.edp.cdp.web.component.metadata.define.WebComponentMetadata; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.environment.ExecuteEnvironment; import com.inspur.edp.web.common.metadata.MetadataGetterParameter; import com.inspur.edp.web.common.metadata.MetadataTypeEnum; @@ -45,7 +46,7 @@ public class ComponentMetadataManager extends BaseMetaDataManager { return getterMetadataInfo; }, null, this.getDefaultMetadataNotFoundFormatMessage(metadataManagerParameter.getId(), MetadataTypeEnum.Component)); if (webComponentMetadata == null) { - throw new RuntimeException("load webComponent metadata is null,the metaDataId is " + metadataManagerParameter.getId()); + throw new WebCustomException("load webComponent metadata is null,the metaDataId is " + metadataManagerParameter.getId()); } return (WebComponentMetadata) webComponentMetadata.getContent(); } diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/EapiMetadataManager.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/EapiMetadataManager.java index 4f08904408cd11860d447d057c036b7623244c1b..6b29b2ab1b108bb1530bf66ba081b2453b85626b 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/EapiMetadataManager.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/EapiMetadataManager.java @@ -17,6 +17,7 @@ package com.inspur.edp.web.formmetadata.metadatamanager; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.environment.ExecuteEnvironment; import com.inspur.edp.web.common.metadata.MetadataGetterParameter; import com.inspur.edp.web.common.metadata.MetadataTypeEnum; @@ -50,7 +51,7 @@ public class EapiMetadataManager extends BaseMetaDataManager { return getterMetadataInfo; }, null, this.getDefaultMetadataNotFoundFormatMessage(metadataManagerParameter.getId(), MetadataTypeEnum.Eapi)); if (eapiMetadata == null) { - throw new RuntimeException("load eapi metadata is null,the metaDataId is " + metadataManagerParameter.getId()); + throw new WebCustomException("load eapi metadata is null,the metaDataId is " + metadataManagerParameter.getId()); } return Optional.ofNullable(eapiMetadata); } diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/FormMetadataManager.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/FormMetadataManager.java index b06d35ba70e28f4912e8d2ec608001e1566f99a0..5ec1c832a85d39bb2ca357286127f44c0c1bbb17 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/FormMetadataManager.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/FormMetadataManager.java @@ -17,6 +17,7 @@ package com.inspur.edp.web.formmetadata.metadatamanager; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.environment.ExecuteEnvironment; import com.inspur.edp.web.common.metadata.MetadataGetterParameter; import com.inspur.edp.web.common.metadata.MetadataTypeEnum; @@ -60,7 +61,7 @@ public class FormMetadataManager extends BaseMetaDataManager { return getterMetadataInfo; }, null, this.getDefaultMetadataNotFoundFormatMessage(metadataManagerParameter.getId(), MetadataTypeEnum.Frm)); if (metadata == null) { - throw new RuntimeException("load form metadata is null,the metaDataId is " + metadataManagerParameter.getId()); + throw new WebCustomException("load form metadata is null,the metaDataId is " + metadataManagerParameter.getId()); } return metadata; } diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/StateMachineMetadataManager.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/StateMachineMetadataManager.java index aeaa413ca3388ae5edae933ef9879c1329c8763a..73c84ac82494f999019254e590ed35db41359706 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/StateMachineMetadataManager.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/metadatamanager/StateMachineMetadataManager.java @@ -17,6 +17,7 @@ package com.inspur.edp.web.formmetadata.metadatamanager; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.environment.ExecuteEnvironment; import com.inspur.edp.web.common.metadata.MetadataGetterParameter; import com.inspur.edp.web.common.metadata.MetadataTypeEnum; @@ -44,7 +45,7 @@ public class StateMachineMetadataManager extends BaseMetaDataManager { return getterMetadataInfo; }, null, this.getDefaultMetadataNotFoundFormatMessage(metadataManagerParameter.getId(), MetadataTypeEnum.StateMachine)); if (stateMachineMetaData == null) { - throw new RuntimeException("load statemachine metadata is null,the metaDataId is " + metadataManagerParameter.getId()); + throw new WebCustomException("load statemachine metadata is null,the metaDataId is " + metadataManagerParameter.getId()); } return stateMachineMetaData; } diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/replication/FormMetadataReplicator.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/replication/FormMetadataReplicator.java index bd136365dd132c91044d9ec163932c5cac5dbe6a..1415f56969afb03f931e94575b7ebc17b0e23479 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/replication/FormMetadataReplicator.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/replication/FormMetadataReplicator.java @@ -21,6 +21,7 @@ import com.inspur.edp.i18n.resource.api.metadata.LinguisticResource; import com.inspur.edp.i18n.resource.api.metadata.ResourceItem; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; import com.inspur.edp.lcm.metadata.api.entity.MetadataDto; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.entity.ResultCode; import com.inspur.edp.web.common.entity.ResultMessage; import com.inspur.edp.web.common.io.FileUtility; @@ -33,6 +34,8 @@ import com.inspur.edp.web.formmetadata.metadata.FormMetadataContentService; import com.inspur.edp.web.formmetadata.metadata.formdom.FormDOM; import org.apache.commons.lang3.StringUtils; +import java.util.Arrays; + /** * 表单元数据复制器 * @@ -121,13 +124,13 @@ public class FormMetadataReplicator { // 同步复制表单元数据的英文、繁体中文资源元数据 copyResourceMetadataWithSpecificLanguage(context, sourceFormMetadata, replicateFormMetadata); } catch (RuntimeException ex) { - WebLogger.Instance.error("表单复制出现错误," + ex.getMessage() + ex.getStackTrace()); + WebLogger.Instance.error("表单复制出现错误," + ex.getMessage() + Arrays.toString(ex.getStackTrace())); // 执行元数据的清理工作 此处仅删除表单元数据 因此存在表单元数据级联删除动作 if (replicateFormMetadata != null) { MetadataUtility.getInstance().deleteMetadataWithDesign(replicateFormMetadata.getRelativePath(), replicateFormMetadata.getHeader().getFileName()); } - throw new RuntimeException(ex); + throw new WebCustomException("", ex); } return ResultCode.success(); diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/replication/FormMetadataSmManager.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/replication/FormMetadataSmManager.java index 70b0d027a3ebdb69b0df4645a01c776df02be91d..e31fa7fdaa62479358f30148b053ce0644f9ed58 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/replication/FormMetadataSmManager.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/replication/FormMetadataSmManager.java @@ -26,6 +26,7 @@ import com.inspur.edp.web.formmetadata.metadata.formdom.FormDOM; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; /** * description: diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/replication/FormMetadataVoManager.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/replication/FormMetadataVoManager.java index 95f12725271a5760674a17be641753856d619640..2a06ff3ef0520a73600bada25cf3fcdda60dc241 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/replication/FormMetadataVoManager.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/replication/FormMetadataVoManager.java @@ -21,6 +21,7 @@ import com.inspur.edp.lcm.metadata.api.entity.MetadataDto; import com.inspur.edp.sgf.api.common.ResourceType; import com.inspur.edp.sgf.api.entity.SgMetadata; import com.inspur.edp.sgf.api.service.EapiMetadataDtService; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.metadata.MetadataGetterParameter; import com.inspur.edp.web.common.metadata.MetadataTypeEnum; import com.inspur.edp.web.common.metadata.MetadataUtility; @@ -30,6 +31,7 @@ import io.iec.edp.caf.commons.utils.SpringBeanUtils; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; /** * description: @@ -59,7 +61,7 @@ class FormMetadataVoManager { GspMetadata viewObjectMetadata = MetadataUtility.getInstance().getMetadataWithDesign(metadataGetterParameter); if (viewObjectMetadata == null) { - throw new RuntimeException("根据VoId获取对应元数据为空,对应voId为:" + viewObjectId); + throw new WebCustomException("根据VoId获取对应元数据为空,对应voId为:" + viewObjectId); } MetadataDto viewObjectMetadataDto = new MetadataDto(); viewObjectMetadataDto.setCode(viewObjectMetadata.getHeader().getCode().replace(sourceFormMetadata.getHeader().getCode(), targetMetadataDescription.getCode())); diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/service/FormMetadataCommonServiceImpl.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/service/FormMetadataCommonServiceImpl.java index 08e74405fc824367d4928b4b6e561f7149ce9000..195a5a79441946b5a456c6bf01a2c492ffbc067f 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/service/FormMetadataCommonServiceImpl.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/service/FormMetadataCommonServiceImpl.java @@ -17,6 +17,7 @@ package com.inspur.edp.web.formmetadata.service; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.utility.StringUtility; import com.inspur.edp.web.formmetadata.api.FormMetadataCommonService; import com.inspur.edp.web.formmetadata.api.entity.FormSuInfoEntity; @@ -39,11 +40,11 @@ public class FormMetadataCommonServiceImpl implements FormMetadataCommonService @Override public FormSuInfoEntity getSuInfoWithBizobjId(String bizObjId) { if (StringUtility.isNullOrEmpty(bizObjId)) { - throw new RuntimeException("根据业务对象获取对应关键应用信息,业务对象id不能为控"); + throw new WebCustomException("根据业务对象获取对应关键应用信息,业务对象id不能为控"); } DevBasicBoInfo basicBoInfo = this.devBasicInfoService.getDevBasicBoInfo(bizObjId); if (basicBoInfo == null) { - throw new RuntimeException(String.format("根据业务对象获取bo信息为控,对应业务对象id为:%s", bizObjId)); + throw new WebCustomException(String.format("根据业务对象获取bo信息为控,对应业务对象id为:%s", bizObjId)); } FormSuInfoEntity formSuInfo = new FormSuInfoEntity(); formSuInfo.setAppCode(basicBoInfo.getAppCode()); diff --git a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/service/FormRelateMetadataService.java b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/service/FormRelateMetadataService.java index 2c6bff49bb905bf204e58ca988b0e7dcb1b682bf..8cc915cc53e20c4aced71849f878d401695d3348 100644 --- a/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/service/FormRelateMetadataService.java +++ b/web-form-metadata/src/main/java/com/inspur/edp/web/formmetadata/service/FormRelateMetadataService.java @@ -17,6 +17,7 @@ package com.inspur.edp.web.formmetadata.service; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.environment.ExecuteEnvironment; import com.inspur.edp.web.common.logger.WebLogger; import com.inspur.edp.web.common.metadata.MetadataUtility; @@ -70,7 +71,7 @@ public class FormRelateMetadataService { try { combineCompletableFuture.get(); } catch (ExecutionException | InterruptedException e) { - throw new RuntimeException(e); + throw new WebCustomException("", e); } safeFormRelateMetadataInDesignResultList.addAll(formRelateMetadataInDesignResultDtoConcurrentHashMap.values()); diff --git a/web-form-metadata/src/test/java/com/inspur/edp/web/formmetadata/i18n/FormMetadataI18nServiceTest.java b/web-form-metadata/src/test/java/com/inspur/edp/web/formmetadata/i18n/FormMetadataI18nServiceTest.java index 9e3c0d8d7d7aab5c3ec8aa9f531febf230dbf07a..5d707978e60f0150ebe64d1128ff96077ced2d52 100644 --- a/web-form-metadata/src/test/java/com/inspur/edp/web/formmetadata/i18n/FormMetadataI18nServiceTest.java +++ b/web-form-metadata/src/test/java/com/inspur/edp/web/formmetadata/i18n/FormMetadataI18nServiceTest.java @@ -23,6 +23,7 @@ import com.inspur.edp.web.formmetadata.metadata.formdom.FormDOM; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; class FormMetadataI18nServiceTest { diff --git a/web-form-metadata/src/test/java/com/inspur/edp/web/formmetadata/replication/FormMetadataReplicatorTest.java b/web-form-metadata/src/test/java/com/inspur/edp/web/formmetadata/replication/FormMetadataReplicatorTest.java index 48c78c7aed68893b6987d4ddd948da91fb26e971..bbb07e709b2b8122fb132d1a8e68a411395ac606 100644 --- a/web-form-metadata/src/test/java/com/inspur/edp/web/formmetadata/replication/FormMetadataReplicatorTest.java +++ b/web-form-metadata/src/test/java/com/inspur/edp/web/formmetadata/replication/FormMetadataReplicatorTest.java @@ -16,6 +16,7 @@ package com.inspur.edp.web.formmetadata.replication; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.io.FileUtility; import org.apache.commons.lang3.StringUtils; import org.junit.Test; @@ -72,9 +73,9 @@ public class FormMetadataReplicatorTest { int ii = 4 / 0; } catch (Exception ex) { source = "noah catch"; - throw new RuntimeException(ex); + throw new WebCustomException("", ex); } finally { source = "noah finally"; } } -} \ No newline at end of file +} diff --git a/web-form-metadata/src/test/java/com/inspur/edp/web/formmetadata/serializer/FormMetadataContentSerializerTest.java b/web-form-metadata/src/test/java/com/inspur/edp/web/formmetadata/serializer/FormMetadataContentSerializerTest.java index a78c11289b8b9ce8ce74a736e6ffd35c0ab3105a..6e4926f886703bb7224a2b878397e3dda2c47aaa 100644 --- a/web-form-metadata/src/test/java/com/inspur/edp/web/formmetadata/serializer/FormMetadataContentSerializerTest.java +++ b/web-form-metadata/src/test/java/com/inspur/edp/web/formmetadata/serializer/FormMetadataContentSerializerTest.java @@ -18,6 +18,7 @@ package com.inspur.edp.web.formmetadata.serializer; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.serialize.SerializeUtility; import com.inspur.edp.web.formmetadata.metadata.FormMetadataContent; @@ -55,12 +56,12 @@ class FormMetadataContentSerializerTest { try { future2.get(); } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); + throw new WebCustomException("", e); } try { future3.get(); } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); + throw new WebCustomException("", e); } return null; }); diff --git a/web-form-process-api/src/main/java/com/inspur/edp/web/form/process/api/webservice/FormProcessWebService.java b/web-form-process-api/src/main/java/com/inspur/edp/web/form/process/api/webservice/FormProcessWebService.java new file mode 100644 index 0000000000000000000000000000000000000000..23ae41230b8943cdbe4ac4365b0ea798a6ffc467 --- /dev/null +++ b/web-form-process-api/src/main/java/com/inspur/edp/web/form/process/api/webservice/FormProcessWebService.java @@ -0,0 +1,18 @@ +package com.inspur.edp.web.form.process.service; + +import javax.ws.rs.Consumes; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; + +@Path("/") +@Consumes({"application/json"}) +@Produces({"application/json"}) +public class FormProcessWebService { + @Path("/form-format") + @PUT + public void publishFormFormat(@QueryParam("id") String formId, @QueryParam("path") String path) { + FormProcessManager.getInstance().publishFormFormat(formId, path); + } +} diff --git a/web-form-process/src/main/java/com/inspur/edp/web/form/process/service/FormProcessManager.java b/web-form-process/src/main/java/com/inspur/edp/web/form/process/service/FormProcessManager.java new file mode 100644 index 0000000000000000000000000000000000000000..38b6db02e3c4c4a81ddd28a7d9b816048a6ac248 --- /dev/null +++ b/web-form-process/src/main/java/com/inspur/edp/web/form/process/service/FormProcessManager.java @@ -0,0 +1,73 @@ +package com.inspur.edp.web.form.process.service; + +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.lcm.metadata.api.entity.GspProject; +import com.inspur.edp.lcm.metadata.api.entity.MetadataHeader; +import com.inspur.edp.lcm.metadata.api.service.MetadataService; +import com.inspur.edp.metadata.businesstype.api.MdBizTypeMappingService; +import com.inspur.edp.wf.bizprocess.entity.FormFormat; +import com.inspur.edp.wf.bizprocess.entity.UrlParameter; +import com.inspur.edp.wf.bizprocess.service.FormFormatRpcService; +import io.iec.edp.caf.commons.utils.SpringBeanUtils; +import io.iec.edp.caf.rpc.client.RpcClassHolder; +import java.util.Arrays; +import java.util.List; + +public class FormProcessManager { + private static class LazyHolder { + private static final FormProcessManager INSTANCE = new FormProcessManager(); + } + + private FormProcessManager() {} + + public static final FormProcessManager getInstance() { + return LazyHolder.INSTANCE; + } + + public void publishFormFormat(String formId, String formPath) { + if (formPath == null || formPath.equals("")) + throw new RuntimeException("); + String unifiedPath = formPath.replace('\\', '/'); + if (unifiedPath.startsWith("/")) + unifiedPath = unifiedPath.substring(1); + MetadataService metadataService = (MetadataService)SpringBeanUtils.getBean(MetadataService.class); + List mdList = metadataService.getMetadataList(unifiedPath); + GspMetadata md = mdList.stream().filter(item -> item.getHeader().getId().equals(formId)).findFirst().orElse(null); + if (md == null) + throw new RuntimeException("" + formId + "+ unifiedPath + "); + MetadataHeader header = md.getHeader(); + GspProject project = metadataService.getGspProjectInfo(unifiedPath); + String deploymentPath = project.getSuDeploymentPath(); + String projectName = project.getMetadataProjectName().toLowerCase(); + String url = "/" + deploymentPath + "/web/" + projectName + "/index.html#/" + header.getCode(); + FormFormat ff = new FormFormat(); + ff.setId(formId); + ff.setCode(header.getCode()); + ff.setName(header.getName()); + ff.setUrlType("url"); + ff.setFormUrl(url); + UrlParameter actionParam = new UrlParameter(); + actionParam.setCode("action"); + actionParam.setName("); + actionParam.setValue("LoadAndView1"); + UrlParameter idParam = new UrlParameter(); + idParam.setCode("id"); + idParam.setName("); + idParam.setValue("{\"expr\":\"DefaultFunction.GetContextParameter(\\\"dataId\\\")\",\"sexpr\":\"\"}\n"); + List list = Arrays.asList(new UrlParameter[] { actionParam, idParam }); + ff.setUrlParameters(list); + ff.setFormatType("wf"); + String boId = project.getBizobjectID(); + ff.setBizCategory(getBizTypeId(boId)); + ff.setTerminal("PC"); + RpcClassHolder rpcHelper = (RpcClassHolder)SpringBeanUtils.getBean(RpcClassHolder.class); + FormFormatRpcService service = (FormFormatRpcService)rpcHelper.getRpcClass(FormFormatRpcService.class); + service.addFormFormat(ff); + } + + private String getBizTypeId(String bizObjectId) { + MdBizTypeMappingService service = (MdBizTypeMappingService)SpringBeanUtils.getBean(MdBizTypeMappingService.class); + List bizTypeIds = service.getBizTypeIdsByBoId(bizObjectId); + return (bizTypeIds == null || bizTypeIds.size() == 0) ? "" : bizTypeIds.get(0); + } +} diff --git a/web-form-process/src/main/java/com/inspur/edp/web/form/process/webservice/FormProcessWebServiceImpl.java b/web-form-process/src/main/java/com/inspur/edp/web/form/process/webservice/FormProcessWebServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..ce1e282e7f5500b39d5d404b05e07f154cd53992 --- /dev/null +++ b/web-form-process/src/main/java/com/inspur/edp/web/form/process/webservice/FormProcessWebServiceImpl.java @@ -0,0 +1,18 @@ +package com.inspur.edp.web.form.process.service; + +import javax.ws.rs.Consumes; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; + +@Path("/") +@Consumes({"application/json"}) +@Produces({"application/json"}) +public class FormProcessWebServiceImpl { + @Path("/form-format") + @PUT + public void publishFormFormat(@QueryParam("id") String formId, @QueryParam("path") String path) { + FormProcessManager.getInstance().publishFormFormat(formId, path); + } +} diff --git a/web-formconfig-core/src/main/java/com/inspur/edp/web/formconfig/core/entity/FormConfigEntity.java b/web-formconfig-core/src/main/java/com/inspur/edp/web/formconfig/core/entity/FormConfigEntity.java index ced2542dd2969d49e41e18fb25098168296f7093..b4c56bc94e744e8a921eb922279445fe0ca768dd 100644 --- a/web-formconfig-core/src/main/java/com/inspur/edp/web/formconfig/core/entity/FormConfigEntity.java +++ b/web-formconfig-core/src/main/java/com/inspur/edp/web/formconfig/core/entity/FormConfigEntity.java @@ -19,6 +19,7 @@ package com.inspur.edp.web.formconfig.core.entity; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.formconfig.api.dto.FormConfig; import com.inspur.edp.web.formconfig.api.dto.FormConfigItem; import io.iec.edp.caf.commons.utils.StringUtils; @@ -139,7 +140,7 @@ public class FormConfigEntity { } formConfig.setItems(items); } catch (JsonProcessingException e) { - throw new RuntimeException(e); + throw new WebCustomException("FormConfig toModel失败",e); } formConfig.setId(this.getId()); formConfig.setFormId(this.getFormId()); diff --git a/web-formmetadata-relycheck/.gitignore b/web-formmetadata-relycheck/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5ff6309b7199129c1afe4f4ec1906e640bec48c6 --- /dev/null +++ b/web-formmetadata-relycheck/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/web-formmetadata-relycheck/pom.xml b/web-formmetadata-relycheck/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..ef4c13efe9684eee99f0ebed61bdfc30a2d9ab9e --- /dev/null +++ b/web-formmetadata-relycheck/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + + com.inspur.edp + web + 0.1.9-SNAPSHOT + + + web-formmetadata-relycheck + jar + + + + com.inspur.edp + web-jitengine-common + + + com.inspur.edp + lcm-metadata-spi + 0.1.40-SNAPSHOT + + + com.inspur.edp + formserver-viewmodel + + + com.inspur.edp + web-jitengine-formmetadata + + + com.inspur.edp + web-designschema + + + + + diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/RelyCheckApplication.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/RelyCheckApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..a7e581eefd88b5c3b1196c44700ddc137c6b43a1 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/RelyCheckApplication.java @@ -0,0 +1,14 @@ +package com.inspur.edp.web.relycheck; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author noah + * 2023/8/9 14:30 + */ +@SpringBootApplication +public class RelyCheckApplication { + public static void main(String[] args) { + + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/config/RelyCheckConfig.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/config/RelyCheckConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..8342de80cbe6a75263ef6a31a6f6b9c015722cae --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/config/RelyCheckConfig.java @@ -0,0 +1,113 @@ +package com.inspur.edp.web.relycheck.config; + +import com.inspur.edp.web.relycheck.dependencygenerator.SchemaEntityDependencyGenerator; +import com.inspur.edp.web.relycheck.dependencygenerator.SchemaFieldDependencyGenerator; +import com.inspur.edp.web.relycheck.dependencyvalidator.VoElementValidator; +import com.inspur.edp.web.relycheck.dependencyvalidator.VoEntityValidator; +import com.inspur.edp.web.relycheck.dependencyvalidator.element.*; +import com.inspur.edp.web.relycheck.service.FormMetadataElementService; +import com.inspur.edp.web.relycheck.service.MobileFormMetadataElementService; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; + +/** + * relyCheck 的配置类 + * + * @author noah + * 2023/7/27 15:44 + */ +@Configuration(proxyBeanMethods = false) +public class RelyCheckConfig { + /** + * PC表单的element service + * + * @return + */ + @Bean + public FormMetadataElementService formMetadataElementService() { + return new FormMetadataElementService(); + } + + /** + * mobile 表单的element service + * + * @return + */ + @Bean + public MobileFormMetadataElementService mobileFormMetadataElementService() { + return new MobileFormMetadataElementService(); + } + + /** + * vo entity 校验 + * + * @return + */ + @Bean + public VoEntityValidator voEntityValidator() { + return new VoEntityValidator(); + } + + /** + * vo element 校验 + * + * @return + */ + @Bean + public VoElementValidator voElementValidator() { + return new VoElementValidator(); + } + + @Bean + public RequireValidator requireValidator() { + return new RequireValidator(); + } + + @Bean + public MultiLanguageValidator multiLanguageValidator(){ + return new MultiLanguageValidator(); + } + + @Bean + public LengthValidator lengthValidator(){ + return new LengthValidator(); + } + + @Bean + public PrecisionValidator precisionValidator(){ + return new PrecisionValidator(); + } + + @Bean + public DataTypeValidator dataTypeValidator(){ + return new DataTypeValidator(); + } + + @Bean + public EnumValueValidator enumValueValidator(){ + return new EnumValueValidator(); + } + + /** + * entity 校验依赖项构造 + * + * @return + */ + @Bean + @Scope(value = "prototype") + public SchemaEntityDependencyGenerator schemaEntityDependencyGenerator() { + return new SchemaEntityDependencyGenerator(); + } + + /** + * field 校验依赖项构造 + * + * @return + */ + @Bean + @Scope(value = "prototype") + public SchemaFieldDependencyGenerator schemaFieldDependencyGenerator() { + return new SchemaFieldDependencyGenerator(); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/constant/NeedCheckLengthType.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/constant/NeedCheckLengthType.java new file mode 100644 index 0000000000000000000000000000000000000000..05f2dc1f588e2cb0a8a1049163647202089516a0 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/constant/NeedCheckLengthType.java @@ -0,0 +1,45 @@ +package com.inspur.edp.web.relycheck.constant; + +import com.inspur.edp.web.common.utility.ListUtility; +import com.inspur.edp.web.designschema.elements.type.BigNumericType; +import com.inspur.edp.web.designschema.elements.type.NumericType; +import com.inspur.edp.web.designschema.elements.type.StringType; +import com.inspur.edp.web.designschema.elements.type.TextType; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 允许检测字段长度的类型 + * + * @author noah + * 2023/8/7 16:29 + */ +public class NeedCheckLengthType { + private List needCheckLengthList = new ArrayList<>(); + + public NeedCheckLengthType() { + this.needCheckLengthList.add(new BigNumericType().get$type()); + this.needCheckLengthList.add(new NumericType().get$type()); + this.needCheckLengthList.add(new StringType().get$type()); + this.needCheckLengthList.add(new TextType().get$type()); + } + + public static NeedCheckLengthType getInstance() { + return new NeedCheckLengthType(); + } + + public boolean contains(String $type) { + return ListUtility.contains(this.needCheckLengthList, $type); + } + + /** + * 获取所有可以检测length的 $type 参数 + * + * @return + */ + public List getNeedCheckLengthList() { + return this.needCheckLengthList; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/constant/NeedCheckPrecisionType.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/constant/NeedCheckPrecisionType.java new file mode 100644 index 0000000000000000000000000000000000000000..191b8f49f5e2fe91996fbc593308aa871fd7e8d3 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/constant/NeedCheckPrecisionType.java @@ -0,0 +1,29 @@ +package com.inspur.edp.web.relycheck.constant; + +import com.inspur.edp.web.common.utility.ListUtility; +import com.inspur.edp.web.designschema.elements.type.BigNumericType; +import com.inspur.edp.web.designschema.elements.type.NumericType; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author noah + * 2023/8/7 16:39 + */ +public class NeedCheckPrecisionType { + private List needCheckPrecisionList = new ArrayList<>(); + + public NeedCheckPrecisionType() { + this.needCheckPrecisionList.add(new BigNumericType().get$type()); + this.needCheckPrecisionList.add(new NumericType().get$type()); + } + + public static NeedCheckPrecisionType getInstance() { + return new NeedCheckPrecisionType(); + } + + public boolean contains(String $type) { + return ListUtility.contains(this.needCheckPrecisionList, $type); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/constant/RelyCheckType.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/constant/RelyCheckType.java new file mode 100644 index 0000000000000000000000000000000000000000..c8faa87d93dace6a011e1c21cdcea079f4b715f8 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/constant/RelyCheckType.java @@ -0,0 +1,61 @@ +package com.inspur.edp.web.relycheck.constant; + +/** + * 一致性检查类型定义 + * + * @author noah + */ +public enum RelyCheckType { + /** + * schema entity 实体类型 + */ + SchemaEntity { + @Override + public String getType() { + return "SchemaEntity"; + } + + @Override + public String getReferenceType() { + return "VoEntity"; + } +// +// @Override +// public String getValidateRefType() { +// return "Schema-VoEntity"; +// } + }, + /** + * schema field 字段类型 + */ + SchemaField { + @Override + public String getType() { + return "SchemaField"; + } + + @Override + public String getReferenceType() { + return "VoElement"; + } + +// @Override +// public String getValidateRefType() { +// return "Schema-VoElement"; +// } + }; + + /** + * 获取具体的类型参数字符串表示 + * + * @return + */ + public abstract String getType(); + + /** + * 获取对应的referenceType参数值 + * + * @return + */ + public abstract String getReferenceType(); +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/constant/ValidateConstants.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/constant/ValidateConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..80ad9c9611448768e23d14e57a4e55a5dcbdb7da --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/constant/ValidateConstants.java @@ -0,0 +1,22 @@ +package com.inspur.edp.web.relycheck.constant; + +/** + * @author noah + * 2023/8/7 17:28 + */ +public class ValidateConstants { + + public static final String Name = "名称"; + + public static final String Code = "编号"; + + /** + * 校验常量 逗号 + */ + public static final String Comma = ","; + + /** + * 校验常量 冒号 + */ + public static final String Colon = ":"; +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/MetadataElementGenerator.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/MetadataElementGenerator.java new file mode 100644 index 0000000000000000000000000000000000000000..12eea004d5ccc8f506545ca487f719054bc4c09f --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/MetadataElementGenerator.java @@ -0,0 +1,37 @@ +package com.inspur.edp.web.relycheck.dependencygenerator; + +import com.inspur.edp.lcm.metadata.spi.entity.MetadataElement; +import com.inspur.edp.web.relycheck.constant.RelyCheckType; +import com.inspur.edp.web.relycheck.dependencygenerator.entity.BaseSourceElement; + +/** + * 元数据 element 实体构造 + * + * @author noah + */ +class MetadataElementGenerator { + /** + * 构造 metadataElement 实例 + * + * @param type + * @param content + * @return + */ + static MetadataElement generate(String type, BaseSourceElement content) { + MetadataElement metadataElement = new MetadataElement(); + metadataElement.setType(type); + metadataElement.setContent(content); + return metadataElement; + } + + /** + * 构造 metadataElement 实例 + * + * @param relyCheckType + * @param content + * @return + */ + static MetadataElement generate(RelyCheckType relyCheckType, BaseSourceElement content) { + return generate(relyCheckType.getType(), content); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/MetadataVOElementLocatorGenerator.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/MetadataVOElementLocatorGenerator.java new file mode 100644 index 0000000000000000000000000000000000000000..8749e6aa8b64955b7bb9757e82d9949d47de8b1c --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/MetadataVOElementLocatorGenerator.java @@ -0,0 +1,49 @@ +package com.inspur.edp.web.relycheck.dependencygenerator; + +import com.inspur.edp.lcm.metadata.spi.entity.MetadataElementLocator; +import com.inspur.edp.web.relycheck.constant.RelyCheckType; + +import java.util.function.Supplier; + +/** + * metadataElementLocator 实例构造 + * + * @author noah + */ +class MetadataVOElementLocatorGenerator { + + + /** + * 构造 metadataElementLocator 实例 + * 主要参数是构造对应的 id 及 id + * + * @param id + * @return + */ + static MetadataElementLocator generate(RelyCheckType relyCheckType, String id) { + MetadataElementLocator metadataElementLocator = new MetadataElementLocator(); + metadataElementLocator.setId(id); + metadataElementLocator.setPath(relyCheckType.getReferenceType()); + return metadataElementLocator; + } + + /** + * 构造 metadataElementLocator 实例 + * 主要参数是构造对应的 id 及 path + * + * @param idSupplier + * @param pathSupplier + * @return + */ + static MetadataElementLocator generate(Supplier idSupplier, Supplier pathSupplier) { + MetadataElementLocator metadataElementLocator = new MetadataElementLocator(); + if (idSupplier != null) { + metadataElementLocator.setId(idSupplier.get()); + } + if (pathSupplier != null) { + metadataElementLocator.setPath(pathSupplier.get()); + } + + return metadataElementLocator; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/SchemaEntityDependencyGenerator.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/SchemaEntityDependencyGenerator.java new file mode 100644 index 0000000000000000000000000000000000000000..c943910e4ea8bc2cf86422a41d1352626ee7af92 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/SchemaEntityDependencyGenerator.java @@ -0,0 +1,90 @@ +package com.inspur.edp.web.relycheck.dependencygenerator; + +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.lcm.metadata.spi.entity.MetadataElementDependencyDetail; +import com.inspur.edp.web.common.utility.ListUtility; +import com.inspur.edp.web.formmetadata.metadata.formdom.FormDOM; +import com.inspur.edp.web.relycheck.constant.RelyCheckType; +import com.inspur.edp.web.relycheck.dependencygenerator.entity.SourceElementEntity; +import com.inspur.edp.web.relycheck.elements.CustomEntity; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +/** + * 表单元数据 schema entity 依赖项构造 + * 此处每次返回新实例的原因是该方法执行次数极少,定义bean的scope 为 prototype + * 所以为了更加方便垃圾回收 设计为每次 new 新实例 + * + * @author noah + */ +public class SchemaEntityDependencyGenerator { + + private final RelyCheckType entityRelyCheckType = RelyCheckType.SchemaEntity; + + /** + * 字段一致性检查 + * 字段生成项 + */ + @Resource + private SchemaFieldDependencyGenerator schemaFieldDependencyGenerator; + + /** + * 依据 schema entity 列表构造依赖 + * + * @param schemaCustomEntityList schema entity 列表 + * @return + */ + public List generateDependencyDetailWithSchemaEntityList(List schemaCustomEntityList, FormDOM formDOM, GspMetadata gspMetadata) { + if (ListUtility.isEmpty(schemaCustomEntityList)) { + return new ArrayList<>(0); + } + List dependencyDetailList = new ArrayList<>(); + schemaCustomEntityList.forEach(entityItem -> { + // 依据字段列表 构造对应的依赖信息 + List entityDependencyDetailList = this.generateDependencyDetailWithSchemaEntity(entityItem, formDOM, gspMetadata); + ListUtility.add(dependencyDetailList, entityDependencyDetailList); + }); + return dependencyDetailList; + } + + + /** + * 依据 schemaEntity 构造对应的依赖信息 + * + * @param schemaCustomEntity schema entity 信息 + */ + private List generateDependencyDetailWithSchemaEntity(CustomEntity schemaCustomEntity, FormDOM formDOM, GspMetadata gspMetadata) { + if (schemaCustomEntity == null) { + return new ArrayList<>(0); + } + List entityDependencyDetailList = new ArrayList<>(); + + MetadataElementDependencyDetail metadataElementDependencyDetail = new MetadataElementDependencyDetail(); + + // 构造传递的源参数 + SourceElementEntity sourceElementEntity = SourceElementEntity.init(schemaCustomEntity, formDOM, gspMetadata); + + metadataElementDependencyDetail.setSourceElement(MetadataElementGenerator.generate(entityRelyCheckType, sourceElementEntity)); + metadataElementDependencyDetail.setReferenceType(entityRelyCheckType.getReferenceType()); + metadataElementDependencyDetail.setTargetElementLocator(MetadataVOElementLocatorGenerator.generate(entityRelyCheckType, schemaCustomEntity.getId())); + + ListUtility.add(entityDependencyDetailList, metadataElementDependencyDetail); + + + if (schemaCustomEntity.getType() != null) { + // 添加对应的 field 字段依赖信息 + List elementDependencyDetailList = this.schemaFieldDependencyGenerator.generateDependencyDetailWithSchemaFieldList(schemaCustomEntity, schemaCustomEntity.getType().getFields(), formDOM, gspMetadata); + ListUtility.add(entityDependencyDetailList, elementDependencyDetailList); + + // 如果当前 entity 存在子表 那么递归进行子表依赖项的构造 + if (ListUtility.isNotEmpty(schemaCustomEntity.getType().getEntities())) { + List childEntityDependencyDetailList = this.generateDependencyDetailWithSchemaEntityList(schemaCustomEntity.getType().getEntities(), formDOM, gspMetadata); + ListUtility.add(entityDependencyDetailList, childEntityDependencyDetailList); + } + } + + return entityDependencyDetailList; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/SchemaFieldDependencyGenerator.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/SchemaFieldDependencyGenerator.java new file mode 100644 index 0000000000000000000000000000000000000000..16328350f05e2b97bf12df44044f0c9a5853a914 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/SchemaFieldDependencyGenerator.java @@ -0,0 +1,71 @@ +package com.inspur.edp.web.relycheck.dependencygenerator; + +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.lcm.metadata.spi.entity.MetadataElementDependencyDetail; +import com.inspur.edp.web.common.utility.ListUtility; + +import com.inspur.edp.web.formmetadata.metadata.formdom.FormDOM; +import com.inspur.edp.web.relycheck.constant.RelyCheckType; +import com.inspur.edp.web.relycheck.dependencygenerator.entity.SourceElementField; +import com.inspur.edp.web.relycheck.elements.CustomField; +import com.inspur.edp.web.relycheck.elements.CustomEntity; + + +import java.util.ArrayList; +import java.util.List; + +/** + * schema 字段依赖信息构造 + * + * @author noah + */ +public class SchemaFieldDependencyGenerator { + + private final RelyCheckType fieldRelyCheckType = RelyCheckType.SchemaField; + + /** + * 构造字段列表对应的依赖信息 + * + * @param fieldList schema 中的字段信息列表 + * @return + */ + public List generateDependencyDetailWithSchemaFieldList(CustomEntity schemaCustomEntity, List fieldList, FormDOM formDOM, GspMetadata gspMetadata) { + if (ListUtility.isEmpty(fieldList)) { + return new ArrayList<>(0); + } + + List metadataElementDependencyDetailList = new ArrayList<>(); + + fieldList.forEach(fieldItem -> { + // 从字段中构造对应的依赖信息 + MetadataElementDependencyDetail metadataElementDependencyDetail = this.generateDependencyDetailWithSchemaField(schemaCustomEntity, fieldItem, formDOM, gspMetadata); + ListUtility.add(metadataElementDependencyDetailList, metadataElementDependencyDetail); + }); + return metadataElementDependencyDetailList; + } + + /** + * 构造的是字段的依赖信息 + * + * @param fieldItem 传递的表单schema中美 + * @return + */ + private MetadataElementDependencyDetail generateDependencyDetailWithSchemaField(CustomEntity schemaCustomEntity, CustomField fieldItem, FormDOM formDOM, GspMetadata gspMetadata) { + if (fieldItem == null) { + return null; + } + MetadataElementDependencyDetail dependencyDetail = new MetadataElementDependencyDetail(); + + SourceElementField sourceElementField = SourceElementField.init(schemaCustomEntity, fieldItem, formDOM, gspMetadata); + + dependencyDetail.setSourceElement(MetadataElementGenerator.generate(fieldRelyCheckType, sourceElementField)); + dependencyDetail.setReferenceType(fieldRelyCheckType.getReferenceType()); + dependencyDetail.setTargetElementLocator(MetadataVOElementLocatorGenerator.generate( + () -> schemaCustomEntity.getId() + "/" + fieldItem.getId(), + () -> fieldRelyCheckType.getReferenceType() + + )); + + return dependencyDetail; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/entity/BaseSourceElement.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/entity/BaseSourceElement.java new file mode 100644 index 0000000000000000000000000000000000000000..b1cf262e615d90d77ddc38e3c8c2de34d309e2f2 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/entity/BaseSourceElement.java @@ -0,0 +1,76 @@ +package com.inspur.edp.web.relycheck.dependencygenerator.entity; + +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; + +/** + * entity 和 field的传递参数 + * 传递对应的元数据相关信息 + * + * @author noah + * 2023/7/25 11:40 + */ +public class BaseSourceElement { + /** + * 元数据id参数 + */ + private String metadataId; + /** + * 元数据code参数 + */ + private String metadataCode; + /** + * 元数据name参数 + */ + private String metadataName; + /** + * 元数据 namespace参数 + */ + private String metadataNameSpace; + + public String getMetadataId() { + return metadataId; + } + + public void setMetadataId(String metadataId) { + this.metadataId = metadataId; + } + + public String getMetadataCode() { + return metadataCode; + } + + public void setMetadataCode(String metadataCode) { + this.metadataCode = metadataCode; + } + + public String getMetadataName() { + return metadataName; + } + + public void setMetadataName(String metadataName) { + this.metadataName = metadataName; + } + + public String getMetadataNameSpace() { + return metadataNameSpace; + } + + public void setMetadataNameSpace(String metadataNameSpace) { + this.metadataNameSpace = metadataNameSpace; + } + + /** + * 依据元数据进行参数构造 + * + * @param gspMetadata + */ + protected void initWithGspMetadata(GspMetadata gspMetadata) { + if (gspMetadata == null) { + return; + } + this.setMetadataId(gspMetadata.getHeader().getId()); + this.setMetadataCode(gspMetadata.getHeader().getCode()); + this.setMetadataName(gspMetadata.getHeader().getName()); + this.setMetadataNameSpace(gspMetadata.getHeader().getNameSpace()); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/entity/SourceElementEntity.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/entity/SourceElementEntity.java new file mode 100644 index 0000000000000000000000000000000000000000..42aedcd55779cc2d24981b49005c6b5286458cb4 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/entity/SourceElementEntity.java @@ -0,0 +1,44 @@ +package com.inspur.edp.web.relycheck.dependencygenerator.entity; + +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.web.formmetadata.metadata.formdom.FormDOM; +import com.inspur.edp.web.relycheck.elements.CustomEntity; + + +/** + * 用于记录需要针对entity进行验证时,传递的参数值 + * + * @author noah + * 2023/7/25 11:34 + */ +public class SourceElementEntity extends BaseSourceElement { + private CustomEntity sourceCustomEntity; + private FormDOM formDOM; + + public CustomEntity getSourceEntity() { + return sourceCustomEntity; + } + + public FormDOM getFormDOM() { + return formDOM; + } + + private SourceElementEntity() { + } + + /** + * sourceEntity的参数构造 + * @param sourceCustomEntity + * @param formDOM + * @param gspMetadata + * @return + */ + public static SourceElementEntity init(CustomEntity sourceCustomEntity, FormDOM formDOM, GspMetadata gspMetadata) { + SourceElementEntity sourceElementEntity = new SourceElementEntity(); + sourceElementEntity.sourceCustomEntity = sourceCustomEntity; + sourceElementEntity.formDOM = formDOM; + sourceElementEntity.initWithGspMetadata(gspMetadata); + return sourceElementEntity; + } + +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/entity/SourceElementField.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/entity/SourceElementField.java new file mode 100644 index 0000000000000000000000000000000000000000..704c004b9e22adf04da06a96a415b4c637c6ad7c --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencygenerator/entity/SourceElementField.java @@ -0,0 +1,42 @@ +package com.inspur.edp.web.relycheck.dependencygenerator.entity; + +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.web.formmetadata.metadata.formdom.FormDOM; +import com.inspur.edp.web.relycheck.elements.CustomField; +import com.inspur.edp.web.relycheck.elements.CustomEntity; + +/** + * 用于进行字段验证时 ,字段验证需要的参数值 + * + * @author noah + * 2023/7/25 11:34 + */ +public class SourceElementField extends BaseSourceElement { + private CustomEntity sourceCustomEntity; + private CustomField sourceField; + private FormDOM formDOM; + + public CustomEntity getSourceEntity() { + return sourceCustomEntity; + } + + public CustomField getSourceField() { + return sourceField; + } + + public FormDOM getFormDOM() { + return formDOM; + } + + private SourceElementField() { + } + + public static SourceElementField init(CustomEntity sourceCustomEntity, CustomField sourceField, FormDOM formDOM, GspMetadata gspMetadata) { + SourceElementField sourceElementField = new SourceElementField(); + sourceElementField.sourceCustomEntity = sourceCustomEntity; + sourceElementField.sourceField = sourceField; + sourceElementField.formDOM = formDOM; + sourceElementField.initWithGspMetadata(gspMetadata); + return sourceElementField; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/AbstractDependencyValidator.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/AbstractDependencyValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..f60a48b14e882ed2eba5947c2ccfd3f21af392be --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/AbstractDependencyValidator.java @@ -0,0 +1,17 @@ +package com.inspur.edp.web.relycheck.dependencyvalidator; + +import com.inspur.edp.lcm.metadata.spi.entity.ValidateResult; +import com.inspur.edp.lcm.metadata.spi.entity.ValidationLevelEnum; +import com.inspur.edp.web.relycheck.utility.ValidateResultUtility; + +/** + * 定义抽象类 + * + * @author noah + */ +public abstract class AbstractDependencyValidator { + + + + +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/VoElementValidator.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/VoElementValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..037ab1d795eb98f2f090b2c719e839d27625710d --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/VoElementValidator.java @@ -0,0 +1,174 @@ +package com.inspur.edp.web.relycheck.dependencyvalidator; + +import com.inspur.edp.formserver.viewmodel.GspViewModel; +import com.inspur.edp.formserver.viewmodel.GspViewModelElement; +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.lcm.metadata.spi.MetadataElementValidator; +import com.inspur.edp.lcm.metadata.spi.entity.MetadataElement; +import com.inspur.edp.lcm.metadata.spi.entity.ValidateResult; +import com.inspur.edp.web.common.customexception.WebCustomException; +import com.inspur.edp.web.common.utility.StringUtility; +import com.inspur.edp.web.relycheck.constant.RelyCheckType; +import com.inspur.edp.web.relycheck.constant.ValidateConstants; +import com.inspur.edp.web.relycheck.dependencygenerator.entity.SourceElementField; +import com.inspur.edp.web.relycheck.dependencyvalidator.element.*; +import com.inspur.edp.web.relycheck.utility.StringConcatUtility; +import com.inspur.edp.web.relycheck.utility.ValidateResultUtility; + +import javax.annotation.Resource; + +/** + * VoElement 依赖检查 + * + * @author noah + */ +public class VoElementValidator extends AbstractDependencyValidator implements MetadataElementValidator { + @Resource + private RequireValidator requireValidator; + + @Resource + private MultiLanguageValidator multiLanguageValidator; + + @Resource + private LengthValidator lengthValidator; + + @Resource + private PrecisionValidator precisionValidator; + + @Resource + private DataTypeValidator dataTypeValidator; + + @Resource + private EnumValueValidator enumValueValidator; + + @Override + public String getReferenceType() { + return RelyCheckType.SchemaField.getReferenceType(); + } + + @Override + public ValidateResult validate(MetadataElement sourceMetadataElement, MetadataElement targetMetadataElement, GspMetadata sourceGspMetadata, GspMetadata targetGspMetadata) { + if (targetGspMetadata == null) { + // 如果VO元数据不存在 从VOEntity中进行校验 不在此处校验 + return ValidateResultUtility.success(); + } + + // 目标元数据必须为VO元数据 + if (!(targetGspMetadata.getContent() instanceof GspViewModel)) { + throw new WebCustomException("表单元数据字段校验,目标类型必须为GspViewModel,当前为:" + targetGspMetadata.getContent().getClass().getName()); + } + + ValidateResult warningValidateResult = ValidateResultUtility.success(); + if (sourceMetadataElement.getType().equals(RelyCheckType.SchemaField.getType()) && + targetMetadataElement.getType().equals(RelyCheckType.SchemaField.getReferenceType())) { + SourceElementField field = (SourceElementField) sourceMetadataElement.getContent(); + GspViewModelElement gspViewModelElement = (GspViewModelElement) targetMetadataElement.getContent(); + // 新增字段不关心 放在实体校验中进行warning 提示 + + String voMetadataName = targetGspMetadata.getHeader().getName(); + String formMetadataName = sourceGspMetadata.getHeader().getName(); + String entityCode = field.getSourceEntity().getCode(); + + ElementValidateParameter validateParameter = new ElementValidateParameter() { + { + this.setFormMetadata(sourceGspMetadata); + this.setSourceElementField(field); + this.setGspViewModelElement(gspViewModelElement); + this.setViewModelMetadata(targetGspMetadata); + this.setVoMetadataName(voMetadataName); + this.setFormMetadataName(formMetadataName); + this.setEntityCode(entityCode); + } + }; + + + // 1.删除字段 表中删除了字段 + if (gspViewModelElement == null) { + return ValidateResultUtility.failureWithError(String.format("视图对象%1$s中子表%2$s删除了字段%3$s" + ValidateConstants.Comma + "请在表单%4$s的实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(voMetadataName, true), + StringConcatUtility.concatWithCodePrefix(entityCode, true), + StringConcatUtility.concatWithCodePrefix(field.getSourceField().getCode(), true), + StringConcatUtility.concatWithNamePrefix(formMetadataName, true))); + } + // 2.修改字段 code,理论上 字段code是不允许更改 + if (!StringUtility.equals(field.getSourceField().getCode(), gspViewModelElement.getCode())) { + return ValidateResultUtility.failureWithError(String.format("视图对象%1$s中子表%2$s的字段编号由%3$s更改为%4$s" + ValidateConstants.Comma + "请在表单%5$s的实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(voMetadataName, true), + StringConcatUtility.concatWithCodePrefix(entityCode, true), + StringConcatUtility.concatWithCodePrefix(field.getSourceField().getCode(), true), + StringConcatUtility.concatWithCodePrefix(gspViewModelElement.getCode(), true), + StringConcatUtility.concatWithNamePrefix(formMetadataName, true))); + } + + // 3.修改字段名称,表单不是必须需要调整,但可以依据新的字段名称进行调整 warning + if (!StringUtility.equals(field.getSourceField().getName(), gspViewModelElement.getName())) { + warningValidateResult = ValidateResultUtility.failureWithWarning(String.format("视图对象%1$s中子表%2$s的字段名称由%3$s更改为%4$s" + ValidateConstants.Comma + "请在表单%5$s的实体树种执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(voMetadataName, true), + StringConcatUtility.concatWithCodePrefix(entityCode, true), + StringConcatUtility.concatWithCodePrefix(field.getSourceField().getCode(), true), + StringConcatUtility.concatWithNamePrefix(gspViewModelElement.getName(), true), + StringConcatUtility.concatWithNamePrefix(formMetadataName, true) + )); + } + + // 是否必填 + ValidateResult requireValidateResult = this.requireValidator.validate(validateParameter); + if (ValidateResultUtility.canContinute(requireValidateResult)) { + warningValidateResult = requireValidateResult; + } else { + return requireValidateResult; + } + + + // 是否多语 + ValidateResult multiLanguageValidateResult = this.multiLanguageValidator.validate(validateParameter); + if (ValidateResultUtility.canContinute(multiLanguageValidateResult)) { + warningValidateResult = multiLanguageValidateResult; + } else { + return multiLanguageValidateResult; + } + + // 比较长度 + // 仅比较存在长度的字段参数 + ValidateResult lengthValidateResult = this.lengthValidator.validate(validateParameter); + if (ValidateResultUtility.canContinute(lengthValidateResult)) { + warningValidateResult = lengthValidateResult; + } else { + return lengthValidateResult; + } + + // 比较精度 + ValidateResult precisionValidateResult = this.precisionValidator.validate(validateParameter); + if (ValidateResultUtility.canContinute(precisionValidateResult)) { + warningValidateResult = precisionValidateResult; + } else { + return precisionValidateResult; + } + + + // 比较数据类型 + ValidateResult checkDataTypeRelateResult = this.dataTypeValidator.validate(validateParameter); + if (ValidateResultUtility.canContinute(checkDataTypeRelateResult)) { + warningValidateResult = checkDataTypeRelateResult; + } else { + return checkDataTypeRelateResult; + } + + // 比较枚举值 首先如果数据类型发生了变更,需要先检测数据类型发生了变化 + // 在检测枚举值是否发生变化时,可以认为类型一致 且均为枚举类型 + ValidateResult enumValueValidateResul = this.enumValueValidator.validate(validateParameter); + if (ValidateResultUtility.canContinute(enumValueValidateResul)) { + warningValidateResult = enumValueValidateResul; + } else { + return enumValueValidateResul; + } + + } + + if (!warningValidateResult.isValid()) { + return warningValidateResult; + } + return ValidateResultUtility.success(); + } + +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/VoEntityValidator.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/VoEntityValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..aa10216897ce5ebca5ec6aacc06b991fc906c79b --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/VoEntityValidator.java @@ -0,0 +1,113 @@ +package com.inspur.edp.web.relycheck.dependencyvalidator; + +import com.inspur.edp.formserver.viewmodel.GspViewObject; +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.lcm.metadata.spi.MetadataElementValidator; +import com.inspur.edp.lcm.metadata.spi.entity.MetadataElement; +import com.inspur.edp.lcm.metadata.spi.entity.ValidateResult; +import com.inspur.edp.web.common.logger.WebLogger; +import com.inspur.edp.web.common.utility.StringUtility; +import com.inspur.edp.web.relycheck.constant.RelyCheckType; +import com.inspur.edp.web.relycheck.constant.ValidateConstants; +import com.inspur.edp.web.relycheck.dependencygenerator.entity.SourceElementEntity; +import com.inspur.edp.web.relycheck.utility.StringConcatUtility; +import com.inspur.edp.web.relycheck.utility.ValidateResultUtility; + +import java.util.concurrent.atomic.AtomicReference; + +/** + * 关联的 VoEntity 依赖验证 + * + * @author noah + */ +public class VoEntityValidator extends AbstractDependencyValidator implements MetadataElementValidator { + private final RelyCheckType relyCheckType = RelyCheckType.SchemaEntity; + + @Override + public String getReferenceType() { + return RelyCheckType.SchemaEntity.getReferenceType(); + } + + @Override + public ValidateResult validate(MetadataElement sourceMetadataElement, MetadataElement targetMetadataElement, + GspMetadata sourceGspMetadata, GspMetadata targetGspMetadata) { + if (sourceMetadataElement != null && sourceGspMetadata != null && + sourceMetadataElement.getType().equals(relyCheckType.getType()) && + targetMetadataElement.getType().equals("VoEntity")) { + // 比较 SchemaEntity 的名称 + SourceElementEntity schemaEntity = (SourceElementEntity) sourceMetadataElement.getContent(); + GspViewObject gspViewObject = (GspViewObject) targetMetadataElement.getContent(); + String formMetadataName = sourceGspMetadata.getHeader().getName(); + // 1.VO元数据被删除 + if (targetGspMetadata == null) { + // 说明VO元数据已经不存在 那么需要将对应表单移除 + // 理论上不应该出现此种情况 + return ValidateResultUtility.failureWithError(String.format("表单%1$s关联视图对象不存在" + ValidateConstants.Comma + "该表单将无法正确运行" + ValidateConstants.Comma + "请调整关联视图对象或移除该表单", + StringConcatUtility.concatWithNamePrefix(formMetadataName, true) + )); + } + String voMetadataName = targetGspMetadata.getHeader().getName(); + // 2.VO元数据中子表删除 + if (targetMetadataElement.getContent() == null) { + // 说明删除了对应的对象 + return ValidateResultUtility.failureWithError(String.format("视图对象%1$s删除了子表%2$s" + ValidateConstants.Comma + "请在表单%3$s的实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(voMetadataName, true), + StringConcatUtility.concatWithCodePrefix(schemaEntity.getSourceEntity().getCode(), true), + StringConcatUtility.concatWithNamePrefix(formMetadataName, true) + )); + } + // 3.VO元数据中子表编号更改 + if (!StringUtility.equals(schemaEntity.getSourceEntity().getCode(), gspViewObject.getCode())) { + return ValidateResultUtility.failureWithError(String.format("视图对象%1$s更改了%2$s的子表" + ValidateConstants.Comma + "请在表单%3$s的实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(voMetadataName, true), + StringConcatUtility.concatWithCodePrefix(gspViewObject.getCode(), true), + StringConcatUtility.concatWithNamePrefix(formMetadataName, true) + )); + } + + // 判断 schema 中的字段是否全部在vo 存在 + // 字段删除判断放在vo element 校验中 +// AtomicReference schemaEntityFieldCode = new AtomicReference<>(""); +// boolean allSchemaFieldsInVo = schemaEntity.getSourceEntity().getType().getFields().stream().allMatch(t -> { +// boolean exists = gspViewObject.getContainElements().stream().anyMatch(m -> m.getCode().equals(t.getCode())); +// if (!exists) { +// schemaEntityFieldCode.set(t.getCode()); +// } +// return exists; +// } +// ); +// if (!allSchemaFieldsInVo) { +// return this.failureWithError(String.format("视图对象%1$s删除了字段" + ValidateConstants.Colon + "%2$s" + ValidateConstants.Comma + "请在表单%3$s的实体树中执行更新schema操作", +// StringConcatUtility.concatWithNamePrefix(voMetadataName, true), +// StringConcatUtility.concatWithCodePrefix(schemaEntityFieldCode.get(), true), +// StringConcatUtility.concatWithNamePrefix(formMetadataName, true) +// )); +// } + + // 判断vo 中的字段是否全部在 schema 中 + AtomicReference addedVoFieldCode = new AtomicReference<>(""); + AtomicReference addedVoFieldName = new AtomicReference<>(""); + boolean allVoFieldsInSchema = gspViewObject.getContainElements().stream().allMatch(t -> { + boolean exists = schemaEntity.getSourceEntity().getType().getFields().stream().anyMatch(m -> m.getCode().equals(t.getCode())); + if (!exists) { + addedVoFieldCode.set(t.getCode()); + addedVoFieldName.set(t.getName()); + } + return exists; + } + ); + + if (!allVoFieldsInSchema) { + return ValidateResultUtility.failureWithWarning(String.format("视图对象%1$s新增了字段" + ValidateConstants.Colon + "%2$s" + ValidateConstants.Comma + "若要在表单使用该字段" + ValidateConstants.Comma + "请在表单%3$s的实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(voMetadataName, true), + StringConcatUtility.concatWithCodePrefix(addedVoFieldCode.get(), true), + StringConcatUtility.concatWithNamePrefix(formMetadataName, true) + )); + } + + } else { + WebLogger.Instance.info("SchemaEntity 校验,不是有效的 SchemaEntity 类型"); + } + return ValidateResultUtility.success(); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/BaseElementValidator.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/BaseElementValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..9d40f7eaae5f74c26dd7442128bb0153c873e313 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/BaseElementValidator.java @@ -0,0 +1,57 @@ +package com.inspur.edp.web.relycheck.dependencyvalidator.element; + +import com.inspur.edp.formserver.viewmodel.GspViewModelElement; +import com.inspur.edp.lcm.metadata.spi.entity.ValidateResult; +import com.inspur.edp.web.relycheck.dependencygenerator.entity.SourceElementField; +import com.inspur.edp.web.relycheck.elements.CustomField; +import com.inspur.edp.web.relycheck.utility.ValidateResultUtility; + +import java.util.Optional; + + +/** + * element 依赖检查 + * + * @author noah + * 2023/8/10 10:45 + */ +public abstract class BaseElementValidator { + public abstract ValidateResult validate(ElementValidateParameter parameter); + + protected String getVoMetadataName(ElementValidateParameter parameter) { + return Optional.ofNullable(parameter.getVoMetadataName()).orElseGet(() -> parameter.getViewModelMetadata().getHeader().getName()); + } + + protected String getEntityCode(ElementValidateParameter parameter) { + return Optional.ofNullable(parameter.getEntityCode()).orElseGet(() -> parameter.getSourceElementField().getSourceEntity().getCode()); + } + + protected String getFormMetadataName(ElementValidateParameter parameter) { + return Optional.ofNullable(parameter.getFormMetadataName()).orElseGet(() -> parameter.getFormMetadata().getHeader().getName()); + } + + protected String getSourceFieldCode(ElementValidateParameter parameter) { + return parameter.getSourceElementField().getSourceField().getCode(); + } + + protected CustomField getSourceField(ElementValidateParameter parameter) { + return parameter.getSourceElementField().getSourceField(); + } + + /** + * 构造快捷访问 + * + * @return + */ + protected ValidateResult success() { + return ValidateResultUtility.success(); + } + + protected ValidateResult failureWithWarning(String message) { + return ValidateResultUtility.failureWithWarning(message); + } + + protected ValidateResult failureWithError(String message){ + return ValidateResultUtility.failureWithError(message); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/DataTypeValidator.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/DataTypeValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..aa573877f5276731c75e55fa128410612e7a5a24 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/DataTypeValidator.java @@ -0,0 +1,113 @@ +package com.inspur.edp.web.relycheck.dependencyvalidator.element; + +import com.inspur.edp.cef.designtime.api.element.GspElementDataType; +import com.inspur.edp.formserver.viewmodel.GspViewModel; +import com.inspur.edp.lcm.metadata.spi.entity.ValidateResult; +import com.inspur.edp.web.common.utility.ListUtility; +import com.inspur.edp.web.designschema.elements.ComplexField; +import com.inspur.edp.web.designschema.elements.Entity; +import com.inspur.edp.web.designschema.elements.Field; +import com.inspur.edp.web.designschema.elements.Schema; +import com.inspur.edp.web.designschema.generator.SchemaBuilder; +import com.inspur.edp.web.relycheck.constant.ValidateConstants; +import com.inspur.edp.web.relycheck.dependencygenerator.entity.SourceElementField; +import com.inspur.edp.web.relycheck.elements.CustomEntity; +import com.inspur.edp.web.relycheck.elements.CustomField; +import com.inspur.edp.web.relycheck.utility.StringConcatUtility; +import com.inspur.edp.web.relycheck.utility.ValidateResultUtility; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * 数据类型验证 + * + * @author noah + * 2023/8/10 16:50 + */ +public class DataTypeValidator extends BaseElementValidator { + @Override + public ValidateResult validate(ElementValidateParameter parameter) { + ValidateResult warningValidateResult = ValidateResultUtility.success(); + + SchemaBuilder schemaBuilder = new SchemaBuilder(); + GspViewModel targetViewModel = (GspViewModel) parameter.getViewModelMetadata().getContent(); + // 通过当前的ViewModel构造出来对应的表单schema节点 + Schema schema = schemaBuilder.buildWithScene(targetViewModel, "", false); + Optional optionalTargetFindField = this.findFieldInFormSchema(schema, parameter.getSourceElementField()); + + // 如果查找到目标 Field + if (optionalTargetFindField.isPresent()) { + GspElementDataType voFieldType = parameter.getGspViewModelElement().getMDataType(); + Field targetFindField = optionalTargetFindField.get(); + CustomField sourceField = this.getSourceField(parameter); + // 字段类型比较 + if (!sourceField.getType().get$type().equals(targetFindField.getType().get$type())) { + return ValidateResultUtility.failureWithError(String.format("视图对象%1$s中子表%2$s的字段%3$s类型变更为" + ValidateConstants.Colon + "%4$s" + ValidateConstants.Comma + "而表单字段类型为" + ValidateConstants.Colon + "%5$s" + ValidateConstants.Comma + "实际应为" + ValidateConstants.Colon + "%6$s" + ValidateConstants.Comma + "请在表单%7$s的实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(this.getVoMetadataName(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getEntityCode(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getSourceFieldCode(parameter), true), + StringConcatUtility.concat("", voFieldType.name(), true), + StringConcatUtility.concat("", sourceField.get$type(), true), + StringConcatUtility.concat("", targetFindField.get$type(), true), + StringConcatUtility.concatWithNamePrefix(this.getFormMetadataName(parameter), true) + )); + } + + // 复杂类型更换 例如 从人员 UDT 更改为 部门 UDT + if (targetFindField instanceof ComplexField) { + ComplexField targetComplexField = (ComplexField) targetFindField; + + if (!sourceField.getType().getName().equals(targetComplexField.getType().getName())) { + return ValidateResultUtility.failureWithError(String.format("视图对象%1$s中子表%2$s的字段%3$s的引用关系由" + ValidateConstants.Colon + "%4$s调整为" + ValidateConstants.Colon + "%5$s" + ValidateConstants.Comma + "请在表单%6$s的实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(this.getVoMetadataName(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getEntityCode(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getSourceFieldCode(parameter), true), + StringConcatUtility.concat("", sourceField.getType().getName(), true), + StringConcatUtility.concat("", targetComplexField.getType().getName(), true), + StringConcatUtility.concatWithNamePrefix(this.getFormMetadataName(parameter), true) + )); + } + } + + } + return warningValidateResult; + } + + private Optional findFieldInFormSchema(Schema schema, SourceElementField sourceElementField) { + CustomEntity sourceEntity = sourceElementField.getSourceEntity(); + CustomField sourceField = sourceElementField.getSourceField(); + + Entity relateEntity = this.findEntityRescure(schema.getEntities(), sourceEntity); + if (relateEntity != null) { + // 获取对应的字段 + Optional optionalField = relateEntity.getType().getFields().stream().filter(t -> t.getId().equals(sourceField.getId()) && t.getCode().equals(sourceField.getCode())).findFirst(); + return optionalField; + } + return Optional.empty(); + } + + private Entity findEntityRescure(List entityList, CustomEntity sourceEntity) { + if (ListUtility.isEmpty(entityList)) { + return null; + } + Optional optionalEntity = entityList.stream().filter(t -> t.getId().equals(sourceEntity.getId()) && t.getCode().equals(sourceEntity.getCode())).findFirst(); + if (optionalEntity.isPresent()) { + return optionalEntity.get(); + } + + List hasChildrenEntities = entityList.stream().filter(t -> ListUtility.isNotEmpty(t.getType().getEntities())).collect(Collectors.toList()); + if (ListUtility.isNotEmpty(hasChildrenEntities)) { + for (Entity entity : hasChildrenEntities) { + Entity result = this.findEntityRescure(entity.getType().getEntities(), sourceEntity); + if (result != null) { + return result; + } + } + } + return null; + } + + +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/ElementValidateParameter.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/ElementValidateParameter.java new file mode 100644 index 0000000000000000000000000000000000000000..7dc074361f23d8e4191cf7763942bbce0062593f --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/ElementValidateParameter.java @@ -0,0 +1,47 @@ +package com.inspur.edp.web.relycheck.dependencyvalidator.element; + +import com.inspur.edp.formserver.viewmodel.GspViewModelElement; +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.web.relycheck.dependencygenerator.entity.SourceElementField; +import lombok.Data; + +/** + * element 验证参数 + * + * @author noah + * 2023/8/10 10:48 + */ +@Data +public class ElementValidateParameter { + /** + * 校验源字段 + */ + private SourceElementField sourceElementField; + /** + * 校验viewmodel 字段 + */ + private GspViewModelElement gspViewModelElement; + /** + * 校验 表单元数据 + */ + private GspMetadata formMetadata; + /** + * 校验 viewmodel 元数据 + */ + private GspMetadata viewModelMetadata; + + /** + * vo 元数据 name + */ + private String voMetadataName; + + /** + * 表单元数据 name + */ + private String formMetadataName; + + /** + * vo 关联实体 code + */ + private String entityCode; +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/EnumValueValidator.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/EnumValueValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..28a77938f0c206661675e1e7230fe73408ac141e --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/EnumValueValidator.java @@ -0,0 +1,59 @@ +package com.inspur.edp.web.relycheck.dependencyvalidator.element; + +import com.inspur.edp.cef.designtime.api.collection.GspEnumValueCollection; +import com.inspur.edp.lcm.metadata.spi.entity.ValidateResult; +import com.inspur.edp.web.common.serialize.SerializeUtility; +import com.inspur.edp.web.relycheck.constant.ValidateConstants; +import com.inspur.edp.web.relycheck.elements.type.CustomEnumItem; +import com.inspur.edp.web.relycheck.utility.StringConcatUtility; +import com.inspur.edp.web.relycheck.utility.ValidateResultUtility; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * 枚举元素验证 + * + * @author noah + * 2023/8/10 16:56 + */ +public class EnumValueValidator extends BaseElementValidator { + @Override + public ValidateResult validate(ElementValidateParameter parameter) { + ValidateResult warningValidateResult = ValidateResultUtility.success(); + + GspEnumValueCollection voEnumValueCollection = parameter.getGspViewModelElement().getContainEnumValues(); + List fieldCustomEnumItemList = this.getSourceField(parameter).getType().getEnumValues(); + + // 必须是枚举类型比较对应的枚举值 + if (this.getSourceField(parameter).getType().get$type().equals("EnumType") && parameter.getGspViewModelElement().getObjectType().name().equals("Enum")) { +// if (voEnumValueCollection.size() != fieldCustomEnumItemList.size()) { +// return this.failureWithError(String.format("视图对象%1$s中子表%2$s更改了%3$s的枚举项。为使表单生效" + ValidateConstants.Comma + "请在表单%4$s的实体树中执行更新schema操作", +// StringConcatUtility.concatWithNamePrefix(voMetadataName, true), +// StringConcatUtility.concatWithCodePrefix(entityCode, true), +// StringConcatUtility.concatWithCodePrefix(field.getSourceField().getCode(), true), +// StringConcatUtility.concatWithNamePrefix(formMetadataName, true) +// )); +// } + + List customEnumItemList = voEnumValueCollection.stream().map(t -> { + CustomEnumItem customEnumItem = new CustomEnumItem(); + customEnumItem.setName(t.getName()); + customEnumItem.setValue(t.getValue()); + return customEnumItem; + }).collect(Collectors.toList()); + String serializedVoEnum = SerializeUtility.getInstance().serialize(customEnumItemList); + String serializedFieldEnum = SerializeUtility.getInstance().serialize(fieldCustomEnumItemList); + if (!serializedVoEnum.equals(serializedFieldEnum)) { + return ValidateResultUtility.failureWithError(String.format("视图对象%1$s中子表%2$s更改了%3$s的枚举项,其中视图对象中枚举项为:%5$s,表单字段枚举项为:%6$s。为使表单生效" + ValidateConstants.Comma + "请在表单%4$s的实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(this.getVoMetadataName(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getEntityCode(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getSourceFieldCode(parameter), true), + StringConcatUtility.concatWithNamePrefix(this.getFormMetadataName(parameter), true), + serializedVoEnum, serializedFieldEnum + )); + } + } + return warningValidateResult; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/LengthValidator.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/LengthValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..3fe0b0aaa04de372db5225b3ec81bd1312f78c52 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/LengthValidator.java @@ -0,0 +1,45 @@ +package com.inspur.edp.web.relycheck.dependencyvalidator.element; + +import com.inspur.edp.lcm.metadata.spi.entity.ValidateResult; +import com.inspur.edp.web.relycheck.constant.NeedCheckLengthType; +import com.inspur.edp.web.relycheck.constant.ValidateConstants; +import com.inspur.edp.web.relycheck.utility.StringConcatUtility; +import com.inspur.edp.web.relycheck.utility.ValidateResultUtility; + +/** + * 长度校验 + * + * @author noah + * 2023/8/10 14:01 + */ +public class LengthValidator extends BaseElementValidator { + @Override + public ValidateResult validate(ElementValidateParameter parameter) { + ValidateResult warningValidateResult = ValidateResultUtility.success(); + if (NeedCheckLengthType.getInstance().contains(this.getSourceField(parameter).getType().get$type())) { + int voElementLength = parameter.getGspViewModelElement().getLength(); + int fieldLength = this.getSourceField(parameter).getType().getLength(); + if (voElementLength > fieldLength) { + warningValidateResult = ValidateResultUtility.failureWithWarning(String.format("视图对象%1$s中子表%2$s的字段%3$s长度增加为" + ValidateConstants.Colon + "%4$s" + ValidateConstants.Comma + "而表单对应字段长度为" + ValidateConstants.Colon + "%5$s。为同步表单控件长度属性" + ValidateConstants.Comma + "请在表单%6$s的实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(this.getVoMetadataName(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getEntityCode(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getSourceFieldCode(parameter), true), + StringConcatUtility.concat("", String.valueOf(voElementLength), true), + StringConcatUtility.concat("", String.valueOf(fieldLength), true), + StringConcatUtility.concatWithNamePrefix(this.getFormMetadataName(parameter), true) + )); + } + if (voElementLength < fieldLength) { + return ValidateResultUtility.failureWithError(String.format("视图对象%1$s中子表%2$s的字段%3$s长度减小了为" + ValidateConstants.Colon + "%4$s" + ValidateConstants.Comma + "而表单对应字段长度为" + ValidateConstants.Colon + "%5$s。为同步表单控件长度属性" + ValidateConstants.Comma + "请在表单%6$s的实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(this.getVoMetadataName(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getEntityCode(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getSourceFieldCode(parameter), true), + StringConcatUtility.concat("", String.valueOf(voElementLength), true), + StringConcatUtility.concat("", String.valueOf(fieldLength), true), + StringConcatUtility.concatWithNamePrefix(this.getFormMetadataName(parameter), true) + )); + } + } + return warningValidateResult; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/MultiLanguageValidator.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/MultiLanguageValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..c99d3c46bc05d436e1b99cacdf4e3e77660b7420 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/MultiLanguageValidator.java @@ -0,0 +1,38 @@ +package com.inspur.edp.web.relycheck.dependencyvalidator.element; + +import com.inspur.edp.lcm.metadata.spi.entity.ValidateResult; +import com.inspur.edp.web.relycheck.constant.ValidateConstants; +import com.inspur.edp.web.relycheck.utility.StringConcatUtility; +import com.inspur.edp.web.relycheck.utility.ValidateResultUtility; + +/** + * 是否多语验证 + * @author noah + * 2023/8/10 16:35 + */ +public class MultiLanguageValidator extends BaseElementValidator { + @Override + public ValidateResult validate(ElementValidateParameter parameter) { + ValidateResult warningValidateResult = ValidateResultUtility.success(); + + boolean voElementIsMultiLanguage = parameter.getGspViewModelElement().getIsMultiLanguage(); + boolean fieldIsMultiLanguage = this.getSourceField(parameter).getMultiLanguage(); + if (voElementIsMultiLanguage && !fieldIsMultiLanguage) { + return ValidateResultUtility.failureWithError(String.format("视图对象%1$s中子表%2$s的字段%3$s启用多语属性" + ValidateConstants.Comma + "而表单对应字段不是多语属性。若要使表单控件变更为多语控件" + ValidateConstants.Comma + "请在表单%4$s的实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(this.getVoMetadataName(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getEntityCode(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getSourceFieldCode(parameter), true), + StringConcatUtility.concatWithNamePrefix(this.getFormMetadataName(parameter), true) + )); + } + if (!voElementIsMultiLanguage && fieldIsMultiLanguage) { + return ValidateResultUtility.failureWithError(String.format("视图对象%1$s中子表%2$s的字段%3$s关闭多语属性" + ValidateConstants.Comma + "而表单对应字段仍是多语。若要同步变更表单控件" + ValidateConstants.Comma + "请在表单%4$s实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(this.getVoMetadataName(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getEntityCode(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getSourceFieldCode(parameter), true), + StringConcatUtility.concatWithNamePrefix(this.getFormMetadataName(parameter), true) + )); + } + return warningValidateResult; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/PrecisionValidator.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/PrecisionValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..852460b77a3bc2275d92d3cf6025d8c7163e3e47 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/PrecisionValidator.java @@ -0,0 +1,43 @@ +package com.inspur.edp.web.relycheck.dependencyvalidator.element; + +import com.inspur.edp.lcm.metadata.spi.entity.ValidateResult; +import com.inspur.edp.web.relycheck.constant.NeedCheckPrecisionType; +import com.inspur.edp.web.relycheck.constant.ValidateConstants; +import com.inspur.edp.web.relycheck.utility.StringConcatUtility; +import com.inspur.edp.web.relycheck.utility.ValidateResultUtility; + +/** + * @author noah + * 2023/8/10 14:01 + */ +public class PrecisionValidator extends BaseElementValidator { + @Override + public ValidateResult validate(ElementValidateParameter parameter) { + ValidateResult warningValidateResult = ValidateResultUtility.success(); + if (NeedCheckPrecisionType.getInstance().contains(this.getSourceField(parameter).getType().get$type())) { + int voElementPrecision = parameter.getGspViewModelElement().getPrecision(); + int fieldPrecision = this.getSourceField(parameter).getType().getPrecision(); + if (voElementPrecision > fieldPrecision) { + warningValidateResult = ValidateResultUtility.failureWithWarning(String.format("视图对象%1$s中子表%2$s的字段%3$s精度增加为" + ValidateConstants.Colon + "%4$s" + ValidateConstants.Comma + "而表单对应字段精度为" + ValidateConstants.Colon + "%5$s。为同步表单控件精度属性" + ValidateConstants.Comma + "请在表单%6$s的实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(this.getVoMetadataName(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getEntityCode(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getSourceFieldCode(parameter), true), + StringConcatUtility.concat("", String.valueOf(voElementPrecision), true), + StringConcatUtility.concat("", String.valueOf(fieldPrecision), true), + StringConcatUtility.concatWithNamePrefix(this.getFormMetadataName(parameter), true) + )); + } + if (voElementPrecision < fieldPrecision) { + return ValidateResultUtility.failureWithError(String.format("视图对象%1$s中子表%2$s的字段%3$s精度减小为" + ValidateConstants.Colon + "%4$s" + ValidateConstants.Comma + "而表单对应字段精度为" + ValidateConstants.Colon + "%5$s。为同步表单控件精度属性" + ValidateConstants.Comma + "请在表单%6$s的实体树种执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(this.getVoMetadataName(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getEntityCode(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getSourceFieldCode(parameter), true), + StringConcatUtility.concat("", String.valueOf(voElementPrecision), true), + StringConcatUtility.concat("", String.valueOf(fieldPrecision), true), + StringConcatUtility.concatWithNamePrefix(this.getFormMetadataName(parameter), true) + )); + } + } + return warningValidateResult; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/RequireValidator.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/RequireValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..a8ebcccc8741a0b12a92b2ca6a0813af14d8c857 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/dependencyvalidator/element/RequireValidator.java @@ -0,0 +1,38 @@ +package com.inspur.edp.web.relycheck.dependencyvalidator.element; + +import com.inspur.edp.lcm.metadata.spi.entity.ValidateResult; +import com.inspur.edp.web.relycheck.constant.ValidateConstants; +import com.inspur.edp.web.relycheck.utility.StringConcatUtility; +import com.inspur.edp.web.relycheck.utility.ValidateResultUtility; + +/** + * 必填校验 + * + * @author noah + * 2023/8/10 14:00 + */ +public class RequireValidator extends BaseElementValidator { + @Override + public ValidateResult validate(ElementValidateParameter parameter) { + ValidateResult warningValidateResult = this.success(); + boolean voElementRequire = parameter.getGspViewModelElement().getIsRequire(); + boolean fieldRequire = this.getSourceField(parameter).getRequire(); + if (!voElementRequire && fieldRequire) { + warningValidateResult = ValidateResultUtility.failureWithWarning(String.format("视图对象%1$s中子表%2$s的字段%3$s由必填调整为非必填" + ValidateConstants.Comma + "而表单对应字段为必填。若要使表单生效" + ValidateConstants.Comma + "请在表单%4$s的实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(this.getVoMetadataName(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getEntityCode(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getSourceFieldCode(parameter), true), + StringConcatUtility.concatWithNamePrefix(this.getFormMetadataName(parameter), true) + )); + } + if (voElementRequire && !fieldRequire) { + return ValidateResultUtility.failureWithError(String.format("视图对象%1$s中子表%2$s的字段%3$s启用必填属性" + ValidateConstants.Comma + "而表单对应字段为非必填。若要使表单控件生效" + ValidateConstants.Comma + "请在表单%4$s的实体树中执行更新schema操作", + StringConcatUtility.concatWithNamePrefix(this.getVoMetadataName(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getEntityCode(parameter), true), + StringConcatUtility.concatWithCodePrefix(this.getSourceFieldCode(parameter), true), + StringConcatUtility.concatWithNamePrefix(this.getFormMetadataName(parameter), true) + )); + } + return warningValidateResult; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/BaseField.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/BaseField.java new file mode 100644 index 0000000000000000000000000000000000000000..6f4f0282ad8f9dca2f1629ada8e5bc9cea6f9357 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/BaseField.java @@ -0,0 +1,142 @@ +/* + * 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.web.relycheck.elements; + +import com.inspur.edp.web.relycheck.elements.type.CustomBaseFieldType; + +/** + * 字段元素 + * + * @author noah + */ +public class BaseField { + + public BaseField() { + } + + public BaseField(String _$type) { + this.$type = _$type; + } + + private String Id; + + public final String getId() { + return Id; + } + + public final void setId(String value) { + Id = value; + } + + + private String OriginalId; + + public final String getOriginalId() { + return OriginalId; + } + + public final void setOriginalId(String value) { + OriginalId = value; + } + + + private String Code; + + public final String getCode() { + return Code; + } + + public final void setCode(String value) { + Code = value; + } + + + private String Name; + + public final String getName() { + return Name; + } + + public final void setName(String value) { + Name = value; + } + + + private String Label; + + public final String getLabel() { + return Label; + } + + public final void setLabel(String value) { + Label = value; + } + + + private String BindingField; + + public final String getBindingField() { + return BindingField; + } + + public final void setBindingField(String value) { + BindingField = value; + } + + + private CustomBaseFieldType Type; + + public final CustomBaseFieldType getType() { + return Type; + } + + public final void setType(CustomBaseFieldType value) { + Type = value; + } + + + private String Path; + + public final String getPath() { + return Path; + } + + public final void setPath(String value) { + Path = value; + } + + private String BindingPath; + + public final String getBindingPath() { + return BindingPath; + } + + public final void setBindingPath(String value) { + BindingPath = value; + } + + private String $type; + + public String get$type() { + return $type; + } + + public void set$type(String $type) { + this.$type = $type; + } + +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomEntity.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomEntity.java new file mode 100644 index 0000000000000000000000000000000000000000..4248105f691e93d4e957eb13ba6b0f72e175d12b --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomEntity.java @@ -0,0 +1,90 @@ +/* + * 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.web.relycheck.elements; + +import com.inspur.edp.web.relycheck.elements.type.CustomEntityTypeBase; + +/** + * 实体元素 + * @author noah + */ +public class CustomEntity { + /** + * 实体标识 + */ + private String Id; + + public final String getId() { + return Id; + } + + public final void setId(String value) { + Id = value; + } + + /** + * 实体编号 + */ + private String Code; + + public final String getCode() { + return Code; + } + + public final void setCode(String value) { + Code = value; + } + + /** + * 实体名称 + */ + private String Name; + + public final String getName() { + return Name; + } + + public final void setName(String value) { + Name = value; + } + + /** + * 实体标签,即别名 + */ + private String Label; + + public final String getLabel() { + return Label; + } + + public final void setLabel(String value) { + Label = value; + } + + /** + * 实体类型描述 + */ + private CustomEntityTypeBase Type; + + public final CustomEntityTypeBase getType() { + return Type; + } + + public final void setType(CustomEntityTypeBase value) { + Type = value; + } +} \ No newline at end of file diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomField.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomField.java new file mode 100644 index 0000000000000000000000000000000000000000..e9b1db4ee89fd818e9a4e5916739afcb6185032a --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomField.java @@ -0,0 +1,66 @@ +package com.inspur.edp.web.relycheck.elements; + + + +/** + * 增加此属性的目的 是因为反序列化需要到具体的子类,但鉴于反序列化到子类需要调整较多源代码 + * 因此将子类的属性复制到该类中,用于进行反序列化 + * @author noah + * 2023/8/3 14:35 + */ +public class CustomField extends BaseField { + + private String defaultValue; + + public final String getDefaultValue() { + return defaultValue; + } + + public final void setDefaultValue(String value) { + defaultValue = value; + } + + + private boolean require; + + public final boolean getRequire() { + return require; + } + + public final void setRequire(boolean value) { + require = value; + } + + + private boolean readonly; + + public final boolean getReadonly() { + return readonly; + } + + public final void setReadonly(boolean value) { + readonly = value; + } + + + private CustomFieldEditor editor ; + + public final CustomFieldEditor getEditor() { + return editor; + } + + public final void setEditor(CustomFieldEditor value) { + editor = value; + } + + + private boolean multiLanguage = false; + + public final boolean getMultiLanguage() { + return multiLanguage; + } + + public final void setMultiLanguage(boolean value) { + multiLanguage = value; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomFieldEditor.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomFieldEditor.java new file mode 100644 index 0000000000000000000000000000000000000000..6cf7afb1eb8af13b99af8e4d62cca390c3246da4 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomFieldEditor.java @@ -0,0 +1,124 @@ +package com.inspur.edp.web.relycheck.elements; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.inspur.edp.cdp.common.utils.json.JsonUtil; +import com.inspur.edp.web.relycheck.elements.editor.DataSource; +import com.inspur.edp.web.relycheck.elements.editor.FieldEditor; + +import java.io.IOException; +import java.util.HashMap; + +/** + * @author noah + * 2023/8/3 14:37 + */ +public class CustomFieldEditor extends FieldEditor { + protected CustomFieldEditor(String _$type) { + super(_$type); + } + + public CustomFieldEditor() { + super(""); + } + + private String format; + + public final String getFormat() { + return format; + } + + public final void setFormat(String value) { + format = value; + } + + private String helpId; + + public final String getHelpId() { + return helpId; + } + + public final void setHelpId(String value) { + helpId = value; + } + + private String uri; + + public final String getUri() { + return uri; + } + + public final void setUri(String value) { + uri = value; + } + + private String textField; + + public final String getTextField() { + return textField; + } + + public final void setTextField(String value) { + textField = value; + } + + private String valueField; + + public final String getValueField() { + return valueField; + } + + public final void setValueField(String value) { + valueField = value; + } + + private String displayType; + + public final String getDisplayType() { + return displayType; + } + + public final void setDisplayType(String value) { + displayType = value; + } + + private com.inspur.edp.web.relycheck.elements.editor.DataSource DataSource; + + public final DataSource getDataSource() { + return DataSource; + } + + public final void setDataSource(DataSource value) { + DataSource = value; + } + + private HashMap map; + + + @JsonProperty(value = "mapFields") + public final HashMap getMap() { + return map; + } + + public final void setMap(HashMap value) { + map = value; + } + + @JsonInclude(JsonInclude.Include.NON_NULL) + private JsonNode options; + + public final JsonNode getOptions() { + return options; + } + + public final void setOptions(JsonNode options) { + this.options = options; + } +} + + diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomSchema.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomSchema.java new file mode 100644 index 0000000000000000000000000000000000000000..bbf5c9cf1aaa16f1a19abcf39341e1625c1b14ae --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomSchema.java @@ -0,0 +1,178 @@ +/* + * 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.web.relycheck.elements; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 表单Schema元素 + * + * @author guozhiqi + */ +@Data +public class CustomSchema { + private String Id; + + public final String getId() { + return Id; + } + + public final void setId(String value) { + Id = value; + } + + private String Code; + + public final String getCode() { + return Code; + } + + public final void setCode(String value) { + Code = value; + } + + private String Name; + + public final String getName() { + return Name; + } + + public final void setName(String value) { + Name = value; + } + + private String SourceUri; + + public final String getSourceUri() { + return SourceUri; + } + + public final void setSourceUri(String value) { + SourceUri = value; + } + + private String SourceType; + + public final String getSourceType() { + return SourceType; + } + + public final void setSourceType(String value) { + SourceType = value; + } + + private String eapiId; + private String eapiCode; + private String eapiName; + private String eapiNameSpace; + private String voPath; + private String voNameSpace; + + public String getEapiId() { + return eapiId; + } + + public void setEapiId(String eapiId) { + this.eapiId = eapiId; + } + + public String getEapiCode() { + return eapiCode; + } + + public void setEapiCode(String eapiCode) { + this.eapiCode = eapiCode; + } + + public String getEapiName() { + return eapiName; + } + + public void setEapiName(String eapiName) { + this.eapiName = eapiName; + } + + public String getEapiNameSpace() { + return eapiNameSpace; + } + + public void setEapiNameSpace(String eapiNameSpace) { + this.eapiNameSpace = eapiNameSpace; + } + + public String getVoPath() { + return voPath; + } + + public void setVoPath(String voPath) { + this.voPath = voPath; + } + + public String getVoNameSpace() { + return voNameSpace; + } + + public void setVoNameSpace(String voNameSpace) { + this.voNameSpace = voNameSpace; + } + + private List Entities; + + public final List getEntities() { + if (this.Entities == null) { + this.Entities = new ArrayList<>(); + } + return Entities; + } + + public final void setEntities(List value) { + Entities = value; + } + + private List Variables; + + public final List getVariables() { + if (this.Variables == null) { + this.Variables = new ArrayList<>(); + } + return Variables; + } + + public final void setVariables(List value) { + Variables = value; + } + + @JsonProperty("extendProperties") + private Map ExtendProperties; + + public Map getExtendProperties() { + if (this.ExtendProperties == null) { + this.ExtendProperties = new HashMap<>(); + } + return ExtendProperties; + } + + public void setExtendProperties(Map extendProperties) { + ExtendProperties = extendProperties; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomVariable.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomVariable.java new file mode 100644 index 0000000000000000000000000000000000000000..b3d6b8e449557aef012a10ab0ba8d017d012bd48 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/CustomVariable.java @@ -0,0 +1,63 @@ +/* + * 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.web.relycheck.elements; + +/** + * 变量定义 + * @author noah + */ +public class CustomVariable { + private String Id; + + public final String getId() { + return Id; + } + + public final void setId(String value) { + Id = value; + } + + private String Code; + + public final String getCode() { + return Code; + } + + public final void setCode(String value) { + Code = value; + } + + private String Name; + + public final String getName() { + return Name; + } + + public final void setName(String value) { + Name = value; + } + + private String Type; + + public final String getType() { + return Type; + } + + public final void setType(String value) { + Type = value; + } +} \ No newline at end of file diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/CheckBox.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/CheckBox.java new file mode 100644 index 0000000000000000000000000000000000000000..6c478c74171474c8bf77e2bdf5c916e87241bd70 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/CheckBox.java @@ -0,0 +1,27 @@ +/* + * 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.web.relycheck.elements.editor; + +/** + * checkbox 编辑器 + * @author noah + */ +public class CheckBox extends FieldEditor { + public CheckBox() { + super("CheckBox"); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/DataSource.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/DataSource.java new file mode 100644 index 0000000000000000000000000000000000000000..be852923328cc3a6deff70d3803eabfda7dc322c --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/DataSource.java @@ -0,0 +1,63 @@ +/* + * 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.web.relycheck.elements.editor; + +/** + * datasource 数据源实体配置 + * @author noah + */ +public class DataSource { + private String Uri; + + public final String getUri() { + return Uri; + } + + public final void setUri(String value) { + Uri = value; + } + + private String DisplayName; + + public final String getDisplayName() { + return DisplayName; + } + + public final void setDisplayName(String value) { + DisplayName = value; + } + + private String IdField; + + public final String getIdField() { + return IdField; + } + + public final void setIdField(String value) { + IdField = value; + } + + private String Type; + + public final String getType() { + return Type; + } + + public final void setType(String value) { + Type = value; + } +} \ No newline at end of file diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/DateBox.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/DateBox.java new file mode 100644 index 0000000000000000000000000000000000000000..e214f90a9cd4959805ec3895d76b42a2b7cc08ba --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/DateBox.java @@ -0,0 +1,37 @@ +/* + * 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.web.relycheck.elements.editor; + +/** + * datebox 实体 + * @author noah + */ +public class DateBox extends FieldEditor { + private String Format; + + public final String getFormat() { + return Format; + } + + public final void setFormat(String value) { + Format = value; + } + + public DateBox() { + super("DateBox"); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/DefaultEditor.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/DefaultEditor.java new file mode 100644 index 0000000000000000000000000000000000000000..ca9a41c1822fd2509c8b3dd7349fca1f4d2b6780 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/DefaultEditor.java @@ -0,0 +1,27 @@ +/* + * 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.web.relycheck.elements.editor; + +/** + * 同步schema 默认editor + * @author noah + */ +public class DefaultEditor extends FieldEditor { + public DefaultEditor() { + super("DefaultEditor"); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/EnumField.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/EnumField.java new file mode 100644 index 0000000000000000000000000000000000000000..2906976a0bc4cb2df76f64356b458be42d7a7df7 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/EnumField.java @@ -0,0 +1,28 @@ +/* + * 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.web.relycheck.elements.editor; + +/** + * 枚举字段 + * @author noah + */ +public class EnumField extends FieldEditor { + + public EnumField() { + super("EnumField"); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/FieldEditor.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/FieldEditor.java new file mode 100644 index 0000000000000000000000000000000000000000..df5c2159194b0936be07f2da73a0a490498c2eeb --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/FieldEditor.java @@ -0,0 +1,37 @@ +/* + * 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.web.relycheck.elements.editor; + +/** + * 字段编辑器类型 + * @author noah + */ +public class FieldEditor { + private String $type; + + public String get$type() { + return $type; + } + + public void set$type(String $type) { + this.$type = $type; + } + + protected FieldEditor(String _$type) { + this.$type = _$type; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/LanguageTextBox.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/LanguageTextBox.java new file mode 100644 index 0000000000000000000000000000000000000000..d4bac05be1f304621b11c7216ca4a70a549ef814 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/LanguageTextBox.java @@ -0,0 +1,23 @@ +/* + * 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.web.relycheck.elements.editor; + +public class LanguageTextBox extends FieldEditor { + public LanguageTextBox() { + super("LanguageTextBox"); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/LookupEdit.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/LookupEdit.java new file mode 100644 index 0000000000000000000000000000000000000000..c9dfdb1a7eec60ba35b9f1c5671f298347a27c92 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/LookupEdit.java @@ -0,0 +1,128 @@ +/* + * 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.web.relycheck.elements.editor; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.inspur.edp.cdp.common.utils.json.JsonUtil; + +import java.io.IOException; +import java.util.HashMap; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class LookupEdit extends FieldEditor { + private String HelpId; + + public final String getHelpId() { + return HelpId; + } + + public final void setHelpId(String value) { + HelpId = value; + } + + private String Uri; + + public final String getUri() { + return Uri; + } + + public final void setUri(String value) { + Uri = value; + } + + private String TextField; + + public final String getTextField() { + return TextField; + } + + public final void setTextField(String value) { + TextField = value; + } + + private String ValueField; + + public final String getValueField() { + return ValueField; + } + + public final void setValueField(String value) { + ValueField = value; + } + + private String DisplayType; + + public final String getDisplayType() { + return DisplayType; + } + + public final void setDisplayType(String value) { + DisplayType = value; + } + + private com.inspur.edp.web.relycheck.elements.editor.DataSource DataSource; + + public final com.inspur.edp.web.relycheck.elements.editor.DataSource getDataSource() { + return DataSource; + } + + public final void setDataSource(com.inspur.edp.web.relycheck.elements.editor.DataSource value) { + DataSource = value; + } + + private HashMap Map; + + @JsonSerialize(using = MapFieldsSerializer.class) + @JsonProperty(value = "mapFields") + public final HashMap getMap() { + return Map; + } + + public final void setMap(HashMap value) { + Map = value; + } + + @JsonInclude(JsonInclude.Include.NON_NULL) + private JsonNode options; + + public final JsonNode getOptions() { + return options; + } + + public final void setOptions(JsonNode options) { + this.options = options; + } + + public LookupEdit() { + super("LookupEdit"); + } +} + +class MapFieldsSerializer extends JsonSerializer> { + + @Override + public void serialize(HashMap map, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { + String mapString = JsonUtil.toJson(map); + jsonGenerator.writeString(mapString); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/MultiTextBox.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/MultiTextBox.java new file mode 100644 index 0000000000000000000000000000000000000000..ddb09815572cf6460ed5f71a62a03d1b6c5e8ad9 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/MultiTextBox.java @@ -0,0 +1,23 @@ +/* + * 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.web.relycheck.elements.editor; + +public class MultiTextBox extends FieldEditor { + public MultiTextBox() { + super("MultiTextBox"); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/NumericBox.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/NumericBox.java new file mode 100644 index 0000000000000000000000000000000000000000..14c3d06a367cca46cea0a753c4dbfe36ecf725a9 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/NumericBox.java @@ -0,0 +1,23 @@ +/* + * 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.web.relycheck.elements.editor; + +public class NumericBox extends FieldEditor { + public NumericBox() { + super("NumericBox"); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/RadioGroup.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/RadioGroup.java new file mode 100644 index 0000000000000000000000000000000000000000..4fdfb509fb2e8dbe7b44a9d2f4ef01e6761d32e1 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/RadioGroup.java @@ -0,0 +1,23 @@ +/* + * 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.web.relycheck.elements.editor; + +public class RadioGroup extends FieldEditor { + public RadioGroup() { + super("RadioGroup"); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/SwitchField.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/SwitchField.java new file mode 100644 index 0000000000000000000000000000000000000000..0a64b85c7315fd242fa322f87c3cf5147fa042e3 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/SwitchField.java @@ -0,0 +1,23 @@ +/* + * 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.web.relycheck.elements.editor; + +public class SwitchField extends FieldEditor { + public SwitchField() { + super("SwitchField"); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/TextBox.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/TextBox.java new file mode 100644 index 0000000000000000000000000000000000000000..ce696b9e0b2b1804002a3ba9d48f8a2147a14d20 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/editor/TextBox.java @@ -0,0 +1,24 @@ +/* + * 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.web.relycheck.elements.editor; + +public class TextBox extends FieldEditor { + + public TextBox() { + super("TextBox"); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/type/BaseFieldType.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/type/BaseFieldType.java new file mode 100644 index 0000000000000000000000000000000000000000..1aac0ab251cf8432528b914e6ce3a8bef484bc33 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/type/BaseFieldType.java @@ -0,0 +1,61 @@ +/* + * 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.web.relycheck.elements.type; + +/** + * 字段类型 + * @author noah + */ +public class BaseFieldType { + private String $type; + + public String get$type() { + return $type; + } + + public void set$type(String $type) { + this.$type = $type; + } + + + public BaseFieldType() { + + } + public BaseFieldType(String _$type) { + this.$type = _$type; + } + + private String Name; + + public String getName() { + return Name; + } + + public void setName(String value) { + Name = value; + } + + private String DisplayName; + + public String getDisplayName() { + return DisplayName; + } + + public void setDisplayName(String value) { + DisplayName = value; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/type/CustomBaseFieldType.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/type/CustomBaseFieldType.java new file mode 100644 index 0000000000000000000000000000000000000000..eb77d847faf80e165f42fa54fb1d44beda5cb7c7 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/type/CustomBaseFieldType.java @@ -0,0 +1,77 @@ +package com.inspur.edp.web.relycheck.elements.type; + +import com.inspur.edp.web.relycheck.elements.CustomField; +import com.inspur.edp.web.relycheck.elements.CustomEntity; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author noah + * 2023/8/4 16:56 + */ +public class CustomBaseFieldType extends BaseFieldType { + + + private int Length; + + public final int getLength() { + return Length; + } + + public final void setLength(int value) { + Length = value; + } + + private int Precision; + + public final int getPrecision() { + return Precision; + } + + public final void setPrecision(int value) { + Precision = value; + } + + private String Primary; + + public final String getPrimary() { + return Primary; + } + + public final void setPrimary(String value) { + Primary = value; + } + + private List Fields = new ArrayList<>(); + + public final List getFields() { + return Fields; + } + + public final void setFields(List value) { + Fields = value; + } + + private List Entities = new ArrayList<>(); + + public final List getEntities() { + return Entities; + } + + public final void setEntities(List value) { + Entities = value; + } + + private ArrayList EnumValues = new ArrayList<>(); + + public final ArrayList getEnumValues() { + return EnumValues; + } + + public final void setEnumValues(ArrayList value) { + EnumValues = value; + } + + +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/type/CustomEntityTypeBase.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/type/CustomEntityTypeBase.java new file mode 100644 index 0000000000000000000000000000000000000000..b0d787e5a633afe426a4c86992a40bd95a812d91 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/type/CustomEntityTypeBase.java @@ -0,0 +1,64 @@ +/* + * 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.web.relycheck.elements.type; + +import com.inspur.edp.web.relycheck.elements.CustomField; +import com.inspur.edp.web.relycheck.elements.CustomEntity; + +import java.util.ArrayList; +import java.util.List; + +/** + * 实体类型 + * @author noah + */ +public class CustomEntityTypeBase extends BaseFieldType { + + public CustomEntityTypeBase() { + super("EntityType"); + } + + private String Primary; + + public final String getPrimary() { + return Primary; + } + + public final void setPrimary(String value) { + Primary = value; + } + + private List Fields = new ArrayList<>(); + + public final List getFields() { + return Fields; + } + + public final void setFields(List value) { + Fields = value; + } + + private List Entities = new ArrayList<>(); + + public final List getEntities() { + return Entities; + } + + public final void setEntities(List value) { + Entities = value; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/type/CustomEnumItem.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/type/CustomEnumItem.java new file mode 100644 index 0000000000000000000000000000000000000000..30ad3ff733c0adfab8652b7479e2780044ab9b6f --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/elements/type/CustomEnumItem.java @@ -0,0 +1,44 @@ +/* + * 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.web.relycheck.elements.type; + +/** + * 枚举项定义 + * @author noah + */ +public class CustomEnumItem { + + private String Value; + + public final String getValue() { + return Value; + } + + public final void setValue(String value) { + Value = value; + } + + private String Name; + + public final String getName() { + return Name; + } + + public final void setName(String value) { + Name = value; + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/service/BaseMetadataElementService.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/service/BaseMetadataElementService.java new file mode 100644 index 0000000000000000000000000000000000000000..ad6dcd81834b1d67d55d8d94f57e208c650c1354 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/service/BaseMetadataElementService.java @@ -0,0 +1,74 @@ +package com.inspur.edp.web.relycheck.service; + +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.lcm.metadata.spi.entity.MetadataDependencyDetail; +import com.inspur.edp.lcm.metadata.spi.entity.MetadataElementDependencyDetail; +import com.inspur.edp.web.common.customexception.WebCustomException; +import com.inspur.edp.web.common.logger.WebLogger; +import com.inspur.edp.web.common.serialize.SerializeUtility; +import com.inspur.edp.web.common.utility.StringUtility; +import com.inspur.edp.web.formmetadata.metadata.FormMetadataContent; +import com.inspur.edp.web.formmetadata.metadata.FormMetadataContentService; +import com.inspur.edp.web.formmetadata.metadata.formdom.FormDOM; +import com.inspur.edp.web.relycheck.dependencygenerator.SchemaEntityDependencyGenerator; +import com.inspur.edp.web.relycheck.elements.CustomSchema; +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * 元数据检测 service base + */ +public abstract class BaseMetadataElementService implements ApplicationContextAware { + protected ApplicationContext applicationContext; + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + this.applicationContext = applicationContext; + } + + /** + * 获取表单元数据对应的依赖项 + * + * @param gspMetadata + * @return + */ + protected List getMetadataDependencyDetails(GspMetadata gspMetadata) { + if (gspMetadata == null) { + throw new WebCustomException("元数据一致性检查,getMetadataDependencyDetails 传递的gspMetadata参数为空"); + } + if (gspMetadata.getContent() instanceof FormMetadataContent) { + List dependencyDetailList = new ArrayList<>(); + + // 如果是表单元数据 那么提取其中的schema节点 + FormMetadataContent formMetadataContent = (FormMetadataContent) gspMetadata.getContent(); + FormDOM formDOM = FormMetadataContentService.getInstance().getFormContent(formMetadataContent); + List> schemsList = formDOM.getModule().getSchemas(); + schemsList.forEach(schemaItem -> { + String voMetadataId = (String) schemaItem.get("id"); + if (StringUtility.isNotNullOrEmpty(voMetadataId)) { + SchemaEntityDependencyGenerator schemaEntityDependencyGenerator = this.applicationContext.getBean(SchemaEntityDependencyGenerator.class); + + MetadataDependencyDetail schemaDependencyDetail = new MetadataDependencyDetail(); + schemaDependencyDetail.setMetadataId(voMetadataId); + + String serializedSchema = SerializeUtility.getInstance().serialize(schemaItem); + CustomSchema deserializedCustomSchema = SerializeUtility.getInstance().deserialize(serializedSchema, CustomSchema.class); + // 当前共检查两类 + List schemaEntityDependencyDetailList = schemaEntityDependencyGenerator.generateDependencyDetailWithSchemaEntityList(deserializedCustomSchema.getEntities(), formDOM, gspMetadata); + schemaDependencyDetail.setElementReferences(schemaEntityDependencyDetailList); + + dependencyDetailList.add(schemaDependencyDetail); + } else { + WebLogger.Instance.info(String.format("表单元数据依赖 VO metadataId 为空,对应表单元数据 id:%s,对应 namespace:%s", gspMetadata.getHeader().getId(), gspMetadata.getHeader().getNameSpace())); + } + }); + return dependencyDetailList; + } + return new ArrayList<>(0); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/service/FormMetadataElementService.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/service/FormMetadataElementService.java new file mode 100644 index 0000000000000000000000000000000000000000..d57b54df1cad1c7191f8f8a221146b91f283fd86 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/service/FormMetadataElementService.java @@ -0,0 +1,38 @@ +package com.inspur.edp.web.relycheck.service; + +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.lcm.metadata.spi.MetadataElementService; +import com.inspur.edp.lcm.metadata.spi.entity.MetadataDependencyDetail; +import com.inspur.edp.lcm.metadata.spi.entity.MetadataElement; +import com.inspur.edp.lcm.metadata.spi.entity.MetadataElementLocator; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 表单元数据依赖检查 + * 注册为bean,通过外部统一调用 + * + * @author noah + */ +public class FormMetadataElementService extends BaseMetadataElementService implements MetadataElementService { + + + @Override + public String getMetadataType() { + return "Form"; + } + + + @Override + public Map getMetadataElement(GspMetadata gspMetadata, Set set) { + return null; + } + + @Override + public List getMetadataDependencyDetails(GspMetadata gspMetadata) { + return super.getMetadataDependencyDetails(gspMetadata); + } + +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/service/MobileFormMetadataElementService.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/service/MobileFormMetadataElementService.java new file mode 100644 index 0000000000000000000000000000000000000000..882f8cc1c7aa92acf07a417c9a0aaf7a1962027e --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/service/MobileFormMetadataElementService.java @@ -0,0 +1,35 @@ +package com.inspur.edp.web.relycheck.service; + +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.lcm.metadata.spi.MetadataElementService; +import com.inspur.edp.lcm.metadata.spi.entity.MetadataDependencyDetail; +import com.inspur.edp.lcm.metadata.spi.entity.MetadataElement; +import com.inspur.edp.lcm.metadata.spi.entity.MetadataElementLocator; + +import java.util.*; + +/** + * 移动表单元数据依赖检查 + * 注册为bean 统一外部统一进行调用 + * + * @author noah + */ +public class MobileFormMetadataElementService extends BaseMetadataElementService implements MetadataElementService { + + @Override + public String getMetadataType() { + return "MobileForm"; + } + + + @Override + public Map getMetadataElement(GspMetadata gspMetadata, Set set) { + return null; + } + + @Override + public List getMetadataDependencyDetails(GspMetadata gspMetadata) { + return super.getMetadataDependencyDetails(gspMetadata); + } + +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/utility/StringConcatUtility.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/utility/StringConcatUtility.java new file mode 100644 index 0000000000000000000000000000000000000000..3a6296cb887f3e81f7ccb6eefa99aae46fb3ccf6 --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/utility/StringConcatUtility.java @@ -0,0 +1,46 @@ +package com.inspur.edp.web.relycheck.utility; + +import com.inspur.edp.web.common.utility.StringUtility; +import com.inspur.edp.web.relycheck.constant.ValidateConstants; + +/** + * @author noah + * 2023/8/7 17:30 + */ +public class StringConcatUtility { + + /** + * 合并前缀 后缀及其对应的是否包含边界 + * @param prefix + * @param suffix + * @param includeBorder + * @return + */ + public static String concat(String prefix, String suffix, boolean includeBorder) { + String result = !StringUtility.isNullOrEmpty(prefix) ? (prefix + ":" + suffix) : suffix; + if (includeBorder) { + return "【" + result + "】"; + } + return result; + } + + /** + * 快捷方式 合并 名称前缀 + * @param suffix + * @param includeBorder + * @return + */ + public static String concatWithNamePrefix(String suffix, boolean includeBorder) { + return concat(ValidateConstants.Name, suffix, includeBorder); + } + + /** + * 快捷方式 合并编号前缀 + * @param suffix + * @param includeBorder + * @return + */ + public static String concatWithCodePrefix(String suffix, boolean includeBorder) { + return concat(ValidateConstants.Code, suffix, includeBorder); + } +} diff --git a/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/utility/ValidateResultUtility.java b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/utility/ValidateResultUtility.java new file mode 100644 index 0000000000000000000000000000000000000000..4b254a803e9bc6b1192162cc072231d89ba6dbcd --- /dev/null +++ b/web-formmetadata-relycheck/src/main/java/com/inspur/edp/web/relycheck/utility/ValidateResultUtility.java @@ -0,0 +1,76 @@ +package com.inspur.edp.web.relycheck.utility; + +import com.inspur.edp.lcm.metadata.spi.entity.ValidateResult; +import com.inspur.edp.lcm.metadata.spi.entity.ValidationLevelEnum; + +/** + * 校验返回值信息构造 + * + * @author noah + * 2023/8/10 16:13 + */ +public class ValidateResultUtility { + /** + * 定义成功的返回结果 + * + * @return + */ + public static ValidateResult success() { + ValidateResult validateResult = new ValidateResult(); + validateResult.setValid(true); + return validateResult; + } + + /** + * 定义失败的返回结果 + * 默认级别为error + * + * @param message + * @return + */ + public static ValidateResult failureWithError(String message) { + return failure(message, ValidationLevelEnum.ERROR); + } + + /** + * 校验提示信息 + * 校验级别为warning + * + * @param message + * @return + */ + public static ValidateResult failureWithWarning(String message) { + return failure(message, ValidationLevelEnum.WARNING); + } + + + /** + * 传递校验级别 + * + * @param message + * @param validationLevel + * @return + */ + public static ValidateResult failure(String message, ValidationLevelEnum validationLevel) { + ValidateResult validateResult = new ValidateResult(); + validateResult.setValid(false); + validateResult.setMessage(message); + validateResult.setLevel(validationLevel); + return validateResult; + } + + /** + * 判断校验结果是否应该继续进行验证 + * @param validateResult + * @return + */ + public static boolean canContinute(ValidateResult validateResult) { + if (validateResult == null) { + return true; + } + if (!validateResult.isValid() && validateResult.getLevel() == ValidationLevelEnum.ERROR) { + return false; + } + return true; + } +} diff --git a/web-formmetadata-relycheck/src/main/resources/META-INF/spring.factories b/web-formmetadata-relycheck/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000000000000000000000000000000000000..258c71c74f6a75076247efec78657da9d113447d --- /dev/null +++ b/web-formmetadata-relycheck/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.inspur.edp.web.relycheck.config.RelyCheckConfig \ No newline at end of file diff --git a/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/custom/CustomApplication.java b/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/custom/CustomApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..d42235993f1b5c1b763f272434ae956544209e2b --- /dev/null +++ b/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/custom/CustomApplication.java @@ -0,0 +1,25 @@ +package com.inspur.edp.web.relycheck.custom; + +import org.junit.Test; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ConfigurableApplicationContext; + +/** + * @author noah + * 2023/8/7 09:04 + */ +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +public class CustomApplication { + @Test + public void test() { + ConfigurableApplicationContext context = SpringApplication.run(CustomApplication.class); + TestBean testBean = context.getBean(MyConfig.class).testBean(); + TestBean testBean1 = context.getBean(TestBean.class); + System.out.println(testBean); + System.out.println(testBean1); + + context.close(); + } +} diff --git a/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/custom/MyConfig.java b/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/custom/MyConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..a9e051b6af45cb14d1731e15c497ed062616cd24 --- /dev/null +++ b/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/custom/MyConfig.java @@ -0,0 +1,16 @@ +package com.inspur.edp.web.relycheck.custom; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author noah + * 2023/8/7 09:03 + */ +@Configuration +public class MyConfig { + @Bean + public TestBean testBean() { + return new TestBean(); + } +} diff --git a/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/custom/TestBean.java b/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/custom/TestBean.java new file mode 100644 index 0000000000000000000000000000000000000000..6dd371730fd9d02501821e3efce10c751e3c9d85 --- /dev/null +++ b/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/custom/TestBean.java @@ -0,0 +1,13 @@ +package com.inspur.edp.web.relycheck.custom; + +import lombok.Data; + +/** + * @author noah + * 2023/8/7 09:03 + */ +@Data +public class TestBean { + private String name; + +} diff --git a/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/dependencyvalidator/VoElementValidatorTest.java b/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/dependencyvalidator/VoElementValidatorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b9fae0733f54a069cd2129de5fa8a765fb83a225 --- /dev/null +++ b/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/dependencyvalidator/VoElementValidatorTest.java @@ -0,0 +1,40 @@ +package com.inspur.edp.web.relycheck.dependencyvalidator; + +import com.inspur.edp.web.relycheck.config.RelyCheckConfig; +import org.junit.Test; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.core.env.ConfigurableEnvironment; + +import javax.annotation.Resource; + +import static org.junit.Assert.*; + +/** + * @author noah + * 2023/7/31 16:50 + */ +@SpringBootTest +public class VoElementValidatorTest implements ApplicationContextAware { + + private ApplicationContext context; + + @Autowired + private VoElementValidator voElementValidator; + + @Test + public void test() { + System.out.println(this.voElementValidator); + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + this.context = applicationContext; + } +} \ No newline at end of file diff --git a/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/dependencyvalidator/VoEntityValidatorTest.java b/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/dependencyvalidator/VoEntityValidatorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0c5594abee9e35aa5e682d2e0a181533431ad3aa --- /dev/null +++ b/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/dependencyvalidator/VoEntityValidatorTest.java @@ -0,0 +1,18 @@ +package com.inspur.edp.web.relycheck.dependencyvalidator; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * @author noah + * 2023/8/8 10:57 + */ +public class VoEntityValidatorTest { + + @Test + public void testFormat(){ + String result=String.format("Noah name is %1$s %2$s",55,66); + System.out.println(result); + } +} \ No newline at end of file diff --git a/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/elements/SchemaTest.java b/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/elements/SchemaTest.java new file mode 100644 index 0000000000000000000000000000000000000000..97b193c3ee6f17c4b082cd83d32e7bb0cce8c304 --- /dev/null +++ b/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/elements/SchemaTest.java @@ -0,0 +1,21 @@ +package com.inspur.edp.web.relycheck.elements; + +import com.inspur.edp.web.common.serialize.SerializeUtility; +import org.junit.Test; + +/** + * @author noah + * 2023/8/4 16:23 + */ +public class SchemaTest { + @Test + public void test() { + CustomSchema customSchema = new CustomSchema(); + customSchema.setCode("fff"); + String jsonResult = SerializeUtility.getInstance().serialize(customSchema); + CustomSchema ss = SerializeUtility.getInstance().deserialize(jsonResult, CustomSchema.class); + + System.out.println(ss.getCode().equals("fff")); + } + +} \ No newline at end of file diff --git a/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/utility/StringConcatUtilityTest.java b/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/utility/StringConcatUtilityTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e515eab276798286b89b360c69f3148dbdae3422 --- /dev/null +++ b/web-formmetadata-relycheck/src/test/java/com/inspur/edp/web/relycheck/utility/StringConcatUtilityTest.java @@ -0,0 +1,43 @@ +package com.inspur.edp.web.relycheck.utility; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.Assert; +import org.junit.Test; + +public class StringConcatUtilityTest { + + @Test + public void testConcat() { + String prefix = "Hello"; + String suffix = "World"; + boolean includeBorder = true; + + String expected = "【Hello:World】"; + String actual = StringConcatUtility.concat(prefix, suffix, includeBorder); + + Assert.assertEquals(expected, actual); + } + + @Test + public void testConcatWithNamePrefix() { + String suffix = "John"; + boolean includeBorder = false; + + String expected = "名称:John"; + String actual = StringConcatUtility.concatWithNamePrefix(suffix, includeBorder); + + Assert.assertEquals(expected, actual); + } + + @Test + public void testConcatWithCodePrefix() { + String suffix = "123"; + boolean includeBorder = true; + + String expected = "【编号:123】"; + String actual = StringConcatUtility.concatWithCodePrefix(suffix, includeBorder); + + Assert.assertEquals(expected, actual); + } +} \ No newline at end of file diff --git a/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/debuguri/FormMetadataDebugUriWithMobile.java b/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/debuguri/FormMetadataDebugUriWithMobile.java index 89e7355c4181635fb7827c3513cb8a39add280b5..0dc882904a80c6019d885283175c581b20188ff4 100644 --- a/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/debuguri/FormMetadataDebugUriWithMobile.java +++ b/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/debuguri/FormMetadataDebugUriWithMobile.java @@ -29,6 +29,7 @@ import com.inspur.edp.web.formmetadata.metadata.formdom.FormDOM; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; /** * description:移动表单调试Url地址 diff --git a/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/metadata/FormMetadataManager.java b/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/metadata/FormMetadataManager.java index cce6f1f49b7ec0a034976e29c3d704bb02ca823f..bd30f80ab949bf3a29e1ccab8cfebf405d363274 100644 --- a/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/metadata/FormMetadataManager.java +++ b/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/metadata/FormMetadataManager.java @@ -20,6 +20,7 @@ import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; import com.inspur.edp.lcm.metadata.api.service.MetadataService; import com.inspur.edp.web.appconfig.api.entity.GspAppConfig; import com.inspur.edp.web.appconfig.core.service.GspAppConfigService; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.entity.TerminalType; import com.inspur.edp.web.common.io.FileUtility; import com.inspur.edp.web.common.utility.RandomUtility; @@ -117,11 +118,11 @@ public class FormMetadataManager { // 如果对应的表单元数据路径为绝对路径 那么需要进行调整 if (FileUtility.isAbsolute(pageRelativePath)) { - throw new RuntimeException("页面流文件(后缀为.pf)中包含绝对路径,依赖于单个环境路径配置,请调整为相对路径。具体操作:打开页面流文件,通过将表单从页面流中先移除再添加的方式,自动进行调整。 对应表单元数据为:" + page.getName() + ",当前绝对路径为:" + page.getRelativePath()); + throw new WebCustomException("页面流文件(后缀为.pf)中包含绝对路径,依赖于单个环境路径配置,请调整为相对路径。具体操作:打开页面流文件,通过将表单从页面流中先移除再添加的方式,自动进行调整。 对应表单元数据为:" + page.getName() + ",当前绝对路径为:" + page.getRelativePath()); } // 增加表单元数据的存在检测 if (!metadataService.isMetadataExist(pageRelativePath, page.getFileName())) { - throw new RuntimeException("页面流文件(后缀为.pf)中配置表单元数据路径不正确,请移除。对应表单元数据code:" + page.getCode() + ",name: " + page.getName()); + throw new WebCustomException("页面流文件(后缀为.pf)中配置表单元数据路径不正确,请移除。对应表单元数据code:" + page.getCode() + ",name: " + page.getName()); } GspMetadata currentRouteMetadata = metadataService.loadMetadata(page.getFileName(), pageRelativePath); diff --git a/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/zerocode/ZeroCodeConstants.java b/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/zerocode/ZeroCodeConstants.java index f64865daf299e63a496d81cdc0f1d4f2b6fa0a60..00f37752d80ced3d4ed9c4c47c7b999012152b6a 100644 --- a/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/zerocode/ZeroCodeConstants.java +++ b/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/zerocode/ZeroCodeConstants.java @@ -25,11 +25,11 @@ public class ZeroCodeConstants { /** * 零代码-代码部署路径--根路径 */ - public static String ZeroCodePath = "zerocode"; + public static final String ZeroCodePath = "zerocode"; /** * 零代码部署路径 相对于 server 的路径 */ - public static String ZeroCodeRelativePath="web/runtime/projects"; + public static final String ZeroCodeRelativePath="web/runtime/projects"; } diff --git a/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/zerocode/ZeroCodeParameterValidator.java b/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/zerocode/ZeroCodeParameterValidator.java index 54c4e188b4e8dc4663fa1fda25dc5a3b61037eea..0461cd50a89d44fb1f4d26775551978b7a2da326 100644 --- a/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/zerocode/ZeroCodeParameterValidator.java +++ b/web-frontendproject/src/main/java/com/inspur/edp/web/frontendproject/zerocode/ZeroCodeParameterValidator.java @@ -16,6 +16,7 @@ package com.inspur.edp.web.frontendproject.zerocode; +import com.inspur.edp.web.common.customexception.WebCustomException; import com.inspur.edp.web.common.utility.StringUtility; public class ZeroCodeParameterValidator { @@ -26,25 +27,25 @@ public class ZeroCodeParameterValidator { */ public static void validate(ZeroCodeParameter zeroCodeParameter) { if (zeroCodeParameter == null) { - throw new RuntimeException("零代码编译入参不能为null"); + throw new WebCustomException("零代码编译入参不能为null"); } if (StringUtility.isNullOrEmpty(zeroCodeParameter.getAbsoluteBasePath())) { - throw new RuntimeException("零代码编译入参路径参数absoluteBasePath不能为空"); + throw new WebCustomException("零代码编译入参路径参数absoluteBasePath不能为空"); } if (StringUtility.isNullOrEmpty(zeroCodeParameter.getProjectName())) { - throw new RuntimeException("零代码编译入参工程名称projectName不能为空"); + throw new WebCustomException("零代码编译入参工程名称projectName不能为空"); } if (StringUtility.isNullOrEmpty(zeroCodeParameter.getRelyNodeModulesPath())) { - throw new RuntimeException("零代码编译入参依赖node_modules 路径不能为空"); + throw new WebCustomException("零代码编译入参依赖node_modules 路径不能为空"); } if (zeroCodeParameter.getFormParameters() == null || zeroCodeParameter.getFormParameters().size() == 0) { - throw new RuntimeException("零代码编译入参,至少包含一个表单参数"); + throw new WebCustomException("零代码编译入参,至少包含一个表单参数"); } if(StringUtility.isNullOrEmpty(zeroCodeParameter.getServiceUnitPath())){ - throw new RuntimeException("服务单元serviceUnitPath参数未配置"); + throw new WebCustomException("服务单元serviceUnitPath参数未配置"); } }