diff --git a/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/entity/EApiSummaryInfo.java b/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/entity/EApiSummaryInfo.java index 53ccacec9273625b4f90646c38ce898851690c92..cc573a9b1feac3c8cdecc6818a13df5dedbb4674 100644 --- a/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/entity/EApiSummaryInfo.java +++ b/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/entity/EApiSummaryInfo.java @@ -24,14 +24,18 @@ public class EApiSummaryInfo { private String serviceUnitCode; private String serviceUnitName; private String bizObjectId; + private String bizObjectCode; + private String bizObjectName; private String serviceCode; private String serviceName; + private String billCategoryId; + private String billCategoryCode; + private String billCategoryName; private String basePath; private String version; - private String bizObjectCode; - private String bizObjectName; private String sourceType; private String sourceId; private String sourceVersion; private String serviceUsage; + private String accessScope; } diff --git a/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/entity/ServiceDefine.java b/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/entity/ServiceDefine.java index 6864cf77adc50beee81a4da268ce2d12f1f8f568..65f292aa58614a88dc9d4cf5596d3e7b76a6305c 100644 --- a/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/entity/ServiceDefine.java +++ b/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/entity/ServiceDefine.java @@ -24,8 +24,8 @@ import java.util.Map; @Data public class ServiceDefine { - public ServiceDefine(){ - this.operations=new ArrayList<>(); + public ServiceDefine() { + this.operations = new ArrayList<>(); } private String id; @@ -38,6 +38,8 @@ public class ServiceDefine { private String resourceName; + private String resourceNameSpace; + private String resourcePath; private String resourceFileName; diff --git a/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/entity/SgModelType.java b/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/entity/SgModelType.java index a744c3dad87e1dbd155eb4183e521afb49d3e876..97259e5dc18fa21b3569f6052a00730b5488f214 100644 --- a/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/entity/SgModelType.java +++ b/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/entity/SgModelType.java @@ -22,28 +22,28 @@ import com.inspur.edp.cdp.common.utils.enums.EnumValueParsable; public enum SgModelType implements EnumValueParsable { - VO(0), + VO(0), - DTO(1); + DTO(1); - private int value; + private int value; - SgModelType(int enumValue) { - this.value = enumValue; - } + @JsonValue + @Override + public Integer getValue() { + return value; + } - @JsonCreator - public static SgModelType of(Integer value) throws EnumValueParseException { - return EnumValueParsable.parse(value, SgModelType.class); - } + public void setValue(int value) { + this.value = value; + } - @JsonValue - @Override - public Integer getValue() { - return value; - } + SgModelType(int enumValue) { + this.value = enumValue; + } - public void setValue(int value) { - this.value = value; - } + @JsonCreator + public static SgModelType of(Integer value) throws EnumValueParseException { + return EnumValueParsable.parse(value, SgModelType.class); + } } diff --git a/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/utils/EApiSerializeException.java b/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/utils/EApiSerializeException.java new file mode 100644 index 0000000000000000000000000000000000000000..1411873232166373edaf79b5660a154e831bb4db --- /dev/null +++ b/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/utils/EApiSerializeException.java @@ -0,0 +1,34 @@ +/* + * 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.sgf.api.utils; + +import io.iec.edp.caf.commons.exception.CAFRuntimeException; +import io.iec.edp.caf.commons.exception.ExceptionLevel; + +/** + * @author Kaixuan Shi + * @since 2023/3/20 + */ +class EApiSerializeException extends CAFRuntimeException { + + private static final String GSP_EAPI_SERIALIZE_0001 = "GSP_EAPI_SERIALIZE_0001"; + private static final String SERVICE_UNIT_CODE = "pfcommon"; + + public EApiSerializeException(Exception innerException) { + super(SERVICE_UNIT_CODE, GSP_EAPI_SERIALIZE_0001, "", innerException, ExceptionLevel.Error); + } +} diff --git a/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/utils/ObjectMapperUtil.java b/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/utils/ObjectMapperUtil.java index 0efce365145316d4e4f39c8a79472db61ed7dc64..e7985629ccd48d20d8c91834ea3a846f75232838 100644 --- a/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/utils/ObjectMapperUtil.java +++ b/rest-api-metadata/src/main/java/com/inspur/edp/sgf/api/utils/ObjectMapperUtil.java @@ -67,7 +67,7 @@ public class ObjectMapperUtil { try { return factory.createParser(jsonStr); } catch (Exception e) { - throw new RuntimeException(e); + throw new EApiSerializeException(e); } } @@ -83,7 +83,7 @@ public class ObjectMapperUtil { try { return mapper.readTree(json); } catch (Exception e) { - throw new RuntimeException(e); + throw new EApiSerializeException(e); } } @@ -91,7 +91,7 @@ public class ObjectMapperUtil { try { return mapper.readValue(json, clazz); } catch (Exception e) { - throw new RuntimeException(e); + throw new EApiSerializeException(e); } } @@ -99,7 +99,7 @@ public class ObjectMapperUtil { try { return mapper.treeToValue(jsonNode, clazz); } catch (Exception e) { - throw new RuntimeException(e); + throw new EApiSerializeException(e); } } @@ -107,7 +107,7 @@ public class ObjectMapperUtil { try { return mapper.writeValueAsString(obj); } catch (Exception e) { - throw new RuntimeException(e); + throw new EApiSerializeException(e); } } @@ -115,7 +115,7 @@ public class ObjectMapperUtil { try { return mapper.readValue(json, clazz); } catch (Exception e) { - throw new RuntimeException(e); + throw new EApiSerializeException(e); } } @@ -124,7 +124,7 @@ public class ObjectMapperUtil { try { return mapper.readValue(content, javaType); } catch (Exception e) { - throw new RuntimeException(e); + throw new EApiSerializeException(e); } } @@ -132,7 +132,7 @@ public class ObjectMapperUtil { try { return mapper.readValue(content, javaType); } catch (Exception e) { - throw new RuntimeException(e); + throw new EApiSerializeException(e); } } @@ -140,7 +140,7 @@ public class ObjectMapperUtil { try { return mapper.readValue(content, valueTypeRef); } catch (Exception e) { - throw new RuntimeException(e); + throw new EApiSerializeException(e); } } @@ -148,7 +148,7 @@ public class ObjectMapperUtil { try { return mapper.readValue(p, valueType); } catch (Exception e) { - throw new RuntimeException(e); + throw new EApiSerializeException(e); } } @@ -159,7 +159,7 @@ public class ObjectMapperUtil { try { return (T) mapper.treeToValue(node, classz); } catch (Exception e) { - throw new RuntimeException(e); + throw new EApiSerializeException(e); } } @@ -173,7 +173,7 @@ public class ObjectMapperUtil { try { return mapper.readValue(str, javaType); } catch (Exception e) { - throw new RuntimeException(e); + throw new EApiSerializeException(e); } } diff --git a/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/BasicActionProvider.java b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/BasicActionProvider.java index 0e34f45732c70157c9bc11279d8ad5f18be253f6..d2fb90b9b5811aa74f261fc06a71fd21a42661a1 100644 --- a/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/BasicActionProvider.java +++ b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/BasicActionProvider.java @@ -30,7 +30,10 @@ import java.util.ArrayList; import java.util.List; /** - * 功能描述 : @ClassName: BasicActionProvider @Author: Fynn Qi @Date: 2020/2/3 10:43 @Version: V1.0 + * @author Fynn Qi + * @author Kaixuan Shi + * @version 1.1 + * @since 2020/2/3 10:43 */ public class BasicActionProvider { //更新API文档会使用 @@ -84,6 +87,8 @@ public class BasicActionProvider { operations.add(save(gspMetadata)); // 取消 operations.add(cancel(gspMetadata)); + //是否存在变更 + operations.add(hasChanges(gspMetadata)); // 获取字段帮助操作 operations.add(getElementHelp(gspMetadata)); // 新增子对象数据 @@ -155,7 +160,7 @@ public class BasicActionProvider { : nodesCodesStringBuidler + "#" + viewObject.getCode(); ServiceOperation operation = getExtendBatchDeleteChildOperation( - vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); + vmMetadata, viewObject.getName(), nodesCodesStringBuidler); if (operation != null) { operations.add(operation); } @@ -177,7 +182,7 @@ public class BasicActionProvider { ? viewObject.getCode() : nodesCodesStringBuidler + "#" + viewObject.getCode(); ServiceOperation operation = - getExtendDeleteChildOperation(vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); + getExtendDeleteChildOperation(vmMetadata, viewObject.getName(), nodesCodesStringBuidler); if (operation != null) { operations.add(operation); } @@ -231,8 +236,8 @@ public class BasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&{1}", voId, methodId)); operation.setCode(methodCode); - operation.setName(MessageFormat.format("扩展批量删除从表{0}数据", currentNodeCode)); - operation.setDescription(MessageFormat.format("扩展批量删除从表{0}数据", currentNodeCode)); + operation.setName(MessageFormat.format("批量删除{0}", currentNodeCode)); + operation.setDescription(MessageFormat.format("批量删除{0}。", currentNodeCode)); operation.setResourceOpId( MessageFormat.format("{0}&^^&{1}", voId, methodId)); operation.setHttpMethod("PUT"); @@ -301,8 +306,10 @@ public class BasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&{1}", voId, methodId)); operation.setCode(methodCode); - operation.setName(MessageFormat.format("扩展删除从表{0}数据", currentNodeCode)); - operation.setDescription(MessageFormat.format("扩展删除从表{0}数据", currentNodeCode)); + operation.setName(MessageFormat.format("删除{0}", currentNodeCode)); + operation.setDescription(MessageFormat.format("删除{0},该操作仅在当前业务上下文中删除,并不会持久化到" + + "数据库。后续需调用”保存“操作进行持久化。也可通过变更集,在删除过程中修改其他数据,并返回删除过程中产" + + "生的其他变更。", currentNodeCode)); operation.setResourceOpId( MessageFormat.format("{0}&^^&{1}", voId, methodId)); operation.setHttpMethod("PUT"); @@ -319,12 +326,14 @@ public class BasicActionProvider { private static ServiceOperation extendElementHelp(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId( MessageFormat.format("{0}&^^&Extend_ElementHelp", voId)); operation.setCode("Extend_GetElementHelp"); - operation.setName("扩展获取字段帮助"); - operation.setDescription("根据labelId获取字段帮助扩展方法"); + operation.setName("获取字段帮助数据"); + operation.setDescription(MessageFormat.format("获取指定帮助字段的帮助数据,支持{0}及其子表的所有帮助字段的" + + "帮助数据。也可通过变更集,在删除过程中修改其他数据,并返回删除过程中产生的其他变更。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Extend_ElementHelp", voId)); operation.setHttpMethod("PUT"); @@ -398,12 +407,14 @@ public class BasicActionProvider { private static ServiceOperation extensionFilter(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId( MessageFormat.format("{0}&^^&Extension_Filter", voId)); operation.setCode("Extension_Filter"); - operation.setName("查询数据"); - operation.setDescription("查询数据带过滤条件"); + operation.setName("查询" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("按照查询条件查询{0},可指定查询过滤条件、排序字段、设置分页。" + + "也可通过变更集,在删除过程中修改其他数据,并返回删除过程中产生的其他变更。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Extension_Filter", voId)); operation.setHttpMethod("POST"); @@ -447,16 +458,18 @@ public class BasicActionProvider { private static ServiceOperation extendQuery(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId(MessageFormat.format("{0}&^^&Extend_Query", voId)); operation.setCode("Extend_Query"); - operation.setName("扩展过滤查询"); - operation.setDescription("扩展过滤查询"); + operation.setName("查询" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("按照查询条件查询{0}。如果查询条件较长,建议使用”查询{0}" + + "“操作。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Extend_Query", voId)); operation.setHttpMethod("PUT"); operation.setTemplate("/extension/query"); - operation.setDeprecated(false); + operation.setDeprecated(true); operation.setExtend1("Basic"); operation.setParameters(new ArrayList<>()); @@ -489,11 +502,13 @@ public class BasicActionProvider { private static ServiceOperation extendRetrieve(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId(MessageFormat.format("{0}&^^&Extend_Retrieve", voId)); operation.setCode("Extend_Retrieve"); - operation.setName("扩展数据检索"); - operation.setDescription("扩展数据检索"); + operation.setName("检索" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("检索指定的{0},返回结果中包含{0}的所有子表数据。也可通过" + + "变更集,在删除过程中修改其他数据,并返回删除过程中产生的其他变更。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Extend_Retrieve", voId)); operation.setHttpMethod("PUT"); @@ -530,17 +545,19 @@ public class BasicActionProvider { private static ServiceOperation extendBatchDelete(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId( MessageFormat.format("{0}&^^&Extend_BatchDelete", voId)); operation.setCode("Extend_BatchDelete"); - operation.setName("扩展批量删除"); - operation.setDescription("扩展批量删除"); + operation.setName("批量删除" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("批量删除指定的{0},如删除数据较多,建议使用”批量删除{0}" + + "“操作。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Extend_BatchDelete", voId)); operation.setHttpMethod("PUT"); operation.setTemplate("/extension/batchdelete"); - operation.setDeprecated(false); + operation.setDeprecated(true); operation.setExtend1("Basic"); operation.setParameters(new ArrayList<>()); @@ -573,12 +590,15 @@ public class BasicActionProvider { private static ServiceOperation extendBatchDeletion(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId( MessageFormat.format("{0}&^^&Extension_BatchDeletion", voId)); operation.setCode("Extension_BatchDeletion"); - operation.setName("扩展批量删除"); - operation.setDescription("扩展批量删除"); + operation.setName("批量删除" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("批量删除指定的{0},该操作仅在当前业务上下文中删除,并不会" + + "持久化到数据库。后续需调用”保存“操作进行持久化,如需要立即持久化,请调用”批量删除{0}并保存“操作。" + + "可在删除过程中,修改其他数据,并返回删除过程中产生的其他变更。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Extension_BatchDeletion", voId)); operation.setHttpMethod("PUT"); @@ -614,14 +634,16 @@ public class BasicActionProvider { } private static ServiceOperation extendDelete(GspMetadata vmMetadata) { - + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); operation.setId(MessageFormat.format("{0}&^^&Extend_Delete", voId)); operation.setCode("Extend_Delete"); - operation.setName("扩展删除"); - operation.setDescription("扩展删除"); + operation.setName("删除" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("删除指定的{0}。该操作仅在当前业务上下文中删除,并不会持久化" + + "到数据库。后续需调用”保存“操作进行持久化,如需要立即持久化,请调用”删除{0}并保存“操作。也可通过变更集," + + "在删除过程中修改其他数据,并返回删除过程中产生的其他变更。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Extend_Delete", voId)); operation.setHttpMethod("PUT"); @@ -679,7 +701,7 @@ public class BasicActionProvider { ? viewObject.getCode() : nodesCodesStringBuidler + "#" + viewObject.getCode(); ServiceOperation operation = - GetDeleteChildOperation(vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); + GetDeleteChildOperation(vmMetadata, viewObject.getName(), nodesCodesStringBuidler); if (operation != null) { operations.add(operation); } @@ -722,8 +744,9 @@ public class BasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&{1}", voId, methodId)); operation.setCode(methodCode); - operation.setName(MessageFormat.format("删除从表{0}数据", currentNodeCode)); - operation.setDescription(MessageFormat.format("删除从表{0}数据", currentNodeCode)); + operation.setName(MessageFormat.format("删除{0}", currentNodeCode)); + operation.setDescription(MessageFormat.format("删除{0},该操作仅在当前业务上下文中删除,并不会持久化到" + + "数据库。后续需调用”保存“操作进行持久化。", currentNodeCode)); operation.setResourceOpId( MessageFormat.format("{0}&^^&{1}", voId, methodId)); operation.setHttpMethod("DELETE"); @@ -797,7 +820,7 @@ public class BasicActionProvider { ? viewObject.getCode() : nodesCodesStringBuidler + "#" + viewObject.getCode(); ServiceOperation operation = - getBatchCreateChildOperation(vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); + getBatchCreateChildOperation(vmMetadata, viewObject.getName(), nodesCodesStringBuidler); if (operation != null) { operations.add(operation); } @@ -819,7 +842,7 @@ public class BasicActionProvider { ? viewObject.getCode() : nodesCodesStringBuidler + "#" + viewObject.getCode(); ServiceOperation operation = - getCreateChildOperation(vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); + getCreateChildOperation(vmMetadata, viewObject.getName(), nodesCodesStringBuidler); if (operation != null) { operations.add(operation); } @@ -874,8 +897,8 @@ public class BasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&{1}", voId, methodId)); operation.setCode(methodCode); - operation.setName(MessageFormat.format("批量新增从表{0}数据", currentNodeCode)); - operation.setDescription(MessageFormat.format("批量新增从表{0}数据", currentNodeCode)); + operation.setName(MessageFormat.format("批量新增{0}", currentNodeCode)); + operation.setDescription(MessageFormat.format("批量新增{0},可指定字段初始值。", currentNodeCode)); operation.setResourceOpId( MessageFormat.format("{0}&^^&{1}", voId, methodId)); operation.setHttpMethod("POST"); @@ -957,8 +980,8 @@ public class BasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&{1}", voId, methodId)); operation.setCode(methodCode); - operation.setName(MessageFormat.format("新增从表{0}数据", currentNodeCode)); - operation.setDescription(MessageFormat.format("新增从表{0}数据", currentNodeCode)); + operation.setName(MessageFormat.format("新增{0}", currentNodeCode)); + operation.setDescription(MessageFormat.format("新增{0}。", currentNodeCode)); operation.setResourceOpId( MessageFormat.format("{0}&^^&{1}", voId, methodId)); operation.setHttpMethod("POST"); @@ -999,16 +1022,18 @@ public class BasicActionProvider { private static ServiceOperation getElementHelp(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId(MessageFormat.format("{0}&^^&ElementHelp", voId)); operation.setCode("GetElementHelp"); - operation.setName("获取字段帮助"); - operation.setDescription("根据labelId获取字段帮助"); + operation.setName("获取字段帮助数据"); + operation.setDescription(MessageFormat.format("获取指定帮助字段的帮助数据,支持{0}及其子表的所有帮助字" + + "段的帮助数据。如果查询条件较长,建议使用”获取字段帮助数据“操作。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&ElementHelp", voId)); operation.setHttpMethod("GET"); operation.setTemplate("elementhelps/{labelId}"); - operation.setDeprecated(false); + operation.setDeprecated(true); operation.setExtend1("Basic"); operation.setParameters(new ArrayList<>()); @@ -1090,7 +1115,7 @@ public class BasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&Cancel", voId)); operation.setCode("Cancel"); operation.setName("取消"); - operation.setDescription("取消"); + operation.setDescription("取消所有数据的修改,此操作会将修改过程中锁定的数据解锁。"); operation.setResourceOpId( MessageFormat.format("{0}&^^&Cancel", voId)); operation.setHttpMethod("POST"); @@ -1108,7 +1133,7 @@ public class BasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&Save", voId)); operation.setCode("Save"); operation.setName("保存"); - operation.setDescription("保存"); + operation.setDescription("将当前业务上下文内所有修改的数据持久化到数据库。"); operation.setResourceOpId(MessageFormat.format("{0}&^^&Save", voId)); operation.setHttpMethod("PUT"); operation.setTemplate(""); @@ -1126,6 +1151,31 @@ public class BasicActionProvider { return operation; } + private static ServiceOperation hasChanges(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&HasChanges", voId)); + operation.setCode("HasChanges"); + operation.setName("检查变更"); + operation.setDescription("检查当前业务上下文内是否存在未保存的变更"); + operation.setResourceOpId(MessageFormat.format("{0}&^^&HasChanges", voId)); + operation.setHttpMethod("PUT"); + operation.setTemplate("haschanges"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + private static ServiceOperation query(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); @@ -1133,12 +1183,12 @@ public class BasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&Query", voId)); operation.setCode("Query"); - operation.setName("过滤查询"); - operation.setDescription("过滤查询"); + operation.setName("查询" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("查询{0},可指定查询过滤条件、排序字段、设置分页。", viewModel.getMainObject().getName())); operation.setResourceOpId(MessageFormat.format("{0}&^^&Query", voId)); operation.setHttpMethod("GET"); operation.setTemplate(""); - operation.setDeprecated(false); + operation.setDeprecated(true); operation.setExtend1("Basic"); operation.setParameters(new ArrayList<>()); @@ -1186,11 +1236,12 @@ public class BasicActionProvider { private static ServiceOperation retrieveChildByIndex(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId(MessageFormat.format("{0}&^^&QueryChild", voId)); operation.setCode("QueryChild"); - operation.setName("子表查询"); - operation.setDescription("子表数据查询"); + operation.setName(MessageFormat.format("查询{0}特定子表的数据", viewModel.getMainObject().getName())); + operation.setDescription(MessageFormat.format("查询指定的{0}下特定子表的数据。可对指定子表进行过滤、排序、分页。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&QueryChild", voId)); operation.setHttpMethod("PUT"); @@ -1263,14 +1314,15 @@ public class BasicActionProvider { private static ServiceOperation retrieveWithChildPagination(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); - + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); ServiceOperation operation = new ServiceOperation(); operation.setId( MessageFormat.format("{0}&^^&RetrieveWithChildPagination", voId)); operation.setCode("RetrieveWithChildPagination"); - operation.setName("数据检索"); - operation.setDescription("数据检索(包含子表数据)"); + operation.setName(MessageFormat.format("检索{0}(支持子表分页)", viewModel.getMainObject().getName())); + operation.setDescription(MessageFormat.format("检索指定的{0},可对指定子表进行分页。", + viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&RetrieveWithChildPagination", voId)); operation.setHttpMethod("PUT"); @@ -1333,8 +1385,9 @@ public class BasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&Retrieve", voId)); operation.setCode("Retrieve"); - operation.setName("数据检索"); - operation.setDescription("数据检索"); + operation.setName("检索" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("检索指定的{0},返回结果中包含{0}的所有子表数据。", + viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Retrieve", voId)); operation.setHttpMethod("GET"); @@ -1386,11 +1439,12 @@ public class BasicActionProvider { private static ServiceOperation update(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId(MessageFormat.format("{0}&^^&Update", voId)); operation.setCode("Update"); - operation.setName("修改"); - operation.setDescription("修改"); + operation.setName("更新" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("通过变更集更新{0}。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Update", voId)); operation.setHttpMethod("PATCH"); @@ -1434,11 +1488,13 @@ public class BasicActionProvider { private static ServiceOperation deleteAndSave(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId(MessageFormat.format("{0}&^^&DeleteAndSave", voId)); operation.setCode("DeleteAndSave"); - operation.setName("删除并保存"); - operation.setDescription("删除并保存"); + operation.setName(MessageFormat.format("删除{0}并保存", viewModel.getMainObject().getName())); + operation.setDescription(MessageFormat.format("删除指定的{0},并持久化到数据库。", + viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&DeleteAndSave", voId)); operation.setHttpMethod("PUT"); @@ -1475,16 +1531,19 @@ public class BasicActionProvider { private static ServiceOperation batchDelete(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId(MessageFormat.format("{0}&^^&BatchDelete", voId)); operation.setCode("BatchDelete"); - operation.setName("批量删除"); - operation.setDescription("批量删除"); + operation.setName("批量删除" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("批量删除指定的{0},该操作仅在当前业务上下文中删除," + + "并不会持久化到数据库。后续需调用”保存“操作进行持久化,如需要立即持久化,请调用”批量删除{1}并保存" + + "“操作。", viewModel.getMainObject().getName(), viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&BatchDelete", voId)); operation.setHttpMethod("DELETE"); operation.setTemplate(""); - operation.setDeprecated(false); + operation.setDeprecated(true); operation.setExtend1("Basic"); operation.setParameters(new ArrayList<>()); @@ -1511,11 +1570,12 @@ public class BasicActionProvider { private static ServiceOperation batchDeleteAndSave(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId(MessageFormat.format("{0}&^^&BatchDeleteAndSave", voId)); operation.setCode("BatchDeleteAndSave"); - operation.setName("批量删除并保存"); - operation.setDescription("批量删除并保存"); + operation.setName(MessageFormat.format("批量删除{0}并保存", viewModel.getMainObject().getName())); + operation.setDescription(MessageFormat.format("批量删除指定的{0},并持久化到数据库。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&BatchDeleteAndSave", voId)); operation.setHttpMethod("POST"); @@ -1552,11 +1612,14 @@ public class BasicActionProvider { private static ServiceOperation delete(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId(MessageFormat.format("{0}&^^&Delete", voId)); operation.setCode("Delete"); - operation.setName("删除"); - operation.setDescription("删除"); + operation.setName("删除" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("删除指定的{0},该操作仅在当前业务上下文中删除,并不" + + "会持久化到数据库。后续需调用”保存“操作进行持久化,如需要立即持久化,请调用”删除{0}并保存“操作。", + viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Delete", voId)); operation.setHttpMethod("DELETE"); @@ -1587,11 +1650,13 @@ public class BasicActionProvider { private static ServiceOperation edit(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId(MessageFormat.format("{0}&^^&Edit", voId)); operation.setCode("Edit"); - operation.setName("编辑"); - operation.setDescription("编辑"); + operation.setName("编辑" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("编辑指定的{0},此操作会锁定相应的{0}数据。该操作成功" + + "后,其他用户不能修改该数据,直到调用”保存“或”取消“操作。", viewModel.getMainObject().getName())); operation.setResourceOpId(MessageFormat.format("{0}&^^&Edit", voId)); operation.setHttpMethod("PUT"); operation.setTemplate("/service/edit/{dataId}"); @@ -1626,12 +1691,13 @@ public class BasicActionProvider { private static ServiceOperation create(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); ServiceOperation operation = new ServiceOperation(); operation.setId(MessageFormat.format("{0}&^^&Create", voId)); operation.setCode("Create"); - operation.setName("新增"); - operation.setDescription("新增主表数据"); + operation.setName("新增" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("新增{0},可指定字段初始值。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Create", voId)); operation.setHttpMethod("POST"); @@ -1675,11 +1741,12 @@ public class BasicActionProvider { private static ServiceOperation batchCreate(GspMetadata vmMetadata) { String voId = vmMetadata.getHeader().getId(); ServiceOperation operation = new ServiceOperation(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); operation.setId(MessageFormat.format("{0}&^^&BatchCreate", voId)); operation.setCode("BatchCreate"); - operation.setName("批量新增主表数据"); - operation.setDescription("根据默认值批量新增主表数据"); + operation.setName("批量新增" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("批量新增{0},可指定字段初始值。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&BatchCreate", voId)); operation.setHttpMethod("POST"); @@ -1743,7 +1810,8 @@ public class BasicActionProvider { ServiceOperation operation = new ServiceOperation(); operation.setId(MessageFormat.format("{0}&^^&CloseSession", voId)); operation.setCode("CloseSession"); - operation.setName("关闭Session"); + operation.setName("关闭业务上下文"); + operation.setDescription("在调用该服务的其他操作完成业务功能后,应该调用该操作关闭业务上下文,否则该业务上下文内修改的数据将保持锁定状态,无法被其他用户修改。"); operation.setResourceOpId( MessageFormat.format("{0}&^^&CloseSession", voId)); operation.setHttpMethod("POST"); @@ -1759,7 +1827,8 @@ public class BasicActionProvider { ServiceOperation operation = new ServiceOperation(); operation.setId(MessageFormat.format("{0}&^^&CreateSession", voId)); operation.setCode("CreateSession"); - operation.setName("创建Session"); + operation.setName("创建业务上下文"); + operation.setDescription("在调用该服务其他操作前,应该首先调用该操作创建业务上下文。在业务上下文存在期间,所有通过该服务修改的数据均被锁定,其他业务上下文无法修改。"); operation.setResourceOpId( MessageFormat.format("{0}&^^&CreateSession", voId)); operation.setHttpMethod("POST"); diff --git a/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/BasicActionSummary.java b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/BasicActionSummary.java index f1210af3260610469fd394cf094709e3b06d2fd0..f301dd2b3a97fb570a6c6eec2722c3dbad455bed 100644 --- a/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/BasicActionSummary.java +++ b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/BasicActionSummary.java @@ -16,14 +16,10 @@ package com.inspur.edp.sgf.provider.vo.basic; -import com.inspur.edp.das.commonmodel.IGspCommonObject; -import com.inspur.edp.formserver.viewmodel.GspViewModel; -import com.inspur.edp.formserver.viewmodel.GspViewObject; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; import com.inspur.edp.sgf.api.common.SummaryInfo; -import org.apache.commons.lang3.StringUtils; +import com.inspur.edp.sgf.api.entity.ServiceOperation; -import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; @@ -32,527 +28,535 @@ import java.util.List; */ public class BasicActionSummary { public static List getBasicActions(GspMetadata gspMetadata) { - //todo 添加入参检测 - List operations = new ArrayList<>(); - // 创建BeSession - operations.add(createSession(gspMetadata)); - // 关闭Session - operations.add(closeSession(gspMetadata)); - // 增加 - operations.add(create(gspMetadata)); - // 批量增加 - operations.add(batCreate(gspMetadata)); - // 编辑 - operations.add(edit(gspMetadata)); - // 删除 - operations.add(delete(gspMetadata)); - // 批量删除 - operations.add(batchDelete(gspMetadata)); - //批量删除并保存 - operations.add(batchDeleteAndSave(gspMetadata)); - // 删除并保存 - operations.add(deleteAndSave(gspMetadata)); - // 修改 - operations.add(update(gspMetadata)); - // 查询 - operations.add(retrieve(gspMetadata)); - // 查询(所有数据) - operations.add(retrieveWithChildPagination(gspMetadata)); - // 查询子表 - operations.add(retrieveChildByIndex(gspMetadata)); - // 过滤查询 - operations.add(query(gspMetadata)); - // 保存 - operations.add(save(gspMetadata)); - // 取消 - operations.add(cancel(gspMetadata)); - // 获取字段帮助操作 - operations.add(getElementHelp(gspMetadata)); - // 新增子对象数据 - operations.addAll(getCreateChildOperationList(gspMetadata)); - // 批量新增子对象数据,可批量传子对象默认值 - operations.addAll(getBatchCreateChildOperationList(gspMetadata)); - // 删除子对象数据 - operations.addAll(getDeleteChildOperationList(gspMetadata)); - // 扩展删除 - operations.add(extendDelete(gspMetadata)); - // 扩展批量删除 - operations.add(extendBatchDelete(gspMetadata)); - // 扩展批量删除(body传参) - operations.add(extendBatchDeletion(gspMetadata)); - // 扩展查询 - operations.add(extendRetrieve((gspMetadata))); - // 扩展过滤查询 - operations.add(extendQuery(gspMetadata)); - // 查询数据 - operations.add(extensionFilter(gspMetadata)); - // 扩展帮助 - operations.add(extendElementHelp(gspMetadata)); - // 扩展删除子对象数据 - operations.addAll(getExtendDeleteChildOperationList(gspMetadata)); - // 扩展批量删除子对象数据 - operations.addAll(getExtendBatchDeleteChildOperationList(gspMetadata)); - return operations; - } - - private static List getExtendBatchDeleteChildOperationList(GspMetadata vmMetadata) { - List operations = new ArrayList<>(); - GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); - GspViewObject mainObject = viewModel.getMainObject(); - if (mainObject == null || mainObject.getContainChildObjects().size() <= 0) { - return operations; - } - for (IGspCommonObject obj : mainObject.getContainChildObjects()) { - String nodesCodesStringBuidler = ""; - getExtendBatchDeleteChildActions( - (GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); - } - return operations; - } - - private static List getExtendDeleteChildOperationList(GspMetadata vmMetadata) { - List operations = new ArrayList<>(); - GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); - GspViewObject mainObject = viewModel.getMainObject(); - if (mainObject == null || mainObject.getContainChildObjects().size() <= 0) { - return operations; - } - for (IGspCommonObject obj : mainObject.getContainChildObjects()) { - String nodesCodesStringBuidler = ""; - getExtendDeleteChildActions( - (GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); - } - return operations; - } - - private static void getExtendBatchDeleteChildActions( - GspViewObject viewObject, - List operations, - String nodesCodesStringBuidler, - GspMetadata vmMetadata) { - nodesCodesStringBuidler = - StringUtils.isBlank(nodesCodesStringBuidler) - ? viewObject.getCode() - : nodesCodesStringBuidler + "#" + viewObject.getCode(); - SummaryInfo operation = - getExtendBatchDeleteChildOperation(vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); - if (operation != null) { - operations.add(operation); - } - if (viewObject.getContainChildObjects().size() > 0) { - for (IGspCommonObject obj : viewObject.getContainChildObjects()) { - getExtendBatchDeleteChildActions( - (GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); - } - } - } - - private static void getExtendDeleteChildActions( - GspViewObject viewObject, - List operations, - String nodesCodesStringBuidler, - GspMetadata vmMetadata) { - nodesCodesStringBuidler = - StringUtils.isBlank(nodesCodesStringBuidler) - ? viewObject.getCode() - : nodesCodesStringBuidler + "#" + viewObject.getCode(); - SummaryInfo operation = - getExtendDeleteChildOperation(vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); - if (operation != null) { - operations.add(operation); - } - if (viewObject.getContainChildObjects().size() > 0) { - for (IGspCommonObject obj : viewObject.getContainChildObjects()) { - getExtendDeleteChildActions( - (GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); - } - } - } - - private static SummaryInfo getExtendBatchDeleteChildOperation( - GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { - String[] nodeCodes = nodeCodesStringBuilder.split("#"); - if (nodeCodes.length <= 0) { - return null; - } - SummaryInfo operation = new SummaryInfo(); - String methodCode = "Extend_BatchDeleteChild"; - String methodId = "Extend_BatchDeleteChild"; - for (String nodeCode : nodeCodes) { - methodCode = methodCode + String.format("_%s", nodeCode); - methodId = methodId + MessageFormat.format("##{0}", nodeCode); - } - operation.setId(MessageFormat.format("{0}&^^&{1}", vmMetadata.getHeader().getId(), methodId)); - operation.setCode(methodCode); - operation.setName(MessageFormat.format("扩展批量删除从表{0}数据", currentNodeCode)); - return operation; - } - - private static SummaryInfo getExtendDeleteChildOperation( - GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { - String[] nodeCodes = nodeCodesStringBuilder.split("#"); - if (nodeCodes.length <= 0) { - return null; - } - SummaryInfo operation = new SummaryInfo(); - String methodCode = "Extend_DeleteChild"; - String methodId = "Extend_DeleteChild"; - for (String nodeCode : nodeCodes) { - methodCode = methodCode + String.format("_%s", nodeCode); - methodId = methodId + MessageFormat.format("##{0}", nodeCode); - } - operation.setId(MessageFormat.format("{0}&^^&{1}", vmMetadata.getHeader().getId(), methodId)); - operation.setCode(methodCode); - operation.setName(MessageFormat.format("扩展删除从表{0}数据", currentNodeCode)); - return operation; - } - - private static SummaryInfo extendElementHelp(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId( - MessageFormat.format("{0}&^^&Extend_ElementHelp", vmMetadata.getHeader().getId())); - operation.setCode("Extend_GetElementHelp"); - operation.setName("扩展获取字段帮助"); - return operation; - } - - private static SummaryInfo extensionFilter(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId( - MessageFormat.format("{0}&^^&Extension_Filter", vmMetadata.getHeader().getId())); - operation.setCode("Extension_Filter"); - operation.setName("查询数据"); - return operation; - } - - private static SummaryInfo extendQuery(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&Extend_Query", vmMetadata.getHeader().getId())); - operation.setCode("Extend_Query"); - operation.setName("扩展过滤查询"); - return operation; - } - - private static SummaryInfo extendRetrieve(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&Extend_Retrieve", vmMetadata.getHeader().getId())); - operation.setCode("Extend_Retrieve"); - operation.setName("扩展数据检索"); - return operation; - } - - private static SummaryInfo extendBatchDelete(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId( - MessageFormat.format("{0}&^^&Extend_BatchDelete", vmMetadata.getHeader().getId())); - operation.setCode("Extend_BatchDelete"); - operation.setName("扩展批量删除"); - return operation; - } - - private static SummaryInfo extendBatchDeletion(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId( - MessageFormat.format("{0}&^^&Extension_BatchDeletion", vmMetadata.getHeader().getId())); - operation.setCode("Extension_BatchDeletion"); - operation.setName("扩展批量删除"); - return operation; - } - - private static SummaryInfo extendDelete(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&Extend_Delete", vmMetadata.getHeader().getId())); - operation.setCode("Extend_Delete"); - operation.setName("扩展删除"); - return operation; - } - - private static List getDeleteChildOperationList(GspMetadata vmMetadata) { - List operations = new ArrayList<>(); - GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); - GspViewObject mainObject = viewModel.getMainObject(); - if (mainObject == null || mainObject.getContainChildObjects().size() <= 0) { - return operations; - } - for (IGspCommonObject obj : mainObject.getContainChildObjects()) { - String nodesCodesStringBuidler = ""; - getDeleteChildActions((GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); - } - return operations; - } - - private static void getDeleteChildActions(GspViewObject viewObject, List operations, - String nodesCodesStringBuidler, GspMetadata vmMetadata) { - nodesCodesStringBuidler = StringUtils.isBlank(nodesCodesStringBuidler) ? - viewObject.getCode() : nodesCodesStringBuidler + "#" + viewObject.getCode(); - SummaryInfo operation = - getDeleteChildOperation(vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); - if (operation != null) { - operations.add(operation); - } - if (viewObject.getContainChildObjects().size() > 0) { - for (IGspCommonObject obj : viewObject.getContainChildObjects()) { - getDeleteChildActions((GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); - } - } - } - - private static SummaryInfo getDeleteChildOperation( - GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { - String[] nodeCodes = nodeCodesStringBuilder.split("#"); - if (nodeCodes.length <= 0) { - return null; - } - SummaryInfo operation = new SummaryInfo(); - String methodCode = "DeleteChild"; - String methodId = "DeleteChild"; - for (String nodeCode : nodeCodes) { - methodCode = methodCode + String.format("_%s", nodeCode); - methodId = methodId + MessageFormat.format("##{0}", nodeCode); - } - operation.setId(MessageFormat.format("{0}&^^&{1}", vmMetadata.getHeader().getId(), methodId)); - operation.setCode(methodCode); - operation.setName(MessageFormat.format("删除从表{0}数据", currentNodeCode)); - return operation; - } - - private static List getBatchCreateChildOperationList(GspMetadata vmMetadata) { - List operations = new ArrayList<>(); - GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); - GspViewObject mainObject = viewModel.getMainObject(); - if (mainObject == null || mainObject.getContainChildObjects().size() <= 0) { - return operations; - } - for (IGspCommonObject obj : mainObject.getContainChildObjects()) { - String nodesCodesStringBuidler = ""; - getBatchCreateChildActions((GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); - } - return operations; - } - - private static List getCreateChildOperationList(GspMetadata vmMetadata) { - List operations = new ArrayList<>(); - GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); - GspViewObject mainObject = viewModel.getMainObject(); - if (mainObject == null || mainObject.getContainChildObjects().size() <= 0) { - return operations; - } - for (IGspCommonObject obj : mainObject.getContainChildObjects()) { - String nodesCodesStringBuidler = ""; - getCreateChildActions((GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); - } - return operations; - } - - private static void getBatchCreateChildActions( - GspViewObject viewObject, - List operations, - String nodesCodesStringBuidler, - GspMetadata vmMetadata) { - nodesCodesStringBuidler = - StringUtils.isBlank(nodesCodesStringBuidler) - ? viewObject.getCode() - : nodesCodesStringBuidler + "#" + viewObject.getCode(); - SummaryInfo operation = - getBatchCreateChildOperation(vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); - if (operation != null) { - operations.add(operation); - } - if (viewObject.getContainChildObjects().size() > 0) { - for (IGspCommonObject obj : viewObject.getContainChildObjects()) { - getBatchCreateChildActions((GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); - } - } - } - - private static void getCreateChildActions(GspViewObject viewObject, List operations, - String nodesCodesStringBuidler, GspMetadata vmMetadata) { - nodesCodesStringBuidler = StringUtils.isBlank(nodesCodesStringBuidler) ? - viewObject.getCode() : nodesCodesStringBuidler + "#" + viewObject.getCode(); - SummaryInfo operation = - getCreateChildOperation(vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); - if (operation != null) { - operations.add(operation); - } - if (viewObject.getContainChildObjects().size() > 0) { - for (IGspCommonObject obj : viewObject.getContainChildObjects()) { - getCreateChildActions((GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); - } - } - } - - private static SummaryInfo getBatchCreateChildOperation( - GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { - String[] nodeCodes = nodeCodesStringBuilder.split("#"); - if (nodeCodes.length <= 0) { - return null; + List summaryInfos = new ArrayList<>(); + List operations = BasicActionProvider.getBasicActions(gspMetadata); + for (ServiceOperation op : operations) { + SummaryInfo summaryInfo = new SummaryInfo(); + summaryInfo.setId(op.getId()); + summaryInfo.setCode(op.getCode()); + summaryInfo.setName(op.getName()); + summaryInfos.add(summaryInfo); } - SummaryInfo operation = new SummaryInfo(); - String methodCode = "BatchCreateChild"; - String methodId = "BatchCreateChild"; - for (String nodeCode : nodeCodes) { - methodCode = methodCode + String.format("_%s", nodeCode); - methodId = methodId + MessageFormat.format("##{0}", nodeCode); - } - operation.setId(MessageFormat.format("{0}&^^&{1}", vmMetadata.getHeader().getId(), methodId)); - operation.setCode(methodCode); - operation.setName(MessageFormat.format("批量新增从表{0}数据", currentNodeCode)); - return operation; - } - - private static SummaryInfo getCreateChildOperation( - GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { - String[] nodeCodes = nodeCodesStringBuilder.split("#"); - if (nodeCodes.length <= 0) { - return null; - } - SummaryInfo operation = new SummaryInfo(); - String methodCode = "CreateChild"; - String methodId = "CreateChild"; - for (String nodeCode : nodeCodes) { - methodCode = methodCode + String.format("_%s", nodeCode); - methodId = methodId + MessageFormat.format("##{0}", nodeCode); - } - operation.setId(MessageFormat.format("{0}&^^&{1}", vmMetadata.getHeader().getId(), methodId)); - operation.setCode(methodCode); - operation.setName(MessageFormat.format("新增从表{0}数据", currentNodeCode)); - return operation; - } - - private static SummaryInfo getElementHelp(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&ElementHelp", vmMetadata.getHeader().getId())); - operation.setCode("GetElementHelp"); - operation.setName("获取字段帮助"); - return operation; - } - - private static SummaryInfo cancel(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&Cancel", vmMetadata.getHeader().getId())); - operation.setCode("Cancel"); - operation.setName("取消"); - return operation; - } - - private static SummaryInfo save(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&Save", vmMetadata.getHeader().getId())); - operation.setCode("Save"); - operation.setName("保存"); - return operation; - } - - private static SummaryInfo query(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&Query", vmMetadata.getHeader().getId())); - operation.setCode("Query"); - operation.setName("过滤查询"); - return operation; - } - - private static SummaryInfo retrieveChildByIndex(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&QueryChild", vmMetadata.getHeader().getId())); - operation.setCode("QueryChild"); - operation.setName("子表查询"); - return operation; - } - - private static SummaryInfo retrieveWithChildPagination(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId( - MessageFormat.format("{0}&^^&RetrieveWithChildPagination", vmMetadata.getHeader().getId())); - operation.setCode("RetrieveWithChildPagination"); - operation.setName("数据检索"); - return operation; - } - - private static SummaryInfo retrieve(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&Retrieve", vmMetadata.getHeader().getId())); - operation.setCode("Retrieve"); - operation.setName("数据检索"); - return operation; - } - - private static SummaryInfo update(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&Update", vmMetadata.getHeader().getId())); - operation.setCode("Update"); - operation.setName("修改"); - return operation; - } - - private static SummaryInfo deleteAndSave(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&DeleteAndSave", vmMetadata.getHeader().getId())); - operation.setCode("DeleteAndSave"); - operation.setName("删除并保存"); - return operation; - } - - private static SummaryInfo batchDelete(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&BatchDelete", vmMetadata.getHeader().getId())); - operation.setCode("BatchDelete"); - operation.setName("批量删除"); - return operation; - } - - private static SummaryInfo batchDeleteAndSave(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&BatchDeleteAndSave", vmMetadata.getHeader().getId())); - operation.setCode("BatchDeleteAndSave"); - operation.setName("批量删除并保存"); - return operation; - } - - private static SummaryInfo delete(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&Delete", vmMetadata.getHeader().getId())); - operation.setCode("Delete"); - operation.setName("删除"); - return operation; - } - - private static SummaryInfo edit(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&Edit", vmMetadata.getHeader().getId())); - operation.setCode("Edit"); - operation.setName("编辑"); - return operation; - } - - private static SummaryInfo create(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&Create", vmMetadata.getHeader().getId())); - operation.setCode("Create"); - operation.setName("新增"); - return operation; - } - - private static SummaryInfo batCreate(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&BatchCreate", vmMetadata.getHeader().getId())); - operation.setCode("BatchCreate"); - operation.setName("批量新增主表数据"); - return operation; - } - - private static SummaryInfo closeSession(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&CloseSession", vmMetadata.getHeader().getId())); - operation.setCode("CloseSession"); - operation.setName("关闭Session"); - return operation; - } - - private static SummaryInfo createSession(GspMetadata vmMetadata) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(MessageFormat.format("{0}&^^&CreateSession", vmMetadata.getHeader().getId())); - operation.setCode("CreateSession"); - operation.setName("创建Session"); - return operation; - } + return summaryInfos; +// // 创建BeSession +// operations.add(createSession(gspMetadata)); +// // 关闭Session +// operations.add(closeSession(gspMetadata)); +// // 增加 +// operations.add(create(gspMetadata)); +// // 批量增加 +// operations.add(batCreate(gspMetadata)); +// // 编辑 +// operations.add(edit(gspMetadata)); +// // 删除 +// operations.add(delete(gspMetadata)); +// // 批量删除 +// operations.add(batchDelete(gspMetadata)); +// //批量删除并保存 +// operations.add(batchDeleteAndSave(gspMetadata)); +// // 删除并保存 +// operations.add(deleteAndSave(gspMetadata)); +// // 修改 +// operations.add(update(gspMetadata)); +// // 查询 +// operations.add(retrieve(gspMetadata)); +// // 查询(所有数据) +// operations.add(retrieveWithChildPagination(gspMetadata)); +// // 查询子表 +// operations.add(retrieveChildByIndex(gspMetadata)); +// // 过滤查询 +// operations.add(query(gspMetadata)); +// // 保存 +// operations.add(save(gspMetadata)); +// // 取消 +// operations.add(cancel(gspMetadata)); +// // 获取字段帮助操作 +// operations.add(getElementHelp(gspMetadata)); +// // 新增子对象数据 +// operations.addAll(getCreateChildOperationList(gspMetadata)); +// // 批量新增子对象数据,可批量传子对象默认值 +// operations.addAll(getBatchCreateChildOperationList(gspMetadata)); +// // 删除子对象数据 +// operations.addAll(getDeleteChildOperationList(gspMetadata)); +// // 扩展删除 +// operations.add(extendDelete(gspMetadata)); +// // 扩展批量删除 +// operations.add(extendBatchDelete(gspMetadata)); +// // 扩展批量删除(body传参) +// operations.add(extendBatchDeletion(gspMetadata)); +// // 扩展查询 +// operations.add(extendRetrieve((gspMetadata))); +// // 扩展过滤查询 +// operations.add(extendQuery(gspMetadata)); +// // 查询数据 +// operations.add(extensionFilter(gspMetadata)); +// // 扩展帮助 +// operations.add(extendElementHelp(gspMetadata)); +// // 扩展删除子对象数据 +// operations.addAll(getExtendDeleteChildOperationList(gspMetadata)); +// // 扩展批量删除子对象数据 +// operations.addAll(getExtendBatchDeleteChildOperationList(gspMetadata)); +// return operations; + } + +// private static List getExtendBatchDeleteChildOperationList(GspMetadata vmMetadata) { +// List operations = new ArrayList<>(); +// GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); +// GspViewObject mainObject = viewModel.getMainObject(); +// if (mainObject == null || mainObject.getContainChildObjects().size() <= 0) { +// return operations; +// } +// for (IGspCommonObject obj : mainObject.getContainChildObjects()) { +// String nodesCodesStringBuidler = ""; +// getExtendBatchDeleteChildActions( +// (GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); +// } +// return operations; +// } +// +// private static List getExtendDeleteChildOperationList(GspMetadata vmMetadata) { +// List operations = new ArrayList<>(); +// GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); +// GspViewObject mainObject = viewModel.getMainObject(); +// if (mainObject == null || mainObject.getContainChildObjects().size() <= 0) { +// return operations; +// } +// for (IGspCommonObject obj : mainObject.getContainChildObjects()) { +// String nodesCodesStringBuidler = ""; +// getExtendDeleteChildActions( +// (GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); +// } +// return operations; +// } +// +// private static void getExtendBatchDeleteChildActions( +// GspViewObject viewObject, +// List operations, +// String nodesCodesStringBuidler, +// GspMetadata vmMetadata) { +// nodesCodesStringBuidler = +// StringUtils.isBlank(nodesCodesStringBuidler) +// ? viewObject.getCode() +// : nodesCodesStringBuidler + "#" + viewObject.getCode(); +// SummaryInfo operation = +// getExtendBatchDeleteChildOperation(vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); +// if (operation != null) { +// operations.add(operation); +// } +// if (viewObject.getContainChildObjects().size() > 0) { +// for (IGspCommonObject obj : viewObject.getContainChildObjects()) { +// getExtendBatchDeleteChildActions( +// (GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); +// } +// } +// } +// +// private static void getExtendDeleteChildActions( +// GspViewObject viewObject, +// List operations, +// String nodesCodesStringBuidler, +// GspMetadata vmMetadata) { +// nodesCodesStringBuidler = +// StringUtils.isBlank(nodesCodesStringBuidler) +// ? viewObject.getCode() +// : nodesCodesStringBuidler + "#" + viewObject.getCode(); +// SummaryInfo operation = +// getExtendDeleteChildOperation(vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); +// if (operation != null) { +// operations.add(operation); +// } +// if (viewObject.getContainChildObjects().size() > 0) { +// for (IGspCommonObject obj : viewObject.getContainChildObjects()) { +// getExtendDeleteChildActions( +// (GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); +// } +// } +// } +// +// private static SummaryInfo getExtendBatchDeleteChildOperation( +// GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { +// String[] nodeCodes = nodeCodesStringBuilder.split("#"); +// if (nodeCodes.length <= 0) { +// return null; +// } +// SummaryInfo operation = new SummaryInfo(); +// String methodCode = "Extend_BatchDeleteChild"; +// String methodId = "Extend_BatchDeleteChild"; +// for (String nodeCode : nodeCodes) { +// methodCode = methodCode + String.format("_%s", nodeCode); +// methodId = methodId + MessageFormat.format("##{0}", nodeCode); +// } +// operation.setId(MessageFormat.format("{0}&^^&{1}", vmMetadata.getHeader().getId(), methodId)); +// operation.setCode(methodCode); +// operation.setName(MessageFormat.format("扩展批量删除从表{0}数据", currentNodeCode)); +// return operation; +// } +// +// private static SummaryInfo getExtendDeleteChildOperation( +// GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { +// String[] nodeCodes = nodeCodesStringBuilder.split("#"); +// if (nodeCodes.length <= 0) { +// return null; +// } +// SummaryInfo operation = new SummaryInfo(); +// String methodCode = "Extend_DeleteChild"; +// String methodId = "Extend_DeleteChild"; +// for (String nodeCode : nodeCodes) { +// methodCode = methodCode + String.format("_%s", nodeCode); +// methodId = methodId + MessageFormat.format("##{0}", nodeCode); +// } +// operation.setId(MessageFormat.format("{0}&^^&{1}", vmMetadata.getHeader().getId(), methodId)); +// operation.setCode(methodCode); +// operation.setName(MessageFormat.format("扩展删除从表{0}数据", currentNodeCode)); +// return operation; +// } +// +// private static SummaryInfo extendElementHelp(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId( +// MessageFormat.format("{0}&^^&Extend_ElementHelp", vmMetadata.getHeader().getId())); +// operation.setCode("Extend_GetElementHelp"); +// operation.setName("扩展获取字段帮助"); +// return operation; +// } +// +// private static SummaryInfo extensionFilter(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId( +// MessageFormat.format("{0}&^^&Extension_Filter", vmMetadata.getHeader().getId())); +// operation.setCode("Extension_Filter"); +// operation.setName("查询数据"); +// return operation; +// } +// +// private static SummaryInfo extendQuery(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&Extend_Query", vmMetadata.getHeader().getId())); +// operation.setCode("Extend_Query"); +// operation.setName("扩展过滤查询"); +// return operation; +// } +// +// private static SummaryInfo extendRetrieve(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&Extend_Retrieve", vmMetadata.getHeader().getId())); +// operation.setCode("Extend_Retrieve"); +// operation.setName("扩展数据检索"); +// return operation; +// } +// +// private static SummaryInfo extendBatchDelete(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId( +// MessageFormat.format("{0}&^^&Extend_BatchDelete", vmMetadata.getHeader().getId())); +// operation.setCode("Extend_BatchDelete"); +// operation.setName("扩展批量删除"); +// return operation; +// } +// +// private static SummaryInfo extendBatchDeletion(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId( +// MessageFormat.format("{0}&^^&Extension_BatchDeletion", vmMetadata.getHeader().getId())); +// operation.setCode("Extension_BatchDeletion"); +// operation.setName("扩展批量删除"); +// return operation; +// } +// +// private static SummaryInfo extendDelete(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&Extend_Delete", vmMetadata.getHeader().getId())); +// operation.setCode("Extend_Delete"); +// operation.setName("扩展删除"); +// return operation; +// } +// +// private static List getDeleteChildOperationList(GspMetadata vmMetadata) { +// List operations = new ArrayList<>(); +// GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); +// GspViewObject mainObject = viewModel.getMainObject(); +// if (mainObject == null || mainObject.getContainChildObjects().size() <= 0) { +// return operations; +// } +// for (IGspCommonObject obj : mainObject.getContainChildObjects()) { +// String nodesCodesStringBuidler = ""; +// getDeleteChildActions((GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); +// } +// return operations; +// } +// +// private static void getDeleteChildActions(GspViewObject viewObject, List operations, +// String nodesCodesStringBuidler, GspMetadata vmMetadata) { +// nodesCodesStringBuidler = StringUtils.isBlank(nodesCodesStringBuidler) ? +// viewObject.getCode() : nodesCodesStringBuidler + "#" + viewObject.getCode(); +// SummaryInfo operation = +// getDeleteChildOperation(vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); +// if (operation != null) { +// operations.add(operation); +// } +// if (viewObject.getContainChildObjects().size() > 0) { +// for (IGspCommonObject obj : viewObject.getContainChildObjects()) { +// getDeleteChildActions((GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); +// } +// } +// } +// +// private static SummaryInfo getDeleteChildOperation( +// GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { +// String[] nodeCodes = nodeCodesStringBuilder.split("#"); +// if (nodeCodes.length <= 0) { +// return null; +// } +// SummaryInfo operation = new SummaryInfo(); +// String methodCode = "DeleteChild"; +// String methodId = "DeleteChild"; +// for (String nodeCode : nodeCodes) { +// methodCode = methodCode + String.format("_%s", nodeCode); +// methodId = methodId + MessageFormat.format("##{0}", nodeCode); +// } +// operation.setId(MessageFormat.format("{0}&^^&{1}", vmMetadata.getHeader().getId(), methodId)); +// operation.setCode(methodCode); +// operation.setName(MessageFormat.format("删除从表{0}数据", currentNodeCode)); +// return operation; +// } +// +// private static List getBatchCreateChildOperationList(GspMetadata vmMetadata) { +// List operations = new ArrayList<>(); +// GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); +// GspViewObject mainObject = viewModel.getMainObject(); +// if (mainObject == null || mainObject.getContainChildObjects().size() <= 0) { +// return operations; +// } +// for (IGspCommonObject obj : mainObject.getContainChildObjects()) { +// String nodesCodesStringBuidler = ""; +// getBatchCreateChildActions((GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); +// } +// return operations; +// } +// +// private static List getCreateChildOperationList(GspMetadata vmMetadata) { +// List operations = new ArrayList<>(); +// GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); +// GspViewObject mainObject = viewModel.getMainObject(); +// if (mainObject == null || mainObject.getContainChildObjects().size() <= 0) { +// return operations; +// } +// for (IGspCommonObject obj : mainObject.getContainChildObjects()) { +// String nodesCodesStringBuidler = ""; +// getCreateChildActions((GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); +// } +// return operations; +// } +// +// private static void getBatchCreateChildActions( +// GspViewObject viewObject, +// List operations, +// String nodesCodesStringBuidler, +// GspMetadata vmMetadata) { +// nodesCodesStringBuidler = +// StringUtils.isBlank(nodesCodesStringBuidler) +// ? viewObject.getCode() +// : nodesCodesStringBuidler + "#" + viewObject.getCode(); +// SummaryInfo operation = +// getBatchCreateChildOperation(vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); +// if (operation != null) { +// operations.add(operation); +// } +// if (viewObject.getContainChildObjects().size() > 0) { +// for (IGspCommonObject obj : viewObject.getContainChildObjects()) { +// getBatchCreateChildActions((GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); +// } +// } +// } +// +// private static void getCreateChildActions(GspViewObject viewObject, List operations, +// String nodesCodesStringBuidler, GspMetadata vmMetadata) { +// nodesCodesStringBuidler = StringUtils.isBlank(nodesCodesStringBuidler) ? +// viewObject.getCode() : nodesCodesStringBuidler + "#" + viewObject.getCode(); +// SummaryInfo operation = +// getCreateChildOperation(vmMetadata, viewObject.getCode(), nodesCodesStringBuidler); +// if (operation != null) { +// operations.add(operation); +// } +// if (viewObject.getContainChildObjects().size() > 0) { +// for (IGspCommonObject obj : viewObject.getContainChildObjects()) { +// getCreateChildActions((GspViewObject) obj, operations, nodesCodesStringBuidler, vmMetadata); +// } +// } +// } +// +// private static SummaryInfo getBatchCreateChildOperation( +// GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { +// String[] nodeCodes = nodeCodesStringBuilder.split("#"); +// if (nodeCodes.length <= 0) { +// return null; +// } +// SummaryInfo operation = new SummaryInfo(); +// String methodCode = "BatchCreateChild"; +// String methodId = "BatchCreateChild"; +// for (String nodeCode : nodeCodes) { +// methodCode = methodCode + String.format("_%s", nodeCode); +// methodId = methodId + MessageFormat.format("##{0}", nodeCode); +// } +// operation.setId(MessageFormat.format("{0}&^^&{1}", vmMetadata.getHeader().getId(), methodId)); +// operation.setCode(methodCode); +// operation.setName(MessageFormat.format("批量新增从表{0}数据", currentNodeCode)); +// return operation; +// } +// +// private static SummaryInfo getCreateChildOperation( +// GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { +// String[] nodeCodes = nodeCodesStringBuilder.split("#"); +// if (nodeCodes.length <= 0) { +// return null; +// } +// SummaryInfo operation = new SummaryInfo(); +// String methodCode = "CreateChild"; +// String methodId = "CreateChild"; +// for (String nodeCode : nodeCodes) { +// methodCode = methodCode + String.format("_%s", nodeCode); +// methodId = methodId + MessageFormat.format("##{0}", nodeCode); +// } +// operation.setId(MessageFormat.format("{0}&^^&{1}", vmMetadata.getHeader().getId(), methodId)); +// operation.setCode(methodCode); +// operation.setName(MessageFormat.format("新增从表{0}数据", currentNodeCode)); +// return operation; +// } +// +// private static SummaryInfo getElementHelp(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&ElementHelp", vmMetadata.getHeader().getId())); +// operation.setCode("GetElementHelp"); +// operation.setName("获取字段帮助"); +// return operation; +// } +// +// private static SummaryInfo cancel(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&Cancel", vmMetadata.getHeader().getId())); +// operation.setCode("Cancel"); +// operation.setName("取消"); +// return operation; +// } +// +// private static SummaryInfo save(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&Save", vmMetadata.getHeader().getId())); +// operation.setCode("Save"); +// operation.setName("保存"); +// return operation; +// } +// +// private static SummaryInfo query(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&Query", vmMetadata.getHeader().getId())); +// operation.setCode("Query"); +// operation.setName("过滤查询"); +// return operation; +// } +// +// private static SummaryInfo retrieveChildByIndex(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&QueryChild", vmMetadata.getHeader().getId())); +// operation.setCode("QueryChild"); +// operation.setName("子表查询"); +// return operation; +// } +// +// private static SummaryInfo retrieveWithChildPagination(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId( +// MessageFormat.format("{0}&^^&RetrieveWithChildPagination", vmMetadata.getHeader().getId())); +// operation.setCode("RetrieveWithChildPagination"); +// operation.setName("数据检索"); +// return operation; +// } +// +// private static SummaryInfo retrieve(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&Retrieve", vmMetadata.getHeader().getId())); +// operation.setCode("Retrieve"); +// operation.setName("数据检索"); +// return operation; +// } +// +// private static SummaryInfo update(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&Update", vmMetadata.getHeader().getId())); +// operation.setCode("Update"); +// operation.setName("修改"); +// return operation; +// } +// +// private static SummaryInfo deleteAndSave(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&DeleteAndSave", vmMetadata.getHeader().getId())); +// operation.setCode("DeleteAndSave"); +// operation.setName("删除并保存"); +// return operation; +// } +// +// private static SummaryInfo batchDelete(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&BatchDelete", vmMetadata.getHeader().getId())); +// operation.setCode("BatchDelete"); +// operation.setName("批量删除"); +// return operation; +// } +// +// private static SummaryInfo batchDeleteAndSave(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&BatchDeleteAndSave", vmMetadata.getHeader().getId())); +// operation.setCode("BatchDeleteAndSave"); +// operation.setName("批量删除并保存"); +// return operation; +// } +// +// private static SummaryInfo delete(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&Delete", vmMetadata.getHeader().getId())); +// operation.setCode("Delete"); +// operation.setName("删除"); +// return operation; +// } +// +// private static SummaryInfo edit(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&Edit", vmMetadata.getHeader().getId())); +// operation.setCode("Edit"); +// operation.setName("编辑"); +// return operation; +// } +// +// private static SummaryInfo create(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&Create", vmMetadata.getHeader().getId())); +// operation.setCode("Create"); +// operation.setName("新增"); +// return operation; +// } +// +// private static SummaryInfo batCreate(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&BatchCreate", vmMetadata.getHeader().getId())); +// operation.setCode("BatchCreate"); +// operation.setName("批量新增主表数据"); +// return operation; +// } +// +// private static SummaryInfo closeSession(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&CloseSession", vmMetadata.getHeader().getId())); +// operation.setCode("CloseSession"); +// operation.setName("关闭Session"); +// return operation; +// } +// +// private static SummaryInfo createSession(GspMetadata vmMetadata) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(MessageFormat.format("{0}&^^&CreateSession", vmMetadata.getHeader().getId())); +// operation.setCode("CreateSession"); +// operation.setName("创建Session"); +// return operation; +// } } diff --git a/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/SimpleBasicActionProvider.java b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/SimpleBasicActionProvider.java index b5112b45ed16bf1a841b503ceccb773cf4da5e82..c3733ded960d7f472b80272e80da82093f133cf8 100644 --- a/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/SimpleBasicActionProvider.java +++ b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/SimpleBasicActionProvider.java @@ -63,8 +63,9 @@ public class SimpleBasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&Query", vmMetadata.getHeader().getId())); operation.setCode("Query"); - operation.setName("过滤查询"); - operation.setDescription("过滤查询"); + operation.setName("查询" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("查询{0},可指定查询过滤条件、排序字段、设置分页。", + viewModel.getMainObject().getName())); operation.setResourceOpId(MessageFormat.format("{0}&^^&Query", vmMetadata.getHeader().getId())); operation.setHttpMethod("GET"); operation.setTemplate(""); @@ -119,8 +120,8 @@ public class SimpleBasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&Retrieve", vmMetadata.getHeader().getId())); operation.setCode("Retrieve"); - operation.setName("数据检索"); - operation.setDescription("数据检索"); + operation.setName("检索" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("检索指定的{0},返回结果中包含{0}的所有子表数据。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Retrieve", vmMetadata.getHeader().getId())); operation.setHttpMethod("GET"); @@ -176,8 +177,8 @@ public class SimpleBasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&Update", vmMetadata.getHeader().getId())); operation.setCode("Update"); - operation.setName("更新"); - operation.setDescription("更新"); + operation.setName("更新" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("修改指定的{0},传入值必须包含完整的{0}数据。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Update", vmMetadata.getHeader().getId())); operation.setHttpMethod("PUT"); @@ -237,8 +238,8 @@ public class SimpleBasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&BatchDelete", vmMetadata.getHeader().getId())); operation.setCode("BatchDelete"); - operation.setName("批量删除"); - operation.setDescription("批量删除"); + operation.setName("批量删除" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("批量删除指定的{0}。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&BatchDelete", vmMetadata.getHeader().getId())); operation.setHttpMethod("DELETE"); @@ -274,8 +275,8 @@ public class SimpleBasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&Delete", vmMetadata.getHeader().getId())); operation.setCode("Delete"); - operation.setName("删除"); - operation.setDescription("删除"); + operation.setName("删除" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("删除指定的{0}。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Delete", vmMetadata.getHeader().getId())); operation.setHttpMethod("DELETE"); @@ -310,8 +311,8 @@ public class SimpleBasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&Create", vmMetadata.getHeader().getId())); operation.setCode("Create"); - operation.setName("新增"); - operation.setDescription("新增"); + operation.setName("新增" + viewModel.getMainObject().getName()); + operation.setDescription(MessageFormat.format("新增{0},可指定字段初始值。", viewModel.getMainObject().getName())); operation.setResourceOpId( MessageFormat.format("{0}&^^&Create", vmMetadata.getHeader().getId())); operation.setHttpMethod("POST"); @@ -371,8 +372,8 @@ public class SimpleBasicActionProvider { operation.setId(MessageFormat.format("{0}&^^&CreateDefaultValue", vmMetadata.getHeader().getId())); operation.setCode("CreateDefaultValue"); - operation.setName("新增"); - operation.setDescription("新增(返回默认数据)"); + operation.setName("新增" + viewModel.getMainObject().getName()); + operation.setDescription("新增" + viewModel.getMainObject().getName()); operation.setResourceOpId( MessageFormat.format("{0}&^^&CreateDefaultValue", vmMetadata.getHeader().getId())); operation.setHttpMethod("PUT"); diff --git a/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/SimpleBasicActionSummary.java b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/SimpleBasicActionSummary.java index 44e3a99251f4e2178871cb4ba9239363fda3d774..9e99032e135cff89eddf875e5a9d891d1891c714 100644 --- a/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/SimpleBasicActionSummary.java +++ b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/SimpleBasicActionSummary.java @@ -18,6 +18,7 @@ package com.inspur.edp.sgf.provider.vo.basic; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; import com.inspur.edp.sgf.api.common.SummaryInfo; +import com.inspur.edp.sgf.api.entity.ServiceOperation; import java.util.ArrayList; import java.util.List; @@ -33,83 +34,92 @@ import java.util.List; public class SimpleBasicActionSummary { public static List getSimpleBasicActions(GspMetadata gspMetadata) { - List operations = new ArrayList<>(); - String voId = gspMetadata.getHeader().getId(); - //增加 - operations.add(create(voId)); - //删除 - operations.add(delete(voId)); - //批量删除 - operations.add(batchDelete(voId)); - //保存 - operations.add(update(voId)); - //查询 - operations.add(retrieve(voId)); - //过滤查询 - operations.add(query(voId)); - //新增默认值 - operations.add(createDefaultValue(voId)); - return operations; + List summaryInfos = new ArrayList<>(); + List operations = SimpleBasicActionProvider.getSimpleBasicActions(gspMetadata); + for (ServiceOperation op : operations) { + SummaryInfo summaryInfo = new SummaryInfo(); + summaryInfo.setId(op.getId()); + summaryInfo.setCode(op.getCode()); + summaryInfo.setName(op.getName()); + summaryInfos.add(summaryInfo); + } + return summaryInfos; +// String voId = gspMetadata.getHeader().getId(); +// //增加 +// operations.add(create(voId)); +// //删除 +// operations.add(delete(voId)); +// //批量删除 +// operations.add(batchDelete(voId)); +// //保存 +// operations.add(update(voId)); +// //查询 +// operations.add(retrieve(voId)); +// //过滤查询 +// operations.add(query(voId)); +// //新增默认值 +// operations.add(createDefaultValue(voId)); +// return operations; } - private static SummaryInfo query(String voId) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(getOperationId(voId, "Query")); - operation.setCode("Query"); - operation.setName("过滤查询"); - return operation; - } - - private static SummaryInfo retrieve(String voId) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(getOperationId(voId, "Retrieve")); - operation.setCode("Retrieve"); - operation.setName("数据检索"); - return operation; - } - - private static SummaryInfo update(String voId) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(getOperationId(voId, "Update")); - operation.setCode("Update"); - operation.setName("更新"); - return operation; - } - - private static SummaryInfo batchDelete(String voId) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(getOperationId(voId, "BatchDelete")); - operation.setCode("BatchDelete"); - operation.setName("批量删除"); - return operation; - } - - private static SummaryInfo delete(String voId) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(getOperationId(voId, "Delete")); - operation.setCode("Delete"); - operation.setName("删除"); - return operation; - } - - private static SummaryInfo create(String voId) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(getOperationId(voId, "Create")); - operation.setCode("Create"); - operation.setName("新增"); - return operation; - } - - private static SummaryInfo createDefaultValue(String voId) { - SummaryInfo operation = new SummaryInfo(); - operation.setId(getOperationId(voId, "CreateDefaultValue")); - operation.setCode("CreateDefaultValue"); - operation.setName("新增"); - return operation; - } - - private static String getOperationId(String voId, String code) { - return String.format("%s&^^&%s", voId, code); - } +// private static SummaryInfo query(String voId) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(getOperationId(voId, "Query")); +// operation.setCode("Query"); +// operation.setName("过滤查询"); +// return operation; +// } +// +// private static SummaryInfo retrieve(String voId) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(getOperationId(voId, "Retrieve")); +// operation.setCode("Retrieve"); +// operation.setName("数据检索"); +// return operation; +// } +// +// private static SummaryInfo update(String voId) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(getOperationId(voId, "Update")); +// operation.setCode("Update"); +// operation.setName("更新"); +// return operation; +// } +// +// private static SummaryInfo batchDelete(String voId) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(getOperationId(voId, "BatchDelete")); +// operation.setCode("BatchDelete"); +// operation.setName("批量删除"); +// return operation; +// } +// +// private static SummaryInfo delete(String voId) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(getOperationId(voId, "Delete")); +// operation.setCode("Delete"); +// operation.setName("删除"); +// return operation; +// } +// +// private static SummaryInfo create(String voId) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(getOperationId(voId, "Create")); +// operation.setCode("Create"); +// operation.setName("新增"); +// return operation; +// } +// +// private static SummaryInfo createDefaultValue(String voId) { +// SummaryInfo operation = new SummaryInfo(); +// operation.setId(getOperationId(voId, "CreateDefaultValue")); +// operation.setCode("CreateDefaultValue"); +// operation.setName("新增"); +// return operation; +// } +// +// private static String getOperationId(String voId, String code) { +// return String.format("%s&^^&%s", voId, code); +// } } diff --git a/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/common/EapiBuilder.java b/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/common/EapiBuilder.java index 8ff052ec7f458f821c87f430b47cf4d9a895f141..f7fbe581408c7fda1e253cf07d293d76a54456e2 100644 --- a/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/common/EapiBuilder.java +++ b/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/common/EapiBuilder.java @@ -31,9 +31,11 @@ import com.inspur.edp.sgf.api.entity.ServiceParameter; import com.inspur.edp.sgf.api.entity.SgMetadata; import com.inspur.edp.sgf.api.entity.SgModel; import com.inspur.edp.sgf.api.utils.ObjectMapperUtil; +import com.inspur.edp.sgf.dt.provider.exception.EApiDtVOExceptionCode; import com.inspur.edp.sgf.dt.provider.utils.MetadataUtils; import com.inspur.edp.sgf.provider.vo.utils.SimpleViewModelUtils; import com.inspur.edp.sgf.provider.vo.utils.ViewModelUtils; +import com.inspur.edp.sgf.utils.exception.EApiDesignException; import io.iec.edp.caf.businessobject.api.entity.DevBasicBoInfo; import io.iec.edp.caf.commons.utils.SpringBeanUtils; import org.apache.commons.lang3.StringUtils; @@ -170,7 +172,7 @@ public class EapiBuilder { //eapiContent.setRouteUrl(String.format("%s_%s", boCode.toLowerCase(), vo.getHeader().getCode().toLowerCase())); // 版本信息,默认1.0 eapiContent.setVersion("1.0"); - eapiContent.setDescription(vo.getHeader().getCode() + "服务"); + eapiContent.setDescription(eapiMetadata.getHeader().getName() + "服务"); // 生成服务定义 eapiContent.setService(this.buildServiceDefine(vo)); // 获取服务模型列表 @@ -231,6 +233,7 @@ public class EapiBuilder { serviceDefine.setResourceType(getResourceType(resourceType)); serviceDefine.setResourceCode(((GspViewModel) vo.getContent()).getGeneratedConfigID()); serviceDefine.setResourceName(vo.getHeader().getName()); + serviceDefine.setResourceNameSpace(vo.getHeader().getNameSpace()); serviceDefine.setOperations(new ArrayList<>()); switch (resourceType) { case VO_ADVANCE: @@ -240,7 +243,7 @@ public class EapiBuilder { serviceDefine.getOperations().addAll(SimpleViewModelUtils.getAllOperations(vo)); break; default: - throw new RuntimeException("不支持的资源类型:" + resourceType); + throw new EApiDesignException(EApiDtVOExceptionCode.GSP_EAPI_PROVIDER_0001, "不支持的资源类型:" + resourceType); } return serviceDefine; } @@ -253,7 +256,8 @@ public class EapiBuilder { header.setName(vo.getHeader().getName()); header.setExtendable(vo.getHeader().isExtendable()); if (StringUtils.isBlank(vo.getHeader().getBizobjectID())) { - throw new RuntimeException(String.format("VO元数据【%s(ID:%s)】的业务对象不能为空", vo.getHeader().getCode(), vo.getHeader().getId())); + throw new EApiDesignException(EApiDtVOExceptionCode.GSP_EAPI_PROVIDER_0002, + String.format("VO元数据【%s(ID:%s)】的业务对象不能为空", vo.getHeader().getCode(), vo.getHeader().getId())); } header.setBizobjectID(vo.getHeader().getBizobjectID()); header.setType(EAPI_TYPE_NAME); @@ -269,7 +273,8 @@ public class EapiBuilder { metadata.getHeader().setName(vo.getHeader().getName()); metadata.getHeader().setExtendable(vo.getHeader().isExtendable()); if (StringUtils.isBlank(vo.getHeader().getBizobjectID())) { - throw new RuntimeException(String.format("VO元数据【%s(ID:%s)】的业务对象不能为空", vo.getHeader().getCode(), vo.getHeader().getId())); + throw new EApiDesignException(EApiDtVOExceptionCode.GSP_EAPI_PROVIDER_0003, + String.format("VO元数据【%s(ID:%s)】的业务对象不能为空", vo.getHeader().getCode(), vo.getHeader().getId())); } metadata.getHeader().setBizobjectID(vo.getHeader().getBizobjectID()); metadata.getHeader().setType(EAPI_TYPE_NAME); @@ -291,7 +296,8 @@ public class EapiBuilder { case VO_SIMPLE: return EAPI_RESOURCE_TYPE_VO_SIMPLE; default: - throw new RuntimeException("不支持的资源类型:" + resourceType); + throw new EApiDesignException(EApiDtVOExceptionCode.GSP_EAPI_PROVIDER_0001, + "不支持的资源类型:" + resourceType); } } diff --git a/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/exception/EApiDtVOExceptionCode.java b/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/exception/EApiDtVOExceptionCode.java new file mode 100644 index 0000000000000000000000000000000000000000..9f89420e96824bde39601fbdc01faf987908801e --- /dev/null +++ b/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/exception/EApiDtVOExceptionCode.java @@ -0,0 +1,58 @@ +/* + * 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.sgf.dt.provider.exception; + +/** + * @author Kaixuan Shi + * @since 2023/3/20 + */ +public class EApiDtVOExceptionCode { + + /** + * 不支持的资源类型 + */ + public static final String GSP_EAPI_PROVIDER_0001 = "GSP_EAPI_PROVIDER_0001"; + /** + * VO元数据【%s(ID:%s)】的业务对象不能为空 + */ + public static final String GSP_EAPI_PROVIDER_0002 = "GSP_EAPI_PROVIDER_0002"; + /** + * VO元数据【%s(ID:%s)】的业务对象不能为空 + */ + public static final String GSP_EAPI_PROVIDER_0003 = "GSP_EAPI_PROVIDER_0003"; + + /** + * 外部服务获取解析的资源ID为空 + */ + public static final String GSP_EAPI_PROVIDER_0101 = "GSP_EAPI_PROVIDER_0101"; + /** + * 获取MetadataProjectService Bean为空 + */ + public static final String GSP_EAPI_PROVIDER_0102 = "GSP_EAPI_PROVIDER_0102"; + /** + * 根据相对路径【%s】获取元数据工程信息为空! + */ + public static final String GSP_EAPI_PROVIDER_0103 = "GSP_EAPI_PROVIDER_0103"; + /** + * 根据业务对象ID[%s]获取的DevBasicBoInfo为的AppCode为空 + */ + public static final String GSP_EAPI_PROVIDER_0104 = "GSP_EAPI_PROVIDER_0104"; + /** + * 根据业务对象ID[%s]获取的DevBasicBoInfo为的SuCode为空 + */ + public static final String GSP_EAPI_PROVIDER_0105 = "GSP_EAPI_PROVIDER_0105"; +} diff --git a/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/service/SimpleViewModelProvider.java b/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/service/SimpleViewModelProvider.java index 2c677bd79f2f992ce56f3484beddb7b94629d2f5..a0433c8d392f62ab1be4a5900734cf6f83789461 100644 --- a/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/service/SimpleViewModelProvider.java +++ b/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/service/SimpleViewModelProvider.java @@ -17,6 +17,7 @@ package com.inspur.edp.sgf.dt.provider.service; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.lcm.metadata.api.entity.uri.MetadataURI; import com.inspur.edp.sgf.api.common.ResourceType; import com.inspur.edp.sgf.api.common.SummaryInfo; import com.inspur.edp.sgf.api.entity.ServiceOperation; @@ -25,7 +26,6 @@ import com.inspur.edp.sgf.dt.provider.utils.MetadataUtils; import com.inspur.edp.sgf.dt.spi.EapiProvider; import com.inspur.edp.sgf.dt.spi.ResourceProvider; import com.inspur.edp.sgf.provider.vo.utils.SimpleViewModelUtils; -import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.List; @@ -34,47 +34,33 @@ import java.util.stream.Collectors; /** * 功能描述: 经典型视图对象元数据设计时定义适配器 * - * @ClassName:SimpleViewModelProvider - * @Author: Fynn Qi - * @Date: 2020/8/31 15:29 - * @Version: V1.0 + * @author Fynn Qi + * @author Kaixuan Shi + * @version 1.1 + * @since 2020/8/31 15:29 */ @EapiProvider(resourceType = "VO-Simple") public class SimpleViewModelProvider implements ResourceProvider { @Override - public List getSummaryOperations(String resourceId) { - if (StringUtils.isBlank(resourceId)) { - throw new RuntimeException("外部服务获取服务操作概要信息的资源ID为空"); - } - List summaryInfos = new ArrayList<>(); - GspMetadata metadata = MetadataUtils.getDtVoMetadata(resourceId); - summaryInfos.addAll(SimpleViewModelUtils.getAllSummaryOperations(metadata)); - return summaryInfos; + public List getSummaryOperations(MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath) { + GspMetadata metadata = MetadataUtils.getDtVoMetadata(targetMdURI, sourceMdURI, projectPath); + return new ArrayList<>(SimpleViewModelUtils.getAllSummaryOperations(metadata)); } @Override - public List getOperations(String resourceId) { - if (StringUtils.isBlank(resourceId)) { - throw new RuntimeException("外部服务获取服务操作的资源ID为空"); - } - List operations = new ArrayList<>(); - GspMetadata metadata = MetadataUtils.getDtVoMetadata(resourceId); - operations.addAll(SimpleViewModelUtils.getAllOperations(metadata)); - return operations; + public List getOperations(MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath) { + GspMetadata metadata = MetadataUtils.getDtVoMetadata(targetMdURI, sourceMdURI, projectPath); + return new ArrayList<>(SimpleViewModelUtils.getAllOperations(metadata)); } @Override - public List getOperations(String resourceId, List operationIds) { - if (StringUtils.isBlank(resourceId)) { - throw new RuntimeException("外部服务获取服务操作的资源ID为空"); - } - GspMetadata metadata = MetadataUtils.getDtVoMetadata(resourceId); - List operations = new ArrayList<>(); - operations.addAll(SimpleViewModelUtils.getAllOperations(metadata)); - if (operationIds == null || operationIds.size() <= 0) { - return null; + public List getOperations(MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath, List operationIds) { + if (operationIds == null || operationIds.isEmpty()) { + return new ArrayList<>(); } + GspMetadata metadata = MetadataUtils.getDtVoMetadata(targetMdURI, sourceMdURI, projectPath); + List operations = SimpleViewModelUtils.getAllOperations(metadata); // 返回过滤的服务操作 return operations.stream().filter(x -> operationIds.stream().anyMatch(id -> id.equals(x.getId()))).collect(Collectors.toList()); } diff --git a/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/service/ViewModelProvider.java b/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/service/ViewModelProvider.java index 05997bead565c5b66d965e8e0a689873dcbc8afe..5416f4e1cc0679f42b31a600ef2914d3946153d6 100644 --- a/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/service/ViewModelProvider.java +++ b/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/service/ViewModelProvider.java @@ -17,6 +17,7 @@ package com.inspur.edp.sgf.dt.provider.service; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.lcm.metadata.api.entity.uri.MetadataURI; import com.inspur.edp.sgf.api.common.ResourceType; import com.inspur.edp.sgf.api.common.SummaryInfo; import com.inspur.edp.sgf.api.entity.ServiceOperation; @@ -26,39 +27,40 @@ import com.inspur.edp.sgf.dt.spi.EapiProvider; import com.inspur.edp.sgf.dt.spi.ResourceProvider; import com.inspur.edp.sgf.provider.vo.utils.ViewModelUtils; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * 功能描述: 高级型视图对象元数据设计时定义适配器 * - * @ClassName: ViewModelProvider - * @Author: Fynn Qi - * @Date:2020/2/3 10:21 - * @Version: V1.0 + * @author Fynn Qi + * @author Kaixuan Shi + * @version V1.1 + * @since 2020/2/3 10:21 */ @EapiProvider(resourceType = "VO") public class ViewModelProvider implements ResourceProvider { @Override - public List getSummaryOperations(String resourceId) { - GspMetadata metadata = MetadataUtils.getDtVoMetadata(resourceId); + public List getSummaryOperations(MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath) { + GspMetadata metadata = MetadataUtils.getDtVoMetadata(targetMdURI, sourceMdURI, projectPath); return ViewModelUtils.getAllSummaryOperations(metadata); } @Override - public List getOperations(String resourceId) { - GspMetadata metadata = MetadataUtils.getDtVoMetadata(resourceId); + public List getOperations(MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath) { + GspMetadata metadata = MetadataUtils.getDtVoMetadata(targetMdURI, sourceMdURI, projectPath); return ViewModelUtils.getAllOperations(metadata); } @Override - public List getOperations(String resourceId, List operationIds) { - GspMetadata metadata = MetadataUtils.getDtVoMetadata(resourceId); - List operations = ViewModelUtils.getAllOperations(metadata); - if (operationIds == null || operationIds.size() <= 0) { - return null; + public List getOperations(MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath, List operationIds) { + if (operationIds == null || operationIds.isEmpty()) { + return new ArrayList<>(); } + GspMetadata metadata = MetadataUtils.getDtVoMetadata(targetMdURI, sourceMdURI, projectPath); + List operations = ViewModelUtils.getAllOperations(metadata); // 返回过滤的服务操作 return operations.stream().filter(x -> operationIds.stream().anyMatch(id -> id.equals(x.getId()))).collect(Collectors.toList()); } diff --git a/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/utils/MetadataUtils.java b/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/utils/MetadataUtils.java index 7855e258d66b0d454c8b45c6ee322f84bba0bc93..472923162d1ac79a073af66e726a0f357de1b3b6 100644 --- a/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/utils/MetadataUtils.java +++ b/rest-api-provider-dev/src/main/java/com/inspur/edp/sgf/dt/provider/utils/MetadataUtils.java @@ -17,88 +17,95 @@ package com.inspur.edp.sgf.dt.provider.utils; 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.MetadataProject; -import com.inspur.edp.lcm.metadata.api.service.GspProjectService; +import com.inspur.edp.lcm.metadata.api.entity.uri.MetadataURI; import com.inspur.edp.lcm.metadata.api.service.MetadataProjectService; import com.inspur.edp.lcm.metadata.api.service.MetadataService; import com.inspur.edp.lcm.metadata.api.service.RefCommonService; +import com.inspur.edp.sgf.dt.provider.exception.EApiDtVOExceptionCode; +import com.inspur.edp.sgf.utils.exception.EApiDesignException; import io.iec.edp.caf.businessobject.api.entity.DevBasicBoInfo; import io.iec.edp.caf.businessobject.api.service.DevBasicInfoService; import io.iec.edp.caf.commons.utils.SpringBeanUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.util.Assert; -import java.io.IOException; - -/** 功能描述: @ClassName: MetadataUtils @Author: Fynn Qi @Date: 2020/9/1 14:15 @Version: V1.0 */ +/** + * @author Fynn Qi + * @author Kaixuan Shi + * @version v1.1 + * @since 2020/9/1 14:15 + */ public class MetadataUtils { - public static GspMetadata getDtVoMetadata(String resourceId) { - if (StringUtils.isBlank(resourceId)) { - throw new RuntimeException("外部服务获取解析的资源ID为空"); - } - if(resourceId.contains("##")){ - String[] temps=resourceId.split("##"); - MetadataService service = SpringBeanUtils.getBean(MetadataService.class); - return service.getRefMetadata(temps[1],temps[0]); + public static GspMetadata getDtVoMetadata(MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath) { + if (targetMdURI == null || StringUtils.isBlank(targetMdURI.getId())) { + throw new EApiDesignException(EApiDtVOExceptionCode.GSP_EAPI_PROVIDER_0101, "外部服务获取解析的资源ID为空"); + } + if (targetMdURI.getId().contains("##")) { + String[] temps = targetMdURI.getId().split("##"); + MetadataService service = SpringBeanUtils.getBean(MetadataService.class); + return service.getRefMetadata(temps[1], temps[0]); + } else { + RefCommonService service = SpringBeanUtils.getBean(RefCommonService.class); + return service.getRefMetadata(targetMdURI, sourceMdURI, projectPath); + } } - else{ - RefCommonService service = SpringBeanUtils.getBean(RefCommonService.class); - return service.getRefMetadata(resourceId); - } - } - public static MetadataProject getMetadataProject(String path) { - MetadataProjectService service = SpringBeanUtils.getBean(MetadataProjectService.class); - if (service == null) { - throw new RuntimeException("获取MetadataProjectService Bean为空"); - } - MetadataProject projectInfo = service.getMetadataProjInfo(path); - if (projectInfo == null) { - throw new RuntimeException(String.format("根据相对路径【%s】获取元数据工程信息为空!", path)); + public static MetadataProject getMetadataProject(String path) { + MetadataProjectService service = SpringBeanUtils.getBean(MetadataProjectService.class); + if (service == null) { + throw new EApiDesignException(EApiDtVOExceptionCode.GSP_EAPI_PROVIDER_0102, + "获取MetadataProjectService Bean为空"); + } + MetadataProject projectInfo = service.getMetadataProjInfo(path); + if (projectInfo == null) { + throw new EApiDesignException(EApiDtVOExceptionCode.GSP_EAPI_PROVIDER_0103, + String.format("根据相对路径【%s】获取元数据工程信息为空!", path)); + } + return projectInfo; } - return projectInfo; - } - public static GspProject getProjectInfo(GspMetadata metadata) { - if (StringUtils.isBlank(metadata.getRelativePath())) { - throw new RuntimeException( - String.format( - "元数据【%s(ID:%s)】的相对路径为空,无法获取工程信息!", - metadata.getHeader().getCode(), metadata.getHeader().getId())); - } - GspProjectService service = SpringBeanUtils.getBean(GspProjectService.class); - if (service == null) { - throw new RuntimeException("获取MetadataProjectService Bean为空"); - } - GspProject projectInfo = null; - try { - projectInfo = service.getGspProjectInfo(metadata.getRelativePath()); - } catch (IOException e) { - throw new RuntimeException(e); - } - if (projectInfo == null) { - throw new RuntimeException( - String.format( - "元数据【%s(ID:%s)】根据相对路径【%s】获取工程信息为空!", - metadata.getHeader().getCode(), - metadata.getHeader().getId(), - metadata.getRelativePath())); - } - return projectInfo; - } +// public static GspProject getProjectInfo(GspMetadata metadata) { +// if (StringUtils.isBlank(metadata.getRelativePath())) { +// throw new EApiDesignException(EApiDtVOExceptionCode, +// String.format( +// "元数据【%s(ID:%s)】的相对路径为空,无法获取工程信息!", +// metadata.getHeader().getCode(), metadata.getHeader().getId())); +// } +// GspProjectService service = SpringBeanUtils.getBean(GspProjectService.class); +// if (service == null) { +// throw new EApiDesignException(EApiDtVOExceptionCode,"获取MetadataProjectService Bean为空"); +// } +// GspProject projectInfo = null; +// try { +// projectInfo = service.getGspProjectInfo(metadata.getRelativePath()); +// } catch (IOException e) { +// throw new EApiDesignException(EApiDtVOExceptionCode,e); +// } +// if (projectInfo == null) { +// throw new EApiDesignException(EApiDtVOExceptionCode, +// String.format( +// "元数据【%s(ID:%s)】根据相对路径【%s】获取工程信息为空!", +// metadata.getHeader().getCode(), +// metadata.getHeader().getId(), +// metadata.getRelativePath())); +// } +// return projectInfo; +// } - public static DevBasicBoInfo getDevBasicBoInfo(String bizId) { - DevBasicInfoService devBasicInfoService = SpringBeanUtils.getBean(DevBasicInfoService.class); - DevBasicBoInfo devBasicBoInfo = devBasicInfoService.getDevBasicBoInfo(bizId); - Assert.notNull(devBasicBoInfo, String.format("根据业务对象ID[%s]获取的DevBasicBoInfo为空", bizId)); - if (StringUtils.isBlank(devBasicBoInfo.getAppCode())) { - throw new RuntimeException(String.format("根据业务对象ID[%s]获取的DevBasicBoInfo为的AppCode为空", bizId)); - } - if (StringUtils.isBlank(devBasicBoInfo.getSuCode())) { - throw new RuntimeException(String.format("根据业务对象ID[%s]获取的DevBasicBoInfo为的SuCode为空", bizId)); + public static DevBasicBoInfo getDevBasicBoInfo(String bizId) { + DevBasicInfoService devBasicInfoService = SpringBeanUtils.getBean(DevBasicInfoService.class); + DevBasicBoInfo devBasicBoInfo = devBasicInfoService.getDevBasicBoInfo(bizId); + Assert.notNull(devBasicBoInfo, String.format("根据业务对象ID[%s]获取的DevBasicBoInfo为空", bizId)); + if (StringUtils.isBlank(devBasicBoInfo.getAppCode())) { + throw new EApiDesignException(EApiDtVOExceptionCode.GSP_EAPI_PROVIDER_0104, + String.format("根据业务对象ID[%s]获取的DevBasicBoInfo为的AppCode为空", bizId)); + } + if (StringUtils.isBlank(devBasicBoInfo.getSuCode())) { + throw new EApiDesignException(EApiDtVOExceptionCode.GSP_EAPI_PROVIDER_0105, + String.format("根据业务对象ID[%s]获取的DevBasicBoInfo为的SuCode为空", bizId)); + } + return devBasicBoInfo; } - return devBasicBoInfo; - } } diff --git a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/common/EApiDefinitionVO.java b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/common/EApiDefinitionVO.java index 248c343e1ce3545b9f3854888c5cf123159cbe50..5d65d6466231aca403eb7202ec84743096079766 100644 --- a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/common/EApiDefinitionVO.java +++ b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/common/EApiDefinitionVO.java @@ -32,6 +32,7 @@ public class EApiDefinitionVO { private String bizObjectName; private String bizObjectCode; private String serviceUsage; + private String accessScope; private String serviceCode; private String serviceName; private String basePath; @@ -89,6 +90,14 @@ public class EApiDefinitionVO { this.serviceUsage = serviceUsage; } + public String getAccessScope() { + return accessScope; + } + + public void setAccessScope(String accessScope) { + this.accessScope = accessScope; + } + public String getServiceCode() { return serviceCode; } diff --git a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/exception/ExceptionCode.java b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/exception/ExceptionCode.java new file mode 100644 index 0000000000000000000000000000000000000000..a4afa85ec8efe250eebb3c4609a9601b0ac82808 --- /dev/null +++ b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/exception/ExceptionCode.java @@ -0,0 +1,85 @@ +/* + * 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.sgf.dt.core.exception; + +/** + * @author Kaixuan Shi + * @since 2023/3/20 + */ +public class ExceptionCode { + + /** + * 根据业务对象ID获取业务对象信息失败,请检查业务对象ID是否被修改、与当前是否一致 + */ + public static final String GSP_EAPI_DESIGN_0001 = "GSP_EAPI_DESIGN_0001"; + /** + * Eapi异常:根据业务对象ID获取业务对象编号失败,请检查业务对象ID是否被修改、与当前是否一致 + */ + public static final String GSP_EAPI_DESIGN_0002 = "GSP_EAPI_DESIGN_0002"; + + /** + * 获取{0}外部服务定义资源适配器失败 + */ + public static final String GSP_EAPI_DESIGN_0101 = "GSP_EAPI_DESIGN_0101"; + + /** + * EAPI创建时参数校验不通过:依赖元数据的相对路径不能为空 + */ + public static final String GSP_EAPI_DESIGN_0201 = "GSP_EAPI_DESIGN_0201"; + /** + * 参数校验不通过:元数据不能为空 + */ + public static final String GSP_EAPI_DESIGN_0202 = "GSP_EAPI_DESIGN_0202"; + /** + * 参数校验不通过:元数据的Header字段不能为空 + */ + public static final String GSP_EAPI_DESIGN_0203 = "GSP_EAPI_DESIGN_0203"; + /** + * 参数校验不通过:元数据类型字段不能为空 + */ + public static final String GSP_EAPI_DESIGN_0204 = "GSP_EAPI_DESIGN_0204"; + /** + * 参数校验不通过:元数据ID字段不能为空 + */ + public static final String GSP_EAPI_DESIGN_0205 = "GSP_EAPI_DESIGN_0205"; + /** + * 不支持的资源类型 + */ + public static final String GSP_EAPI_DESIGN_0206 = "GSP_EAPI_DESIGN_0206"; + + /** + * 元数据ID不能为空 + */ + public static final String GSP_EAPI_DESIGN_0301 = "GSP_EAPI_DESIGN_0301"; + /** + * 元数据【%s(ID:%s)】的相对路径为空,无法获取工程信息! + */ + public static final String GSP_EAPI_DESIGN_0302 = "GSP_EAPI_DESIGN_0302"; + /** + * 获取MetadataProjectService Bean为空 + */ + public static final String GSP_EAPI_DESIGN_0303 = "GSP_EAPI_DESIGN_0303"; + /** + * 元数据【%s(ID:%s)】根据相对路径【%s】获取工程信息为空! + */ + public static final String GSP_EAPI_DESIGN_0304 = "GSP_EAPI_DESIGN_0304"; + /** + * 获取元数据工程信息失败 + */ + public static final String GSP_EAPI_DESIGN_0305 = "GSP_EAPI_DESIGN_0305"; + +} diff --git a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/initializer/EapiInitializer.java b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/initializer/EapiInitializer.java index 1e4db5bb57c48f1bde4beeb3146ec1d02deca7da..8a407e7140ef6a8fc2f05bedd074deb2f45f17bf 100644 --- a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/initializer/EapiInitializer.java +++ b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/initializer/EapiInitializer.java @@ -19,6 +19,8 @@ package com.inspur.edp.sgf.dt.core.initializer; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; import com.inspur.edp.lcm.metadata.spi.MetadataContentManager; import com.inspur.edp.sgf.api.entity.SgMetadata; +import com.inspur.edp.sgf.dt.core.exception.ExceptionCode; +import com.inspur.edp.sgf.utils.exception.EApiDesignException; import io.iec.edp.caf.businessobject.api.entity.DevBasicBoInfo; import io.iec.edp.caf.businessobject.api.service.DevBasicInfoService; import io.iec.edp.caf.commons.utils.SpringBeanUtils; @@ -51,10 +53,12 @@ public class EapiInitializer implements MetadataContentManager { eapi.setCriticalApplication(devBasicBoInfo.getAppCode()); eapi.setServiceUnit(devBasicBoInfo.getSuCode()); } else { - throw new RuntimeException("Eapi异常:根据业务对象ID:" + metadata.getHeader().getBizobjectID() + "获取业务对象信息失败,请检查业务对象ID是否被修改、与当前是否一致"); + throw new EApiDesignException(ExceptionCode.GSP_EAPI_DESIGN_0001, + "Eapi异常:根据业务对象ID:" + metadata.getHeader().getBizobjectID() + "获取业务对象信息失败,请检查业务对象ID是否被修改、与当前是否一致"); } if (devBasicBoInfo.getBoInfo() == null || StringUtils.isBlank(devBasicBoInfo.getBoInfo().getCode())) { - throw new RuntimeException("Eapi异常:根据业务对象ID:" + metadata.getHeader().getBizobjectID() + "获取业务对象编号失败,请检查业务对象ID是否被修改、与当前是否一致"); + throw new EApiDesignException(ExceptionCode.GSP_EAPI_DESIGN_0002, + "Eapi异常:根据业务对象ID:" + metadata.getHeader().getBizobjectID() + "获取业务对象编号失败,请检查业务对象ID是否被修改、与当前是否一致"); } //TODO 后续修改routerUrl eapi.setRouteUrl(eapi.getCode().toLowerCase()); diff --git a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/manager/EapiProviderManager.java b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/manager/EapiProviderManager.java index 2e7f4c4e0fd2db1509e6378c06ca1978e9c5d706..435d3c7ffa88cfb3a17afcb528a0cb1a6b7fa0df 100644 --- a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/manager/EapiProviderManager.java +++ b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/manager/EapiProviderManager.java @@ -17,17 +17,24 @@ package com.inspur.edp.sgf.dt.core.manager; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.lcm.metadata.api.entity.uri.MetadataURI; import com.inspur.edp.sgf.api.common.SummaryInfo; import com.inspur.edp.sgf.api.entity.ServiceOperation; import com.inspur.edp.sgf.dt.core.cache.ResourceProviderCache; +import com.inspur.edp.sgf.dt.core.exception.ExceptionCode; import com.inspur.edp.sgf.dt.spi.ResourceProvider; +import com.inspur.edp.sgf.utils.exception.EApiDesignException; +import javax.annotation.Nonnull; import java.text.MessageFormat; import java.util.List; import java.util.Objects; /** - * 功能描述: @ClassName: EapiProviderManager @Author: Fynn Qi @Date: 2020/12/23 11:45 @Version: V1.0 + * @author Fynn Qi + * @author Kaixuan Shi + * @version 1.1 + * @since 2020/12/23 11:45 */ public class EapiProviderManager { @@ -37,19 +44,19 @@ public class EapiProviderManager { instance = new EapiProviderManager(); } - public List getSummaryOperations(String resourceType, String resourceId) { + public List getSummaryOperations(@Nonnull String resourceType, MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath) { ResourceProvider provider = getResourceProvider(resourceType); - return provider.getSummaryOperations(resourceId); + return provider.getSummaryOperations(targetMdURI, sourceMdURI, projectPath); } - public List getOperations(String resourceType, String resourceId) { + public List getOperations(String resourceType, MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath) { ResourceProvider provider = getResourceProvider(resourceType); - return provider.getOperations(resourceId); + return provider.getOperations(targetMdURI, sourceMdURI, projectPath); } - public List getOperations(String resourceType, String resourceId, List operationIds) { + public List getOperations(String resourceType, MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath, List operationIds) { ResourceProvider provider = getResourceProvider(resourceType); - return provider.getOperations(resourceId, operationIds); + return provider.getOperations(targetMdURI, sourceMdURI, projectPath, operationIds); } public GspMetadata createEapi(GspMetadata metadata, String path, String resourceType) { @@ -70,13 +77,13 @@ public class EapiProviderManager { /** * 获取资源定义适配器 * - * @param resourceType - * @return + * @param resourceType 资源类型 */ private ResourceProvider getResourceProvider(String resourceType) { ResourceProvider provider = ResourceProviderCache.getInstance().getResourceProvider(resourceType); if (Objects.isNull(provider)) { - throw new RuntimeException(MessageFormat.format("获取{0}外部服务定义资源适配器失败。", resourceType)); + throw new EApiDesignException(ExceptionCode.GSP_EAPI_DESIGN_0101, + MessageFormat.format("获取{0}外部服务定义资源适配器失败。", resourceType)); } return provider; } diff --git a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/refer/EapiRefConstraint.java b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/refer/EapiRefConstraint.java index 5f1feb2556c5e07595e6b027be4e1954623b9a4f..2c28f7384adf4e5d5cfe321e5af8808926b2e00f 100644 --- a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/refer/EapiRefConstraint.java +++ b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/refer/EapiRefConstraint.java @@ -18,8 +18,14 @@ package com.inspur.edp.sgf.dt.core.refer; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; import com.inspur.edp.lcm.metadata.api.entity.MetadataReference; +import com.inspur.edp.lcm.metadata.api.entity.uri.MetadataURI; +import com.inspur.edp.lcm.metadata.api.service.RefCommonService; import com.inspur.edp.lcm.metadata.spi.IMetadataReferenceManager; +import com.inspur.edp.sgf.api.entity.SgMetadata; +import io.iec.edp.caf.commons.utils.SpringBeanUtils; +import org.apache.commons.lang3.StringUtils; +import java.util.ArrayList; import java.util.List; /** @@ -31,8 +37,55 @@ import java.util.List; * @Version: V1.0 */ public class EapiRefConstraint implements IMetadataReferenceManager { + + private static final String EAPI_RESOURCE_TYPE_VO = "VO"; + + private static final String EAPI_RESOURCE_TYPE_VO_SIMPLE = "VO-Simple"; + + private static final String VO_TYPE = "GSPViewModel"; + @Override - public List getConstraint(GspMetadata metadata) { - return metadata.getRefs(); + public List getConstraint(GspMetadata gspMetadata) { + if (gspMetadata == null || gspMetadata.getContent() == null) { + return null; + } + SgMetadata eapi = (SgMetadata) gspMetadata.getContent(); + if (eapi.getService() == null + || StringUtils.isBlank(eapi.getService().getResourceId())) { + return null; + } + List metadataRefs = new ArrayList<>(); + if (EAPI_RESOURCE_TYPE_VO.equals(eapi.getService().getResourceType()) + || EAPI_RESOURCE_TYPE_VO_SIMPLE.equals(eapi.getService().getResourceType())) { + MetadataReference reference = new MetadataReference(); + reference.setMetadata(gspMetadata.getHeader()); + GspMetadata voMetadata = this.getResourceMetadata(gspMetadata); + reference.setDependentMetadata(voMetadata.getHeader()); + metadataRefs.add(reference); + } + return metadataRefs; } + + private GspMetadata getResourceMetadata(GspMetadata eapiMetadata) { + SgMetadata eapi = (SgMetadata) eapiMetadata.getContent(); + MetadataURI targetMdURI = new MetadataURI(); + targetMdURI.setId(eapi.getService().getResourceId()); + targetMdURI.setCode(eapi.getService().getResourceCode()); + targetMdURI.setNameSpace(eapi.getService().getResourceNameSpace()); + if (EAPI_RESOURCE_TYPE_VO.equals(eapi.getService().getResourceType()) + || EAPI_RESOURCE_TYPE_VO_SIMPLE.equals(eapi.getService().getResourceType())) { + targetMdURI.setType(VO_TYPE); + } + MetadataURI sourceMdURI = new MetadataURI(); + sourceMdURI.setId(eapiMetadata.getHeader().getId()); + sourceMdURI.setCode(eapiMetadata.getHeader().getCode()); + sourceMdURI.setType(eapiMetadata.getHeader().getType()); + sourceMdURI.setNameSpace(eapiMetadata.getHeader().getNameSpace()); + + GspMetadata resourceMeta = SpringBeanUtils.getBean(RefCommonService.class) + .getRefMetadata(targetMdURI, sourceMdURI, eapiMetadata.getRelativePath()); + return resourceMeta; + } + + } diff --git a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/rest/EapiDefinitionService.java b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/rest/EapiDefinitionService.java index 47f3eee4b26e2a9c7293e8a4af2fcb1524fe72d4..1269db1ba5572c58435f0e807bfe91d66ab1d566 100644 --- a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/rest/EapiDefinitionService.java +++ b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/rest/EapiDefinitionService.java @@ -17,24 +17,24 @@ package com.inspur.edp.sgf.dt.core.rest; import com.inspur.edp.sgf.api.entity.ServiceOperation; +import com.inspur.edp.sgf.dt.core.vo.ResourceInfoVo; import javax.ws.rs.Consumes; -import javax.ws.rs.GET; import javax.ws.rs.POST; +import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import java.util.List; /** * 功能描述: * - * @ClassName: EapiDefinitionService - * @Author: Fynn Qi - * @Date: 2020/12/23 10:55 - * @Version: V1.0 + * @author Fynn Qi + * @author Kaixuan Shi + * @version 1.1 + * @since 2020/12/23 10:55 */ @Path("/") @Consumes(MediaType.APPLICATION_JSON) @@ -44,17 +44,13 @@ public interface EapiDefinitionService { /** * 获取资源定义的服务操作集合 * - * @param resourceType 资源类型 - * @param resourceId 资源ID - * @param opIdListstr 指定的操作id集合,是一个数组的拼接,例如id1,id2,以逗号隔开 + * @param resourceInfo 资源信息 * @return 返回值 */ - @GET + @PUT @Path("/resources/operations") List getOperations( - @QueryParam("resourceType") String resourceType, - @QueryParam("resourceId") String resourceId, - @QueryParam("opIdListstr") String opIdListstr); + ResourceInfoVo resourceInfo); @Path("/service/publish/{metadataId}") @POST diff --git a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/rest/EapiDefinitionServiceImpl.java b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/rest/EapiDefinitionServiceImpl.java index b02d6614f4e06048b59626fa3a5e37c5cc41046c..8db851fae4fad3e8d20d64706b000da59f09980e 100644 --- a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/rest/EapiDefinitionServiceImpl.java +++ b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/rest/EapiDefinitionServiceImpl.java @@ -18,24 +18,36 @@ package com.inspur.edp.sgf.dt.core.rest; import com.inspur.edp.sgf.api.entity.ServiceOperation; import com.inspur.edp.sgf.dt.core.service.EapiMetadataDtServiceImpl; +import com.inspur.edp.sgf.dt.core.vo.ResourceInfoVo; import org.apache.commons.lang3.StringUtils; +import org.springframework.util.CollectionUtils; -import java.util.Arrays; import java.util.List; /** - * 功能描述: @ClassName: EapiDefinitionServiceImpl @Author: Fynn Qi @Date: 2020/12/23 10:56 @Version: - * V1.0 + * @author Fynn Qi + * @author shikaixuan + * @version 1.1 + * @since 2020/12/23 10:56 */ public class EapiDefinitionServiceImpl implements EapiDefinitionService { @Override - public List getOperations(String resourceType, String resourceId, String opIdListstr) { - if (StringUtils.isBlank(opIdListstr)) { - return EapiMetadataDtServiceImpl.instance.getSummaryOperations(resourceType, resourceId); + public List getOperations(ResourceInfoVo resourceInfo) { + if (resourceInfo == null || StringUtils.isEmpty(resourceInfo.getResourceType()) + || resourceInfo.getTargetMdUri() == null || resourceInfo.getSourceMdUri() == null) { + return null; + } + if (StringUtils.isEmpty(resourceInfo.getTargetMdUri().getId())) { + return null; + } + if (CollectionUtils.isEmpty(resourceInfo.getOpIds())) { + return EapiMetadataDtServiceImpl.instance.getSummaryOperations(resourceInfo.getResourceType(), + resourceInfo.getTargetMdUri(), resourceInfo.getSourceMdUri(), resourceInfo.getProjectPath()); } else { - List ids = Arrays.asList(opIdListstr.split(",")); - return EapiMetadataDtServiceImpl.instance.getSelectOperations(resourceType, resourceId, ids); + return EapiMetadataDtServiceImpl.instance.getSelectOperations(resourceInfo.getResourceType(), + resourceInfo.getTargetMdUri(), resourceInfo.getSourceMdUri(), resourceInfo.getProjectPath(), + resourceInfo.getOpIds()); } } diff --git a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/service/EapiMetadataDtServiceImpl.java b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/service/EapiMetadataDtServiceImpl.java index c01407216676d407f2c7a35d0d66d4e8286829e8..931a579e2e3a587b061c4296be2d451cd0d421e2 100644 --- a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/service/EapiMetadataDtServiceImpl.java +++ b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/service/EapiMetadataDtServiceImpl.java @@ -18,6 +18,7 @@ package com.inspur.edp.sgf.dt.core.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.uri.MetadataURI; import com.inspur.edp.lcm.metadata.api.service.NoCodeService; import com.inspur.edp.sgf.api.common.ResourceType; import com.inspur.edp.sgf.api.common.SummaryInfo; @@ -27,8 +28,11 @@ import com.inspur.edp.sgf.api.service.EapiMetadataDtService; import com.inspur.edp.sgf.api.service.EapiRuntimeDeployment; import com.inspur.edp.sgf.api.utils.ObjectMapperUtil; import com.inspur.edp.sgf.dt.core.common.EApiDefinitionVO; +import com.inspur.edp.sgf.dt.core.exception.ExceptionCode; import com.inspur.edp.sgf.dt.core.manager.EapiProviderManager; import com.inspur.edp.sgf.dt.core.utils.MetadataProjectUtils; +import com.inspur.edp.sgf.utils.exception.EApiDesignException; +import io.iec.edp.caf.commons.exception.CAFRuntimeException; import io.iec.edp.caf.commons.utils.SpringBeanUtils; import io.iec.edp.caf.rpc.api.service.RpcClient; import org.apache.commons.lang3.StringUtils; @@ -41,16 +45,18 @@ import java.util.LinkedHashMap; import java.util.List; /** - * 功能描述: @ClassName: EapiMetadataDtServiceImpl @Author: Fynn Qi @Date: 2020/12/23 9:55 @Version: - * V1.0 + * @author Fynn Qi + * @author shikaixuan + * @version 1.1 + * @since 2020/12/23 9:55 */ public class EapiMetadataDtServiceImpl implements EapiMetadataDtService { - private Logger logger= LoggerFactory.getLogger(EapiMetadataDtServiceImpl.class); + private final static Logger logger = LoggerFactory.getLogger(EapiMetadataDtServiceImpl.class); - private final String EAPI_RESOURCE_TYPE_VO = "VO"; + private final static String EAPI_RESOURCE_TYPE_VO = "VO"; - private final String EAPI_RESOURCE_TYPE_VO_SIMPLE = "VO-Simple"; + private final static String EAPI_RESOURCE_TYPE_VO_SIMPLE = "VO-Simple"; public static EapiMetadataDtServiceImpl instance; @@ -67,15 +73,14 @@ public class EapiMetadataDtServiceImpl implements EapiMetadataDtService { public GspMetadata create(GspMetadata metadata, String path, ResourceType resourceType) { this.validateMetadata(metadata); if (StringUtils.isBlank(path)) { - throw new RuntimeException("EAPI创建时参数校验不通过:依赖元数据的相对路径不能为空"); + throw new EApiDesignException(ExceptionCode.GSP_EAPI_DESIGN_0201, "EAPI创建时参数校验不通过:依赖元数据的相对路径不能为空"); } String type = getResourceType(resourceType); GspMetadata eapiMetadata = EapiProviderManager.instance.createEapi(metadata, path, type); try { publishOasDoc(eapiMetadata); - } - catch (Exception e){ - logger.error("EAPI注册出错:"+e.getMessage(),e); + } catch (Exception e) { + logger.error("EAPI注册出错:" + e.getMessage(), e); } return eapiMetadata; } @@ -85,7 +90,6 @@ public class EapiMetadataDtServiceImpl implements EapiMetadataDtService { this.validateMetadata(metadata); String type = getResourceType(resourceType); GspMetadata eapiMetadata = EapiProviderManager.instance.createEapi(metadata, type); - //TODO 服务发布后续补充 return eapiMetadata; } @@ -94,7 +98,6 @@ public class EapiMetadataDtServiceImpl implements EapiMetadataDtService { this.validateMetadata(metadata); String type = getResourceType(resourceType); GspMetadata eapiMetadata = EapiProviderManager.instance.updateEapi(metadataId, metadata, type); - //TODO 服务发布后续补充 return eapiMetadata; } @@ -112,7 +115,11 @@ public class EapiMetadataDtServiceImpl implements EapiMetadataDtService { EApiDefinitionVO vo = getEapiDefinitionVo(eapiMetadata); LinkedHashMap map = new LinkedHashMap<>(); map.put("content", ObjectMapperUtil.serialize(vo)); - SpringBeanUtils.getBean(RpcClient.class).invoke(void.class, "com.inspur.edp.sgf.eapi.doc.api.DevEapiPublishService.getPublishServiceInfo", "sg", map, new HashMap<>()); + try { + SpringBeanUtils.getBean(RpcClient.class).invoke(void.class, "com.inspur.edp.sgf.eapi.doc.api.DevEapiPublishService.getPublishServiceInfo", "sg", map, new HashMap<>()); + } catch (CAFRuntimeException e) { + throw e; + } } private EApiDefinitionVO getEapiDefinitionVo(GspMetadata metadata) { @@ -122,10 +129,12 @@ public class EapiMetadataDtServiceImpl implements EapiMetadataDtService { vo.setServiceName(metadata.getHeader().getName()); vo.setServiceUsage("internal"); vo.setSourceType("Metadata"); + vo.setAccessScope("PRIVATE"); vo.setSourceId(metadata.getHeader().getId()); vo.setBasePath(getBasePath(metadata)); GspProject projectInfo = MetadataProjectUtils.getProjectInfo(metadata); vo.setServiceUnitCode(projectInfo.getServiceUnitCode()); + //todo 尝试设置业务种类字段 vo.setBizObjectId(metadata.getHeader().getBizobjectID()); vo.setVersion(String.format("v%s", ((SgMetadata) metadata.getContent()).getVersion())); return vo; @@ -136,10 +145,10 @@ public class EapiMetadataDtServiceImpl implements EapiMetadataDtService { return sgMetadata.getRouter(); } - public List getSummaryOperations(String resourceType, String resourceId) { + public List getSummaryOperations(String resourceType, MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath) { List operations = new ArrayList<>(); List summaryInfos = - EapiProviderManager.instance.getSummaryOperations(resourceType, resourceId); + EapiProviderManager.instance.getSummaryOperations(resourceType, targetMdURI, sourceMdURI, projectPath); if (summaryInfos != null) { for (SummaryInfo summaryInfo : summaryInfos) { ServiceOperation operation = new ServiceOperation(); @@ -152,23 +161,23 @@ public class EapiMetadataDtServiceImpl implements EapiMetadataDtService { return operations; } - public List getSelectOperations( - String resourceType, String resourceId, List operationIds) { - return EapiProviderManager.instance.getOperations(resourceType, resourceId, operationIds); + public List getSelectOperations(String resourceType, MetadataURI targetMdURI, MetadataURI sourceMdURI, + String projectPath, List operationIds) { + return EapiProviderManager.instance.getOperations(resourceType, targetMdURI, sourceMdURI, projectPath, operationIds); } private void validateMetadata(GspMetadata metadata) { if (metadata == null) { - throw new RuntimeException("参数校验不通过:元数据不能为空"); + throw new EApiDesignException(ExceptionCode.GSP_EAPI_DESIGN_0202, "参数校验不通过:元数据不能为空"); } if (metadata.getHeader() == null) { - throw new RuntimeException("参数校验不通过:元数据的Header字段不能为空"); + throw new EApiDesignException(ExceptionCode.GSP_EAPI_DESIGN_0203, "参数校验不通过:元数据的Header字段不能为空"); } if (StringUtils.isBlank(metadata.getHeader().getType())) { - throw new RuntimeException("参数校验不通过:元数据类型字段不能为空"); + throw new EApiDesignException(ExceptionCode.GSP_EAPI_DESIGN_0204, "参数校验不通过:元数据类型字段不能为空"); } if (StringUtils.isBlank(metadata.getHeader().getId())) { - throw new RuntimeException("参数校验不通过:元数据ID字段不能为空"); + throw new EApiDesignException(ExceptionCode.GSP_EAPI_DESIGN_0205, "参数校验不通过:元数据ID字段不能为空"); } } @@ -185,7 +194,7 @@ public class EapiMetadataDtServiceImpl implements EapiMetadataDtService { case VO_SIMPLE: return EAPI_RESOURCE_TYPE_VO_SIMPLE; default: - throw new RuntimeException("不支持的资源类型:" + resourceType); + throw new EApiDesignException(ExceptionCode.GSP_EAPI_DESIGN_0206, "不支持的资源类型:" + resourceType); } } } diff --git a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/utils/MetadataProjectUtils.java b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/utils/MetadataProjectUtils.java index 2d8e38da8d89675c620a2b7eda0c6372af1c8c6c..32d52610d38ad3c0c6aa2e38d40b0b9fa3d306e2 100644 --- a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/utils/MetadataProjectUtils.java +++ b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/utils/MetadataProjectUtils.java @@ -20,6 +20,8 @@ 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.service.GspProjectService; import com.inspur.edp.lcm.metadata.api.service.RefCommonService; +import com.inspur.edp.sgf.dt.core.exception.ExceptionCode; +import com.inspur.edp.sgf.utils.exception.EApiDesignException; import io.iec.edp.caf.commons.utils.SpringBeanUtils; import org.apache.commons.lang3.StringUtils; @@ -32,7 +34,7 @@ public class MetadataProjectUtils { public static GspMetadata getMetadata(String metadataId) { if (StringUtils.isBlank(metadataId)) { - throw new RuntimeException("元数据ID不能为空"); + throw new EApiDesignException(ExceptionCode.GSP_EAPI_DESIGN_0301, "元数据ID不能为空"); } RefCommonService service = SpringBeanUtils.getBean(RefCommonService.class); return service.getRefMetadata(metadataId); @@ -40,23 +42,23 @@ public class MetadataProjectUtils { public static GspProject getProjectInfo(GspMetadata metadata) { if (StringUtils.isBlank(metadata.getRelativePath())) { - throw new RuntimeException( + throw new EApiDesignException(ExceptionCode.GSP_EAPI_DESIGN_0302, String.format( "元数据【%s(ID:%s)】的相对路径为空,无法获取工程信息!", metadata.getHeader().getCode(), metadata.getHeader().getId())); } GspProjectService service = SpringBeanUtils.getBean(GspProjectService.class); if (service == null) { - throw new RuntimeException("获取MetadataProjectService Bean为空"); + throw new EApiDesignException(ExceptionCode.GSP_EAPI_DESIGN_0303, "获取MetadataProjectService Bean为空"); } GspProject projectInfo = null; try { projectInfo = service.getGspProjectInfo(metadata.getRelativePath()); } catch (IOException e) { - throw new RuntimeException(e); + throw new EApiDesignException(ExceptionCode.GSP_EAPI_DESIGN_0305, "", e); } if (projectInfo == null) { - throw new RuntimeException( + throw new EApiDesignException(ExceptionCode.GSP_EAPI_DESIGN_0304, String.format( "元数据【%s(ID:%s)】根据相对路径【%s】获取工程信息为空!", metadata.getHeader().getCode(), diff --git a/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/vo/ResourceInfoVo.java b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/vo/ResourceInfoVo.java new file mode 100644 index 0000000000000000000000000000000000000000..a844447e0ee90a869de5723d9695513c66f32756 --- /dev/null +++ b/rest-api-service-dev/src/main/java/com/inspur/edp/sgf/dt/core/vo/ResourceInfoVo.java @@ -0,0 +1,51 @@ +/* + * 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.sgf.dt.core.vo; + +import com.inspur.edp.lcm.metadata.api.entity.uri.MetadataURI; +import lombok.Data; + +import java.util.List; + +/** + * @author Kaixuan Shi + * @version 1.0 + * @since 2023/3/15 + */ +@Data +public class ResourceInfoVo { + /** + * 资源类型 + */ + private String resourceType; + /** + * 资源元数据信息 + */ + private MetadataURI targetMdUri; + /** + * 引用资源元数据的元数据信息 + */ + private MetadataURI sourceMdUri; + /** + * 工程路径 + */ + private String projectPath; + /** + * 服务操作集合 + */ + private List opIds; +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/constraint/MetadataRtRefConstraint.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/constraint/MetadataRtRefConstraint.java index 4b595fc4538859a3141dc32614840c05bdd4a854..1342c316586c40b2f1a340be64b9ad7919d66dbd 100644 --- a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/constraint/MetadataRtRefConstraint.java +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/constraint/MetadataRtRefConstraint.java @@ -38,16 +38,15 @@ public class MetadataRtRefConstraint implements IMetadataRtReferenceManager { @Override public List getConstraint(GspMetadata gspMetadata) { - if (gspMetadata == null) { - return new ArrayList<>(); - } - if (gspMetadata.getContent() == null - || ((SgMetadata) gspMetadata.getContent()).getService() == null - || StringUtils.isBlank( - ((SgMetadata) gspMetadata.getContent()).getService().getResourceId())) { - return gspMetadata.getRefs(); + if (gspMetadata == null || gspMetadata.getContent() == null) { + return null; } SgMetadata eapi = (SgMetadata) gspMetadata.getContent(); + if (eapi.getService() == null + || StringUtils.isBlank(eapi.getService().getResourceId())) { + return null; + } + List metadataRefs = new ArrayList<>(); if (EAPI_RESOURCE_TYPE_VO.equals(eapi.getService().getResourceType()) || EAPI_RESOURCE_TYPE_VO_SIMPLE.equals(eapi.getService().getResourceType())) { MetadataReference reference = new MetadataReference(); @@ -55,15 +54,9 @@ public class MetadataRtRefConstraint implements IMetadataRtReferenceManager { GspMetadata voMetadata = SpringBeanUtils.getBean(CustomizationService.class) .getMetadata(eapi.getService().getResourceId()); - //todo 此处可能会引发空指针异常 reference.setDependentMetadata(voMetadata.getHeader()); - if (gspMetadata.getRefs() == null) { - gspMetadata.setRefs(new ArrayList<>()); - } - gspMetadata.getRefs().add(reference); - return gspMetadata.getRefs(); - } else { - return gspMetadata.getRefs(); + metadataRefs.add(reference); } + return metadataRefs; } } diff --git a/rest-api-spi-dev/src/main/java/com/inspur/edp/sgf/dt/spi/ResourceProvider.java b/rest-api-spi-dev/src/main/java/com/inspur/edp/sgf/dt/spi/ResourceProvider.java index 452679de979c5a6c7b0a1ef99c40b973012a7c56..986f5b4467f18145728f5b725a302cafae703928 100644 --- a/rest-api-spi-dev/src/main/java/com/inspur/edp/sgf/dt/spi/ResourceProvider.java +++ b/rest-api-spi-dev/src/main/java/com/inspur/edp/sgf/dt/spi/ResourceProvider.java @@ -17,6 +17,7 @@ package com.inspur.edp.sgf.dt.spi; import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.lcm.metadata.api.entity.uri.MetadataURI; import com.inspur.edp.sgf.api.common.SummaryInfo; import com.inspur.edp.sgf.api.entity.ServiceOperation; import io.iec.edp.caf.multicontext.annotation.Collect; @@ -26,10 +27,10 @@ import java.util.List; /** * 功能描述:设计时的资源适配接口 * - * @ClassName: ProviderService - * @Author: Fynn Qi - * @Date: 2020/8/26 14:42 - * @Version: V1.0 + * @author Fynn Qi + * @author Kaixuan Shi + * @version 1.1 + * @since 2020/8/26 14:42 */ @Collect public interface ResourceProvider { @@ -37,27 +38,33 @@ public interface ResourceProvider { /** * 获取操作的概要信息集合 * - * @param resourceId 资源ID + * @param targetMdURI 资源元数据uri + * @param sourceMdURI 引用资源元数据的元数据uri + * @param projectPath 工程路径 * @return 返回值 */ - List getSummaryOperations(String resourceId); + List getSummaryOperations(MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath); /** * 获取操作的集合 * - * @param resourceId 资源ID + * @param targetMdURI 资源元数据uri + * @param sourceMdURI 引用资源元数据的元数据uri + * @param projectPath 工程路径 * @return 返回值 */ - List getOperations(String resourceId); + List getOperations(MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath); /** * 获取指定操作的集合 * - * @param resourceId 资源ID + * @param targetMdURI 资源元数据uri + * @param sourceMdURI 引用资源元数据的元数据uri + * @param projectPath 工程路径 * @param operationIds 资源操作ID集合 * @return 返回值 */ - List getOperations(String resourceId, List operationIds); + List getOperations(MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath, List operationIds); /** * 创建EAPI diff --git a/rest-api-utils/src/main/java/com/inspur/edp/sgf/utils/bsession/BackendSessionUtils.java b/rest-api-utils/src/main/java/com/inspur/edp/sgf/utils/bsession/BackendSessionUtils.java index 0d6bdb64b24d36e51f9ba97ec28f8be62ab8ee05..6287735e54447c93b01ea78ec9c58028e2c18cb4 100644 --- a/rest-api-utils/src/main/java/com/inspur/edp/sgf/utils/bsession/BackendSessionUtils.java +++ b/rest-api-utils/src/main/java/com/inspur/edp/sgf/utils/bsession/BackendSessionUtils.java @@ -40,12 +40,11 @@ import java.util.function.Consumer; */ @Slf4j public class BackendSessionUtils { - private static String BACKEND_SESSION_USER_ID = "abc"; + private static final String BACKEND_SESSION_USER_ID = "abc"; public static void wrapFirstTenantBackendSession(Consumer consumer) { - ICafSessionService service = SpringBeanUtils.getBean(ICafSessionService.class); + ICafSessionService cafSessionService = SpringBeanUtils.getBean(ICafSessionService.class); ITenantService tenantService = SpringBeanUtils.getBean(ITenantService.class); - CafSession oldSession = CAFSessionThreadHolder.getCurrentSession(); try { @@ -58,27 +57,36 @@ public class BackendSessionUtils { } if (CAFContext.current.getCurrentSession() == null) { //如果session已经没了,就创建一个bsesion - CafSession cafSession = service.create(tenant.getId(), BACKEND_SESSION_USER_ID, "zh-CHS", new HashMap<>(), SessionType.backend); + CafSession cafSession = cafSessionService.create(tenant.getId(), BACKEND_SESSION_USER_ID, "zh-CHS", new HashMap<>(), SessionType.backend); CAFSessionThreadHolder.setCurrentSession(cafSession); - log.info("create bsession with tenant=" + tenant.getId() + ",userId=" + BACKEND_SESSION_USER_ID + ", lang=zh-CHS"); + log.info("create bsession with tenant=" + tenant.getId() + ",userId=" + BACKEND_SESSION_USER_ID + ", lang=zh-CHS, sessionId=" + cafSession.getId()); } else { //如果还存在,就用当前的。这个分支应该不会走到。 CafSession curSession = CAFContext.current.getCurrentSession(); log.warn("exist session with tenant={}, userId={}, lang={}, sessionType={}", curSession.getTenantId(), curSession.getUserId(), curSession.getLanguage(), curSession.getSessionType()); } + //TODO 使用现有session时,tenant信息错误 consumer.accept(tenant); } else { log.warn("not fount tenants"); } } finally { - if (oldSession == null) { - //如果原来不存在Session,清空当前Session - CAFSessionThreadHolder.purge(); - } else { + try { + CafSession curSession = CAFSessionThreadHolder.getCurrentSession(); + if (curSession != null) { + cafSessionService.deleteById(curSession.getId()); + CAFSessionThreadHolder.purge(); + log.info("delete bsession with sessionId=" + curSession.getId()); + } + } catch (Throwable e) { + log.warn("删除BSession出错,等待过期自动删除", e); + } + if (oldSession != null) { //如果原来存在Session,则设回之前的Session CAFSessionThreadHolder.setCurrentSession(oldSession); } } } + } diff --git a/rest-api-utils/src/main/java/com/inspur/edp/sgf/utils/exception/EApiCustomizeException.java b/rest-api-utils/src/main/java/com/inspur/edp/sgf/utils/exception/EApiCustomizeException.java new file mode 100644 index 0000000000000000000000000000000000000000..e38da906fa04d6c77f03633914fb67e65ad7c0e5 --- /dev/null +++ b/rest-api-utils/src/main/java/com/inspur/edp/sgf/utils/exception/EApiCustomizeException.java @@ -0,0 +1,45 @@ +/* + * 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.sgf.utils.exception; + +import io.iec.edp.caf.commons.exception.CAFRuntimeException; +import io.iec.edp.caf.commons.exception.ExceptionLevel; + +/** + * @author Kaixuan Shi + * @since 2023/3/20 + */ +public class EApiCustomizeException extends CAFRuntimeException { + + private static final String SERVICE_UNIT_CODE = "pfcommon"; + + public EApiCustomizeException(String exceptionCode, String message, Exception innerException, ExceptionLevel level, boolean bizException) { + super(SERVICE_UNIT_CODE, exceptionCode, message, innerException, level, bizException); + } + + public EApiCustomizeException(String exceptionCode, String message, Exception innerException, boolean bizException) { + this(exceptionCode, message, innerException, ExceptionLevel.Error, bizException); + } + + public EApiCustomizeException(String exceptionCode, String message, Exception innerException) { + this(exceptionCode, message, innerException, ExceptionLevel.Error, true); + } + + public EApiCustomizeException(String exceptionCode, String message) { + this(exceptionCode, message, null, ExceptionLevel.Error, true); + } +} diff --git a/rest-api-utils/src/main/java/com/inspur/edp/sgf/utils/exception/EApiDesignException.java b/rest-api-utils/src/main/java/com/inspur/edp/sgf/utils/exception/EApiDesignException.java new file mode 100644 index 0000000000000000000000000000000000000000..5d725e18eb03f80ad65faff566787241e9f5b3f3 --- /dev/null +++ b/rest-api-utils/src/main/java/com/inspur/edp/sgf/utils/exception/EApiDesignException.java @@ -0,0 +1,46 @@ +/* + * 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.sgf.utils.exception; + +import io.iec.edp.caf.commons.exception.CAFRuntimeException; +import io.iec.edp.caf.commons.exception.ExceptionLevel; + +/** + * @author Kaixuan Shi + * @since 2023/3/20 + */ +public class EApiDesignException extends CAFRuntimeException { + + private static final String SERVICE_UNIT_CODE = "main"; + + public EApiDesignException(String exceptionCode, String message, Exception innerException, ExceptionLevel level, boolean bizException) { + super(SERVICE_UNIT_CODE, exceptionCode, message, innerException, level, bizException); + } + + public EApiDesignException(String exceptionCode, String message, Exception innerException, boolean bizException) { + this(exceptionCode, message, innerException, ExceptionLevel.Error, bizException); + } + + public EApiDesignException(String exceptionCode, String message, Exception innerException) { + this(exceptionCode, message, innerException, ExceptionLevel.Error, true); + } + + public EApiDesignException(String exceptionCode, String message) { + this(exceptionCode, message, null, ExceptionLevel.Error, true); + } + +}