From 5b33f791aef66e431e532e9a8bb7996bc69787e1 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Wed, 6 Sep 2017 11:04:15 +0530 Subject: [PATCH 1/3] Minor refactorings and fixing formatting issues --- .../mgt/core/dao/impl/ApplicationDAOImpl.java | 22 +++++--- .../public/js/geo_fencing.js | 56 +++++++++---------- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationDAOImpl.java index c391f1057f..0de0e3aefb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationDAOImpl.java @@ -26,8 +26,16 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; -import java.io.*; -import java.sql.*; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.ObjectInputStream; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Properties; @@ -84,14 +92,14 @@ public class ApplicationDAOImpl implements ApplicationDAO { try { bao.close(); } catch (IOException e) { - log.warn("Error occurred while closing ByteArrayOutputStream", e); + log.error("Error occurred while closing ByteArrayOutputStream", e); } } if (oos != null) { try { oos.close(); } catch (IOException e) { - log.warn("Error occurred while closing ObjectOutputStream", e); + log.error("Error occurred while closing ObjectOutputStream", e); } } DeviceManagementDAOUtil.cleanupResources(stmt, rs); @@ -150,14 +158,14 @@ public class ApplicationDAOImpl implements ApplicationDAO { try { bao.close(); } catch (IOException e) { - log.warn("Error occurred while closing ByteArrayOutputStream", e); + log.error("Error occurred while closing ByteArrayOutputStream", e); } } if (oos != null) { try { oos.close(); } catch (IOException e) { - log.warn("Error occurred while closing ObjectOutputStream", e); + log.error("Error occurred while closing ObjectOutputStream", e); } } DeviceManagementDAOUtil.cleanupResources(stmt, null); @@ -193,7 +201,7 @@ public class ApplicationDAOImpl implements ApplicationDAO { conn.rollback(); } } catch (SQLException e1) { - log.warn("Error occurred while roll-backing the transaction", e); + log.error("Error occurred while roll-backing the transaction", e); } throw new DeviceManagementDAOException("Error occurred while removing bulk application list", e); } finally { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/geo_fencing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/geo_fencing.js index 3ef341187c..37e2aba94e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/geo_fencing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/geo_fencing.js @@ -40,27 +40,27 @@ function loadGeoFencing() { function openTools(id) { lastId = id; - if(drawControl){ + if (drawControl) { try{ map.removeControl(drawControl); - }catch(e){ + } catch(e) { console.log("error: " + e.message); } console.log("removed drawControl"); } - if(removeAllControl){ - try{ + if (removeAllControl) { + try { map.removeControl(removeAllControl); - }catch(e){ + } catch(e) { console.log("error: " + e.message); } console.log("removed removeAllControl"); } - if(drawnItems){ + if (drawnItems) { try{ map.removeLayer(drawnItems); console.log("removing layer"); - }catch(e){ + } catch(e) { console.log("error: " + e.message); } console.log("removed drawnItems"); @@ -112,7 +112,7 @@ function openTools(id) { drawnItems = new L.FeatureGroup(); map.addLayer(drawnItems); - if(id=="WithIn"){ + if (id=="WithIn") { // Initialise the draw control and pass it the FeatureGroup of editable layers drawControl = new L.Control.Draw({ draw: { @@ -139,7 +139,7 @@ function openTools(id) { featureGroup: drawnItems } }); - } else if(id=="Exit"){ + } else if (id=="Exit") { // Initialise the draw control and pass it the FeatureGroup of editable layers drawControl = new L.Control.Draw({ draw: { @@ -198,7 +198,7 @@ function openTools(id) { featureGroup: drawnItems } }); - } else if(id=="Traffic"){ + } else if (id=="Traffic") { // Initialise the draw control and pass it the FeatureGroup of editable layers drawControl = new L.Control.Draw({ draw: { @@ -233,7 +233,7 @@ function openTools(id) { featureGroup: drawnItems } }); - } else if(id =="Prediction"){ + } else if (id =="Prediction") { drawControl = new L.Control.Draw({ draw: { polygon: false, @@ -260,20 +260,20 @@ function openTools(id) { } function createPopup(layer,id) { - if(id=="WithIn"){ + if (id=="WithIn") { var popupTemplate = $('#setWithinAlert'); popupTemplate.find('#addWithinAlert').attr('leaflet_id', layer._leaflet_id); - } else if(id=="Exit"){ + } else if (id=="Exit") { var popupTemplate = $('#setExitAlert'); popupTemplate.find('#addExitAlert').attr('leaflet_id', layer._leaflet_id); - } else if(id=="Stationery"){ + } else if (id=="Stationery") { var popupTemplate = $('#setStationeryAlert'); popupTemplate.find('#addStationeryAlert').attr('leaflet_id', layer._leaflet_id); - } else if(id=="Traffic"){ + } else if (id=="Traffic") { var popupTemplate = $('#setTrafficAlert'); popupTemplate.find('#addTrafficAlert').attr('leaflet_id', layer._leaflet_id); //console.log(">>got here " + id + " " + popupTemplate.find('#addTrafficAlert') + " " + layer._leaflet_id); - } else if(id=="Prediction"){ + } else if (id=="Prediction") { getPrediction(layer._leaflet_id); return; } @@ -364,7 +364,7 @@ function viewFence(geoFenceElement,id) { var areaName = $(geoFenceElement).attr('data-areaName'); var geometryShape; - if(geoJson.type=="Point"){ + if (geoJson.type=="Point") { var circleOptions = { color: '#ff0043' @@ -373,7 +373,7 @@ function viewFence(geoFenceElement,id) { // var marker=new L.marker([geoJson.coordinates[1],geoJson.coordinates[0]]); map.addLayer(geometryShape); // map.addLayer(marker); - } else if(geoJson.type=="Polygon"){ + } else if (geoJson.type=="Polygon") { geoJson.coordinates[0].pop(); // popout the last coordinate set(lat,lng pair) due to circular chain var leafletLatLngs = []; $.each(geoJson.coordinates[0], function (idx, pItem) { @@ -385,7 +385,7 @@ function viewFence(geoFenceElement,id) { var geoPublicUri = $("#geo-charts").data("geo-public-uri"); - if(id=="Stationery"){ + if (id=="Stationery") { var stationeryTime=$(geoFenceElement).attr('data-stationeryTime'); $('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewStationeryAlert", function () { @@ -401,7 +401,7 @@ function viewFence(geoFenceElement,id) { $(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)"); }); - } else if(id=="WithIn"){ + } else if (id=="WithIn") { $('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewWithinAlert", function () { var popupTemplate = $('#templateLoader').find('#viewWithinAlert'); @@ -414,7 +414,7 @@ function viewFence(geoFenceElement,id) { // transparent the layer .leaflet-popup-content-wrapper $(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)"); }); - } else if(id=="Exit"){ + } else if (id=="Exit") { $('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewExitAlert", function () { var popupTemplate = $('#templateLoader').find('#viewExitAlert'); @@ -427,7 +427,7 @@ function viewFence(geoFenceElement,id) { // transparent the layer .leaflet-popup-content-wrapper $(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)"); }); - } else if(id=="Traffic"){ + } else if (id=="Traffic") { } closeAll(); } @@ -440,7 +440,7 @@ function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) { geoJson = JSON.parse(geoJson.replace(/'/g, '"')); var geometryShape; - if(geoJson.type=="Point"){ + if (geoJson.type=="Point") { var circleOptions = { color: '#ff0043' @@ -449,7 +449,7 @@ function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) { // var marker=new L.marker([geoJson.coordinates[1],geoJson.coordinates[0]]); map.addLayer(geometryShape); // map.addLayer(marker); - } else if(geoJson.type=="Polygon"){ + } else if (geoJson.type=="Polygon") { geoJson.coordinates[0].pop(); // popout the last coordinate set(lat,lng pair) due to circular chain var leafletLatLngs = []; $.each(geoJson.coordinates[0], function (idx, pItem) { @@ -461,7 +461,7 @@ function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) { var geoPublicUri = $("#geo-charts").data("geo-public-uri"); - if(id=="Stationery"){ + if (id=="Stationery") { $('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewStationeryAlert", function () { var popupTemplate = $('#templateLoader').find('#viewStationeryAlert'); @@ -473,7 +473,7 @@ function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) { $(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)"); }); - } else if(id=="WithIn"){ + } else if (id=="WithIn") { $('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewWithinAlert", function () { var popupTemplate = $('#templateLoader').find('#viewWithinAlert'); @@ -486,7 +486,7 @@ function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) { // transparent the layer .leaflet-popup-content-wrapper $(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)"); }); - } else if(id=="Exit"){ + } else if (id=="Exit") { $('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewExitAlert", function () { var popupTemplate = $('#templateLoader').find('#viewExitAlert'); @@ -499,7 +499,7 @@ function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) { // transparent the layer .leaflet-popup-content-wrapper $(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)"); }); - } else if(id=="Traffic"){ + } else if (id=="Traffic") { } closeAll(); } From 5cb6bc2afa2f53d26984120fa9d13760f88fbd91 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Mon, 18 Sep 2017 10:20:27 +0530 Subject: [PATCH 2/3] Fixing formatting issues --- .../app/units/cdmf.unit.device.view/public/css/main.css | 2 +- .../app/units/cdmf.unit.device.view/public/js/device-view.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/css/main.css b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/css/main.css index 2fbb99f134..c83dfff14e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/css/main.css +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/css/main.css @@ -141,7 +141,7 @@ margin: 0px; } .tab-actions { - margin: 0px; + margin: 0px; margin-bottom: 10px; } .tab-actions .action-prop{ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/js/device-view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/js/device-view.js index a7f393bc6a..cedfb8bdc9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/js/device-view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/js/device-view.js @@ -59,7 +59,7 @@ function getLogStatusIcon(entry) { case 'ERROR': return 'fw-error'; default: - return 'fw-info' + return 'fw-info'; } } @@ -203,7 +203,7 @@ function loadOperationsLog(update) { case 'ERROR': return 'fw-error'; default: - return 'fw-info' + return 'fw-info'; } } } @@ -306,7 +306,6 @@ function loadApplicationsList() { data[i]["name"] = decodeURIComponent(data[i]["name"]); data[i]["platform"] = deviceType; } - var viewModel = {}; viewModel["applications"] = data; viewModel["deviceType"] = deviceType; From b566d98ecfecd4e9009682fbf8b06cd35ca4c5d5 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Mon, 18 Sep 2017 10:57:51 +0530 Subject: [PATCH 3/3] Fixed formatting issues --- .../cdmf.unit.geo-dashboard/public/js/geo_fencing.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/geo_fencing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/geo_fencing.js index 37e2aba94e..8457e973e5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/geo_fencing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/geo_fencing.js @@ -65,8 +65,7 @@ function openTools(id) { } console.log("removed drawnItems"); } - - + closeAll(); noty({text: "Please draw the required area on the map", type: "information"}); @@ -107,7 +106,6 @@ function openTools(id) { removeAllControl = new L.Control.RemoveAll(); map.addControl(removeAllControl); - // Initialise the FeatureGroup to store editable layers drawnItems = new L.FeatureGroup(); map.addLayer(drawnItems); @@ -168,7 +166,6 @@ function openTools(id) { }); } else if(id=="Stationery"){ // Initialise the draw control and pass it the FeatureGroup of editable layers - drawControl = new L.Control.Draw({ draw: { polygon: { @@ -252,11 +249,7 @@ function openTools(id) { }); console.log("prediction tool opened"); } - map.addControl(drawControl); - - - } function createPopup(layer,id) { @@ -427,7 +420,6 @@ function viewFence(geoFenceElement,id) { // transparent the layer .leaflet-popup-content-wrapper $(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)"); }); - } else if (id=="Traffic") { } closeAll(); } @@ -499,7 +491,6 @@ function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) { // transparent the layer .leaflet-popup-content-wrapper $(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)"); }); - } else if (id=="Traffic") { } closeAll(); }