Ich benutze Jaspersoft Studio 6.2.0 und den Bericht in einem Maven-Projekt mit Abhängigkeiten kompilieren:Kann ich Lambda-Ausdrücke in Jaspersoft Studio 6.2.0 verwenden?
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.2.0</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-fonts</artifactId>
<version>6.0.0</version>
</dependency>
Der Bericht mit einem
gespeist wirdJRBeanArrayDataSource beanDS = new JRBeanArrayDataSource(new Incident[]{incident}, false);
ich versucht hat, einen labmda Ausdruck zu verwenden, in Drucken beim Ausdruck einer Band. Es scheint es nicht zu erkennen. Der Ausdruck lautet:
$F{actionList} == null || $F{actionList}.stream().allMatch(a -> ActionStatus.COMPLETED.equals(a.getStatus()))
ActionStatus ist ein Enum. Und ich bekomme Syntaxfehler wie:
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. a cannot be resolved to a variable
(((java.util.List)field_actionList.getValue()) == null || ((java.util.List)field_actionList.getValue()).stream().allMatch(a -> ActionStatus.COMPLETED.equals(a.getStatus()))) //$JR_EXPR_ID=248$
^
2. Syntax error on token "-", -- expected
(((java.util.List)field_actionList.getValue()) == null || ((java.util.List)field_actionList.getValue()).stream().allMatch(a -> ActionStatus.COMPLETED.equals(a.getStatus()))) //$JR_EXPR_ID=248$
Ich habe auch versucht die Methode aus dem Objekt mit direkt mag:
this.hasAllActionsCompleted()
, die das gleiche tut (dies ist bei dem Vorfall Objekt, das für die festgelegt ist Bericht des DS):
/**
* Checks if the incident has all actions completed
* @return true if all actions are completed or none defined, false otherwise
*/
public boolean hasAllActionsCompleted() {
return actionList == null || actionList.stream().allMatch(a -> ActionStatus.COMPLETED.equals(a.getStatus()));
}
und ich bekomme:
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. The method hasAllActionsCompleted() is undefined for the type Incident_1461053626798_784639
this.hasAllActionsCompleted() //$JR_EXPR_ID=248$
Gibt es einen anderen Weg, dies zu tun? Oder sollte ich das Ergebnis des Lambda-Ausdrucks einfach in einen Parameter für den Bericht setzen (das ist ein offensichtlicher Umweg, aber ich hatte auf einen direkten Ansatz gehofft)?