2 ================================================================================
4 ================================================================================
5 Copyright (C) 2017 AT&T Intellectual Property
6 ================================================================================
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ================================================================================
20 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.DataColumnType" %>
21 <%@ page import="org.openecomp.portalsdk.analytics.util.AppConstants" %>
22 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.ReportDefinition" %>
23 <%@ page import="org.openecomp.portalsdk.analytics.system.AppUtils" %>
24 <%@ page import="org.openecomp.portalsdk.analytics.controller.WizardSequence" %>
25 <%@ page import="java.util.List" %>
26 <%@ page import="java.util.Iterator" %>
27 <%@ page import="org.openecomp.portalsdk.analytics.system.Globals" %>
28 <%@ page import="org.openecomp.portalsdk.analytics.util.Utils" %>
29 <%@ page import="java.util.Vector" %>
30 <%@ page import="org.openecomp.portalsdk.analytics.model.ReportLoader" %>
31 <%@ page import="org.openecomp.portalsdk.analytics.model.base.IdNameValue" %>
32 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.FormFieldType" %>
33 <%@ page import="org.openecomp.portalsdk.analytics.model.base.ReportWrapper" %>
34 <%@ page import="org.openecomp.portalsdk.analytics.model.DataCache" %>
35 <%@ page import="org.openecomp.portalsdk.analytics.model.runtime.FormField" %>
36 <%@ page import="org.openecomp.portalsdk.analytics.model.base.OrderBySeqComparator" %>
37 <%@ page import="java.util.Collections" %>
38 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.TableSource" %>
40 ReportDefinition rdef = (ReportDefinition) request.getAttribute(AppConstants.SI_REPORT_DEFINITION);
41 WizardSequence ws = rdef.getWizardSequence();
42 String curSubStep = ws.getCurrentSubStep();
43 String reportID = rdef.getReportID();
44 boolean isCrossTab = rdef.getReportType().equals(AppConstants.RT_CROSSTAB);
45 boolean isSQLBased = rdef.getReportDefType().equals(AppConstants.RD_SQL_BASED);
48 <script language="JavaScript">
50 function addText(newText) {
51 document.forma.reportSQL.value += (""+newText+" ");
52 document.forma.sqlValidated.value = "N";
55 function getSelectedTableName() {
57 tableName = document.forma.dbTables.options[document.forma.dbTables.selectedIndex].value;
59 } // getSelectedTableName
62 addText(getSelectedTableName());
65 function showTableColsPopup() {
66 var w = window.open("<%= AppUtils.getRaptorActionURL() %>report.popup.table.cols&<%= AppConstants.RI_TABLE_NAME %>="+getSelectedTableName(), "tableColsPopup", "width=450,height=330,location=no,menubar=no,toolbar=no,status=no,resizable=yes,scrollbars=yes");
69 } // showTableColsPopup
71 function showTestRunSQLPopup() {
72 //var w = window.open("<%= AppUtils.getRaptorActionURL() %>report.popup.testrun.sql&<%= AppConstants.RI_FORMATTED_SQL %>="+escape(""+document.forma.reportSQL.value), "testRunSQLPopup", "width=450,height=330,location=no,menubar=no,toolbar=no,status=no,resizable=yes,scrollbars=yes");
73 var w = window.open("<%= AppUtils.getRaptorActionURL() %>report.test.jsp", "testRunSQLPopup", "width=450,height=330,location=no,menubar=no,toolbar=no,status=no,resizable=yes,scrollbars=yes");
76 } // showTestRunSQLPopup
78 function showFormFieldPopup() {
79 var w = window.open("", "fieldPopup", "width=400,height=400,location=no,menubar=no,toolbar=no,status=no,resizable=yes,scrollbars=yes");
83 w.document.writeln("<html><head>");
84 w.document.writeln("<title>Form Fields</title>");
85 w.document.writeln("<link rel=stylesheet type=text/css href='<%= AppUtils.getBaseFolderURL() %>css/raptor.css'>");
86 w.document.writeln("<script language=JavaScript>");
87 w.document.writeln("function setValue(newValue) {");
88 w.document.writeln(" window.opener.addText(newValue);");
89 w.document.writeln(" window.close();");
90 w.document.writeln("} // setValue");
91 w.document.writeln("</"+"script>");
92 w.document.writeln("</head><body>");
94 w.document.writeln("<table width=94% border=0 cellspacing=1 align=center>");
95 w.document.writeln(" <tr class=rbg1>");
96 w.document.writeln(" <td height=30> </td>");
97 w.document.writeln(" <td><b class=rtableheader>Report Form Fields</b></td>");
98 w.document.writeln(" </tr>");
100 if(rdef.getFormFieldList()!=null)
101 for(Iterator iter=rdef.getFormFieldList().getFormField().iterator(); iter.hasNext(); iCnt++) {
102 FormFieldType fft = (FormFieldType) iter.next(); %>
103 w.document.writeln(" <tr<%= (iCnt%2==0)?" class=rbg8":"" %>>");
104 w.document.writeln(" <td align=center valign=middle height=30><font class=rtabletext><%= (iCnt+1) %></font></td>");
105 w.document.writeln(" <td valign=middle>");
106 w.document.writeln(" <b class=rtabletext><a href=\"javascript:setValue('[<%= fft.getFieldName() %>]')\"><%= fft.getFieldName() %></a></b>");
107 w.document.writeln(" </td>");
108 w.document.writeln(" </tr>");
111 w.document.writeln(" <tr class=rbg8 height=30>");
112 w.document.writeln(" <td colspan=2 align=center valign=middle><b class=rtabletext>There are no form fields defined</b></td>");
113 w.document.writeln(" </tr>");
114 w.document.writeln(" <tr>");
115 w.document.writeln(" <td colspan=2 align=center><br><button type='submit' onClick=\"window.close();\" att-button btn-type=\"primary\" size=\"small\" title='Save'>Close</button></td>");
116 w.document.writeln(" </tr>");
118 w.document.writeln(" <tr class=rbg1 height=30>");
119 w.document.writeln(" <td> </td>");
120 w.document.writeln(" <td> </td>");
121 w.document.writeln(" </tr>");
124 w.document.writeln("</table>");
126 w.document.writeln("</body></html>");
128 } // showFormFieldPopup
132 <table width="100%" class="tableBorder" border="0" cellspacing="1" cellpadding="3" align=center>
134 <td class=rbg1 colspan=2 valign="Middle"><b class=rtableheader>Step <%= ws.getCurrentStepIndex() %> of <%= ws.getStepCount() %> - Report <%= ws.getCurrentStep() %></b></td>
137 <td class=rbg3 width="60%" align="left" valign="top">
138 <font class=rtabletext>Report SQL: </font><br>
139 <% boolean sqlValidated = (nvl(AppUtils.getRequestValue(request, "sqlValidated"), nvl(rdef.getReportSQL())).length()>0);
140 if(request.getAttribute(AppConstants.RI_ERROR_LIST)!=null)
141 sqlValidated = false;
143 String sql = nvl(rdef.getReportSQL(), "SELECT ");
145 sql = nvl(AppUtils.getRequestValue(request, "reportSQL"), sql); %>
146 <input type="hidden" id="sqlValidated" name="sqlValidated" value="<%= sqlValidated?"Y":"N" %>">
147 <textarea name="reportSQL" cols="155" rows="32" onChange="document.getElementById('sqlValidated').value='N';" style="height: 400px;"><%= sql %></textarea>
149 <td class=rbg2 width="40%" align="left" valign="top" nowrap>
150 <font class=rtabletext>Keyword Assistance </font><br>
152 <a href="javascript:addText('SELECT')">SELECT</a> <a href="javascript:addText('DISTINCT')">DISTINCT</a> <br>
153 <a href="javascript:addText('FROM')">FROM</a> <br>
154 <a href="javascript:addText('WHERE')">WHERE</a> <br>
155 <a href="javascript:addText('GROUP BY')">GROUP BY</a> <br>
156 <a href="javascript:addText('HAVING')">HAVING</a> <br>
157 <a href="javascript:addText('ORDER BY')">ORDER BY</a> <a href="javascript:addText('ASC')">ASC</a> <a href="javascript:addText('DESC')">DESC</a> <br>
159 <a href="javascript:addText('UNION')">UNION</a> <a href="javascript:addText('ALL')">ALL</a> <a href="javascript:addText('INTERSECT')">INTERSECT</a> <a href="javascript:addText('MINUS')">MINUS</a> <br>
161 <a href="javascript:addText('AND')">AND</a> <a href="javascript:addText('OR')">OR</a> <a href="javascript:addText('NOT')">NOT</a> <a href="javascript:addText('EXISTS')">EXISTS</a> <br>
162 <a href="javascript:addText('IS')">IS</a> <a href="javascript:addText('NULL')">NULL</a> <a href="javascript:addText('IN')">IN</a> <a href="javascript:addText('BETWEEN')">BETWEEN</a> <br>
164 <a href="javascript:addText('COUNT(')">COUNT(</a> <a href="javascript:addText('SUM(')">SUM(</a> <a href="javascript:addText('AVG(')">AVG(</a> <a href="javascript:addText('MAX(')">MAX(</a> <a href="javascript:addText('MIN(')">MIN(</a> <br>
166 <a href="javascript:addText('NVL(')">NVL(</a> <a href="javascript:addText('DECODE(')">DECODE(</a> <a href="javascript:addText('SYSDATE')">SYSDATE</a> <br>
167 <a href="javascript:addText('TO_CHAR(')">TO_CHAR(</a> <a href="javascript:addText('TO_NUMBER(')">TO_NUMBER(</a> <a href="javascript:addText('TO_DATE(')">TO_DATE(</a> <br>
168 <a href="javascript:addText('TRUNC(')">TRUNC(</a> <a href="javascript:addText('ROUND(')">ROUND(</a> <a href="javascript:addText('ABS(')">ABS(</a> <br>
169 <a href="javascript:addText('SUBSTR(')">SUBSTR(</a> <a href="javascript:addText('REPLACE(')">REPLACE(</a> <a href="javascript:addText('LOWER(')">LOWER(</a> <a href="javascript:addText('UPPER(')">UPPER(</a> <br>
170 <a href="javascript:addText('LTRIM(')">LTRIM(</a> <a href="javascript:addText('RTRIM(')">RTRIM(</a> <a href="javascript:addText('LPAD(')">LPAD(</a> <a href="javascript:addText('RPAD(')">RPAD(</a> <br>
175 <td class=rbg2 height="40" align="left" valign="Middle" nowrap>
176 <font class=rtabletext style="display: none">
178 <select name="dbTables" style="width: 200px">
179 <% Vector reportTableSources = DataCache.getReportTableSources((String) session.getAttribute("remoteDB"));
180 for(int i=0; i<reportTableSources.size(); i++) {
181 TableSource tableSource = (TableSource) reportTableSources.get(i); %>
182 <option value="<%= tableSource.getTableName() %>"><%= tableSource.getTableName() %>
185 <button type="submit" onClick="addTable()" att-button btn-type="primary" size="small" title='Add Table'>Add Table</button>
186 <button type="submit" onClick="showTableColsPopup()" att-button btn-type="primary" size="small" title='Columns'>Columns</button>
187 <button type="submit" onClick="showFormFieldPopup()" att-button btn-type="primary" size="small" title='Form Fields'>Form Fields</button>
191 <td class=rbg2 align="left" valign="Middle" nowrap>
192 <font class=rtabletext>
193 <button type="submit" onClick="document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_VALIDATE %>';" att-button btn-type="primary" size="small" title='Validate SQL'>Validate SQL</button>
195 <button type="Button" onClick="showTestRunSQLPopup()" att-button btn-type="primary" size="small" title='Test Run SQL'>Test Run SQL</button>
201 <td class=rbg1 colspan=2 height="30" align="center" valign="Middle"><b class=rtableheader>You need to click the "Validate SQL" button in order to store the SQL before going forward</b></td>
206 <script language="JavaScript">
208 function dataValidate() {
209 if(document.getElementById("sqlValidated") && document.getElementById("sqlValidated").value!="Y") {
210 <% if(nvl(rdef.getReportSQL()).length()>0) { %>
211 return confirm("The changes made to the SQL have not been validated.\nYou need to click the \"Validate SQL\" button in order to do that.\nDo you want to continue now and lose the changes made to the SQL after the last validation?");
213 alert("The SQL has not been validated.\nPlease click the \"Validate SQL\" button in order to do that.\nYou cannot go forward without SQL validation.");
224 private String nvl(String s) { return (s==null)?"":s; }
225 private String nvl(String s, String sDefault) { return nvl(s).equals("")?sDefault:s; }