Commit 86115436 authored by kpandey's avatar kpandey

Shifted to Proteus-Framework jar

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@200588 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 4793cd5e
package ibase.dashboard.common.webService;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.json.JSONObject;
import ibase.dashboard.common.hibernate.bean.ObjUserPref;
import ibase.dashboard.common.hibernate.dao.ObjUserPrefDao;
import ibase.utility.BaseException;
import ibase.utility.UserInfoBean;
@Path("/exploreReport")
public class ObjUserPrefService {
@Context
HttpServletRequest request; // The proxy of Request will be injected into this singleton
@Context
ServletContext context;
//Added by Kamal.P Created a service which used to call the server from client end when save report functionality will be called START.
@POST
@Path("/saveExploreReport/{reportName}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes({ "application/json" })
public Response saveExploreReport( @PathParam("reportName") String reportName, String reportConfig) throws Exception
{
System.out.println("In saveExploreReport ["+reportName+"] reportConfig["+reportConfig+"]");
JSONObject respJsonObject = new JSONObject();
UserInfoBean userInfo = getUserInfo();
String trandDb = userInfo.getTransDB();
System.out.println("trandDb for save explore report==>"+trandDb);
try
{
if( userInfo != null )
{
System.out.println("if user info is not null==>"+userInfo);
ObjUserPrefDao objUserPrefDao = new ObjUserPrefDao();
String loginCode = userInfo.getLoginCode();
objUserPrefDao.saveExploreReport(loginCode,reportName,reportConfig,trandDb);
System.out.println("util result for save explore report==>"+objUserPrefDao);
}
}
catch (Exception e)
{
e.printStackTrace();
respJsonObject.put("result", "failure" );
}
return Response.status(200).entity( respJsonObject.toString() ).build();
}
//Added by Kamal.P Created a service which used to call the server from client end when save report functionality will be called END.
//Added by Kamal.P Created a service which used to call the server from client end when get report functionality will be called START.
@SuppressWarnings("unused")
@GET
@Path("/getExploreReport/{reportName}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes({ "application/json" })
public Response getExploreReport( @PathParam("reportName") String reportName) throws Exception
{
System.out.println("In getExploreReport ["+reportName+"]");
JSONObject respJsonObject = new JSONObject();
UserInfoBean userInfo = getUserInfo();
String tranDB = userInfo.getTransDB();
try
{
if( userInfo != null )
{
System.out.println("inside dashboard service if userInfo is not null for get Explore report"+userInfo);
ObjUserPrefDao objUserPrefDao = new ObjUserPrefDao();
String loginCode = userInfo.getLoginCode();
ObjUserPref userPref = objUserPrefDao.getExploreReport(loginCode, reportName, tranDB);
JSONObject reportConfig = new JSONObject(userPref.getPrefValue());
System.out.println("jsonObjectof reportConfig in get Explore Report===>"+reportConfig);
if(reportConfig != null)
{
System.out.println("if reportConfig is not null in getExploreReport ===>"+reportConfig);
respJsonObject.put("result", "success");
respJsonObject.put("report", reportConfig);
System.out.println("respJsonObject in getExploreReport===>"+reportConfig);
}
else
{
System.out.println("in else of get Explore report");
respJsonObject.put("result", "failure" );
}
}
}
catch (Exception e)
{
System.out.println("exception in service for get explore report");
e.printStackTrace();
respJsonObject.put("result", "failure" );
}
return Response.status(200).entity( respJsonObject.toString() ).build();
}
//Added by Kamal.P Created a service which used to call the server from client end when get report functionality will be called END.
private UserInfoBean getUserInfo()
{
UserInfoBean userInfo = null;
HttpSession session = request.getSession();
Object userObj = session.getAttribute( "USER_INFO" );
if(userObj != null)
{
try
{
userInfo = new UserInfoBean( userObj.toString() );
}
catch (BaseException e)
{
e.printStackTrace();
}
}
return userInfo;
}
}
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