Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / WEB-INF / fusion / raptor / popup_table_cols.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="java.util.*" %>
21
22 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.*" %>
23 <%@ page import="org.openecomp.portalsdk.analytics.model.*" %>
24 <%@ page import="org.openecomp.portalsdk.analytics.model.base.*" %>
25 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.*" %>
26 <%@ page import="org.openecomp.portalsdk.analytics.system.*" %>
27 <%@ page import="org.openecomp.portalsdk.analytics.util.*" %>
28
29 <%      String tableName = AppUtils.getRequestValue(request, AppConstants.RI_TABLE_NAME);
30         String remoteDbPrefix = (String) session.getAttribute("remoteDB");
31         Vector tableSources = null;
32         Vector dbColumns = null;
33         if(tableName==null) {
34                 tableSources = DataCache.getReportTableSources(remoteDbPrefix);
35                 if(tableSources.size()>0)
36                 tableName = ((TableSource) DataCache.getReportTableSources(remoteDbPrefix).get(0)).getTableName();
37         }
38             if(tableName!=null)  
39                         dbColumns = DataCache.getReportTableDbColumns(tableName.toUpperCase(),remoteDbPrefix); 
40         
41         
42         boolean isSingleValueChoice      = AppUtils.getRequestFlag(request, "single_value");
43         boolean includeTableNameInResult = AppUtils.getRequestFlag(request, "return_table_name");
44         boolean includeColTypeInResult   = AppUtils.getRequestFlag(request, "return_col_type"); %>
45
46 <html>
47 <head>
48         <title>Table Columns</title>
49         <link rel="stylesheet" type="text/css" href="<%= AppUtils.getBaseFolderURL() %>css/raptor.css">
50         <link rel="stylesheet" type="text/css" href="<%= AppUtils.getBaseFolderURL() %>css/ral.css">
51
52 <script language=JavaScript>
53 <!--
54         function setValue(newValue) {
55                 window.opener.addText(newValue);
56                 window.close();
57         }   // setValue
58
59         function clearValue() {
60                 window.opener.clearText();
61                 window.close();
62         }   // clearValue       
63 //-->
64 </script>
65
66 </head>
67 <body>
68
69 <% if(! isSingleValueChoice) { %>
70 <script language=JavaScript>
71 <!--
72         function getSelection() {
73                 var selList = "";
74                 <% if(dbColumns!=null) { %>
75                 for(var i=0; i<<%= dbColumns.size() %>; i++)
76                         if(document.dataform.dataChk[i].checked)
77                                 selList += ((selList=="")?"":", ")+document.dataform.dataChk[i].value;
78                 <% } %>
79                 
80                 setValue(selList);
81                 
82                 return false;
83         }   // getSelection
84 //-->
85 </script>
86 <% }    // if 
87 %>
88
89
90 <form name="dataform" action="<%= AppUtils.getBaseURL() %>" method="post">
91         <input type="hidden" name="action" value="raptor">
92         <input type="hidden" name="<%= AppConstants.RI_ACTION %>" value="report.popup.table.cols">
93 <% if(isSingleValueChoice) { %>
94         <input type="hidden" name="single_value" value="Y">
95 <% } %>
96 <% if(includeTableNameInResult) { %>
97         <input type="hidden" name="return_table_name" value="Y">
98 <% } %>
99 <% if(includeColTypeInResult) { %>
100         <input type="hidden" name="return_col_type" value="Y">
101 <% } %>
102
103 <table class="mTAB" width=94% border=0 cellspacing=1 align=center>
104         <tr class=rbg1>
105                 <td align="center" valign="middle" height="30">&nbsp;
106                 <% if(! isSingleValueChoice) { %>
107                         <input type=image src='<%= AppUtils.getImgFolderURL() %>downloadicon.gif' alt='Store selection' width=12 height=12 border=0 onClick="return getSelection()">&nbsp;
108                 <% } %>
109                 </td>
110                 <td colspan="2" valign="middle" nowrap>
111                         <select name="<%= AppConstants.RI_TABLE_NAME %>" onChange="document.dataform.submit()">
112                         <%      for(Iterator iter=DataCache.getReportTableSources(remoteDbPrefix).iterator(); iter.hasNext(); ) { 
113                                         String iTableName = ((TableSource) iter.next()).getTableName(); %>
114                             <option value="<%= iTableName %>"<%= iTableName.equals(tableName)?" selected":"" %>><%= iTableName %>
115                         <%      }       // for 
116                         %>
117                         </select>
118                         <b class=rtableheader> DB Table Columns</b>
119                 </td>
120         </tr>
121         <%      int rNum = 0;
122                 if(dbColumns!=null)
123                         for(rNum=0; rNum<dbColumns.size(); rNum++) {
124                                 DBColumnInfo dbCol = (DBColumnInfo) dbColumns.get(rNum); 
125                                 String sValue   = (includeTableNameInResult?(tableName+"."):"")+dbCol.getColName()+(includeColTypeInResult?("|"+dbCol.getColType()):""); 
126                                 String sDisplay = "["+tableName+"]."+dbCol.getColName(); %>
127         <tr<%= (rNum%2==0)?" class=rowalt1":" class=rowalt2" %>>
128                 <td align="center" height="30"><font class=rtabletext><%= (rNum+1) %></font></td>
129         <%                      if(isSingleValueChoice) { %>
130                 <td colspan="2"><font class=rtabletext><a href="javascript:setValue('<%= sValue %>')"><%= sDisplay %></a></font></td>
131         <%                      } else { %>
132                 <td align="center" valign="middle">
133                         <input type="checkbox" name="dataChk" value="<%= sValue %>">
134                 </td>
135                 <td><font class=rtabletext><%= sDisplay %></font></td>
136         <%                      }       // else 
137         %>
138         </tr>
139         <%              }       // for 
140                 if(rNum==0) { %>
141         <tr class=rbg3>
142                 <td align="center" height="30" colspan="3"><font class=rtabletext>No columns found for table [<%= tableName %>]</font></td>
143         </tr>
144         <%      } else {        // if
145         %>
146         <tr class=rbg3>
147                 <td colspan="3"><font class=rtabletext><a href="javascript:clearValue()"><%= "CLEAR VALUE" %></a></font></td>
148         </tr>   
149         <%      
150         }
151         %>
152         <tr class=rbg1>
153                 <td align="center" valign="middle" height="30">&nbsp;
154                 <% if(! isSingleValueChoice) { %>
155                         <input type=image src='<%= AppUtils.getImgFolderURL() %>downloadicon.gif' alt='Store selection' width=12 height=12 border=0 onClick="return getSelection()">&nbsp;
156                 <% } %>
157                 </td>
158                 <td colspan="2">&nbsp;</td>
159         </tr>
160 </table>
161
162         <input type="hidden" name="dataChk" value="">
163         <input type="hidden" name="dataChk" value="">
164 </form>
165
166 </body>
167 </html>
168
169 <%!     private String nvl(String s)                  { return (s==null)?"":s; }
170         private String nvl(String s, String sDefault) { return nvl(s).equals("")?sDefault:s; } %>
171