diff options
author | Indrijeet kumar <indriku1@in.ibm.com> | 2020-05-11 12:21:21 +0530 |
---|---|---|
committer | Indrijeet kumar <indriku1@in.ibm.com> | 2020-05-11 12:21:32 +0530 |
commit | d81155c7bada6a3d70634072274a4c907214807b (patch) | |
tree | 14d5e969d8510edb60a106cd91a7c5977e4d94cf /ecomp-sdk/epsdk-analytics/src/main/java/org | |
parent | e1dce346175ec18962e8687479da76b59ca75ab2 (diff) |
Removed some code smells
Removed some code smells
Issue-ID: PORTAL-813
Change-Id: Id56bd50ec08132313c06726555ee2dfb8d13245a
Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org')
3 files changed, 16 insertions, 179 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeCollection.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeCollection.java index e630f52c..320f15c9 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeCollection.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/node/NodeCollection.java @@ -99,93 +99,11 @@ public class NodeCollection { public HashMap<String,NodeInfo> getNodeCollection() { return nodeCollection; } - -/* public NodeInfo getNode(String nodeID) { - for (NodeInfo nodeInfo : nodeCollection) { - if (nodeInfo.getNodeID().equalsIgnoreCase(nodeID) ) { - return nodeInfo; - } - } - - return null; - } -*/ -/* public NodeInfo getNode(String nodeID, String nodeType) { - for (NodeInfo nodeInfo : nodeCollection) { - if (nodeInfo.getNodeID().equalsIgnoreCase(nodeID) && nodeInfo.getNodeType().equalsIgnoreCase(nodeType)) { - return nodeInfo; - } - } - - return null; - } -*/ + public NodeInfo getNode(String nodeType) { return (NodeInfo)nodeCollection.get(nodeType); } -/* public ArrayList<NodeInfo> getWildCardNode(String nodeID, String nodeType) { - ArrayList<NodeInfo> list = new ArrayList<NodeInfo>(); - - for (NodeInfo nodeInfo : nodeCollection) { - if (nodeInfo.getNodeType().equalsIgnoreCase(nodeType) && - nodeInfo.getNodeID().toLowerCase().indexOf(nodeID.toLowerCase()) != -1) { - list.add(nodeInfo); - } - } - - return list; - }*/ - -/* public NodeInfo removeNode(String nodeID) { - for (int i = 0; i < nodeCollection.size(); i++) { - if (nodeCollection.get(i).getNodeID().equalsIgnoreCase(nodeID)) { - return nodeCollection.remove(i); - } - } - - removeSelectedNode(nodeID); - return null; - } - - public NodeInfo removeNode(String nodeID, String nodeType) { - for (int i = 0; i < nodeCollection.size(); i++) { - if (nodeCollection.get(i).getNodeID().equalsIgnoreCase(nodeID) && - nodeCollection.get(i).getNodeType().equalsIgnoreCase(nodeType)) { - return nodeCollection.remove(i); - } - } - - removeSelectedNode(nodeID, nodeType); - return null; - } -*/ -/* public void removeNode(String nodeType) { - nodeCollection.remove(nodeType); - }*/ - -/* public ArrayList<NodeInfo> getCellsiteLocation(String location, boolean exactMatch) { - ArrayList<NodeInfo> list = new ArrayList<NodeInfo>(); - - for (NodeInfo nodeInfo : nodeCollection) { - if (nodeInfo.getAttribute("Location") == null) { - continue; - } - - if (exactMatch) { - if (nodeInfo.getAttribute("Location").equalsIgnoreCase(location)) { - list.add(nodeInfo); - } - } - else { - if (nodeInfo.getAttribute("Location").toUpperCase().indexOf(location.toUpperCase()) != -1) { - list.add(nodeInfo); - } - } - } - - return list; - } -*/ + public void clearNode() { nodeCollection.clear(); selectedNode.clear(); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/MapUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/MapUtils.java index 6bc6dd5c..0914c12c 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/MapUtils.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/utils/MapUtils.java @@ -64,18 +64,4 @@ public class MapUtils { * @return null if not valid number (must be between 2008/01 to 2010/12) */ - -/* public static void saveColor(HttpServletRequest request, DomainService domainService, - String type, String colorValue) { -// String userID = Integer.toString(UserUtils.getUserId(request)); -// MapColorPK colorPK = new MapColorPK(); -// MapColorVO colorVO = new MapColorVO(); -// -// colorPK.setUserID(userID); -// colorPK.setPrefID(type); -// colorVO.setMapColorPK(colorPK); -// colorVO.setColorValue(colorValue); -// -// domainService.saveDomainObject(colorVO); - } */ } 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; |