summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-analytics/src/main
diff options
context:
space:
mode:
authorLorraine Welch <lb2391@att.com>2020-05-18 15:24:46 +0000
committerGerrit Code Review <gerrit@onap.org>2020-05-18 15:24:46 +0000
commit2053ff0eaa2e4d1efcdb56a953af7c631757369e (patch)
treeec87e20c54452af29bc32a1308d4bc91a6d97e51 /ecomp-sdk/epsdk-analytics/src/main
parent07870a71d51a96f66e363846357744d3dbbe833b (diff)
parent5cdd932bde0de18856ea6c4466cc693197f1cefc (diff)
Merge "removed some unwanted codes in ReportSchedule.java"
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/main')
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java110
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 dbc68008..d6a4fb47 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
@@ -426,8 +426,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);
@@ -452,10 +450,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");
@@ -464,18 +460,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());
@@ -493,11 +484,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());
@@ -519,8 +506,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);
@@ -581,19 +567,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;
@@ -614,7 +591,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;
@@ -636,7 +612,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,
@@ -647,10 +622,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 = "";
@@ -658,16 +630,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
@@ -686,8 +648,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
@@ -695,10 +656,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
@@ -743,8 +701,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"));
@@ -820,18 +776,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);
@@ -855,8 +806,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;
@@ -922,15 +871,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 = '");
@@ -950,7 +892,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);
@@ -1005,14 +946,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());
@@ -1027,10 +960,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());
@@ -1038,13 +968,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);
@@ -1054,13 +978,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);
@@ -1069,15 +987,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());