Browse Source

Pull request #1655: REPORT-30889 组件是否复用的埋点

Merge in DESIGN/design from ~HARRISON/design:release/10.0 to release/10.0

* commit '39e5bcf935f9ccfa3c6ff18ddfec86cb6c8304db':
  REPORT-30889 组件是否复用的埋点 埋点迁移至主 jar 中。
feature/big-screen
Harrison 5 years ago
parent
commit
ed7d12974d
  1. 7
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java
  2. 3
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateProcessInfo.java
  3. 17
      designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java
  4. 24
      designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java
  5. 5
      designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java

7
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java

@ -10,9 +10,10 @@ import com.fr.json.JSONObject;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.joda.time.DateTime;
import java.util.HashMap;
import java.util.Map;
import com.fr.third.joda.time.DateTime;
/**
* 对应一张模版的记录
@ -42,6 +43,7 @@ public class TemplateInfo extends AbstractPointInfo {
private static final String ATTR_SAVE_RECORD = "saveRecord";
private static final String ATTR_PARA_APPLY = "paraApply";
private static final String ATTR_COMPONENTS_INFO = "components_info";
private static final String ATTR_REUSE_CMP_LIST = "reuseCmptList";
private static final String TEST_TEMPLATE_FLAG = "test_template";
@ -148,6 +150,7 @@ public class TemplateInfo extends AbstractPointInfo {
writer.attr(ATTR_REPORT_TYPE, (int) processMap.get(ATTR_REPORT_TYPE));
writer.attr(ATTR_PARA_APPLY, (int) processMap.get(ATTR_PARA_APPLY));
writer.attr(ATTR_COMPONENTS_INFO, (String) processMap.get(ATTR_COMPONENTS_INFO));
writer.attr(ATTR_REUSE_CMP_LIST, (String) processMap.get(ATTR_REUSE_CMP_LIST));
writer.end();
}
@ -179,6 +182,7 @@ public class TemplateInfo extends AbstractPointInfo {
processMap.put(ATTR_REPORT_TYPE, reader.getAttrAsInt(ATTR_REPORT_TYPE, 0));
processMap.put(ATTR_PARA_APPLY, reader.getAttrAsInt(ATTR_PARA_APPLY, 0));
processMap.put(ATTR_COMPONENTS_INFO, reader.getAttrAsString(ATTR_COMPONENTS_INFO, StringUtils.EMPTY));
processMap.put(ATTR_REUSE_CMP_LIST, reader.getAttrAsString(ATTR_REUSE_CMP_LIST, StringUtils.EMPTY));
processMap.put(ATTR_TEMPLATE_ID, templateID);
} else if (XML_CONSUMING_MAP.equals(name)) {
consumingMap.put(ATTR_CREATE_TIME, reader.getAttrAsString(ATTR_CREATE_TIME, StringUtils.EMPTY));
@ -238,6 +242,7 @@ public class TemplateInfo extends AbstractPointInfo {
processMap.put(ATTR_WIDGET_COUNT, processInfo.getWidgetCount());
processMap.put(ATTR_PARA_APPLY, processInfo.useParaPane() ? 1 : 0);
processMap.put(ATTR_COMPONENTS_INFO, processInfo.getComponentsInfo().toString());
processMap.put(ATTR_REUSE_CMP_LIST, processInfo.getReuseCmpList().toString());
this.processMap = processMap;
}

3
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateProcessInfo.java

@ -45,6 +45,9 @@ public abstract class TemplateProcessInfo<T extends BaseBook> {
//获取组件信息
public abstract JSONArray getComponentsInfo();
//获取重用组件数
public abstract JSONArray getReuseCmpList();
public abstract void updateTemplateOperationInfo(TemplateOperate templateOption);

17
designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java

@ -6,7 +6,6 @@ import com.fr.invoke.Reflect;
import com.fr.json.JSON;
import com.fr.json.JSONArray;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FileUtils;
@ -18,6 +17,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
import java.io.File;
@ -34,6 +34,7 @@ import static org.junit.Assert.assertTrue;
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({ProductConstants.class, MarketConfig.class, DesignerEnvManager.class})
@SuppressStaticInitializationFor({"com.fr.jvm.assist.FineAssist"})
public class TemplateInfoCollectorTest {
private String filePath;
private String initialFileContent;
@ -58,6 +59,7 @@ public class TemplateInfoCollectorTest {
EasyMock.expect(mockProcessInfo.useParaPane()).andReturn(false).anyTimes();
EasyMock.expect(mockProcessInfo.getComponentsInfo()).andReturn(new JSONArray()).anyTimes();
EasyMock.expect(mockProcessInfo.isTestTemplate()).andReturn(true).anyTimes();
EasyMock.expect(mockProcessInfo.getReuseCmpList()).andReturn(JSONArray.create().add("reuse-id-1")).anyTimes();
EasyMock.replay(mockProcessInfo);
// 缓存 tpl.info
@ -102,7 +104,8 @@ public class TemplateInfoCollectorTest {
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," +
"\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}",
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\",\"reuseCmptList\":\"[\\\"reuse-id-1\\\"]\"" +
"}",
JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
Assert.assertEquals(71113, consumingMap.get("uid"));
@ -133,7 +136,8 @@ public class TemplateInfoCollectorTest {
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," +
"\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\",\"reuseCmptList\":\"[\\\"reuse-id-1\\\"]\"" +
"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
Assert.assertEquals(71113, consumingMap.get("uid"));
@ -159,9 +163,10 @@ public class TemplateInfoCollectorTest {
TemplateInfo templateInfo = getTemplateInfoByID(templateID);
Map processMap = Reflect.on(templateInfo).field("processMap").get();
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0,\"cell_count\":13," +
"\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," +
"\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\",\"reuseCmptList\":\"[\\\"reuse-id-1\\\"]\"" +
"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
Assert.assertEquals(71113, consumingMap.get("uid"));

24
designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java

@ -1,9 +1,12 @@
package com.fr.design.mainframe.template.info;
import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.form.FormElementCaseProvider;
import com.fr.form.main.Form;
import com.fr.form.main.WidgetGather;
import com.fr.form.main.WidgetUtil;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.BaseChartEditor;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.ElementCaseEditorProvider;
@ -175,6 +178,26 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
return ja;
}
@Override
public JSONArray getReuseCmpList() {
final JSONArray jo = JSONArray.create();
WLayout container = this.template.getContainer();
WidgetUtil.bfsTraversalWidget(container, new WidgetUtil.BfsWidgetGather<AbstractBorderStyleWidget>() {
@Override
public boolean dealWith(AbstractBorderStyleWidget styleWidget) {
ExtendSharableAttrMark widgetAttrMark = styleWidget.getWidgetAttrMark(ExtendSharableAttrMark.XML_TAG);
if (widgetAttrMark != null) {
String shareId = widgetAttrMark.getShareId();
jo.add(shareId);
return true;
}
return false;
}
}, AbstractBorderStyleWidget.class);
return jo;
}
@Override
public void updateTemplateOperationInfo(TemplateOperate templateOperate) {
if (ComparatorUtils.equals(ComponentCreateOperate.OPERATE_TYPE, templateOperate.getOperateType())) {
@ -184,6 +207,7 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
addComponentRemoveInfo(templateOperate.toJSONObject());
}
}
private void addComponentCreateInfo(JSONObject jsonObject) {
String componentID = jsonObject.getString("componentID");
componentProcessInfoMap.put(componentID, jsonObject);

5
designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java

@ -136,6 +136,11 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo<WorkBook> {
return new JSONArray();
}
@Override
public JSONArray getReuseCmpList() {
return JSONArray.create();
}
@Override
public void updateTemplateOperationInfo(TemplateOperate templateOption) {

Loading…
Cancel
Save