Skip to content

Commit

Permalink
Added big demo report with example data
Browse files Browse the repository at this point in the history
  • Loading branch information
nabbl committed Jan 26, 2018
1 parent 4abece4 commit 68552af
Show file tree
Hide file tree
Showing 24 changed files with 2,091 additions and 68 deletions.
1,652 changes: 1,652 additions & 0 deletions demo/data/h2_data.sql

Large diffs are not rendered by default.

Binary file added demo/fonts/DejaVuSans-Bold.ttf
Binary file not shown.
Binary file added demo/fonts/DejaVuSans-BoldOblique.ttf
Binary file not shown.
Binary file added demo/fonts/DejaVuSans-Oblique.ttf
Binary file not shown.
Binary file added demo/fonts/DejaVuSans.ttf
Binary file not shown.
Binary file added demo/fonts/DejaVuSansMono-Bold.ttf
Binary file not shown.
Binary file added demo/fonts/DejaVuSansMono-BoldOblique.ttf
Binary file not shown.
Binary file added demo/fonts/DejaVuSansMono-Oblique.ttf
Binary file not shown.
Binary file added demo/fonts/DejaVuSansMono.ttf
Binary file not shown.
Binary file added demo/fonts/DejaVuSerif-Bold.ttf
Binary file not shown.
Binary file added demo/fonts/DejaVuSerif-BoldItalic.ttf
Binary file not shown.
Binary file added demo/fonts/DejaVuSerif-Italic.ttf
Binary file not shown.
Binary file added demo/fonts/DejaVuSerif.ttf
Binary file not shown.
Binary file added demo/images/sourcepole.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
405 changes: 405 additions & 0 deletions demo/reports/PieChartReport.jrxml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions gs-rest-service.iml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
Expand Down
23 changes: 0 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/reports</outputDirectory>
<resources>
<resource>
<directory>${basedir}/reports/</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
11 changes: 8 additions & 3 deletions src/main/java/jasperapp/Config.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jasperapp;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
Expand All @@ -21,21 +22,24 @@ public void configureDefaultServletHandling(final DefaultServletHandlerConfigure
configurer.enable();
}

private String uploadLocation = System.getProperty("user.dir") + "/reports/";

@Value("${reports.directory}")
private String reportsDirectory;

@Bean
public JasperReportsViewResolver getJasperReportsViewResolver() {

String uploadLocation = System.getProperty("user.dir") + reportsDirectory;

JasperReportsViewResolver resolver = new JasperReportsViewResolver();

resolver.setPrefix("file:" + uploadLocation);
resolver.setSuffix(".jrxml");

resolver.setReportDataKey("datasource");
resolver.setViewNames("rpt_*");
resolver.setViewNames("*");
resolver.setViewClass(JasperReportsMultiFormatView.class);


resolver.setOrder(0);
return resolver;
}
Expand All @@ -49,4 +53,5 @@ public ViewResolver htmlViewResolver() {
resolver.setOrder(1);
return resolver;
}

}
14 changes: 12 additions & 2 deletions src/main/java/jasperapp/JasperEndpointController.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,18 @@ public ModelAndView getRptByParam(final ModelMap modelMap, ModelAndView modelAnd

// connecting to H2
modelMap.put(DATASOURCE, dataSource);
//
map.forEach( (String k, String[] v) -> modelMap.put(k, v[0]));

map.forEach((String k, String[] v) -> {
if (v[0].matches("\\d+")) {
//its a number:
modelMap.put(k, Integer.parseInt(v[0]));
} else {
modelMap.put(k, v[0]);
}
});

// This can be used in JasperReports to have absolute Image Paths
modelMap.put("ROOT_DIR", System.getProperty("user.dir"));

//It is important that the underlying Jasper Report supports the Query parameters

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# H2
spring.h2.console.enabled=true
spring.h2.console.enabled=false
spring.h2.console.path=/h2
# Datasource
spring.datasource.url=jdbc:h2:file:~/test
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
# Reports
spring.resources.static-locations=file:../reports/
# Custom Parameters
reports.directory=/demo/reports/
10 changes: 10 additions & 0 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# H2
spring.h2.console.enabled=true
spring.h2.console.path=/h2
# Datasource
spring.datasource.url=jdbc:h2:file:~/test
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
# Custom Parameters
reports.directory=/src/test/resources/
File renamed without changes.
Binary file added src/test/resources/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 0 additions & 37 deletions test/run.sh

This file was deleted.

0 comments on commit 68552af

Please sign in to comment.