Adding temporary development code bits for dashboard analytics feature

revert-70aa11f8
dilanua 9 years ago
parent 945e188917
commit d568c6e8bd

@ -19,7 +19,6 @@
package org.wso2.carbon.device.mgt.analytics.dashboard; package org.wso2.carbon.device.mgt.analytics.dashboard;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.InvalidParameterException; import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.InvalidParameterException;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.PaginationResult;
import java.sql.SQLException; import java.sql.SQLException;
@ -50,7 +49,7 @@ public interface GadgetDataService {
int getUnmonitoredDeviceCount() throws SQLException; int getUnmonitoredDeviceCount() throws SQLException;
@SuppressWarnings("unused") @SuppressWarnings("unused")
PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest) PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
throws InvalidParameterException, SQLException; throws InvalidParameterException, SQLException;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -76,11 +75,11 @@ public interface GadgetDataService {
@SuppressWarnings("unused") @SuppressWarnings("unused")
PaginationResult getDevicesWithDetails(Map<String, Object> filters, PaginationResult getDevicesWithDetails(Map<String, Object> filters,
PaginationRequest paginationRequest) throws InvalidParameterException, SQLException; int startIndex, int resultCount) throws InvalidParameterException, SQLException;
@SuppressWarnings("unused") @SuppressWarnings("unused")
PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode, PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
Map<String, Object> filters, PaginationRequest paginationRequest) Map<String, Object> filters, int startIndex, int resultCount)
throws InvalidParameterException, SQLException; throws InvalidParameterException, SQLException;
@SuppressWarnings("unused") @SuppressWarnings("unused")

@ -19,7 +19,6 @@
package org.wso2.carbon.device.mgt.analytics.dashboard.dao; package org.wso2.carbon.device.mgt.analytics.dashboard.dao;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.InvalidParameterException; import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.InvalidParameterException;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.PaginationResult;
import java.sql.SQLException; import java.sql.SQLException;
@ -70,7 +69,7 @@ public interface GadgetDataServiceDAO {
*/ */
int getUnmonitoredDeviceCount() throws SQLException; int getUnmonitoredDeviceCount() throws SQLException;
PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest) PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
throws InvalidParameterException, SQLException; throws InvalidParameterException, SQLException;
int getDeviceCount(Map<String, Object> filters) throws SQLException; int getDeviceCount(Map<String, Object> filters) throws SQLException;
@ -89,10 +88,10 @@ public interface GadgetDataServiceDAO {
Map<String, Object> filters) throws InvalidParameterException, SQLException; Map<String, Object> filters) throws InvalidParameterException, SQLException;
PaginationResult getDevicesWithDetails(Map<String, Object> filters, PaginationResult getDevicesWithDetails(Map<String, Object> filters,
PaginationRequest paginationRequest) throws InvalidParameterException, SQLException; int startIndex, int resultCount) throws InvalidParameterException, SQLException;
PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode, PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
Map<String, Object> filters, PaginationRequest paginationRequest) Map<String, Object> filters, int startIndex, int resultCount)
throws InvalidParameterException, SQLException; throws InvalidParameterException, SQLException;
List<Map<String, Object>> getDevicesWithDetails(Map<String, Object> filters) throws SQLException; List<Map<String, Object>> getDevicesWithDetails(Map<String, Object> filters) throws SQLException;

@ -22,7 +22,6 @@ import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAO; import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAO;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAOFactory; import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAOFactory;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.InvalidParameterException; import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.InvalidParameterException;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
@ -78,21 +77,17 @@ public class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
} }
@Override @Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest) public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
throws InvalidParameterException, SQLException { throws InvalidParameterException, SQLException {
if (paginationRequest == null) { if (startIndex < 0) {
throw new InvalidParameterException("PaginationRequest object should not be null."); throw new InvalidParameterException("Start index (startIndex) should be " +
"equal to 0 or greater than that.");
} }
if (paginationRequest.getStartIndex() < 0) { if (resultCount < 5) {
throw new InvalidParameterException("startIndex of PaginationRequest object " + throw new InvalidParameterException("Result count (resultCount) should be " +
"should be equal to 0 or greater than that."); "equal to 5 or greater than that.");
}
if (paginationRequest.getRowCount() < 5) {
throw new InvalidParameterException("rowCount of PaginationRequest object " +
"should be equal to 5 or greater than that.");
} }
Connection con; Connection con;
@ -107,8 +102,8 @@ public class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
"WHERE TENANT_ID = ? GROUP BY FEATURE_CODE ORDER BY DEVICE_COUNT DESC LIMIT ?, ?"; "WHERE TENANT_ID = ? GROUP BY FEATURE_CODE ORDER BY DEVICE_COUNT DESC LIMIT ?, ?";
stmt = con.prepareStatement(sql); stmt = con.prepareStatement(sql);
stmt.setInt(1, tenantId); stmt.setInt(1, tenantId);
stmt.setInt(2, paginationRequest.getStartIndex()); stmt.setInt(2, startIndex);
stmt.setInt(3, paginationRequest.getRowCount()); stmt.setInt(3, resultCount);
// executing query // executing query
rs = stmt.executeQuery(); rs = stmt.executeQuery();
@ -281,7 +276,8 @@ public class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
Map<String, Object> filters) throws InvalidParameterException, SQLException { Map<String, Object> filters) throws InvalidParameterException, SQLException {
if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) { if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) {
throw new InvalidParameterException("nonCompliantFeatureCode should not be either null or empty."); throw new InvalidParameterException("Non-compliant feature code (nonCompliantFeatureCode) " +
"should not be either null or empty.");
} }
Connection con; Connection con;
@ -376,7 +372,8 @@ public class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
Map<String, Object> filters) throws InvalidParameterException, SQLException { Map<String, Object> filters) throws InvalidParameterException, SQLException {
if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) { if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) {
throw new InvalidParameterException("nonCompliantFeatureCode should not be either null or empty."); throw new InvalidParameterException("Non-compliant feature code (nonCompliantFeatureCode) " +
"should not be either null or empty.");
} }
Connection con; Connection con;
@ -424,20 +421,16 @@ public class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
} }
public PaginationResult getDevicesWithDetails(Map<String, Object> filters, public PaginationResult getDevicesWithDetails(Map<String, Object> filters,
PaginationRequest paginationRequest) throws InvalidParameterException, SQLException { int startIndex, int resultCount) throws InvalidParameterException, SQLException {
if (paginationRequest == null) {
throw new InvalidParameterException("PaginationRequest object should not be null.");
}
if (paginationRequest.getStartIndex() < 0) { if (startIndex < 0) {
throw new InvalidParameterException("startIndex of PaginationRequest object " + throw new InvalidParameterException("Start index (startIndex) should be " +
"should be equal to 0 or greater than that."); "equal to 0 or greater than that.");
} }
if (paginationRequest.getRowCount() < 5) { if (resultCount < 5) {
throw new InvalidParameterException("rowCount of PaginationRequest object " + throw new InvalidParameterException("Result count (resultCount) should be " +
"should be equal to 5 or greater than that."); "equal to 5 or greater than that.");
} }
Connection con; Connection con;
@ -471,11 +464,11 @@ public class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
} }
i++; i++;
} }
stmt.setInt(i, paginationRequest.getStartIndex()); stmt.setInt(i, startIndex);
stmt.setInt(++i, paginationRequest.getRowCount()); stmt.setInt(++i, resultCount);
} else { } else {
stmt.setInt(2, paginationRequest.getStartIndex()); stmt.setInt(2, startIndex);
stmt.setInt(3, paginationRequest.getRowCount()); stmt.setInt(3, resultCount);
} }
// executing query // executing query
rs = stmt.executeQuery(); rs = stmt.executeQuery();
@ -511,25 +504,22 @@ public class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
} }
public PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode, public PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
Map<String, Object> filters, PaginationRequest paginationRequest) Map<String, Object> filters, int startIndex, int resultCount)
throws InvalidParameterException, SQLException { throws InvalidParameterException, SQLException {
if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) { if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) {
throw new InvalidParameterException("nonCompliantFeatureCode should not be either null or empty."); throw new InvalidParameterException("Non-compliant feature code (nonCompliantFeatureCode) " +
"should not be either null or empty.");
} }
if (paginationRequest == null) { if (startIndex < 0) {
throw new InvalidParameterException("PaginationRequest object should not be null."); throw new InvalidParameterException("Start index (startIndex) should be " +
"equal to 0 or greater than that.");
} }
if (paginationRequest.getStartIndex() < 0) { if (resultCount < 5) {
throw new InvalidParameterException("startIndex of PaginationRequest object " + throw new InvalidParameterException("Result count (resultCount) should be " +
"should be equal to 0 or greater than that."); "equal to 5 or greater than that.");
}
if (paginationRequest.getRowCount() < 5) {
throw new InvalidParameterException("rowCount of PaginationRequest object " +
"should be equal to 5 or greater than that.");
} }
Connection con; Connection con;
@ -564,11 +554,11 @@ public class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
} }
i++; i++;
} }
stmt.setInt(i, paginationRequest.getStartIndex()); stmt.setInt(i, startIndex);
stmt.setInt(++i, paginationRequest.getRowCount()); stmt.setInt(++i, resultCount);
} else { } else {
stmt.setInt(3, paginationRequest.getStartIndex()); stmt.setInt(3, startIndex);
stmt.setInt(4, paginationRequest.getRowCount()); stmt.setInt(4, resultCount);
} }
// executing query // executing query
rs = stmt.executeQuery(); rs = stmt.executeQuery();
@ -658,7 +648,8 @@ public class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
Map<String, Object> filters) throws InvalidParameterException, SQLException { Map<String, Object> filters) throws InvalidParameterException, SQLException {
if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) { if (nonCompliantFeatureCode == null || "".equals(nonCompliantFeatureCode)) {
throw new InvalidParameterException("nonCompliantFeatureCode should not be either null or empty."); throw new InvalidParameterException("Non-compliant feature code (nonCompliantFeatureCode) " +
"should not be either null or empty.");
} }
Connection con; Connection con;

@ -107,13 +107,13 @@ public class GadgetDataServiceImpl implements GadgetDataService {
} }
@Override @Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(PaginationRequest paginationRequest) public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
throws SQLException, InvalidParameterException { throws SQLException, InvalidParameterException {
PaginationResult paginationResult; PaginationResult paginationResult;
try { try {
GadgetDataServiceDAOFactory.openConnection(); GadgetDataServiceDAOFactory.openConnection();
paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getNonCompliantDeviceCountsByFeatures(paginationRequest); getNonCompliantDeviceCountsByFeatures(startIndex, resultCount);
} finally { } finally {
GadgetDataServiceDAOFactory.closeConnection(); GadgetDataServiceDAOFactory.closeConnection();
} }
@ -202,12 +202,12 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override @Override
public PaginationResult getDevicesWithDetails(Map<String, Object> filters, public PaginationResult getDevicesWithDetails(Map<String, Object> filters,
PaginationRequest paginationRequest) throws InvalidParameterException, SQLException { int startIndex, int resultCount) throws InvalidParameterException, SQLException {
PaginationResult paginationResult; PaginationResult paginationResult;
try { try {
GadgetDataServiceDAOFactory.openConnection(); GadgetDataServiceDAOFactory.openConnection();
paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getDevicesWithDetails(filters, paginationRequest); getDevicesWithDetails(filters, startIndex, resultCount);
} finally { } finally {
GadgetDataServiceDAOFactory.closeConnection(); GadgetDataServiceDAOFactory.closeConnection();
} }
@ -216,13 +216,13 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override @Override
public PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode, public PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
Map<String, Object> filters, PaginationRequest paginationRequest) Map<String, Object> filters, int startIndex, int resultCount)
throws InvalidParameterException, SQLException { throws InvalidParameterException, SQLException {
PaginationResult paginationResult; PaginationResult paginationResult;
try { try {
GadgetDataServiceDAOFactory.openConnection(); GadgetDataServiceDAOFactory.openConnection();
paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, filters, paginationRequest); getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, filters, startIndex, resultCount);
} finally { } finally {
GadgetDataServiceDAOFactory.closeConnection(); GadgetDataServiceDAOFactory.closeConnection();
} }

Loading…
Cancel
Save