| 
						
						
						
					 | 
					 | 
					@ -1,9 +1,13 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					package info.bukova.isspst.ui.reporting;
 | 
					 | 
					 | 
					 | 
					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.Report;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import info.bukova.isspst.reporting.ReportDefinition;
 | 
					 | 
					 | 
					 | 
					import info.bukova.isspst.reporting.ReportDefinition;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import info.bukova.isspst.reporting.ReportType;
 | 
					 | 
					 | 
					 | 
					import info.bukova.isspst.reporting.ReportType;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import info.bukova.isspst.services.Service;
 | 
					 | 
					 | 
					 | 
					import info.bukova.isspst.services.Service;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import info.bukova.isspst.sort.ReflectionTools;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import info.bukova.isspst.ui.DocumentViewModel;
 | 
					 | 
					 | 
					 | 
					import info.bukova.isspst.ui.DocumentViewModel;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.zkoss.bind.annotation.BindingParam;
 | 
					 | 
					 | 
					 | 
					import org.zkoss.bind.annotation.BindingParam;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.zkoss.bind.annotation.Command;
 | 
					 | 
					 | 
					 | 
					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.Init;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.zkoss.bind.annotation.NotifyChange;
 | 
					 | 
					 | 
					 | 
					import org.zkoss.bind.annotation.NotifyChange;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.zkoss.zk.ui.Executions;
 | 
					 | 
					 | 
					 | 
					import org.zkoss.zk.ui.Executions;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import org.zkoss.zk.ui.Sessions;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.zkoss.zk.ui.select.annotation.WireVariable;
 | 
					 | 
					 | 
					 | 
					import org.zkoss.zk.ui.select.annotation.WireVariable;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.zkoss.zul.Window;
 | 
					 | 
					 | 
					 | 
					import org.zkoss.zul.Window;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import javax.servlet.ServletContext;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import java.lang.reflect.InvocationTargetException;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import java.util.List;
 | 
					 | 
					 | 
					 | 
					import java.util.List;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					public class ReportDialogVM extends DocumentViewModel
 | 
					 | 
					 | 
					 | 
					public class ReportDialogVM extends DocumentViewModel
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -25,6 +32,7 @@ public class ReportDialogVM extends DocumentViewModel
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private ReportDefinition reportDefinition;
 | 
					 | 
					 | 
					 | 
						private ReportDefinition reportDefinition;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private List<Object> dataList;
 | 
					 | 
					 | 
					 | 
						private List<Object> dataList;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private Object singleObject;
 | 
					 | 
					 | 
					 | 
						private Object singleObject;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						private ServletContext ctx;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						
 | 
					 | 
					 | 
					 | 
						
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						@Init(superclass = true)
 | 
					 | 
					 | 
					 | 
						@Init(superclass = true)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public void init(@ExecutionArgParam("reports") List<Report> reports, 
 | 
					 | 
					 | 
					 | 
						public void init(@ExecutionArgParam("reports") List<Report> reports, 
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -40,6 +48,8 @@ public class ReportDialogVM extends DocumentViewModel
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							dataList = data;
 | 
					 | 
					 | 
					 | 
							dataList = data;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							this.singleObject = singleObject;
 | 
					 | 
					 | 
					 | 
							this.singleObject = singleObject;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							reportDefinition.setService(service);
 | 
					 | 
					 | 
					 | 
							reportDefinition.setService(service);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							ctx = Sessions.getCurrent().getWebApp().getServletContext();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						}
 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						
 | 
					 | 
					 | 
					 | 
						
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public List<Report> getReports() {
 | 
					 | 
					 | 
					 | 
						public List<Report> getReports() {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -59,12 +69,37 @@ public class ReportDialogVM extends DocumentViewModel
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							this.selected = selected;
 | 
					 | 
					 | 
					 | 
							this.selected = selected;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							reportDefinition.setReport(selected);
 | 
					 | 
					 | 
					 | 
							reportDefinition.setReport(selected);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if (selected.isSingleRecord()) {
 | 
					 | 
					 | 
					 | 
							if (selected.isSingleRecord()) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								reportDefinition.setSingleObject(singleObject);
 | 
					 | 
					 | 
					 | 
								setObject(selected);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							} else {
 | 
					 | 
					 | 
					 | 
							} else {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								reportDefinition.setDataSet(dataList);
 | 
					 | 
					 | 
					 | 
								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
 | 
					 | 
					 | 
					 | 
						@Command
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public void print(@BindingParam("window") Window window) {
 | 
					 | 
					 | 
					 | 
						public void print(@BindingParam("window") Window window) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if (window != null) {
 | 
					 | 
					 | 
					 | 
							if (window != null) {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
 
 |