From bf8d6fbe99769688bcb3e20b5ee1b07241027e32 Mon Sep 17 00:00:00 2001 From: abel Date: Fri, 21 Dec 2018 15:57:11 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-13573=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E9=A2=84=E8=A7=88=E5=A4=A7=E6=A8=A1=E6=9D=BF=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E5=8D=A1=E9=A1=BF=EF=BC=88=E5=B0=86?= =?UTF-8?q?=E4=BC=A0=E8=BE=93=E5=85=A8=E9=83=A8=E6=A8=A1=E6=9D=BF=E6=94=B9?= =?UTF-8?q?=E6=88=90=E5=8F=AA=E4=BC=A0=E6=95=B0=E6=8D=AE=E9=9B=86=EF=BC=89?= =?UTF-8?q?&&=20=E5=8F=AA=E5=90=AB=E6=95=B0=E6=8D=AE=E9=9B=86=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=BA=8F=E5=88=97=E5=8C=96=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/DesignTableDataManager.java | 15 +- .../design/AbstractTableDatasourceTest.java | 166 ++++++++++++++++++ 2 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 designer-base/src/test/java/com/fr/design/AbstractTableDatasourceTest.java diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index ec1f69d98b..ee7df60151 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -3,6 +3,7 @@ package com.fr.design.data; import com.fr.base.FRContext; import com.fr.base.StoreProcedureParameter; import com.fr.base.TableData; +import com.fr.data.AbstractTableDataSource; import com.fr.data.TableDataSource; import com.fr.data.core.DataCoreXmlUtils; import com.fr.data.impl.EmbeddedTableData; @@ -444,7 +445,19 @@ public abstract class DesignTableDataManager { parameter.setValue(parameterMap.get(parameter.getName())); } } - return DataOperator.getInstance().previewTableData(tableDataSource, tabledata, parameterMap, rowCount); + //这边数据集预览不需要把整个模板都发送过去,只需要把模板中的数据集挑出来,传过去就行了。模板一大,预览数据集很变得很慢。 + TableDataSource wrapper = null; + if (tableDataSource != null) { + wrapper = new AbstractTableDataSource(){}; + for (Iterator it = tableDataSource.getTableDataNameIterator(); it != null && it.hasNext(); ) { + String name = it.next(); + TableData tableData = tableDataSource.getTableData(name); + if (tableData != null) { + wrapper.putTableData(name, tableData); + } + } + } + return DataOperator.getInstance().previewTableData(wrapper, tabledata, parameterMap, rowCount); } catch (Exception e) { throw new TableDataException(e.getMessage(), e); } finally { diff --git a/designer-base/src/test/java/com/fr/design/AbstractTableDatasourceTest.java b/designer-base/src/test/java/com/fr/design/AbstractTableDatasourceTest.java new file mode 100644 index 0000000000..e75ec4eb19 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/AbstractTableDatasourceTest.java @@ -0,0 +1,166 @@ +package com.fr.design; + +import com.fr.base.AbstractTableData; +import com.fr.base.TableData; +import com.fr.cert.token.lang.Assert; +import com.fr.data.AbstractTableDataSource; +import com.fr.data.TableDataSource; +import com.fr.general.data.TableDataException; +import com.fr.script.Calculator; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLableReader; +import com.fr.third.javax.xml.stream.XMLStreamException; +import junit.framework.TestCase; + +import java.io.ByteArrayOutputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; + +public class AbstractTableDatasourceTest extends TestCase { + + public void testAbstractTableDataSourceReadAndWrite() throws XMLStreamException, TableDataException, UnsupportedEncodingException { + String xml = "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "7.nI9\\uimQ~\n" + + "]]>\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "9UT+>AM9kpGY!\\4\\SXO$EO1[i^/XKmIMmdu\n" + + "!\"Q5sC\"9Ji(qlAa_kVTnCC/+p:XVF.KGR?GMsmI)2\">1s>(/T71G7cFsfA\"UpjYr4R)A14-*\n" + + "qc6ri_1*%/XSsf!PM]ARc+ojE:eo:_gma!ut7eZ6BoFc2b5hu4@TUtuOT);aq6l4Vj\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "YfS3J$NPo=IB3AP?eiop.bk9Qu\n" + + "P:F\\.L&t$31~\n" + + "]]>\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "5++,D>0thk;G<`mPXn.b)QZb5j^mQri%8Ji5q\\\n" + + "\n" + + "\n"; + + AbstractTableDataSource source = new AbstractTableDataSource() { + }; + XMLableReader.createXMLableReader(xml).readXMLObject(source); + TableData tableData = source.getTableData("热销产品"); + Assert.notNull(tableData); + Assert.isTrue(tableData.createDataModel(Calculator.createCalculator()).getRowCount() == 4); + Assert.isTrue(tableData.createDataModel(Calculator.createCalculator()).getColumnCount() == 2); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + XMLPrintWriter writer = XMLPrintWriter.create(new OutputStreamWriter(out,"UTF-8")); + source.writeXML(writer); + writer.close(); + TableDataSource another = new AbstractTableDataSource(){}; + XMLableReader.createXMLableReader(new String(out.toByteArray(),"UTF-8")).readXMLObject(another); + tableData = another.getTableData("热销产品"); + Assert.notNull(tableData); + Assert.isTrue(tableData.createDataModel(Calculator.createCalculator()).getRowCount() == 4); + Assert.isTrue(tableData.createDataModel(Calculator.createCalculator()).getColumnCount() == 2); + } +} From 1f1c2cb4c0df44984d67d18bf6cf0963f5659e03 Mon Sep 17 00:00:00 2001 From: abel Date: Fri, 21 Dec 2018 16:01:17 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=A4=A7=E6=A8=A1=E6=9D=BF=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E9=A2=84=E8=A7=88=E6=80=A7=E8=83=BD=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...stractTableDatasourceTest.java => TableDatasourceTest.java} | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) rename designer-base/src/test/java/com/fr/design/{AbstractTableDatasourceTest.java => TableDatasourceTest.java} (99%) diff --git a/designer-base/src/test/java/com/fr/design/AbstractTableDatasourceTest.java b/designer-base/src/test/java/com/fr/design/TableDatasourceTest.java similarity index 99% rename from designer-base/src/test/java/com/fr/design/AbstractTableDatasourceTest.java rename to designer-base/src/test/java/com/fr/design/TableDatasourceTest.java index e75ec4eb19..ed6aa3657a 100644 --- a/designer-base/src/test/java/com/fr/design/AbstractTableDatasourceTest.java +++ b/designer-base/src/test/java/com/fr/design/TableDatasourceTest.java @@ -13,11 +13,10 @@ import com.fr.third.javax.xml.stream.XMLStreamException; import junit.framework.TestCase; import java.io.ByteArrayOutputStream; -import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; -public class AbstractTableDatasourceTest extends TestCase { +public class TableDatasourceTest extends TestCase { public void testAbstractTableDataSourceReadAndWrite() throws XMLStreamException, TableDataException, UnsupportedEncodingException { String xml = "\n" + From 80e049a6275959345f94cf584e278d56d8603b80 Mon Sep 17 00:00:00 2001 From: abel Date: Thu, 27 Dec 2018 14:34:12 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-13573=20=E8=BF=9C=E7=A8=8B=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E6=8A=A5=E8=A1=A8=E6=95=B0=E6=8D=AE=E9=9B=86=EF=BC=8C?= =?UTF-8?q?=E4=BC=9A=E6=8A=8A=E6=8A=A5=E8=A1=A8=E4=BC=A0=E5=88=B0=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=EF=BC=8C=E6=8A=A5=E8=A1=A8=E6=AF=94=E8=BE=83?= =?UTF-8?q?=E5=A4=A7=EF=BC=8C=E4=BC=9A=E6=9C=89=E6=80=A7=E8=83=BD=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E8=A3=81=E5=89=AA=E4=B8=80=E4=B8=8B=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=EF=BC=8C=E5=8F=AA=E6=8A=8A=E9=9C=80=E8=A6=81=E7=9A=84?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=8F=91=E8=BF=87=E5=8E=BB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/DesignTableDataManager.java | 16 +- .../com/fr/design/TableDatasourceTest.java | 165 ------------------ 2 files changed, 2 insertions(+), 179 deletions(-) delete mode 100644 designer-base/src/test/java/com/fr/design/TableDatasourceTest.java diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index ee7df60151..fc5e8b54fc 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -3,8 +3,8 @@ package com.fr.design.data; import com.fr.base.FRContext; import com.fr.base.StoreProcedureParameter; import com.fr.base.TableData; -import com.fr.data.AbstractTableDataSource; import com.fr.data.TableDataSource; +import com.fr.data.TableDataSourceTailor; import com.fr.data.core.DataCoreXmlUtils; import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.storeproc.ProcedureDataModel; @@ -445,19 +445,7 @@ public abstract class DesignTableDataManager { parameter.setValue(parameterMap.get(parameter.getName())); } } - //这边数据集预览不需要把整个模板都发送过去,只需要把模板中的数据集挑出来,传过去就行了。模板一大,预览数据集很变得很慢。 - TableDataSource wrapper = null; - if (tableDataSource != null) { - wrapper = new AbstractTableDataSource(){}; - for (Iterator it = tableDataSource.getTableDataNameIterator(); it != null && it.hasNext(); ) { - String name = it.next(); - TableData tableData = tableDataSource.getTableData(name); - if (tableData != null) { - wrapper.putTableData(name, tableData); - } - } - } - return DataOperator.getInstance().previewTableData(wrapper, tabledata, parameterMap, rowCount); + return DataOperator.getInstance().previewTableData(TableDataSourceTailor.extractTableData(tableDataSource), tabledata, parameterMap, rowCount); } catch (Exception e) { throw new TableDataException(e.getMessage(), e); } finally { diff --git a/designer-base/src/test/java/com/fr/design/TableDatasourceTest.java b/designer-base/src/test/java/com/fr/design/TableDatasourceTest.java deleted file mode 100644 index ed6aa3657a..0000000000 --- a/designer-base/src/test/java/com/fr/design/TableDatasourceTest.java +++ /dev/null @@ -1,165 +0,0 @@ -package com.fr.design; - -import com.fr.base.AbstractTableData; -import com.fr.base.TableData; -import com.fr.cert.token.lang.Assert; -import com.fr.data.AbstractTableDataSource; -import com.fr.data.TableDataSource; -import com.fr.general.data.TableDataException; -import com.fr.script.Calculator; -import com.fr.stable.xml.XMLPrintWriter; -import com.fr.stable.xml.XMLableReader; -import com.fr.third.javax.xml.stream.XMLStreamException; -import junit.framework.TestCase; - -import java.io.ByteArrayOutputStream; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; - -public class TableDatasourceTest extends TestCase { - - public void testAbstractTableDataSourceReadAndWrite() throws XMLStreamException, TableDataException, UnsupportedEncodingException { - String xml = "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "7.nI9\\uimQ~\n" + - "]]>\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "9UT+>AM9kpGY!\\4\\SXO$EO1[i^/XKmIMmdu\n" + - "!\"Q5sC\"9Ji(qlAa_kVTnCC/+p:XVF.KGR?GMsmI)2\">1s>(/T71G7cFsfA\"UpjYr4R)A14-*\n" + - "qc6ri_1*%/XSsf!PM]ARc+ojE:eo:_gma!ut7eZ6BoFc2b5hu4@TUtuOT);aq6l4Vj\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "YfS3J$NPo=IB3AP?eiop.bk9Qu\n" + - "P:F\\.L&t$31~\n" + - "]]>\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "5++,D>0thk;G<`mPXn.b)QZb5j^mQri%8Ji5q\\\n" + - "\n" + - "\n"; - - AbstractTableDataSource source = new AbstractTableDataSource() { - }; - XMLableReader.createXMLableReader(xml).readXMLObject(source); - TableData tableData = source.getTableData("热销产品"); - Assert.notNull(tableData); - Assert.isTrue(tableData.createDataModel(Calculator.createCalculator()).getRowCount() == 4); - Assert.isTrue(tableData.createDataModel(Calculator.createCalculator()).getColumnCount() == 2); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - XMLPrintWriter writer = XMLPrintWriter.create(new OutputStreamWriter(out,"UTF-8")); - source.writeXML(writer); - writer.close(); - TableDataSource another = new AbstractTableDataSource(){}; - XMLableReader.createXMLableReader(new String(out.toByteArray(),"UTF-8")).readXMLObject(another); - tableData = another.getTableData("热销产品"); - Assert.notNull(tableData); - Assert.isTrue(tableData.createDataModel(Calculator.createCalculator()).getRowCount() == 4); - Assert.isTrue(tableData.createDataModel(Calculator.createCalculator()).getColumnCount() == 2); - } -}