Commit 1326f8bd authored by sbade's avatar sbade

new bean component fir BSR transfer dashboard


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97705 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 7f8dc113
/**
*
*/
package ibase.dashboard.mfg.bean;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.List;
import ibase.dashboard.mfg.ejb.BSRTransferReportRemote;
import ibase.system.config.AppConnectParm;
import ibase.webitm.utility.ITMException;
import javax.naming.InitialContext;
/**
* @author base
*
*/
public class BSRTransferReportBean
{
BSRTransferReportRemote bSRTrnsfrRmt=null;
/**
*
*/
public BSRTransferReportBean()
{
AppConnectParm appConnectParm=new AppConnectParm();
try
{
InitialContext context=new InitialContext(appConnectParm.getProperty());
System.out.println(" in BSRTransferReportBean method");
bSRTrnsfrRmt =(BSRTransferReportRemote)context.lookup("ibase/BSRTransferReport/remote");
System.out.println(" after in BSRTransferReportBean method"+bSRTrnsfrRmt);
}
catch (Exception e)
{
System.out.println(" ibase.dashboard.mfg.bean :BSRTransferReportBean "+e.getMessage());
e.printStackTrace();
}
}
public String getBSRTransfer(String frmDate,String toDate,String geoLoc,String unitForm) throws RemoteException, ITMException
{
String xmlString="";
try
{
xmlString= bSRTrnsfrRmt.getBSRTransfer(frmDate, toDate,geoLoc,unitForm);
}
catch (Exception e)
{
System.out.println("ibase.dashboard.mfg.bean :BSRTransferReportBean "+e.getMessage());
e.printStackTrace();
}
return xmlString;
}
public String getGeoLoCodeXmlData() throws RemoteException, ITMException
{
String xmlDataString="";
try
{
xmlDataString= bSRTrnsfrRmt.getGeoLoCodeXmlData();
}
catch (Exception e)
{
System.out.println("ibase.dashboard.mfg.bean :BSRTransferReportBean "+e.getMessage());
e.printStackTrace();
}
return xmlDataString;
}
public String getUnitFormXmlData() throws RemoteException, ITMException
{
String xmlDataString="";
try
{
xmlDataString= bSRTrnsfrRmt.getUnitFormXmlData();
}
catch (Exception e)
{
System.out.println("ibase.dashboard.mfg.bean :BSRTransferReportBean "+e.getMessage());
e.printStackTrace();
}
return xmlDataString;
}
public String generatePDF(HashMap<String, List<String>> hashMap ,String exportPDFPath,String exportImagePath,String preyearMonth,String rptTitle,String userID) throws RemoteException, ITMException
{
String resultString="false";
try
{
resultString= bSRTrnsfrRmt.generatePDF(hashMap,exportPDFPath,exportImagePath,preyearMonth,rptTitle,userID);
}
catch (Exception e)
{
System.out.println("ibase.dashboard.mfg.bean :ProductionVsBudgetReportBean "+e.getMessage());
e.printStackTrace();
}
return resultString;
}
}
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.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.awt.Desktop;
import java.net.URI;
public class BSRTransferReportSchedule 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 BSRTransferReportSchedule.........");
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;
//add new variable on dated1/02/2013
String os = System.getProperty("os.name").toLowerCase();
String browserPathForLinex = "";
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
sendFinalURIList = new ArrayList<String>();
//sql = " select user_id,uri from dashboard_comp where uri like '%ProductionVsBudgetReportExport.jsp%'";
sql = "select user_id,uri from dashboard_comp where uri like '%ExportExample/BSRTransferReportExport.jsp%'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
userID = checkNull(rs.getString("user_id").trim());
uri = checkNull(rs.getString("uri"));
finalURI = CommonConstants.TOMCAT_HOME + uri + "&userID=" + userID;
System.out.println("direct uri from table =" + uri);
System.out.println("User id is =" + userID);
System.out.println("Final url appended user id in URL =" + finalURI);
sendFinalURIList.add(finalURI);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (os.indexOf("win") >= 0)
{
System.out.println("Start Window Section part execution");
if (Desktop.isDesktopSupported())
{
Desktop desktop = Desktop.getDesktop();
for (String resourcePath : sendFinalURIList)
{
try
{
System.out.println("run on browser(IE) through window machine");
desktop.browse(new URI(resourcePath));
Thread.sleep(120000);
System.out.println("End run on browser through window ");
} catch (Exception e)
{
e.printStackTrace();
}
}
//Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler" + resourcePath);
//Thread.sleep(25000L);
}
System.out.println("End of Window Machine section part execution");
}
/* Ended Added new code for windows palform */
if (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0)
{
//browserPathForLinex ="/usr/lib/firefox/firefox";//this is my PC firefox
browserPathForLinex = "/usr/bin/firefox";
for (String resourcePath : sendFinalURIList)
{
callURL(browserPathForLinex, resourcePath); //call synchronized method
//String[] b = {browserPath, 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("ibase.dashboard.mfg.bean: BSRTransferReportSchedule :runSchedule() " + e.getMessage());
}
}
}
synchronized void callURL(String browserPath, String resourcePath)
{
try
{
int second = (int) (System.currentTimeMillis() / 1000) % 60;
System.out.println("View for Time when next URL are comming===" + second);
Runtime.getRuntime().exec(new String[]
{ browserPath, resourcePath });
Thread.sleep(120000);
System.out.println("In Linex12");
} catch (Exception e)
{
System.out.println("ibase.dashboard.mfg.bean: BSRTransferReportSchedule:callURL() " + e.getMessage());
}
}
// This method call for check null
private String checkNull(String input)
{
if (input == null)
{
input = "";
} else
{
input = input.trim();
}
return input;
}
}
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