summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java')
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java143
1 files changed, 83 insertions, 60 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java
index a50a04eb..0846efda 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java
@@ -73,6 +73,7 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
@@ -95,6 +96,7 @@ import org.onap.portalsdk.analytics.error.RaptorSchedularException;
import org.onap.portalsdk.analytics.error.ReportSQLException;
import org.onap.portalsdk.analytics.error.UserDefinedException;
import org.onap.portalsdk.analytics.error.ValidationException;
+import org.onap.portalsdk.analytics.model.DashboardChildReport;
import org.onap.portalsdk.analytics.model.DataCache;
import org.onap.portalsdk.analytics.model.ReportHandler;
import org.onap.portalsdk.analytics.model.ReportLoader;
@@ -131,7 +133,10 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SecurityCodecUtil;
import org.owasp.esapi.ESAPI;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
@@ -322,9 +327,9 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
request.getSession().setAttribute(AppConstants.SI_DASHBOARD_REP_ID, reportID);
String strHTML = rr1.getDashboardLayoutHTML();
-
- TreeMap treeMap = getListOfReportsFromDashBoardHTML(strHTML);
-
+ String strJson = rr1.getDashboardLayoutJSON();
+ TreeMap treeMap = getListOfReportsFromDashBoardJson(strJson);
+ TreeMap treeMapHtml = getListOfReportsFromDashBoardHTML(strHTML);
Set set = treeMap.entrySet();
HashMap reportsRuntimeMap = new HashMap();
@@ -350,10 +355,13 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
record++;
Map.Entry entry = (Entry) iter.next();
reportIDFromMap = entry.getValue().toString().substring(1);
- // The below line is used to optimize, so that if there is already same report id it wouldn't go through the whole process
+ // The below line is used to optimize, so that if there is
+ // already same report id it wouldn't go through the whole
+ // process
similiarReportRuntime = getSimiliarReportRuntime(reportsRuntimeMap, reportIDFromMap);
if(similiarReportRuntime != null ) {
- rrDashboardReports = (ReportRuntime) getSimiliarReportRuntime(reportsRuntimeMap, reportIDFromMap).clone();
+ rrDashboardReports = (ReportRuntime) getSimiliarReportRuntime(reportsRuntimeMap,
+ reportIDFromMap).clone();
intObj = getKey(reportsRuntimeMap,reportIDFromMap);
} else {
rrDashboardReports = rh.loadReportRuntime(request, reportIDFromMap, true, requestFlag);
@@ -364,10 +372,12 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
rrDashboardReports.setDisplayMode(ReportRuntime.DISPLAY_DATA_ONLY);
}
- downloadLimit = (rrDashboardReports.getMaxRowsInExcelDownload()>0)?rrDashboardReports.getMaxRowsInExcelDownload():Globals.getDownloadLimit();
+ downloadLimit = (rrDashboardReports.getMaxRowsInExcelDownload() > 0)
+ ? rrDashboardReports.getMaxRowsInExcelDownload() : Globals.getDownloadLimit();
if(record == 1) {
- if(rrDashboardReports.getReportFormFields()!=null && rrDashboardReports.getReportFormFields().size()>0) {
+ if (rrDashboardReports.getReportFormFields() != null
+ && rrDashboardReports.getReportFormFields().size() > 0) {
buildReportdata = false;
if(rDisplayContent)
buildReportdata = true;
@@ -380,26 +390,37 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
ds = (DataSet) reportChartDataMap.get(intObj);
} else {
if (!rrDashboardReports.getReportType().equals(AppConstants.RT_HIVE))
- rd = rrDashboardReports.loadReportData(pageNo, userId, downloadLimit,request, false /*download*/);
+ rd = rrDashboardReports.loadReportData(pageNo, userId, downloadLimit, request,
+ false /* download */);
else
- rd = rrDashboardReports.loadHiveLinearReportData(rrDashboardReports.getReportSQL(), userId, 2,request);
+ rd = rrDashboardReports.loadHiveLinearReportData(rrDashboardReports.getReportSQL(),
+ userId, 2, request);
ds = rrDashboardReports.loadChartData(userId,request);
}
}
-
long totalTime = System.currentTimeMillis() - currentTime;
formFields = AppUtils.getRequestNvlValue(request, FORM_FIELDS);
if(buildReportdata) {
- rrDashboardReports.logReportRun(userId, String.valueOf(totalTime),formFields);
- rrDashboardReports.logReportExecutionTime(userId, String.valueOf(totalTime),AppConstants.RLA_EXECUTION_TIME, formFields);
+ /*
+ * rrDashboardReports.logReportRun(userId, String.valueOf(totalTime),
+ * formFields); rrDashboardReports.logReportExecutionTime(userId,
+ * String.valueOf(totalTime), AppConstants.RLA_EXECUTION_TIME, formFields);
+ */
}
-
- reportsRuntimeMap.put(new Integer(entry.getKey().toString())+"_"+rrDashboardReports.getReportID(), rrDashboardReports);
- reportDisplayTypeMap.put(new Integer(entry.getKey().toString())+"_"+rrDashboardReports.getReportID(), entry.getValue().toString().substring(0,1));
+ if(!entry.getValue().toString().toLowerCase().startsWith("c")) {
+ reportsRuntimeMap.put(
+ new Integer(entry.getKey().toString()) + "_" + rrDashboardReports.getReportID(),
+ rrDashboardReports);
+ reportDisplayTypeMap.put(
+ new Integer(entry.getKey().toString()) + "_" + rrDashboardReports.getReportID(),
+ entry.getValue().toString().substring(0, 1));
if(buildReportdata) {
- reportDataMap.put(new Integer(entry.getKey().toString())+"_"+rrDashboardReports.getReportID(), rd);
- reportChartDataMap.put(new Integer(entry.getKey().toString())+"_"+rrDashboardReports.getReportID(), ds);
+ reportDataMap.put(
+ new Integer(entry.getKey().toString()) + "_" + rrDashboardReports.getReportID(), rd);
+ reportChartDataMap.put(
+ new Integer(entry.getKey().toString()) + "_" + rrDashboardReports.getReportID(), ds);
+ }
}
}
@@ -417,7 +438,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
request.getSession().setAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME, rr1);
}
- return "raptor/report_dashboard_run_container.jsp";
+ return "{\"return\" : \"raptor/report_dashboard_run_container.jsp\"}";
} else {
fromDashboard = AppUtils.getRequestFlag(request,"fromDashboard");
if(isDashboardInDrillDownList(request))
@@ -465,7 +486,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
int requestFlag = DASH;
ReportHandler rh = new ReportHandler();
request.getSession().setAttribute(AppConstants.SI_DASHBOARD_REP_ID, reportID);
- //rr = null;
// get dashboard HTML from report runtime. getListOfReportsFromDashBoardHTML
String strHTML = rr.getDashboardLayoutHTML();
//System.out.println("StrHTML " + strHTML);
@@ -511,17 +531,12 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
downloadLimit = (rrDashboardReports.getMaxRowsInExcelDownload()>0)?rrDashboardReports.getMaxRowsInExcelDownload():Globals.getDownloadLimit();
- if (new Integer(nvl(rrDashboardReports.getDataContainerWidth(),"100")).intValue() >100)
- widthFlag = 1;
- if (new Integer(nvl(rrDashboardReports.getDataContainerHeight(),"100")).intValue() >100)
- heightFlag = 1;
+ if (new Integer(nvl(rrDashboardReports.getDataContainerWidth(),"100")).intValue() >100) widthFlag = 1;
+ if (new Integer(nvl(rrDashboardReports.getDataContainerHeight(),"100")).intValue() >100) heightFlag = 1;
if(record == 1) {
if(rrDashboardReports.getReportFormFields()!=null && rrDashboardReports.getReportFormFields().size()>0) {
buildReportdata = false;
- if(rDisplayContent){
- buildReportdata = true;
- }
-
+ if(rDisplayContent) buildReportdata = true;
}
}
if(buildReportdata) {
@@ -805,8 +820,12 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
else
rr.logReportExecutionTime(userId, "", "On Demand: " + AppConstants.RLA_ERROR, formFields);
}
-
+ ReportJSONRuntime reportJSONRuntime = new ReportJSONRuntime();
+ if (rr != null) {
+ reportJSONRuntime = rr.createReportJSONRuntime(request, rd);
+ }
ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
+ errorJSONRuntime.setAllowEdit(reportJSONRuntime.isAllowEdit());
errorJSONRuntime.setErrormessage(e.getMessage());
errorJSONRuntime.setStacktrace(getStackTrace(e));
ObjectMapper mapper = new ObjectMapper();
@@ -825,7 +844,12 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
} catch (RaptorException ex) {
nextPage = (new ErrorHandler()).processFatalError(request, ex);
+ ReportJSONRuntime reportJSONRuntime = new ReportJSONRuntime();
+ if (rr != null) {
+ reportJSONRuntime = rr.createReportJSONRuntime(request, rd);
+ }
ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
+ errorJSONRuntime.setAllowEdit(reportJSONRuntime.isAllowEdit());
errorJSONRuntime.setErrormessage(ex.getMessage());
errorJSONRuntime.setStacktrace(getStackTrace(ex));
ObjectMapper mapper = new ObjectMapper();
@@ -844,7 +868,14 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
//nextPage = (new ErrorHandler()).processFatalError(request, e);
} catch (Exception t) {
logger.error(EELFLoggerDelegate.errorLogger,t.getMessage(), t);
+
+ ReportJSONRuntime reportJSONRuntime = new ReportJSONRuntime();
+ if (rr != null) {
+ reportJSONRuntime = rr.createReportJSONRuntime(request, rd);
+ }
+
ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
+ errorJSONRuntime.setAllowEdit(reportJSONRuntime.isAllowEdit());
errorJSONRuntime.setErrormessage(t.toString());
errorJSONRuntime.setStacktrace(getStackTrace(t));
ObjectMapper mapper = new ObjectMapper();
@@ -891,7 +922,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
for(Iterator iter = set.iterator(); iter.hasNext(); ) {
Map.Entry entry = (Entry) iter.next();
if (((ReportRuntime) entry.getValue()).getReportID().equals(reportID)) {
- return new Integer(((String) entry.getKey()).substring(2));
+ return new Integer(((String) entry.getKey()).substring(((String) entry.getKey()).indexOf("_")+1));
}
}
return null;
@@ -1377,8 +1408,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
value = (String) entry.getValue();
}
// added so empty string would be treated as null value if not given in single quotes.
- if(value==null || value.trim().length()<=0)
- value="NULL";
+ if(value==null || value.trim().length()<=0) value="NULL";
SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", Utils.oracleSafe(value));
}
if(request.getParameter(ff.getFieldName())!=null) {
@@ -1391,10 +1421,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
}
//lookup.loadData("0");
}
- if(lookup instanceof IdNameSql){
- ((IdNameSql)lookup).setDataSizeUsedinPopup(-3); // -3 indicates to run the count sql for pagination.
- }
-
+ if(lookup instanceof IdNameSql) ((IdNameSql)lookup).setDataSizeUsedinPopup(-3); // -3 indicates to run the count sql for pagination.
}
if(lookup instanceof IdNameSql) {
((IdNameSql)lookup).loadUserData(request.getParameter(AppConstants.RI_NEXT_PAGE),
@@ -1749,8 +1776,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
ReportRuntime rr = null;
if(!isFromSchedule) {
rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
- if(rr!=null)
- AppUtils.getUserEmail(request);
+ if(rr!=null) AppUtils.getUserEmail(request);
}
String scheduleId = "";
@@ -1966,9 +1992,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
}
public String getChildDropDown(HttpServletRequest request, String nextPage) throws RaptorRuntimeException {
- if(request.getParameter("firstTime") != null){
- return nextPage;
- }
+ if(request.getParameter("firstTime") != null) { return nextPage; }
/*ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(
AppConstants.SI_REPORT_RUNTIME);
@@ -2033,11 +2057,25 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
}
+ private TreeMap getListOfReportsFromDashBoardJson(String jsonString) throws Exception {
+ HashMap hashReports = new HashMap();
+ ObjectMapper mapper = new ObjectMapper();
+
+ TypeReference<List<DashboardChildReport>> mapType = new TypeReference<List<DashboardChildReport>>() {
+ };
+ List<DashboardChildReport> reportList = mapper.readValue(jsonString, mapType);
+ int index = 1;
+ for (DashboardChildReport childRep : reportList) {
+ String str = childRep.getHasContent().get("id");
+ hashReports.put(index, (str.substring(0).toLowerCase().startsWith("chart") ? "c" : "d")
+ + str.substring(str.indexOf("#") + 1, str.length()));
+ index++;
+ }
+ return new TreeMap(hashReports);
+ }
+
private TreeMap getListOfReportsFromDashBoardHTML(String htmlString) {
- //String sourcestring = "<table border=1><tr><td>[Report#123]</td><td>[Report#124]</td></tr><tr><td>[Report#125]</td><td>[Report#126]</td></tr></table>";
String sourcestring = htmlString;
- //Pattern re = Pattern.compile("([a-z]+)\\[([a-z]+)([=<>]+)([a-z]+)\\]",Pattern.CASE_INSENSITIVE);
- //Pattern re = Pattern.compile("\\[([R][e][p][o][r][t][#])[(*)]\\]");
Pattern re = Pattern.compile("\\[(.*?)\\]"); //\\[(.*?)\\]
Matcher m = re.matcher(sourcestring);
HashMap hashReports = new HashMap();
@@ -2045,24 +2083,10 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
while (m.find()){
for( int groupIdx = 0; groupIdx < m.groupCount(); groupIdx++ ){
String str = m.group(groupIdx);
- //System.out.println(str);
hashReports.put(new String(Integer.toString(mIdx+1)), (str.substring(1).toLowerCase().startsWith("chart")?"c":"d") + str.substring(str.indexOf("#")+1, str.length()-1));
}
mIdx++;
}
- // Sorting HashMap based on Keys
- /*List mapKeys = new ArrayList(hashReports.keySet());
- List mapValues = new ArrayList(hashReports.values());
- hashReports.clear();
- hashReports = null;
- hashReports = new HashMap();
-
- TreeSet sortedSet = new TreeSet(mapKeys);
- Object[] sortedArray = sortedSet.toArray();
- int size = sortedArray.length;
- for (int i=0; i<size; i++) {
- hashReports.put(sortedArray[i], mapValues.get(mapKeys.indexOf(sortedArray[i])));
- }*/
return new TreeMap(hashReports);
}
@@ -2201,8 +2225,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
// "[ReportRuntime.loadLinearReportData] The number of visible columns
// does not match the number of data columns");
//TODO: This should be optimized to accept -1 for flat file download
- if(maxRows > totalRows)
- maxRows = totalRows;
+ if(maxRows > totalRows) maxRows = totalRows;
ArrayList reportDataList = new ArrayList();
for (int r = 0; r < maxRows; r++) {
DataRow dr = new DataRow();
@@ -2329,4 +2352,4 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
return "";
}
-} // ActionHandler
+} // ActionHandler \ No newline at end of file