diff options
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model')
-rw-r--r-- | ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/DataCache.java | 95 |
1 files changed, 14 insertions, 81 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/DataCache.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/DataCache.java index 5e875f76..41a5ae20 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/DataCache.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/DataCache.java @@ -82,27 +82,20 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { /* try */{ dataViewActions = new Vector(); - //DataSet ds = DbUtils - // .executeQuery("SELECT ts.web_view_action FROM cr_table_source ts WHERE ts.web_view_action IS NOT NULL"); - String sql = Globals.getTheDataViewActions(); DataSet ds = DbUtils .executeQuery(sql); for (int i = 0; i < ds.getRowCount(); i++) dataViewActions.add(ds.getString(i, 0)); - } // catch(Exception e) {} + } return dataViewActions; } // getDataViewActions public static Vector getPublicReportIdNames() throws RaptorException { - // if(publicReportIdNames==null) => needs to be up-to-date at any time /* try */{ publicReportIdNames = new Vector(); - - //DataSet ds = DbUtils - // .executeQuery("SELECT rep_id, title FROM cr_report WHERE public_yn = 'Y' ORDER BY title"); String sql = Globals.getThePublicReportIdNames(); DataSet ds = DbUtils @@ -116,18 +109,14 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { } // getPublicReportIdNames public static Vector getPrivateAccessibleReportIdNames(String user_id, Vector userRoles) throws RaptorException { - // if(publicReportIdNames==null) => needs to be up-to-date at any time /* try */{ privateReportIdNames = new Vector(); - // StringBuffer query = new StringBuffer(" SELECT cr.rep_id, cr.title FROM cr_report cr "); String sql = Globals.getThePrivateAccessibleNamesA(); - //query.append(" WHERE cr.rep_id not in (select rep_id from cr_report_access cra where user_id = '"+ user_id+"' "); sql = sql.replace("[user_id]", user_id); StringBuffer query = new StringBuffer(sql); for (int i = 0; i < userRoles.size(); i++) { if( i == 0){ - // query.append(" OR role_id in ("); query.append(Globals.getThePrivateAccessibleNamesIf()); } if(i < (userRoles.size()-1)) @@ -137,8 +126,7 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { query.append((String)userRoles.get(i)+")"); } - //query.append(" ) "); - //query.append(" AND public_yn = 'N' and cr.owner_id = '"+ user_id+"' order by 2 "); + sql = Globals.getThePrivateAccessibleNamesB(); sql = sql.replace("[user_id]", user_id); query.append(sql); @@ -156,12 +144,9 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { public static Vector getGroupAccessibleReportIdNames(String user_id, Vector userRoles) throws RaptorException { - // if(publicReportIdNames==null) => needs to be up-to-date at any time /* try */{ groupReportIdNames = new Vector(); - - //StringBuffer query = new StringBuffer(" SELECT cr.rep_id, cr.title FROM cr_report cr "); - //query.append(" WHERE cr.rep_id in (select rep_id from cr_report_access cra where user_id = '"+ user_id+"' "); + String sql = Globals.getTheGroupAccessibleNamesA(); sql = sql.replace("[user_id]", user_id); StringBuffer query = new StringBuffer(sql); @@ -175,8 +160,7 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { query.append((String)userRoles.get(i)+")"); } - //query.append(" ) "); - //query.append(" AND public_yn = 'N' order by 2 "); + query.append(Globals.getTheGroupAccessibleNamesB()); DataSet ds = DbUtils @@ -185,7 +169,7 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { for (int i = 0; i < ds.getRowCount(); i++) groupReportIdNames .add(new IdNameValue(ds.getString(i, 0), ds.getString(i, 1))); - } // catch(Exception e) {} + } return groupReportIdNames; } // getGroupAccessibleReportIdNames @@ -218,27 +202,22 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { if (reportTableSources == null) /* try */{ reportTableSources = new Vector(); - //String query = " SELECT table_name, display_name, pk_fields, web_view_action, large_data_source_yn, filter_sql FROM cr_table_source "; String query = Globals.getTheReportTableSourcesA(); if (dBInfo != null && !dBInfo.equals(AppConstants.DB_LOCAL)){ - //query += " where SOURCE_DB= '" + dBInfo + "'"; query+=Globals.getTheReportTableSourcesWhere(); query = query.replace("[dBInfo]", dBInfo); } else { - //query += " where SOURCE_DB is null or SOURCE_DB = '" + AppConstants.DB_LOCAL - // + "'"; query+=Globals.getTheReportTableSourcesIf(); query = query.replace("[AppConstants.DB_LOCAL]", AppConstants.DB_LOCAL); } - //query += " ORDER BY table_name "; query+=Globals.getTheReportTableSourcesElse(); DataSet ds = DbUtils.executeQuery(query); for (int i = 0; i < ds.getRowCount(); i++) reportTableSources.add(new TableSource(ds.getString(i, 0), ds.getString(i, 1), ds.getString(i, 2), ds.getString(i, 3), ds.getString(i, 4), ds .getString(i, 5))); - } // catch(Exception e) {} + } return reportTableSources; } // getReportTableSources @@ -256,13 +235,9 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { sb.append(iter.next()); } // for sb.append(")"); - //StringBuffer query = new StringBuffer("SELECT ts.table_name, ts.display_name, ts.pk_fields, "); - // query.append(" ts.web_view_action, ts.large_data_source_yn, ts.filter_sql FROM cr_table_source ts "); - // query.append (" WHERE "); + StringBuffer query = new StringBuffer(Globals.grabTheReportTableA()); - //if(!(AppUtils.isAdminUser(userId) || AppUtils.isSuperUser(userId))) - // query.append (" (EXISTS (SELECT 1 FROM cr_table_role tr WHERE tr.table_name=ts.table_name AND tr.role_id IN "+sb.toString()+")) and "); - //+ " OR (NOT EXISTS (SELECT 1 FROM cr_table_role tr WHERE tr.table_name=ts.table_name)) "; + if (dBInfo != null && !dBInfo.equals(AppConstants.DB_LOCAL)){ String d_sql = Globals.grabTheReportTableIf(); d_sql = d_sql.replace("[dBInfo]", dBInfo); @@ -270,43 +245,35 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { query.append(d_sql); } else{ - //query.append(" (ts.SOURCE_DB is null or ts.SOURCE_DB = '"+ AppConstants.DB_LOCAL + "')"); String d_sql = Globals.grabTheReportTableElse(); d_sql = d_sql.replace("[AppConstants.DB_LOCAL]", AppConstants.DB_LOCAL); query.append(d_sql); } if(!(AppUtils.isAdminUser(request) || AppUtils.isSuperUser(request))) { - //query.append(" minus "); - - // query.append(" SELECT ts.table_name, ts.display_name, ts.pk_fields, ts.web_view_action, "); - // query.append(" ts.large_data_source_yn, ts.filter_sql from cr_table_source ts where "); - // query.append(" table_name in (select table_name from cr_table_role where role_id not IN "+sb.toString()+") and "); String e_sql = Globals.grabTheReportTableB(); e_sql = e_sql.replace("[sb.toString()]", sb.toString()); query.append(e_sql); if (dBInfo != null && !dBInfo.equals(AppConstants.DB_LOCAL)){ - // query.append( " ts.SOURCE_DB= '" + dBInfo + "'"); String d_sql = Globals.grabTheReportTableIf(); d_sql = d_sql.replace("[dBInfo]", dBInfo); query.append(d_sql); } else{ - //query.append(" (ts.SOURCE_DB is null or ts.SOURCE_DB = '"+ AppConstants.DB_LOCAL + "')"); String d_sql = Globals.grabTheReportTableElse(); d_sql = d_sql.replace("[AppConstants.DB_LOCAL]", AppConstants.DB_LOCAL); query.append(d_sql); } } - //query.append(" ORDER BY 1 "); + query.append(Globals.grabTheReportTableC()); DataSet ds = DbUtils.executeQuery(query.toString()); for (int i = 0; i < ds.getRowCount(); i++) userTableSources.add(new TableSource(ds.getString(i, 0), ds.getString(i, 1), ds.getString(i, 2), ds.getString(i, 3), ds.getString(i, 4), ds .getString(i, 5))); - } // catch(Exception e) {} + } return userTableSources; } // getReportTableSources @@ -316,14 +283,12 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { /* try */{ reportTableJoins = new Vector(); - //DataSet ds = DbUtils - // .executeQuery("SELECT src_table_name, dest_table_name, join_expr FROM cr_table_join"); DataSet ds = DbUtils .executeQuery(Globals.getTheReportTableCrJoin()); for (int i = 0; i < ds.getRowCount(); i++) reportTableJoins.add(new TableJoin(ds.getString(i, 0), ds.getString(i, 1), ds .getString(i, 2))); - } // catch(Exception e) {} + } return reportTableJoins; } // getReportTableJoins @@ -341,18 +306,6 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { sb.append(iter.next()); } // for sb.append(")"); - - /*DataSet ds = DbUtils - .executeQuery("SELECT tj.src_table_name, tj.dest_table_name, tj.join_expr FROM cr_table_join tj " - + "WHERE ((EXISTS (SELECT 1 FROM cr_table_role trs WHERE trs.table_name=tj.src_table_name AND trs.role_id IN " - + sb.toString() - + ")) " - + "OR (NOT EXISTS (SELECT 1 FROM cr_table_role trs WHERE trs.table_name=tj.src_table_name))) " - + "AND ((EXISTS (SELECT 1 FROM cr_table_role trd WHERE trd.table_name=tj.dest_table_name AND trd.role_id IN " - + sb.toString() - + ")) " - + "OR (NOT EXISTS (SELECT 1 FROM cr_table_role trd WHERE trd.table_name=tj.dest_table_name)))");*/ - String f_sql = Globals.getTheReportTableJoins(); f_sql = f_sql.replace("[sb.toString()]", sb.toString()); @@ -363,7 +316,7 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { for (int i = 0; i < ds.getRowCount(); i++) userTableJoins.add(new TableJoin(ds.getString(i, 0), ds.getString(i, 1), ds .getString(i, 2))); - } // catch(Exception e) {} + } return userTableJoins; } // getReportTableJoins @@ -386,10 +339,6 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { private static String generateReportTableDbUserColumnSQL(String tableName) { StringBuffer sb = new StringBuffer(); - // sb.append("SELECT a.table_name, a.column_name, a.data_type, a.label "); - //sb.append(" FROM user_column_def a "); - // sb.append("WHERE a.table_name = '" + tableName.toUpperCase() + "' "); - // sb.append("ORDER BY a.column_id"); String sql = Globals.getGenerateReportTableCol(); sql = sql.replace("[tableName.toUpperCase()]", tableName.toUpperCase()); @@ -399,15 +348,11 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { }//generateReportTableDbUserColumnSQL private static String generateReportTableDbColumnsSQL(String tableName, String maskSql) { StringBuffer sb = new StringBuffer(); - //sb.append("SELECT utc.table_name, utc.column_name, utc.data_type, "); sb.append(Globals.getGenerateDbUserSqlA()); if (maskSql == null){ - //sb.append("utc.column_name label "); sb.append(Globals.getGenerateDbUserSqlIf()); } else{ - //sb.append("nvl(x.label, utc.column_name) label "); - //sb.append("FROM user_tab_columns utc "); sb.append(Globals.getGenerateDbUserSqlElse()); } if (maskSql != null) { @@ -415,17 +360,13 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { sb.append(maskSql); sb.append(") AS x "); } - //sb.append("WHERE utc.table_name = '" + tableName.toUpperCase() + "' "); String g_sql = Globals.getGenerateDbUserSqlB(); g_sql = g_sql.replace("[tableName.toUpperCase()]", tableName.toUpperCase()); sb.append(g_sql); if (maskSql != null){ - //sb.append(" AND utc.table_name = x.table_name AND utc.column_name = x.column_name "); sb.append(Globals.getGenerateDbUserSqlC()); } - //sb.append("ORDER BY utc.column_id"); sb.append(Globals.getGenerateDbUserSqlD()); - //System.out.println(sb.toString()); return sb.toString(); } // generateReportTableDbColumnsSQL @@ -472,7 +413,7 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { processDollarFields(tableDbColumns); reportTableDbColumns.put(tableName, tableDbColumns); - } // catch(Exception e) {} + } return tableDbColumns; } // getReportTableDbColumns @@ -518,15 +459,7 @@ public class DataCache extends org.onap.portalsdk.analytics.RaptorObject { fieldName); return lookupDBInfo; - } // getLookupTable - - // public static void setRemoteDBPrefix (String remoteDBPrefix) { - // _remoteDBPrefix = remoteDBPrefix; - // } - // - // public static String getRemoteDBPrefix () { - // return _remoteDBPrefix; - // } + } public static void refreshAll() { DataCache.dataViewActions = null; |