Adding temporary development code bits for dashboard analytics feature

revert-70aa11f8
dilanua 9 years ago
parent a0d260e6a3
commit c828a5264b

@ -30,58 +30,61 @@ import java.util.Map;
public interface GadgetDataService {
@SuppressWarnings("unused")
int getTotalDeviceCount();
int getTotalDeviceCount() throws GadgetDataServiceException;
@SuppressWarnings("unused")
int getActiveDeviceCount();
int getActiveDeviceCount() throws GadgetDataServiceException;
@SuppressWarnings("unused")
int getInactiveDeviceCount();
int getInactiveDeviceCount() throws GadgetDataServiceException;
@SuppressWarnings("unused")
int getRemovedDeviceCount();
int getRemovedDeviceCount() throws GadgetDataServiceException;
@SuppressWarnings("unused")
int getNonCompliantDeviceCount();
int getNonCompliantDeviceCount() throws GadgetDataServiceException;
@SuppressWarnings("unused")
int getUnmonitoredDeviceCount();
int getUnmonitoredDeviceCount() throws GadgetDataServiceException;
@SuppressWarnings("unused")
PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest);
PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest)
throws GadgetDataServiceException;
@SuppressWarnings("unused")
int getDeviceCount(Map<String, Object> filters);
int getDeviceCount(Map<String, Object> filters) throws GadgetDataServiceException;
@SuppressWarnings("unused")
int getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode, Map<String, Object> filters);
int getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode,
Map<String, Object> filters) throws GadgetDataServiceException;
@SuppressWarnings("unused")
Map<String, Integer> getDeviceCountsByPlatforms(Map<String, Object> filters);
Map<String, Integer> getDeviceCountsByPlatforms(Map<String, Object> filters) throws GadgetDataServiceException;
@SuppressWarnings("unused")
Map<String, Integer> getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode,
Map<String, Object> filters);
Map<String, Object> filters) throws GadgetDataServiceException;
@SuppressWarnings("unused")
Map<String, Integer> getDeviceCountsByOwnershipTypes(Map<String, Object> filters);
Map<String, Integer> getDeviceCountsByOwnershipTypes(Map<String, Object> filters) throws GadgetDataServiceException;
@SuppressWarnings("unused")
Map<String, Integer> getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode,
Map<String, Object> filters);
Map<String, Object> filters) throws GadgetDataServiceException;
@SuppressWarnings("unused")
PaginationResult getDevicesWithDetails(Map<String, Object> filters, PaginationRequest paginationRequest);
PaginationResult getDevicesWithDetails(Map<String, Object> filters,
PaginationRequest paginationRequest) throws GadgetDataServiceException;
@SuppressWarnings("unused")
PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
Map<String, Object> filters, PaginationRequest paginationRequest);
Map<String, Object> filters, PaginationRequest paginationRequest) throws GadgetDataServiceException;
@SuppressWarnings("unused")
List<Map<String, Object>> getDevicesWithDetails(Map<String, Object> filters);
List<Map<String, Object>> getDevicesWithDetails(Map<String, Object> filters) throws GadgetDataServiceException;
@SuppressWarnings("unused")
List<Map<String, Object>> getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
Map<String, Object> filters);
Map<String, Object> filters) throws GadgetDataServiceException;
}

@ -18,11 +18,11 @@
package org.wso2.carbon.device.mgt.analytics.dashboard.dao;
@SuppressWarnings("unused")
/**
* Custom exception class for data access related exceptions.
* Custom exception class for GadgetDataServiceDAO layer.
*/
public class GadgetDataServiceDAOException extends Exception {
private String errorMessage;
private static final long serialVersionUID = 2021891706072918864L;
@ -43,6 +43,7 @@ public class GadgetDataServiceDAOException extends Exception {
* @param errorMessage Specific error message.
* @param cause Cause of this exception.
*/
@SuppressWarnings("unused")
public GadgetDataServiceDAOException(String errorMessage, Throwable cause) {
super(errorMessage, cause);
setErrorMessage(errorMessage);
@ -53,6 +54,7 @@ public class GadgetDataServiceDAOException extends Exception {
*
* @param errorMessage Specific error message.
*/
@SuppressWarnings("unused")
public GadgetDataServiceDAOException(String errorMessage) {
super(errorMessage);
setErrorMessage(errorMessage);
@ -63,10 +65,12 @@ public class GadgetDataServiceDAOException extends Exception {
*
* @param cause Cause of this exception.
*/
@SuppressWarnings("unused")
public GadgetDataServiceDAOException(Throwable cause) {
super(cause);
}
@SuppressWarnings("unused")
public String getErrorMessage() {
return errorMessage;
}
@ -74,4 +78,5 @@ public class GadgetDataServiceDAOException extends Exception {
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}

@ -33,6 +33,7 @@ import java.util.List;
@SuppressWarnings("unused")
public class GadgetDataServiceDAOFactory {
private static final Log log = LogFactory.getLog(GadgetDataServiceDAOFactory.class);
private static DataSource dataSource;
private static String databaseEngine;
@ -47,7 +48,7 @@ public class GadgetDataServiceDAOFactory {
try {
databaseEngine = dataSource.getConnection().getMetaData().getDatabaseProductName();
} catch (SQLException e) {
log.error("Error occurred while retrieving config.datasource connection", e);
log.error("Error occurred while retrieving config.datasource connection.", e);
}
}
@ -56,7 +57,7 @@ public class GadgetDataServiceDAOFactory {
try {
databaseEngine = dataSource.getConnection().getMetaData().getDatabaseProductName();
} catch (SQLException e) {
log.error("Error occurred while retrieving config.datasource connection", e);
log.error("Error occurred while retrieving config.datasource connection.", e);
}
}
@ -65,7 +66,7 @@ public class GadgetDataServiceDAOFactory {
if (conn != null) {
throw new IllegalTransactionStateException("A transaction is already active within the context of " +
"this particular thread. Therefore, calling 'beginTransaction/openConnection' while another " +
"transaction is already active is a sign of improper transaction handling");
"transaction is already active is a sign of improper transaction handling.");
}
conn = dataSource.getConnection();
currentConnection.set(conn);
@ -76,7 +77,7 @@ public class GadgetDataServiceDAOFactory {
if (conn == null) {
throw new IllegalTransactionStateException("No connection is associated with the current transaction. " +
"This might have ideally been caused by not properly initiating the transaction via " +
"'beginTransaction'/'openConnection' methods");
"'beginTransaction'/'openConnection' methods.");
}
return conn;
}
@ -86,35 +87,34 @@ public class GadgetDataServiceDAOFactory {
if (conn == null) {
throw new IllegalTransactionStateException("No connection is associated with the current transaction. " +
"This might have ideally been caused by not properly initiating the transaction via " +
"'beginTransaction'/'openConnection' methods");
"'beginTransaction'/'openConnection' methods.");
}
try {
conn.close();
} catch (SQLException e) {
log.warn("Error occurred while close the connection");
log.warn("Error occurred while close the connection.");
}
currentConnection.remove();
}
/**
* Resolve data source from the data source definition
* Resolve data source from the data source definition.
*
* @param config data source configuration
* @return data source resolved from the data source definition
* @param config data source configuration.
* @return data source resolved from the data source definition.
*/
private static DataSource resolveDataSource(DataSourceConfig config) {
DataSource dataSource = null;
if (config == null) {
throw new RuntimeException(
"Device Management Repository data source configuration " + "is null and " +
"thus, is not initialized");
"thus, is not initialized.");
}
JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();
if (jndiConfig != null) {
if (log.isDebugEnabled()) {
log.debug("Initializing Device Management Repository data source using the JNDI " +
"Lookup Definition");
log.debug("Initializing Device Management Repository data source using the JNDI Lookup Definition.");
}
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList = jndiConfig.getJndiProperties();
if (jndiPropertyList != null) {

@ -18,8 +18,6 @@
package org.wso2.carbon.device.mgt.analytics.dashboard.dao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult;
@ -35,8 +33,6 @@ import java.util.List;
import java.util.Map;
class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
@SuppressWarnings("unused")
private static final Log log = LogFactory.getLog(GadgetDataServiceDAOImpl.class);
@Override
public int getTotalDeviceCount() throws GadgetDataServiceDAOException {
@ -72,7 +68,15 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
}
@Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest) throws GadgetDataServiceDAOException {
public int getUnmonitoredDeviceCount() throws GadgetDataServiceDAOException {
Map<String, Object> filters = new HashMap<>();
filters.put("POLICY_ID", -1);
return this.getDeviceCount(filters);
}
@Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest)
throws GadgetDataServiceDAOException {
Connection con;
PreparedStatement stmt = null;
ResultSet rs = null;
@ -112,7 +116,8 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
totalRecordsCount = rs.getInt("NON_COMPLIANT_FEATURE_COUNT");
}
} catch (SQLException e) {
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
throw new GadgetDataServiceDAOException("Error occurred @ GadgetDataServiceDAO layer while trying to " +
"execute relevant SQL queries for getting non compliant device counts by features.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -122,13 +127,6 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
return paginationResult;
}
@Override
public int getUnmonitoredDeviceCount() throws GadgetDataServiceDAOException {
Map<String, Object> filters = new HashMap<>();
filters.put("POLICY_ID", -1);
return this.getDeviceCount(filters);
}
public int getDeviceCount(Map<String, Object> filters) throws GadgetDataServiceDAOException {
Connection con;
PreparedStatement stmt = null;
@ -166,7 +164,8 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
filteredDeviceCount = rs.getInt("DEVICE_COUNT");
}
} catch (SQLException e) {
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
throw new GadgetDataServiceDAOException("Error occurred @ GadgetDataServiceDAO layer while trying to " +
"execute relevant SQL queries for getting a filtered device count.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -211,7 +210,9 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
filteredDeviceCount = rs.getInt("DEVICE_COUNT");
}
} catch (SQLException e) {
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
throw new GadgetDataServiceDAOException("Error occurred @ GadgetDataServiceDAO layer while trying to " +
"execute relevant SQL queries for getting a filtered device count, " +
"non compliant by a particular feature.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -257,7 +258,8 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
filteredDeviceCountsByPlatforms.put(rs.getString("PLATFORM"), rs.getInt("DEVICE_COUNT"));
}
} catch (SQLException e) {
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
throw new GadgetDataServiceDAOException("Error occurred @ GadgetDataServiceDAO layer while trying to " +
"execute relevant SQL queries for getting a filtered set of device counts by platforms.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -304,7 +306,8 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
filteredDeviceCountsByPlatforms.put(rs.getString("PLATFORM"), rs.getInt("DEVICE_COUNT"));
}
} catch (SQLException e) {
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
throw new GadgetDataServiceDAOException("Error occurred @ GadgetDataServiceDAO layer while trying to " +
"execute relevant SQL queries for getting a set of feature non-compliant device counts by platforms.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -350,7 +353,8 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
filteredDeviceCountsByOwnershipTypes.put(rs.getString("OWNERSHIP"), rs.getInt("DEVICE_COUNT"));
}
} catch (SQLException e) {
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
throw new GadgetDataServiceDAOException("Error occurred @ GadgetDataServiceDAO layer while trying to " +
"execute relevant SQL queries for getting a filtered set of device counts by ownership types.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -398,7 +402,9 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
filteredDeviceCountsByOwnershipTypes.put(rs.getString("OWNERSHIP"), rs.getInt("DEVICE_COUNT"));
}
} catch (SQLException e) {
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
throw new GadgetDataServiceDAOException("Error occurred @ GadgetDataServiceDAO layer while trying to " +
"execute relevant SQL queries for getting a filtered set of feature " +
"non-compliant device counts by ownership types.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -469,7 +475,9 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
totalRecordsCount = rs.getInt("DEVICE_COUNT");
}
} catch (SQLException e) {
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
throw new GadgetDataServiceDAOException("Error occurred @ GadgetDataServiceDAO layer while trying to " +
"execute relevant SQL queries for getting a filtered set of devices " +
"with details when pagination is enabled.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -546,7 +554,9 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
totalRecordsCount = rs.getInt("DEVICE_COUNT");
}
} catch (SQLException e) {
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
throw new GadgetDataServiceDAOException("Error occurred @ GadgetDataServiceDAO layer while trying to " +
"execute relevant SQL queries for getting a filtered set of feature non-compliant devices " +
"with details when pagination is enabled.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -600,7 +610,8 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
filteredDevicesWithDetails.add(filteredDeviceWithDetails);
}
} catch (SQLException e) {
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
throw new GadgetDataServiceDAOException("Error occurred @ GadgetDataServiceDAO layer while trying to " +
"execute relevant SQL queries for getting a filtered set of devices with details.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -654,7 +665,8 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
filteredDevicesWithDetails.add(filteredDeviceWithDetails);
}
} catch (SQLException e) {
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
throw new GadgetDataServiceDAOException("Error occurred @ GadgetDataServiceDAO layer while trying to " +
"execute relevant SQL queries for getting filtered set of feature non-compliant devices with details.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}

@ -39,6 +39,7 @@ import org.wso2.carbon.ndatasource.core.DataSourceService;
* unbind="unsetDataSourceService"
*/
public class GadgetDataServiceComponent {
private static final Log log = LogFactory.getLog(GadgetDataServiceComponent.class);
protected void activate(ComponentContext componentContext) {
@ -56,10 +57,10 @@ public class GadgetDataServiceComponent {
componentContext.getBundleContext().
registerService(GadgetDataService.class.getName(), new GadgetDataServiceImpl(), null);
if (log.isDebugEnabled()) {
log.debug("Device Management Dashboard Analytics Bundle has been started successfully");
log.debug("Device Management Dashboard Analytics Bundle has been started successfully.");
}
} catch (Throwable e) {
log.error("Error occurred while initializing the bundle", e);
log.error("Error occurred while initializing the bundle.", e);
}
}
@ -70,11 +71,18 @@ public class GadgetDataServiceComponent {
//do nothing
}
public void setDataSourceService(DataSourceService dataSourceService){
public void setDataSourceService(DataSourceService dataSourceService) {
if (log.isDebugEnabled()) {
log.debug("Binding org.wso2.carbon.ndatasource.core.DataSourceService...");
}
//do nothing
}
public void unsetDataSourceService(DataSourceService dataSourceService){
public void unsetDataSourceService(DataSourceService dataSourceService) {
if (log.isDebugEnabled()) {
log.debug("Unbinding org.wso2.carbon.ndatasource.core.DataSourceService...");
}
//do nothing
}
}

@ -18,9 +18,8 @@
package org.wso2.carbon.device.mgt.analytics.dashboard.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.analytics.dashboard.GadgetDataService;
import org.wso2.carbon.device.mgt.analytics.dashboard.GadgetDataServiceException;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAOException;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAOFactory;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
@ -35,18 +34,18 @@ import java.util.Map;
*/
class GadgetDataServiceImpl implements GadgetDataService {
@SuppressWarnings("unused")
private static final Log log = LogFactory.getLog(GadgetDataServiceImpl.class);
@Override
public int getTotalDeviceCount() {
public int getTotalDeviceCount() throws GadgetDataServiceException {
int totalDeviceCount;
try {
GadgetDataServiceDAOFactory.openConnection();
totalDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getTotalDeviceCount();
} catch (GadgetDataServiceDAOException | SQLException e) {
totalDeviceCount = -1;
return totalDeviceCount;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection.", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in calling DAO function for total device count.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -54,14 +53,17 @@ class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public int getActiveDeviceCount() {
public int getActiveDeviceCount() throws GadgetDataServiceException {
int activeDeviceCount;
try {
GadgetDataServiceDAOFactory.openConnection();
activeDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getActiveDeviceCount();
} catch (GadgetDataServiceDAOException | SQLException e) {
activeDeviceCount = -1;
return activeDeviceCount;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection.", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in calling DAO function for active device count.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -69,14 +71,17 @@ class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public int getInactiveDeviceCount() {
public int getInactiveDeviceCount() throws GadgetDataServiceException {
int inactiveDeviceCount;
try {
GadgetDataServiceDAOFactory.openConnection();
inactiveDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getInactiveDeviceCount();
} catch (GadgetDataServiceDAOException | SQLException e) {
inactiveDeviceCount = -1;
return inactiveDeviceCount;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection.", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in calling DAO function for inactive device count.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -84,14 +89,17 @@ class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public int getRemovedDeviceCount() {
public int getRemovedDeviceCount() throws GadgetDataServiceException {
int removedDeviceCount;
try {
GadgetDataServiceDAOFactory.openConnection();
removedDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getRemovedDeviceCount();
} catch (GadgetDataServiceDAOException | SQLException e) {
removedDeviceCount = -1;
return removedDeviceCount;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection.", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in calling DAO function for removed device count.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -99,14 +107,17 @@ class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public int getNonCompliantDeviceCount() {
public int getNonCompliantDeviceCount() throws GadgetDataServiceException {
int nonCompliantDeviceCount;
try {
GadgetDataServiceDAOFactory.openConnection();
nonCompliantDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getNonCompliantDeviceCount();
} catch (GadgetDataServiceDAOException | SQLException e) {
nonCompliantDeviceCount = -1;
return nonCompliantDeviceCount;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection.", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in calling DAO function for non-compliant device count.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -114,14 +125,17 @@ class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public int getUnmonitoredDeviceCount() {
public int getUnmonitoredDeviceCount() throws GadgetDataServiceException {
int unmonitoredDeviceCount;
try {
GadgetDataServiceDAOFactory.openConnection();
unmonitoredDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getUnmonitoredDeviceCount();
} catch (GadgetDataServiceDAOException | SQLException e) {
unmonitoredDeviceCount = -1;
return unmonitoredDeviceCount;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection.", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in calling DAO function for unmonitored device count.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -129,14 +143,19 @@ class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest) {
PaginationResult paginationResult = null;
public PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest)
throws GadgetDataServiceException {
PaginationResult paginationResult;
try {
GadgetDataServiceDAOFactory.openConnection();
paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getNonCompliantDeviceCountsByFeatures(paginationRequest);
} catch (GadgetDataServiceDAOException | SQLException e) {
return null;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection.", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer in calling DAO function " +
"for non-compliant device counts by features.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -144,14 +163,17 @@ class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public int getDeviceCount(Map<String, Object> filters) {
public int getDeviceCount(Map<String, Object> filters) throws GadgetDataServiceException {
int deviceCount;
try {
GadgetDataServiceDAOFactory.openConnection();
deviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getDeviceCount(filters);
} catch (GadgetDataServiceDAOException | SQLException e) {
deviceCount = -1;
return deviceCount;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection.", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in calling DAO function for getting a filtered device count.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -159,15 +181,19 @@ class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public int getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode, Map<String, Object> filters) {
public int getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode, Map<String, Object> filters)
throws GadgetDataServiceException {
int featureNonCompliantDeviceCount;
try {
GadgetDataServiceDAOFactory.openConnection();
featureNonCompliantDeviceCount = GadgetDataServiceDAOFactory.
getGadgetDataServiceDAO().getFeatureNonCompliantDeviceCount(nonCompliantFeatureCode, filters);
} catch (GadgetDataServiceDAOException | SQLException e) {
featureNonCompliantDeviceCount = -1;
return featureNonCompliantDeviceCount;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection.", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer in calling DAO function " +
"for getting a filtered device count, non compliant by a particular feature.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -175,14 +201,19 @@ class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public Map<String, Integer> getDeviceCountsByPlatforms(Map<String, Object> filters) {
Map<String, Integer> deviceCountsByPlatforms = null;
public Map<String, Integer> getDeviceCountsByPlatforms(Map<String, Object> filters)
throws GadgetDataServiceException {
Map<String, Integer> deviceCountsByPlatforms;
try {
GadgetDataServiceDAOFactory.openConnection();
deviceCountsByPlatforms = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getDeviceCountsByPlatforms(filters);
} catch (GadgetDataServiceDAOException | SQLException e) {
return null;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection.", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer in calling DAO function " +
"for getting filtered device counts by platforms.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -191,14 +222,18 @@ class GadgetDataServiceImpl implements GadgetDataService {
@Override
public Map<String, Integer> getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode,
Map<String, Object> filters) {
Map<String, Integer> featureNonCompliantDeviceCountsByPlatforms = null;
Map<String, Object> filters) throws GadgetDataServiceException {
Map<String, Integer> featureNonCompliantDeviceCountsByPlatforms;
try {
GadgetDataServiceDAOFactory.openConnection();
featureNonCompliantDeviceCountsByPlatforms = GadgetDataServiceDAOFactory.
getGadgetDataServiceDAO().getFeatureNonCompliantDeviceCountsByPlatforms(nonCompliantFeatureCode, filters);
} catch (GadgetDataServiceDAOException | SQLException e) {
return null;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection.", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer in calling DAO function " +
"for getting filtered device counts by platforms, non compliant by a particular feature.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -206,14 +241,19 @@ class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public Map<String, Integer> getDeviceCountsByOwnershipTypes(Map<String, Object> filters) {
Map<String, Integer> deviceCountsByOwnershipTypes = null;
public Map<String, Integer> getDeviceCountsByOwnershipTypes(Map<String, Object> filters)
throws GadgetDataServiceException {
Map<String, Integer> deviceCountsByOwnershipTypes;
try {
GadgetDataServiceDAOFactory.openConnection();
deviceCountsByOwnershipTypes = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getDeviceCountsByOwnershipTypes(filters);
} catch (GadgetDataServiceDAOException | SQLException e) {
return null;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection.", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer in calling DAO function " +
"for getting filtered device counts by ownership types.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -222,15 +262,19 @@ class GadgetDataServiceImpl implements GadgetDataService {
@Override
public Map<String, Integer> getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode,
Map<String, Object> filters) {
Map<String, Integer> featureNonCompliantDeviceCountsByOwnershipTypes = null;
Map<String, Object> filters) throws GadgetDataServiceException {
Map<String, Integer> featureNonCompliantDeviceCountsByOwnershipTypes;
try {
GadgetDataServiceDAOFactory.openConnection();
featureNonCompliantDeviceCountsByOwnershipTypes =
GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getFeatureNonCompliantDeviceCountsByOwnershipTypes(nonCompliantFeatureCode, filters);
} catch (GadgetDataServiceDAOException | SQLException e) {
return null;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection.", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer in calling DAO function " +
"for getting filtered device counts by ownership types, non compliant by a particular feature.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -238,14 +282,19 @@ class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public PaginationResult getDevicesWithDetails(Map<String, Object> filters, PaginationRequest paginationRequest) {
PaginationResult paginationResult = null;
public PaginationResult getDevicesWithDetails(Map<String, Object> filters,
PaginationRequest paginationRequest) throws GadgetDataServiceException {
PaginationResult paginationResult;
try {
GadgetDataServiceDAOFactory.openConnection();
paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getDevicesWithDetails(filters, paginationRequest);
} catch (GadgetDataServiceDAOException | SQLException e) {
return null;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer in calling DAO function " +
"for getting filtered devices with details when pagination is enabled.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -254,14 +303,18 @@ class GadgetDataServiceImpl implements GadgetDataService {
@Override
public PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
Map<String, Object> filters, PaginationRequest paginationRequest) {
PaginationResult paginationResult = null;
Map<String, Object> filters, PaginationRequest paginationRequest) throws GadgetDataServiceException {
PaginationResult paginationResult;
try {
GadgetDataServiceDAOFactory.openConnection();
paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, filters, paginationRequest);
} catch (GadgetDataServiceDAOException | SQLException e) {
return null;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer in calling DAO function " +
"for getting filtered devices with details, non compliant by feature when pagination is enabled.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -269,13 +322,18 @@ class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public List<Map<String, Object>> getDevicesWithDetails(Map<String, Object> filters) {
List<Map<String, Object>> devicesWithDetails = null;
public List<Map<String, Object>> getDevicesWithDetails(Map<String, Object> filters)
throws GadgetDataServiceException {
List<Map<String, Object>> devicesWithDetails;
try {
GadgetDataServiceDAOFactory.openConnection();
devicesWithDetails = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getDevicesWithDetails(filters);
} catch (GadgetDataServiceDAOException | SQLException e) {
return null;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer in calling DAO function " +
"for getting filtered devices with details.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -284,14 +342,18 @@ class GadgetDataServiceImpl implements GadgetDataService {
@Override
public List<Map<String, Object>> getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
Map<String, Object> filters) {
List<Map<String, Object>> featureNonCompliantDevicesWithDetails = null;
Map<String, Object> filters) throws GadgetDataServiceException {
List<Map<String, Object>> featureNonCompliantDevicesWithDetails;
try {
GadgetDataServiceDAOFactory.openConnection();
featureNonCompliantDevicesWithDetails = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, filters);
} catch (GadgetDataServiceDAOException | SQLException e) {
return null;
} catch (SQLException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer " +
"in opening database connection", e);
} catch (GadgetDataServiceDAOException e) {
throw new GadgetDataServiceException("Error occurred @ GadgetDataService layer in calling DAO function " +
"for getting filtered devices with details, non compliant by feature.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}

Loading…
Cancel
Save