diff options
Diffstat (limited to 'ecomp-sdk')
14 files changed, 197 insertions, 97 deletions
diff --git a/ecomp-sdk/epsdk-analytics/README.md b/ecomp-sdk/epsdk-analytics/README.md index be0b376c..5fd6d23d 100644 --- a/ecomp-sdk/epsdk-analytics/README.md +++ b/ecomp-sdk/epsdk-analytics/README.md @@ -11,6 +11,6 @@ features including charts, maps and reports ("Raptor"). Version 1.1.0 - [Portal-7] Improvements added as part of the rebasing process - + Version 1.0.0 - Initial release diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartD3Helper.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartD3Helper.java index 22602e03..698d52a5 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartD3Helper.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartD3Helper.java @@ -1074,7 +1074,7 @@ public class ChartD3Helper { } else { wholeScript.append(" .rotateLabels(\"0\") \n "); } - //wholeScript.append(" .axisLabel('" + legendColumnName + "')"); + wholeScript.append(" .axisLabel('" + legendColumnName + "')"); if(flagNoDate == 1 || !timeAxis) { wholeScript.append(";\n"); } else { diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartJSON.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartJSON.java index 8ec6bc19..66bce17a 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartJSON.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartJSON.java @@ -130,6 +130,8 @@ public class ChartJSON { this.hasCategoryAxis = hasCategoryAxis; } private ArrayList <RangeAxisJSON> rangeAxisList; + private ArrayList <RangeAxisJSON> rangeAxisRemoveList; + private ArrayList <ArrayList<Row>> wholeList; private String primaryAxisLabel; @@ -447,5 +449,12 @@ public class ChartJSON { else return ""; } + public ArrayList<RangeAxisJSON> getRangeAxisRemoveList() { + return rangeAxisRemoveList; + } + public void setRangeAxisRemoveList(ArrayList<RangeAxisJSON> rangeAxisRemoveList) { + this.rangeAxisRemoveList = rangeAxisRemoveList; + } + } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java index 0194b52d..48fdbe4c 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java @@ -29,6 +29,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -1276,6 +1277,10 @@ public class RaptorControllerAsync extends RestrictedBaseController { ArrayList<RangeAxisJSON> rangeAxisList = chartJSON.getRangeAxisList(); int r = 0; + HashSet<String> removeRangeAxisMap = new HashSet<>(); + for(RangeAxisJSON rangeAxis:chartJSON.getRangeAxisRemoveList()){ + removeRangeAxisMap.add(rangeAxis.getRangeAxis()); + } for (int i = 0; i < rangeAxisList.size(); i++) { RangeAxisJSON rangeAxisJSON = rangeAxisList.get(i); String rangeAxis = rangeAxisJSON.getRangeAxis(); @@ -1287,7 +1292,10 @@ public class RaptorControllerAsync extends RestrictedBaseController { rangefor: for (Iterator<DataColumnType> iterator = reportCols.iterator(); iterator.hasNext();) { DataColumnType dct = (DataColumnType) iterator.next(); if (dct.getColId().equals(rangeAxis)) { - dct.setChartSeq(++r); + if(removeRangeAxisMap.contains(rangeAxis)) + dct.setChartSeq(-1); // if we set it to -1, means this range axis will not be included + else + dct.setChartSeq(++r); dct.setColOnChart("0"); dct.setYAxis(rangeYAxis); // +"|"+dct.getColId()); dct.setChartGroup(rangeChartGroup); // +"|"+dct.getColId()); diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java index c5614f80..e44aef8b 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java @@ -55,13 +55,13 @@ public class ProfileSearchController extends RestrictedBaseController { private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ProfileSearchController.class); @Autowired - UserProfileService service; + private UserProfileService service; @Autowired - FnMenuService fnMenuService; + private FnMenuService fnMenuService; @RequestMapping(value = { "/profile_search" }, method = RequestMethod.GET) - public ModelAndView ProfileSearch(HttpServletRequest request) { + public ModelAndView profileSearch(HttpServletRequest request) { Map<String, Object> model = new HashMap<String, Object>(); ObjectMapper mapper = new ObjectMapper(); List<User> profileList = null; @@ -71,14 +71,13 @@ public class ProfileSearchController extends RestrictedBaseController { model.putAll(setDashboardData(request)); model.put("profileList", mapper.writeValueAsString(profileList)); } catch (Exception e) { - logger.error(EELFLoggerDelegate.applicationLogger, - "error while profile_search process in ProfileSearchController" + e.getMessage()); + logger.error(EELFLoggerDelegate.applicationLogger, "profileSearch failed", e); } return new ModelAndView(getViewName(), "model", model); } @RequestMapping(value = { "/get_user" }, method = RequestMethod.GET) - public void GetUser(HttpServletRequest request, HttpServletResponse response) { + public void getUser(HttpServletRequest request, HttpServletResponse response) { logger.info(EELFLoggerDelegate.applicationLogger, "Initiating get_user in ProfileSearchController"); ObjectMapper mapper = new ObjectMapper(); List<User> profileList = null; @@ -86,11 +85,10 @@ public class ProfileSearchController extends RestrictedBaseController { profileList = service.findAll(); JsonMessage msg = new JsonMessage(mapper.writeValueAsString(profileList)); JSONObject j = new JSONObject(msg); + response.setContentType("application/json"); response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.applicationLogger, - "error while get_user process in ProfileSearchController" + e.getMessage()); + logger.error(EELFLoggerDelegate.applicationLogger, "getUser failed", e); } } @@ -111,16 +109,15 @@ public class ProfileSearchController extends RestrictedBaseController { model.put("profileList", mapper.writeValueAsString(profileList)); JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); JSONObject j = new JSONObject(msg); + response.setContentType("application/json"); response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.applicationLogger, - "error while get_user_pagination process in ProfileSearchController" + e.getMessage()); + logger.error(EELFLoggerDelegate.applicationLogger, "getUserPagination failed", e); } } @SuppressWarnings("unchecked") - public Map<String, Object> setDashboardData(HttpServletRequest request) throws Exception { + private Map<String, Object> setDashboardData(HttpServletRequest request) throws Exception { ObjectMapper mapper = new ObjectMapper(); Map<String, Object> model = new HashMap<String, Object>(); List<List<MenuData>> childItemList = new ArrayList<List<MenuData>>(); @@ -132,8 +129,7 @@ public class ProfileSearchController extends RestrictedBaseController { .getAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME)); fnMenuService.setMenuDataStructure(childItemList, parentList, menuResult); } catch (Exception e) { - logger.error(EELFLoggerDelegate.applicationLogger, - "error while setDashboardData process in ProfileSearchController" + e.getMessage()); + logger.error(EELFLoggerDelegate.applicationLogger, "setDashboardData failed", e); } model.put("childItemList", mapper.writeValueAsString(childItemList)); model.put("parentList", mapper.writeValueAsString(parentList)); @@ -156,8 +152,7 @@ public class ProfileSearchController extends RestrictedBaseController { PrintWriter out = response.getWriter(); out.write(mapper.writeValueAsString(user.getActive())); } catch (Exception e) { - logger.error(EELFLoggerDelegate.applicationLogger, - "error while toggleProfileActive process in ProfileSearchController" + e.getMessage()); + logger.error(EELFLoggerDelegate.applicationLogger, "toggleProfileActive failed", e); } } } diff --git a/ecomp-sdk/epsdk-app-os/pom.xml b/ecomp-sdk/epsdk-app-os/pom.xml index efcbbe0a..5060f56e 100644 --- a/ecomp-sdk/epsdk-app-os/pom.xml +++ b/ecomp-sdk/epsdk-app-os/pom.xml @@ -10,9 +10,6 @@ <packaging>war</packaging> <name>ECOMP SDK Webapp for OpenSource</name> <description>ECOMP SDK Web Application for public release</description> - <scm> - <connection>scm:git:https://todourl/</connection> - </scm> <properties> <encoding>UTF-8</encoding> diff --git a/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-profile/profile_searchDS2.html b/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-profile/profile_searchDS2.html index 36b8c2a4..e0709672 100644 --- a/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-profile/profile_searchDS2.html +++ b/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-profile/profile_searchDS2.html @@ -34,8 +34,9 @@ <td> <div class="form-row"> <label class="btn-switch-label" tabindex="0" role="option"> - <input type="checkbox" b2b-switches ng-model="rowData.active" - ng-disabled="allDisabled" aria-disabled="{{allDisabled}}"> + <input type="checkbox" b2b-switches + ng-model="rowData.active" ng-click="toggleProfileActive(rowData)" + ng-disabled="allDisabled" aria-disabled="{{allDisabled}}" /> <div class="sr-text hidden-spoken" ng-if="!allDisabled">Double tap to turn</div> </label> diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js index fc36b73d..8fa14643 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js @@ -187,7 +187,8 @@ appDS2.controller('reportChartController', function ($scope, $rootScope, $timeou $scope.reportRunJson.categoryAxisJSON = {}; $scope.reportRunJson.categoryAxisJSON.value = -1; } - + //add the remove list to the json + $scope.reportRunJson.rangeAxisRemoveList= $scope.rangeAxisRemoveList; $http.post("save_chart", JSON.stringify($scope.reportRunJson)).success(function(data, status) { $scope.successSubmit=true; $scope.showLoader = false; @@ -201,8 +202,9 @@ appDS2.controller('reportChartController', function ($scope, $rootScope, $timeou $scope.reportRunJson.barChartOptions.timeAxis =$scope.reportRunJson.barChartOptions.timeAxis+""; $scope.reportRunJson.barChartOptions.verticalOrientation = $scope.reportRunJson.barChartOptions.verticalOrientation +""; $scope.reportRunJson.barChartOptions.xAxisDateType = $scope.reportRunJson.barChartOptions.xAxisDateType +""; - } - }) + } + $scope.populateChrtWzdFields(); + }) } @@ -211,14 +213,17 @@ appDS2.controller('reportChartController', function ($scope, $rootScope, $timeou }); }; - $scope.removeRangeAxisRow = function (index) { - $scope.reportRunJson.rangeAxisList.splice(index, 1); + $scope.rangeAxisRemoveList= []; + $scope.removeRangeAxisRow = function (index) { + $scope.rangeAxisRemoveList.push($scope.reportRunJson.rangeAxisList[index]); + $scope.reportRunJson.rangeAxisList[index].removed="true"; }; $scope.init = function () { if ($scope) { $scope.populateChrtWzdFields(); + $scope.reportRunJson.rangeAxisRemoveList= []; } }; diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-search-controller-DS2.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-search-controller-DS2.js index 57e2e80b..5236001f 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-search-controller-DS2.js +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/profile-search-controller-DS2.js @@ -1,10 +1,12 @@ -appDS2.controller('profileSearchCtrlDS2', function($scope, $http,ProfileServiceDS2){ +appDS2.controller('profileSearchCtrlDS2', function($scope, $log, $modal, ProfileServiceDS2){ $scope.showInput = true; - $scope.totalPages1 = 5; + $scope.totalPages1 = 0; $scope.viewPerPage1 = 8; $scope.currentPage1 = 1; $scope.showLoader = false; + var debug = false; + $scope.$watch('viewPerPage1', function(val) { $scope.showLoader = true; ProfileServiceDS2.getProfilePagination($scope.currentPage1, val).then(function(data){ @@ -12,15 +14,9 @@ appDS2.controller('profileSearchCtrlDS2', function($scope, $http,ProfileServiceD $scope.data = JSON.parse(j.data); $scope.tableData =JSON.parse($scope.data.profileList); $scope.totalPages1 =JSON.parse($scope.data.totalPage); - for(x in $scope.tableData){ - if($scope.tableData[x].active_yn=='Y') - $scope.tableData[x].active_yn=true; - else - $scope.tableData[x].active_yn=false; - } $scope.showLoader = false; },function(error){ - console.log("failed"); + console.log("watch of viewPerPage1 failed"); reloadPageOnce(); }); @@ -34,15 +30,9 @@ appDS2.controller('profileSearchCtrlDS2', function($scope, $http,ProfileServiceD $scope.data = JSON.parse(j.data); $scope.tableData =JSON.parse($scope.data.profileList); $scope.totalPages1 =JSON.parse($scope.data.totalPage); - for(x in $scope.tableData){ - if($scope.tableData[x].active_yn=='Y') - $scope.tableData[x].active_yn=true; - else - $scope.tableData[x].active_yn=false; - } $scope.showLoader = false; },function(error){ - console.log("failed"); + console.log("customHandler failed"); reloadPageOnce(); }); @@ -52,13 +42,52 @@ appDS2.controller('profileSearchCtrlDS2', function($scope, $http,ProfileServiceD window.location = 'userProfile#/profile/' + profileId; }; + var ModalInstanceCtrl = function ($scope, $log, $modalInstance, items) { + $scope.msg = items; + + $scope.toggleUserStatus = function(id) { + if (debug) + $log.debug('profileSearchCtrlDS2:ModalInstanceCtrl:toggleUserStatus: data is ' + id); + ProfileServiceDS2.toggleProfileStatus(id); + $modalInstance.close(); + }; + + $scope.cancelUserStatusToggle = function(rowData) { + if (debug) + $log.debug('profileSearchCtrlDS2:ModalInstanceCtrl: cancelUserStatusToggle: data is ' + JSON.stringify(rowData)); + // Undo the toggle of the checkbox + rowData.active = ! rowData.active; + $modalInstance.dismiss('cancel'); + } + + } + + // user activation/deactivation $scope.toggleProfileActive = function(rowData) { - modalService.popupConfirmWinWithCancel("Confirm","You are about to change user's active status. Do you want to continue?", - function(){ - $http.get("profile/toggleProfileActive?profile_id="+rowData.id).success(function(){}); - }, - function(){ - rowData.active=!rowData.active; - }) - }; + if (debug) + $log.debug('profileSearchCtrlDS2:toggleProfileActive: id is ' + rowData.id + + ', active is ' + rowData.active); + var toggleType = null; + // The checkbox is already in the desired state, + // so the sense of the "if" is reversed here. + if (rowData.active) + toggleType = "activate"; + else + toggleType = "deactivate"; + var modalInstance = $modal.open({ + templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-profile/modals/profile-confirm-toggle.html', + controller: ModalInstanceCtrl, + sizeClass: 'modal-small', + resolve: { + items: function () { + var message = { + text : toggleType, + rowData : rowData + }; + return message; + } + } + }); + }; + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-services/profileServiceDS2.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-services/profileServiceDS2.js index 1ca373f9..812e8320 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-services/profileServiceDS2.js +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-services/profileServiceDS2.js @@ -73,6 +73,21 @@ appDS2.factory('ProfileServiceDS2', function ($http, $q) { // something went wrong return $q.reject(response.data); }); + }, + + toggleProfileStatus: function(id) { + return $http.get('profile/toggleProfileActive?profile_id=' + id) + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); } + }; }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-profile/modals/profile-confirm-toggle.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-profile/modals/profile-confirm-toggle.html new file mode 100644 index 00000000..0fe37686 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-profile/modals/profile-confirm-toggle.html @@ -0,0 +1,23 @@ +<div> + <div class="b2b-modal-header ng-scope in"> + <h1><i class="icon-primary-alert"></i></h1> + <h2 id="myModalLabel" modal-title="">Confirm</h2> + <div class="corner-button in"> + <button type="button" class="close" aria-label="Close" + ng-click="$dismiss('cancel')"></button> + </div> + </div> + <div class="b2b-modal-body ng-scope ng-isolate-scope in" tabindex="0" + role="region" aria-label="Modal header text content" + style="height: 55px;"> + You are about to {{msg.text}} the user with ID {{msg.rowData.id}}. Do you want to continue? + </div> + <div class="b2b-modal-footer ng-scope ng-isolate-scope in"> + <div class="cta-button-group in"> + <button class="btn btn-alt btn-medium" type="button" + ng-click="toggleUserStatus(msg.rowData.id);">Ok</button> + <button class="btn btn-clear btn-medium" type="button" + ng-click="cancelUserStatusToggle(msg.rowData);">Cancel</button> + </div> + </div> +</div> diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-chart-wizard.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-chart-wizard.html index 3fae62f1..8558729e 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-chart-wizard.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/report-chart-wizard.html @@ -138,29 +138,32 @@ table{ <tbody> <tr> <td> - <select name="chartType" b2b-dropdown ng-model="rangeReport.rangeAxisLabelJSON.value" placeholder-text="Select"> + <select name="chartType" b2b-dropdown ng-model="rangeReport.rangeAxisLabelJSON.value" placeholder-text="Select" ng-disabled="rangeReport.removed=='true'"> <option b2b-dropdown-list option-repeat="d in reportRunJson.chartColumnJSONList" value="{{d.value}}">{{d.title}}</option> - </select> + </select> </td> <td> - <input type="text" name="displayName" ng-model="rangeReport.rangeYAxis" style="width:100px;"> + <input type="text" name="displayName" ng-model="rangeReport.rangeYAxis" ng-disabled="rangeReport.removed=='true'" style="width:100px;"> </td> <td> - <input type="text" name="displayName" ng-model="rangeReport.rangeChartGroup" style="width:150px;"> + <input type="text" name="displayName" ng-model="rangeReport.rangeChartGroup" ng-disabled="rangeReport.removed=='true'" style="width:150px;"> </td> <td> - <select name="chartType" b2b-dropdown ng-model="rangeReport.rangeColor"> + <select name="chartType" b2b-dropdown ng-model="rangeReport.rangeColor" ng-disabled="rangeReport.removed=='true'"> <option b2b-dropdown-list option-repeat="d in rangeColors" value="{{d.value}}">{{d.title}}</option> - </select> + </select> </td> <td> - <select name="lineType" b2b-dropdown ng-model="rangeReport.rangeLineType"> - <option b2b-dropdown-list option-repeat="d in lineTypes" value="{{d.value}}">{{d.title}}</option> - </select> + <select name="lineType" b2b-dropdown ng-model="rangeReport.rangeLineType" ng-disabled="rangeReport.removed=='true'"> + <option b2b-dropdown-list option-repeat="d in lineTypes" value="{{d.value}}">{{d.title}}</option> + </select> </td> <td> <button ng-show="$index==0" type="submit" style="width: 90px; height:35px;margin-left:5px;" class="btn btn-secondary btn-small" ng-click="addRangeAxisRow()">Add</button> - <button ng-hide="$index==0" type="submit" style="width: 90px; height:35px;margin-left:5px;" class="btn btn-secondary btn-small" ng-click="removeRangeAxisRow($index)">Remove</button> + <span ng-hide="$index==0"> + <button ng-if="rangeReport.removed!='true'" type="submit" style="width: 90px; height:35px;margin-left:5px;" class="btn btn-secondary btn-small" ng-click="removeRangeAxisRow($index)">Remove</button> + <button ng-if="rangeReport.removed=='true'" type="submit" style="width: 90px; height:35px;margin-left:5px;" class="btn btn-secondary btn-small" disabled="disabled">Removed</button> + </span> </td> </tr> @@ -891,4 +894,4 @@ table{ <button type="submit" style="width: 90px; height:35px;margin-top:20px; margin-left:5px;" class="btn btn-alt btn-small">Run</button> </a> </div> -</div>
\ No newline at end of file +</div> diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java index 95f149ae..10d71872 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/conf/AppConfig.java @@ -171,27 +171,23 @@ public class AppConfig extends WebMvcConfigurerAdapter implements Configurable, /** * - * Application Data Source + * Creates the Application Data Source. * * @return DataSource Object + * @throws Exception + * on failure to create data source object */ - @Bean public DataSource dataSource() throws Exception { - + systemProperties(); - - Boolean testConnectionOnCheckout = getConnectionOnCheckout(); - String preferredTestQuery = getPreferredTestQuery(); - ComboPooledDataSource dataSource = new ComboPooledDataSource(); try { dataSource.setDriverClass(SystemProperties.getProperty(SystemProperties.DB_DRIVER)); dataSource.setJdbcUrl(SystemProperties.getProperty(SystemProperties.DB_CONNECTIONURL)); dataSource.setUser(SystemProperties.getProperty(SystemProperties.DB_USERNAME)); - // dataSource.setPassword(SystemProperties.getProperty(SystemProperties.DB_PASSWOR)); - String password = SystemProperties.getProperty(SystemProperties.DB_PASSWOR); + String password = SystemProperties.getProperty(SystemProperties.DB_PASSWORD); if (SystemProperties.containsProperty(SystemProperties.DB_ENCRYPT_FLAG)) { String encryptFlag = SystemProperties.getProperty(SystemProperties.DB_ENCRYPT_FLAG); if (encryptFlag != null && encryptFlag.equalsIgnoreCase("true")) { @@ -205,9 +201,8 @@ public class AppConfig extends WebMvcConfigurerAdapter implements Configurable, .setMaxPoolSize(Integer.parseInt(SystemProperties.getProperty(SystemProperties.DB_MAX_POOL_SIZE))); dataSource.setIdleConnectionTestPeriod( Integer.parseInt(SystemProperties.getProperty(SystemProperties.IDLE_CONNECTION_TEST_PERIOD))); - dataSource.setTestConnectionOnCheckout(testConnectionOnCheckout); - dataSource.setPreferredTestQuery(preferredTestQuery); - + dataSource.setTestConnectionOnCheckout(getConnectionOnCheckout()); + dataSource.setPreferredTestQuery(getPreferredTestQuery()); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "Error initializing database, verify database settings in properties file: " @@ -217,37 +212,55 @@ public class AppConfig extends WebMvcConfigurerAdapter implements Configurable, "Error initializing database, verify database settings in properties file: " + UserUtils.getStackTrace(e), AlarmSeverityEnum.CRITICAL); - // Raise an alarm that opening a connection to the database is - // failed. + // Raise an alarm that opening a connection to the database failed. logger.logEcompError(AppMessagesEnum.BeDaoSystemError); throw e; } return dataSource; } + /** + * Gets the value of the property + * {@link SystemProperties#PREFERRED_TEST_QUERY}; defaults to "Select 1" if + * the property is not defined. + * + * @return String value that is a SQL query + */ private String getPreferredTestQuery() { - String preferredTestQueryStr = null; - try { + // Use simple default + String preferredTestQueryStr = "SELECT 1"; + if (SystemProperties.containsProperty(SystemProperties.PREFERRED_TEST_QUERY)) { preferredTestQueryStr = SystemProperties.getProperty(SystemProperties.PREFERRED_TEST_QUERY); - } catch (Exception e) { + logger.debug(EELFLoggerDelegate.debugLogger, "getPreferredTestQuery: property key {} value is {}", + SystemProperties.PREFERRED_TEST_QUERY, preferredTestQueryStr); + } else { logger.info(EELFLoggerDelegate.errorLogger, - SystemProperties.PREFERRED_TEST_QUERY + " value not found " - + UserUtils.getStackTrace(e)); + "getPreferredTestQuery: property key {} not found, using default value {}", + SystemProperties.PREFERRED_TEST_QUERY, preferredTestQueryStr); } - String preferredTestQuery = ((preferredTestQueryStr == null) ? "SELECT 1" : preferredTestQueryStr); - return preferredTestQuery; + return preferredTestQueryStr; } + /** + * Gets the value of the property + * {@link SystemProperties#TEST_CONNECTION_ON_CHECKOUT}; defaults to true if + * the property is not defined. + * + * @return Boolean value + */ private Boolean getConnectionOnCheckout() { - String testConnectionOnCheckoutStr = null; - try { - testConnectionOnCheckoutStr = SystemProperties.getProperty(SystemProperties.TEST_CONNECTION_ON_CHECKOUT); - } catch (Exception e) { + // Default to true, always test connection + boolean testConnectionOnCheckout = true; + if (SystemProperties.containsProperty(SystemProperties.TEST_CONNECTION_ON_CHECKOUT)) { + testConnectionOnCheckout = Boolean + .valueOf(SystemProperties.getProperty(SystemProperties.TEST_CONNECTION_ON_CHECKOUT)); + logger.debug(EELFLoggerDelegate.debugLogger, "getConnectionOnCheckout: property key {} value is {}", + SystemProperties.TEST_CONNECTION_ON_CHECKOUT, testConnectionOnCheckout); + } else { logger.info(EELFLoggerDelegate.errorLogger, - SystemProperties.TEST_CONNECTION_ON_CHECKOUT + " value not found " - + UserUtils.getStackTrace(e)); + "getConnectionOnCheckout: property key {} not found, using default value {}", + SystemProperties.TEST_CONNECTION_ON_CHECKOUT, testConnectionOnCheckout); } - Boolean testConnectionOnCheckout = Boolean.valueOf(testConnectionOnCheckoutStr == null ? "true":testConnectionOnCheckoutStr); return testConnectionOnCheckout; } diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java index 033bb26b..2dacae84 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java @@ -74,7 +74,7 @@ public class SystemProperties { /** * Tests whether a property value is available for the specified key. * - * @param key + * @param key Property key * @return True if the key is known, otherwise false. */ public static boolean containsProperty(String key) { @@ -85,12 +85,12 @@ public class SystemProperties { * Returns the property value associated with the given key (never * {@code null}), after trimming any trailing space. * - * @throws IllegalStateException - * if the key cannot be resolved * @param key * Property key * @return Property value; the empty string if the environment was not * autowired, which should never happen. + * @throws IllegalStateException + * if the key cannot be resolved */ public static String getProperty(String key) { String value = ""; @@ -244,15 +244,17 @@ public class SystemProperties { // Hibernate Config public static final String HB_DIALECT = "hb.dialect"; public static final String HB_SHOW_SQL = "hb.show_sql"; + public static final String IDLE_CONNECTION_TEST_PERIOD = "hb.idle_connection_test_period"; // DataSource public static final String DB_DRIVER = "db.driver"; public static final String DB_CONNECTIONURL = "db.connectionURL"; public static final String DB_USERNAME = "db.userName"; + /** @deprecated this variable is used in many places so don't remove */ public static final String DB_PASSWOR = "db.password"; + public static final String DB_PASSWORD = "db.password"; public static final String DB_MIN_POOL_SIZE = "db.min_pool_size"; public static final String DB_MAX_POOL_SIZE = "db.max_pool_size"; - public static final String IDLE_CONNECTION_TEST_PERIOD = "hb.idle_connection_test_period"; public static final String TEST_CONNECTION_ON_CHECKOUT = "db.test_connection_on_checkout"; public static final String PREFERRED_TEST_QUERY = "db.preferred_test_query"; |