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.system.Globals" %>
25 <%@ page import="org.openecomp.portalsdk.analytics.controller.WizardSequence" %>
26 <%@ page import="java.util.Vector" %>
27 <%@ page import="java.util.List" %>
28 <%@ page import="org.openecomp.portalsdk.analytics.model.DataCache" %>
29 <%@ page import="java.util.Iterator" %>
30 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.DataSourceType" %>
31 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.DBColumnInfo" %>
32 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.TableSource" %>
33 <%@ page import="org.openecomp.portalsdk.analytics.model.base.IdNameValue" %>
34 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.SemaphoreType" %>
35 <%@ page import="org.openecomp.portalsdk.analytics.xmlobj.FormFieldType" %>
36 <%@ page import="org.openecomp.portalsdk.analytics.model.definition.ReportSchedule" %>
37 <%@ page import="org.openecomp.portalsdk.analytics.util.Utils" %>
40 ReportDefinition rdef = (ReportDefinition) request.getAttribute(AppConstants.SI_REPORT_DEFINITION);
41 WizardSequence ws = rdef.getWizardSequence();
42 ReportSchedule reportSchedule = rdef.getReportSchedule();
43 String remoteDbPrefix = (String) session.getAttribute("remoteDB");
44 boolean isSQLAllowed = Globals.getAllowSQLBasedReports();
47 <%@page import="java.util.Calendar"%>
48 <%@page import="java.text.DateFormat"%>
49 <%@page import="java.text.SimpleDateFormat"%>
50 <%@page import="java.util.TimeZone"%>
51 <%@page import="java.util.Date"%>
52 <%@page import="org.openecomp.portalsdk.analytics.model.ReportLoader"%>
53 <script language="JavaScript">
55 function showTestConditionPopup() {
56 var w = window.open("<%= AppUtils.getRaptorActionURL() %>report.popup.test.cond&remoteDbPrefix=<%=remoteDbPrefix%>&<%= AppConstants.RI_FORMATTED_SQL %>="+escape(""+document.forma.conditionSQL.value), "testCondSQLPopup", "width=450,height=180,location=no,menubar=no,toolbar=no,status=no,resizable=yes,scrollbars=yes");
59 } // showTestConditionPopup
61 function exclusiveCheckBox(which) {
63 for (i=0; i<size; i++) {
64 if(document.getElementById("notify" + i) != which) {
65 document.getElementById("notify" + i).checked = false;
68 //alert("exclusive " + which.form.notify_type.value);
70 function initFormFields() {
72 var requestStr = "<%=reportSchedule.getFormFields()%>";
74 if(requestStr.length > 0) {
75 SplitName = requestStr.substring(1,requestStr.length).split("&");
76 for (num = 0; num < SplitName.length; num++) {
77 keyValue = SplitName[num].split("=");
78 //alert(keyValue[0]+ " " + keyValue[1]);
79 var obj = eval("document.forma."+keyValue[0]);
81 if(obj.tagName == "SELECT") {
82 //var opt = document.getElementsByName(keyValue[0]);
84 for (var intLoop=0; intLoop < obj.length; intLoop++) {
85 if (obj[intLoop].value == keyValue[1]) {
86 obj[intLoop].selected=true;
92 document.getElementsByName(keyValue[0])[0].value = unescape(keyValue[1]);
99 <script language="javascript" src="<%= AppUtils.getBaseFolderURL() %>js/other_scripts.js"></script>
100 <script type="text/javascript" src="<%= AppUtils.getBaseFolderURL() %>js/CalendarPopup.js"></script>
101 <link rel="stylesheet" type="text/css" href="<%= AppUtils.getBaseFolderURL() %>css/calendar.css">
102 <iframe id="calendarFrame" class="nav" z-index:199; scrolling="no" frameborder="0" width=165px height=165px src="" style="position:absolute; display:none;">
104 <div id="calendarDiv" name="calendarDiv" style="position:absolute; z-index:20000; visibility:hidden; background-color:white;layer-background-color:white;"></div>
106 Calendar startCalendarDate = Calendar.getInstance();
107 startCalendarDate.add(Calendar.DAY_OF_MONTH, - 540);
108 Calendar endCalendarDate = Calendar.getInstance();
109 endCalendarDate.add(Calendar.DAY_OF_MONTH, 540);
110 SimpleDateFormat dtf = new SimpleDateFormat("MM/dd/yyyy");
111 SimpleDateFormat oracleDateFormat = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss");
112 Date sysdate = oracleDateFormat.parse(ReportLoader.getSystemDateTime());
113 SimpleDateFormat dtimestamp = new SimpleDateFormat(Globals.getScheduleDatePattern());
114 //dtimestamp.setTimeZone(TimeZone.getTimeZone(Globals.getTimeZone()));
121 <SCRIPT LANGUAGE="JavaScript">
122 var oCalendar = new CalendarPopup("calendarDiv");
124 oCalendar.addDisabledDates(null, "<%=dtf.format(startCalendarDate.getTime())%>");
125 oCalendar.addDisabledDates("<%=dtf.format(endCalendarDate.getTime())%>", null);
128 oCalendar.setCssPrefix("raptor");
130 <table class=mSDL width="100%" class="tableBorder" border="0" cellspacing="1" cellpadding="3" align=center>
131 <% if(request.getAttribute("schedule_only")!=null) { %>
133 <td class=rbg1 colspan=2 valign="Middle"><b class=rtableheader>Step <%= ws.getCurrentStepIndex() %> of <%= ws.getStepCount() %> - Report <%= ws.getCurrentStep() %></b></td>
137 <td class=rbg1 colspan=2 valign="Middle"><b class=rtableheader><a href="javascript:uitmpl_qh('schedule_help')" class="qh-link"></a>Please enter Time in <%= Globals.getTimeZone()%>. The Current System Time is <%=dtimestamp.format(sysdate)%> <%=Globals.getTimeZone()%></b></td>
140 <td colspan=2 class="nopad"><!-- quick help text -->
141 <div id="schedule_help" class="mQH">
142 <p><span class="label">Quick Help:</span>
145 <!-- /quick help text --></td>
149 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Schedule Emails: </font></td>
150 <td class=rbg3 align="left" width="50%" valign="middle" nowrap><font class=rtabletext>
151 <input type='radio' name='schedEnabled' id='schedEnabled' value='Y' <%= reportSchedule.getSchedEnabled().equals("Y")?" checked":"" %> />Yes
153 <input type='radio' name='schedEnabled' id='schedEnabled' value='N' <%= reportSchedule.getSchedEnabled().equals("N")?" checked":"" %> />No
157 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Email Attachment:</font></td>
158 <td class=rbg3 align="left" width="50%" valign="middle" nowrap>
159 <font class=rtabletext>
160 <input type='radio' name='notify' id='notify' value='2' <%= reportSchedule.getNotify_type().equals("2")?" checked":(reportSchedule.getNotify_type().length()<=0)?" checked":(!reportSchedule.getNotify_type().equals("4"))? " checked " :"" %> />PDF Attachment
162 <input type='radio' name='notify' id='notify' value='4' <%= reportSchedule.getNotify_type().equals("4")?" checked":"" %> />Excel Attachment
163 <input type='hidden' name='notify_type' value='1'/>
168 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Recurrence: </font></td>
169 <td class=rbg3 align="left" width="50%"><font class=rtabletext>
170 <select name="schedRecurrence">
171 <option value="" <%= reportSchedule.getRecurrence().equals("" )?" selected":"" %>>One Time
172 <option value="<%= AppConstants.SR_HOURLY %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_HOURLY )?" selected":"" %>>Hourly
173 <option value="<%= AppConstants.SR_DAILY %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_DAILY )?" selected":"" %>>Daily
174 <option value="<%= AppConstants.SR_DAILY_MO_FR %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_DAILY_MO_FR)?" selected":"" %>>Daily Mo-Fr
175 <option value="<%= AppConstants.SR_WEEKLY %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_WEEKLY )?" selected":"" %>>Weekly
176 <option value="<%= AppConstants.SR_MONTHLY %>"<%= reportSchedule.getRecurrence().equals(AppConstants.SR_MONTHLY )?" selected":"" %>>Monthly
177 </select></font></td>
180 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Start Date: </font></td>
181 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>
182 <input type="text" size="10" maxlength="10" name="schedStartDate" value="<%= reportSchedule.getStartDate() %>">
183 <!--<a href="#" onClick="window.dateField = document.forma.schedStartDate;calendar = window.open('<%= AppUtils.getRaptorActionURL() %>popup.calendar','cal','WIDTH=200,HEIGHT=250');return false;">
184 <img src="<%= AppUtils.getImgFolderURL() %>calender_icon.gif" align=absmiddle border=0 width="20" height="20">
186 <img src="<%= AppUtils.getImgFolderURL() %>calender_icon.gif" align=absmiddle border=0 width="20" height="20" onClick="oCalendar.select(document.getElementById('schedStartDate'),event,'MM/dd/yyyy'); return false;" style="cursor:hand">
187
188 <select name="schedHour">
189 <option value="01"<%= reportSchedule.getRunHour().equals("01")?" selected":"" %>>1
190 <option value="02"<%= reportSchedule.getRunHour().equals("02")?" selected":"" %>>2
191 <option value="03"<%= reportSchedule.getRunHour().equals("03")?" selected":"" %>>3
192 <option value="04"<%= reportSchedule.getRunHour().equals("04")?" selected":"" %>>4
193 <option value="05"<%= reportSchedule.getRunHour().equals("05")?" selected":"" %>>5
194 <option value="06"<%= reportSchedule.getRunHour().equals("06")?" selected":"" %>>6
195 <option value="07"<%= reportSchedule.getRunHour().equals("07")?" selected":"" %>>7
196 <option value="08"<%= reportSchedule.getRunHour().equals("08")?" selected":"" %>>8
197 <option value="09"<%= reportSchedule.getRunHour().equals("09")?" selected":"" %>>9
198 <option value="10"<%= reportSchedule.getRunHour().equals("10")?" selected":"" %>>10
199 <option value="11"<%= reportSchedule.getRunHour().equals("11")?" selected":"" %>>11
200 <option value="12"<%= reportSchedule.getRunHour().equals("12")?" selected":"" %>>12
202 <select name="schedMin">
203 <option value="00"<%= reportSchedule.getRunMin().equals("00")?" selected":"" %>>00
204 <option value="15"<%= reportSchedule.getRunMin().equals("15")?" selected":"" %>>15
205 <option value="30"<%= reportSchedule.getRunMin().equals("30")?" selected":"" %>>30
206 <option value="45"<%= reportSchedule.getRunMin().equals("45")?" selected":"" %>>45
208 <select name="schedAMPM">
209 <option value="AM"<%= reportSchedule.getRunAMPM().equals("AM")?" selected":"" %>>AM
210 <option value="PM"<%= reportSchedule.getRunAMPM().equals("PM")?" selected":"" %>>PM
216 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>End Date: </font></td>
217 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>
218 <input type="text" size="10" maxlength="10" name="schedEndDate" value="<%= reportSchedule.getEndDate() %>">
219 <!--<a href="#" onClick="window.dateField = document.forma.schedEndDate;calendar = window.open('<%= AppUtils.getRaptorActionURL() %>popup.calendar','cal','WIDTH=200,HEIGHT=250');return false;">
220 <img src="<%= AppUtils.getImgFolderURL() %>calender_icon.gif" align=absmiddle border=0 width="20" height="20">
222 <img src="<%= AppUtils.getImgFolderURL() %>calender_icon.gif" align=absmiddle border=0 width="20" height="20" onClick="oCalendar.select(document.getElementById('schedEndDate'),event,'MM/dd/yyyy'); return false;" style="cursor:hand">
226 <% if(AppUtils.isAdminUser(request) || isSQLAllowed ) { %>
228 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Use Condition:</font></td>
229 <td class=rbg3 align="left" width="50%" valign="middle" nowrap><font class=rtabletext>
230 <input type="checkbox" name="conditional" value="Y"<%= reportSchedule.getConditional().equals("Y")?" checked":"" %>> Send Emails Only When Condition Is Met
234 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Condition SQL:</font></td>
235 <td class=rbg3 align="left" width="50%" valign="middle" nowrap><font class=rtabletext>SELECT 1 FROM DUAL WHERE EXISTS (<br>
236 <textarea name="conditionSQL" cols="40" rows="3"><%= nvl(reportSchedule.getConditionSQL()) %></textarea>
238
239 <input type="Button" class=button value="Test" onClick="showTestConditionPopup()">
246 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext>Max rows in attachment:</font></td>
247 <td class=rbg3 align="left" width="50%" valign="middle" nowrap>
248 <input type='text' name='downloadLimit' value="<%=reportSchedule.getDownloadLimit()%>" size='4'/>
252 <jsp:include page="wizard_schedule_formfield_include.jsp" flush="true" />
253 <script type="text/javascript">initFormFields();</script>
255 <% List emailToUsers = reportSchedule.getEmailToUsers();
256 for(int i=0; i<emailToUsers.size(); i++) {
257 IdNameValue userValue = (IdNameValue) emailToUsers.get(i); %>
259 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext><%= (i==0)?"Email To: ":" " %></font></td>
260 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>
261 <%= userValue.getName() %>
262
263 <input type=image border="0" src="<%= AppUtils.getImgFolderURL() %>deleteicon.gif" alt="Remove" width="12" height="12" onClick="if(! dataValidate()) {return false;} else if(! confirm('Are you sure?')) {return false;} else {document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_DELETE_USER %>'; document.forma.<%= AppConstants.RI_DETAIL_ID %>.value='<%= userValue.getId() %>'; }">
267 List emailToRoles = reportSchedule.getEmailToRoles();
268 for(int i=0; i<emailToRoles.size(); i++) {
269 IdNameValue roleValue = (IdNameValue) emailToRoles.get(i); %>
271 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext><%= (emailToUsers.size()==0&&i==0)?"Email To: ":" " %></font></td>
272 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>Everyone With Role:
273 <%= roleValue.getName() %>
274
275 <input type=image border="0" src="<%= AppUtils.getImgFolderURL() %>deleteicon.gif" alt="Remove" width="12" height="12" onClick="if(! dataValidate()) {return false;} else if(! confirm('Are you sure?')) {return false;} else {document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_DELETE_ROLE %>'; document.forma.<%= AppConstants.RI_DETAIL_ID %>.value='<%= roleValue.getId() %>'; }">
280 Vector remainingUsers = Utils.getUsersNotInList(emailToUsers,request);
281 Vector remainingRoles = Utils.getRolesNotInList(emailToRoles,request);
282 if((emailToUsers.size()+emailToRoles.size()==0)||(remainingUsers.size()>0)||(remainingRoles.size()>0)) { %>
284 <td class=rbg2 align="right" width="25%" height="30"><font class=rtabletext><%= (emailToUsers.size()+emailToRoles.size()==0)?"Email To: ":" " %></font></td>
285 <td class=rbg3 align="left" width="50%" nowrap><font class=rtabletext>
286 <% if(remainingUsers.size()>0) { %>
287 <select name="schedEmailAdd" onChange="if(! dataValidate()) {selectedIndex=0;} else {document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_ADD_USER %>'; document.forma.submit();}">
288 <option value="" selected>--- Select User ---
289 <% for(int i=0; i<remainingUsers.size(); i++) {
290 IdNameValue userValue = (IdNameValue) remainingUsers.get(i); %>
291 <option value="<%= userValue.getId() %>"><%= userValue.getName() %>
295 No user emails available
297
298 <% if(remainingRoles.size()>0) { %>
299 <select name="schedEmailAddRole" onChange="if(! dataValidate()) {selectedIndex=0;} else {document.forma.<%= AppConstants.RI_WIZARD_ACTION %>.value='<%= AppConstants.WA_ADD_ROLE %>'; document.forma.submit();}">
300 <option value="" selected>--- Select Role ---
301 <% for(int i=0; i<remainingRoles.size(); i++) {
302 IdNameValue roleValue = (IdNameValue) remainingRoles.get(i); %>
303 <option value="<%= roleValue.getId() %>"><%= roleValue.getName() %>
316 <script language="JavaScript">
318 function dataValidate() {
319 if(! checkDate(document.forma.schedStartDate.value, true)) {
320 alert("Invalid Start Date. The date format should be MM/DD/YYYY");
321 document.forma.schedStartDate.focus();
322 document.forma.schedStartDate.select();
325 if(! checkDate(document.forma.schedEndDate.value, true)) {
326 alert("Invalid End Date. The date format should be MM/DD/YYYY");
327 document.forma.schedEndDate.focus();
328 document.forma.schedEndDate.select();
331 /*if(! checkDate(document.forma.schedRunDate.value, true)) {
332 alert("Invalid Execution Date. The date format should be MM/DD/YYYY");
333 document.forma.schedRunDate.focus();
334 document.forma.schedRunDate.select();
337 <% if (AppUtils.isAdminUser(request) || isSQLAllowed){ %>
338 if(document.forma.conditional.checked&&document.forma.conditionSQL.value=="") {
339 alert("Please provide Condition SQL");
340 document.forma.conditionSQL.focus();
341 document.forma.conditionSQL.select();
345 if(! checkNonNegativeInteger(document.forma.downloadLimit.value)) {
346 alert("Max row in attachment is not a valid integer.\nPlease enter a valid value.");
347 document.forma.downloadLimit.focus();
348 document.forma.downloadLimit.select();
353 if((document.forma.downloadLimit.value) > <%=Globals.getDownloadLimit()%>) {
354 alert("Max row you can download should not be more than <%=Globals.getDownloadLimit()%> rows.\nPlease enter a valid value.");
355 document.forma.downloadLimit.focus();
356 document.forma.downloadLimit.select();
361 for (var i=0; i < document.forma.notify.length; i++) {
362 if (document.forma.notify[i].checked) {
363 document.forma.notify_type.value = document.forma.notify[i].value;
366 return validateForm();
374 private String nvl(String s) { return (s==null)?"":s; }
375 private String nvl(String s, String sDefault) { return nvl(s).equals("")?sDefault:s; }