-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP:Added a module reporting from devonfw #194
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.devonfw.java.dev</groupId> | ||
<artifactId>devon4j-modules</artifactId> | ||
<version>dev-SNAPSHOT</version> | ||
</parent> | ||
<groupId>com.devonfw.java.modules</groupId> | ||
<artifactId>devon4j-reporting</artifactId> | ||
<version>${devon4j.version}</version> | ||
<packaging>jar</packaging> | ||
<name>${project.artifactId}</name> | ||
<description>Module for reporting.</description> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.devonfw.java.modules</groupId> | ||
<artifactId>devon4j-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- JASPER REPORTS LIBRARY --> | ||
<dependency> | ||
<groupId>net.sf.jasperreports</groupId> | ||
<artifactId>jasperreports</artifactId> | ||
<version>6.11.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.poi</groupId> | ||
<artifactId>poi</artifactId> | ||
<version>4.1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.sf.m-m-m</groupId> | ||
<artifactId>mmm-util-exception</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.devonfw.module.reporting.common; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
/** | ||
* This is the entry point for unit tests. | ||
* | ||
*/ | ||
@SpringBootApplication | ||
public class ReportingModuleApp { | ||
/** | ||
* Entry point for spring-boot based app | ||
* | ||
* @param args - arguments | ||
*/ | ||
public static void main(String[] args) { | ||
|
||
SpringApplication.run(ReportingModuleApp.class, args); | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package com.devonfw.module.reporting.common.api; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Class to encapsulate a report | ||
* | ||
* @param <T> type of the data that is provided to be included in the report | ||
*/ | ||
public class Report<T> { | ||
private String name; | ||
|
||
private String dataSourceName; | ||
|
||
private List<T> data; | ||
|
||
private String templatePath; | ||
|
||
private HashMap<String, Object> params; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
/** | ||
* @return name | ||
*/ | ||
public String getName() { | ||
|
||
return this.name; | ||
} | ||
|
||
/** | ||
* @param name new value of {@link #getName}. | ||
*/ | ||
public void setName(String name) { | ||
|
||
this.name = name; | ||
} | ||
|
||
/** | ||
* @return dataSourceName | ||
*/ | ||
public String getDataSourceName() { | ||
|
||
return this.dataSourceName; | ||
} | ||
|
||
/** | ||
* @param dataSourceName new value of {@link #getDataSourceName}. | ||
*/ | ||
public void setDataSourceName(String dataSourceName) { | ||
|
||
this.dataSourceName = dataSourceName; | ||
} | ||
|
||
/** | ||
* @return data | ||
*/ | ||
public List<T> getData() { | ||
|
||
return this.data; | ||
} | ||
|
||
/** | ||
* @param data new value of {@link #getData}. | ||
*/ | ||
public void setData(List<T> data) { | ||
|
||
this.data = data; | ||
} | ||
|
||
/** | ||
* @return templatePath | ||
*/ | ||
public String getTemplatePath() { | ||
|
||
return this.templatePath; | ||
} | ||
|
||
/** | ||
* @param templatePath new value of {@link #getTemplatePath}. | ||
*/ | ||
public void setTemplatePath(String templatePath) { | ||
|
||
this.templatePath = templatePath; | ||
} | ||
|
||
/** | ||
* @return params | ||
*/ | ||
public Map<String, Object> getParams() { | ||
|
||
return this.params; | ||
} | ||
|
||
/** | ||
* @param params new value of {@link #getParams}. | ||
*/ | ||
public void setParams(HashMap<String, Object> params) { | ||
|
||
this.params = params; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.devonfw.module.reporting.common.api; | ||
|
||
import java.io.File; | ||
import java.io.OutputStream; | ||
import java.util.List; | ||
|
||
/** | ||
* This is the interface for a simple facade to generate a report based on Jasper Reports library. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO this is an API that abstracts from the underlying implementation. Hence |
||
* | ||
* @param <T> type of the data that is provided to be included in the report. | ||
*/ | ||
public interface Reporting<T> { | ||
|
||
/** | ||
* Generates a report file with the given data, the template located in the templatePath and the type of file. | ||
* specified. | ||
* | ||
* @param report the {@link Report} that encapsulates the data to be included in the report, the location of the | ||
* report template and the values of the parameters defined in the report template (in case template uses | ||
* parameters). | ||
* @param file the file where the report must be created. | ||
* @param format - report format | ||
*/ | ||
public void generateReport(Report report, File file, String format); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
/** | ||
* Generates a report stream with the given data, the template located in the templatePath and the type of file. | ||
* | ||
* @param report the {@link Report} that encapsulates the data to be included in the report, the location of the | ||
* report template and the values of the parameters defined in the report template (in case template uses | ||
* parameters). | ||
* @param stream the stream where the report will be written. | ||
* @param format - report format | ||
*/ | ||
public void generateReport(Report report, OutputStream stream, String format); | ||
|
||
/** | ||
* Generates a file with a main report that stores other sub-reports. | ||
* | ||
* @param masterReport the main {@link Report}. | ||
* @param reports a list of {@link Report} reports to be included within the main report. | ||
* @param file the file where the report must be created. | ||
* @param format - report format | ||
*/ | ||
public void generateSubreport(Report masterReport, List<Report> reports, File file, String format); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Who. This is quite a sophisticated API. From the JavaDoc I do not really get what it will do. |
||
|
||
/** | ||
* Generates a stream with a main report that stores other sub-reports. | ||
* | ||
* @param masterReport the main {@link Report}. | ||
* @param reports a list of {@link Report} reports to be included within the main report. | ||
* @param stream the stream to manage the resultant report. | ||
* @param format - report format | ||
*/ | ||
public void generateSubreport(Report masterReport, List<Report> reports, OutputStream stream, String format); | ||
|
||
/** | ||
* Generates a report file that contains a concatenation of reports. | ||
* | ||
* @param reports the list of reports to be included in the report file. | ||
* @param file the file where the report must be created. | ||
* @param format - report format | ||
*/ | ||
public void concatenateReports(List<Report> reports, File file, String format); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does |
||
|
||
/** | ||
* Generates a stream that contains a concatenation of reports. | ||
* | ||
* @param reports the list of reports to be included in the report stream. | ||
* @param stream the stream to manage the resultant report. | ||
* @param format - report format | ||
*/ | ||
public void concatenateReports(List<Report> reports, OutputStream stream, String format); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.devonfw.module.reporting.common.api.exception; | ||
|
||
import net.sf.mmm.util.exception.api.NlsRuntimeException; | ||
import net.sf.mmm.util.nls.api.NlsMessage; | ||
|
||
/** | ||
* This is the checked exception for Reporting module. | ||
* | ||
*/ | ||
public class ReportingException extends NlsRuntimeException { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* The constructor. | ||
* | ||
* @param message the error {@link #getNlsMessage() message}. | ||
*/ | ||
public ReportingException(NlsMessage message) { | ||
|
||
super(message); | ||
} | ||
|
||
/** | ||
* Constructs an {@code ReportingException} with the root cause. | ||
* | ||
* @param cause the error {@link #getCause() cause}. | ||
* @param message the error {@link #getNlsMessage() message}. | ||
*/ | ||
public ReportingException(Throwable cause, NlsMessage message) { | ||
|
||
super(cause, message); | ||
} | ||
|
||
/** | ||
* The constructor. | ||
* | ||
* @param cause the error {@link #getCause() cause}. | ||
* @param message the error message. | ||
*/ | ||
public ReportingException(Throwable cause, String message) { | ||
|
||
super(cause, message); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is for Unit tests, why is it in
src/main
then rather thansrc/test
?