Commit 2173834e authored by dkasliwal's avatar dkasliwal

Create file for to open a drill-down dashboard in same page


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@103449 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f89efc9c
package ibase.client;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.google.gwt.core.client.Callback;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
public class SamePageOpenContainer
{
ArrayList<String> parametrList = null;
ArrayList<FilterInfo> filterList = null;
String urlStr = "";
String currentId = "";
public void getFrameJSONData(String metadataName, String url, String currentID)
{
CommonUtils.printOnConsole("In getFrameJSONData");
this.urlStr = url ;
this.currentId = currentID ;
CommonUtils.printOnConsole("metadataName :"+metadataName+"------------- urlStr :"+urlStr+"-------- currentId :"+currentId);
CommonUtils.printOnConsole("metadataName :"+metadataName+"------------- url :"+url+"-------- currentID :"+currentID);
parametrList = new ArrayList<String>();
parametrList.add(metadataName);
E12DashBoardPage.getJsonForFilterData(new Callback<JSONObject, String>()
{
@Override
public void onSuccess(JSONObject jsnObj)
{
JSONValue jsonValue = jsnObj.get("metaData");
if (jsonValue.toString().length() != 2)
{
getParameterList(jsnObj,urlStr,currentId);
}else
{
Window.alert("MetaData Should Be Proper");
}
}
@Override
public void onFailure(String result)
{
Window.alert("Exception :: getFrameJSONData getJsonForFilterData() [" + result + "]");
}
}, metadataName);
ArrayList<String> newDrillDownIdList = null;
ArrayList<String> tempIdList = null;
String mapKey = "";
HashMap<String, ArrayList<String>> drillDownIdsMapTemp = GWTDashBoardReport.drillDownIdsMap ;
//CommonUtils.printOnConsole("************ Custom Grid drillDownIdsMap => "+drillDownIdsMapTemp);
boolean isOver = false;
for(Map.Entry<String, ArrayList<String>> entry : drillDownIdsMapTemp.entrySet())
{
newDrillDownIdList = new ArrayList<String>();
tempIdList = new ArrayList<String>();
mapKey = entry.getKey();
tempIdList = entry.getValue();
int listIdSize = tempIdList.size();
//CommonUtils.printOnConsole("1312 E12DBMobReport Size of list = "+listIdSize);
for(int i = 0 ; i<listIdSize ; i++)
{
CommonUtils.printOnConsole(+i+"th Element tempIdList ="+tempIdList.get(i));
if(currentID.equalsIgnoreCase(tempIdList.get(i)))
{
//CommonUtils.printOnConsole("In if condition case matches");
newDrillDownIdList.add(tempIdList.get(i));
isOver = true;
break;
}
//CommonUtils.printOnConsole("In for loop i = "+i);
newDrillDownIdList.add(tempIdList.get(i));
}
if(isOver)
{
break;
}
}
//CommonUtils.printOnConsole("1332 E12DBMobReport newDrillDownIdList = "+newDrillDownIdList);
//CommonUtils.printOnConsole("1333 E12DBMobReport tempIdList List= "+tempIdList);
//CommonUtils.printOnConsole("1334 E12DBMobReport newDrillDownIdList.size() = "+newDrillDownIdList.size());
tempIdList.removeAll(newDrillDownIdList);
//CommonUtils.printOnConsole("tempIdList List after = "+tempIdList);
for(int j=tempIdList.size()-1; j>=0 ; j--)
{
//CommonUtils.printOnConsole("Value of j= "+j);
//CommonUtils.printOnConsole("Clearing divs of id = "+tempIdList.get(j));
clearDivContainer(tempIdList.get(j));
}
GWTDashBoardReport.drillDownIdsMap.put(mapKey, newDrillDownIdList);
}
public void getParameterList(JSONObject metaDataJsnObj,String url,String childID)
{
Date date = new Date();
MetaDataDtl dataDtl = new MetaDataDtl();
filterList =dataDtl.getFilters(metaDataJsnObj);
int year=0;
String month="";
String scmMonth="";
String monthYear="";
year= 1900+date.getYear();
month=String.valueOf(date.getMonth()+1);
scmMonth=String.valueOf((date.getMonth()));
if(month.trim().length()==1)
{
month="0"+month;
}
monthYear=year+month;
int count =0;
if(filterList.size()>0)
{
for (FilterInfo filterInfo : filterList)
{
count++;
//if(count==1)
CommonUtils.printOnConsole("filterInfo.getFieldName() :"+filterInfo.getFieldName());
if(filterInfo.getFieldName().equals("PRD_SALESDASH"))
{
String prdFilterName=filterInfo.getFieldName();
if(prdFilterName=="PRD_SALESDASH")
{
if(scmMonth.trim().length()==1)
{
scmMonth="0"+scmMonth;
}
monthYear=year+scmMonth;
parametrList.add(Window.Location.getParameter(filterInfo.getFieldName()) == null ? monthYear : Window.Location.getParameter(filterInfo.getFieldName()));
}
else
{
parametrList.add(Window.Location.getParameter(filterInfo.getFieldName()) == null ? monthYear : Window.Location.getParameter(filterInfo.getFieldName()));
}
}
/*Add code for current prd code by dhanendra on 06-10-2015 */
else if(filterInfo.getFieldName().equals("CURRENT_PRDCODE"))
{
parametrList.add(Window.Location.getParameter(filterInfo.getFieldName()) == null ? monthYear : Window.Location.getParameter(filterInfo.getFieldName()));
}
/*End code for current prd code by dhanendra on 06-10-2015 */
else
{
//parameterList.add(Window.Location.getParameter(filterInfo.getFieldName()) == null ? "" : Window.Location.getParameter(filterInfo.getFieldName()));
String guess = filterInfo.getFieldName();
CommonUtils.printOnConsole("guess :"+guess);
int wordLgth = guess.length();
CommonUtils.printOnConsole("wordLgth :"+wordLgth);
int index = url.indexOf(guess);
CommonUtils.printOnConsole("index :"+index);
if(index !=-1)
{
String newUri = url.substring(index + 1+wordLgth);
CommonUtils.printOnConsole("newUri :"+newUri);
int parameter = newUri.indexOf("&");
if(parameter == -1 && guess.equals("P1"))
{
parametrList.add(newUri);
}else{
CommonUtils.printOnConsole("parameter :"+parameter);
String paramVal = newUri.substring(0,parameter);
CommonUtils.printOnConsole("paramVal :"+paramVal);
parametrList.add(paramVal == null ? "" : paramVal);
}
CommonUtils.printOnConsole("parameterList in :"+parametrList);
}
else
{
parametrList.add("");
}
}
}
}
/*else
{
parameterList.add(Window.Location.getParameter("metadataname"));
}*/
GWTDashBoardReport boardReport = new GWTDashBoardReport();
parametrList.add(boardReport.getDefaultView(metaDataJsnObj));
CommonUtils.printOnConsole("parameterList in SamePage :"+parametrList);
E12DashBoardPage e12DashBoardPage = new E12DashBoardPage(parametrList,metaDataJsnObj,childID);
RootPanel.get("filterDiv").add(e12DashBoardPage);
}
public void putIdListInMap(String currentID, String childID)
{
CommonUtils.printOnConsole("in putIdListInMap");
ArrayList<String> newDrillDownIdList = null;
HashMap<String, ArrayList<String>> drillDownIdsMapTemp = null;
ArrayList<String> values = null;
String key = null;
ArrayList<String> ids = null;
//CommonUtils.printOnConsole("481 Graphcomponent -- childID => "+childID);
//CommonUtils.printOnConsole("480 Graphcomponent -- DrillDownIdsMap values => "+GWTDashBoardReport.drillDownIdsMap);
//CommonUtils.printOnConsole("------------------------------------------------------------------------------------");
if(childID.equalsIgnoreCase(""))
{
newDrillDownIdList = new ArrayList<String>();
newDrillDownIdList.add(currentID);
GWTDashBoardReport.drillDownIdsMap.put(currentID, newDrillDownIdList);
//CommonUtils.printOnConsole("486 Graphcomponent -- DrillDownIdsMap values => "+GWTDashBoardReport.drillDownIdsMap);
//CommonUtils.printOnConsole("------------------------------------------------------------------------------------");
}
else
{
drillDownIdsMapTemp = new HashMap<String, ArrayList<String>>();
drillDownIdsMapTemp = GWTDashBoardReport.drillDownIdsMap;
//CommonUtils.printOnConsole("490 else Graphcomponent -- DrillDownIdsMap values => "+GWTDashBoardReport.drillDownIdsMap);
//CommonUtils.printOnConsole("------------------------------------------------------------------------------------");
for(Map.Entry<String, ArrayList<String>> entry : drillDownIdsMapTemp.entrySet())
{
key = "";
key = entry.getKey();
values = new ArrayList<String>();
values = entry.getValue();
if(values.contains(childID))
{
//CommonUtils.printOnConsole("499 break Graphcomponent childID = "+childID);
//CommonUtils.printOnConsole("500 break values = "+values);
break;
}
else
{
key="";
}
}
//CommonUtils.printOnConsole("508 Graphcomponent key = "+key);
if(!key.equalsIgnoreCase(""))
{
ids = new ArrayList<String>();
ids = GWTDashBoardReport.drillDownIdsMap.get(key);
//CommonUtils.printOnConsole("512 Graphcomponent ids = "+ids);
ids.add(currentID);
//CommonUtils.printOnConsole("514 Graphcomponent ids = "+ids);
GWTDashBoardReport.drillDownIdsMap.put(key, ids);
///CommonUtils.printOnConsole("520 else Graphcomponent -- DrillDownIdsMap values => "+GWTDashBoardReport.drillDownIdsMap);
//CommonUtils.printOnConsole("------------------------------------------------------------------------------------");
}
}
}
public void closeLinkedMetadataDiv(Label closeButton)
{
CommonUtils.printOnConsole("click pn close button");
ArrayList<String> newDrillDownIdList = null;
ArrayList<String> tempIdList = null;
String mapKey = "";
HashMap<String, ArrayList<String>> drillDownIdsMapTemp = GWTDashBoardReport.drillDownIdsMap;
//CommonUtils.printOnConsole("636 graphcomponent drillDownIdsMap=>"+drillDownIdsMapTemp);
boolean isOver = false;
for(Map.Entry<String, ArrayList<String>> entry : drillDownIdsMapTemp.entrySet())
{
newDrillDownIdList = new ArrayList<String>();
tempIdList = new ArrayList<String>();
mapKey = entry.getKey();
tempIdList = entry.getValue();
int listIdSize = tempIdList.size();
//CommonUtils.printOnConsole("Size of list = "+listIdSize);
for(int i = 0 ; i<listIdSize ; i++)
{
CommonUtils.printOnConsole(+i+"th Element tempIdList ="+tempIdList.get(i));
if(closeButton.getElement().getId().equalsIgnoreCase(tempIdList.get(i)))
{
//CommonUtils.printOnConsole("In if condition case matches");
isOver = true;
break;
}
//CommonUtils.printOnConsole("In for loop i = "+i);
newDrillDownIdList.add(tempIdList.get(i));
}
if(isOver)
{
break;
}
}
//CommonUtils.printOnConsole("656 newDrillDownIdList = "+newDrillDownIdList);
//CommonUtils.printOnConsole("657 tempIdList List= "+tempIdList);
//CommonUtils.printOnConsole("658 newDrillDownIdList.size() = "+newDrillDownIdList.size());
tempIdList.removeAll(newDrillDownIdList);
//CommonUtils.printOnConsole("tempIdList List after = "+tempIdList);
for(int j=tempIdList.size()-1; j>=0 ; j--)
{
//CommonUtils.printOnConsole("Clearing divs of id = "+tempIdList.get(j));
clearDivContainer(tempIdList.get(j));
}
GWTDashBoardReport.drillDownIdsMap.put(mapKey, newDrillDownIdList);
}
private static native void clearDivContainer(String ChartId)
/*-{
try {
$wnd.clearDivOnCloseButton(ChartId);
} catch (e) {
E12CommonUtils.printOnConsole("Exception :: Custom Grid : clearDivOnCloseButton [" + e.message + "]");
}
}-*/;
}
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