Commit 48290e35 authored by kpandey's avatar kpandey

Added EDetailing Service for EDetailing Analysis

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@191723 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a4788231
package ibase.dashboard.common.webService;
import java.text.SimpleDateFormat;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import org.json.simple.JSONArray;
import org.json.JSONObject;
import ibase.dashboard.common.hibernate.dao.DashboardUtil;
import ibase.dashboard.common.hibernate.dao.EDetailingDao;
import ibase.utility.BaseException;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
@Path("/edetailing")
public class EDetailingService {
@Context
HttpServletRequest request;
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public String getEdetailingData( @QueryParam("fromDate") String fromDate,
@QueryParam("toDate") String toDate,
@QueryParam("USER_INFO") String userInfoString,
@QueryParam("TRANS_DATA") String transData) throws Exception
{
System.out.println("In getEdetailingData:: fromDate:: ["+fromDate+"] toDate:: ["+toDate+"]");
System.out.println("USER_INFO ["+userInfoString+"]");
System.out.println("trans_data in account acitivity"+transData);
if(transData != null)
{
DashboardUtil util = new DashboardUtil();
JSONObject data = util.xmlToJson(transData);
System.out.println("getEdetailingData json data for tranData>>" + data);
if(data != null) {
JSONObject filterData=new JSONObject();
filterData=data.optJSONObject("Detail1");
System.out.println("filterData fetch during jsonObject" +filterData);
if(filterData != null) {
System.out.println("filterData from getEdetailingData if not null "+filterData);
fromDate=filterData.optString("fromDate");
toDate=filterData.optString("toDate");
System.out.println("filterData from account activity fromDate[ "+fromDate+"] toDate ["+toDate+"]");
}
}
}
JSONObject edetailingDataObj = new JSONObject();
JSONArray edetailingDataArr = new JSONArray();
JSONObject errorObj = new JSONObject();
E12GenericUtility genericUtility = new E12GenericUtility();
try
{
if( userInfoString == null )
{
HttpSession session = request.getSession();
Object userObj = session.getAttribute("USER_INFO");
System.out.println("getAccountActivityData userObj [" + userObj + "]");
if (userObj != null)
{
userInfoString = userObj.toString();
}
else
{
userInfoString = null;
}
}
if (fromDate == null || fromDate == "" )
{
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
fromDate = sdf.format(new java.util.Date());
System.out.println("getEdetailingData fromDate is null [" + fromDate + "]");
}
if (toDate == null || toDate == "")
{
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
toDate = sdf.format(new java.util.Date());
System.out.println("getEdetailingData toDate is null [" + toDate + "]");
}
UserInfoBean userInfo = new UserInfoBean( userInfoString );
String loginCode = userInfo.getLoginCode();
EDetailingDao edetailingDao = new EDetailingDao();
edetailingDao.setUserInfo(userInfo);
edetailingDataArr = edetailingDao.getDetailingData(loginCode, fromDate, toDate);
System.out.println("edetailingDataArr:::["+edetailingDataArr+"]");
edetailingDataObj.put("data", edetailingDataArr);
System.out.println("edetailingDataObj:::["+edetailingDataObj+"]");
System.out.println("EDetailing Data Array"+edetailingDataArr.toString());
if(edetailingDataObj.length() == 0) {
errorObj.put("status", "Failure" );
return errorObj.toString();
}
}
catch (Exception e)
{
e.printStackTrace();
errorObj.put("status", "Failure" );
return errorObj.toString();
}
return edetailingDataObj.toString();
}
}
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