From 8e43ec44ec02c668df8f23cb4162e1217eca5d37 Mon Sep 17 00:00:00 2001 From: "Jimmy.Zheng" Date: Thu, 20 Jul 2023 19:15:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3Demo=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/DemoComponentProvider.java | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/finebi/plugin/custom/component/DemoComponentProvider.java b/src/main/java/com/finebi/plugin/custom/component/DemoComponentProvider.java index 8ea8035..1a4e70a 100644 --- a/src/main/java/com/finebi/plugin/custom/component/DemoComponentProvider.java +++ b/src/main/java/com/finebi/plugin/custom/component/DemoComponentProvider.java @@ -1,14 +1,21 @@ package com.finebi.plugin.custom.component; -import com.finebi.common.api.service.plugin.common.context.OperationContext; -import com.finebi.common.api.service.plugin.component.AbstractCustomComponentProvider; +import com.finebi.common.context.OperationContext; +import com.finebi.provider.api.component.AbstractCustomComponentProvider; +import com.finebi.provider.api.component.CustomComponentContext; +import com.finebi.provider.api.component.DataModel; import com.fr.general.IOUtils; import com.fr.plugin.transform.ExecuteFunctionRecord; import com.fr.plugin.transform.FunctionRecorder; import com.fr.web.struct.AssembleComponent; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + @FunctionRecorder -public class DemoComponentProvider extends AbstractCustomComponentProvider{ +public class DemoComponentProvider extends AbstractCustomComponentProvider { /** * 自定义图表名称 */ @@ -63,7 +70,7 @@ public class DemoComponentProvider extends AbstractCustomComponentProvider{ public String getEditPageHTML(OperationContext context) { return "" + "" + - "
context:
" + context.getSystemInfo() + context.getUserInfo() + + "
context:
" + context.getSystemInfo().getServletURL() + context.getUserInfo().getDisplayName() + "
这是编辑
"; } @@ -83,4 +90,40 @@ public class DemoComponentProvider extends AbstractCustomComponentProvider{ public String config() { return IOUtils.readResourceAsString("com/finebi/plugin/custom/component/config.json"); } + + /** + * 返回是否需要进行自定义数据处理 + * + * @param customComponentContext 自定义图表相关的上下文信息,目前包含前端传的查询配置 + * @return 是否需要进行自定义数据处理 + */ + @Override + public boolean needDataProcess(CustomComponentContext customComponentContext) { + return true; + } + + /** + * 对BI计算后即将返回前端的数据进行自定义处理 + * + * @param dataModels 数据模型 + * @param customComponentContext 自定义图表相关的上下文信息,目前包含前端传的查询配置 + * @return 处理过的数据模型 + */ + @Override + public List process(List dataModels, CustomComponentContext customComponentContext) { + + return dataModels.stream().map(dataModel -> new DataModel() { + @Override + public List getFields() { + return dataModel.getFields(); + } + + @Override + public List> getColData() { + List> colData = new ArrayList<>(dataModel.getFields().size()); + dataModel.getColData().forEach(d -> colData.add(Collections.singletonList(d.get(0)))); + return colData; + } + }).collect(Collectors.toList()); + } }