@Override
protected void extraValidation(final List<Throwable> validationErrors, final Configuration configuration) {
final boolean styleRefDeclared = this.firstHeaderStyle != null || this.lastHeaderStyle != null || this.headerStyle != null ||
this.firstDetailStyle != null || this.lastDetailStyle != null || this.detailStyle != null;
if (styleRefDeclared && this.jasperTemplate == null) {
validationErrors.add(new ConfigurationException(
"if a style is declared a 'jasperTemplate' must also be declared (in !tableProcessor)."));
}
if (styleRefDeclared && !this.dynamic) {
validationErrors.add(new ConfigurationException(
"if a style is declared dynamic must be true (in !tableProcessor)."));
}
if (this.dynamic) {
if (this.jasperTemplate == null) {
validationErrors.add(new ConfigurationException(
"'jasperTemplate' property must be declared if !tableProcessor is dynamic."));
}
if (this.headerStyle == null) {
validationErrors.add(new ConfigurationException(
"'headerStyle' property must be declared if !tableProcessor is dynamic."));
}
if (this.detailStyle == null) {
validationErrors.add(new ConfigurationException(
"'detailStyle' property must be declared if !tableProcessor is dynamic."));
}
try {
byte[] bytes = configuration.loadFile(this.jasperTemplate);
final JasperDesign templateDesign = JRXmlLoader.load(new ByteArrayInputStream(bytes));
final Map<String, JRStyle> stylesMap = templateDesign.getStylesMap();
if (templateDesign.getColumnHeader() == null) {
validationErrors.add(new ConfigurationException(
"JasperTemplate must have a column band defined for height and positioning information"));
} else if (templateDesign.getColumnHeader().getElements().length == 0) {
validationErrors.add(new ConfigurationException(
"column header band must have at least one element defined for to height and positioning information"));
}
final JRDesignSection detailSection = (JRDesignSection) templateDesign.getDetailSection();
if (detailSection.getBands().length == 0) {
validationErrors.add(new ConfigurationException(
"JasperTemplate must have a detail band defined for height and positioning information"));
} else if (detailSection.getBands()[0].getElements().length == 0) {
validationErrors.add(new ConfigurationException(
"detail band must have at least one element defined for to height and positioning information"));
}
checkStyleExists(validationErrors, stylesMap, this.firstDetailStyle);
checkStyleExists(validationErrors, stylesMap, this.detailStyle);