Commit 1dfee3ba authored by prumde's avatar prumde

For processing composite elements

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@214106 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 7f7efc10
......@@ -414,6 +414,61 @@ public class DashboardUtil
componentData.remove("pivotcolumns");
}
finalDataArray = processColumnGroups(componentData);
componentData.put("columns", finalDataArray);
JSONArray finalCompositeArray = processComposite(componentData);
componentData.put("composite", finalCompositeArray);
System.out.println("componentData final::::::::"+componentData);
JSONObject feedJSON = componentData.optJSONObject("feed");
if(feedJSON != null) {
JSONArray tempFeedList = new JSONArray();
tempFeedList.put(feedJSON);
componentData.put("feed", tempFeedList);
}
JSONArray feedList = componentData.optJSONArray("feed");
if(feedList != null) {
for(int i = 0; i < feedList.length() ; i++) {
JSONObject detailJSON = feedList.getJSONObject(i).optJSONObject("detail");
if(detailJSON != null) {
JSONArray detailList = new JSONArray();
detailList.put(detailJSON);
feedList.getJSONObject(i).put("detail", detailList);
}
}
componentData.put("feed", feedList);
}
//Added By Saitej D on 26 Nov 2018 [To fetch report config from json file] START
JSONObject exploreDetails = componentData.optJSONObject("explore_details");
System.out.println("exploreDetails in getColumnsData::::::::"+exploreDetails);
if(exploreDetails != null && exploreDetails.length() > 0) {
String reportFile = exploreDetails.optString("reportFile");
System.out.println("exploreDetails reportFile in getColumnsData::::::::"+reportFile);
if(reportFile != null && !reportFile.isEmpty()) {
String reportFilePath = 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 +reportFile+".json";
File file = new File(reportFilePath);
if(file.exists()) {
String fileString = FileUtils.readFileToString(file);
JSONObject reportJson = new JSONObject(fileString);
exploreDetails.put("reportConfig", reportJson);
componentData.put("explore_details", exploreDetails);
}
}
}
//Added By Saitej D on 26 Nov 2018 [To fetch report config from json file] END
return componentData;
}
private JSONArray processColumnGroups(JSONObject componentData) throws JSONException
{
JSONArray finalDataArray = new JSONArray();
JSONArray columnGroup=componentData.optJSONArray("column_group");
if(columnGroup !=null) {
int idx = 0;
......@@ -421,16 +476,12 @@ public class DashboardUtil
for(int i = 0, size = columnGroup.length(); i < size; i++) {
JSONObject finalData = new JSONObject();
System.out.println("columnGroup if>>>>>>>>>");
//System.out.println("filter>>>>>>"+columnGroup);
JSONObject columsObj= columnGroup.optJSONObject(i);
System.out.println("columsObj>>>>>>"+columsObj);
// if(columsObj.optJSONArray("columns") instanceof JSONArray) {
// JSONArray columsArray=columsObj.optJSONArray("columns");
String linkMetadata=columsObj.optString("link_metadata");
System.out.println("link metadata "+linkMetadata );
if(linkMetadata != null && !linkMetadata.equalsIgnoreCase("{}")) {
columsObj.put("link_metadata",columsObj.optString("link_metadata") );
}
else {
columsObj.put("link_metadata", "");
......@@ -444,25 +495,8 @@ public class DashboardUtil
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);
}
*///TOBE REMOVE
for(int j = 0, sizeColumns = columsArray.length(); j < sizeColumns; j++) {
JSONObject columsArrayObj=columsArray.optJSONObject(j);
//JSONObject columArray=columsArrayObj.optJSONObject("column");
System.out.println("columsArrayObj>>>>>>"+columsArrayObj);
JSONObject columnData = new JSONObject();
......@@ -484,23 +518,6 @@ public class DashboardUtil
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);
}
*///TOBE REMOVE
}
else
{
......@@ -614,55 +631,7 @@ public class DashboardUtil
componentData.put("columns", finalDataArray);
}
}
//componentData.remove("column_group");
System.out.println("componentData final::::::::"+componentData);
// finalDataObj=getPivotTableData(componentData);
JSONObject feedJSON = componentData.optJSONObject("feed");
if(feedJSON != null) {
JSONArray tempFeedList = new JSONArray();
tempFeedList.put(feedJSON);
componentData.put("feed", tempFeedList);
}
JSONArray feedList = componentData.optJSONArray("feed");
if(feedList != null) {
for(int i = 0; i < feedList.length() ; i++) {
JSONObject detailJSON = feedList.getJSONObject(i).optJSONObject("detail");
if(detailJSON != null) {
JSONArray detailList = new JSONArray();
detailList.put(detailJSON);
feedList.getJSONObject(i).put("detail", detailList);
}
}
componentData.put("feed", feedList);
}
//Added By Saitej D on 26 Nov 2018 [To fetch report config from json file] START
JSONObject exploreDetails = componentData.optJSONObject("explore_details");
System.out.println("exploreDetails in getColumnsData::::::::"+exploreDetails);
if(exploreDetails != null && exploreDetails.length() > 0) {
String reportFile = exploreDetails.optString("reportFile");
System.out.println("exploreDetails reportFile in getColumnsData::::::::"+reportFile);
if(reportFile != null && !reportFile.isEmpty()) {
String reportFilePath = 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 +reportFile+".json";
File file = new File(reportFilePath);
if(file.exists()) {
String fileString = FileUtils.readFileToString(file);
JSONObject reportJson = new JSONObject(fileString);
exploreDetails.put("reportConfig", reportJson);
componentData.put("explore_details", exploreDetails);
}
}
}
//Added By Saitej D on 26 Nov 2018 [To fetch report config from json file] END
return componentData;
return finalDataArray;
}
private JSONObject getPivotTableData(JSONObject dashboardConfig) throws JSONException {
......@@ -1399,5 +1368,57 @@ public class DashboardUtil
return valueObj;
}
//Added by Prajyot on 26-DEC-2019 [For processing composite elements] Start
private JSONArray processComposite(JSONObject componentData) throws JSONException
{
JSONArray finalCompositeArray = new JSONArray();
JSONArray compositeArr = componentData.optJSONArray("composite");
if(compositeArr !=null)
{
for(int i = 0, size = compositeArr.length(); i < size; i++) {
System.out.println("compositeArr if>>>>>>>>>");
JSONObject compositeObj= compositeArr.optJSONObject(i);
System.out.println("compositeObj>>>>>>"+compositeObj);
String linkMetadata=compositeObj.optString("link_metadata");
System.out.println("link metadata "+linkMetadata );
if(linkMetadata != null && !linkMetadata.equalsIgnoreCase("{}")) {
compositeObj.put("link_metadata",compositeObj.optString("link_metadata") );
}
else {
compositeObj.put("link_metadata", "");
}
JSONArray finalDataArray = processColumnGroups(compositeObj);
compositeObj.put("columns", finalDataArray);
finalCompositeArray.put(compositeObj);
}
}
else
{
System.out.println("componentData else>>>>>>>>>"+componentData);
JSONObject compositeObj=componentData.optJSONObject("composite");
if(compositeObj != null) {
System.out.println("compositeObj>>>>>>"+compositeObj);
String linkMetadata=compositeObj.optString("link_metadata");
System.out.println("link metadata "+linkMetadata );
if(linkMetadata != null && !linkMetadata.equalsIgnoreCase("{}")) {
compositeObj.put("link_metadata",compositeObj.optString("link_metadata") );
}
else {
compositeObj.put("link_metadata", "");
}
JSONArray finalDataArray = processColumnGroups(compositeObj);
compositeObj.put("columns", finalDataArray);
finalCompositeArray.put(compositeObj);
}
}
return finalCompositeArray;
}
//Added by Prajyot on 26-DEC-2019 [For processing composite elements] 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