diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/GadgetDataService.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/GadgetDataService.java index bfaa2d38ff6..6cd23d2727e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/GadgetDataService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/GadgetDataService.java @@ -28,60 +28,219 @@ import org.wso2.carbon.device.mgt.common.PaginationResult; import java.util.List; /** - * To be updated... + * This interface exposes useful service layer functions to retrieve data + * required by high level dashboard APIs. */ public interface GadgetDataService { + /** + * This method is used to get a count of devices based on a defined filter set. + * @param filterSet An abstract representation of possible filtering options. + * if this value is simply "null" or no values are set for the defined filtering options, + * this method would return total device count in the system + * wrapped with in the defined return format. + * @return An object of type DeviceCountByGroupEntry. + * @throws InvalidParameterValueException This can occur if and only if potentialVulnerability value of filterSet + * is set with some value other than "NON_COMPLIANT" or "UNMONITORED". + * @throws DataAccessLayerException This can occur due to errors connecting to database, + * executing SQL query and retrieving data. + */ @SuppressWarnings("unused") DeviceCountByGroupEntry getDeviceCount(FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException; + /** + * This method is used to get a count of devices non-compliant upon on a particular feature + * and a defined filter set. + * @param nonCompliantFeatureCode Code name of the non-compliant feature. + * @param filterSet An abstract representation of possible filtering options. + * if this value is simply "null" or no values are set for the defined filtering options, + * this method would return total device count in the system + * wrapped with in the defined return format. + * @return An object of type DeviceCountByGroupEntry. + * @throws InvalidParameterValueException This can occur if and only if potentialVulnerability value of filterSet + * is set with some value other than "NON_COMPLIANT" or "UNMONITORED". + * @throws DataAccessLayerException This can occur due to errors connecting to database, + * executing SQL query and retrieving data. + */ @SuppressWarnings("unused") DeviceCountByGroupEntry getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode, FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException; + /** + * This method is used to get total count of devices currently enrolled under a particular tenant. + * @return An object of type DeviceCountByGroupEntry. + * @throws DataAccessLayerException This can occur due to errors connecting to database, + * executing SQL query and retrieving data. + */ @SuppressWarnings("unused") DeviceCountByGroupEntry getTotalDeviceCount() throws DataAccessLayerException; + /** + * This method is used to get device counts classified by connectivity statuses. + * @return A list of objects of type DeviceCountByGroupEntry. + * @throws DataAccessLayerException This can occur due to errors connecting to database, + * executing SQL query and retrieving data. + */ @SuppressWarnings("unused") List getDeviceCountsByConnectivityStatuses() throws DataAccessLayerException; + /** + * This method is used to get device counts classified by potential vulnerabilities. + * @return A list of objects of type DeviceCountByGroupEntry. + * @throws DataAccessLayerException This can occur due to errors connecting to database, + * executing SQL query and retrieving data. + */ @SuppressWarnings("unused") List getDeviceCountsByPotentialVulnerabilities() throws DataAccessLayerException; + /** + * This method is used to get non-compliant device counts classified by individual features. + * @param startIndex Starting index of the data set to be retrieved. + * @param resultCount Total count of the result set retrieved. + * @return An object of type PaginationResult. + * @throws InvalidParameterValueException This can occur if and only if potentialVulnerability value of filterSet + * is set with some value other than "NON_COMPLIANT" or "UNMONITORED". + * @throws DataAccessLayerException This can occur due to errors connecting to database, + * executing SQL query and retrieving data. + */ @SuppressWarnings("unused") PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount) throws InvalidParameterValueException, DataAccessLayerException; + /** + * This method is used to get device counts classified by platforms. + * @param filterSet An abstract representation of possible filtering options. + * if this value is simply "null" or no values are set for the defined filtering options, + * this method would return total device count in the system + * wrapped with in the defined return format. + * @return An object of type DeviceCountByGroupEntry. + * @throws InvalidParameterValueException This can occur if and only if potentialVulnerability value of filterSet + * is set with some value other than "NON_COMPLIANT" or "UNMONITORED". + * @throws DataAccessLayerException This can occur due to errors connecting to database, + * executing SQL query and retrieving data. + */ @SuppressWarnings("unused") List getDeviceCountsByPlatforms(FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException; + /** + * This method is used to get device counts non-compliant upon a particular feature classified by platforms. + * @param nonCompliantFeatureCode Code name of the non-compliant feature. + * @param filterSet An abstract representation of possible filtering options. + * if this value is simply "null" or no values are set for the defined filtering options, + * this method would return total device count in the system + * wrapped with in the defined return format. + * @return A list of objects of type DeviceCountByGroupEntry. + * @throws InvalidParameterValueException This can occur if and only if potentialVulnerability value of filterSet + * is set with some value other than "NON_COMPLIANT" or "UNMONITORED". + * @throws DataAccessLayerException This can occur due to errors connecting to database, + * executing SQL query and retrieving data. + */ @SuppressWarnings("unused") List getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode, FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException; + /** + * This method is used to get device counts classified by ownership types. + * @param filterSet An abstract representation of possible filtering options. + * if this value is simply "null" or no values are set for the defined filtering options, + * this method would return total device count in the system + * wrapped with in the defined return format. + * @return A list of objects of type DeviceCountByGroupEntry. + * @throws InvalidParameterValueException This can occur if and only if potentialVulnerability value of filterSet + * is set with some value other than "NON_COMPLIANT" or "UNMONITORED". + * @throws DataAccessLayerException This can occur due to errors connecting to database, + * executing SQL query and retrieving data. + */ @SuppressWarnings("unused") List getDeviceCountsByOwnershipTypes(FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException; + /** + * This method is used to get device counts non-compliant upon a particular feature classified by ownership types. + * @param nonCompliantFeatureCode Code name of the non-compliant feature. + * @param filterSet An abstract representation of possible filtering options. + * if this value is simply "null" or no values are set for the defined filtering options, + * this method would return total device count in the system + * wrapped with in the defined return format. + * @return A list of objects of type DeviceCountByGroupEntry. + * @throws InvalidParameterValueException This can occur if and only if potentialVulnerability value of filterSet + * is set with some value other than "NON_COMPLIANT" or "UNMONITORED". + * @throws DataAccessLayerException This can occur due to errors connecting to database, + * executing SQL query and retrieving data. + */ @SuppressWarnings("unused") List getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode, FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException; + /** + * This method is used to get a paginated list of devices with details, based on a defined filter set. + * @param filterSet An abstract representation of possible filtering options. + * if this value is simply "null" or no values are set for the defined filtering options, + * this method would return total device count in the system + * wrapped with in the defined return format. + * @param startIndex Starting index of the data set to be retrieved. + * @param resultCount Total count of the result set retrieved. + * @return An object of type PaginationResult. + * @throws InvalidParameterValueException This can occur if and only if potentialVulnerability value of filterSet + * is set with some value other than "NON_COMPLIANT" or "UNMONITORED". + * @throws DataAccessLayerException This can occur due to errors connecting to database, + * executing SQL query and retrieving data. + */ @SuppressWarnings("unused") PaginationResult getDevicesWithDetails(FilterSet filterSet, int startIndex, int resultCount) throws InvalidParameterValueException, DataAccessLayerException; + /** + * This method is used to get a paginated list of non-compliant devices with details, upon a particular feature. + * @param nonCompliantFeatureCode Code name of the non-compliant feature. + * @param filterSet An abstract representation of possible filtering options. + * if this value is simply "null" or no values are set for the defined filtering options, + * this method would return total device count in the system + * wrapped with in the defined return format. + * @param startIndex Starting index of the data set to be retrieved. + * @param resultCount Total count of the result set retrieved. + * @return An object of type PaginationResult. + * @throws InvalidParameterValueException This can occur if and only if potentialVulnerability value of filterSet + * is set with some value other than "NON_COMPLIANT" or "UNMONITORED". + * @throws DataAccessLayerException This can occur due to errors connecting to database, + * executing SQL query and retrieving data. + */ @SuppressWarnings("unused") PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode, FilterSet filterSet, int startIndex, int resultCount) throws InvalidParameterValueException, DataAccessLayerException; + /** + * This method is used to get a list of devices with details, based on a defined filter set. + * @param filterSet An abstract representation of possible filtering options. + * if this value is simply "null" or no values are set for the defined filtering options, + * this method would return total device count in the system + * wrapped with in the defined return format. + * @return A list of objects of type DetailedDeviceEntry. + * @throws InvalidParameterValueException This can occur if and only if potentialVulnerability value of filterSet + * is set with some value other than "NON_COMPLIANT" or "UNMONITORED". + * @throws DataAccessLayerException This can occur due to errors connecting to database, + * executing SQL query and retrieving data. + */ @SuppressWarnings("unused") List getDevicesWithDetails(FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException; + /** + * This method is used to get a list of non-compliant devices with details, upon a particular feature. + * @param nonCompliantFeatureCode Code name of the non-compliant feature. + * @param filterSet An abstract representation of possible filtering options. + * if this value is simply "null" or no values are set for the defined filtering options, + * this method would return total device count in the system + * wrapped with in the defined return format. + * @return A list of objects of type DetailedDeviceEntry. + * @throws InvalidParameterValueException This can occur if and only if potentialVulnerability value of filterSet + * is set with some value other than "NON_COMPLIANT" or "UNMONITORED". + * @throws DataAccessLayerException This can occur due to errors connecting to database, + * executing SQL query and retrieving data. + */ @SuppressWarnings("unused") List getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode, FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAO.java index 77fb489f50d..9bb3b26b325 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAO.java @@ -29,18 +29,6 @@ import java.util.List; public interface GadgetDataServiceDAO { - /** - * This method is used to get device count based on a defined filter set. - * @param filterSet An abstract representation of possible filtering options. - * if this value is simply "null" or no values are set for the defined filtering options, - * this method would return total device count in the system - * wrapped with in the defined return format. - * @return An object of type DeviceCountByGroupEntry. - * @throws InvalidParameterValueException This can occur if and only if potentialVulnerability value of filterSet - * is set with some value other than "NON_COMPLIANT" or "UNMONITORED". - * @throws DataAccessLayerException This can occur due to errors connecting to database, - * executing SQL query and retrieving data. - */ DeviceCountByGroupEntry getDeviceCount(FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAOConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAOConstants.java index 927d4b7ad18..bbaf5d657ae 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAOConstants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAOConstants.java @@ -31,6 +31,18 @@ public final class GadgetDataServiceDAOConstants { } + public static class Pagination { + + // Minimum acceptable values for start index and result count + public static final int MIN_START_INDEX = 0; + public static final int MIN_RESULT_COUNT = 5; + + private Pagination() { + throw new AssertionError(); + } + + } + public static class PotentialVulnerability { // These constants do not hold actual database values diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GenericGadgetDataServiceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GenericGadgetDataServiceDAOImpl.java index 1885dfd79f9..de4eb05faec 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GenericGadgetDataServiceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GenericGadgetDataServiceDAOImpl.java @@ -43,12 +43,14 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount) throws InvalidParameterValueException, DataAccessLayerException { - if (startIndex < 0) { - throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that."); + if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { + throw new InvalidParameterValueException("Start index should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX + " or greater than that."); } - if (resultCount < 5) { - throw new InvalidParameterValueException("Result count should be equal to 5 or greater than that."); + if (resultCount < GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT) { + throw new InvalidParameterValueException("Result count should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT + " or greater than that."); } Connection con; @@ -108,12 +110,14 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA public PaginationResult getDevicesWithDetails(FilterSet filterSet, int startIndex, int resultCount) throws InvalidParameterValueException, DataAccessLayerException { - if (startIndex < 0) { - throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that."); + if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { + throw new InvalidParameterValueException("Start index should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX + " or greater than that."); } - if (resultCount < 5) { - throw new InvalidParameterValueException("Result count should be equal to 5 or greater than that."); + if (resultCount < GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT) { + throw new InvalidParameterValueException("Result count should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT + " or greater than that."); } Map filters = this.extractDatabaseFiltersFromBean(filterSet); @@ -204,12 +208,14 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty."); } - if (startIndex < 0) { - throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that."); + if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { + throw new InvalidParameterValueException("Start index should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX + " or greater than that."); } - if (resultCount < 5) { - throw new InvalidParameterValueException("Result count should be equal to 5 or greater than that."); + if (resultCount < GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT) { + throw new InvalidParameterValueException("Result count should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT + " or greater than that."); } Map filters = this.extractDatabaseFiltersFromBean(filterSet); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/MSSQLGadgetDataServiceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/MSSQLGadgetDataServiceDAOImpl.java index 90163baddad..97e8c48cc23 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/MSSQLGadgetDataServiceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/MSSQLGadgetDataServiceDAOImpl.java @@ -43,12 +43,14 @@ public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount) throws InvalidParameterValueException, DataAccessLayerException { - if (startIndex < 0) { - throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that."); + if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { + throw new InvalidParameterValueException("Start index should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX + " or greater than that."); } - if (resultCount < 5) { - throw new InvalidParameterValueException("Result count should be equal to 5 or greater than that."); + if (resultCount < GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT) { + throw new InvalidParameterValueException("Result count should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT + " or greater than that."); } Connection con; @@ -108,12 +110,14 @@ public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO public PaginationResult getDevicesWithDetails(FilterSet filterSet, int startIndex, int resultCount) throws InvalidParameterValueException, DataAccessLayerException { - if (startIndex < 0) { - throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that."); + if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { + throw new InvalidParameterValueException("Start index should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX + " or greater than that."); } - if (resultCount < 5) { - throw new InvalidParameterValueException("Result count should be equal to 5 or greater than that."); + if (resultCount < GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT) { + throw new InvalidParameterValueException("Result count should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT + " or greater than that."); } Map filters = this.extractDatabaseFiltersFromBean(filterSet); @@ -204,12 +208,14 @@ public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty."); } - if (startIndex < 0) { - throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that."); + if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { + throw new InvalidParameterValueException("Start index should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX + " or greater than that."); } - if (resultCount < 5) { - throw new InvalidParameterValueException("Result count should be equal to 5 or greater than that."); + if (resultCount < GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT) { + throw new InvalidParameterValueException("Result count should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT + " or greater than that."); } Map filters = this.extractDatabaseFiltersFromBean(filterSet); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/OracleGadgetDataServiceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/OracleGadgetDataServiceDAOImpl.java index 53c48cab567..77612007622 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/OracleGadgetDataServiceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/OracleGadgetDataServiceDAOImpl.java @@ -43,12 +43,14 @@ public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount) throws InvalidParameterValueException, DataAccessLayerException { - if (startIndex < 0) { - throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that."); + if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { + throw new InvalidParameterValueException("Start index should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX + " or greater than that."); } - if (resultCount < 5) { - throw new InvalidParameterValueException("Result count should be equal to 5 or greater than that."); + if (resultCount < GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT) { + throw new InvalidParameterValueException("Result count should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT + " or greater than that."); } Connection con; @@ -110,12 +112,14 @@ public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO public PaginationResult getDevicesWithDetails(FilterSet filterSet, int startIndex, int resultCount) throws InvalidParameterValueException, DataAccessLayerException { - if (startIndex < 0) { - throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that."); + if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { + throw new InvalidParameterValueException("Start index should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX + " or greater than that."); } - if (resultCount < 5) { - throw new InvalidParameterValueException("Result count should be equal to 5 or greater than that."); + if (resultCount < GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT) { + throw new InvalidParameterValueException("Result count should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT + " or greater than that."); } Map filters = this.extractDatabaseFiltersFromBean(filterSet); @@ -208,12 +212,14 @@ public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty."); } - if (startIndex < 0) { - throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that."); + if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { + throw new InvalidParameterValueException("Start index should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX + " or greater than that."); } - if (resultCount < 5) { - throw new InvalidParameterValueException("Result count should be equal to 5 or greater than that."); + if (resultCount < GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT) { + throw new InvalidParameterValueException("Result count should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT + " or greater than that."); } Map filters = this.extractDatabaseFiltersFromBean(filterSet); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/PostgreSQLGadgetDataServiceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/PostgreSQLGadgetDataServiceDAOImpl.java index 81c2d777648..3fb005c1fbb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/PostgreSQLGadgetDataServiceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/PostgreSQLGadgetDataServiceDAOImpl.java @@ -43,12 +43,14 @@ public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServic public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount) throws InvalidParameterValueException, DataAccessLayerException { - if (startIndex < 0) { - throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that."); + if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { + throw new InvalidParameterValueException("Start index should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX + " or greater than that."); } - if (resultCount < 5) { - throw new InvalidParameterValueException("Result count should be equal to 5 or greater than that."); + if (resultCount < GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT) { + throw new InvalidParameterValueException("Result count should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT + " or greater than that."); } Connection con; @@ -109,12 +111,14 @@ public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServic public PaginationResult getDevicesWithDetails(FilterSet filterSet, int startIndex, int resultCount) throws InvalidParameterValueException, DataAccessLayerException { - if (startIndex < 0) { - throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that."); + if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { + throw new InvalidParameterValueException("Start index should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX + " or greater than that."); } - if (resultCount < 5) { - throw new InvalidParameterValueException("Result count should be equal to 5 or greater than that."); + if (resultCount < GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT) { + throw new InvalidParameterValueException("Result count should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT + " or greater than that."); } Map filters = this.extractDatabaseFiltersFromBean(filterSet); @@ -206,12 +210,14 @@ public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServic throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty."); } - if (startIndex < 0) { - throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that."); + if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { + throw new InvalidParameterValueException("Start index should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX + " or greater than that."); } - if (resultCount < 5) { - throw new InvalidParameterValueException("Result count should be equal to 5 or greater than that."); + if (resultCount < GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT) { + throw new InvalidParameterValueException("Result count should be equal to " + + GadgetDataServiceDAOConstants.Pagination.MIN_RESULT_COUNT + " or greater than that."); } Map filters = this.extractDatabaseFiltersFromBean(filterSet); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/impl/GadgetDataServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/impl/GadgetDataServiceImpl.java index ac87e46fec7..a7a635427d9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/impl/GadgetDataServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/impl/GadgetDataServiceImpl.java @@ -31,7 +31,7 @@ import java.sql.SQLException; import java.util.List; /** - * To be updated... + * Implementation class of GadgetDataService. */ public class GadgetDataServiceImpl implements GadgetDataService {