Skip to content

Commit c5f8d99

Browse files
committed
Update Reporting Engine
1 parent 2e427f4 commit c5f8d99

15 files changed

+969
-4
lines changed

Examples/DocsExamples/Java/src/main/java/DocsExamples/LINQ_Reporting_Engine/Tables.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
package DocsExamples.LINQ_Reporting_Engine;
22

33
import DocsExamples.DocsExamplesBase;
4-
import DocsExamples.LINQ_Reporting_Engine.Helpers.Common;
4+
import TestData.Common;
5+
import TestData.TestClasses.ContractTestClass;
6+
import TestData.TestClasses.ManagerTestClass;
57
import org.testng.annotations.Test;
68
import com.aspose.words.Document;
79
import com.aspose.words.ReportingEngine;
810

911
@Test
10-
class Tables extends DocsExamplesBase
12+
public class Tables extends DocsExamplesBase
1113
{
1214
@Test
1315
public void inTableAlternateContent() throws Exception
1416
{
1517
//ExStart:InTableAlternateContent
16-
Document doc = new Document(getMyDir() + "Reporting engine template - Total.docx");
18+
Document doc = new Document(getMyDir() + "ReportingEngine.Total.Java.docx");
1719

1820
ReportingEngine engine = new ReportingEngine();
21+
engine.getKnownTypes().add(ContractTestClass.class);
22+
1923
engine.buildReport(doc, Common.getContracts(), "Contracts");
2024

2125
doc.save(getArtifactsDir() + "ReportingEngine.InTableAlternateContent.docx");
@@ -26,9 +30,12 @@ public void inTableAlternateContent() throws Exception
2630
public void inTableMasterDetail() throws Exception
2731
{
2832
//ExStart:InTableMasterDetail
29-
Document doc = new Document(getMyDir() + "Reporting engine template - Nested data table.docx");
33+
Document doc = new Document(getMyDir() + "ReportingEngine.TestNestedDataTable.Java.docx");
3034

3135
ReportingEngine engine = new ReportingEngine();
36+
engine.getKnownTypes().add(ManagerTestClass.class);
37+
engine.getKnownTypes().add(ContractTestClass.class);
38+
3239
engine.buildReport(doc, Common.getManagers(), "Managers");
3340

3441
doc.save(getArtifactsDir() + "ReportingEngine.InTableMasterDetail.docx");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
package TestData;
2+
3+
//////////////////////////////////////////////////////////////////////////
4+
// Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved.
5+
//
6+
// This file is part of Aspose.Words. The source code in this file
7+
// is only intended as a supplement to the documentation, and is provided
8+
// "as is", without warranty of any kind, either expressed or implied.
9+
//////////////////////////////////////////////////////////////////////////
10+
11+
import TestData.TestClasses.ClientTestClass;
12+
import TestData.TestClasses.ContractTestClass;
13+
import TestData.TestClasses.ManagerTestClass;
14+
15+
import java.time.LocalDate;
16+
import java.util.ArrayList;
17+
18+
public class Common {
19+
private static ArrayList<ManagerTestClass> managers = new ArrayList<>();
20+
private static ArrayList<ContractTestClass> contracts = new ArrayList<>();
21+
private static ArrayList<ClientTestClass> clients = new ArrayList<>();
22+
23+
static {
24+
// --------------------------------------------------
25+
// First manager
26+
// --------------------------------------------------
27+
ManagerTestClass firstManager = new ManagerTestClass();
28+
firstManager.setName("John Smith");
29+
firstManager.setAge(36);
30+
31+
ArrayList<ContractTestClass> contracts = new ArrayList<>();
32+
{
33+
contracts.add(new ContractTestClass());
34+
{
35+
contracts.get(0).setManager(firstManager);
36+
contracts.get(0).setPrice(1200000f);
37+
contracts.get(0).setDate(LocalDate.of(2017, 1, 1));
38+
contracts.get(0).setClient(new ClientTestClass("A Company", "Australia", "219-241 Cleveland St STRAWBERRY HILLS NSW 1427"));
39+
}
40+
contracts.add(new ContractTestClass());
41+
{
42+
contracts.get(1).setManager(firstManager);
43+
contracts.get(1).setPrice(750000f);
44+
contracts.get(1).setDate(LocalDate.of(2017, 4, 1));
45+
contracts.get(1).setClient(new ClientTestClass("B Ltd.", "Brazil", "Avenida João Jorge, 112, ap. 31 Vila Industrial Campinas - SP 13035-680"));
46+
}
47+
contracts.add(new ContractTestClass());
48+
{
49+
contracts.get(2).setManager(firstManager);
50+
contracts.get(2).setPrice(350000f);
51+
contracts.get(2).setDate(LocalDate.of(2017, 7, 1));
52+
contracts.get(2).setClient(new ClientTestClass("C & D", "Canada", "101-3485 RUE DE LA MONTAGNE MONTRÉAL (QUÉBEC) H3G 2A6"));
53+
}
54+
}
55+
56+
firstManager.setContracts(contracts);
57+
58+
// --------------------------------------------------
59+
// Second manager
60+
// --------------------------------------------------
61+
ManagerTestClass secondManager = new ManagerTestClass();
62+
secondManager.setName("Tony Anderson");
63+
secondManager.setAge(37);
64+
65+
contracts = new ArrayList<>();
66+
{
67+
contracts.add(new ContractTestClass());
68+
{
69+
contracts.get(0).setManager(secondManager);
70+
contracts.get(0).setPrice(650000f);
71+
contracts.get(0).setDate(LocalDate.of(2017, 2, 1));
72+
contracts.get(0).setClient(new ClientTestClass("E Corp.", "445 Mount Eden Road Mount Eden Auckland 1024"));
73+
}
74+
contracts.add(new ContractTestClass());
75+
{
76+
contracts.get(1).setManager(secondManager);
77+
contracts.get(1).setPrice(550000f);
78+
contracts.get(1).setDate(LocalDate.of(2017, 8, 1));
79+
contracts.get(1).setClient(new ClientTestClass("F & Partners", "20 Greens Road Tuahiwi Kaiapoi 7691"));
80+
}
81+
}
82+
83+
secondManager.setContracts(contracts);
84+
85+
// --------------------------------------------------
86+
// Third manager
87+
// --------------------------------------------------
88+
ManagerTestClass thirdManager = new ManagerTestClass();
89+
thirdManager.setName("July James");
90+
thirdManager.setAge(38);
91+
92+
contracts = new ArrayList<>();
93+
{
94+
contracts.add(new ContractTestClass());
95+
{
96+
contracts.get(0).setManager(thirdManager);
97+
contracts.get(0).setPrice(350000f);
98+
contracts.get(0).setDate(LocalDate.of(2017, 2, 1));
99+
contracts.get(0).setClient(new ClientTestClass("G & Co.", "Greece", "Karkisias 6 GR-111 42 ATHINA GRÉCE"));
100+
}
101+
contracts.add(new ContractTestClass());
102+
{
103+
contracts.get(1).setManager(thirdManager);
104+
contracts.get(1).setPrice(250000f);
105+
contracts.get(1).setDate(LocalDate.of(2017, 5, 1));
106+
contracts.get(1).setClient(new ClientTestClass("H Group", "Hungary", "Budapest Fiktív utca 82., IV. em./28.2806"));
107+
}
108+
contracts.add(new ContractTestClass());
109+
{
110+
contracts.get(2).setManager(thirdManager);
111+
contracts.get(2).setPrice(100000f);
112+
contracts.get(2).setDate(LocalDate.of(2017, 7, 1));
113+
contracts.get(2).setClient(new ClientTestClass("I & Sons", "43 Vogel Street Roslyn Palmerston North 4414"));
114+
}
115+
contracts.add(new ContractTestClass());
116+
{
117+
contracts.get(3).setManager(thirdManager);
118+
contracts.get(3).setPrice(100000f);
119+
contracts.get(3).setDate(LocalDate.of(2017, 8, 1));
120+
contracts.get(3).setClient(new ClientTestClass("J Ent.", "Japan", "Hakusan 4-Chōme 3-2 Bunkyō-ku, TŌKYŌ 112-0001 Japan"));
121+
}
122+
}
123+
124+
thirdManager.setContracts(contracts);
125+
126+
managers.add(firstManager);
127+
managers.add(secondManager);
128+
managers.add(thirdManager);
129+
}
130+
131+
public static ArrayList<ManagerTestClass> getEmptyManagers() {
132+
return new ArrayList<>();
133+
}
134+
135+
public static ArrayList<ManagerTestClass> getManagers() {
136+
return managers;
137+
}
138+
139+
public static ArrayList<ClientTestClass> getClients() {
140+
for (ManagerTestClass manager : getManagers()) {
141+
for (ContractTestClass contract : manager.getContracts())
142+
clients.add(contract.getClient());
143+
}
144+
145+
return clients;
146+
}
147+
148+
public static ArrayList<ContractTestClass> getContracts() {
149+
for (ManagerTestClass manager : getManagers()) {
150+
for (ContractTestClass contract : manager.getContracts())
151+
contracts.add(contract);
152+
}
153+
154+
return contracts;
155+
}
156+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package TestData.TestBuilders;
2+
3+
//////////////////////////////////////////////////////////////////////////
4+
// Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved.
5+
//
6+
// This file is part of Aspose.Words. The source code in this file
7+
// is only intended as a supplement to the documentation, and is provided
8+
// "as is", without warranty of any kind, either expressed or implied.
9+
//////////////////////////////////////////////////////////////////////////
10+
11+
import TestData.TestClasses.ColorItemTestClass;
12+
13+
import java.awt.*;
14+
15+
public class ColorItemTestBuilder {
16+
private String mName;
17+
private Color mColor;
18+
private int mColorCode;
19+
private double mValue1;
20+
private double mValue2;
21+
private double mValue3;
22+
23+
public ColorItemTestBuilder() {
24+
mName = "DefaultName";
25+
mColor = Color.BLACK;
26+
mColorCode = Color.BLACK.getRGB();
27+
mValue1 = 1.0;
28+
mValue2 = 1.0;
29+
mValue3 = 1.0;
30+
}
31+
32+
public ColorItemTestBuilder withColor(final String name, final Color color) {
33+
mName = name;
34+
mColor = color;
35+
return this;
36+
}
37+
38+
public ColorItemTestBuilder withColorCode(final String name, final int colorCode) {
39+
mName = name;
40+
mColorCode = colorCode;
41+
return this;
42+
}
43+
44+
public ColorItemTestBuilder withColorAndValues(final String name, final Color color, final double value1,
45+
final double value2, final double value3) {
46+
mName = name;
47+
mColor = color;
48+
mValue1 = value1;
49+
mValue2 = value2;
50+
mValue3 = value3;
51+
return this;
52+
}
53+
54+
public ColorItemTestBuilder withColorCodeAndValues(final String name, final int colorCode, final double value1,
55+
final double value2, final double value3) {
56+
mName = name;
57+
mColorCode = colorCode;
58+
mValue1 = value1;
59+
mValue2 = value2;
60+
mValue3 = value3;
61+
return this;
62+
}
63+
64+
public ColorItemTestClass build() {
65+
return new ColorItemTestClass(mName, mColor, mColorCode, mValue1, mValue2, mValue3);
66+
}
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package TestData.TestBuilders;
2+
3+
//////////////////////////////////////////////////////////////////////////
4+
// Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved.
5+
//
6+
// This file is part of Aspose.Words. The source code in this file
7+
// is only intended as a supplement to the documentation, and is provided
8+
// "as is", without warranty of any kind, either expressed or implied.
9+
//////////////////////////////////////////////////////////////////////////
10+
11+
import TestData.TestClasses.DocumentTestClass;
12+
import com.aspose.words.Document;
13+
14+
import java.io.FileInputStream;
15+
16+
public class DocumentTestBuilder {
17+
private Document mDocument;
18+
private FileInputStream mDocumentStream;
19+
private byte[] mDocumentBytes;
20+
private String mDocumentString;
21+
22+
public DocumentTestBuilder() throws Exception {
23+
mDocument = new Document();
24+
mDocumentStream = null;
25+
mDocumentBytes = new byte[0];
26+
mDocumentString = "";
27+
}
28+
29+
public DocumentTestBuilder withDocument(final Document doc) {
30+
mDocument = doc;
31+
return this;
32+
}
33+
34+
public DocumentTestBuilder withDocumentStream(final FileInputStream stream) {
35+
mDocumentStream = stream;
36+
return this;
37+
}
38+
39+
public DocumentTestBuilder withDocumentBytes(final byte[] docBytes) {
40+
mDocumentBytes = docBytes;
41+
return this;
42+
}
43+
44+
public DocumentTestBuilder withDocumentString(final String docUri) {
45+
mDocumentString = docUri;
46+
return this;
47+
}
48+
49+
public DocumentTestClass build() {
50+
return new DocumentTestClass(mDocument, mDocumentStream, mDocumentBytes, mDocumentString);
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package TestData.TestBuilders;
2+
3+
//////////////////////////////////////////////////////////////////////////
4+
// Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved.
5+
//
6+
// This file is part of Aspose.Words. The source code in this file
7+
// is only intended as a supplement to the documentation, and is provided
8+
// "as is", without warranty of any kind, either expressed or implied.
9+
//////////////////////////////////////////////////////////////////////////
10+
11+
import DocsExamples.DocsExamplesBase;
12+
import TestData.TestClasses.ImageTestClass;
13+
14+
import javax.imageio.ImageIO;
15+
import java.awt.image.BufferedImage;
16+
import java.io.File;
17+
import java.io.FileInputStream;
18+
import java.io.IOException;
19+
20+
public class ImageTestBuilder extends DocsExamplesBase {
21+
private BufferedImage mImage;
22+
private FileInputStream mImageStream;
23+
private byte[] mImageBytes;
24+
private String mImageString;
25+
26+
public ImageTestBuilder() throws Exception {
27+
28+
mImage = ImageIO.read(new File(getImagesDir() + "Transparent background logo.png"));
29+
30+
mImageStream = null;
31+
mImageBytes = new byte[0];
32+
mImageString = "";
33+
}
34+
35+
public ImageTestBuilder withImage(final String imagePath) throws IOException {
36+
mImage = ImageIO.read(new File(imagePath));
37+
return this;
38+
}
39+
40+
public ImageTestBuilder withImageStream(final FileInputStream imageStream) {
41+
mImageStream = imageStream;
42+
return this;
43+
}
44+
45+
public ImageTestBuilder withImageBytes(final byte[] imageBytes) {
46+
mImageBytes = imageBytes;
47+
return this;
48+
}
49+
50+
public ImageTestBuilder withImageString(final String imageString) {
51+
mImageString = imageString;
52+
return this;
53+
}
54+
55+
public ImageTestClass build() {
56+
return new ImageTestClass(mImage, mImageStream, mImageBytes, mImageString);
57+
}
58+
}

0 commit comments

Comments
 (0)