Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / WEB-INF / fusion / raptor / wizard_filters_list.jsp
1 <%--
2   ================================================================================
3   eCOMP Portal SDK
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
10   
11        http://www.apache.org/licenses/LICENSE-2.0
12   
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   ================================================================================
19   --%>
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.ColFilterType" %>
33 <%      
34     ReportDefinition rdef = (ReportDefinition) request.getAttribute(AppConstants.SI_REPORT_DEFINITION);
35     WizardSequence ws = rdef.getWizardSequence();
36     String curSubStep = ws.getCurrentSubStep();
37         String reportID   = rdef.getReportID();
38 %>
39 <table class="mTAB" width="100%" class="tableBorder" border="0" cellspacing="1" cellpadding="3" align=center>
40         <tr>
41                 <td class=rbg1 colspan=8 valign="Middle"><b class=rtableheader>Step <%= ws.getCurrentStepIndex() %> of <%= ws.getStepCount() %> - Report <%= ws.getCurrentStep() %></b></td>
42         </tr>
43         <tr class=rbg1>
44                 <td align="center" valign="Middle" width="7%" height="30"><b class=rtableheader>&nbsp;&nbsp;No&nbsp;&nbsp;</b></td>
45                 <td align="center" valign="Middle" width="10%"><b class=rtableheader>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
46                 <td align="center" valign="Middle" width="5%"><b class=rtableheader>&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
47                 <td align="center" valign="Middle" width="33%"><b class=rtableheader>Column</b></td>
48                 <td align="center" valign="Middle" width="26%"><b class=rtableheader>Filter</b></td>
49                 <td align="center" valign="Middle" width="5%"><b class=rtableheader>&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
50                 <td align="center" valign="Middle" width="14%" colspan=2><input type="button" class=button value="Add" border="0" width="71" height="28" onClick="document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_ADD %>';document.forma.submit()"></td>
51         </tr>
52 <%      int iCount = 0;
53         int iPos   = 0;
54         int nOpenBrackets  = 0;
55         int nCloseBrackets = 0;
56         String colId = "";
57         List reportFilters = rdef.getAllFilters();
58         for(Iterator iter=reportFilters.iterator(); iter.hasNext(); iCount++, iPos++) { 
59                 ColFilterType cft = (ColFilterType) iter.next();
60                 
61                 nOpenBrackets  += nvl(cft.getOpenBrackets()).length();
62                 nCloseBrackets += nvl(cft.getCloseBrackets()).length();
63                 
64                 if(! colId.equals(cft.getColId()))
65                         iPos = 0;
66                 colId = cft.getColId(); %>
67                 <tr class=<%=(iCount % 2 == 0)?"rowalt1":"rowalt2"%>>
68                 <td align="center" height="30"><font class=rtabletext><%= iCount+1 %></font></td>
69                 <td align="center"><font class=rtabletext><%= iCount>0?cft.getJoinCondition():"&nbsp;" %></font></td>
70                 <td align="center"><font class=rtabletext><%= nvl(cft.getOpenBrackets(), "&nbsp;") %></font></td>
71                 <td><font class=rtabletext><%= rdef.getColumnById(colId).getDisplayName() %></font></td>
72                 <td><font class=rtabletext><%= HTMLEncode(rdef.getFilterLabel(cft)) %></font></td>
73                 <td align="center"><font class=rtabletext><%= nvl(cft.getCloseBrackets(), "&nbsp;") %></font></td>
74                 <td align="center"><input type=image border="0" src="<%= AppUtils.getImgFolderURL() %>pen_paper.gif" alt="Edit" width="12" height="12" onClick="document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_EDIT %>'; document.forma.<%= AppConstants.RI_DETAIL_ID %>.value='<%= colId+"|"+iPos %>';"></td>
75                 <td align="center"><input type=image border="0" src="<%= AppUtils.getImgFolderURL() %>deleteicon.gif" alt="Remove" width="12" height="12" onClick="if(! confirm('Are you sure you want to remove this filter?')) {return false;} else {document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_DELETE %>'; document.forma.<%= AppConstants.RI_DETAIL_ID %>.value='<%= colId+"|"+iPos %>'; }"></td>
76         </tr>
77 <%      }   // for
78         if(iCount==0) { %>
79         <tr class=rbg2>
80                 <td colspan=8 align="center" height="30"><font class=rtabletext>No filters defined</font></td>
81         </tr>
82 <%      } %>
83 </table>
84 <br>
85
86 <script language="JavaScript">
87 <!--
88 function dataValidate() {
89 <%      if(nOpenBrackets!=nCloseBrackets) { %>
90         alert("The number of opening brackets (<%= nOpenBrackets %>) must be equal to the number of closing brackets (<%= nCloseBrackets %>).");
91         return false;
92 <%      } %>
93         return true;
94 }   // dataValidate
95 //-->
96 </script>
97
98 <%!
99    private String HTMLEncode(String value) {
100                 StringBuffer sb = new StringBuffer(value);
101
102                 for(int i=0; i<sb.length(); i++)
103                         if(sb.charAt(i)=='<')
104                                 sb.replace(i, i+1, "&lt;");
105                         else if(sb.charAt(i)=='>')
106                                 sb.replace(i, i+1, "&gt;");
107                         else if(sb.charAt(i)=='"')
108                                 sb.replace(i, i+1, "&quot;");
109
110                 return sb.toString();
111         }   // HTMLEncode
112         private String nvl(String s)                  { return (s==null)?"":s; }
113         private String nvl(String s, String sDefault) { return nvl(s).equals("")?sDefault:s; } 
114 %>
115