Commit dee809c6 authored by vbhosale's avatar vbhosale

Added methods To Save Explore Report

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@194881 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0b090e9e
...@@ -1062,5 +1062,66 @@ public class DashboardUtil ...@@ -1062,5 +1062,66 @@ public class DashboardUtil
System.out.println("file exits "+fileCheck); System.out.println("file exits "+fileCheck);
return fileCheck; return fileCheck;
} }
//Added By Saitej D on [26 Dec 2018] To [Save Explore Report] START
public void saveExploreReport(String loginCode, String reportName, String reportConfig) {
String dashboardUsersPath = CommonConstants.JBOSSHOME + File.separator + "server" + File.separator + "default" + File.separator + "deploy" + File.separator + "ibase.ear" + File.separator + "ibase.war" + File.separator + "dashboard" + File.separator + "users";
String dashboardUserPath = dashboardUsersPath + File.separator + loginCode;
String reportFilepath = dashboardUserPath + File.separator +reportName+".json";
System.out.println("reportFilepath in saveExploreReport ["+reportFilepath+"]");
try
{
File existingUsersFolder = new File(dashboardUsersPath);
if(!existingUsersFolder.exists()) {
existingUsersFolder.mkdir();
}
File existingUserFolder = new File(dashboardUserPath);
if(!existingUserFolder.exists()) {
existingUserFolder.mkdir();
}
File existingFile = new File(reportFilepath);
if(!existingFile.exists()) {
existingFile.createNewFile();
}
FileUtils.writeStringToFile(existingFile, reportConfig);
}
catch(Exception e)
{
System.out.println("Exception in saveExploreReport ::["+e+"]");
}
}
public JSONObject getExploreReport(String loginCode, String reportName) {
String dashboardUsersPath = CommonConstants.JBOSSHOME + File.separator + "server" + File.separator + "default" + File.separator + "deploy" + File.separator + "ibase.ear" + File.separator + "ibase.war" + File.separator + "dashboard" + File.separator + "users";
String dashboardUserPath = dashboardUsersPath + File.separator + loginCode;
String reportFilepath = dashboardUserPath + File.separator +reportName+".json";
JSONObject reportConfig = null;
System.out.println("reportFilepath in saveExploreReport ["+reportFilepath+"]");
try
{
File existingUsersFolder = new File(dashboardUsersPath);
File existingUserFolder = new File(dashboardUserPath);
File file = new File(reportFilepath);
if(existingUsersFolder.exists() && existingUserFolder.exists() && file.exists())
{
String fileString = FileUtils.readFileToString(file);
reportConfig = new JSONObject(fileString);
}
}
catch(Exception e)
{
System.out.println("Exception in getExploreReport ::["+e+"]");
}
return reportConfig;
}
//Added By Saitej D on [26 Dec 2018] To [Save Explore Report] END
} }
package ibase.dashboard.common.webService; package ibase.dashboard.common.webService;
import java.io.File; import java.io.File;
import java.util.Date;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
...@@ -21,7 +26,10 @@ import javax.ws.rs.core.Context; ...@@ -21,7 +26,10 @@ import javax.ws.rs.core.Context;
//import com.sun.corba.se.impl.javax.rmi.CORBA.Util; //import com.sun.corba.se.impl.javax.rmi.CORBA.Util;
import ibase.dashboard.common.hibernate.dao.DashboardUtil; import ibase.dashboard.common.hibernate.dao.DashboardUtil;
import ibase.ejb.UserEventLogEJB;
import ibase.utility.BaseException;
import ibase.utility.CommonConstants; import ibase.utility.CommonConstants;
import ibase.utility.UserInfoBean;
@Path("/dashboard") @Path("/dashboard")
public class DashboardService { public class DashboardService {
...@@ -97,6 +105,92 @@ public class DashboardService { ...@@ -97,6 +105,92 @@ public class DashboardService {
return dashboardMetadata.toString(); return dashboardMetadata.toString();
} }
//Added By Saitej D on [26 Dec 2018] To [Save Explore Report] 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();
try
{
if( userInfo != null )
{
DashboardUtil util = new DashboardUtil();
String loginCode = userInfo.getLoginCode();
util.saveExploreReport(loginCode, reportName, reportConfig);
}
}
catch (Exception e)
{
e.printStackTrace();
respJsonObject.put("result", "failure" );
}
return Response.status(200).entity( respJsonObject.toString() ).build();
}
@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();
try
{
if( userInfo != null )
{
DashboardUtil util = new DashboardUtil();
String loginCode = userInfo.getLoginCode();
JSONObject reportConfig = util.getExploreReport(loginCode, reportName);
if(reportConfig != null)
{
respJsonObject.put("result", "success");
respJsonObject.put("report", reportConfig);
}
else
{
respJsonObject.put("result", "failure" );
}
}
}
catch (Exception e)
{
e.printStackTrace();
respJsonObject.put("result", "failure" );
}
return Response.status(200).entity( respJsonObject.toString() ).build();
}
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;
}
//Added By Saitej D on [26 Dec 2018] To [Save Explore Report] END
} }
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