Commit 7855d186 authored by bpandey's avatar bpandey

add new changes for pdf and scheduler component


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94120 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 09ca60e0
......@@ -4,6 +4,9 @@
package ibase.dashboard.mfg.bean;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.List;
import java.util.Properties;
import ibase.dashboard.mfg.ejb.ProductionVsBudgetReportRemote;
import ibase.system.config.AppConnectParm;
......@@ -29,6 +32,7 @@ public class ProductionVsBudgetReportBean
try
{
InitialContext context=new InitialContext(appConnectParm.getProperty());
budgetReportRemote=(ProductionVsBudgetReportRemote)context.lookup("ibase/ProductionVsBudgetReport/remote");
}
catch (Exception e)
......@@ -87,14 +91,36 @@ public class ProductionVsBudgetReportBean
return xmlDataString;
}
//***************22/11/2013**************************
public String getPDFFormate() throws RemoteException, ITMException
public void generatePDF(HashMap<String, List<String>> hashMap ,String exportPDFPath,String exportImagePath,String preyearMonth,String rptTitle,String userID) throws RemoteException, ITMException
{
try
{
budgetReportRemote.generatePDF(hashMap,exportPDFPath,exportImagePath,preyearMonth,rptTitle,userID);
}
catch (Exception e)
{
System.out.println("ibase.dashboard.mfg.bean :ProductionVsBudgetReportBean "+e.getMessage());
e.printStackTrace();
}
}
public boolean getRoleValid(String userCode, String roleCode) throws RemoteException, ITMException
{
String strMessage="";
boolean isRoleExists=false;
try
{
strMessage = budgetReportRemote.getPDFFormate();
isRoleExists = budgetReportRemote.getRoleValid(userCode,roleCode);
}
catch (Exception e)
{
......@@ -102,8 +128,9 @@ public class ProductionVsBudgetReportBean
e.printStackTrace();
}
return strMessage;
return isRoleExists;
}
}
package ibase.dashboard.mfg.bean;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.utility.ITMException;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class ProductionVsBudgetReportSchedule implements Schedule
{
public String schedule(HashMap map) throws Exception
{
System.out.println(schedule((String) map.get("PROCESS_NAME")));
return schedule((String) map.get("PROCESS_NAME"));
}
public String schedule(String schedule) throws Exception
{
System.out.println("inside ProductionVsBudgetReportSchedule.........");
this.runSchedule();
return schedule;
}
public String schedulePriority(String arg0) throws Exception
{
return null;
}
private void runSchedule() throws ITMException
{
// Add new code on dated 10/01/2013
String sql = "";
ResultSet rs = null;
Connection conn = null;
PreparedStatement pstmt = null;
ConnDriver connDriver = new ConnDriver();
String userID = "";
String uri = "";
String finalURI = "";
List<String> sendFinalURIList = null;
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
sendFinalURIList = new ArrayList<String>();
sql = " select user_id,uri from dashboard_comp where uri like '%ProductionVsBudgetReportExport.jsp%'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
userID = checkNull(rs.getString("user_id"));
uri = checkNull(rs.getString("uri"));
// finalURI = CommonConstants.TOMCAT_HOME + uri + "&userID ="+userID;
finalURI = CommonConstants.TOMCAT_HOME + uri;
System.out.println("finalURI is =" + finalURI);
sendFinalURIList.add(finalURI);
System.out.println("User id is =" + userID);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
for (String resourcePath : sendFinalURIList)
{
if (Desktop.isDesktopSupported())
{
Desktop desktop = Desktop.getDesktop();
try
{
desktop.browse(new URI(resourcePath));
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
} else
{
Runtime runtime = Runtime.getRuntime();
try
{
runtime.exec("xdg-open " + resourcePath);
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// String resourcePath = CommonConstants.TOMCAT_HOME + File.separator + "ibase" +File.separator + "dashboard" + File.separator + "mfg" +File.separator+"JSP"+File.separator+"ExportExample"+File.separator +"ProductionVsBudgetReport_export.jsp";
System.out.println("ProductionVsBudgetReportSchedule path =[" + resourcePath + "]");
}// end forloop
}// end try block
catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception e)
{
e.printStackTrace();
System.out.println("error inside when scheduler invoke ProductionVsBudgetExport.jsp " + e.getMessage());
}
}
}
// This method call for check null
private String checkNull(String input)
{
if (input == null)
{
input = "";
} else
{
input = input.trim();
}
return input;
}
}
package ibase.dashboard.mfg.bean;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@SuppressWarnings("serial")
public class ProductionVsBudgetReportServlet extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost( request, response );
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
ProductionVsBudgetReportBean bean=null;
String exportPDFPath ="";
String exportImagePath ="";
String preyearMonth ="";
String rptTitle ="";
String userID ="";
System.out.println(" ENTER - ProductionVsBudgetReportServlet ***********************");
try
{
bean = new ProductionVsBudgetReportBean();
HttpSession session= request.getSession();
HashMap <String, List<String>> gridDataMap = (HashMap<String, List<String>>) session.getAttribute("gridDataMap");
userID =(String)request.getParameter("userID");
exportPDFPath =(String)request.getParameter("exportPDFPath");
exportImagePath =(String)request.getParameter("exportImagePath");
preyearMonth =(String)request.getParameter("preyearMonth");
rptTitle =(String)request.getParameter("rptTitle");
System.out.println("userID====="+userID);
//System.out.println("exportPDFPath====="+exportPDFPath);
//System.out.println("exportImagePath====="+exportImagePath);
//System.out.println("preyearMonth====="+preyearMonth);
//System.out.println("rptTitle====="+rptTitle);
//call EJB method for PDF creation*******************
bean.generatePDF(gridDataMap, exportPDFPath, exportImagePath, preyearMonth, rptTitle,userID);
response.setContentType("text/html");
response.getWriter().write("PDF Creation");
}
catch (Exception e)
{
System.out.println("Exception :ProductionVsBudgetReportServlet : ProductionVsBudgetReportServlet) :"+e.getMessage()); //$NON-NLS-1$
try
{
throw new ITMException(e);
}
catch (ITMException e1)
{
e1.printStackTrace();
}
}
finally
{
}
}
}
\ No newline at end of file
......@@ -3,15 +3,18 @@ import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.List;
import javax.ejb.Local;
@Local
public interface ProductionVsBudgetReportLocal extends ValidatorLocal{
public String getProductionBudget(String frmDate,String toDate,String geoLoc,String unitForm) throws RemoteException, ITMException;
public String getGeoLoCodeXmlData() throws RemoteException, ITMException;
public String getUnitFormXmlData() throws RemoteException, ITMException;
public String getPDFFormate () throws RemoteException, ITMException;
public String getProductionBudget(String frmDate,String toDate,String geoLoc,String unitForm) throws RemoteException, ITMException;
public String getGeoLoCodeXmlData() throws RemoteException, ITMException;
public String getUnitFormXmlData() throws RemoteException, ITMException;
public boolean getRoleValid(String userCode, String roleCode) throws RemoteException, ITMException;
public void generatePDF(HashMap<String, List<String>> hashMap ,String exportPDFPath,String exportImagePath,String preyearMonth,String rptTitle,String userID) throws RemoteException, ITMException;
}
......@@ -3,6 +3,8 @@ import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.List;
import javax.ejb.Remote;
......@@ -10,9 +12,10 @@ import javax.ejb.Remote;
public interface ProductionVsBudgetReportRemote extends ValidatorRemote
{
public String getProductionBudget(String frmDate,String toDate,String geoLoc,String unitForm) throws RemoteException, ITMException;
public String getGeoLoCodeXmlData() throws RemoteException, ITMException;
public String getUnitFormXmlData() throws RemoteException, ITMException;
public String getPDFFormate () throws RemoteException, ITMException;
public String getProductionBudget(String frmDate,String toDate,String geoLoc,String unitForm) throws RemoteException, ITMException;
public String getGeoLoCodeXmlData() throws RemoteException, ITMException;
public String getUnitFormXmlData() throws RemoteException, ITMException;
public boolean getRoleValid(String userCode, String roleCode) throws RemoteException, ITMException;
public void generatePDF(HashMap<String, List<String>> hashMap ,String exportPDFPath,String exportImagePath,String preyearMonth,String rptTitle,String userID) throws RemoteException, ITMException;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment