<%-- ================================================================================ eCOMP Portal SDK ================================================================================ Copyright (C) 2017 AT&T Intellectual Property ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================================================ --%> <%-- Name: wizard_schedule_formfield_include.jsp Use : Shows formfield of the report in the schedule page. Change Log ========== 28-Aug-2009 : Version 8.5.1 (Sundar); Checkbox and Radio button are also handled. 18-Aug-2009 : Version 8.5.1 (Sundar); a) ajax.js is loaded in startup for AJAX functionality. b) showArgPopupNew is modified as per report_form.jsp c) Ajax function is added very similiar to report_form.jsp d) "auto" bug is resolved. 14-Jul-2009 : Version 8.4 (Sundar); --%> <%@ page import="java.io.*" %> <%@ page import="java.util.*" %> <%@ page import="java.text.*" %> <%@ page import="org.openecomp.portalsdk.analytics.model.runtime.*" %> <%@ page import="org.openecomp.portalsdk.analytics.system.*" %> <%@ page import="org.openecomp.portalsdk.analytics.util.*" %> <%@ page import="org.openecomp.portalsdk.analytics.model.definition.ReportDefinition" %> <%@ page import="org.openecomp.portalsdk.analytics.model.ReportHandler" %> <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.JavascriptItemType"%> <%@ page import="java.util.regex.*"%> <%@ page import="javax.servlet.http.*"%> <%@ page import="org.openecomp.portalsdk.analytics.model.definition.ReportSchedule" %> <% ReportDefinition rdef = (ReportDefinition) request.getAttribute(AppConstants.SI_REPORT_DEFINITION); ReportHandler rh = new ReportHandler(); ReportRuntime rr = rh.loadReportRuntime(request, rdef.getReportID()); request.getSession().setAttribute(AppConstants.SI_REPORT_RUNTIME, rr); boolean isDashboard = rr.isDashboardType(); ReportFormFields rff = rr.getReportFormFields(); ReportFormFields rff1 = (ReportFormFields) rff.clone(); ReportFormFields rff2 = (ReportFormFields) rff.clone(); ReportFormFields rff5 = (ReportFormFields) rff.clone(); boolean isFirstTime = nvl(request.getParameter("refresh")).toUpperCase().startsWith("Y"); ReportSchedule reportSchedule = (ReportSchedule) request.getSession().getAttribute(AppConstants.SI_REPORT_SCHEDULE); int dashboardFlag = 0; ReportRuntime rr1 = null; java.text.SimpleDateFormat sdf = null; %> <%--=(rr.getJavascriptElement()!=null && rr.getJavascriptElement().length()>0)?rr.getJavascriptElement().replaceAll("formd","forma"):""--%> <% if(rr.getReportType().equals(AppConstants.RT_DASHBOARD)) { dashboardFlag = 1; String strHTML = rr.getDashboardLayoutHTML(); //getdashboardLayoutHTML(); String rep_id = parseAndGetFirstReportID(strHTML); ReportHandler rh1 = new ReportHandler(); rr1 = null; int requestFlag = 1; try { rr1 = rh1.loadReportRuntime(request, rep_id, true, requestFlag); } catch(Exception e) { } rff = rr1.getReportFormFields(); } %> <%if((dashboardFlag == 0 && rr.needFormInput()) || (dashboardFlag == 1 && rr1.needFormInput())) { %> Please input values into the Form Fields for email attachment. Note those fields user must provide value can not leave as blank. <% int colidx = 0; java.util.HashMap paramsMap = Globals.getRequestParamtersMap(request, false); java.util.HashMap getScheduleMap = getFormFieldsHashMap (request, reportSchedule.getFormFields()); java.util.HashMap paramsScheduleMap = Globals.getRequestParametersMap(request, getScheduleMap); for (int i = 0; i < rff.size(); i ++){ FormField ff = (FormField) rff.get(i); ff.setDbInfo(rr.getDbInfo()); ff.setUserId(AppUtils.getUserID(request)); if(ff.getFieldType().equals(FormField.FFT_HIDDEN)) { %> <% if(nvl(reportSchedule.getFormFields()).length() <= 0) out.println(ff.getHtml(rr.getParamValue(ff.getFieldName()), paramsMap, rr, true)); else out.println(ff.getHtml(getParameterString(request, ff.getFieldName(), getScheduleMap), paramsScheduleMap, rr, true).replaceAll("formd","forma")); %> <% } if(!ff.getFieldType().equals(FormField.FFT_HIDDEN) && ff.isVisible()) { %> <%if (colidx == 0){%><%}%> <%colidx++;%> <%if (colidx == rr.getNumFormColsAsInt()){%><%colidx=0;}%> <% } } //for %>
<%if (!ff.getFieldType().equals(FormField.FFT_BLANK)){%> <%= ff.getDisplayNameHtml() %>: <%}%> <%-- ff.getHtml(rr.getParamValue(ff.getFieldName()), paramsMap,rr, true).replaceAll("formd","forma") --%> <% if(nvl(reportSchedule.getFormFields()).length() <= 0) out.println(ff.getHtml(rr.getParamValue(ff.getFieldName()), paramsMap, rr, true).replaceAll("formd","forma")); else out.println(ff.getHtml(getParameterString(request, ff.getFieldName(), getScheduleMap), paramsScheduleMap, rr, true).replaceAll("formd","forma")); %>
<% } //if(rr.needFormInput()) %> <% /* if(request.getAttribute(AppConstants.RI_REPORT_DATA) == null){ */ %> <%! private String nvl(String s) { return (s==null)?"":s; } private String nvl(String s, String sDefault) { return nvl(s).equals("")?sDefault:s; } private String getCallableJavascriptForSubmit(ReportRuntime rr) { JavascriptItemType javascriptItemType = null; StringBuffer callJavascriptText = new StringBuffer(""); if(rr.getJavascriptList()!=null) { for (Iterator iter = rr.getJavascriptList().getJavascriptItem().iterator(); iter.hasNext();) { javascriptItemType = (JavascriptItemType)iter.next(); if(javascriptItemType.getFieldId().equals("os1")) { callJavascriptText.append(" "+javascriptItemType.getCallText()); break; } } } return callJavascriptText.toString(); } private HashMap getFormFieldsHashMap (HttpServletRequest request, String formFieldsString) { String splitName[] = null; ArrayList keyValue = new ArrayList(); HashMap keyValueMap = new HashMap(); String newValue = ""; //System.out.println("Request Str "+ formFieldsString); StringTokenizer st = null; StringTokenizer st2 = null; String key1 = ""; String value = ""; if(formFieldsString.length() > 0) { st = new StringTokenizer(formFieldsString, "&"); while (st.hasMoreTokens()) { keyValue.add(st.nextToken()); } if(keyValue.size() > 0) { for (int num = 0; num < keyValue.size(); num++) { st2 = new StringTokenizer((String) keyValue.get(num), "="); while(st2.hasMoreTokens()) { key1 = ""; value = ""; key1 = st2.nextToken(); key1 = Utils.replaceInString(key1, "_auto", ""); try { value = st2.nextToken(); }catch (NoSuchElementException ex) { value = "";} if(!keyValueMap.containsKey(key1)) keyValueMap.put(key1,value); else { String value1 = (String) keyValueMap.get(key1); value = value+"|"+value1; keyValueMap.put(key1,value); } } } } } return keyValueMap; } private String getParameterString (HttpServletRequest request, String key, HashMap keyValueMap) { String newValue = ""; if(keyValueMap.containsKey(key)) { //System.out.println("VALUE IN MAP IS " +key+ " "+ (String) keyValueMap.get(key)); newValue = XSSFilter.filterRequestOnlyScript((String) keyValueMap.get(key)); if(nvl(newValue).length()<=0) { newValue = XSSFilter.filterRequestOnlyScript((String) keyValueMap.get(key+"_auto")); } } return newValue; } private String parseAndGetFirstReportID(String strHTML) { String sourcestring = strHTML; //System.out.println("String HTML1 " + strHTML); Pattern re = Pattern.compile("\\[(.*?)\\]"); //\\[(.*?)\\] Matcher m = re.matcher(sourcestring); int mIdx = 0; while (m.find()){ for( int groupIdx = 0; groupIdx < m.groupCount(); groupIdx++ ){ String str = m.group(groupIdx); //System.out.println("REP ID1 " + str.substring(str.indexOf("#")+1, str.length()-1)) ; return str.substring(str.indexOf("#")+1, str.length()-1); } mIdx++; }return ""; } %>