Oprevena sestava Žádost o SC- tisk z agend Cestovní příkazy a Požadavky na SC odkazuje na stejnou sestavu.
Byla přidána možnost použít property hlavní entity jako zdroje dat pro sestavu- rozšířen constructor třídy Report o parametr property.
This commit is contained in:
@@ -143,7 +143,7 @@ public class Constants {
|
||||
public final static ReportMapping REPORTS[] = {
|
||||
new ReportMapping(MOD_ADDRESSBOOK, new Report(1, false, "Adresní karty", "address")),
|
||||
new ReportMapping(MOD_ADDRESSBOOK, new Report(2, false, "Adresa", "address", false, true)),
|
||||
new ReportMapping(MOD_TRIPBILL, new Report(3, false, "Žádost", "tripRequirement", false, true)),
|
||||
new ReportMapping(MOD_TRIPBILL, new Report(7, true, "Žádost o SC", "tripRequirementApp", false, true, "requirement")),
|
||||
new ReportMapping(MOD_TRIPBILL, new Report(4, true, "Vyúčtování", "tripBill", false, true, true)),
|
||||
new ReportMapping(MOD_ORDER, new Report(5, false, "Objednávka", "order", true, true)),
|
||||
new ReportMapping(MOD_REQUIREMENTS, new Report(6, false, "Požadavky", "requirements")),
|
||||
|
||||
@@ -11,6 +11,7 @@ public class Report {
|
||||
private boolean hasSettings;
|
||||
private boolean singleRecord;
|
||||
private boolean hasCondition;
|
||||
private String property;
|
||||
|
||||
public Report() {
|
||||
this.reportId = 0;
|
||||
@@ -60,6 +61,11 @@ public class Report {
|
||||
this.singleRecord = singleRecord;
|
||||
}
|
||||
|
||||
public Report(long reportId, boolean signable, String name, String jasperFile, boolean hasSettings, boolean singleRecord, String property) {
|
||||
this(reportId, signable, name, jasperFile, hasSettings, singleRecord);
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param reportId
|
||||
@@ -138,4 +144,12 @@ public class Report {
|
||||
public void setSignable(boolean signable) {
|
||||
this.signable = signable;
|
||||
}
|
||||
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
public void setProperty(String property) {
|
||||
this.property = property;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package info.bukova.isspst.ui.reporting;
|
||||
|
||||
import info.bukova.isspst.Module;
|
||||
import info.bukova.isspst.ModuleUtils;
|
||||
import info.bukova.isspst.data.DataModel;
|
||||
import info.bukova.isspst.reporting.Report;
|
||||
import info.bukova.isspst.reporting.ReportDefinition;
|
||||
import info.bukova.isspst.reporting.ReportType;
|
||||
import info.bukova.isspst.services.Service;
|
||||
import info.bukova.isspst.sort.ReflectionTools;
|
||||
import info.bukova.isspst.ui.DocumentViewModel;
|
||||
import org.zkoss.bind.annotation.BindingParam;
|
||||
import org.zkoss.bind.annotation.Command;
|
||||
@@ -11,9 +15,12 @@ import org.zkoss.bind.annotation.ExecutionArgParam;
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
import org.zkoss.bind.annotation.NotifyChange;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.Sessions;
|
||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
public class ReportDialogVM extends DocumentViewModel
|
||||
@@ -24,7 +31,8 @@ public class ReportDialogVM extends DocumentViewModel
|
||||
@WireVariable
|
||||
private ReportDefinition reportDefinition;
|
||||
private List<Object> dataList;
|
||||
private Object singleObject;
|
||||
private Object singleObject;
|
||||
private ServletContext ctx;
|
||||
|
||||
@Init(superclass = true)
|
||||
public void init(@ExecutionArgParam("reports") List<Report> reports,
|
||||
@@ -40,6 +48,8 @@ public class ReportDialogVM extends DocumentViewModel
|
||||
dataList = data;
|
||||
this.singleObject = singleObject;
|
||||
reportDefinition.setService(service);
|
||||
|
||||
ctx = Sessions.getCurrent().getWebApp().getServletContext();
|
||||
}
|
||||
|
||||
public List<Report> getReports() {
|
||||
@@ -59,11 +69,36 @@ public class ReportDialogVM extends DocumentViewModel
|
||||
this.selected = selected;
|
||||
reportDefinition.setReport(selected);
|
||||
if (selected.isSingleRecord()) {
|
||||
reportDefinition.setSingleObject(singleObject);
|
||||
setObject(selected);
|
||||
} else {
|
||||
reportDefinition.setDataSet(dataList);
|
||||
}
|
||||
}
|
||||
|
||||
private void setObject(Report report) {
|
||||
if (report.getProperty() == null) {
|
||||
reportDefinition.setSingleObject(singleObject);
|
||||
} else {
|
||||
try {
|
||||
Object o = ReflectionTools.getGetterMethod(singleObject, report.getProperty()).invoke(singleObject);
|
||||
reportDefinition.setSingleObject(o);
|
||||
|
||||
if (!(o instanceof DataModel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Module m = ModuleUtils.getModule((DataModel)o, ctx);
|
||||
|
||||
if (m != null) {
|
||||
reportDefinition.setService((Service<Object>) ModuleUtils.getServiceInstance(m, ctx));
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Command
|
||||
public void print(@BindingParam("window") Window window) {
|
||||
|
||||
Reference in New Issue
Block a user