diff options
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src')
-rw-r--r-- | ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java | 110 |
1 files changed, 13 insertions, 97 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java index 5db298b8..6a0ec833 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java @@ -410,8 +410,6 @@ public class ReportSchedule extends RaptorObject implements Serializable{ private void loadScheduleData(HttpServletRequest request) { try { StringBuffer query = new StringBuffer(""); - //query.append("SELECT rs.enabled_yn, TO_CHAR(rs.start_date, 'MM/DD/YYYY') start_date, TO_CHAR(rs.end_date, 'MM/DD/YYYY') end_date, TO_CHAR(rs.run_date, 'MM/DD/YYYY') run_date, NVL(TO_CHAR(rs.run_date, 'HH'), '12') run_hour, NVL(TO_CHAR(rs.run_date, 'MI'), '00') run_min, NVL(TO_CHAR(rs.run_date, 'AM'), 'AM') run_ampm, rs.recurrence, rs.conditional_yn, rs.notify_type, rs.max_row, rs.initial_formfields, rs.schedule_id, NVL(TO_CHAR(rs.end_date, 'HH'), '11') end_hour, NVL(TO_CHAR(rs.end_date, 'MI'), '45') end_min, NVL(TO_CHAR(rs.end_date, 'AM'), 'PM') end_ampm, encrypt_yn, attachment_yn FROM cr_report_schedule rs WHERE rs.rep_id = " - // + reportID); String q_sql = Globals.getLoadScheduleData(); q_sql = q_sql.replace("[reportID]", reportID); query.append(q_sql); @@ -436,10 +434,8 @@ public class ReportSchedule extends RaptorObject implements Serializable{ runAMPM = nvl(ds.getString(0, 6), "AM"); recurrence = nvl(ds.getString(0, 7)); conditional = nvl(ds.getString(0, 8), "N"); - //conditionSQL = nvl(ds.getString(0, 9)); notify_type = nvl(ds.getString(0, 9), "1"); downloadLimit = nvl(ds.getString(0, 10), "1000"); - //if(nvl(ds.getString(0, 13).) formFields = nvl(ds.getString(0, 11)); setScheduleID(ds.getString(0, 12)); endHour = nvl(ds.getString(0, 13), "11"); @@ -448,18 +444,13 @@ public class ReportSchedule extends RaptorObject implements Serializable{ encryptMode = nvl(ds.getString(0, "encrypt_yn"), "N"); attachment = nvl(ds.getString(0, "attachment_yn"), "Y"); conditionSQL = loadConditionalSQL(getScheduleID()); - } else { // if - //DataSet dsSeq = DbUtils.executeQuery("select SEQ_CR_REPORT_SCHEDULE.nextval from dual" ); + } else { String n_sql = Globals.getNewScheduleData(); DataSet dsSeq = DbUtils.executeQuery(n_sql); String schedule_id = dsSeq.getString(0,0); setScheduleID(schedule_id); } if(getScheduleID().length() > 0) { - //ds = DbUtils - // .executeQuery("SELECT rsu.user_id, fuser.last_name||', '||fuser.first_name, fuser.login_id FROM cr_report_schedule_users rsu, fn_user fuser WHERE rsu.rep_id = " - // + reportID + " AND rsu.schedule_id = " + getScheduleID() + " and rsu.user_id IS NOT NULL and rsu.user_id = fuser.user_id"); - String t_sql = Globals.getLoadScheduleGetId(); t_sql = t_sql.replace("[reportID]", reportID); t_sql = t_sql.replace("[getScheduleID()]", getScheduleID()); @@ -477,11 +468,7 @@ public class ReportSchedule extends RaptorObject implements Serializable{ emailToUsers.add(new IdNameValue(ds.getString(i, 0), ds.getString(i, 1))); } Collections.sort(emailToUsers, new NameComparator()); - - //ds = DbUtils - // .executeQuery("SELECT rsu.role_id FROM cr_report_schedule_users rsu WHERE rsu.rep_id = " - // + reportID + " AND rsu.schedule_id = " + getScheduleID() + " AND rsu.role_id IS NOT NULL"); - + String r_sql = Globals.getLoadScheduleUsers(); r_sql = r_sql.replace("[reportID]", reportID); r_sql = r_sql.replace("[getScheduleID()]", getScheduleID()); @@ -503,8 +490,7 @@ public class ReportSchedule extends RaptorObject implements Serializable{ } // loadScheduleData private void newScheduleData() { - try { - //DataSet dsSeq = DbUtils.executeQuery("select SEQ_CR_REPORT_SCHEDULE.nextval from dual" ); + try { String sql = Globals.getNewScheduleData(); DataSet dsSeq = DbUtils.executeQuery(sql); @@ -566,19 +552,10 @@ public class ReportSchedule extends RaptorObject implements Serializable{ } else { fieldCount++; if(fieldCount == 1) { - //sql = sql + " "; - //sql = Pattern.compile("(^[\r\n]*|([\\s]))[Ss][Ee][Ll][Ee][Cc][Tt]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" SELECT "); - //sql = Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Rr][Ee]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" WHERE "); - //sql = Pattern.compile("(^[\r\n]*|([\\s]))[Aa][Nn][Dd]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" AND "); } - //sql = getReportSQL(); while(sql.indexOf(fieldDisplay) > 0) { -/* sql = Utils.replaceInString(sql, "SELECT ", "select "); - sql = Utils.replaceInString(sql, "WHERE", "where"); - sql = Utils.replaceInString(sql, " AND ", " and "); -*/ + re1 = Pattern.compile("(^[\r\n]|[\\s])AND(.*?[^\r\n]*)"+ "\\["+fft.getFieldName()+ "\\](.*?)\\s", Pattern.DOTALL); - //re1 = Pattern.compile("(^[\r\n]|[\\s])AND(.*?[^\r\n]*)"+ "\\["+fft.getFieldName()+ "\\]", Pattern.DOTALL); /* posFormField = sql.indexOf(fieldDisplay); posAnd = sql.lastIndexOf("and", posFormField); if(posAnd < 0) posAnd = 0; @@ -599,7 +576,6 @@ public class ReportSchedule extends RaptorObject implements Serializable{ if (posAnd > 0 && matcher.find(posAnd-1)) { - //sql = Utils.replaceInString(sql, matcher.group(), " "); matcher = re1.matcher(sql); index = sql!=null?sql.lastIndexOf("["+fft.getFieldName()+"]"):-1; @@ -621,7 +597,6 @@ public class ReportSchedule extends RaptorObject implements Serializable{ if(index >= 0 && matcher.find(index-30)) { sql = sql.replace(matcher.group(), " WHERE 1=1 "); } - //sql = Utils.replaceInString(sql, matcher.group(), " where 1=1 "); } /*else { replaceValue = formatListValue("", Utils .oracleSafe(nvl(paramValues.getParamValue(fieldId))), null, false, @@ -632,10 +607,7 @@ public class ReportSchedule extends RaptorObject implements Serializable{ } } } - - //sql = Utils.replaceInString(sql, " select ", " SELECT "); - //sql = Utils.replaceInString(sql, " where ", " WHERE "); - //sql = Utils.replaceInString(sql, " and ", " AND "); + } else { String paramValue = ""; @@ -643,16 +615,6 @@ public class ReportSchedule extends RaptorObject implements Serializable{ String value = ""; value = nvl(paramValues .getParamValue(fieldId)); -// value = Utils.oracleSafe(nvl(value)); -// if (!(dbType.equals("DAYTONA") && sql.trim().toUpperCase().startsWith("SELECT"))) { -// value = "('" + Utils.replaceInString(value, ",", "'|'") + "')"; -// value = Utils.replaceInString(value, "|", ","); -// paramValue = XSSFilter.filterRequestOnlyScript(value); -// } else if (nvl(value.trim()).length()>0) { -// value = "('" + Utils.replaceInString(value, ",", "'|'") + "')"; -// value = Utils.replaceInString(value, "|", ","); -// paramValue = XSSFilter.filterRequestOnlyScript(value); -// } paramValue = value; } else paramValue = nvl(paramValues @@ -671,8 +633,7 @@ public class ReportSchedule extends RaptorObject implements Serializable{ } } logger.debug(EELFLoggerDelegate.debugLogger, ("SQLSQLBASED B4^^^^^^^^^ " + sql + " " + fft.getValidationType() + " " + fft.getFieldName() + " " + fft.getFieldId())); - if(fft!=null && (fft.getValidationType()!=null && (fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) ||fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC) ||fft.getValidationType().equals(FormField.VT_DATE) ))) { - //System.out.println("paramValues.getParamValue(fieldId_Hr) Inside if " + fft.getValidationType() + " " + fieldDisplay); + if(fft!=null && (fft.getValidationType()!=null && (fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) ||fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC) ||fft.getValidationType().equals(FormField.VT_DATE) ))) { if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)) { sql = Utils.replaceInString(sql, fieldDisplay, nvl( paramValue) +((nvl(paramValues @@ -680,10 +641,7 @@ public class ReportSchedule extends RaptorObject implements Serializable{ .getParamValue(fieldId+"_Hr") ) ):"")); } else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)) { -/* System.out.println("paramValues.getParamValue(fieldId_Hr)" + paramValues - .getParamValue(fieldId+"_Hr") + " " + paramValues - .getParamValue(fieldId+"_Min")) ; -*/ sql = Utils.replaceInString(sql, fieldDisplay, nvl( + sql = Utils.replaceInString(sql, fieldDisplay, nvl( paramValue) + ((nvl(paramValues .getParamValue(fieldId+"_Hr") ).length()>0)?" "+addZero(nvl(paramValues .getParamValue(fieldId+"_Hr") ) ):"") + ((nvl(paramValues @@ -728,8 +686,6 @@ public class ReportSchedule extends RaptorObject implements Serializable{ } else throw new UserDefinedException("Expected number, Given String for the form field \"" + fieldDisplay+"\""); } - /*sql = Utils.replaceInString(sql, fieldDisplay, nvl( - paramValue, "NULL"));*/ } else sql = Utils.replaceInString(sql, fieldDisplay, nvl( paramValue, "NULL")); @@ -805,18 +761,13 @@ public class ReportSchedule extends RaptorObject implements Serializable{ } if(session != null ) { for (int i = 0; i < sessionParameters.length; i++) { - //if(!sessionParameters[i].startsWith("ff")) - // paramValue = Utils.replaceInString(paramValue, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i].toUpperCase()) ); - // else { logger.debug(EELFLoggerDelegate.debugLogger, (" Session " + " sessionParameters[i] " + sessionParameters[i] + " " + (String)session.getAttribute(sessionParameters[i]))); sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) ); - //} + } } } else { logger.debug(EELFLoggerDelegate.debugLogger, ("BEFORE LOGGED USERID REPLACE " + sql)); - //sql = Utils.replaceInString(sql, "'[logged_userId]'", "'"+userId+"'"); - //debugLogger.debug("Replacing string 2 " + sql); sql = Utils.replaceInString(sql, "[LOGGED_USERID]", userId); sql = Utils.replaceInString(sql, "[USERID]", userId); sql = Utils.replaceInString(sql, "[USER_ID]", userId); @@ -840,8 +791,6 @@ public class ReportSchedule extends RaptorObject implements Serializable{ sql = Utils.replaceInString(sql, "[USERID]", userId); sql = Utils.replaceInString(sql, "[USER_ID]", userId); logger.debug(EELFLoggerDelegate.debugLogger, ("SQLSQLBASED no formfields after" + sql)); - //debugLogger.debug("Replacing String 2 "+ sql); - //debugLogger.debug("Replaced String " + sql); sql = Pattern.compile("([\n][\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" "); return sql; @@ -907,15 +856,8 @@ public class ReportSchedule extends RaptorObject implements Serializable{ sb.append("NULL"); sb.append(", conditional_yn = '"); sb.append(getConditional()); - //sb.append("', condition_sql = "); - sb.append("'"); -/* if (getConditionSQL().length() > 0) { - sb.append("'"); - sb.append(parseScheduleSQL(request, Utils.oracleSafe(getConditionSQL()))); sb.append("'"); - } else - sb.append("NULL"); -*/ + sb.append(", notify_type = "); sb.append(getNotify_type()); sb.append(", encrypt_yn = '"); @@ -935,7 +877,6 @@ public class ReportSchedule extends RaptorObject implements Serializable{ DbUtils.executeUpdate(conn, sb.toString()); } else { - //DataSet dsSeq = DbUtils.executeQuery("select seq_cr_report_schedule.nextval from dual " ); String w_sql = Globals.getNewScheduleData(); DataSet dsSeq = DbUtils.executeQuery(w_sql); String schedule_id = dsSeq.getString(0,0); @@ -990,14 +931,6 @@ public class ReportSchedule extends RaptorObject implements Serializable{ sb.append(", '"); sb.append(getConditional()); sb.append("', "); -/* if (getConditionSQL().length() > 0) { - sb.append("'"); - sb.append(parseScheduleSQL(request, Utils.oracleSafe(getConditionSQL()))); - sb.append("'"); - } else - sb.append("NULL"); - sb.append(", "); -*/ sb.append(getNotify_type()); sb.append(", "); sb.append(getDownloadLimit()); @@ -1012,10 +945,7 @@ public class ReportSchedule extends RaptorObject implements Serializable{ } // else - - //DbUtils.executeUpdate(conn, - // "DELETE cr_report_schedule_users WHERE rep_id = " + reportID+ " and schedule_id = " + getScheduleID()); - + String d_sql = Globals.getExecuteUpdate(); d_sql = d_sql.replace("[reportID]", reportID); d_sql = d_sql.replace("[getScheduleID()]", getScheduleID()); @@ -1023,13 +953,7 @@ public class ReportSchedule extends RaptorObject implements Serializable{ DbUtils.executeUpdate(conn, d_sql); for (int i = 0; i < emailToUsers.size(); i++){ - //DbUtils.executeUpdate(conn, - // "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES(" - // + getScheduleID() + ", " - // + reportID + ", " - // + ((IdNameValue) emailToUsers.get(i)).getId() + ", NULL, " - // + (i + 1) + ")"); - + String sql = Globals.getExecuteUpdateUsers(); sql = sql.replace("[getScheduleID()]", getScheduleID()); sql = sql.replace("[reportID]", reportID); @@ -1039,13 +963,7 @@ public class ReportSchedule extends RaptorObject implements Serializable{ } for (int i = 0; i < emailToRoles.size(); i++){ - //DbUtils.executeUpdate(conn, - // "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES(" - // + getScheduleID() +", " - // + reportID + ", NULL, " - // + ((IdNameValue) emailToRoles.get(i)).getId() + ", " - // + (emailToUsers.size() + i + 1) + ")"); - + String sql = Globals.getExecuteUpdateRoles(); sql = sql.replace("[getScheduleID()]", getScheduleID()); sql = sql.replace("[reportID]", reportID); @@ -1054,15 +972,13 @@ public class ReportSchedule extends RaptorObject implements Serializable{ DbUtils.executeUpdate(conn, sql); } - //if (conn == null) + DbUtils.commitTransaction(conn); persistConditionSql(conn, getScheduleID(), parseScheduleSQL(request, getConditionSQL())); logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] DB update report " + reportID + " - schedule data updated")); - //DbUtils.executeUpdate(conn, - // "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ("+getScheduleID()+",'Submitted:Schedule',TO_DATE('"+ getRunDate()+" "+ getRunHour()+":"+getRunMin()+" "+getRunAMPM()+"', 'MM/DD/YYYY HH:MI AM'))"); String e_sql = Globals.getExecuteUpdateActivity(); e_sql = e_sql.replace("[getScheduleID()]", getScheduleID()); e_sql = e_sql.replace("[getRunDate()]", getRunDate()); |