org.databene.dbsanity.report.AbstractReportModule Maven / Gradle / Ivy
/*
* (c) Copyright 2010 by Volker Bergmann. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, is permitted under the terms of the
* GNU General Public License (GPL).
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* WITHOUT A WARRANTY OF ANY KIND. ALL EXPRESS OR IMPLIED CONDITIONS,
* REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE
* HEREBY EXCLUDED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.databene.dbsanity.report;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.databene.commons.ArrayFormat;
import org.databene.commons.IOUtil;
import org.databene.commons.StringUtil;
import org.databene.commons.file.FilePrintStream;
import org.databene.commons.math.Interval;
import org.databene.commons.math.Intervals;
import org.databene.commons.version.VersionNumber;
import org.databene.dbsanity.DbSanity;
import org.databene.dbsanity.model.SanityCheck;
import org.databene.dbsanity.model.SanityCheckSuite;
import org.databene.html.HTMLUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Abstract implementation of the {@link ReportModule} interface.
* It provides a {@link PrintStream} attribute named out
* and methods to open and close an HTML file on this attribute.
* Created: 13.10.2010 16:39:39
* @since 1.0
* @author Volker Bergmann
*/
public abstract class AbstractReportModule implements ReportModule {
protected final Logger logger = LoggerFactory.getLogger(getClass());
protected ReportContext context;
protected String style = DbSanity.DEFAULT_STYLE;
public int getDashboardColSpan(ReportScope scope) {
return 0;
}
public void setContext(ReportContext context) {
this.context = (ReportContext) context;
}
public void setStyle(String style) {
this.style = style;
}
public void success(SanityCheck check) {
}
public void failure(SanityCheck check, Object[] errorInfo, String[] infoHeaders) {
}
public void error(SanityCheck check, Exception e) {
}
public void skipped(SanityCheck check) {
}
public void summary(SanityCheckSuite rootSuite) {
}
public void renderDashboardView(ReportScope scope, SanityCheckSuite suite,
FilePrintStream out) {
}
public void close() {
}
// non-public helpers ----------------------------------------------------------------------------------------------
protected FilePrintStream openNewFile(File file, String title) throws FileNotFoundException {
return ReportUtil.openNewFile(file, title, new File(context.getReportRoot(), style + ".css"));
}
protected void closeFile(FilePrintStream out) {
out.println(context.footer());
out.println(" ");
out.println("