From 3ec42020a3108f5d58dc7b2a7b883a3b1b6cda77 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Tue, 11 Oct 2022 10:55:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?style(VO-I18n):=20=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96=E6=9C=8D=E5=8A=A1=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增代码类注释、public方法注释 --- .../i18nservice/ViewModelI18nService.java | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/i18nservice/ViewModelI18nService.java b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/i18nservice/ViewModelI18nService.java index d388c2c..e86a056 100644 --- a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/i18nservice/ViewModelI18nService.java +++ b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/i18nservice/ViewModelI18nService.java @@ -24,18 +24,30 @@ import com.inspur.edp.formserver.viewmodel.i18n.merger.ViewModelResourceMerger; import com.inspur.edp.lcm.metadata.api.entity.*; import com.inspur.edp.lcm.metadata.spi.MetadataI18nService; +/** + * 视图模型国际化 + * + * @author haoxiaofei + */ public class ViewModelI18nService implements MetadataI18nService { + /** + * 国际化元数据合并 + * + * @param metadata 元数据 + * @param list 国际化资源 + * @return 合并后元数据 + */ public GspMetadata merge(GspMetadata metadata, java.util.List list) { - if (list==null || list.size()==0) + if (list == null || list.size() == 0) return metadata; if (!(metadata.getContent() instanceof GspViewModel)) - return metadata; - I18nResourceItemCollection resourceItems=list.get(0).getStringResources(); - if (resourceItems==null) return metadata; - GspViewModel viewModel= (GspViewModel) metadata.getContent(); - mergeViewModelResource(viewModel,resourceItems); + I18nResourceItemCollection resourceItems = list.get(0).getStringResources(); + if (resourceItems == null) + return metadata; + GspViewModel viewModel = (GspViewModel) metadata.getContent(); + mergeViewModelResource(viewModel, resourceItems); metadata.setContent(viewModel); return metadata; @@ -43,11 +55,17 @@ public class ViewModelI18nService implements MetadataI18nService { private void mergeViewModelResource(GspViewModel viewModel, I18nResourceItemCollection resourceItems) { - CefResourceMergeContext context=new CefResourceMergeContext(viewModel.getDotnetGeneratingAssembly(),resourceItems); - ViewModelResourceMerger merger=new ViewModelResourceMerger(viewModel,context); + CefResourceMergeContext context = new CefResourceMergeContext(viewModel.getDotnetGeneratingAssembly(), resourceItems); + ViewModelResourceMerger merger = new ViewModelResourceMerger(viewModel, context); merger.merge(); } + /** + * 获取元数据 Resource信息 + * + * @param metadata 元数据 + * @return 国际化资源 + */ public I18nResource getResourceItem(GspMetadata metadata) { I18nResource resource = new I18nResource(); resource.setResourceType(ResourceType.Metadata); -- Gitee From 67712acfebefaeecf8cd256c97abc260952b0166 Mon Sep 17 00:00:00 2001 From: haoxiaofei Date: Tue, 11 Oct 2022 11:02:26 +0800 Subject: [PATCH 2/2] =?UTF-8?q?style(VO-I18n):=20=E5=B8=AE=E5=8A=A9?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增代码类注释、public方法注释 --- .../HelpConfigFilterSortHandler.java | 383 +++++++++--------- 1 file changed, 196 insertions(+), 187 deletions(-) diff --git a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/helpconfig/HelpConfigFilterSortHandler.java b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/helpconfig/HelpConfigFilterSortHandler.java index a05783c..6f6f0ae 100644 --- a/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/helpconfig/HelpConfigFilterSortHandler.java +++ b/view-object-manager/src/main/java/com/inspur/edp/formserver/vmmanager/helpconfig/HelpConfigFilterSortHandler.java @@ -36,206 +36,215 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.UUID; +/** + * 帮助信息过滤排序Handler + * + * @author haoxiaofei + */ public class HelpConfigFilterSortHandler { - public static final String SORT_FILTER_CMPID = "07156c90-f6ee-4d1b-ad57-a40e4027c50c"; - public static final String FILTER_CONDITION_PROPERTY = "filterCondition"; - public static final String SORT_CONDITION_PROPERTY = "orderByCondition"; - public static final String COMMON_CMP_PKGNAME = "Inspur.Gsp.Common.CommonCmp.mdpkg"; + public static final String SORT_FILTER_CMPID = "07156c90-f6ee-4d1b-ad57-a40e4027c50c"; + + public static final String FILTER_CONDITION_PROPERTY = "filterCondition"; + + public static final String SORT_CONDITION_PROPERTY = "orderByCondition"; + + public static final String COMMON_CMP_PKGNAME = "Inspur.Gsp.Common.CommonCmp.mdpkg"; + + private MdpkgService mdpkgService; + + private MdpkgService getMdpkgService() { + if (mdpkgService == null) { + this.mdpkgService = SpringBeanUtils.getBean(MdpkgService.class); + } + return this.mdpkgService; + } + + private HashMap actionMap; + private ValueHelpConfig config; + private String metaPath; + + public HelpConfigFilterSortHandler(ValueHelpConfig config, String path) { - private MdpkgService mdpkgService; + this.config = config; + this.metaPath = path; + } - private MdpkgService getMdpkgService() { - if (mdpkgService == null) { - this.mdpkgService = SpringBeanUtils.getBean(MdpkgService.class); + public HelpConfigFilterSortHandler(ValueHelpConfig config) { + this.config = config; } - return this.mdpkgService; - } - - private HashMap actionMap; - private ValueHelpConfig config; - private String metaPath; - - public HelpConfigFilterSortHandler(ValueHelpConfig config, String path) { - - this.config = config; - this.metaPath = path; - } - - public HelpConfigFilterSortHandler(ValueHelpConfig config) { - this.config = config; - } - - public static HelpConfigFilterSortHandler getInstance(ValueHelpConfig config, String path) { - return new HelpConfigFilterSortHandler(config, path); - } - - public static HelpConfigFilterSortHandler getInstance(ValueHelpConfig config) { - return new HelpConfigFilterSortHandler(config); - } - /** - * 处理帮助配置中的过滤排序 - */ - public void handleConfigFilterAndSort(String newFilterCondition, String newSortCondition - ) { - // 无过滤条件且无排序条件,删除对应Action - if (isConditionNull(newSortCondition) && isConditionNull(newFilterCondition)) { - MappedCdpAction action = getCurrentAction(); - if (action != null) { - config.getHelpExtend().getBeforeHelp().remove(action); - } - return; + + public static HelpConfigFilterSortHandler getInstance(ValueHelpConfig config, String path) { + return new HelpConfigFilterSortHandler(config, path); } - // 有条件,无Action,新增对应Action - if (getCurrentAction() == null) { - VMActionCollection currentActions = config.getHelpExtend().getBeforeHelp().clone(); - config.getHelpExtend().getBeforeHelp().clear(); - config.getHelpExtend().getBeforeHelp() - .add(getHelpVOAction(config, newFilterCondition, newSortCondition)); - config.getHelpExtend().getBeforeHelp().addAll(currentActions); - // 添加元数据包引用 - addMetadataPkgDependency(metaPath); - return; + + public static HelpConfigFilterSortHandler getInstance(ValueHelpConfig config) { + return new HelpConfigFilterSortHandler(config); } - // 已有Action,赋值对应属性 - getCurrentAction().getParameterCollection().forEach(item -> { - ViewModelParameter para = (ViewModelParameter) item; - switch (para.getParamCode()) { - case FILTER_CONDITION_PROPERTY: - para.getActualValue().setValue(newFilterCondition); - break; - case SORT_CONDITION_PROPERTY: - para.getActualValue().setValue(newSortCondition); - break; - } - }); - } - - - public void handleRtConfigFilterAndSort(String newFilterCondition, String newSortCondition - ) { - // 无过滤条件且无排序条件,删除对应Action - if (isConditionNull(newSortCondition) && isConditionNull(newFilterCondition)) { - MappedCdpAction action = getCurrentAction(); - if (action != null) { - config.getHelpExtend().getBeforeHelp().remove(action); - } - return; + + /** + * 处理帮助配置中的过滤排序 + */ + public void handleConfigFilterAndSort(String newFilterCondition, String newSortCondition + ) { + // 无过滤条件且无排序条件,删除对应Action + if (isConditionNull(newSortCondition) && isConditionNull(newFilterCondition)) { + MappedCdpAction action = getCurrentAction(); + if (action != null) { + config.getHelpExtend().getBeforeHelp().remove(action); + } + return; + } + // 有条件,无Action,新增对应Action + if (getCurrentAction() == null) { + VMActionCollection currentActions = config.getHelpExtend().getBeforeHelp().clone(); + config.getHelpExtend().getBeforeHelp().clear(); + config.getHelpExtend().getBeforeHelp() + .add(getHelpVOAction(config, newFilterCondition, newSortCondition)); + config.getHelpExtend().getBeforeHelp().addAll(currentActions); + // 添加元数据包引用 + addMetadataPkgDependency(metaPath); + return; + } + // 已有Action,赋值对应属性 + getCurrentAction().getParameterCollection().forEach(item -> { + ViewModelParameter para = (ViewModelParameter) item; + switch (para.getParamCode()) { + case FILTER_CONDITION_PROPERTY: + para.getActualValue().setValue(newFilterCondition); + break; + case SORT_CONDITION_PROPERTY: + para.getActualValue().setValue(newSortCondition); + break; + } + }); } - // 有条件,无Action,新增对应Action - if (getCurrentAction() == null) { - VMActionCollection currentActions = config.getHelpExtend().getBeforeHelp().clone(); - config.getHelpExtend().getBeforeHelp().clear(); - config.getHelpExtend().getBeforeHelp() - .add(getHelpVOAction(config, newFilterCondition, newSortCondition)); - config.getHelpExtend().getBeforeHelp().addAll(currentActions); - // 添加元数据包引用 - //addMetadataPkgDependency(metaPath); - return; + + public void handleRtConfigFilterAndSort(String newFilterCondition, String newSortCondition + ) { + // 无过滤条件且无排序条件,删除对应Action + if (isConditionNull(newSortCondition) && isConditionNull(newFilterCondition)) { + MappedCdpAction action = getCurrentAction(); + if (action != null) { + config.getHelpExtend().getBeforeHelp().remove(action); + } + return; + } + // 有条件,无Action,新增对应Action + if (getCurrentAction() == null) { + VMActionCollection currentActions = config.getHelpExtend().getBeforeHelp().clone(); + config.getHelpExtend().getBeforeHelp().clear(); + config.getHelpExtend().getBeforeHelp() + .add(getHelpVOAction(config, newFilterCondition, newSortCondition)); + config.getHelpExtend().getBeforeHelp().addAll(currentActions); + // 添加元数据包引用 + //addMetadataPkgDependency(metaPath); + return; + } + // 已有Action,赋值对应属性 + getCurrentAction().getParameterCollection().forEach(item -> { + ViewModelParameter para = (ViewModelParameter) item; + switch (para.getParamCode()) { + case FILTER_CONDITION_PROPERTY: + para.getActualValue().setValue(newFilterCondition); + break; + case SORT_CONDITION_PROPERTY: + para.getActualValue().setValue(newSortCondition); + break; + } + }); } - // 已有Action,赋值对应属性 - getCurrentAction().getParameterCollection().forEach(item -> { - ViewModelParameter para = (ViewModelParameter) item; - switch (para.getParamCode()) { - case FILTER_CONDITION_PROPERTY: - para.getActualValue().setValue(newFilterCondition); - break; - case SORT_CONDITION_PROPERTY: - para.getActualValue().setValue(newSortCondition); - break; - } - }); - } - private MappedCdpAction getCurrentAction() { - if (actionMap == null) { - actionMap = new HashMap<>(); - MappedCdpAction action = (MappedCdpAction) config.getHelpExtend().getBeforeHelp() - .getItem(item -> (item instanceof MappedCdpAction) && ((MappedCdpAction) item) - .getComponentEntityId().equals(SORT_FILTER_CMPID)); - actionMap.put(config.getElementId(), action); + + private MappedCdpAction getCurrentAction() { + if (actionMap == null) { + actionMap = new HashMap<>(); + MappedCdpAction action = (MappedCdpAction) config.getHelpExtend().getBeforeHelp() + .getItem(item -> (item instanceof MappedCdpAction) && ((MappedCdpAction) item) + .getComponentEntityId().equals(SORT_FILTER_CMPID)); + actionMap.put(config.getElementId(), action); + } + return actionMap.get(config.getElementId()); } - return actionMap.get(config.getElementId()); - } - - /** - * 过滤排序条件是否为空 - */ - private Boolean isConditionNull(String currentSort) { - try { - if (CheckInfoUtil.checkNull(currentSort)) { - return true; - } - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode nodeList = objectMapper.readTree(currentSort); - if (nodeList.getNodeType() != JsonNodeType.ARRAY) { - return true; - } - return nodeList.size() == 0; - } catch (JsonProcessingException e) { - throw new RuntimeException(e); + + /** + * 过滤排序条件是否为空 + */ + private Boolean isConditionNull(String currentSort) { + try { + if (CheckInfoUtil.checkNull(currentSort)) { + return true; + } + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode nodeList = objectMapper.readTree(currentSort); + if (nodeList.getNodeType() != JsonNodeType.ARRAY) { + return true; + } + return nodeList.size() == 0; + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } } - } - - /** - * 添加元数据包引用 - */ - private void addMetadataPkgDependency(String path) { - if (CheckInfoUtil.checkNull(path)) { - return; + + /** + * 添加元数据包引用 + */ + private void addMetadataPkgDependency(String path) { + if (CheckInfoUtil.checkNull(path)) { + return; + } + ArrayList list = new ArrayList(); + list.add(COMMON_CMP_PKGNAME); + this.getMdpkgService().addDepedencyAndRestore(path, list); } - ArrayList list = new ArrayList(); - list.add(COMMON_CMP_PKGNAME); - this.getMdpkgService().addDepedencyAndRestore(path, list); - } - - /** - * 新增过滤排序Action - */ - private MappedCdpAction getHelpVOAction(ValueHelpConfig valueHelpConfig, String filterCondition, - String sortCondition) { - MappedCdpAction mappedCdpAction = new MappedCdpAction(); - mappedCdpAction.setIsGenerateComponent(false); - if (valueHelpConfig.getHelpExtend().getBeforeHelp().isEmpty()) { - mappedCdpAction.setID(Guid.newGuid().toString()); + + /** + * 新增过滤排序Action + */ + private MappedCdpAction getHelpVOAction(ValueHelpConfig valueHelpConfig, String filterCondition, + String sortCondition) { + MappedCdpAction mappedCdpAction = new MappedCdpAction(); + mappedCdpAction.setIsGenerateComponent(false); + if (valueHelpConfig.getHelpExtend().getBeforeHelp().isEmpty()) { + mappedCdpAction.setID(Guid.newGuid().toString()); + } + String originalKey = valueHelpConfig.getElementId(); //此ID分两段,用/区分 + String[] info = originalKey.split("[/]", -1); + if (info.length != 2) { + throw new RuntimeException("ValueHelpConfig对象的ElementId字段不符合约定"); + } + mappedCdpAction.setCode(info[1]); + mappedCdpAction.setName(info[1]); + mappedCdpAction.setComponentEntityId(SORT_FILTER_CMPID); + mappedCdpAction.setComponentName("VO帮助前支持过滤筛选构件"); + + MappedCdpActionParameter filterParameter = getPara(FILTER_CONDITION_PROPERTY, + FILTER_CONDITION_PROPERTY); + ViewModelParActualValue filterValue = new ViewModelParActualValue(); + filterValue.setHasValue(true); + filterValue.setEnable(true); + filterValue.setValue(filterCondition); + filterParameter.setActualValue(filterValue); + mappedCdpAction.getParameterCollection().add(filterParameter); + + MappedCdpActionParameter orderByParameter = getPara(SORT_CONDITION_PROPERTY, + SORT_CONDITION_PROPERTY); + ViewModelParActualValue orderByValue = new ViewModelParActualValue(); + orderByValue.setHasValue(true); + orderByValue.setEnable(true); + orderByValue.setValue(sortCondition); + orderByParameter.setActualValue(orderByValue); + mappedCdpAction.getParameterCollection().add(orderByParameter); + + return mappedCdpAction; } - String originalKey = valueHelpConfig.getElementId(); //此ID分两段,用/区分 - String[] info = originalKey.split("[/]", -1); - if (info.length != 2) { - throw new RuntimeException("ValueHelpConfig对象的ElementId字段不符合约定"); + + private MappedCdpActionParameter getPara(String code, String name) { + MappedCdpActionParameter para = new MappedCdpActionParameter(); + para.setID(UUID.randomUUID().toString()); + para.setParamName(name); + para.setParamCode(code); + para.setMode(VMParameterMode.IN); + return para; } - mappedCdpAction.setCode(info[1]); - mappedCdpAction.setName(info[1]); - mappedCdpAction.setComponentEntityId(SORT_FILTER_CMPID); - mappedCdpAction.setComponentName("VO帮助前支持过滤筛选构件"); - - MappedCdpActionParameter filterParameter = getPara(FILTER_CONDITION_PROPERTY, - FILTER_CONDITION_PROPERTY); - ViewModelParActualValue filterValue = new ViewModelParActualValue(); - filterValue.setHasValue(true); - filterValue.setEnable(true); - filterValue.setValue(filterCondition); - filterParameter.setActualValue(filterValue); - mappedCdpAction.getParameterCollection().add(filterParameter); - - MappedCdpActionParameter orderByParameter = getPara(SORT_CONDITION_PROPERTY, - SORT_CONDITION_PROPERTY); - ViewModelParActualValue orderByValue = new ViewModelParActualValue(); - orderByValue.setHasValue(true); - orderByValue.setEnable(true); - orderByValue.setValue(sortCondition); - orderByParameter.setActualValue(orderByValue); - mappedCdpAction.getParameterCollection().add(orderByParameter); - - return mappedCdpAction; - } - - private MappedCdpActionParameter getPara(String code, String name) { - MappedCdpActionParameter para = new MappedCdpActionParameter(); - para.setID(UUID.randomUUID().toString()); - para.setParamName(name); - para.setParamCode(code); - para.setMode(VMParameterMode.IN); - return para; - } } -- Gitee