Commit 767272c6 authored by pborate's avatar pborate

Updated common dashboard jar classes

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@183370 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c5bd457a
...@@ -7,6 +7,9 @@ import java.util.ArrayList; ...@@ -7,6 +7,9 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.Query; import org.hibernate.Query;
...@@ -23,10 +26,15 @@ import ibase.dashboard.common.hibernate.bean.Pophelp; ...@@ -23,10 +26,15 @@ import ibase.dashboard.common.hibernate.bean.Pophelp;
import ibase.dashboard.common.hibernate.utility.HibernateUtil; import ibase.dashboard.common.hibernate.utility.HibernateUtil;
import ibase.utility.CommonConstants; import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.DBAccessRemote;
import ibase.system.config.AppConnectParm;
import javax.naming.InitialContext;
public class DashboardUtil public class DashboardUtil
{ {
public JSONObject getDashboardConfig(String dashboardFileName) public JSONObject getDashboardConfig(String dashboardFileName,UserInfoBean userInfo)
{ {
//JSONObject dashboardConfig = new JSONObject(); //JSONObject dashboardConfig = new JSONObject();
JSONObject dashboardConfigFinal = new JSONObject(); JSONObject dashboardConfigFinal = new JSONObject();
...@@ -40,7 +48,7 @@ public class DashboardUtil ...@@ -40,7 +48,7 @@ public class DashboardUtil
File dashboardFile = new File( dashboardFileName ); File dashboardFile = new File( dashboardFileName );
String dashboardFileContents = FileUtils.readFileToString(dashboardFile); String dashboardFileContents = FileUtils.readFileToString(dashboardFile);
System.out.println("dashboardFileContents =" + dashboardFileContents); System.out.println("dashboardFileContents =" + dashboardFileContents);
dashboardConfigFinal = processMetadataXML(dashboardFileContents); dashboardConfigFinal = processMetadataXML(dashboardFileContents,userInfo);
} }
catch (IOException e) catch (IOException e)
{ {
...@@ -52,8 +60,9 @@ public class DashboardUtil ...@@ -52,8 +60,9 @@ public class DashboardUtil
return dashboardConfigFinal; return dashboardConfigFinal;
} }
private JSONObject processMetadataXML(String dashboardFileContents) private JSONObject processMetadataXML(String dashboardFileContents,UserInfoBean userInfo) throws NamingException, Exception
{ {
JSONObject dashboardConfig = new JSONObject(); JSONObject dashboardConfig = new JSONObject();
JSONObject dashboardConfig1 = new JSONObject(); JSONObject dashboardConfig1 = new JSONObject();
...@@ -69,21 +78,20 @@ public class DashboardUtil ...@@ -69,21 +78,20 @@ public class DashboardUtil
} }
System.out.println("dashboardConfig xml>>" + dashboardConfig); System.out.println("dashboardConfig xml>>" + dashboardConfig);
dashboardConfig1 = processDashboardMetadata(dashboardConfig); dashboardConfig1 = processDashboardMetadata(dashboardConfig,userInfo);
System.out.println("dashboardConfig>>" + dashboardConfig1); System.out.println("dashboardConfig>>" + dashboardConfig1);
} }
catch(Exception e){ catch(Exception e){
} }
return dashboardConfig1; return dashboardConfig1;
} }
private JSONObject processDashboardMetadata(JSONObject dashboardConfig) throws JSONException private JSONObject processDashboardMetadata(JSONObject dashboardConfig,UserInfoBean userInfo) throws JSONException
{ {
JSONArray popHelp = new JSONArray(); JSONArray popHelp = new JSONArray();
JSONObject popHelpFunction = new JSONObject(); //JSONObject popHelpFunction = new JSONObject();
try try
{ {
...@@ -96,18 +104,21 @@ public class DashboardUtil ...@@ -96,18 +104,21 @@ public class DashboardUtil
System.out.println("view in if === "+view); System.out.println("view in if === "+view);
JSONArray componentDataNewArray = new JSONArray(); JSONArray componentDataNewArray = new JSONArray();
JSONObject componentData = view.optJSONObject("component"); JSONObject componentData = view.optJSONObject("component");
System.out.println("componentData in if === "+componentData);
if(componentData != null) { if(componentData != null) {
componentData = getColumnsData(componentData); componentData = getColumnsData(componentData,userInfo);
componentDataNewArray.put(componentData); componentDataNewArray.put(componentData);
} }
else { else {
JSONArray componentDataArray = view.optJSONArray("component"); JSONArray componentDataArray = view.optJSONArray("component");
System.out.println("componentDataArray in if === "+componentDataArray);
for(int i = 0, size = componentDataArray.length(); i < size; i++) { for(int i = 0, size = componentDataArray.length(); i < size; i++) {
componentData = getColumnsData(componentDataArray.optJSONObject(i)); componentData = getColumnsData(componentDataArray.optJSONObject(i),userInfo);
componentDataNewArray.put(componentData); componentDataNewArray.put(componentData);
} }
} }
view.put("component", componentDataNewArray); view.put("component", componentDataNewArray);
System.out.println("view in final === "+view);
viewArray.put(view); viewArray.put(view);
} }
else else
...@@ -122,7 +133,7 @@ public class DashboardUtil ...@@ -122,7 +133,7 @@ public class DashboardUtil
JSONObject componentData = viewData.optJSONObject("component"); JSONObject componentData = viewData.optJSONObject("component");
if(componentData != null) { if(componentData != null) {
//System.out.println("viewDataArray in else if === "+componentData); //System.out.println("viewDataArray in else if === "+componentData);
componentData = getColumnsData(componentData); componentData = getColumnsData(componentData,userInfo);
//System.out.println("viewDataArray in else if>>>>> === "+viewDataArray); //System.out.println("viewDataArray in else if>>>>> === "+viewDataArray);
componentDataNewArray.put(componentData); componentDataNewArray.put(componentData);
} }
...@@ -130,7 +141,7 @@ public class DashboardUtil ...@@ -130,7 +141,7 @@ public class DashboardUtil
//System.out.println("viewDataArray in else for === "+viewDataArray); //System.out.println("viewDataArray in else for === "+viewDataArray);
JSONArray componentDataArray = componentData.optJSONArray("component"); JSONArray componentDataArray = componentData.optJSONArray("component");
for(int j = 0, size = componentDataArray.length(); j < size; j++) { for(int j = 0, size = componentDataArray.length(); j < size; j++) {
componentData = getColumnsData(componentDataArray.optJSONObject(j)); componentData = getColumnsData(componentDataArray.optJSONObject(j),userInfo);
componentDataNewArray.put(componentData); componentDataNewArray.put(componentData);
} }
} }
...@@ -142,18 +153,9 @@ public class DashboardUtil ...@@ -142,18 +153,9 @@ public class DashboardUtil
} }
System.out.println("viewArray in else if>>>>> === "+viewArray); System.out.println("viewArray in else if>>>>> === "+viewArray);
popHelpFunction.put("view", viewArray); dashboardConfig.put("view", viewArray);
}
System.out.println("popHelpFunction type === "+popHelpFunction);
if(dashboardConfig.has("page_title")) {
String page_title= dashboardConfig.getString("page_title");
System.out.println("page_title ::::"+page_title);
if(page_title.length()>0)
{
popHelpFunction.put("page_title", page_title);
}
} }
System.out.println("dashboardConfig type === "+dashboardConfig);
if(dashboardConfig.has("datasource")) { if(dashboardConfig.has("datasource")) {
Object datasourceVal=dashboardConfig.opt("datasource"); Object datasourceVal=dashboardConfig.opt("datasource");
...@@ -162,13 +164,13 @@ public class DashboardUtil ...@@ -162,13 +164,13 @@ public class DashboardUtil
if(datasourceVal instanceof JSONArray) { if(datasourceVal instanceof JSONArray) {
datasource= dashboardConfig.optJSONArray("datasource"); datasource= dashboardConfig.optJSONArray("datasource");
System.out.println("datasource ::::["+datasource+"] datasource length ["+datasource.length()+"]"); System.out.println("datasource ::::["+datasource+"] datasource length ["+datasource.length()+"]");
popHelpFunction.put("datasource", datasource); dashboardConfig.put("datasource", datasource);
} }
else { else {
JSONObject datasourceObj= dashboardConfig.optJSONObject("datasource"); JSONObject datasourceObj= dashboardConfig.optJSONObject("datasource");
datasource.put(datasourceObj); datasource.put(datasourceObj);
System.out.println("datasource obj::::"+datasource); System.out.println("datasource obj::::"+datasource);
popHelpFunction.put("datasource", datasource); dashboardConfig.put("datasource", datasource);
} }
} }
...@@ -177,25 +179,39 @@ public class DashboardUtil ...@@ -177,25 +179,39 @@ public class DashboardUtil
System.out.println("filters ::::"+filters); System.out.println("filters ::::"+filters);
filters=preapareFilterData(filters); filters=preapareFilterData(filters);
System.out.println("filters after"+filters); System.out.println("filters after"+filters);
popHelpFunction.put("filters", filters); dashboardConfig.put("filters", filters);
} }
System.out.println("popHelpFunction FINAL"+popHelpFunction); System.out.println("dashboardConfig FINAL"+dashboardConfig);
// popHelp.put(popHelpFunction); // popHelp.put(popHelpFunction);
} }
catch (Exception e) { catch (Exception e) {
System.out.println("Exception"+e); System.out.println("Exception"+e);
} }
return popHelpFunction; return dashboardConfig;
//return dashboardConfig; //return dashboardConfig;
} }
public JSONObject getColumnsData(JSONObject componentData) throws JSONException{ public JSONObject getColumnsData(JSONObject componentData,UserInfoBean userInfo) throws NamingException, Exception{
JSONArray finalDataArray = new JSONArray(); JSONArray finalDataArray = new JSONArray();
String componentType=componentData.optString("component_type"); String componentType=componentData.optString("component_type");
System.out.println("componentType:::"+componentType);
/*
String responseStr = "";
String objName=componentData.optString("obj_name");
if(userInfo != null && objName !=null ) {
System.out.println("userInfo for dbAccess"+userInfo+","+objName);
AppConnectParm appConnect = new AppConnectParm();
InitialContext ctx = new InitialContext(appConnect.getProperty());
DBAccessRemote dbAccess = ( DBAccessRemote )ctx.lookup( "ibase/DBAccessEJB/remote" );
responseStr = dbAccess.getAllActionLinksJson(objName, userInfo);
System.out.println("response for dbAccess"+responseStr);
}
*/
if(componentType.equalsIgnoreCase("pivot-grid")) { if(componentType.equalsIgnoreCase("pivot-grid")) {
JSONObject pivotTableData=new JSONObject(); JSONObject pivotTableData=new JSONObject();
pivotTableData=getPivotTableData(componentData); pivotTableData=getPivotTableData(componentData);
...@@ -208,17 +224,50 @@ public class DashboardUtil ...@@ -208,17 +224,50 @@ public class DashboardUtil
JSONArray columnGroup=componentData.optJSONArray("column_group"); JSONArray columnGroup=componentData.optJSONArray("column_group");
if(columnGroup !=null) { if(columnGroup !=null) {
for(int i = 0, size = columnGroup.length(); i < size; i++) { for(int i = 0, size = columnGroup.length(); i < size; i++) {
System.out.println("size>>>>>>>>>"+size + "\n");
JSONObject finalData = new JSONObject(); JSONObject finalData = new JSONObject();
System.out.println("columnGroup if>>>>>>>>>");
//System.out.println("filter>>>>>>"+columnGroup); //System.out.println("filter>>>>>>"+columnGroup);
JSONObject columsObj= columnGroup.optJSONObject(i); JSONObject columsObj= columnGroup.optJSONObject(i);
System.out.println("filter>>>>>>"+columsObj); System.out.println("columsObj>>>>>>"+columsObj);
if(columsObj.optJSONArray("columns") instanceof JSONArray) { if(columsObj.optJSONArray("columns") instanceof JSONArray) {
JSONArray columsArray=columsObj.optJSONArray("columns"); JSONArray columsArray=columsObj.optJSONArray("columns");
System.out.println("columsArray>>>>>>"+columsArray); System.out.println("columsArray>>>>>>"+columsArray);
if(columsArray != null)
{
for(int j = 0, sizeColumns = columsArray.length(); j < sizeColumns; j++) {
JSONObject columsArrayObj=columsArray.optJSONObject(j);
JSONObject columArray=columsArrayObj.optJSONObject("column");
System.out.println("columArray>>>>>>"+columArray);
if(columArray != null) {
String id=columArray.optString("id");
String value=columArray.optString("value");
finalData.put("uniqueName", id);
finalData.put("caption", value);
}
System.out.println("finalData>>>>>>"+finalData);
finalDataArray.put(finalData);
System.out.println("finalDataArray::::::::"+finalDataArray);
}
}
else {
JSONObject columsArrayObj=columsObj.optJSONObject("columns");
JSONObject columArray=columsArrayObj.optJSONObject("column");
System.out.println("columArray>>>>>>"+columArray);
if(columArray != null) {
String id=columArray.optString("id");
String value=columArray.optString("value");
finalData.put("uniqueName", id);
finalData.put("caption", value);
}
System.out.println("finalData>>>>>>"+finalData);
finalDataArray.put(finalData);
System.out.println("finalDataArray::::::::"+finalDataArray);
}
} }
else { else
{
JSONObject columsArray=columsObj.optJSONObject("columns"); JSONObject columsArray=columsObj.optJSONObject("columns");
System.out.println("columsArray>>>>>>else"+columsArray); System.out.println("columsArray>>>>>>else"+columsArray);
JSONObject columArray=columsArray.optJSONObject("column"); JSONObject columArray=columsArray.optJSONObject("column");
...@@ -234,7 +283,49 @@ public class DashboardUtil ...@@ -234,7 +283,49 @@ public class DashboardUtil
System.out.println("finalDataArray::::::::"+finalDataArray); System.out.println("finalDataArray::::::::"+finalDataArray);
} }
componentData.put("columns", finalDataArray); componentData.put("columns", finalDataArray);
}
}
else
{
System.out.println("componentData else>>>>>>>>>"+componentData);
JSONObject columnGroupObj=componentData.optJSONObject("column_group");
if(columnGroupObj != null) {
JSONObject finalData = new JSONObject();
System.out.println("columnGroup else>>>>>>>>>"+columnGroupObj);
JSONArray columnsArray =columnGroupObj.optJSONArray("columns");
System.out.println("columnsArray else>>>>>>>>>"+columnsArray);
if(columnsArray != null ) {
for(int i = 0, sizeColumns = columnsArray.length(); i < sizeColumns; i++) {
JSONObject columsArrayObj=columnsArray.optJSONObject(i);
JSONObject columArray=columsArrayObj.optJSONObject("column");
System.out.println("columArray>>>>>>"+columArray);
if(columArray != null) {
String id=columArray.optString("id");
String value=columArray.optString("value");
finalData.put("uniqueName", id);
finalData.put("caption", value);
}
System.out.println("finalData>>>>>>"+finalData);
finalDataArray.put(finalData);
System.out.println("finalDataArray::::::::"+finalDataArray);
}
}
else {
JSONObject columsArray=columnGroupObj.optJSONObject("columns");
System.out.println("columsArray>>>>>>else"+columsArray);
JSONObject columArray=columsArray.optJSONObject("column");
System.out.println("columArray>>>>>> else"+columArray);
if(columArray != null) {
String id=columArray.optString("id");
String value=columArray.optString("value");
finalData.put("uniqueName", id);
finalData.put("caption", value);
}
System.out.println("finalData>>>>>>"+finalData);
finalDataArray.put(finalData);
System.out.println("finalDataArray::::::::"+finalDataArray);
}
componentData.put("columns", finalDataArray);
} }
} }
componentData.remove("column_group"); componentData.remove("column_group");
......
...@@ -13,6 +13,11 @@ import javax.ws.rs.core.MediaType; ...@@ -13,6 +13,11 @@ import javax.ws.rs.core.MediaType;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
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;
...@@ -22,17 +27,26 @@ import ibase.utility.CommonConstants; ...@@ -22,17 +27,26 @@ import ibase.utility.CommonConstants;
public class DashboardService { public class DashboardService {
@Context @Context
HttpServletRequest request; // The proxy of Request will be injected into this singleton HttpServletRequest request; // The proxy of Request will be injected into this singleton
@Context
ServletContext context;
@GET @GET
@Path("/metadata/{dashboardFileName}") @Path("/metadata/{dashboardFileName}")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String getDashboardMetadata( @PathParam("dashboardFileName") String dashboardFileName ) throws Exception public String getDashboardMetadata( @PathParam("dashboardFileName") String dashboardFileName ) throws Exception
{ {
System.out.println("getDashboardMetadata ["+CommonConstants.JBOSSHOME+"] dashboardFileName[" + dashboardFileName + "] "); System.out.println("getDashboardMetadata ["+CommonConstants.JBOSSHOME+"] dashboardFileName[" + dashboardFileName + "] ");
String dashboardMetadataFilePath = 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 +dashboardFileName+".xml"; String dashboardMetadataFilePath = 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 +dashboardFileName+".xml";
System.out.println("Final File Path =" + dashboardMetadataFilePath); System.out.println("Final File Path =" + dashboardMetadataFilePath);
DashboardUtil util = new DashboardUtil(); DashboardUtil util = new DashboardUtil();
JSONObject dashboardMetadata = util.getDashboardConfig(dashboardMetadataFilePath); HttpSession session = request.getSession();
ibase.utility.UserInfoBean userInfo = ( ibase.utility.UserInfoBean )session.getAttribute( "USER_INFO" );
JSONObject dashboardMetadata = util.getDashboardConfig(dashboardMetadataFilePath,userInfo);
return dashboardMetadata.toString(); return dashboardMetadata.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