From 8e86ee4d75f1a2ed278d54dd6e35a1d834fe0d74 Mon Sep 17 00:00:00 2001 From: zhangweiqing Date: Mon, 17 Oct 2022 09:40:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Erest-api-provider-common?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 1 + rest-api-provider-common/pom.xml | 38 + .../vo/basic/BasicActionProvider.java | 1835 +++++++++++++++++ .../provider/vo/basic/BasicActionSummary.java | 556 +++++ .../vo/basic/SimpleBasicActionProvider.java | 405 ++++ .../vo/basic/SimpleBasicActionSummary.java | 113 + .../vo/custom/CustomActionProvider.java | 252 +++ .../vo/custom/CustomActionSummary.java | 55 + .../vo/custom/SimpleCustomActionProvider.java | 228 ++ .../vo/custom/SimpleCustomActionSummary.java | 58 + .../vo/utils/SimpleViewModelUtils.java | 68 + .../sgf/provider/vo/utils/ViewModelUtils.java | 67 + 12 files changed, 3676 insertions(+) create mode 100644 rest-api-provider-common/pom.xml create mode 100644 rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/BasicActionProvider.java create mode 100644 rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/BasicActionSummary.java create mode 100644 rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/SimpleBasicActionProvider.java create mode 100644 rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/SimpleBasicActionSummary.java create mode 100644 rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/CustomActionProvider.java create mode 100644 rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/CustomActionSummary.java create mode 100644 rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/SimpleCustomActionProvider.java create mode 100644 rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/SimpleCustomActionSummary.java create mode 100644 rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/utils/SimpleViewModelUtils.java create mode 100644 rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/utils/ViewModelUtils.java diff --git a/pom.xml b/pom.xml index f90ebf8..cc88858 100644 --- a/pom.xml +++ b/pom.xml @@ -6,6 +6,7 @@ rest-api-metadata rest-api-service + rest-api-provider-common rest-api-service-dev rest-api-spi-dev rest-api-utils diff --git a/rest-api-provider-common/pom.xml b/rest-api-provider-common/pom.xml new file mode 100644 index 0000000..0f302ca --- /dev/null +++ b/rest-api-provider-common/pom.xml @@ -0,0 +1,38 @@ + + + + rest-api-model + com.inspur.edp + 0.2.0 + + 4.0.0 + + rest-api-provider-common + + + + com.inspur.edp + rest-api-metadata + ${project.version} + compile + + + com.inspur.edp + lcm-metadata-api + 0.1.17 + + + com.inspur.edp + formserver-viewmodel + 0.2.7 + + + com.inspur.edp + cef-spi + 0.2.30 + compile + + + \ No newline at end of file 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 new file mode 100644 index 0000000..b99fbe5 --- /dev/null +++ b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/BasicActionProvider.java @@ -0,0 +1,1835 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.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.entity.ServiceOperation; +import com.inspur.edp.sgf.api.entity.ServiceParameter; +import com.inspur.edp.sgf.api.entity.SgModelType; +import org.apache.commons.lang3.StringUtils; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; + +/** + * 功能描述: @ClassName: BasicActionProvider @Author: Fynn Qi @Date: 2020/2/3 10:43 @Version: V1.0 + */ +public class BasicActionProvider { + //更新API文档会使用 + public static List getBasedBasicActions(GspMetadata gspMetadata) { + List operations = new ArrayList<>(); + // 关闭Session + operations.add(closeSession(gspMetadata)); + // 删除并保存 + operations.add(deleteAndSave(gspMetadata)); + // 查询(所有数据) + operations.add(retrieveWithChildPagination(gspMetadata)); + // 查询子表 + operations.add(retrieveChildByIndex(gspMetadata)); + // 查询数据 + operations.add(extensionFilter(gspMetadata)); + return operations; + } + + 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(batchCreate(gspMetadata)); + // 编辑 + operations.add(edit(gspMetadata)); + // 删除 + operations.add(delete(gspMetadata)); + // 删除并保存 + operations.add(deleteAndSave(gspMetadata)); + // 批量删除 + operations.add(batchDelete(gspMetadata)); + // 批量删除并保存 + operations.add(batchDeleteAndSave(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 nodesCodesStringBuilder = ""; + getExtendDeleteChildActions( + (GspViewObject) obj, operations, nodesCodesStringBuilder, vmMetadata); + } + return operations; + } + + private static void getExtendBatchDeleteChildActions( + GspViewObject viewObject, + List operations, + String nodesCodesStringBuidler, + GspMetadata vmMetadata) { + nodesCodesStringBuidler = + StringUtils.isBlank(nodesCodesStringBuidler) + ? viewObject.getCode() + : nodesCodesStringBuidler + "#" + viewObject.getCode(); + ServiceOperation 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(); + ServiceOperation 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 ServiceOperation getExtendBatchDeleteChildOperation( + GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { + String voId = vmMetadata.getHeader().getId(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); + String[] nodeCodes = nodeCodesStringBuilder.split("#"); + if (nodeCodes.length <= 0) { + return null; + } + ServiceOperation operation = new ServiceOperation(); + operation.setParameters(new ArrayList<>()); + // RequestInfo参数必须放在第一位置 + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + operation.setTemplate("/extension/{rootId}"); + getDeleteChildParam(viewModel, operation, "rootId"); + String methodCode = "Extend_BatchDeleteChild"; + String methodId = "Extend_BatchDeleteChild"; + int count = 0; + for (String nodeCode : nodeCodes) { + methodCode = methodCode + String.format("_%s", nodeCode); + methodId = methodId + MessageFormat.format("##{0}", nodeCode); + operation.setTemplate( + operation.getTemplate() + MessageFormat.format("/{0}", nodeCode.toLowerCase())); + if (count < nodeCodes.length - 1) { + operation.setTemplate( + operation.getTemplate() + + "/{" + + MessageFormat.format( + "{0}Id", com.inspur.edp.cef.spi.jsonser.base.StringUtils.toCamelCase(nodeCode)) + + "}"); + getDeleteChildParam( + viewModel, + operation, + com.inspur.edp.cef.spi.jsonser.base.StringUtils.toCamelCase(nodeCode) + "Id"); + } + count++; + } + + operation.setTemplate(operation.getTemplate() + "/batch"); + + operation.setId(MessageFormat.format("{0}&^^&{1}", voId, methodId)); + operation.setCode(methodCode); + operation.setName(MessageFormat.format("扩展批量删除从表{0}数据", currentNodeCode)); + operation.setDescription(MessageFormat.format("扩展批量删除从表{0}数据", currentNodeCode)); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&{1}", voId, methodId)); + operation.setHttpMethod("PUT"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); // 表示该操作是基本操作中的增加从表数据的操作 + operation.setExtend2(nodeCodesStringBuilder); // 用于存储NodeCode拼接信息(A#B#C) + + ServiceParameter idsParam = + new ServiceParameter() { + { + setId(MessageFormat.format("{0}&^^&Ids", voId)); + setCode("ids"); + setName("内码集合"); + setDescription("批量删除的内码集合"); + setRetVal(false); + setBasicType(true); + setCollection(true); + setListDeepth(1); + setModelId("string"); + setModelName("string"); + setIn("Body"); + setIsRequired(true); + } + }; + + operation.getParameters().add(idsParam); + + // 返回值都放在最后位置 + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + return operation; + } + + private static ServiceOperation getExtendDeleteChildOperation( + GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { + String voId = vmMetadata.getHeader().getId(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); + String[] nodeCodes = nodeCodesStringBuilder.split("#"); + if (nodeCodes.length <= 0) { + return null; + } + ServiceOperation operation = new ServiceOperation(); + operation.setParameters(new ArrayList<>()); + // RequestInfo参数必须放在第一位置 + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + operation.setTemplate("/extension/{rootId}"); + getDeleteChildParam(viewModel, operation, "rootId"); + 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.setTemplate( + operation.getTemplate() + + MessageFormat.format("/{0}", nodeCode.toLowerCase()) + + "/{" + + MessageFormat.format( + "{0}Id", com.inspur.edp.cef.spi.jsonser.base.StringUtils.toCamelCase(nodeCode)) + + "}"); + getDeleteChildParam( + viewModel, + operation, + com.inspur.edp.cef.spi.jsonser.base.StringUtils.toCamelCase(nodeCode) + "Id"); + } + + operation.setId(MessageFormat.format("{0}&^^&{1}", voId, methodId)); + operation.setCode(methodCode); + operation.setName(MessageFormat.format("扩展删除从表{0}数据", currentNodeCode)); + operation.setDescription(MessageFormat.format("扩展删除从表{0}数据", currentNodeCode)); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&{1}", voId, methodId)); + operation.setHttpMethod("PUT"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); // 表示该操作是基本操作中的增加从表数据的操作 + operation.setExtend2(nodeCodesStringBuilder); // 用于存储NodeCode拼接信息(A#B#C) + + // 返回值都放在最后位置 + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + return operation; + } + + private static ServiceOperation extendElementHelp(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId( + MessageFormat.format("{0}&^^&Extend_ElementHelp", voId)); + operation.setCode("Extend_GetElementHelp"); + operation.setName("扩展获取字段帮助"); + operation.setDescription("根据labelId获取字段帮助扩展方法"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Extend_ElementHelp", voId)); + operation.setHttpMethod("PUT"); + operation.setTemplate("/extension/elementhelps"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&labelIdParam", voId)); + parameter2.setCode("labelId"); + parameter2.setName("标签Id"); + parameter2.setDescription("标签内码"); + parameter2.setRetVal(false); + parameter2.setBasicType(true); + parameter2.setCollection(false); + parameter2.setListDeepth(0); + parameter2.setModelId("string"); + parameter2.setModelName("string"); + parameter2.setIn("Body"); + parameter2.setIsRequired(true); + operation.getParameters().add(parameter2); + + ServiceParameter parameter3 = new ServiceParameter(); + parameter3.setId(MessageFormat.format("{0}&^^&nodeCodeParam", voId)); + parameter3.setCode("nodeCode"); + parameter3.setName("节点编号"); + parameter3.setDescription("节点编号"); + parameter3.setRetVal(false); + parameter3.setBasicType(true); + parameter3.setCollection(false); + parameter3.setListDeepth(0); + parameter3.setModelId("string"); + parameter3.setModelName("string"); + parameter3.setIn("Body"); + parameter3.setIsRequired(true); + operation.getParameters().add(parameter3); + + ServiceParameter parameter4 = new ServiceParameter(); + parameter4.setId(MessageFormat.format("{0}&^^&queryParam", voId)); + parameter4.setCode("queryParam"); + parameter4.setName("查询参数"); + parameter4.setDescription("查询参数"); + parameter4.setRetVal(false); + parameter4.setBasicType(true); + parameter4.setCollection(false); + parameter4.setListDeepth(0); + parameter4.setModelId( + MessageFormat.format("{0}&^^&LookupQueryParam", voId)); + parameter4.setModelCode("LookupQueryParam"); + parameter4.setModelName("LookupQueryParam"); + parameter4.setModelType(SgModelType.DTO); + parameter4.setRefId( + MessageFormat.format("{0}&^^&LookupQueryParam", voId)); + parameter4.setRefCode("LookupQueryParam"); + parameter4.setRefName("LookupQueryParam"); + parameter4.setIn("Body"); + parameter4.setIsRequired(true); + operation.getParameters().add(parameter4); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static ServiceOperation extensionFilter(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId( + MessageFormat.format("{0}&^^&Extension_Filter", voId)); + operation.setCode("Extension_Filter"); + operation.setName("查询数据"); + operation.setDescription("查询数据带过滤条件"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Extension_Filter", voId)); + operation.setHttpMethod("POST"); + operation.setTemplate("/extension/filter"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&EntityFilter", voId)); + parameter2.setCode("entityFilter"); + parameter2.setName("过滤条件"); + parameter2.setDescription("过滤条件"); + parameter2.setRetVal(false); + parameter2.setBasicType(false); + parameter2.setCollection(false); + parameter2.setListDeepth(0); + parameter2.setModelId( + MessageFormat.format("{0}&^^&EntityFilter", voId)); + parameter2.setModelCode("EntityFilter"); + parameter2.setModelName("EntityFilter"); + parameter2.setModelType(SgModelType.DTO); + parameter2.setRefId( + MessageFormat.format("{0}&^^&EntityFilter", voId)); + parameter2.setRefCode("EntityFilter"); + parameter2.setRefName("EntityFilter"); + parameter2.setIn("Body"); + parameter2.setIsRequired(false); + operation.getParameters().add(parameter2); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static ServiceOperation extendQuery(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&Extend_Query", voId)); + operation.setCode("Extend_Query"); + operation.setName("扩展过滤查询"); + operation.setDescription("扩展过滤查询"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Extend_Query", voId)); + operation.setHttpMethod("PUT"); + operation.setTemplate("/extension/query"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId( + MessageFormat.format("{0}&^^&EntityFilterParam", voId)); + parameter2.setCode("entityFilter"); + parameter2.setName("过滤条件"); + parameter2.setDescription("过滤条件"); + parameter2.setRetVal(false); + parameter2.setBasicType(true); + parameter2.setCollection(false); + parameter2.setListDeepth(0); + parameter2.setModelId("string"); + parameter2.setModelName("string"); + parameter2.setIn("Query"); + parameter2.setIsRequired(false); + operation.getParameters().add(parameter2); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static ServiceOperation extendRetrieve(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&Extend_Retrieve", voId)); + operation.setCode("Extend_Retrieve"); + operation.setName("扩展数据检索"); + operation.setDescription("扩展数据检索"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Extend_Retrieve", voId)); + operation.setHttpMethod("PUT"); + operation.setTemplate("/extension/retrieve/{dataId}"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&RetrieveParam", voId)); + parameter2.setCode("dataId"); + parameter2.setName("单据内码"); + parameter2.setDescription("单据内码"); + parameter2.setRetVal(false); + parameter2.setBasicType(true); + parameter2.setCollection(false); + parameter2.setListDeepth(0); + parameter2.setModelId("string"); + parameter2.setModelName("string"); + parameter2.setIn("Path"); + parameter2.setIsRequired(true); + operation.getParameters().add(parameter2); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static ServiceOperation extendBatchDelete(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId( + MessageFormat.format("{0}&^^&Extend_BatchDelete", voId)); + operation.setCode("Extend_BatchDelete"); + operation.setName("扩展批量删除"); + operation.setDescription("扩展批量删除"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Extend_BatchDelete", voId)); + operation.setHttpMethod("PUT"); + operation.setTemplate("/extension/batchdelete"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId( + MessageFormat.format("{0}&^^&BatchDeleteParam", voId)); + parameter2.setCode("ids"); + parameter2.setName("单据内码列表"); + parameter2.setDescription("单据内码列表"); + parameter2.setRetVal(false); + parameter2.setBasicType(true); + parameter2.setCollection(false); + parameter2.setListDeepth(0); + parameter2.setModelId("string"); + parameter2.setModelName("string"); + parameter2.setIn("Query"); + parameter2.setIsRequired(true); + operation.getParameters().add(parameter2); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static ServiceOperation extendBatchDeletion(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId( + MessageFormat.format("{0}&^^&Extension_BatchDeletion", voId)); + operation.setCode("Extension_BatchDeletion"); + operation.setName("扩展批量删除"); + operation.setDescription("扩展批量删除"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Extension_BatchDeletion", voId)); + operation.setHttpMethod("PUT"); + operation.setTemplate("/extension/batchdeletion"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter idsParam = new ServiceParameter(); + idsParam.setId( + MessageFormat.format("{0}&^^&Ids", voId)); + idsParam.setCode("ids"); + idsParam.setName("单据内码集合"); + idsParam.setDescription("批量删除的内码集合"); + idsParam.setRetVal(false); + idsParam.setBasicType(true); + idsParam.setCollection(true); + idsParam.setListDeepth(1); + idsParam.setModelId("string"); + idsParam.setModelName("string"); + idsParam.setIn("Body"); + idsParam.setIsRequired(true); + operation.getParameters().add(idsParam); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static ServiceOperation extendDelete(GspMetadata vmMetadata) { + + 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.setResourceOpId( + MessageFormat.format("{0}&^^&Extend_Delete", voId)); + operation.setHttpMethod("PUT"); + operation.setTemplate("/extension/delete/{dataId}"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&DeleteParam", voId)); + parameter2.setCode("dataId"); + parameter2.setName("单据内码"); + parameter2.setDescription("单据内码"); + parameter2.setRetVal(false); + parameter2.setBasicType(true); + parameter2.setCollection(false); + parameter2.setListDeepth(0); + parameter2.setModelId("string"); + parameter2.setModelName("string"); + parameter2.setIn("Path"); + parameter2.setIsRequired(false); + operation.getParameters().add(parameter2); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + 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(); + ServiceOperation 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 ServiceOperation GetDeleteChildOperation( + GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { + String voId = vmMetadata.getHeader().getId(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); + String[] nodeCodes = nodeCodesStringBuilder.split("#"); + if (nodeCodes.length <= 0) { + return null; + } + ServiceOperation operation = new ServiceOperation(); + operation.setParameters(new ArrayList<>()); + operation.setTemplate("/{rootId}"); + getDeleteChildParam(viewModel, operation, "rootId"); + String methodCode = "DeleteChild"; + String methodId = "DeleteChild"; + for (String nodeCode : nodeCodes) { + methodCode = methodCode + String.format("_%s", nodeCode); + methodId = methodId + MessageFormat.format("##{0}", nodeCode); + operation.setTemplate( + operation.getTemplate() + + MessageFormat.format("/{0}", nodeCode.toLowerCase()) + + "/{" + + MessageFormat.format( + "{0}Id", com.inspur.edp.cef.spi.jsonser.base.StringUtils.toCamelCase(nodeCode)) + + "}"); + getDeleteChildParam( + viewModel, + operation, + com.inspur.edp.cef.spi.jsonser.base.StringUtils.toCamelCase(nodeCode) + "Id"); + } + + operation.setId(MessageFormat.format("{0}&^^&{1}", voId, methodId)); + operation.setCode(methodCode); + operation.setName(MessageFormat.format("删除从表{0}数据", currentNodeCode)); + operation.setDescription(MessageFormat.format("删除从表{0}数据", currentNodeCode)); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&{1}", voId, methodId)); + operation.setHttpMethod("DELETE"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); // 表示该操作是基本操作中的增加从表数据的操作 + operation.setExtend2(nodeCodesStringBuilder); // 用于存储NodeCode拼接信息(A#B#C) + + return operation; + } + + private static void getDeleteChildParam( + GspViewModel viewModel, ServiceOperation operation, String currentParamCode) { + ServiceParameter serviceParam = new ServiceParameter(); + serviceParam.setId(viewModel.getId() + currentParamCode); + serviceParam.setCode(currentParamCode); + String nodeCode = currentParamCode.substring(0, currentParamCode.length() - 2); + if (nodeCode.equals("root")) { + serviceParam.setName(MessageFormat.format("主表{0}数据ID", nodeCode)); + serviceParam.setDescription(MessageFormat.format("主表{0}数据的所属实体数据的唯一标识", nodeCode)); + } else { + serviceParam.setName(MessageFormat.format("从表{0}数据ID", nodeCode)); + serviceParam.setDescription(MessageFormat.format("从表{0}数据的所属实体数据的唯一标识", nodeCode)); + } + serviceParam.setRetVal(false); + serviceParam.setBasicType(true); + serviceParam.setCollection(false); + serviceParam.setListDeepth(0); + serviceParam.setModelId("string"); + serviceParam.setModelName("string"); + serviceParam.setIn("Path"); + serviceParam.setIsRequired(true); + operation.getParameters().add(serviceParam); + } + + 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(); + ServiceOperation 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(); + ServiceOperation 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 ServiceOperation getBatchCreateChildOperation( + GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { + String voId = vmMetadata.getHeader().getId(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); + String[] nodeCodes = nodeCodesStringBuilder.split("#"); + if (nodeCodes.length <= 0) { + return null; + } + ServiceOperation operation = new ServiceOperation(); + operation.setParameters(new ArrayList<>()); + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + operation.setTemplate("/{rootId}"); + getCreateChildParam(viewModel, operation, "rootId"); + String methodCode = "BatchCreateChild"; + String methodId = "BatchCreateChild"; + int count = 0; + for (String nodeCode : nodeCodes) { + methodCode = methodCode + String.format("_%s", nodeCode); + methodId = methodId + MessageFormat.format("##{0}", nodeCode); + if (count < nodeCodes.length - 1) { + operation.setTemplate( + operation.getTemplate() + + MessageFormat.format("/{0}", nodeCode.toLowerCase()) + + "/{" + + MessageFormat.format( + "{0}Id", com.inspur.edp.cef.spi.jsonser.base.StringUtils.toCamelCase(nodeCode)) + + "}"); + getCreateChildParam( + viewModel, + operation, + com.inspur.edp.cef.spi.jsonser.base.StringUtils.toCamelCase(nodeCode) + "Id"); + } else { + operation.setTemplate( + operation.getTemplate() + MessageFormat.format("/{0}", nodeCode.toLowerCase())); + } + count++; + } + + operation.setTemplate(operation.getTemplate() + "/batch"); + + operation.setId(MessageFormat.format("{0}&^^&{1}", voId, methodId)); + operation.setCode(methodCode); + operation.setName(MessageFormat.format("批量新增从表{0}数据", currentNodeCode)); + operation.setDescription(MessageFormat.format("批量新增从表{0}数据", currentNodeCode)); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&{1}", voId, methodId)); + operation.setHttpMethod("POST"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); // 表示该操作是基本操作中的增加从表数据的操作 + operation.setExtend2(nodeCodesStringBuilder); // 用于存储NodeCode拼接信息(A#B#C) + + ServiceParameter retrieveDafaultParm = + new ServiceParameter() { + { + setId( + MessageFormat.format("{0}&^^&RetrieveDefaultParam", voId)); + setCode("retrieveDefaultParam"); + setName("默认值"); + setDescription("批量新增从表的默认值"); + setRetVal(false); + setBasicType(false); + setCollection(false); + setListDeepth(0); + setModelId( + MessageFormat.format("{0}&^^&RetrieveDefaultParam", voId)); + setModelCode("RetrieveDefaultParam"); + setModelName("RetrieveDefaultParam"); + setModelType(SgModelType.DTO); + setRefId("RetrieveDefaultParam"); + setRefCode("RetrieveDefaultParam"); + setRefName("RetrieveDefaultParam"); + setIn("Body"); + setIsRequired(true); + } + }; + operation.getParameters().add(retrieveDafaultParm); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static ServiceOperation getCreateChildOperation( + GspMetadata vmMetadata, String currentNodeCode, String nodeCodesStringBuilder) { + String voId = vmMetadata.getHeader().getId(); + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); + String[] nodeCodes = nodeCodesStringBuilder.split("#"); + if (nodeCodes.length <= 0) { + return null; + } + ServiceOperation operation = new ServiceOperation(); + operation.setParameters(new ArrayList<>()); + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + operation.setTemplate("/{rootId}"); + getCreateChildParam(viewModel, operation, "rootId"); + String methodCode = "CreateChild"; + String methodId = "CreateChild"; + int count = 0; + for (String nodeCode : nodeCodes) { + methodCode = methodCode + String.format("_%s", nodeCode); + methodId = methodId + MessageFormat.format("##{0}", nodeCode); + if (count < nodeCodes.length - 1) { + operation.setTemplate( + operation.getTemplate() + + MessageFormat.format("/{0}", nodeCode.toLowerCase()) + + "/{" + + MessageFormat.format( + "{0}Id", com.inspur.edp.cef.spi.jsonser.base.StringUtils.toCamelCase(nodeCode)) + + "}"); + getCreateChildParam( + viewModel, + operation, + com.inspur.edp.cef.spi.jsonser.base.StringUtils.toCamelCase(nodeCode) + "Id"); + } else { + operation.setTemplate( + operation.getTemplate() + MessageFormat.format("/{0}", nodeCode.toLowerCase())); + } + count++; + } + + operation.setId(MessageFormat.format("{0}&^^&{1}", voId, methodId)); + operation.setCode(methodCode); + operation.setName(MessageFormat.format("新增从表{0}数据", currentNodeCode)); + operation.setDescription(MessageFormat.format("新增从表{0}数据", currentNodeCode)); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&{1}", voId, methodId)); + operation.setHttpMethod("POST"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); // 表示该操作是基本操作中的增加从表数据的操作 + operation.setExtend2(nodeCodesStringBuilder); // 用于存储NodeCode拼接信息(A#B#C) + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static void getCreateChildParam( + GspViewModel viewModel, ServiceOperation operation, String currentParamCode) { + ServiceParameter serviceParam = new ServiceParameter(); + serviceParam.setId(viewModel.getId() + currentParamCode); + serviceParam.setCode(currentParamCode); + String nodeCode = currentParamCode.substring(0, currentParamCode.length() - 2); + if (nodeCode.equals("root")) { + serviceParam.setName(MessageFormat.format("主表{0}数据ID", nodeCode)); + serviceParam.setDescription(MessageFormat.format("主表{0}数据的所属实体数据的唯一标识", nodeCode)); + } else { + serviceParam.setName(MessageFormat.format("从表{0}数据ID", nodeCode)); + serviceParam.setDescription(MessageFormat.format("从表{0}数据的所属实体数据的唯一标识", nodeCode)); + } + serviceParam.setRetVal(false); + serviceParam.setBasicType(true); + serviceParam.setCollection(false); + serviceParam.setListDeepth(0); + serviceParam.setModelId("string"); + serviceParam.setModelName("string"); + serviceParam.setIn("Path"); + serviceParam.setIsRequired(true); + operation.getParameters().add(serviceParam); + } + + private static ServiceOperation getElementHelp(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&ElementHelp", voId)); + operation.setCode("GetElementHelp"); + operation.setName("获取字段帮助"); + operation.setDescription("根据labelId获取字段帮助"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&ElementHelp", voId)); + operation.setHttpMethod("GET"); + operation.setTemplate("elementhelps/{labelId}"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter parameter1 = new ServiceParameter(); + parameter1.setId(MessageFormat.format("{0}&^^&labelIdParam", voId)); + parameter1.setCode("labelId"); + parameter1.setName("标签Id"); + parameter1.setDescription("标签内码"); + parameter1.setRetVal(false); + parameter1.setBasicType(true); + parameter1.setCollection(false); + parameter1.setListDeepth(0); + parameter1.setModelId("string"); + parameter1.setModelName("string"); + parameter1.setIn("Path"); + parameter1.setIsRequired(true); + operation.getParameters().add(parameter1); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&nodeCodeParam", voId)); + parameter2.setCode("nodeCode"); + parameter2.setName("节点编号"); + parameter2.setDescription("节点编号"); + parameter2.setRetVal(false); + parameter2.setBasicType(true); + parameter2.setCollection(false); + parameter2.setListDeepth(0); + parameter2.setModelId("string"); + parameter2.setModelName("string"); + parameter2.setIn("Query"); + parameter2.setIsRequired(true); + operation.getParameters().add(parameter2); + + ServiceParameter parameter3 = new ServiceParameter(); + parameter3.setId(MessageFormat.format("{0}&^^&queryParam", voId)); + parameter3.setCode("queryParam"); + parameter3.setName("查询参数"); + parameter3.setDescription("查询参数"); + parameter3.setRetVal(false); + parameter3.setBasicType(true); + parameter3.setCollection(false); + parameter3.setListDeepth(0); + parameter3.setModelId("string"); + parameter3.setModelName("string"); + parameter3.setIn("Query"); + parameter3.setIsRequired(true); + operation.getParameters().add(parameter3); + + ServiceParameter parameter4 = new ServiceParameter(); + parameter4.setId( + MessageFormat.format("{0}&^^&ElementHelpRetParam", voId)); + parameter4.setCode("return"); + parameter4.setName("返回值"); + parameter4.setDescription("返回值"); + parameter4.setRetVal(true); + parameter4.setBasicType(false); + parameter4.setCollection(false); + parameter4.setListDeepth(0); + parameter4.setModelId( + MessageFormat.format("{0}&^^&LookupResult", voId)); + parameter4.setModelCode("LookupResult"); + parameter4.setModelName("LookupResult"); + parameter4.setModelType(SgModelType.DTO); + parameter4.setRefId( + MessageFormat.format("{0}&^^&LookupResult", voId)); + parameter4.setRefCode("LookupResult"); + parameter4.setRefName("LookupResult"); + parameter4.setIn(""); + parameter4.setIsRequired(true); + operation.getParameters().add(parameter4); + + return operation; + } + + private static ServiceOperation cancel(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + operation.setId(MessageFormat.format("{0}&^^&Cancel", voId)); + operation.setCode("Cancel"); + operation.setName("取消"); + operation.setDescription("取消"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Cancel", voId)); + operation.setHttpMethod("POST"); + operation.setTemplate("service/cancel"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + return operation; + } + + private static ServiceOperation save(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&Save", voId)); + operation.setCode("Save"); + operation.setName("保存"); + operation.setDescription("保存"); + operation.setResourceOpId(MessageFormat.format("{0}&^^&Save", voId)); + operation.setHttpMethod("PUT"); + operation.setTemplate(""); + 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(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&Query", voId)); + operation.setCode("Query"); + operation.setName("过滤查询"); + operation.setDescription("过滤查询"); + operation.setResourceOpId(MessageFormat.format("{0}&^^&Query", voId)); + operation.setHttpMethod("GET"); + operation.setTemplate(""); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter parameter1 = new ServiceParameter(); + parameter1.setId( + MessageFormat.format("{0}&^^&EntityFilterParam", voId)); + parameter1.setCode("entityFilter"); + parameter1.setName("过滤条件"); + parameter1.setDescription("过滤条件"); + parameter1.setRetVal(false); + parameter1.setBasicType(true); + parameter1.setCollection(false); + parameter1.setListDeepth(0); + parameter1.setModelId("string"); + parameter1.setModelName("string"); + parameter1.setIn("Query"); + parameter1.setIsRequired(true); + operation.getParameters().add(parameter1); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&QueryParam", voId)); + // TODO code要做ToCamel处理 + parameter2.setCode(viewModel.getMainObject().getCode()); + parameter2.setName(viewModel.getMainObject().getName()); + parameter2.setDescription("实体模型"); + parameter2.setRetVal(true); + parameter2.setBasicType(false); + parameter2.setCollection(true); + parameter2.setListDeepth(1); + parameter2.setModelId(voId); + parameter2.setModelCode(vmMetadata.getHeader().getCode()); + parameter2.setModelName(vmMetadata.getHeader().getName()); + parameter2.setModelType(SgModelType.VO); + parameter2.setRefId(viewModel.getMainObject().getId()); + parameter2.setRefCode(viewModel.getMainObject().getCode()); + parameter2.setRefName(viewModel.getMainObject().getName()); + parameter2.setIn(""); + parameter2.setIsRequired(true); + operation.getParameters().add(parameter2); + + return operation; + } + + private static ServiceOperation retrieveChildByIndex(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&QueryChild", voId)); + operation.setCode("QueryChild"); + operation.setName("子表查询"); + operation.setDescription("子表数据查询"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&QueryChild", voId)); + operation.setHttpMethod("PUT"); + operation.setTemplate("/service/querychild"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&nodeCodes", voId)); + parameter2.setCode("nodeCodes"); + parameter2.setName("节点编号列表"); + parameter2.setDescription("节点编号列表"); + parameter2.setRetVal(false); + parameter2.setBasicType(true); + parameter2.setCollection(true); + parameter2.setListDeepth(1); + parameter2.setModelId("string"); + parameter2.setModelName("string"); + parameter2.setIn("Body"); + parameter2.setIsRequired(true); + operation.getParameters().add(parameter2); + + ServiceParameter parameter3 = new ServiceParameter(); + parameter3.setId(MessageFormat.format("{0}&^^&ids", voId)); + parameter3.setCode("ids"); + parameter3.setName("内码列表"); + parameter3.setDescription("内码列表"); + parameter3.setRetVal(false); + parameter3.setBasicType(true); + parameter3.setCollection(true); + parameter3.setListDeepth(1); + parameter3.setModelId("string"); + parameter3.setModelName("string"); + parameter3.setIn("Body"); + parameter3.setIsRequired(true); + operation.getParameters().add(parameter3); + + ServiceParameter parameter4 = new ServiceParameter(); + parameter4.setId(MessageFormat.format("{0}&^^&pagination", voId)); + parameter4.setCode("pagination"); + parameter4.setName("分页信息"); + parameter4.setDescription("分页信息"); + parameter4.setRetVal(false); + parameter4.setBasicType(false); + parameter4.setCollection(false); + parameter4.setListDeepth(0); + parameter4.setModelId( + MessageFormat.format("{0}&^^&Pagination", voId)); + parameter4.setModelCode("Pagination"); + parameter4.setModelName("Pagination"); + parameter4.setModelType(SgModelType.DTO); + parameter4.setRefId(MessageFormat.format("{0}&^^&Pagination", voId)); + parameter4.setRefCode("Pagination"); + parameter4.setRefName("Pagination"); + parameter4.setIn("Body"); + parameter4.setIsRequired(true); + operation.getParameters().add(parameter4); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static ServiceOperation retrieveWithChildPagination(GspMetadata vmMetadata) { + + String voId = vmMetadata.getHeader().getId(); + + ServiceOperation operation = new ServiceOperation(); + + operation.setId( + MessageFormat.format("{0}&^^&RetrieveWithChildPagination", voId)); + operation.setCode("RetrieveWithChildPagination"); + operation.setName("数据检索"); + operation.setDescription("数据检索(包含子表数据)"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&RetrieveWithChildPagination", voId)); + operation.setHttpMethod("PUT"); + operation.setTemplate("/service/retrieve/{dataId}"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&dataId", voId)); + parameter2.setCode("dataId"); + parameter2.setName("单据内码"); + parameter2.setDescription("单据内码"); + parameter2.setRetVal(false); + parameter2.setBasicType(true); + parameter2.setCollection(false); + parameter2.setListDeepth(0); + parameter2.setModelId("string"); + parameter2.setModelName("string"); + parameter2.setIn("Path"); + parameter2.setIsRequired(true); + operation.getParameters().add(parameter2); + + ServiceParameter parameter3 = new ServiceParameter(); + parameter3.setId(MessageFormat.format("{0}&^^&retrieveParam", voId)); + parameter3.setCode("retrieveParam"); + parameter3.setName("查询参数"); + parameter3.setDescription("查询参数"); + parameter3.setRetVal(false); + parameter3.setBasicType(false); + parameter3.setCollection(false); + parameter3.setListDeepth(0); + parameter3.setModelId( + MessageFormat.format("{0}&^^&RetrieveParam", voId)); + parameter3.setModelCode("RetrieveParam"); + parameter3.setModelName("RetrieveParam"); + parameter3.setModelType(SgModelType.DTO); + parameter3.setRefId( + MessageFormat.format("{0}&^^&RetrieveParam", voId)); + parameter3.setRefCode("RetrieveParam"); + parameter3.setRefName("RetrieveParam"); + parameter3.setIn("Body"); + parameter3.setIsRequired(true); + operation.getParameters().add(parameter3); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static ServiceOperation retrieve(GspMetadata vmMetadata) { + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&Retrieve", voId)); + operation.setCode("Retrieve"); + operation.setName("数据检索"); + operation.setDescription("数据检索"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Retrieve", voId)); + operation.setHttpMethod("GET"); + operation.setTemplate("/{dataId}"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter parameter1 = new ServiceParameter(); + parameter1.setId(MessageFormat.format("{0}&^^&RetrieveParam", voId)); + parameter1.setCode("dataId"); + parameter1.setName("单据内码"); + parameter1.setDescription("单据内码"); + parameter1.setRetVal(false); + parameter1.setBasicType(true); + parameter1.setCollection(false); + parameter1.setListDeepth(0); + parameter1.setModelId("string"); + parameter1.setModelName("string"); + parameter1.setIn("Path"); + parameter1.setIsRequired(true); + operation.getParameters().add(parameter1); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&RetrieveParam1", voId)); + // TODO code要做ToCamel处理 + parameter2.setCode(viewModel.getMainObject().getCode()); + parameter2.setName(viewModel.getMainObject().getName()); + parameter2.setDescription("实体模型"); + parameter2.setRetVal(true); + parameter2.setBasicType(false); + parameter2.setCollection(false); + parameter2.setListDeepth(0); + parameter2.setModelId(voId); + parameter2.setModelCode(vmMetadata.getHeader().getCode()); + parameter2.setModelName(vmMetadata.getHeader().getName()); + parameter2.setModelType(SgModelType.VO); + parameter2.setRefId(viewModel.getMainObject().getId()); + parameter2.setRefCode(viewModel.getMainObject().getCode()); + parameter2.setRefName(viewModel.getMainObject().getName()); + parameter2.setIn(""); + parameter2.setIsRequired(true); + operation.getParameters().add(parameter2); + + return operation; + } + + private static ServiceOperation update(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&Update", voId)); + operation.setCode("Update"); + operation.setName("修改"); + operation.setDescription("修改"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Update", voId)); + operation.setHttpMethod("PATCH"); + operation.setTemplate(""); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&UpdateParam", voId)); + parameter2.setCode("changeDetail"); + parameter2.setName("数据变更集"); + parameter2.setDescription("数据变更集"); + parameter2.setRetVal(false); + parameter2.setBasicType(false); + parameter2.setCollection(false); + parameter2.setListDeepth(0); + parameter2.setModelId( + MessageFormat.format("{0}&^^&ChangeDetail", voId)); + parameter2.setModelCode("ChangeDetail"); + parameter2.setModelName("ChangeDetail"); + parameter2.setModelType(SgModelType.DTO); + parameter2.setRefId( + MessageFormat.format("{0}&^^&ChangeDetail", voId)); + parameter2.setRefCode("ChangeDetail"); + parameter2.setRefName("ChangeDetail"); + parameter2.setIn("Body"); + parameter2.setIsRequired(true); + operation.getParameters().add(parameter2); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static ServiceOperation deleteAndSave(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&DeleteAndSave", voId)); + operation.setCode("DeleteAndSave"); + operation.setName("删除并保存"); + operation.setDescription("删除并保存"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&DeleteAndSave", voId)); + operation.setHttpMethod("PUT"); + operation.setTemplate("/service/delete/{dataId}"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&DeleteParam", voId)); + parameter2.setCode("dataId"); + parameter2.setName("单据内码"); + parameter2.setDescription("单据内码"); + parameter2.setRetVal(false); + parameter2.setBasicType(true); + parameter2.setCollection(false); + parameter2.setListDeepth(0); + parameter2.setModelId("string"); + parameter2.setModelName("string"); + parameter2.setIn("Path"); + parameter2.setIsRequired(true); + operation.getParameters().add(parameter2); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static ServiceOperation batchDelete(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&BatchDelete", voId)); + operation.setCode("BatchDelete"); + operation.setName("批量删除"); + operation.setDescription("批量删除"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&BatchDelete", voId)); + operation.setHttpMethod("DELETE"); + operation.setTemplate(""); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter parameter1 = new ServiceParameter(); + parameter1.setId( + MessageFormat.format("{0}&^^&BatchDeleteParam", voId)); + parameter1.setCode("ids"); + parameter1.setName("单据内码列表"); + parameter1.setDescription("单据内码列表"); + parameter1.setRetVal(false); + parameter1.setBasicType(true); + parameter1.setCollection(false); + parameter1.setListDeepth(0); + parameter1.setModelId("string"); + parameter1.setModelName("string"); + parameter1.setIn("Query"); + parameter1.setIsRequired(true); + operation.getParameters().add(parameter1); + + return operation; + } + + private static ServiceOperation batchDeleteAndSave(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&BatchDeleteAndSave", voId)); + operation.setCode("BatchDeleteAndSave"); + operation.setName("批量删除并保存"); + operation.setDescription("批量删除并保存"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&BatchDeleteAndSave", voId)); + operation.setHttpMethod("POST"); + operation.setTemplate("/batchdeleteandsave"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter idsParam = new ServiceParameter(); + idsParam.setId( + MessageFormat.format("{0}&^^&IdsParam", voId)); + idsParam.setCode("ids"); + idsParam.setName("单据内码列表"); + idsParam.setDescription("批量删除的单据内码列表"); + idsParam.setRetVal(false); + idsParam.setBasicType(true); + idsParam.setCollection(true); + idsParam.setListDeepth(1); + idsParam.setModelId("string"); + idsParam.setModelName("string"); + idsParam.setIn("Body"); + idsParam.setIsRequired(true); + operation.getParameters().add(idsParam); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + return operation; + } + + private static ServiceOperation delete(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&Delete", voId)); + operation.setCode("Delete"); + operation.setName("删除"); + operation.setDescription("删除"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Delete", voId)); + operation.setHttpMethod("DELETE"); + operation.setTemplate("/{dataId}"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter parameter1 = new ServiceParameter(); + parameter1.setId(MessageFormat.format("{0}&^^&DeleteParam", voId)); + parameter1.setCode("dataId"); + parameter1.setName("单据内码"); + parameter1.setDescription("单据内码"); + parameter1.setRetVal(false); + parameter1.setBasicType(true); + parameter1.setCollection(false); + parameter1.setListDeepth(0); + parameter1.setModelId("string"); + parameter1.setModelName("string"); + parameter1.setIn("Path"); + parameter1.setIsRequired(true); + operation.getParameters().add(parameter1); + + return operation; + } + + private static ServiceOperation edit(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&Edit", voId)); + operation.setCode("Edit"); + operation.setName("编辑"); + operation.setDescription("编辑"); + operation.setResourceOpId(MessageFormat.format("{0}&^^&Edit", voId)); + operation.setHttpMethod("PUT"); + operation.setTemplate("/service/edit/{dataId}"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&RetrieveParam", voId)); + parameter2.setCode("dataId"); + parameter2.setName("单据内码"); + parameter2.setDescription("单据内码"); + parameter2.setRetVal(false); + parameter2.setBasicType(true); + parameter2.setCollection(false); + parameter2.setListDeepth(0); + parameter2.setModelId("string"); + parameter2.setModelName("string"); + parameter2.setIn("Path"); + parameter2.setIsRequired(true); + operation.getParameters().add(parameter2); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static ServiceOperation create(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + + ServiceOperation operation = new ServiceOperation(); + operation.setId(MessageFormat.format("{0}&^^&Create", voId)); + operation.setCode("Create"); + operation.setName("新增"); + operation.setDescription("新增主表数据"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Create", voId)); + operation.setHttpMethod("POST"); + operation.setTemplate(""); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter requestInfoParam = constructRequestInfoParameter(voId); + operation.getParameters().add(requestInfoParam); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&defaultValue", voId)); + parameter2.setCode("defaultValue"); + parameter2.setName("默认值"); + parameter2.setDescription("默认值"); + parameter2.setRetVal(false); + parameter2.setBasicType(false); + parameter2.setCollection(false); + parameter2.setListDeepth(0); + parameter2.setModelId( + MessageFormat.format("{0}&^^&DefaultValue", voId)); + parameter2.setModelCode("DefaultValue"); + parameter2.setModelName("DefaultValue"); + parameter2.setModelType(SgModelType.DTO); + parameter2.setRefId( + MessageFormat.format("{0}&^^&DefaultValue", voId)); + parameter2.setRefCode("DefaultValue"); + parameter2.setRefName("DefaultValue"); + parameter2.setIn("Body"); + parameter2.setIsRequired(false); + operation.getParameters().add(parameter2); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static ServiceOperation batchCreate(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&BatchCreate", voId)); + operation.setCode("BatchCreate"); + operation.setName("批量新增主表数据"); + operation.setDescription("根据默认值批量新增主表数据"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&BatchCreate", voId)); + operation.setHttpMethod("POST"); + operation.setTemplate("/batch"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter parameter1 = new ServiceParameter(); + parameter1.setId(MessageFormat.format("{0}&^^&RequestInfo", voId)); + parameter1.setCode("requestInfo"); + parameter1.setName("请求信息"); + parameter1.setDescription("请求信息"); + parameter1.setRetVal(false); + parameter1.setBasicType(false); + parameter1.setCollection(false); + parameter1.setListDeepth(0); + parameter1.setModelId( + MessageFormat.format("{0}&^^&RequestInfo", voId)); + parameter1.setModelCode("RequestInfo"); + parameter1.setModelName("RequestInfo"); + parameter1.setModelType(SgModelType.DTO); + parameter1.setRefId(MessageFormat.format("{0}&^^&RequestInfo", voId)); + parameter1.setRefCode("RequestInfo"); + parameter1.setRefName("RequestInfo"); + parameter1.setIn("Body"); + parameter1.setIsRequired(true); + operation.getParameters().add(parameter1); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&retrieveDefaultParam", voId)); + parameter2.setCode("retrieveDefaultParam"); + parameter2.setName("默认值"); + parameter2.setDescription("默认值"); + parameter2.setRetVal(false); + parameter2.setBasicType(false); + parameter2.setCollection(false); + parameter2.setListDeepth(0); + parameter2.setModelId( + MessageFormat.format("{0}&^^&RetrieveDefaultParam", voId)); + parameter2.setModelCode("RetrieveDefaultParam"); + parameter2.setModelName("RetrieveDefaultParam"); + parameter2.setModelType(SgModelType.DTO); + parameter2.setRefId( + MessageFormat.format("{0}&^^&RetrieveDefaultParam", voId)); + parameter2.setRefCode("RetrieveDefaultParam"); + parameter2.setRefName("RetrieveDefaultParam"); + parameter2.setIn("Body"); + parameter2.setIsRequired(false); + operation.getParameters().add(parameter2); + + ServiceParameter responseInfoParam = constructResponseInfoParameter(voId); + operation.getParameters().add(responseInfoParam); + + return operation; + } + + private static ServiceOperation closeSession(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + operation.setId(MessageFormat.format("{0}&^^&CloseSession", voId)); + operation.setCode("CloseSession"); + operation.setName("关闭Session"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&CloseSession", voId)); + operation.setHttpMethod("POST"); + operation.setTemplate("service/closesession"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + return operation; + } + + private static ServiceOperation createSession(GspMetadata vmMetadata) { + String voId = vmMetadata.getHeader().getId(); + ServiceOperation operation = new ServiceOperation(); + operation.setId(MessageFormat.format("{0}&^^&CreateSession", voId)); + operation.setCode("CreateSession"); + operation.setName("创建Session"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&CreateSession", voId)); + operation.setHttpMethod("POST"); + operation.setTemplate("service/createsession"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + operation.setParameters(new ArrayList<>()); + + ServiceParameter parameter = new ServiceParameter(); + parameter.setId( + MessageFormat.format("{0}&^^&CreateSessionParam", voId)); + parameter.setCode("sessionId"); + parameter.setName("sessionId"); + parameter.setDescription("功能sessionId"); + parameter.setRetVal(true); + parameter.setBasicType(true); + parameter.setCollection(false); + parameter.setListDeepth(0); + parameter.setModelId("string"); + parameter.setModelName("string"); + parameter.setIn(""); + parameter.setIsRequired(true); + + operation.getParameters().add(parameter); + + return operation; + } + + private static ServiceParameter constructRequestInfoParameter(String voId) { + ServiceParameter requestInfo = new ServiceParameter(); + requestInfo.setId(MessageFormat.format("{0}&^^&RequestInfo", voId)); + requestInfo.setCode("requestInfo"); + requestInfo.setName("请求信息"); + requestInfo.setDescription("请求信息"); + requestInfo.setRetVal(false); + requestInfo.setBasicType(false); + requestInfo.setCollection(false); + requestInfo.setListDeepth(0); + requestInfo.setModelId( + MessageFormat.format("{0}&^^&RequestInfo", voId)); + requestInfo.setModelCode("RequestInfo"); + requestInfo.setModelName("RequestInfo"); + requestInfo.setModelType(SgModelType.DTO); + requestInfo.setRefId(MessageFormat.format("{0}&^^&RequestInfo", voId)); + requestInfo.setRefCode("RequestInfo"); + requestInfo.setRefName("RequestInfo"); + requestInfo.setIn("Body"); + requestInfo.setIsRequired(false); + return requestInfo; + } + + private static ServiceParameter constructResponseInfoParameter(String voId) { + ServiceParameter responseInfo = new ServiceParameter(); + responseInfo.setId(MessageFormat.format("{0}&^^&ResponseInfo", voId)); + responseInfo.setCode("responseInfo"); + responseInfo.setName("响应信息"); + responseInfo.setDescription("响应信息"); + responseInfo.setRetVal(true); + responseInfo.setBasicType(false); + responseInfo.setCollection(false); + responseInfo.setListDeepth(0); + responseInfo.setModelId( + MessageFormat.format("{0}&^^&ResponseInfo", voId)); + responseInfo.setModelCode("ResponseInfo"); + responseInfo.setModelName("ResponseInfo"); + responseInfo.setModelType(SgModelType.DTO); + responseInfo.setRefId( + MessageFormat.format("{0}&^^&ResponseInfo", voId)); + responseInfo.setRefCode("ResponseInfo"); + responseInfo.setRefName("ResponseInfo"); + responseInfo.setIn(""); + responseInfo.setIsRequired(true); + return responseInfo; + } +} 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 new file mode 100644 index 0000000..406b963 --- /dev/null +++ b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/BasicActionSummary.java @@ -0,0 +1,556 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.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 java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; + +/** + * 功能描述: @ClassName: BasicActionSummary @Author: Fynn Qi @Date: 2020/8/26 11:33 @Version: V1.0 + */ +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; + } + 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 new file mode 100644 index 0000000..9b5e372 --- /dev/null +++ b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/SimpleBasicActionProvider.java @@ -0,0 +1,405 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.provider.vo.basic; + +import com.inspur.edp.cef.spi.jsonser.base.StringUtils; +import com.inspur.edp.formserver.viewmodel.GspViewModel; +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.sgf.api.entity.ServiceOperation; +import com.inspur.edp.sgf.api.entity.ServiceParameter; +import com.inspur.edp.sgf.api.entity.SgModelType; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; + +/** + * 功能描述: + * + * @ClassName: SimpleBasicActionProvider + * @Author: Fynn Qi + * @Date: 2020/7/31 10:42 + * @Version: V1.0 + */ +public class SimpleBasicActionProvider { + + public static List getSimpleBasicActions(GspMetadata gspMetadata) { + List operations = new ArrayList<>(); + //增加 + operations.add(create(gspMetadata)); + //删除 + operations.add(delete(gspMetadata)); + //批量删除 + operations.add(batchDelete(gspMetadata)); + //保存 + operations.add(update(gspMetadata)); + //查询 + operations.add(retrieve(gspMetadata)); + //过滤查询 + operations.add(query(gspMetadata)); + //增加默认值 + operations.add(createDefaultValue(gspMetadata)); + return operations; + } + + + private static ServiceOperation query(GspMetadata vmMetadata) { + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&Query", vmMetadata.getHeader().getId())); + operation.setCode("Query"); + operation.setName("过滤查询"); + operation.setDescription("过滤查询"); + operation.setResourceOpId(MessageFormat.format("{0}&^^&Query", vmMetadata.getHeader().getId())); + operation.setHttpMethod("GET"); + operation.setTemplate(""); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter parameter1 = new ServiceParameter(); + parameter1.setId( + MessageFormat.format("{0}&^^&entityFilter", vmMetadata.getHeader().getId())); + parameter1.setCode("entityFilter"); + parameter1.setName("过滤条件"); + parameter1.setDescription("过滤条件"); + parameter1.setRetVal(false); + parameter1.setBasicType(true); + parameter1.setCollection(false); + parameter1.setListDeepth(0); + parameter1.setModelId("string"); + parameter1.setModelName("string"); + parameter1.setModelType(SgModelType.VO); + parameter1.setIn("Query"); + parameter1.setIsRequired(true); + operation.getParameters().add(parameter1); + + ServiceParameter parameter2 = new ServiceParameter(); + parameter2.setId(MessageFormat.format("{0}&^^&{1}", vmMetadata.getHeader().getId(), StringUtils.toCamelCase(viewModel.getMainObject().getCode()))); + parameter2.setCode(StringUtils.toCamelCase(viewModel.getMainObject().getCode())); + parameter2.setName(viewModel.getMainObject().getName()); + parameter2.setDescription("实体模型"); + parameter2.setRetVal(true); + parameter2.setBasicType(false); + parameter2.setCollection(true); + parameter2.setListDeepth(1); + parameter2.setModelId(vmMetadata.getHeader().getId()); + parameter2.setModelCode(vmMetadata.getHeader().getCode()); + parameter2.setModelName(vmMetadata.getHeader().getName()); + parameter2.setModelType(SgModelType.VO); + parameter2.setRefId(viewModel.getMainObject().getId()); + parameter2.setRefCode(viewModel.getMainObject().getCode()); + parameter2.setRefName(viewModel.getMainObject().getName()); + parameter2.setIn(""); + parameter2.setIsRequired(true); + operation.getParameters().add(parameter2); + + return operation; + } + + private static ServiceOperation retrieve(GspMetadata vmMetadata) { + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&Retrieve", vmMetadata.getHeader().getId())); + operation.setCode("Retrieve"); + operation.setName("数据检索"); + operation.setDescription("数据检索"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Retrieve", vmMetadata.getHeader().getId())); + operation.setHttpMethod("GET"); + operation.setTemplate("/{dataId}"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter param1 = new ServiceParameter(); + param1.setId(MessageFormat.format("{0}&^^&dataId", vmMetadata.getHeader().getId())); + param1.setCode("dataId"); + param1.setName("单据内码"); + param1.setDescription("单据内码"); + param1.setRetVal(false); + param1.setBasicType(true); + param1.setCollection(false); + param1.setListDeepth(0); + param1.setModelId("string"); + param1.setModelName("string"); + param1.setModelType(SgModelType.VO); + param1.setIn("Path"); + param1.setIsRequired(true); + operation.getParameters().add(param1); + + ServiceParameter param2 = new ServiceParameter(); + param2.setId(MessageFormat.format("{0}&^^&{1}", vmMetadata.getHeader().getId(), StringUtils.toCamelCase(viewModel.getMainObject().getCode()))); + //code要做ToCamel处理 + param2.setCode(StringUtils.toCamelCase(viewModel.getMainObject().getCode())); + param2.setName(viewModel.getMainObject().getName()); + param2.setDescription("实体模型"); + param2.setRetVal(true); + param2.setBasicType(false); + param2.setCollection(false); + param2.setListDeepth(0); + param2.setModelId(vmMetadata.getHeader().getId()); + param2.setModelCode(vmMetadata.getHeader().getCode()); + param2.setModelName(vmMetadata.getHeader().getName()); + param2.setModelType(SgModelType.VO); + param2.setRefId(viewModel.getMainObject().getId()); + param2.setRefCode(viewModel.getMainObject().getCode()); + param2.setRefName(viewModel.getMainObject().getName()); + param2.setIn(""); + param2.setIsRequired(true); + operation.getParameters().add(param2); + + return operation; + } + + private static ServiceOperation update(GspMetadata vmMetadata) { + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&Update", vmMetadata.getHeader().getId())); + operation.setCode("Update"); + operation.setName("更新"); + operation.setDescription("更新"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Update", vmMetadata.getHeader().getId())); + operation.setHttpMethod("PUT"); + operation.setTemplate(""); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + + ServiceParameter param = new ServiceParameter(); + param.setId(MessageFormat.format("{0}&^^&{1}", vmMetadata.getHeader().getId(), StringUtils.toCamelCase(viewModel.getMainObject().getCode()))); + param.setCode(StringUtils.toCamelCase(viewModel.getMainObject().getCode())); + param.setName(viewModel.getMainObject().getName()); + param.setDescription(viewModel.getMainObject().getDescription()); + param.setRetVal(false); + param.setBasicType(false); + param.setCollection(false); + param.setListDeepth(0); + param.setModelId(vmMetadata.getHeader().getId()); + param.setModelCode(vmMetadata.getHeader().getCode()); + param.setModelName(vmMetadata.getHeader().getName()); + param.setModelType(SgModelType.VO); + param.setRefId(viewModel.getMainObject().getId()); + param.setRefCode(viewModel.getMainObject().getCode()); + param.setRefName(viewModel.getMainObject().getName()); + param.setIn("Body"); + param.setIsRequired(true); + operation.getParameters().add(param); + + ServiceParameter retParam = new ServiceParameter(); + retParam.setId(MessageFormat.format("{0}&^^&retParam", vmMetadata.getHeader().getId())); + retParam.setCode("return"); + retParam.setName("返回值"); + retParam.setDescription("返回值"); + retParam.setRetVal(true); + retParam.setBasicType(false); + retParam.setCollection(false); + retParam.setListDeepth(0); + retParam.setModelId(vmMetadata.getHeader().getId()); + retParam.setModelCode(vmMetadata.getHeader().getCode()); + retParam.setModelName(vmMetadata.getHeader().getName()); + retParam.setModelType(SgModelType.VO); + retParam.setRefId(viewModel.getMainObject().getId()); + retParam.setRefCode(viewModel.getMainObject().getCode()); + retParam.setRefName(viewModel.getMainObject().getName()); + retParam.setIn(""); + retParam.setIsRequired(true); + operation.getParameters().add(retParam); + + return operation; + } + + private static ServiceOperation batchDelete(GspMetadata vmMetadata) { + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&BatchDelete", vmMetadata.getHeader().getId())); + operation.setCode("BatchDelete"); + operation.setName("批量删除"); + operation.setDescription("批量删除"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&BatchDelete", vmMetadata.getHeader().getId())); + operation.setHttpMethod("DELETE"); + operation.setTemplate(""); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter param = new ServiceParameter(); + param.setId( + MessageFormat.format("{0}&^^&ids", vmMetadata.getHeader().getId())); + param.setCode("ids"); + param.setName("单据内码列表"); + param.setDescription("单据内码列表"); + param.setRetVal(false); + param.setBasicType(true); + param.setCollection(false); + param.setListDeepth(0); + param.setModelId("string"); + param.setModelName("string"); + param.setModelType(SgModelType.VO); + param.setIn("Query"); + param.setIsRequired(true); + operation.getParameters().add(param); + + return operation; + } + + private static ServiceOperation delete(GspMetadata vmMetadata) { + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&Delete", vmMetadata.getHeader().getId())); + operation.setCode("Delete"); + operation.setName("删除"); + operation.setDescription("删除"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Delete", vmMetadata.getHeader().getId())); + operation.setHttpMethod("DELETE"); + operation.setTemplate("/{dataId}"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter param = new ServiceParameter(); + param.setId(MessageFormat.format("{0}&^^&dataId", vmMetadata.getHeader().getId())); + param.setCode("dataId"); + param.setName("单据内码"); + param.setDescription("单据内码"); + param.setRetVal(false); + param.setBasicType(true); + param.setCollection(false); + param.setListDeepth(0); + param.setModelId("string"); + param.setModelName("string"); + param.setModelType(SgModelType.VO); + param.setIn("Path"); + param.setIsRequired(true); + operation.getParameters().add(param); + + return operation; + } + + private static ServiceOperation create(GspMetadata vmMetadata) { + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&Create", vmMetadata.getHeader().getId())); + operation.setCode("Create"); + operation.setName("新增"); + operation.setDescription("新增"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&Create", vmMetadata.getHeader().getId())); + operation.setHttpMethod("POST"); + operation.setTemplate(""); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter param = new ServiceParameter(); + param.setId(MessageFormat.format("{0}&^^&{1}", vmMetadata.getHeader().getId(), StringUtils.toCamelCase(viewModel.getMainObject().getCode()))); + param.setCode(StringUtils.toCamelCase(viewModel.getMainObject().getCode())); + param.setName(viewModel.getMainObject().getName()); + param.setDescription(viewModel.getMainObject().getDescription()); + param.setRetVal(false); + param.setBasicType(false); + param.setCollection(false); + param.setListDeepth(0); + param.setModelId(vmMetadata.getHeader().getId()); + param.setModelCode(vmMetadata.getHeader().getCode()); + param.setModelName(vmMetadata.getHeader().getName()); + param.setModelType(SgModelType.VO); + param.setRefId(viewModel.getMainObject().getId()); + param.setRefCode(viewModel.getMainObject().getCode()); + param.setRefName(viewModel.getMainObject().getName()); + param.setIn("Body"); + param.setIsRequired(true); + operation.getParameters().add(param); + + + ServiceParameter retParam = new ServiceParameter(); + retParam.setId(MessageFormat.format("{0}&^^&retParam", vmMetadata.getHeader().getId())); + retParam.setCode("return"); + retParam.setName("返回值"); + retParam.setDescription("返回值"); + retParam.setRetVal(true); + retParam.setBasicType(false); + retParam.setCollection(false); + retParam.setListDeepth(0); + retParam.setModelId(vmMetadata.getHeader().getId()); + retParam.setModelCode(vmMetadata.getHeader().getCode()); + retParam.setModelName(vmMetadata.getHeader().getName()); + retParam.setModelType(SgModelType.VO); + retParam.setRefId(viewModel.getMainObject().getId()); + retParam.setRefCode(viewModel.getMainObject().getCode()); + retParam.setRefName(viewModel.getMainObject().getName()); + retParam.setIn(""); + retParam.setIsRequired(true); + operation.getParameters().add(retParam); + + return operation; + } + + private static ServiceOperation createDefaultValue(GspMetadata vmMetadata) { + GspViewModel viewModel = (GspViewModel) vmMetadata.getContent(); + ServiceOperation operation = new ServiceOperation(); + + operation.setId(MessageFormat.format("{0}&^^&CreateDefaultValue", vmMetadata.getHeader().getId())); + operation.setCode("CreateDefaultValue"); + operation.setName("新增"); + operation.setDescription("新增(返回默认数据)"); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&CreateDefaultValue", vmMetadata.getHeader().getId())); + operation.setHttpMethod("PUT"); + operation.setTemplate("/service/defaultvalue"); + operation.setDeprecated(false); + operation.setExtend1("Basic"); + + operation.setParameters(new ArrayList<>()); + + ServiceParameter retParam = new ServiceParameter(); + retParam.setId(MessageFormat.format("{0}&^^&retParam", vmMetadata.getHeader().getId())); + retParam.setCode("return"); + retParam.setName("返回值"); + retParam.setDescription("返回值"); + retParam.setRetVal(true); + retParam.setBasicType(false); + retParam.setCollection(false); + retParam.setListDeepth(0); + retParam.setModelId(vmMetadata.getHeader().getId()); + retParam.setModelCode(vmMetadata.getHeader().getCode()); + retParam.setModelName(vmMetadata.getHeader().getName()); + retParam.setModelType(SgModelType.VO); + retParam.setRefId(viewModel.getMainObject().getId()); + retParam.setRefCode(viewModel.getMainObject().getCode()); + retParam.setRefName(viewModel.getMainObject().getName()); + retParam.setIn(""); + retParam.setIsRequired(true); + operation.getParameters().add(retParam); + + return operation; + } +} 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 new file mode 100644 index 0000000..6a80d51 --- /dev/null +++ b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/basic/SimpleBasicActionSummary.java @@ -0,0 +1,113 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.provider.vo.basic; + +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.sgf.api.common.SummaryInfo; + +import java.util.ArrayList; +import java.util.List; + +/** + * 功能描述: + * + * @ClassName: SimpleBasicActionProvider + * @Author: Fynn Qi + * @Date: 2020/7/31 10:42 + * @Version: V1.0 + */ +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; + } + + 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-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/CustomActionProvider.java b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/CustomActionProvider.java new file mode 100644 index 0000000..7740ae4 --- /dev/null +++ b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/CustomActionProvider.java @@ -0,0 +1,252 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.provider.vo.custom; + +import com.inspur.edp.formserver.viewmodel.GspViewModel; +import com.inspur.edp.formserver.viewmodel.action.IViewModelParameter; +import com.inspur.edp.formserver.viewmodel.action.ViewModelAction; +import com.inspur.edp.formserver.viewmodel.common.VMCollectionParameterType; +import com.inspur.edp.formserver.viewmodel.common.VMParameterType; +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.sgf.api.entity.ServiceOperation; +import com.inspur.edp.sgf.api.entity.ServiceParameter; +import com.inspur.edp.sgf.api.entity.SgModelType; +import com.inspur.edp.sgf.provider.vo.basic.BasicActionSummary; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +/** + * 功能描述: @ClassName: CustomActionProvider @Author: Fynn Qi @Date: 2020/2/3 16:54 @Version: V1.0 + */ +@Slf4j +public class CustomActionProvider { + + public static List getCustomActions(GspMetadata gspMetadata) { + GspViewModel viewModel = (GspViewModel) gspMetadata.getContent(); + List actions = viewModel.getActions(); + return actionToServiceOperation(actions, gspMetadata, viewModel); + } + + /** + * 根据ViewModelAction生成ServiceOperation + * + * @param actions ViewModelAction列表 + * @param voMetadata 元数据 + * @param viewModel vo视图模型 + * @return 生成的ServiceOperation列表,非null + */ + private static List actionToServiceOperation(List actions, + GspMetadata voMetadata, GspViewModel viewModel) { + List operations = new ArrayList<>(); + //动作编号集合,用于判断该动作编号是否已被添加至eapi的操作列表,避免相同动作编号的动作导致eapi生成代码报错 + Set customActionCodeSet = new HashSet<>(); + for (ViewModelAction action : actions) { + long count = + BasicActionSummary.getBasicActions(voMetadata).stream() + .filter(x -> x.getCode().equals(action.getCode())) + .count(); + if (count > 0) { + throw new RuntimeException( + String.format( + "操作编号%s为预置的基本操作编号,请修改%s[ID:%s]的自定义动作编号", + action.getCode(), viewModel.getCode(), viewModel.getID())); + } + //检查vo上是否存在相同编号的动作,保证每个编号的动作仅添加一次 + if (customActionCodeSet.contains(action.getCode())) { + log.error(String.format("根据vo上的自定义动作生成eapi操作时出错,vo【code:%s,ID:%s】上存在相同动作编号(code:%s)的动作,请检查对应vo元数据。该编号的动作仅向eapi添加一个", + voMetadata.getHeader().getCode(), voMetadata.getHeader().getId(), action.getCode())); + } else { + ServiceOperation operation = new ServiceOperation(); + operation.setId(MessageFormat.format("{0}&^^&{1}", action.getID(), action.getCode())); + operation.setCode(action.getCode()); + operation.setName(action.getName()); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&{1}", action.getID(), action.getCode())); + operation.setDescription(action.getName()); + operation.setHttpMethod("PUT"); + operation.setTemplate("/service/" + action.getCode().toLowerCase()); + operation.setDeprecated(false); + operation.setExtend1("Custom"); + operation.setParameters(getParams(action, voMetadata)); + + operations.add(operation); + //添加动作编号至集合中 + customActionCodeSet.add(action.getCode()); + } + } + return operations; + } + + public static List getParams(ViewModelAction action, GspMetadata gspMetadata) { + List parameters = new ArrayList<>(getInputParams(action)); + ServiceParameter retParam = getActionReturnParam(action, gspMetadata); + if (retParam != null && StringUtils.isNotBlank(retParam.getId())) { + parameters.add(retParam); + } + return parameters; + } + + public static List getInputParams(ViewModelAction action) { + List parameters = new ArrayList<>(); + parameters.add(buildRequestInfoParam(action)); + if (action.getParameterCollection() != null && action.getParameterCollection().getCount() > 0) { + Iterator it = action.getParameterCollection().iterator(); + while (it.hasNext()) { + IViewModelParameter param = it.next(); + ServiceParameter serviceParam = getActionParam(param); + if (serviceParam != null && StringUtils.isNotBlank(serviceParam.getId())) { + parameters.add(serviceParam); + } + } + } + return parameters; + } + + public static ServiceParameter buildRequestInfoParam(ViewModelAction action) { + ServiceParameter requestInfoParam = new ServiceParameter(); + requestInfoParam.setId(MessageFormat.format("{0}&^^&RequestInfo", action.getID())); + requestInfoParam.setCode("requestInfo"); + requestInfoParam.setName("请求信息"); + requestInfoParam.setDescription("请求信息"); + requestInfoParam.setRetVal(false); + requestInfoParam.setBasicType(false); + requestInfoParam.setCollection(false); + requestInfoParam.setListDeepth(0); + requestInfoParam.setModelId(MessageFormat.format("{0}&^^&RequestInfo", action.getID())); + requestInfoParam.setModelCode("RequestInfo"); + requestInfoParam.setModelName("RequestInfo"); + requestInfoParam.setModelType(SgModelType.DTO); + requestInfoParam.setRefId(MessageFormat.format("{0}&^^&RequestInfo", action.getID())); + requestInfoParam.setRefCode("RequestInfo"); + requestInfoParam.setRefName("RequestInfo"); + requestInfoParam.setIn("Body"); + requestInfoParam.setIsRequired(false); + return requestInfoParam; + } + + private static ServiceParameter getActionReturnParam( + ViewModelAction action, GspMetadata gspMetadata) { + ServiceParameter responseInfoParam = new ServiceParameter(); + responseInfoParam.setId(MessageFormat.format("{0}&^^&ResponseInfo", action.getID())); + responseInfoParam.setCode("responseInfo"); + responseInfoParam.setName("响应信息"); + responseInfoParam.setDescription("响应信息"); + responseInfoParam.setRetVal(true); + responseInfoParam.setBasicType(false); + responseInfoParam.setCollection(false); + responseInfoParam.setListDeepth(0); + responseInfoParam.setModelId( + MessageFormat.format("{0}&^^&ResponseInfo", gspMetadata.getHeader().getId())); + responseInfoParam.setModelCode("ResponseInfo"); + responseInfoParam.setModelName("ResponseInfo"); + responseInfoParam.setModelType(SgModelType.DTO); + responseInfoParam.setRefId( + MessageFormat.format("{0}&^^&ResponseInfo", gspMetadata.getHeader().getId())); + responseInfoParam.setRefCode("ResponseInfo"); + responseInfoParam.setRefName("ResponseInfo"); + responseInfoParam.setIn(""); + responseInfoParam.setIsRequired(true); + + return responseInfoParam; + } + + private static ServiceParameter getActionParam(IViewModelParameter param) { + ServiceParameter serviceParam = new ServiceParameter(); + serviceParam.setId(MessageFormat.format("{0}&^^&{1}", param.getID(), param.getParamCode())); + serviceParam.setCode(param.getParamCode()); + serviceParam.setName(param.getParamName()); + serviceParam.setDescription(param.getParamDescription()); + serviceParam.setRetVal(false); + serviceParam.setCollection(false); + serviceParam.setListDeepth(0); + + if (param.getCollectionParameterType() == VMCollectionParameterType.List + || param.getCollectionParameterType() == VMCollectionParameterType.Array) { + serviceParam.setCollection(true); + serviceParam.setListDeepth(1); + } + serviceParam.setIn("Body"); + serviceParam.setIsRequired(true); + boolean isBasicType = isBasicType(param.getParameterType()); + String typeString = getTypeInfo(param.getParameterType()); + if (isBasicType) { + serviceParam.setBasicType(true); + serviceParam.setModelId(typeString); + serviceParam.setModelName(typeString); + } else { + serviceParam.setBasicType(false); + serviceParam.setModelType(SgModelType.DTO); + serviceParam.setModelId(typeString); + serviceParam.setModelCode(typeString); + serviceParam.setModelName(typeString); + serviceParam.setRefId(typeString); + serviceParam.setRefCode(typeString); + serviceParam.setRefName(typeString); + } + return serviceParam; + } + + private static String getTypeInfo(VMParameterType vMParameterType) { + String typestring = ""; + switch (vMParameterType) { + case Boolean: + typestring = "bool"; + break; + case DateTime: + typestring = "DateTime"; + break; + case Decimal: + typestring = "Decimal"; + break; + case Double: + typestring = "double"; + break; + case Int32: + typestring = "int"; + break; + case String: + typestring = "string"; + break; + case Object: + case Custom: + default: + typestring = "object"; + break; + } + return typestring; + } + + private static boolean isBasicType(VMParameterType vMParameterType) { + switch (vMParameterType) { + case Boolean: + case DateTime: + case Decimal: + case Double: + case Int32: + case String: + case Object: + return true; + default: + return false; + } + } +} diff --git a/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/CustomActionSummary.java b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/CustomActionSummary.java new file mode 100644 index 0000000..6e7e16e --- /dev/null +++ b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/CustomActionSummary.java @@ -0,0 +1,55 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.provider.vo.custom; + +import com.inspur.edp.formserver.viewmodel.GspViewModel; +import com.inspur.edp.formserver.viewmodel.action.ViewModelAction; +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.sgf.api.common.SummaryInfo; +import com.inspur.edp.sgf.provider.vo.basic.BasicActionSummary; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; + +/** + * 功能描述: @ClassName: CustomActionSummary @Author: Fynn Qi @Date: 2020/8/26 14:03 @Version: V1.0 + */ +public class CustomActionSummary { + + public static List getCustomActions(GspMetadata gspMetadata) { + List operations = new ArrayList<>(); + GspViewModel viewModel = (GspViewModel) gspMetadata.getContent(); + List actions = viewModel.getActions(); + for (ViewModelAction action : actions) { + long count = + BasicActionSummary.getBasicActions(gspMetadata).stream() + .filter(x -> x.getCode().equals(action.getCode())) + .count(); + if (count > 0) { + throw new RuntimeException( + String.format( + "操作编号%s为预置的基本操作编号,请修改%s[ID:%s]的自定义动作编号", + action.getCode(), viewModel.getCode(), viewModel.getID())); + } + SummaryInfo operation = new SummaryInfo(); + operation.setId(MessageFormat.format("{0}&^^&{1}", action.getID(), action.getCode())); + operation.setCode(action.getCode()); + operation.setName(action.getName()); + operations.add(operation); + } + return operations; + } +} diff --git a/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/SimpleCustomActionProvider.java b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/SimpleCustomActionProvider.java new file mode 100644 index 0000000..48526ad --- /dev/null +++ b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/SimpleCustomActionProvider.java @@ -0,0 +1,228 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.provider.vo.custom; + +import com.inspur.edp.formserver.viewmodel.GspViewModel; +import com.inspur.edp.formserver.viewmodel.action.IViewModelParameter; +import com.inspur.edp.formserver.viewmodel.action.ViewModelAction; +import com.inspur.edp.formserver.viewmodel.common.VMCollectionParameterType; +import com.inspur.edp.formserver.viewmodel.common.VMParameterType; +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.sgf.api.entity.ServiceOperation; +import com.inspur.edp.sgf.api.entity.ServiceParameter; +import com.inspur.edp.sgf.api.entity.SgModelType; +import com.inspur.edp.sgf.provider.vo.basic.SimpleBasicActionSummary; +import lombok.extern.slf4j.Slf4j; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +/** + * 功能描述: @ClassName: SimpleCustomActionProvider @Author: Fynn Qi @Date: 2020/7/31 10:44 @Version: + * V1.0 + */ +@Slf4j +public class SimpleCustomActionProvider { + + public static List getSimpleCustomActions(GspMetadata gspMetadata) { + GspViewModel viewModel = (GspViewModel) gspMetadata.getContent(); + List actions = viewModel.getActions(); + return actionToServiceOperation(actions, gspMetadata, viewModel); + } + + /** + * 根据ViewModelAction生成ServiceOperation + * + * @param actions ViewModelAction列表 + * @param voMetadata 元数据 + * @param viewModel vo视图模型 + * @return 生成的ServiceOperation列表,非null + */ + private static List actionToServiceOperation(List actions, + GspMetadata voMetadata, GspViewModel viewModel) { + List operations = new ArrayList<>(); + //动作编号集合,用于判断该动作编号是否已被添加至eapi的操作列表,避免相同动作编号的动作导致eapi生成代码报错 + Set customActionCodeSet = new HashSet<>(); + for (ViewModelAction action : actions) { + long count = + SimpleBasicActionSummary.getSimpleBasicActions(voMetadata).stream() + .filter(x -> x.getCode().equals(action.getCode())) + .count(); + if (count > 0) { + throw new RuntimeException( + String.format( + "操作编号%s为预置的基本操作编号,请修改%s[ID:%s]的自定义动作编号", + action.getCode(), viewModel.getCode(), viewModel.getID())); + } + //检查vo上是否存在相同编号的动作,保证每个编号的动作仅添加一次 + if (customActionCodeSet.contains(action.getCode())) { + log.error(String.format("根据vo上的自定义动作生成eapi操作时出错,vo【code:%s,ID:%s】上存在相同动作编号(code:%s)的动作,请检查对应vo元数据。该编号的动作仅向eapi添加一个", + voMetadata.getHeader().getCode(), voMetadata.getHeader().getId(), action.getCode())); + } else { + ServiceOperation operation = new ServiceOperation(); + operation.setId(MessageFormat.format("{0}&^^&{1}", action.getID(), action.getCode())); + operation.setCode(action.getCode()); + operation.setName(action.getName()); + operation.setResourceOpId( + MessageFormat.format("{0}&^^&{1}", action.getID(), action.getCode())); + operation.setDescription(action.getName()); + operation.setHttpMethod("PUT"); + operation.setTemplate("/service/" + action.getCode().toLowerCase()); + operation.setDeprecated(false); + operation.setExtend1("Custom"); + operation.setParameters(getParams(action, voMetadata)); + + operations.add(operation); + //添加动作编号至集合中 + customActionCodeSet.add(action.getCode()); + } + } + return operations; + } + + public static List getParams(ViewModelAction action, GspMetadata gspMetadata) { + List parameters = new ArrayList<>(getInputParams(action)); + ServiceParameter retParam = getActionReturnParam(action, gspMetadata); + if (retParam != null) { + parameters.add(retParam); + } + return parameters; + } + + public static List getInputParams(ViewModelAction action) { + List parameters = new ArrayList<>(); + if (action.getParameterCollection() != null) { + Iterator it = action.getParameterCollection().iterator(); + while (it.hasNext()) { + IViewModelParameter param = it.next(); + ServiceParameter serviceParam = getActionParam(param); + parameters.add(serviceParam); + } + } + return parameters; + } + + private static ServiceParameter getActionReturnParam( + ViewModelAction action, GspMetadata gspMetadata) { + if (action.getReturnValue() == null) { + return null; + } + ServiceParameter retParam = new ServiceParameter(); + retParam.setId(MessageFormat.format("{0}&^^&retParam", action.getID())); + retParam.setCode("return"); + retParam.setName("返回值"); + retParam.setDescription("返回值"); + retParam.setRetVal(true); + retParam.setBasicType(false); + retParam.setCollection(false); + retParam.setListDeepth(0); + retParam.setModelId("object"); + retParam.setModelCode("object"); + retParam.setModelName("object"); + retParam.setModelType(SgModelType.DTO); + retParam.setRefId("object"); + retParam.setRefCode("object"); + retParam.setRefName("object"); + retParam.setIn(""); + retParam.setIsRequired(true); + + return retParam; + } + + private static ServiceParameter getActionParam(IViewModelParameter viewModelParam) { + ServiceParameter param = new ServiceParameter(); + param.setId( + MessageFormat.format("{0}&^^&{1}", viewModelParam.getID(), viewModelParam.getParamCode())); + param.setCode(viewModelParam.getParamCode()); + param.setName(viewModelParam.getParamName()); + param.setDescription(viewModelParam.getParamDescription()); + param.setRetVal(false); + param.setCollection(false); + param.setListDeepth(0); + + if (viewModelParam.getCollectionParameterType() == VMCollectionParameterType.List + || viewModelParam.getCollectionParameterType() == VMCollectionParameterType.Array) { + param.setCollection(true); + param.setListDeepth(1); + } + param.setIn("Body"); + param.setIsRequired(true); + boolean isBasicType = isBasicType(viewModelParam.getParameterType()); + String typeDesc = getTypeDesc(viewModelParam.getParameterType()); + if (isBasicType) { + param.setBasicType(true); + param.setModelId(typeDesc); + param.setModelName(typeDesc); + param.setModelType(SgModelType.VO); + } else { + param.setBasicType(false); + param.setModelType(SgModelType.DTO); + param.setModelId(typeDesc); + param.setModelCode(typeDesc); + param.setModelName(typeDesc); + param.setRefId(typeDesc); + param.setRefCode(typeDesc); + param.setRefName(typeDesc); + } + return param; + } + + private static String getTypeDesc(VMParameterType vMParameterType) { + String typestring = ""; + switch (vMParameterType) { + case Boolean: + typestring = "bool"; + break; + case DateTime: + typestring = "dateTime"; + break; + case Decimal: + typestring = "decimal"; + break; + case Double: + typestring = "double"; + break; + case Int32: + typestring = "int"; + break; + case String: + typestring = "string"; + break; + default: + typestring = "object"; + break; + } + return typestring; + } + + private static boolean isBasicType(VMParameterType vMParameterType) { + switch (vMParameterType) { + case Boolean: + case DateTime: + case Decimal: + case Double: + case Int32: + case String: + case Object: + return true; + default: + return false; + } + } +} diff --git a/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/SimpleCustomActionSummary.java b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/SimpleCustomActionSummary.java new file mode 100644 index 0000000..f11db7b --- /dev/null +++ b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/custom/SimpleCustomActionSummary.java @@ -0,0 +1,58 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.provider.vo.custom; + +import com.inspur.edp.formserver.viewmodel.GspViewModel; +import com.inspur.edp.formserver.viewmodel.action.ViewModelAction; +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.sgf.api.common.SummaryInfo; +import com.inspur.edp.sgf.provider.vo.basic.SimpleBasicActionSummary; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; + +/** + * 功能描述: @ClassName: SimpleCustomActionProvider @Author: Fynn Qi @Date: 2020/7/31 10:44 @Version: + * V1.0 + */ +public class SimpleCustomActionSummary { + + public static List getSimpleCustomActions(GspMetadata gspMetadata) { + GspViewModel viewModel = (GspViewModel) gspMetadata.getContent(); + List operations = new ArrayList<>(); + List actions = viewModel.getActions(); + for (ViewModelAction action : actions) { + long count = + SimpleBasicActionSummary.getSimpleBasicActions(gspMetadata).stream() + .filter(x -> x.getCode().equals(action.getCode())) + .count(); + if (count > 0) { + throw new RuntimeException( + String.format( + "操作编号%s为预置的基本操作编号,请修改%s[ID:%s]的自定义动作编号", + action.getCode(), viewModel.getCode(), viewModel.getID())); + } + + SummaryInfo operation = new SummaryInfo(); + operation.setId(MessageFormat.format("{0}&^^&{1}", action.getID(), action.getCode())); + operation.setCode(action.getCode()); + operation.setName(action.getName()); + + operations.add(operation); + } + return operations; + } +} diff --git a/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/utils/SimpleViewModelUtils.java b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/utils/SimpleViewModelUtils.java new file mode 100644 index 0000000..369d3a6 --- /dev/null +++ b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/utils/SimpleViewModelUtils.java @@ -0,0 +1,68 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.provider.vo.utils; + +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 com.inspur.edp.sgf.provider.vo.basic.SimpleBasicActionProvider; +import com.inspur.edp.sgf.provider.vo.basic.SimpleBasicActionSummary; +import com.inspur.edp.sgf.provider.vo.custom.SimpleCustomActionProvider; +import com.inspur.edp.sgf.provider.vo.custom.SimpleCustomActionSummary; + +import java.util.ArrayList; +import java.util.List; + +/** + * 功能描述: + * + * @ClassName: SimpleViewModelUtils + * @Author: Fynn Qi + * @Date: 2020/9/1 10:59 + * @Version: V1.0 + */ +public class SimpleViewModelUtils { + + public static List getAllOperations(GspMetadata metadata) { + List operations = new ArrayList<>(); + operations.addAll(SimpleBasicActionProvider.getSimpleBasicActions(metadata)); + operations.addAll(SimpleCustomActionProvider.getSimpleCustomActions(metadata)); + return operations; + } + + public static List getAllBasicOperations(GspMetadata metadata) { + return SimpleBasicActionProvider.getSimpleBasicActions(metadata); + } + + public static List getAllCustomOperations(GspMetadata metadata) { + return SimpleCustomActionProvider.getSimpleCustomActions(metadata); + } + + public static List getAllSummaryOperations(GspMetadata metadata) { + List operations = new ArrayList<>(); + operations.addAll(SimpleBasicActionSummary.getSimpleBasicActions(metadata)); + operations.addAll(SimpleCustomActionSummary.getSimpleCustomActions(metadata)); + return operations; + } + + public static List getAllBasicSummaryOperations(GspMetadata metadata) { + return SimpleBasicActionSummary.getSimpleBasicActions(metadata); + } + + public static List getAllCustomSummaryOperations(GspMetadata metadata) { + return SimpleCustomActionSummary.getSimpleCustomActions(metadata); + } + +} diff --git a/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/utils/ViewModelUtils.java b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/utils/ViewModelUtils.java new file mode 100644 index 0000000..5e63859 --- /dev/null +++ b/rest-api-provider-common/src/main/java/com/inspur/edp/sgf/provider/vo/utils/ViewModelUtils.java @@ -0,0 +1,67 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.provider.vo.utils; + +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 com.inspur.edp.sgf.provider.vo.basic.BasicActionProvider; +import com.inspur.edp.sgf.provider.vo.basic.BasicActionSummary; +import com.inspur.edp.sgf.provider.vo.custom.CustomActionProvider; +import com.inspur.edp.sgf.provider.vo.custom.CustomActionSummary; + +import java.util.ArrayList; +import java.util.List; + +/** + * 功能描述: + * + * @ClassName: ViewModelUtils + * @Author: Fynn Qi + * @Date: 2020/9/1 9:59 + * @Version: V1.0 + */ +public class ViewModelUtils { + + public static List getAllOperations(GspMetadata metadata) { + List operations = new ArrayList<>(); + operations.addAll(BasicActionProvider.getBasicActions(metadata)); + operations.addAll(CustomActionProvider.getCustomActions(metadata)); + return operations; + } + + public static List getAllBasicOperations(GspMetadata metadata) { + return BasicActionProvider.getBasicActions(metadata); + } + + public static List getAllCustomOperations(GspMetadata metadata) { + return CustomActionProvider.getCustomActions(metadata); + } + + public static List getAllSummaryOperations(GspMetadata metadata) { + List operations = new ArrayList<>(); + operations.addAll(BasicActionSummary.getBasicActions(metadata)); + operations.addAll(CustomActionSummary.getCustomActions(metadata)); + return operations; + } + + public static List getAllBasicSummaryOperations(GspMetadata metadata) { + return BasicActionSummary.getBasicActions(metadata); + } + + public static List getAllCustomSummaryOperations(GspMetadata metadata) { + return CustomActionSummary.getCustomActions(metadata); + } +} -- Gitee