Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / WEB-INF / fusion / raptor / wizard_columns_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 <%
28     ReportDefinition rdef = (ReportDefinition) request.getAttribute(AppConstants.SI_REPORT_DEFINITION);
29     WizardSequence ws = rdef.getWizardSequence();
30         boolean isCrossTab = rdef.getReportType().equals(AppConstants.RT_CROSSTAB);
31         boolean isSQLBased = rdef.getReportDefType().equals(AppConstants.RD_SQL_BASED);    
32 %>
33 <table class=mTAB width="100%" class="tableBorder" border="0" cellspacing="1" cellpadding="3" align=center>
34         <tr>
35                 <td class=rbg1 colspan=<%= isSQLBased?"5":"7" %> valign="Middle"><b class=rtableheader>Step <%= ws.getCurrentStepIndex() %> of <%= ws.getStepCount() %> - Report <%= ws.getCurrentStep() %></b></td>
36         </tr>
37         <tr class=rbg1>
38                 <td align="center" valign="Middle" width="7%" height="30"><b class=rtableheader>&nbsp;&nbsp;No&nbsp;&nbsp;</b></td>
39                 <td align="center" valign="Middle" width="58%"><b class=rtableheader>Column</b></td>
40 <% if(isSQLBased) { %>
41                 <td align="center" valign="Middle" width="7%"><b class=rtableheader>ID</b></td>
42         <% if(isCrossTab) { %>
43                 <td align="center" valign="Middle" width="14%"><b class=rtableheader>Cross-Tab Usage</b></td>
44         <% } %>
45                 <td align="center" valign="Middle" width="7%"<%= isCrossTab?"":" colspan=2" %>><b class=rtableheader>Edit</b></td>
46 <% } else { %>
47         <% if(isCrossTab) { %>
48                 <td align="center" valign="Middle" width="14%" colspan=2><b class=rtableheader>Cross-Tab Usage</b></td>
49         <% } else { %>
50                 <td align="center" valign="Middle" width="7%"><b class=rtableheader>Group By</b></td>
51                 <td align="center" valign="Middle" width="7%"><b class=rtableheader>Visible</b></td>
52         <% } %>
53                 <td align="center" valign="Middle" width="7%"><b class=rtableheader>Re-order</b></td>
54                 <td align="center" valign="Middle" width="14%" colspan=2 nowrap>
55         <% if(isCrossTab) { %>
56                         <input type="button" class=button value="Add" border="0" width="104" height="28" onClick="document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_ADD %>';document.forma.submit();">
57         <% } else { %>
58                         <table border="0" cellspacing="0" cellpadding="0"><tr>
59                                 <td height="28"><input type="button" class=button value="Add One" border="0" width="104" height="28" onClick="document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_ADD %>';document.forma.submit()"></td>
60                         </tr><tr>
61                                 <td height="28"><input type="button" class=button value="Add Multiple" border="0" width="104" height="28" onClick="document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_ADD_MULTI %>';document.forma.submit()"></td>
62                         </tr><tr>
63                                 <td height="28"><input type="button" class=button value="Re-order All" border="0" width="104" height="28" onClick="document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_ORDER_ALL %>';document.forma.submit()"></td>
64                         </tr></table>
65         <% } %>
66                 </td>
67 <% } %>
68         </tr>
69 <%      int iCount = 0;
70         boolean visibleColExist = false;
71         boolean rowColExist = false;
72         boolean colColExist = false;
73         boolean valColExist = false;
74         List reportCols = rdef.getAllColumns();
75         for(Iterator iter=reportCols.iterator(); iter.hasNext(); iCount++) { 
76                 DataColumnType dct = (DataColumnType) iter.next();
77                 if(dct.isVisible())
78                         visibleColExist = true;
79                 if(nvl(dct.getCrossTabValue()).equals(AppConstants.CV_ROW))
80                         rowColExist = true;
81                 if(nvl(dct.getCrossTabValue()).equals(AppConstants.CV_COLUMN))
82                         colColExist = true;
83                 if(nvl(dct.getCrossTabValue()).equals(AppConstants.CV_VALUE))
84                         valColExist = true; %>
85         <tr class=<%=(iCount % 2 == 0)?"rowalt1":"rowalt2"%>>
86                 <td align="center" height="30"><font class=rtabletext><%= iCount+1 %><!--dct.getOrderSeq(): <%= dct.getOrderSeq() %>--></font></td>
87                 <td><font class=rtabletext><%= dct.getDisplayName() %></font></td>
88 <% if(isSQLBased) { %>
89                 <td align="center"><font class=rtabletext><%= dct.getColId() %></font></td>
90         <% if(isCrossTab) { %>
91                 <td align="center"><font class=rtabletext><%= nvl(rdef.getCrossTabDisplayValue(dct), "&nbsp;") %></font></td>
92         <% } %>
93                 <td align="center"<%= isCrossTab?"":" colspan=2" %>><input type=image border="0" src="<%= AppUtils.getImgFolderURL() %>pen_paper.gif" alt="Edit" width="12" height="12" onClick="document.getElementById('<%= AppConstants.RI_WIZARD_ACTION %>').value='<%= AppConstants.WA_MODIFY %>'; document.getElementById('<%= AppConstants.RI_DETAIL_ID %>').value='<%= dct.getColId() %>'; document.forma.submit();"></td>
94 <% } else { %>
95         <% if(isCrossTab) { %>
96                 <td align="center" colspan=2><font class=rtabletext><%= nvl(rdef.getCrossTabDisplayValue(dct), "&nbsp;") %></font></td>
97         <% } else { %>
98                 <td align="center"><font class=rtabletext><%= dct.isGroupBreak()?"Yes":"&nbsp;" %></font></td>
99                 <td align="center"><font class=rtabletext><%= dct.isVisible()?"Yes":"No" %></font></td>
100         <% } %>
101                 <td align="center" nowrap>
102         <%              if(iCount==0) { %>
103                                 <img border="0" src="<%= AppUtils.getImgFolderURL() %>columnblankdown.gif" width="25" height="7">
104         <%              } else { %>
105                                 <input type=image border="0" src="<%= AppUtils.getImgFolderURL() %>columnup.gif" width="25" height="7" onClick="document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_MOVE_UP %>'; document.forma.<%= AppConstants.RI_DETAIL_ID %>.value='<%= dct.getColId() %>';">
106         <%              } %>
107         <%              if(iCount==reportCols.size()-1) { %>
108                                 <img border="0" src="<%= AppUtils.getImgFolderURL() %>columnblankup.gif" width="25" height="7">
109         <%              } else { %>
110                                 <input type=image border="0" src="<%= AppUtils.getImgFolderURL() %>columndown.gif" width="25" height="7" onClick="document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_MOVE_DOWN %>'; document.forma.<%= AppConstants.RI_DETAIL_ID %>.value='<%= dct.getColId() %>';">
111         <%              } %>
112                 </td>
113                 <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='<%= dct.getColId() %>'; document.forma.submit();"></td>
114                 <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 column <%= dct.getDisplayName() %>?')) {return false;} else {document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_DELETE %>'; document.forma.<%= AppConstants.RI_DETAIL_ID %>.value='<%= dct.getColId() %>'; document.forma.submit();}"></td>
115 <% } %>
116         </tr>
117 <%      } %>
118 <%      if(iCount==0) { %>
119         <tr class=rbg2>
120                 <td colspan=<%= isSQLBased?"5":"7" %> align="center" height="30"><font class=rtabletext>No columns defined</font></td>
121         </tr>
122 <%      } %>
123 </table>
124 <br>
125
126 <script language="JavaScript">
127 <!--
128 function dataValidate() {
129 <% if(isCrossTab) { 
130                 if(! rowColExist) { %>
131                 alert("You must have at least one column used for cross-tab row headings in the report.\nPlease add a column.");
132                 return false;
133         <% } else if(! colColExist) { %>
134                 alert("You must have at least one column used for cross-tab column headings in the report.\nPlease add a column.");
135                 return false;
136         <% } else if(! valColExist) { %>
137                 alert("You must have at least one column used for cross-tab report values in the report.\nPlease add a column.");
138                 return false;
139         <% } else { %>
140                 return true;
141         <% } 
142         } else { 
143                 if(visibleColExist) { %>
144                 return true;
145         <% } else { %>
146                 alert("You must have at least one visible column in the report.\nPlease add a column.");
147                 return false;
148         <% } 
149         } %>
150 }   // dataValidate
151 //-->
152 </script>
153
154 <%!
155         private String nvl(String s)                  { return (s==null)?"":s; }
156         private String nvl(String s, String sDefault) { return nvl(s).equals("")?sDefault:s; } 
157 %>