Skip to content

Instantly share code, notes, and snippets.

@muuki88
Created January 9, 2012 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muuki88/1585224 to your computer and use it in GitHub Desktop.
Save muuki88/1585224 to your computer and use it in GitHub Desktop.
IReportingService draft
package de.lmu.ifi.dbs.medmon.medic.core.service;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Path;
import java.util.Map;
public interface IReportingService {
//TODO Maybe one more parameter to determine if the report should be rendered as html, pdf, etc
/**
*
* @param reportDocument
* @param reportOutput
*/
public void renderReport(InputStream reportDocument, OutputStream reportOutput);
//TODO Maybe one more parameter to determine if the report should be rendered as html, pdf, etc
/**
*
* @param reportDesign - InputStream for reportDesign
* @param taskParameters - parameters to needed by the report, e.g. data or scheme files
* @param loader - to allocate the classes
* @param reportOutput - OutputStream where the report should be stored
*/
public void renderReport(InputStream reportDesign, Map<String, Object> taskParameters, ClassLoader loader, Path reportOutput);
//TODO Maybe one more parameter to determine if the report should be rendered as html, pdf, etc
/**
*
* @param reportDesign
* @param taskParameters
* @param loader
* @param reportDocumentOutput
*/
public void createReportDocument(InputStream reportDesign, Map<String, Object> taskParameters, ClassLoader loader, Path reportDocumentOutput);
}
@muuki88
Copy link
Author

muuki88 commented Jan 10, 2012

Maybe use a PDF Viewer

@muuki88
Copy link
Author

muuki88 commented Jan 10, 2012

Namingscheme for .xsd and .rptdesign idea:

medmon.medic.scheme.fileprefix

@muuki88
Copy link
Author

muuki88 commented Jan 10, 2012

the createReportDocument method should not use a java.nio.Path argument. Instead use
OutputStream to store the document and write it to a temporary file if necessary. E.g with

        try {
            Path tempFile = Files.createTempFile("prefix", "sufix");
            System.out.println("Temp file " + tempFile);

            try (BufferedWriter writer = Files.newBufferedWriter(tempFile, Charset.defaultCharset())) {
                writer.write("Test string");
                writer.newLine();
                writer.write("Line 2");
                writer.flush();
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }

            try (BufferedReader reader = Files.newBufferedReader(tempFile, Charset.defaultCharset())) {
                String first = reader.readLine();
                System.out.println(first);
                String second = reader.readLine();
                System.out.println(second);
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            Files.deleteIfExists(tempFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment