Commit da538597 authored by vvengurlekar's avatar vvengurlekar

metadata folder added inside src folder

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@177467 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d7009f37
package ibase.dashboard.metadata.ejb;
import ibase.dashboard.Report.Utility.DashboardUtility;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.io.File;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import javax.ejb.Stateless;
import org.json.simple.JSONObject;
@Stateless
public class DashboardParentEJB extends ValidatorEJB implements DashboardParentEJBLocal, DashboardParentEJBRemote
{
public DashboardParentEJB() {
// TODO Auto-generated constructor stub
}
DashboardUtility dashboardUtility = new DashboardUtility();
@Override
public String getKeyString(String modName, String fieldName, String transDB) throws RemoteException, ITMException
{
Statement statement = null;
ResultSet resultSet = null;
String keyString = "";
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
try
{
if (transDB != null && transDB.trim().length() > 0)
{
conn = connDriver.getConnectDB(transDB);
}
else
{
conn = connDriver.getConnectDB("DriverITM");
}
connDriver = null;
statement = conn.createStatement();
String query = "SELECT SQL_INPUT FROM POPHELP WHERE MOD_NAME ='" + modName + "' AND FIELD_NAME = '" + fieldName.toUpperCase() + "'";
System.out.println("modName is ="+modName+ " fieldName is= "+fieldName + " and query " +query);
resultSet = statement.executeQuery(query);
if (resultSet.next())
{
keyString = dashboardUtility.checkNull(resultSet.getString("SQL_INPUT"));
}
} catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
resultSet.close();
resultSet = null;
statement.close();
statement = null;
conn.close();
conn = null;
} catch (Exception ex)
{
System.out.println("Finally Exception : DashboardParentEJB: getKeyString()" + ex.getMessage());
ex.printStackTrace();
}
}
return keyString;
}
@SuppressWarnings("unchecked")
@Override
public JSONObject getDefaultFilterValue(String transDB ) throws RemoteException, ITMException
{
ConnDriver connDriver = new ConnDriver();
Statement statement = null;
ResultSet rs = null;
JSONObject parentDataJson = new JSONObject();
Connection connection = null;
try
{
if (transDB != null && !"null".equalsIgnoreCase(transDB.trim()) && transDB.trim().length() > 0)
{
connection = connDriver.getConnectDB(transDB);
}
else
{
connection = connDriver.getConnectDB("DriverITM");
}
statement = connection.createStatement();
String query = " Select Acct_Prd,Code,Descr From Period Where To_Date(Sysdate) Between Fr_Date and To_Date ";
rs = statement.executeQuery(query);
if (rs.next())
{
parentDataJson.put("CURRENT_ACCTCODE",dashboardUtility.checkNull(rs.getString("Acct_Prd")));
parentDataJson.put("CURRENT_PRDCODE", dashboardUtility.checkNull(rs.getString("Code")));
}
} catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
rs.close();
rs = null;
statement.close();
statement = null;
connection.close();
connection = null;
} catch (Exception ex)
{
System.out.println("Finally Exception : DashboardFilterServlet: getDefaultFilterValue()" + ex.getMessage());
ex.printStackTrace();
}
}
return parentDataJson;
}
}
package ibase.dashboard.metadata.ejb;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.json.simple.JSONObject;
@Local
public interface DashboardParentEJBLocal extends ValidatorLocal
{
public String getKeyString(String ObjectName, String fieldName, String transDB) throws RemoteException, ITMException;
public JSONObject getDefaultFilterValue(String dataSourceName) throws RemoteException, ITMException;
}
package ibase.dashboard.metadata.ejb;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.json.simple.JSONObject;
@Remote
public interface DashboardParentEJBRemote extends ValidatorRemote
{
public String getKeyString(String ObjectName, String fieldName, String transDB) throws RemoteException, ITMException;
public JSONObject getDefaultFilterValue(String dataSourceName) throws RemoteException, ITMException;
}
package ibase.dashboard.metadata.servlet;
import ibase.dashboard.metadata.ejb.DashboardParentEJBRemote;
import ibase.system.config.AppConnectParm;
import ibase.utility.UserInfoBean;
import ibase.webitm.bean.PopUpBean;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
import java.util.StringTokenizer;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class DashboardFilterServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
PopUpBean popUpBean = null;
String xmlString = null;
String[] parameters = null;
String keyString = null;
String objName = null;
StringTokenizer st = null;
HttpSession session = request.getSession(true);
String transDB ="";
DashboardParentEJBRemote dashboardParentEJBRemote = null;
try
{
String fieldName = request.getParameter("FIELDNAME");
UserInfoBean userInfo = (UserInfoBean) session.getAttribute("USER_INFO");
fieldName = fieldName.trim();
objName = request.getParameter("OBJ_NAME");
transDB = userInfo.getTransDB();
//keyString = request.getParameter("KEYSTRING");
//Add new code By birendra on dated 23/6/2015
InitialContext ctx = getInitialContext();
dashboardParentEJBRemote = (DashboardParentEJBRemote)ctx.lookup("ibase/DashboardParentEJB/remote");
keyString = dashboardParentEJBRemote.getKeyString("W_" + objName, fieldName, transDB);
//Add new code By Birendra on dated 23/6/2015
int pos = fieldName.lastIndexOf(".");
fieldName = fieldName.substring(pos + 1, fieldName.length());
//Add new code By Birendra Pandey on dated 27/06/2014
if (objName != null && (objName != (String) session.getAttribute("OBJ_NAME")))
{
objName = request.getParameter("OBJ_NAME");
} else
{
objName = (String) session.getAttribute("OBJ_NAME");
}
//END new code By Birendra Pandey on dated 27/06/2014
objName = objName.trim();
System.out.println("objName=====" + objName + " fieldName=====" + fieldName + " keyString is =====" + keyString);
if (keyString != null && keyString.trim().length()!=0)
{
keyString = keyString.substring(1).trim();
st = new StringTokenizer(keyString, ":");
}
if (st != null && st.countTokens() > 1)
{
parameters = new String[st.countTokens()];
int ctr = 0;
boolean flag = false;
while (st.hasMoreTokens())
{
String curToken = st.nextToken();
if (curToken.indexOf(".") != -1)
{
curToken = curToken.substring(curToken.indexOf(".") + 1);
}
flag = true;
curToken = (curToken.indexOf(",") != -1) ? curToken.substring(0, curToken.indexOf(",")) : curToken;
parameters[ctr] = request.getParameter(curToken);
ctr++;
}
} else
{
parameters = new String[1];
if ((keyString != null) && (keyString.indexOf(".") != -1))
{
keyString = keyString.substring(keyString.indexOf(".") + 1);
parameters[0] = request.getParameter(keyString);
} else
{
parameters[0] = request.getParameter(keyString);
}
}
// change the code by Birendra Pandey used the concept of multitendency
popUpBean = new PopUpBean(userInfo);
popUpBean.setObjName(objName);
popUpBean.setUserInfoBean(userInfo);
xmlString = popUpBean.getPopUpXML(fieldName, parameters);
if (xmlString == null)
{
xmlString = "<Root> </Root>";
}
System.out.println("Pop help xml string==" + xmlString);
OutputStream outputStreampop = response.getOutputStream();
outputStreampop.write(xmlString.toString().getBytes());
outputStreampop.flush();
outputStreampop.close();
} catch (Exception e)
{
System.out.println("Exception : SalesPerfrmncFilterServlet :doPost(HttpServletRequest request, HttpServletResponse response) :" + e.getMessage());
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
}
//Add new method for get sql input string from pophel table by Birendra Pandey on dated:
private InitialContext getInitialContext()throws ITMException
{
InitialContext ctx = null;
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
}
catch(ITMException itme)
{
System.out.println("ITMException :RequestHandlerServlet :getInitialContext :==>");
throw itme;
}
catch(Exception e)
{
System.out.println("Exception :RequestHandlerServlet :getInitialContext :==>");
throw new ITMException(e);
}
return ctx;
}
//
/*public String getKeyString(String modName, String fieldName, UserInfoBean userInfo)
{
ConnDriver connDriver = new ConnDriver();
Statement statement = null;
ResultSet resultSet = null;
String keyString = "";
Connection connection = null;
String transDB = "";
try
{
transDB = userInfo.getTransDB();
dashboardUtility = new DashboardUtility();
if (transDB != null && !"null".equalsIgnoreCase(transDB.trim()) && transDB.trim().length() > 0)
{
connection = connDriver.getConnectDB(transDB);
}
else
{
connection = connDriver.getConnectDB("DriverITM");
}
statement = connection.createStatement();
String query = "SELECT SQL_INPUT FROM POPHELP WHERE MOD_NAME ='" + modName + "' AND FIELD_NAME = '" + fieldName.toUpperCase() + "'";
System.out.println("modName is ="+modName+ " fieldName is= "+fieldName + " and query " +query);
resultSet = statement.executeQuery(query);
if (resultSet.next())
{
keyString = dashboardUtility.checkNull(resultSet.getString("SQL_INPUT"));
}
} catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
resultSet.close();
resultSet = null;
statement.close();
statement = null;
connection.close();
connection = null;
} catch (Exception ex)
{
System.out.println("Finally Exception : DashboardFilterServlet: getKeyString()" + ex.getMessage());
ex.printStackTrace();
}
}
return keyString;
}
*/
//end the getKeyString method
}
\ No newline at end of file
package ibase.dashboard.metadata.servlet;
import ibase.dashboard.metadata.ejb.DashboardParentEJBRemote;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.UserInfoBean;
import ibase.webitm.utility.ITMException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Calendar;
import java.util.Date;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;
public class ParentMetaDataServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
@SuppressWarnings("unused")
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
try
{
JSONObject jsonObjMetaData =null;
JSONObject jsonObjDefaultValue = null;
DashboardParentEJBRemote dashboardParentEJBRemote = null;
String dataSourceName ="";
String fileName = request.getParameter("fileName");
HttpSession session = request.getSession(true);
UserInfoBean userInfo = (ibase.utility.UserInfoBean) session.getAttribute("USER_INFO");
if (userInfo!=null)
{
dataSourceName = userInfo.getTransDB();
}
else
{
userInfo = new UserInfoBean();
dataSourceName = userInfo.getTransDB();
}
if(fileName!=null && fileName.trim().length()>0)
{
//InitialContext ctx = this.getInitialContext();
//dashboardParentEJBRemote = (DashboardParentEJBRemote)ctx.lookup("ibase/DashboardParentEJB/remote");
// jsonObjDefaultValue = (JSONObject)dashboardParentEJBRemote.getDefaultFilterValue(dataSourceName);
jsonObjMetaData = (JSONObject) getMetaData(fileName,userInfo);
}
System.out.println("getMetaData in ParentMetaDataServlet===" + jsonObjMetaData);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjMetaData.toString().getBytes());
outputStream.flush();
outputStream.close();
} catch (Exception e)
{
System.out.println("Exception : ParentMetaDataServlet :doPost(HttpServletRequest request, HttpServletResponse response) :" + e);
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
}
//add new code for get current financial year and period from database
/*@SuppressWarnings("unchecked")
public JSONObject getDefaultFilterValue(UserInfoBean userInfo)
{
ConnDriver connDriver = new ConnDriver();
Statement statement = null;
ResultSet rs = null;
JSONObject parentDataJson = new JSONObject();
Connection connection = null;
String transDB = "";
try
{
transDB = userInfo.getTransDB();
if (transDB != null && !"null".equalsIgnoreCase(transDB.trim()) && transDB.trim().length() > 0)
{
connection = connDriver.getConnectDB(transDB);
}
else
{
connection = connDriver.getConnectDB("DriverITM");
}
statement = connection.createStatement();
String query = " Select Acct_Prd,Code,Descr From Period Where To_Date(Sysdate) Between Fr_Date and To_Date ";
rs = statement.executeQuery(query);
if (rs.next())
{
parentDataJson.put("CURRENT_ACCTCODE",checkNull(rs.getString("Acct_Prd")));
parentDataJson.put("CURRENT_PRDCODE",checkNull(rs.getString("Code")));
parentDataJson.put("CURRENT_SITECODE",userInfo.getSiteCode());
parentDataJson.put("CURRENT_LOGINCODE",userInfo.getSiteCode());
parentDataJson.put("CURRENT_MONTH", "December");
parentDataJson.put("CURRENT_YEAR", "2017");
}
} catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
rs.close();
rs = null;
statement.close();
statement = null;
connection.close();
connection = null;
} catch (Exception ex)
{
System.out.println("Finally Exception : DashboardFilterServlet: getDefaultFilterValue()" + ex.getMessage());
ex.printStackTrace();
}
}
return parentDataJson;
}*/
//end the new code for get current financial year and period from database
@SuppressWarnings("unchecked")
private JSONObject getMetaData(String fileName,UserInfoBean userInfo ) throws RemoteException, ITMException
{
String isCurrentLine = "";
JSONObject jsonMetaData = new JSONObject();
StringBuffer metaData = new StringBuffer();
String filePath = CommonConstants.JBOSSHOME + File.separator + "server" + File.separator + "default" + File.separator + "deploy" + File.separator + "ibase.ear" + File.separator + "ibase.war" + File.separator + "dashboard" + File.separator + "metadataxml" + File.separator +fileName+".xml";
System.out.println("Final File Path =" + filePath);
try
{
@SuppressWarnings("resource")
BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath));
while ((isCurrentLine = bufferedReader.readLine()) != null)
{
System.out.println("isCurrentLine =" + isCurrentLine.trim());
if (isCurrentLine.trim().length() > 0)
{
metaData.append(isCurrentLine.trim());
}
}
}
catch (FileNotFoundException e)
{
System.out.println("getMetaData in ParentMetaDataServlet ********* ");
} catch (IOException e)
{
e.printStackTrace();
}
System.out.println(" metaData.toString().replace :=" + metaData.toString().replace("//", "").trim());
jsonMetaData.put("metaData", metaData.toString().replace("//", "").trim());
// add new logic for create sub title----------------
//jsonMetaData.put("CURRENT_ACCTCODE",jsonObjDefaultValue.get("CURRENT_ACCTCODE"));
//jsonMetaData.put("CURRENT_PRDCODE", jsonObjDefaultValue.get("CURRENT_PRDCODE"));
//End logic for sub title-----------
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH)+1;
String currentYear = year+"";
String nextYear = ((year+1)+"").substring(currentYear.length()-2, currentYear.length());
String finYear = currentYear + nextYear+"";
System.out.println("Financial Year : " + finYear);
System.out.println("Period Code : " + month+currentYear);
jsonMetaData.put("tranDB", userInfo.getTransDB());
jsonMetaData.put("SITE_CODE", userInfo.getSiteCode());
jsonMetaData.put("LOGIN_CODE", userInfo.getLoginCode());
jsonMetaData.put("ACCT_PRD", finYear);
jsonMetaData.put("PRDCODE", month+currentYear);
System.out.println("tranDB in ParentMetaDataServlet ********* :"+userInfo.getTransDB());
return jsonMetaData;
}
private InitialContext getInitialContext()throws ITMException
{
InitialContext ctx = null;
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
}
catch(ITMException itme)
{
System.out.println("ITMException :RequestHandlerServlet :getInitialContext :==>");
throw itme;
}
catch(Exception e)
{
System.out.println("Exception :RequestHandlerServlet :getInitialContext :==>");
throw new ITMException(e);
}
return ctx;
}
private String checkNull(String str)
{
if(str == null)
{
return "";
}
else
{
return str ;
}
}
}
\ No newline at end of file
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