Commit bb3c025c authored by pborate's avatar pborate

Updated hibernate pophelp bean, dashboardUtil dao and dashboardservice class

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@182375 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 2bb9b074
...@@ -42,7 +42,7 @@ public class Pophelp implements java.io.Serializable ...@@ -42,7 +42,7 @@ public class Pophelp implements java.io.Serializable
private String sqlInput; private String sqlInput;
@Column(name="MULTI_OPT") @Column(name="MULTI_OPT")
private Integer multiOpt; private String multiOpt;
@Column(name="AUTO_FILL_LEN") @Column(name="AUTO_FILL_LEN")
private String autoFillLen; private String autoFillLen;
...@@ -59,8 +59,6 @@ public class Pophelp implements java.io.Serializable ...@@ -59,8 +59,6 @@ public class Pophelp implements java.io.Serializable
@Column(name="THUMB_ALT_COL") @Column(name="THUMB_ALT_COL")
private String thumbAltCol; private String thumbAltCol;
@Column(name="DIST_OPT") @Column(name="DIST_OPT")
private String distOpt; private String distOpt;
...@@ -85,7 +83,7 @@ public class Pophelp implements java.io.Serializable ...@@ -85,7 +83,7 @@ public class Pophelp implements java.io.Serializable
public Pophelp() { public Pophelp() {
} }
public Pophelp(String fieldName, String modName, String sqlInput, Integer multiOpt, String autoFillLen, String dataModelName, public Pophelp(String fieldName, String modName, String sqlInput, String multiOpt, String autoFillLen, String dataModelName,
String distOpt, String filterString, Integer defaultCol, String thumbObj, String thumbImageCol, String distOpt, String filterString, Integer defaultCol, String thumbObj, String thumbImageCol,
String thumbAltCol, String objNameDs, String validateData, String itemChange, String helpOption) { String thumbAltCol, String objNameDs, String validateData, String itemChange, String helpOption) {
super(); super();
...@@ -139,11 +137,11 @@ public class Pophelp implements java.io.Serializable ...@@ -139,11 +137,11 @@ public class Pophelp implements java.io.Serializable
this.sqlInput = sqlInput; this.sqlInput = sqlInput;
} }
public Integer getMultiOpt() { public String getMultiOpt() {
return multiOpt; return multiOpt;
} }
public void setMultiOpt(Integer multiOpt) { public void setMultiOpt(String multiOpt) {
this.multiOpt = multiOpt; this.multiOpt = multiOpt;
} }
......
...@@ -26,10 +26,10 @@ import javassist.bytecode.Descriptor.Iterator; ...@@ -26,10 +26,10 @@ import javassist.bytecode.Descriptor.Iterator;
public class DashboardUtil public class DashboardUtil
{ {
public JSONArray getDashboardConfig(String dashboardFileName) public JSONObject getDashboardConfig(String dashboardFileName)
{ {
//JSONObject dashboardConfig = new JSONObject(); //JSONObject dashboardConfig = new JSONObject();
JSONArray dashboardConfigFinal = new JSONArray(); JSONObject dashboardConfigFinal = new JSONObject();
try try
{ {
CommonConstants.setIBASEHOME(); CommonConstants.setIBASEHOME();
...@@ -52,11 +52,11 @@ public class DashboardUtil ...@@ -52,11 +52,11 @@ public class DashboardUtil
return dashboardConfigFinal; return dashboardConfigFinal;
} }
private JSONArray processMetadataXML(String dashboardFileContents) private JSONObject processMetadataXML(String dashboardFileContents)
{ {
JSONObject dashboardConfig = new JSONObject(); JSONObject dashboardConfig = new JSONObject();
JSONArray dashboardConfig1 = new JSONArray(); JSONObject dashboardConfig1 = new JSONObject();
try try
{ {
E12GenericUtility utility = new E12GenericUtility(); E12GenericUtility utility = new E12GenericUtility();
...@@ -80,13 +80,13 @@ public class DashboardUtil ...@@ -80,13 +80,13 @@ public class DashboardUtil
return dashboardConfig1; return dashboardConfig1;
} }
private JSONArray processDashboardMetadata(JSONObject dashboardConfig) throws JSONException private JSONObject processDashboardMetadata(JSONObject dashboardConfig) throws JSONException
{ {
JSONArray popHelp = new JSONArray(); JSONArray popHelp = new JSONArray();
JSONObject popHelpFunction = new JSONObject();
try try
{ {
JSONObject popHelpFunction = new JSONObject();
JSONObject view =dashboardConfig.optJSONObject("view"); JSONObject view =dashboardConfig.optJSONObject("view");
JSONArray viewArray =new JSONArray(); JSONArray viewArray =new JSONArray();
if(view != null) if(view != null)
...@@ -151,75 +151,54 @@ public class DashboardUtil ...@@ -151,75 +151,54 @@ public class DashboardUtil
} }
Object datasourceVal=dashboardConfig.get("datasource"); Object datasourceVal=dashboardConfig.get("datasource");
JSONArray datasource=new JSONArray();
System.out.println("datasourceVal ::::"+datasourceVal); System.out.println("datasourceVal ::::"+datasourceVal);
if(datasourceVal instanceof JSONArray) { if(datasourceVal instanceof JSONArray) {
JSONArray datasource=new 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); popHelpFunction.put("datasource", datasource);
} }
else { else {
JSONObject datasourceObj= dashboardConfig.optJSONObject("datasource"); JSONObject datasourceObj= dashboardConfig.optJSONObject("datasource");
System.out.println("datasourceObj ::::"+datasourceObj); datasource.put(datasourceObj);
popHelpFunction.put("datasource", datasourceObj); System.out.println("datasource obj::::"+datasource);
popHelpFunction.put("datasource", datasource);
} }
if(dashboardConfig.has("filters")) { if(dashboardConfig.has("filters")) {
JSONObject filters= dashboardConfig.getJSONObject("filters"); JSONObject filters= dashboardConfig.getJSONObject("filters");
System.out.println("filters ::::"+filters); System.out.println("filters ::::"+filters);
popHelpFunction=preapareFilterData(filters,popHelpFunction); filters=preapareFilterData(filters);
System.out.println("filters after"+filters);
popHelpFunction.put("filters", filters);
} }
popHelp.put(popHelpFunction); System.out.println("popHelpFunction FINAL"+popHelpFunction);
// popHelp.put(popHelpFunction);
} }
catch (Exception e) { catch (Exception e) {
System.out.println("Exception"+e); System.out.println("Exception"+e);
} }
return popHelp; return popHelpFunction;
//return dashboardConfig; //return dashboardConfig;
} }
public JSONObject getColumnsData(JSONObject componentData) throws JSONException{ public JSONObject getColumnsData(JSONObject componentData) throws JSONException{
JSONObject finalDataObj = new JSONObject();
JSONArray finalDataArray = new JSONArray(); JSONArray finalDataArray = new JSONArray();
System.out.println("componentData>>>>>>>>>"+componentData + "\n");
JSONObject componentDescr=componentData.optJSONObject("component_descr");
finalDataObj.put("component_descr", componentDescr);
String type=componentData.optString("type");
finalDataObj.put("type", type);
String ComponentTitle=componentData.optString("ComponentTitle");
finalDataObj.put("ComponentTitle", ComponentTitle);
JSONObject componentCaption=componentData.optJSONObject("component_caption");
finalDataObj.put("component_caption", componentCaption);
JSONObject layout=componentData.optJSONObject("layout");
finalDataObj.put("layout", layout);
String componentType=componentData.optString("component_type"); String componentType=componentData.optString("component_type");
finalDataObj.put("component_type", componentType);
if(componentType.equalsIgnoreCase("pivot-grid")) { if(componentType.equalsIgnoreCase("pivot-grid")) {
JSONObject pivotTableData=new JSONObject(); JSONObject pivotTableData=new JSONObject();
pivotTableData=getPivotTableData(componentData); pivotTableData=getPivotTableData(componentData);
finalDataObj.put("slice", pivotTableData); componentData.put("slice", pivotTableData);
componentData.remove("pivotrows");
componentData.remove("pivotvalues");
componentData.remove("pivotcolumns");
} }
String componentIcon=componentData.optString("component_icon");
finalDataObj.put("component_icon", componentIcon);
String datasource=componentData.optString("datasource");
finalDataObj.put("datasource", datasource);
String componentName=componentData.optString("ComponentName");
finalDataObj.put("ComponentName", componentName);
String componentCss=componentData.optString("component_css");
finalDataObj.put("component_css", componentCss);
String idCol=componentData.optString("id");
finalDataObj.put("id", idCol);
System.out.println("finalDataObj before>>>>>>"+finalDataObj);
JSONArray columnGroup=componentData.optJSONArray("column_group"); JSONArray columnGroup=componentData.optJSONArray("column_group");
//System.out.println("columnGroup:"+columnGroup + "\n");
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"); System.out.println("size>>>>>>>>>"+size + "\n");
...@@ -247,14 +226,16 @@ public class DashboardUtil ...@@ -247,14 +226,16 @@ public class DashboardUtil
finalDataArray.put(finalData); finalDataArray.put(finalData);
System.out.println("finalDataArray::::::::"+finalDataArray); System.out.println("finalDataArray::::::::"+finalDataArray);
} }
finalDataObj.put("columns", finalDataArray); componentData.put("columns", finalDataArray);
} }
} }
System.out.println("finalDataObj::::::::"+finalDataObj); componentData.remove("column_group");
System.out.println("componentData::::::::"+componentData);
// finalDataObj=getPivotTableData(componentData); // finalDataObj=getPivotTableData(componentData);
return finalDataObj; return componentData;
} }
private JSONObject getPivotTableData(JSONObject dashboardConfig) throws JSONException { private JSONObject getPivotTableData(JSONObject dashboardConfig) throws JSONException {
...@@ -349,109 +330,90 @@ public class DashboardUtil ...@@ -349,109 +330,90 @@ public class DashboardUtil
return finalDataObj; return finalDataObj;
} }
private JSONObject preapareFilterData(JSONObject filters,JSONObject popHelpFunction) throws JSONException{ private JSONObject preapareFilterData(JSONObject filters) throws JSONException{
try try
{ {
if(filters.has("filter"))
Object filterData=filters.get("filter");
JSONArray filter= filters.optJSONArray("filter");
JSONArray filterTemp=filter;
if(filterData instanceof JSONArray)
{ {
filter =new JSONArray(); JSONArray filter= filters.optJSONArray("filter");
List<String> systemOption = new ArrayList<String>(); JSONArray filterTemp=filter;
for(int i = 0, size = filterTemp.length(); i < size; i++){
System.out.println("filter>>>>>>"+filterTemp); if(filter !=null)
JSONObject fil= filterTemp.getJSONObject(i); {
String colName=fil.optString("col_name"); filter =new JSONArray();
String modName=fil.optString("mod_name"); List<String> systemOption = new ArrayList<String>();
String type=fil.optString("type"); for(int i = 0, size = filterTemp.length(); i < size; i++){
System.out.println("size>>>>>>"+size);
JSONObject fil= filterTemp.getJSONObject(i);
System.out.println("filter>>>>>> "+i+" "+fil);
String colName=fil.optString("col_name");
String modName=fil.optString("mod_name");
String type=fil.optString("type");
System.out.println("Inside type processDashboardFilter>>>>>>"+type);
JSONObject popHelpData = new JSONObject();
if(type.equalsIgnoreCase("1")) {
System.out.println("Inside if processDashboardFilter::::");
fil=processPophelpData(colName, modName,fil);
}
else {
fil.put("is_pophelp", false);
}
filter.put( fil);
}
// filters.put("filter", filter);
}
else
{
JSONObject filterObj= filters.optJSONObject("filter");
System.out.println("filter JSONObject>>>>>>"+filterObj);
String colName=filterObj.optString("col_name");
String modName=filterObj.optString("mod_name");
String type=filterObj.optString("type");
System.out.println("Inside type processDashboardFilter>>>>>>"+type); System.out.println("Inside type processDashboardFilter>>>>>>"+type);
JSONObject popHelpData = new JSONObject(); JSONObject popHelpData = new JSONObject();
if(type.equalsIgnoreCase("1")) { if(type.equalsIgnoreCase("1")) {
System.out.println("Inside if processDashboardFilter::::"); System.out.println("Inside if processDashboardFilter::::");
popHelpData=processPophelpData(colName, modName); filterObj=processPophelpData(colName, modName,filterObj);
} }
else { else {
popHelpData.put("is_pophelp", false); filterObj.put("is_pophelp", false);
} }
popHelpData.put("type", checkNull(fil.optString("type")));
popHelpData.put("col_id", checkNull(fil.optString("col_id"))); filter =new JSONArray();
popHelpData.put("col_descr", checkNull(fil.optString("col_descr"))); filter.put(filterObj);
popHelpData.put("default_value", checkNull(fil.optString("default_value"))); // filters.put("filter", filter);
popHelpData.put("col_name", checkNull(colName));
popHelpData.put("show_ontitle", checkNull(fil.optString("show_ontitle")));
popHelpData.put("mandatory", checkNull(fil.optString("mandatory")));
popHelpData.put("key_string", checkNull(fil.optString("key_string")));
System.out.println("processDashboardFilter ::::"+popHelpData);
filter.put( popHelpData);
System.out.println("filter ::::"+filter);
}
filters.put("filter", filter);
popHelpFunction.put("filters", filters);
System.out.println("popHelpFunction ::::"+popHelpFunction);
//System.out.println("popHelp ::::"+popHelpFunction);
}
else {
JSONObject filterObj= filters.optJSONObject("filter");
System.out.println("filter JSONObject>>>>>>"+filterObj);
String colName=filterObj.optString("col_name");
String modName=filterObj.optString("mod_name");
String type=filterObj.optString("type");
System.out.println("Inside type processDashboardFilter>>>>>>"+type);
JSONObject popHelpData = new JSONObject();
if(type.equalsIgnoreCase("1")) {
System.out.println("Inside if processDashboardFilter::::");
popHelpData=processPophelpData(colName, modName);
}
else {
popHelpData.put("is_pophelp", false);
} }
popHelpData.put("type", checkNull(filterObj.optString("type")));
popHelpData.put("col_id", checkNull(filterObj.optString("col_id")));
popHelpData.put("col_descr", checkNull(filterObj.optString("col_descr")));
popHelpData.put("default_value", checkNull(filterObj.optString("default_value")));
popHelpData.put("col_name", checkNull(colName));
popHelpData.put("show_ontitle", checkNull(filterObj.optString("show_ontitle")));
popHelpData.put("mandatory", checkNull(filterObj.optString("mandatory")));
popHelpData.put("key_string", checkNull(filterObj.optString("key_string")));
System.out.println("processDashboardFilter else ::::"+popHelpData);
filter =new JSONArray();
filter.put(popHelpData);
System.out.println("filter ::::"+filter);
filters.put("filter", filter); filters.put("filter", filter);
popHelpFunction.put("filters", filters);
System.out.println("popHelpFunction ::::"+popHelpFunction);
} }
} }
catch (Exception e) { catch (Exception e) {
System.out.println("Exception"+e); System.out.println("Exception"+e);
} }
return popHelpFunction; return filters;
} }
private JSONObject processPophelpData(String colName , String modName ) throws JSONException { private JSONObject processPophelpData(String colName , String modName,JSONObject filter ) throws JSONException {
Pophelp pophelpData = fetchAllPophelpData(colName, modName ); Pophelp pophelpData = fetchAllPophelpData(colName, modName );
System.out.println("pophelpList:::: processPophelpData"+pophelpData); System.out.println("pophelpList:::: processPophelpData"+pophelpData);
JSONObject pophelpConfig = new JSONObject(); // JSONObject pophelpConfig = new JSONObject();
if(pophelpData !=null) { if(pophelpData !=null) {
pophelpConfig.put("is_pophelp", true); filter.put("is_pophelp", true);
pophelpConfig.put("auto_fil_len", checkNull(pophelpData.getAutoFillLen())); filter.put("auto_fil_len", checkNull(pophelpData.getAutoFillLen()));
pophelpConfig.put("help_option", checkNull(pophelpData.getHelpOption())); filter.put("help_option", checkNull(pophelpData.getHelpOption()));
pophelpConfig.put("multi_option", checkNullInt(pophelpData.getMultiOpt())); filter.put("multi_option", checkNull(pophelpData.getMultiOpt()));
} }
else { else {
pophelpConfig.put("is_pophelp", false); filter.put("is_pophelp", false);
} }
System.out.println("is_pophelp:::: processPophelpData"+pophelpConfig); System.out.println("is_pophelp:::: processPophelpData"+filter);
return pophelpConfig; return filter;
} }
private Pophelp fetchAllPophelpData(String colName , String modName ) private Pophelp fetchAllPophelpData(String colName , String modName )
...@@ -463,8 +425,8 @@ public class DashboardUtil ...@@ -463,8 +425,8 @@ public class DashboardUtil
Session session = HibernateUtil.getSessionFactory().openSession(); Session session = HibernateUtil.getSessionFactory().openSession();
System.out.println("fetchAllPophelpData fieldName ["+colName+"] modName ["+modName+"]"); System.out.println("fetchAllPophelpData fieldName ["+colName+"] modName ["+modName+"]");
// 2. Create Query // 2. Create Query
Query query = session.createQuery("from Pophelp WHERE fieldName='"+colName+"' and" Query query = session.createQuery("from Pophelp WHERE fieldName=UPPER('"+colName+"') and"
+ " modName ='"+modName+"'"); + " modName = UPPER('w_"+modName+"')");
System.out.println("Inside fetchAllPophelpData query: [" + query + "]"); System.out.println("Inside fetchAllPophelpData query: [" + query + "]");
List<Pophelp> pophelpDataList = query.getResultList(); List<Pophelp> pophelpDataList = query.getResultList();
...@@ -572,20 +534,5 @@ public class DashboardUtil ...@@ -572,20 +534,5 @@ public class DashboardUtil
} }
private int checkNullInt(int str)
{
System.out.println("checknull int"+str);
if(str == 0)
{
return 0;
}
else
{
return str ;
}
}
} }
...@@ -11,6 +11,7 @@ import javax.ws.rs.core.Context; ...@@ -11,6 +11,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject;
//import com.sun.corba.se.impl.javax.rmi.CORBA.Util; //import com.sun.corba.se.impl.javax.rmi.CORBA.Util;
...@@ -31,7 +32,7 @@ public class DashboardService { ...@@ -31,7 +32,7 @@ public class DashboardService {
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();
JSONArray dashboardMetadata = util.getDashboardConfig(dashboardMetadataFilePath); JSONObject dashboardMetadata = util.getDashboardConfig(dashboardMetadataFilePath);
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