From 1c6c6e4a8a1004c2086ca66dc13e8205f7492fee Mon Sep 17 00:00:00 2001 From: Indrijeet kumar Date: Thu, 7 May 2020 08:49:13 +0530 Subject: removed some code smells removed some code smells Issue-ID: PORTAL-813 Change-Id: I936676da6411bcb84ed61a646664f6df23aa2601 Signed-off-by: Indrijeet Kumar --- .../analytics/model/runtime/ReportRuntime.java | 30 +++++++++++----------- .../analytics/model/search/SearchResultJSON.java | 4 +-- .../portalsdk/analytics/scheduler/SendEmail.java | 6 ++--- .../system/fusion/adapter/RaptorAdapter.java | 16 ++++++------ .../fusion/controller/FileServletController.java | 2 +- .../system/fusion/web/RaptorControllerAsync.java | 12 ++++----- 6 files changed, 35 insertions(+), 35 deletions(-) (limited to 'ecomp-sdk') diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java index 558f5f71..b6f944a7 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java @@ -2684,12 +2684,12 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep reportJSONRuntime.setHideFormFieldsAfterRun(isHideFormFieldAfterRun()); reportJSONRuntime.setDisplayExcel(!isDisplayOptionHideExcelIcons()); reportJSONRuntime.setDisplayPDF(!isDisplayOptionHidePDFIcons()); - ArrayList formFieldValues = new ArrayList(); - ArrayList formFieldJSONList = new ArrayList(); + ArrayList formFieldValues = new ArrayList<>(); + ArrayList formFieldJSONList = new ArrayList<>(); if(getReportFormFields()!=null) { - formFieldJSONList = new ArrayList(getReportFormFields().size()); + formFieldJSONList = new ArrayList<>(getReportFormFields().size()); for (Iterator iter = getReportFormFields().iterator(); iter.hasNext();) { - formFieldValues = new ArrayList(); + formFieldValues = new ArrayList<>(); FormField ff = (FormField) iter.next(); ff.setDbInfo(getDbInfo()); FormFieldJSON ffJSON = new FormFieldJSON(); @@ -2789,8 +2789,8 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep if(rd!=null) { count = 0; reportJSONRuntime.setTotalRows(getReportDataSize()); - ArrayList colList = new ArrayList(); - ArrayList> reportDataRows = new ArrayList>(); + ArrayList colList = new ArrayList<>(); + ArrayList> reportDataRows = new ArrayList<>(); for(rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext(); ) { count++; ColumnHeaderRow chr = rd.reportColumnHeaderRows.getNext(); @@ -2801,7 +2801,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep if(getReportDataSize() > 0) { count = 0; for(rd.reportDataRows.resetNext(); rd.reportDataRows.hasNext(); count++) { - dvJSON = new HashMap(); + dvJSON = new HashMap<>(); DataRow dr = rd.reportDataRows.getNext(); for(dr.resetNext(); dr.hasNext(); ) { DataValue dv = dr.getNext(); @@ -2840,12 +2840,12 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep reportJSONRuntime.setReportSubTitle(getReportSubTitle()); reportJSONRuntime.setAllowEdit(isAllowEdit(request)); reportJSONRuntime.setNumFormCols(getNumFormColsAsInt()); - ArrayList formFieldValues = new ArrayList(); - ArrayList formFieldJSONList = new ArrayList(); + ArrayList formFieldValues = new ArrayList<>(); + ArrayList formFieldJSONList = new ArrayList<>(); if(reportFormFields!=null) { - formFieldJSONList = new ArrayList(reportFormFields.size()); + formFieldJSONList = new ArrayList<>(reportFormFields.size()); for (Iterator iter = reportFormFields.iterator(); iter.hasNext();) { - formFieldValues = new ArrayList(); + formFieldValues = new ArrayList<>(); FormField ff = (FormField) iter.next(); FormFieldJSON ffJSON = new FormFieldJSON(); ffJSON.setFieldId(ff.getFieldName()); @@ -2858,7 +2858,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep formFieldJSONList.add(ffJSON); } for (Iterator iter = reportFormFields.iterator(); iter.hasNext();) { - formFieldValues = new ArrayList(); + formFieldValues = new ArrayList<>(); FormField ff = (FormField) iter.next(); ff.setDbInfo(getDbInfo()); for (Iterator iter1 = formFieldJSONList.iterator(); iter1.hasNext();) { @@ -2895,7 +2895,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep lookup.trimToSize(); String requestValue = request.getParameter(ff.getFieldName()); - ArrayList requestValueList = new ArrayList(); + ArrayList requestValueList = new ArrayList<>(); requestValueList.add(requestValue); /*if(ff.isTriggerThisFormfield()) { @@ -2954,7 +2954,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep private String parseAndFillOtherFormfieldValues(HttpServletRequest request, String SQL, String userId, ArrayList formFieldJSONList) { - ArrayList formFieldValues = new ArrayList(); + ArrayList formFieldValues = new ArrayList<>(); String selectedValue = ""; String displayName = ""; for (Iterator iter1 = formFieldJSONList.iterator(); iter1.hasNext();) { @@ -3028,7 +3028,7 @@ public String parseAndFillWithCurrentValues(HttpServletRequest request, String s String fieldId = fft.getFieldId(); String fieldDisplay = getFormFieldDisplayName(fft); String formfield_value = ""; - List selectedItems = new ArrayList(); + List selectedItems = new ArrayList<>(); //Added so that Combo Box in old RAPTOR definition is translated to List box if(fft.getFieldType().equals(FormField.FFT_COMBO_BOX)) { fft.setFieldType(FormField.FFT_LIST_BOX); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultJSON.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultJSON.java index 3148d277..586ec580 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultJSON.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultJSON.java @@ -41,9 +41,9 @@ import java.util.ArrayList; public class SearchResultJSON{ - public ArrayList searchResultColumns = new ArrayList(); + public ArrayList searchResultColumns = new ArrayList<>(); - public ArrayList searchResultRows = new ArrayList(); + public ArrayList searchResultRows = new ArrayList<>(); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendEmail.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendEmail.java index 144c6ea8..1e0f574b 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendEmail.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendEmail.java @@ -71,7 +71,7 @@ SchedulerUtil schedulerUtil; public void sendEmail( String p_mail_server, String p_sender, String p_subject, String p_mail_text, String p_url, int p_file_type, int p_schedule_id, int p_time_interval, boolean p_send_attachment, int connectionTimeout) throws SQLException, ReportSQLException{ String allEmailAddr = ""; - final List emailArr = new ArrayList(); + final List emailArr = new ArrayList<>(); //int count1 = 0; String schedular_email; @@ -160,8 +160,8 @@ SchedulerUtil schedulerUtil; //v_hist_rec.file_blob = response.toString(); //v_hist_rec.file_size = v_hist_rec.file_blob.length(); - List params = new ArrayList(); - List types = new ArrayList(); + List params = new ArrayList<>(); + List types = new ArrayList<>(); prepareHisRecUpdate(v_hist_rec, params, types); schedulerUtil diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java index c934f8d4..354d72bc 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java @@ -107,7 +107,7 @@ public class RaptorAdapter extends FusionAdapter { /** Obtains user name by ID */ public static String getUserName(String userId) { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put(USER_ID, new Long(userId)); List list = getDataAccessService().executeNamedQuery("getUserNameById", params, null); @@ -130,7 +130,7 @@ public class RaptorAdapter extends FusionAdapter { } public static String getUserEmail(String userId) { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put(USER_ID, new Long(userId)); List list = getDataAccessService().executeNamedQuery("getUserEmail", params, null); String email = ""; @@ -205,7 +205,7 @@ public class RaptorAdapter extends FusionAdapter { /** Obtains role name by ID */ public static String getRoleName(String roleId) { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("role_id", new Long(roleId)); List list = getDataAccessService().executeNamedQuery("getRoleNameById", params, null); @@ -225,7 +225,7 @@ public class RaptorAdapter extends FusionAdapter { public static Map getAllRolesUsingCustomizedQuery(String customizedQuery, String param, boolean isAdmin) { List roles = null; - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); if(customizedQuery.length()>0 && !isAdmin) { @@ -308,7 +308,7 @@ public class RaptorAdapter extends FusionAdapter { public static Set getActiveUsersRoleIds(Long userId) { Set allActiveUserRoles = getActiveUserRoles(userId); Iterator allActiveUserRolesIterator = allActiveUserRoles.iterator(); - Set allActiveUserRoleIds = new TreeSet(); + Set allActiveUserRoleIds = new TreeSet<>(); while(allActiveUserRolesIterator.hasNext()){ Role role = allActiveUserRolesIterator.next(); allActiveUserRoleIds.add(role.getId()); @@ -320,7 +320,7 @@ public class RaptorAdapter extends FusionAdapter { public static Set getActiveUserRoleIds(Long userId) { Set allActiveUserRoles = getActiveUserRoles(userId); Iterator allActiveUserRolesIterator = allActiveUserRoles.iterator(); - Set allActiveUserRoleIds = new TreeSet(); + Set allActiveUserRoleIds = new TreeSet<>(); while(allActiveUserRolesIterator.hasNext()){ Role role = allActiveUserRolesIterator.next(); allActiveUserRoleIds.add(role.getId()); @@ -332,7 +332,7 @@ public class RaptorAdapter extends FusionAdapter { public static Set getActiveRoleFunctions(Long userId) { Set allActiveUserRoles = getActiveUserRoles(userId); Iterator allActiveUserRolesIterator = allActiveUserRoles.iterator(); - Set allActiveRoleFunctions = new TreeSet(); + Set allActiveRoleFunctions = new TreeSet<>(); while(allActiveUserRolesIterator.hasNext()){ Role role = allActiveUserRolesIterator.next(); allActiveRoleFunctions.addAll(role.getRoleFunctions()); @@ -343,7 +343,7 @@ public class RaptorAdapter extends FusionAdapter { public static Set getActiveUserRoles(Long userId) { User user = (User)getDataAccessService().getDomainObject(User.class,userId,null); - Set allActiveUserRoles = new TreeSet(); + Set allActiveUserRoles = new TreeSet<>(); allActiveUserRoles.addAll(user.getRoles()); Iterator userRolesIterator = user.getRoles().iterator(); while(userRolesIterator.hasNext()){ diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/controller/FileServletController.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/controller/FileServletController.java index a03c9539..444b8afc 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/controller/FileServletController.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/controller/FileServletController.java @@ -131,7 +131,7 @@ public class FileServletController { return null; } catch (Exception e) { logger.error(EELFLoggerDelegate.debugLogger, ("Exception occurred..." + e.getMessage())); - Map errView = new HashMap(); + Map errView = new HashMap<>(); errView.put("error", "The requested resource was not found."); //return new ModelAndView(getExceptionView(), "model", errView); return null; diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java index 517d2672..bf7ef0bb 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java @@ -1230,7 +1230,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { public @ResponseBody Map removeSelectedReportRole( @RequestBody String roleIdToRemove, HttpServletRequest request, HttpServletResponse response) { - Map JsonResponse = new HashMap(); + Map JsonResponse = new HashMap<>(); ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION); try { JsonResponse.put("status","success"); @@ -1303,7 +1303,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { @PathVariable("roleID") String roleId, @RequestBody String readOnly, HttpServletRequest request, HttpServletResponse response) { - Map JsonResponse = new HashMap(); + Map JsonResponse = new HashMap<>(); ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION); try { String action =""; @@ -1396,7 +1396,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { int iCount = 0; for(Iterator iter=reportUsers.iterator(); iter.hasNext(); iCount++) { - Map reportUserMap = new HashMap(); + Map reportUserMap = new HashMap<>(); SecurityEntry rUser = (SecurityEntry) iter.next(); reportUserMapList.add(rUser); } @@ -1487,7 +1487,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { wizardJSON.setDbInfo((rdef != null) ? rdef.getDBInfo() : ""); wizardJSON.setFormHelpText((rdef != null) ? rdef.getFormHelpText() : ""); wizardJSON.setPageSize((rdef != null) ? rdef.getPageSize() : 50); - List displayArea = new ArrayList(); + List displayArea = new ArrayList<>(); IdNameBooleanJSON idNameJSON = new IdNameBooleanJSON(); String qMenu = ""; for (int i = 0; i < AppUtils.getQuickLinksMenuIDs().size(); i++) { @@ -1506,7 +1506,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { wizardJSON.setFrozenColumns((rdef != null) ? rdef.getFrozenColumns() : 0); wizardJSON.setDataGridAlign((rdef != null) ? rdef.getDataGridAlign() : "left"); wizardJSON.setEmptyMessage((rdef != null) ? rdef.getEmptyMessage() : "No records found"); - List displayOptions = new ArrayList(); + List displayOptions = new ArrayList<>(); NameBooleanJSON nameBooleanJSON = new NameBooleanJSON(); nameBooleanJSON.setName("HideFormFields"); nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHideForm() : false); @@ -1542,7 +1542,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { String schemaSql = Globals.getRemoteDbSchemaSql(); DataSet ds = null; - ArrayList dbInfoList = new ArrayList(); + ArrayList dbInfoList = new ArrayList<>(); try { ds = DbUtils.executeQuery(schemaSql); -- cgit 1.2.3-korg