package ibase.client;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.xml.client.Document;
import com.google.gwt.xml.client.Node;
import com.google.gwt.xml.client.NodeList;
import com.google.gwt.xml.client.XMLParser;

public class MetaDataDtl
{
	private String getDbDataSource = "";

	public String getGetDbDataSource()
	{
		return getDbDataSource;
	}

	public void setGetDbDataSource(String getDbDataSource)
	{
		this.getDbDataSource = getDbDataSource;
	}

	@SuppressWarnings("unchecked")
	public HashMap<String, HashMap> getGridNMapMetData(JSONObject jsonObjMetadata,String viewOptionSelectd)
	{
		Document document = null;
		ArrayList<String> metaDataList = null;
		LinkedHashMap<JSONString, JSONString> metaDataMap = new LinkedHashMap<JSONString, JSONString>();
		ArrayList<String> xAxisColunList = null;
		ArrayList<String> xAxisColumnName = null;
		ArrayList<String> yAxisColumnName = null;
		ArrayList<String> yAxisColunList = null;
		ArrayList<String> datsSourceDtlList = null;
		ArrayList<String> renderInfoList = null;
		ArrayList<String> showValList = null;
		ArrayList<String> lineVisibleList = null;
		ArrayList<String> dotThicknessList = null;

		ArrayList<String> colorInfoList = null;
		ArrayList<FilterInfo> fltrDtlList = null;
		NodeList gridNodeList = null;
		Node viewNode = null;
		NodeList viewNodeList = null;
		Node graphDataNode = null;
		NodeList xAxsisNodeList = null;
		Node xAxsisNode = null;
		NodeList yAaxixNodeList = null;
		Node yAxsisNode = null;
		String childNodeName = "";
		JSONString jsnStringKey = null;
		JSONString dataStringValue = null;
		String xmlMetadata = null;
		LinkedHashMap<String, ArrayList<String>> gridMeataDataMap = null;
		LinkedHashMap<String, ArrayList<String>> gridNameDataMap = null;
		LinkedHashMap<String, String> gridSizeDataMap = null;
		LinkedHashMap<String, String> gridCaptionDataMap = null;
		LinkedHashMap<String, String> gridAlignDataMap = null;
		LinkedHashMap<String, String> typeGridMap= null;
		LinkedHashMap<String, String> typeGraphMap= null;
		LinkedHashMap<String, String> gridDataSourceMap =null;
		LinkedHashMap<String, String> graphDataSourceMap = null;
		LinkedHashMap<String, String> divIdGrpMap= null;
		LinkedHashMap<String, String> gridCompTypeMap = null;

		LinkedHashMap<String, String> componentTypeMap = null;
		LinkedHashMap<String, ArrayList<String>> datsSourceDtlMap = null;
		LinkedHashMap<String, ArrayList<FilterInfo>> filterDtlMap = null;
		HashMap<String, ArrayList<Object>> graphMeataDataMap = null;
		HashMap<String, HashMap> gridNGraphMeataDataMap = null;
		Node columnGrpNode = null;
		NodeList columnGrpNodeList = null;
		ArrayList<String> columnIDList = null;
		ArrayList<String> chartTypeList = null;
		ArrayList<String> columnNameList = null;
		NodeList columsNodeList = null;
		Node columnNode = null;
		String title = "";
		Node colGrpTitlNode = null;
		String columnID = null;
		String columnName = null;
		Node rootNode = null;
		NodeList rootNodeList = null;
		ArrayList graphDtlList = null;
		NodeList graphNodeList = null;
		String attributeName = "";
		String graphID = "";
		String type = "";
		int conuter = 0;
		String columnGrpId = "";
		String renderDtl = "";
		String showValDtl = "";
		String colorDtl = "";
		String lineVisibleDtl = "";
		String dotThicknessDtl = "";
	//add on 20dec2014 by swati linkedchart
		NodeList pupUpOptNodeList=null;
		Node popUpNode=null;
		ArrayList<String> linkedMetadataList=null;
		ArrayList<String> linkTypeList=null;
		String linkedProperties="";
		String linkedMetadataName="";
		String linkTypeName="";
	//end on 20dec2014 by swati for linkedchart 
		//add on dated 9 july 201041
		Node chartPropertyNode = null;
		NodeList chartPropertyNodeList = null;

		if (jsonObjMetadata != null)
		{
			gridNGraphMeataDataMap 	= 	new HashMap<String, HashMap>();
			gridMeataDataMap 		= 	new LinkedHashMap<String, ArrayList<String>>();
			gridNameDataMap 		= 	new LinkedHashMap<String, ArrayList<String>>();
			gridSizeDataMap 		= 	new LinkedHashMap<String, String>();
			gridCaptionDataMap= 	new LinkedHashMap<String, String>();
			gridAlignDataMap 		= 	new LinkedHashMap<String, String>();
			divIdGrpMap= 	new LinkedHashMap<String, String>();
			componentTypeMap 		= 	new LinkedHashMap<String, String>();
			gridCompTypeMap 		= 	new LinkedHashMap<String, String>();
			datsSourceDtlMap 		= 	new LinkedHashMap<String, ArrayList<String>>();
			filterDtlMap 			= 	new LinkedHashMap<String, ArrayList<FilterInfo>>();
			xmlMetadata 			= 	jsonObjMetadata.get("metaData").toString();
			xmlMetadata 			= 	jsonObjMetadata.get("metaData").toString().replace("\\", "").trim();
			xmlMetadata 			= 	xmlMetadata.replace('"', ' ').trim();
			try
			{
				document = XMLParser.parse(xmlMetadata);
				XMLParser.removeWhitespace(document);
				if (document != null)
				{
					rootNodeList = document.getElementsByTagName("Root").item(0).getChildNodes();
					for (int rootCtr = 0; rootCtr < rootNodeList.getLength(); rootCtr++)
					{
						rootNode = rootNodeList.item(rootCtr);
						if ("datasource".equals(rootNode.getNodeName()))
						{
							datsSourceDtlList = new ArrayList<String>();
							String id = rootNode.getAttributes().getNamedItem("id").getNodeValue();
							datsSourceDtlList.add(rootNode.getAttributes().getNamedItem("driverName").getNodeValue());
							datsSourceDtlList.add(rootNode.getChildNodes().item(0).getNodeValue());
							datsSourceDtlMap.put(id, datsSourceDtlList);
						}
						String columnsize = "";
						String columnAlign = "";
						String dataSource="";
						if ("view".equals(rootNode.getNodeName()))
						{
							viewNodeList = rootNode.getChildNodes();
							if(!viewOptionSelectd.equals(rootNode.getAttributes().getNamedItem("name").getNodeValue()))
							{
							}
							if( viewOptionSelectd !=null && viewOptionSelectd.equals(rootNode.getAttributes().getNamedItem("name").getNodeValue()))
							{
								for (int viewCtr = 0; viewCtr < viewNodeList.getLength(); viewCtr++)
								{
									viewNode = viewNodeList.item(viewCtr);
									if ("grid".equals(viewNode.getNodeName()))
									{
										
										gridNameDataMap=new LinkedHashMap<String, ArrayList<String>>();
										gridMeataDataMap=new LinkedHashMap<String, ArrayList<String>>();
										gridSizeDataMap=new LinkedHashMap<String, String>();
										gridCaptionDataMap=new LinkedHashMap<String, String>();
										gridAlignDataMap=new LinkedHashMap<String, String>();
										typeGridMap = 	new LinkedHashMap<String, String>();
										gridDataSourceMap= 	new LinkedHashMap<String, String>();	
										gridCompTypeMap 	= 	new LinkedHashMap<String, String>();
										graphID = viewNode.getAttributes().getNamedItem("id").getNodeValue();
										dataSource = viewNode.getAttributes().getNamedItem("datasource").getNodeValue();
										type= viewNode.getAttributes().getNamedItem("type").getNodeValue();									
										gridDataSourceMap.put("datasource"+graphID, dataSource);
										typeGridMap.put("type"+graphID, type);
										gridNodeList = viewNode.getChildNodes();
										String componentType = "";
										String componentCaption="";
										for (int gridCtr = 0; gridCtr < gridNodeList.getLength(); gridCtr++)
										{
											columnGrpNode = gridNodeList.item(gridCtr);
											if (columnGrpNode.getNodeName().equals("component_type"))
											{
												componentType = columnGrpNode.getChildNodes().item(0).getNodeValue();
											}
											else if (columnGrpNode.getNodeName().equals("component_caption"))
											{
												componentCaption = columnGrpNode.getChildNodes().item(0).getNodeValue();
												
											} 
											else
											{
												columnGrpId = columnGrpNode.getAttributes().getNamedItem("id").getNodeValue();
												columnGrpNodeList = columnGrpNode.getChildNodes();
												columnIDList = new ArrayList<String>();
												columnNameList = new ArrayList<String>();
												for (int colmnCtr = 0; colmnCtr < columnGrpNodeList.getLength(); colmnCtr++)
												{
													colGrpTitlNode = columnGrpNodeList.item(colmnCtr);
													if ("col_group_title".equals(colGrpTitlNode.getNodeName()))
													{
														title = colGrpTitlNode.getChildNodes().item(0).getNodeValue();
													}
													if ("column_size".equals(colGrpTitlNode.getNodeName()))
													{
														columnsize = colGrpTitlNode.getChildNodes().item(0).getNodeValue();
													}
													if ("column_alignment".equals(colGrpTitlNode.getNodeName()))
													{
														columnAlign = colGrpTitlNode.getChildNodes().item(0).getNodeValue();
													}
													if ("columns".equals(colGrpTitlNode.getNodeName()))
													{
														columsNodeList = colGrpTitlNode.getChildNodes();
														for (int colCtr = 0; colCtr < columsNodeList.getLength(); colCtr++)
														{
															columnNode = columsNodeList.item(colCtr);
															columnName = columnNode.getChildNodes().item(0).getNodeValue();
															columnID = columnNode.getAttributes().getNamedItem("id").getNodeValue();
															columnIDList.add(columnID);
															columnNameList.add(columnName);
														}
													}
												}
											}
											if (!columnGrpNode.getNodeName().equals("component_type"))
											{
												gridMeataDataMap.put(columnGrpId, columnIDList);
												gridNameDataMap.put(title, columnNameList);
												gridSizeDataMap.put(title, columnsize);
												gridAlignDataMap.put(title, columnAlign);
											}
										}
										gridCaptionDataMap.put("componentCaption"+graphID,componentCaption );
										gridCompTypeMap.put("buildComponent"+graphID, componentType);
										gridNGraphMeataDataMap.put("componentType"+graphID, gridCompTypeMap);
										gridNGraphMeataDataMap.put(graphID, gridMeataDataMap);
										gridNGraphMeataDataMap.put("columnName"+graphID, gridNameDataMap);
										gridNGraphMeataDataMap.put("columnSize"+graphID, gridSizeDataMap);
										gridNGraphMeataDataMap.put("componentCaption"+graphID, gridCaptionDataMap);
										gridNGraphMeataDataMap.put("columnAlign"+graphID, gridAlignDataMap);
										gridNGraphMeataDataMap.put("type"+graphID, typeGridMap);
										gridNGraphMeataDataMap.put("datasource"+graphID, gridDataSourceMap);
										columnIDList = new ArrayList<String>();
										columnNameList= new ArrayList<String>();
									}
									if ("graph".equals(viewNode.getNodeName()))
									{
										typeGraphMap= 	new LinkedHashMap<String, String>();
										graphDataSourceMap= 	new LinkedHashMap<String, String>();									
										graphID = viewNode.getAttributes().getNamedItem("id").getNodeValue();
										type= viewNode.getAttributes().getNamedItem("type").getNodeValue();
										dataSource = viewNode.getAttributes().getNamedItem("datasource").getNodeValue();
										graphDataSourceMap.put("datasource"+graphID, dataSource);
										typeGraphMap.put("type"+graphID, type);									
										graphDtlList = new ArrayList<String>();
										xAxisColunList = new ArrayList<String>();
										yAxisColunList = new ArrayList<String>();
										metaDataList = new ArrayList<String>();
										xAxisColumnName = new ArrayList<String>();
										yAxisColumnName = new ArrayList<String>();
										renderInfoList = new ArrayList<String>();
										showValList = new ArrayList<String>();
										lineVisibleList = new ArrayList<String>();
										dotThicknessList = new ArrayList<String>();
										colorInfoList = new ArrayList<String>();
										graphMeataDataMap = new HashMap<String, ArrayList<Object>>();
										graphNodeList = viewNode.getChildNodes();
									//added by swati 20dec2014 for linked chart
										linkedMetadataList= new ArrayList<String>();
										linkTypeList = new ArrayList<String>();	
									//ended by swati 20dec2014 for linked chart
										for (int i = 0; i < graphNodeList.getLength(); i++)
										{
											graphDataNode = graphNodeList.item(i);
											childNodeName = graphDataNode.getNodeName();
											if ("column_group".equalsIgnoreCase(childNodeName))
											{
												attributeName = graphDataNode.getAttributes().getNamedItem("id").getNodeValue();
												if ("x_axis".equalsIgnoreCase(attributeName))
												{
													xAxsisNodeList = graphDataNode.getChildNodes();
													for (int j = 0; j < xAxsisNodeList.getLength(); j++)
													{
														xAxsisNode = xAxsisNodeList.item(j);
														if ("col_group_title".equals(xAxsisNode.getNodeName()))
														{
															dataStringValue = new JSONString(xAxsisNode.getChildNodes().item(0).getNodeValue());
															jsnStringKey = new JSONString("xAxisName");
															metaDataMap.put(jsnStringKey, dataStringValue);
														}
														if ("columns".equals(xAxsisNode.getNodeName()))
														{
															xAxsisNodeList = xAxsisNode.getChildNodes();
															for (int colCtr = 0; colCtr < xAxsisNodeList.getLength(); colCtr++)
															{
																columnNode = xAxsisNodeList.item(colCtr);
																columnID = columnNode.getAttributes().getNamedItem("id").getNodeValue();
																xAxisColunList.add(columnID);
																xAxisColumnName.add(columnNode.getChildNodes().item(0).getNodeValue());
															}
														}
													}
												}
												if ("y_axis".equalsIgnoreCase(attributeName))
												{
													yAaxixNodeList = graphDataNode.getChildNodes();
													for (int j = 0; j < yAaxixNodeList.getLength(); j++)
													{
														yAxsisNode = yAaxixNodeList.item(j);
														if ("col_group_title".equals(yAxsisNode.getNodeName()))
														{
															dataStringValue = new JSONString(yAxsisNode.getChildNodes().item(0).getNodeValue());
															jsnStringKey = new JSONString("yAxisName");
															metaDataMap.put(jsnStringKey, dataStringValue);
														}
														String flag = null;
														if ("columns".equals(yAxsisNode.getNodeName()))
														{
															flag = "false";
															NodeList yAxsisNodeList = yAxsisNode.getChildNodes();
															for (int colCtr = 0; colCtr < yAxsisNodeList.getLength(); colCtr++)
															{
																columnNode = yAxsisNodeList.item(colCtr);
																columnID = columnNode.getAttributes().getNamedItem("id").getNodeValue();
																yAxisColunList.add(columnID);
																yAxisColumnName.add(columnNode.getChildNodes().item(0).getNodeValue());
																renderDtl = columnNode.getAttributes().getNamedItem("render").getNodeValue();
																renderInfoList.add(renderDtl);
	
																showValDtl = columnNode.getAttributes().getNamedItem("showvalue").getNodeValue();
																showValList.add(showValDtl);
	
																colorDtl = columnNode.getAttributes().getNamedItem("color").getNodeValue();
																colorInfoList.add(colorDtl);
																if (columnNode.getAttributes().getNamedItem("linevisibility") != null)
																{
																	lineVisibleDtl = columnNode.getAttributes().getNamedItem("linevisibility").getNodeValue();
																	if (!lineVisibleDtl.trim().equals("0"))
																	{
																		flag = "true";
																	}
																	lineVisibleList.add(lineVisibleDtl);
																}
																if (columnNode.getAttributes().getNamedItem("dotthickness") != null)
																{
																	dotThicknessDtl = columnNode.getAttributes().getNamedItem("dotthickness").getNodeValue();
																	dotThicknessList.add(dotThicknessDtl);
																}
															//added  linked chart metadata name to graphdetail list by swati on 24 Dec 2014
																linkedMetadataName = columnNode.getAttributes().getNamedItem("linkedmetadata").getNodeValue();
																linkedMetadataList.add(linkedMetadataName);
																linkTypeName = columnNode.getAttributes().getNamedItem("linktype").getNodeValue();
																linkTypeList.add(linkTypeName);
														//added  linked chart metadata name to graphdetail list by swati on 24 Dec 2014	
															}
															if (flag.equals("false"))
															{
																metaDataMap.put(new JSONString("lineAlpha"), new JSONString("1"));
																metaDataMap.put(new JSONString("anchorBorderThickness"), new JSONString("3"));
															}
														}
														//added by swati   "placevaluesinside": "1",rotatevalues
														if ("left_yaxis_title".equals(yAxsisNode.getNodeName()))
														{
															dataStringValue = new JSONString(yAxsisNode.getChildNodes().item(0).getNodeValue());
															jsnStringKey = new JSONString("pyaxisname");
															metaDataMap.put(jsnStringKey, dataStringValue);
														}
														if ("right_yaxis_title".equals(yAxsisNode.getNodeName()))
														{
															dataStringValue = new JSONString(yAxsisNode.getChildNodes().item(0).getNodeValue());
															jsnStringKey = new JSONString("syaxisname");
															metaDataMap.put(jsnStringKey, dataStringValue);
														}
														//end added by swati	
													}
												}
											}
											//Add on dated by swati for chart_properties
											if ("chart_properties".equalsIgnoreCase(childNodeName))
											{
												chartTypeList = new ArrayList<String>();
	
												chartPropertyNodeList = graphDataNode.getChildNodes();
												for (int k = 0; k < chartPropertyNodeList.getLength(); k++)
												{
													chartPropertyNode = chartPropertyNodeList.item(k);
													if ("caption".equals(chartPropertyNode.getNodeName()))
													{
														dataStringValue = new JSONString(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														jsnStringKey = new JSONString("caption");
														metaDataMap.put(jsnStringKey, dataStringValue);
													}
													if ("labelDisplay".equals(chartPropertyNode.getNodeName()))
													{
														dataStringValue = new JSONString(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														jsnStringKey = new JSONString("labelDisplay");
														metaDataMap.put(jsnStringKey, dataStringValue);
													}
													if ("bg_color".equals(chartPropertyNode.getNodeName()))
													{
														dataStringValue = new JSONString(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														jsnStringKey = new JSONString("bgcolor");
														metaDataMap.put(jsnStringKey, dataStringValue);
													}
													if ("showlegend".equals(chartPropertyNode.getNodeName()))
													{
														dataStringValue = new JSONString(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														jsnStringKey = new JSONString("showLegend");
														metaDataMap.put(jsnStringKey, dataStringValue);
													}
	
													if ("useroundedges".equals(chartPropertyNode.getNodeName()))
													{
														dataStringValue = new JSONString(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														jsnStringKey = new JSONString("useroundedges");
														metaDataMap.put(jsnStringKey, dataStringValue);
													}
													if ("rotatevalues".equals(chartPropertyNode.getNodeName()))
													{
														dataStringValue = new JSONString(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														jsnStringKey = new JSONString("rotateValues");
														metaDataMap.put(jsnStringKey, dataStringValue);
													}
													if ("decimals".equals(chartPropertyNode.getNodeName()))
													{
														dataStringValue = new JSONString(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														jsnStringKey = new JSONString("decimals");
														metaDataMap.put(jsnStringKey, dataStringValue);
													}
													if ("formatnumberscale".equals(chartPropertyNode.getNodeName()))
													{
														dataStringValue = new JSONString(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														jsnStringKey = new JSONString("formatNumberScale");
														metaDataMap.put(jsnStringKey, dataStringValue);
													}
													if ("formatnumber".equals(chartPropertyNode.getNodeName()))
													{
														dataStringValue = new JSONString(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														jsnStringKey = new JSONString("formatNumber");
														metaDataMap.put(jsnStringKey, dataStringValue);
													}	
													if ("chart_type".equalsIgnoreCase(chartPropertyNode.getNodeName()))
													{
														dataStringValue = new JSONString(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														jsnStringKey = new JSONString("chart_type");
														graphDtlList.add(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														chartTypeList.add(chartPropertyNode.getAttributes().getNamedItem("id").getNodeValue());
													}
													if ("width".equalsIgnoreCase(chartPropertyNode.getNodeName()))
													{
														dataStringValue = new JSONString(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														jsnStringKey = new JSONString("width");
														graphDtlList.add(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														//metaDataMap.put(jsnStringKey, dataStringValue);
													}
													if ("height".equalsIgnoreCase(chartPropertyNode.getNodeName()))
													{
														dataStringValue = new JSONString(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														jsnStringKey = new JSONString("height");
														graphDtlList.add(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														//metaDataMap.put(jsnStringKey, dataStringValue);
													}
												//added  linked chart metadata name to graphdetail list by swati on 22 Dec 2014
													if ("win_properties".equalsIgnoreCase(chartPropertyNode.getNodeName()))
													{
														dataStringValue = new JSONString(chartPropertyNode.getChildNodes().item(0).getNodeValue());
														linkedProperties = (chartPropertyNode.getChildNodes().item(0).getNodeValue());
													}
											    //ended  linked chart metadata name to graphdetail list by swati on 22 Dec 2014
												}
											}
											
											//end swati for chart properties
											
								
										}
										metaDataList.add(metaDataMap.toString().replace('=', ':'));
										graphDtlList.add(xAxisColunList);
										graphDtlList.add(yAxisColunList);
										graphDtlList.add(metaDataList);
										graphDtlList.add(xAxisColumnName);
										graphDtlList.add(yAxisColumnName);
										graphDtlList.add(renderInfoList);
										graphDtlList.add(colorInfoList);
										graphDtlList.add(lineVisibleList);
										graphDtlList.add(dotThicknessList);
										graphDtlList.add(showValList);
										graphDtlList.add(chartTypeList);
									//added  linked chart metadata name to graphdetail list by swati on 22 Dec 2014
										graphDtlList.add(linkedMetadataList);
										graphDtlList.add(linkedProperties);
										graphDtlList.add(linkTypeList);										
									//ended  linked chart metadata name to graphdetail list by swati on 22 Dec 2014
										conuter++;
										gridNGraphMeataDataMap.put("type"+graphID, typeGraphMap);
										graphMeataDataMap.put("graph" + conuter, graphDtlList);
										gridNGraphMeataDataMap.put(graphID, graphMeataDataMap);
										gridNGraphMeataDataMap.put("datasource"+graphID, graphDataSourceMap);
									}
								}
							}
						}
					}
				}
			} catch (Exception e)
			{
				Window.alert(" Exception :: getGridNMapMetData() :: MetaDataDtl [" + e.getMessage() + "]");
			}
		}
		gridNGraphMeataDataMap.put("datSrc", datsSourceDtlMap);
	//	Window.alert("gridNGraphMeataDataMap:"+gridNGraphMeataDataMap);
		return gridNGraphMeataDataMap;
	}

	public ArrayList<FilterInfo> getFilters(JSONObject jsonObjMetadata)
	{
		Document document = null;
		String xmlMetadata = null;
		Node rootNode = null;
		NodeList rootNodeList = null;
		NodeList filtrNodeList = null;
		NodeList fltrDtlNodeList = null;
		Node columNode = null;
		ArrayList<FilterInfo> fltrDtlList = new ArrayList<FilterInfo>();
		;
		FilterInfo filterInfo = null;

		if (jsonObjMetadata != null)
		{
			xmlMetadata = jsonObjMetadata.get("metaData").toString();
			xmlMetadata = jsonObjMetadata.get("metaData").toString().replace("\\", "").trim();
			xmlMetadata = xmlMetadata.replace('"', ' ').trim();
			try
			{
				document = XMLParser.parse(xmlMetadata);
				XMLParser.removeWhitespace(document);
				if (document != null)
				{
					rootNodeList = document.getElementsByTagName("Root").item(0).getChildNodes();
					for (int rootCtr = 0; rootCtr < rootNodeList.getLength(); rootCtr++)
					{
						rootNode = rootNodeList.item(rootCtr);
						if ("filters".equals(rootNode.getNodeName()))
						{
							filtrNodeList = rootNode.getChildNodes();
							for (int fltrCtr = 0; fltrCtr < filtrNodeList.getLength(); fltrCtr++)
							{
								fltrDtlNodeList = filtrNodeList.item(fltrCtr).getChildNodes();
								filterInfo = new FilterInfo();

								filterInfo.setFiltertype(filtrNodeList.item(fltrCtr).getAttributes().getNamedItem("type").getNodeValue());
								for (int dtlCnt = 0; dtlCnt < fltrDtlNodeList.getLength(); dtlCnt++)
								{
									columNode = fltrDtlNodeList.item(dtlCnt);
									if ("col_title".equals(columNode.getNodeName()))
									{
										// fltrDtlList.add(columNode.getChildNodes().item(0).getNodeValue());
										filterInfo.setColTitle(columNode.getChildNodes().item(0).getNodeValue());
									}
									if ("col_name".equals(columNode.getNodeName()))
									{
										// fltrDtlList.add(columNode.getChildNodes().item(0).getNodeValue());

										filterInfo.setColName(columNode.getChildNodes().item(0).getNodeValue());
										filterInfo.setColNameId(columNode.getAttributes().getNamedItem("id").getNodeValue());
										filterInfo.setColModuleName(columNode.getAttributes().getNamedItem("moduleName").getNodeValue());
										/*Add Dhanendra For 2 Attribute in Metaxml 8Dec2014*/
										filterInfo.setName(columNode.getAttributes().getNamedItem("name").getNodeValue());
										filterInfo.setMandatory(columNode.getAttributes().getNamedItem("mandatory").getNodeValue());
										/*End Dhanendra For 2 Attribute in Metaxml 8Dec2014*/
										
									}
									if ("col_descr".equals(columNode.getNodeName()))
									{
										filterInfo.setColDescr(columNode.getChildNodes().item(0).getNodeValue());
										// fltrDtlList.add(columNode.getChildNodes().item(0).getNodeValue());
									}
								}
								fltrDtlList.add(filterInfo);
							}
						}
					}
				}
			} catch (Exception e)
			{
				Window.alert(" Exception :: :: getFilters() :: MetaDataDtl  [" + e.getMessage() + "]");
			}
		}
		return fltrDtlList;
	}

	public ArrayList<String> getTitle(JSONObject jsonObjMetadata)
	{
		Document document = null;
		String xmlMetadata = null;
		Node rootNode = null;
		NodeList rootNodeList = null;

		ArrayList<String> pageTitle = new ArrayList<String>();
		if (jsonObjMetadata != null)
		{
			xmlMetadata = jsonObjMetadata.get("metaData").toString();
			xmlMetadata = jsonObjMetadata.get("metaData").toString().replace("\\", "").trim();
			xmlMetadata = xmlMetadata.replace('"', ' ').trim();
			try
			{
				document = XMLParser.parse(xmlMetadata);
				XMLParser.removeWhitespace(document);
				if (document != null)
				{
					rootNodeList = document.getElementsByTagName("Root").item(0).getChildNodes();
					for (int rootCtr = 0; rootCtr < rootNodeList.getLength(); rootCtr++)
					{
						rootNode = rootNodeList.item(rootCtr);
						if ("page_title".equals(rootNode.getNodeName()))
						{
							pageTitle.add(rootNode.getChildNodes().item(0).getNodeValue());
						}
						if ("sub_title".equals(rootNode.getNodeName()))
						{
							pageTitle.add(rootNode.getChildNodes().item(0).getNodeValue());
						}
					}
				}
			} catch (Exception e)
			{
				Window.alert(" Exception :: getGridNMapMetData() :: MetaDataDtl [" + e.getMessage() + "]");
			}
		}
		return pageTitle;
	}
	
	
	
	
	public boolean isFiltrHide(JSONObject jsonObjMetadata)
	{
		boolean showFilter=false;
		Document document = null;
		String xmlMetadata = null;
		Node rootNode = null;
		NodeList rootNodeList = null;
		String fiterValue="";

		if (jsonObjMetadata != null)
		{
			xmlMetadata = jsonObjMetadata.get("metaData").toString();
			xmlMetadata = jsonObjMetadata.get("metaData").toString().replace("\\", "").trim();
			xmlMetadata = xmlMetadata.replace('"', ' ').trim();
			try
			{
				document = XMLParser.parse(xmlMetadata);
				XMLParser.removeWhitespace(document);
				if (document != null)
				{
					rootNodeList = document.getElementsByTagName("Root").item(0).getChildNodes();
					for (int rootCtr = 0; rootCtr < rootNodeList.getLength(); rootCtr++)
					{
						rootNode = rootNodeList.item(rootCtr);
						if ("filters".equals(rootNode.getNodeName()))
						{
							fiterValue=rootNode.getAttributes().getNamedItem("display").getNodeValue();
						}
					}
				}
			} catch (Exception e)
			{
				Window.alert(" Exception :: :: isFiltrHide() :: MetaDataDtl  [" + e.getMessage() + "]");
			}
		}
		if("Y".equalsIgnoreCase(fiterValue))
		{
			showFilter=true;
		}
		return showFilter;
	}
}
