* [ 1802766 ] JasperReports on VPN Profile
- Integrating contribution from the Posterita Team.
This commit is contained in:
parent
c3b8cebf3a
commit
9c912988c8
|
@ -18,6 +18,7 @@ import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.rmi.RemoteException;
|
import java.rmi.RemoteException;
|
||||||
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -44,11 +45,13 @@ import net.sf.jasperreports.engine.JasperReport;
|
||||||
import net.sf.jasperreports.engine.util.JRLoader;
|
import net.sf.jasperreports.engine.util.JRLoader;
|
||||||
|
|
||||||
import org.compiere.db.CConnection;
|
import org.compiere.db.CConnection;
|
||||||
|
import org.compiere.db.ServerConnection;
|
||||||
import org.compiere.interfaces.MD5;
|
import org.compiere.interfaces.MD5;
|
||||||
import org.compiere.interfaces.MD5Home;
|
import org.compiere.interfaces.MD5Home;
|
||||||
import org.compiere.model.MAttachment;
|
import org.compiere.model.MAttachment;
|
||||||
import org.compiere.model.MAttachmentEntry;
|
import org.compiere.model.MAttachmentEntry;
|
||||||
import org.compiere.model.MProcess;
|
import org.compiere.model.MProcess;
|
||||||
|
import org.compiere.process.ClientProcess;
|
||||||
import org.compiere.process.ProcessCall;
|
import org.compiere.process.ProcessCall;
|
||||||
import org.compiere.process.ProcessInfo;
|
import org.compiere.process.ProcessInfo;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
@ -63,8 +66,12 @@ import org.compiere.utils.DigestOfFile;
|
||||||
/**
|
/**
|
||||||
* @author rlemeill
|
* @author rlemeill
|
||||||
* originaly coming from an application note from compiere.co.uk
|
* originaly coming from an application note from compiere.co.uk
|
||||||
|
* ---
|
||||||
|
* Modifications: Allow Jasper Reports to be able to be run on VPN profile (i.e: no direct connection to DB).
|
||||||
|
* Implemented ClientProcess for it to run on client.
|
||||||
|
* @author Ashley Ramdass
|
||||||
*/
|
*/
|
||||||
public class ReportStarter implements ProcessCall {
|
public class ReportStarter implements ProcessCall, ClientProcess {
|
||||||
//logger
|
//logger
|
||||||
private static CLogger log = CLogger.getCLogger(ReportStarter.class);
|
private static CLogger log = CLogger.getCLogger(ReportStarter.class);
|
||||||
private static File REPORT_HOME = null;
|
private static File REPORT_HOME = null;
|
||||||
|
@ -327,6 +334,29 @@ public class ReportStarter implements ProcessCall {
|
||||||
return reportFile;
|
return reportFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Server Connection if direct connection is not available
|
||||||
|
* (VPN, WAN, Terminal) and thus query has to be run on server only else return
|
||||||
|
* a direct connection to DB.
|
||||||
|
*
|
||||||
|
* Notes: Need to refactor and integrate in DB if confirmed to be working as
|
||||||
|
* expected.
|
||||||
|
*
|
||||||
|
* @author Ashley Ramdass
|
||||||
|
* @return Connection DB Connection
|
||||||
|
*/
|
||||||
|
protected Connection getConnection()
|
||||||
|
{
|
||||||
|
if (DB.isRemoteObjects() && CConnection.get().isAppsServerOK(false))
|
||||||
|
{
|
||||||
|
return new ServerConnection();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return DB.getConnectionRW();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the process.
|
* Start the process.
|
||||||
* Called then pressing the Process button in R_Request.
|
* Called then pressing the Process button in R_Request.
|
||||||
|
@ -465,7 +495,7 @@ public class ReportStarter implements ProcessCall {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//JasperPrint jasperPrint = JasperFillManager.fillReport( jasperReport, params, DB.getConnectionRW());
|
//JasperPrint jasperPrint = JasperFillManager.fillReport( jasperReport, params, DB.getConnectionRW());
|
||||||
JasperPrint jasperPrint = JasperFillManager.fillReport( jasperReport, params, DB.getConnectionRW());
|
JasperPrint jasperPrint = JasperFillManager.fillReport( jasperReport, params, getConnection());
|
||||||
if (reportData.isDirectPrint()) {
|
if (reportData.isDirectPrint()) {
|
||||||
log.info( "ReportStarter.startProcess print report -" + jasperPrint.getName());
|
log.info( "ReportStarter.startProcess print report -" + jasperPrint.getName());
|
||||||
JasperPrintManager.printReport( jasperPrint, false);
|
JasperPrintManager.printReport( jasperPrint, false);
|
||||||
|
|
Loading…
Reference in New Issue