|
|
@ -175,7 +175,7 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmt = con.prepareStatement(sql);
|
|
|
|
stmt = con.prepareStatement(sql);
|
|
|
|
// [2] appending filter column values
|
|
|
|
// [2] appending filter column values, if exist
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
if (filters != null && filters.values().size() > 0) {
|
|
|
|
if (filters != null && filters.values().size() > 0) {
|
|
|
|
int i = 2;
|
|
|
|
int i = 2;
|
|
|
@ -212,8 +212,8 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
|
|
|
|
con = this.getConnection();
|
|
|
|
con = this.getConnection();
|
|
|
|
String sql, advancedSqlFiltering = "";
|
|
|
|
String sql, advancedSqlFiltering = "";
|
|
|
|
// appending filters if exist, to support advanced filtering options
|
|
|
|
// appending filters if exist, to support advanced filtering options
|
|
|
|
// [1] appending filter columns
|
|
|
|
// [1] appending filter columns, if exist
|
|
|
|
if (filters.size() > 0) {
|
|
|
|
if (filters != null && filters.size() > 0) {
|
|
|
|
for (String column : filters.keySet()) {
|
|
|
|
for (String column : filters.keySet()) {
|
|
|
|
advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? ";
|
|
|
|
advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? ";
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -227,8 +227,9 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
|
|
|
|
advancedSqlFiltering + "GROUP BY PLATFORM";
|
|
|
|
advancedSqlFiltering + "GROUP BY PLATFORM";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmt = con.prepareStatement(sql);
|
|
|
|
stmt = con.prepareStatement(sql);
|
|
|
|
// [2] appending filter column values
|
|
|
|
// [2] appending filter column values, if exist
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
|
|
|
|
if (filters != null && filters.values().size() > 0) {
|
|
|
|
int i = 2;
|
|
|
|
int i = 2;
|
|
|
|
for (Object value : filters.values()) {
|
|
|
|
for (Object value : filters.values()) {
|
|
|
|
if (value instanceof Integer) {
|
|
|
|
if (value instanceof Integer) {
|
|
|
@ -238,6 +239,7 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// executing query
|
|
|
|
// executing query
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
// fetching query results
|
|
|
|
// fetching query results
|
|
|
@ -262,23 +264,24 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
|
|
|
|
con = this.getConnection();
|
|
|
|
con = this.getConnection();
|
|
|
|
String sql, advancedSqlFiltering = "";
|
|
|
|
String sql, advancedSqlFiltering = "";
|
|
|
|
// appending filters if exist, to support advanced filtering options
|
|
|
|
// appending filters if exist, to support advanced filtering options
|
|
|
|
// [1] appending filter columns
|
|
|
|
// [1] appending filter columns, if exist
|
|
|
|
if (filters.size() > 0) {
|
|
|
|
if (filters != null && filters.size() > 0) {
|
|
|
|
for (String column : filters.keySet()) {
|
|
|
|
for (String column : filters.keySet()) {
|
|
|
|
advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? ";
|
|
|
|
advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filteringViewID == 1) {
|
|
|
|
if (filteringViewID == 1) {
|
|
|
|
sql = "SELECT PLATFORM, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM DEVICES_VIEW_1 WHERE TENANT_ID = ? " +
|
|
|
|
sql = "SELECT OWNERSHIP, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM DEVICES_VIEW_1 WHERE TENANT_ID = ? " +
|
|
|
|
advancedSqlFiltering + "GROUP BY OWNERSHIP";
|
|
|
|
advancedSqlFiltering + "GROUP BY OWNERSHIP";
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// if filteringViewID == 2
|
|
|
|
// if filteringViewID == 2
|
|
|
|
sql = "SELECT PLATFORM, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM DEVICES_VIEW_2 WHERE TENANT_ID = ? " +
|
|
|
|
sql = "SELECT OWNERSHIP, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM DEVICES_VIEW_2 WHERE TENANT_ID = ? " +
|
|
|
|
advancedSqlFiltering + "GROUP BY OWNERSHIP";
|
|
|
|
advancedSqlFiltering + "GROUP BY OWNERSHIP";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmt = con.prepareStatement(sql);
|
|
|
|
stmt = con.prepareStatement(sql);
|
|
|
|
// [2] appending filter column values
|
|
|
|
// [2] appending filter column values, if exist
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
|
|
|
|
if (filters != null && filters.values().size() > 0) {
|
|
|
|
int i = 2;
|
|
|
|
int i = 2;
|
|
|
|
for (Object value : filters.values()) {
|
|
|
|
for (Object value : filters.values()) {
|
|
|
|
if (value instanceof Integer) {
|
|
|
|
if (value instanceof Integer) {
|
|
|
@ -288,11 +291,12 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// executing query
|
|
|
|
// executing query
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
// fetching query results
|
|
|
|
// fetching query results
|
|
|
|
while (rs.next()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
filteredDeviceCountsByOwnershipTypes.put(rs.getString("PLATFORM"), rs.getInt("DEVICE_COUNT"));
|
|
|
|
filteredDeviceCountsByOwnershipTypes.put(rs.getString("OWNERSHIP"), rs.getInt("DEVICE_COUNT"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
|
|
|
|
throw new GadgetDataServiceDAOException("Error occurred while executing a selection query to the database", e);
|
|
|
@ -319,15 +323,16 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
|
|
|
|
sql = "SELECT DEVICE_ID, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM DEVICES_VIEW_2 WHERE TENANT_ID = ?";
|
|
|
|
sql = "SELECT DEVICE_ID, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM DEVICES_VIEW_2 WHERE TENANT_ID = ?";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// appending filters to support advanced filtering options
|
|
|
|
// appending filters to support advanced filtering options
|
|
|
|
// [1] appending filter columns
|
|
|
|
// [1] appending filter columns, if exist
|
|
|
|
if (filters.size() > 0) {
|
|
|
|
if (filters != null && filters.size() > 0) {
|
|
|
|
for (String column : filters.keySet()) {
|
|
|
|
for (String column : filters.keySet()) {
|
|
|
|
sql = sql + " AND " + column + " = ?";
|
|
|
|
sql = sql + " AND " + column + " = ?";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmt = con.prepareStatement(sql);
|
|
|
|
stmt = con.prepareStatement(sql);
|
|
|
|
// [2] appending filter column values
|
|
|
|
// [2] appending filter column values, if exist
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
|
|
|
|
if (filters != null && filters.values().size() > 0) {
|
|
|
|
int i = 2;
|
|
|
|
int i = 2;
|
|
|
|
for (Object value : filters.values()) {
|
|
|
|
for (Object value : filters.values()) {
|
|
|
|
if (value instanceof Integer) {
|
|
|
|
if (value instanceof Integer) {
|
|
|
@ -337,14 +342,15 @@ class GadgetDataServiceDAOImpl implements GadgetDataServiceDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// executing query
|
|
|
|
// executing query
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
// fetching query results
|
|
|
|
// fetching query results
|
|
|
|
while (rs.next()) {
|
|
|
|
while (rs.next()) {
|
|
|
|
filteredDeviceWithDetails.put("Device-ID", rs.getInt("DEVICE_ID"));
|
|
|
|
filteredDeviceWithDetails.put("device-id", rs.getInt("DEVICE_ID"));
|
|
|
|
filteredDeviceWithDetails.put("Platform", rs.getString("PLATFORM"));
|
|
|
|
filteredDeviceWithDetails.put("platform", rs.getString("PLATFORM"));
|
|
|
|
filteredDeviceWithDetails.put("Ownership", rs.getString("OWNERSHIP"));
|
|
|
|
filteredDeviceWithDetails.put("ownership", rs.getString("OWNERSHIP"));
|
|
|
|
filteredDeviceWithDetails.put("Connectivity-Details", rs.getString("CONNECTIVITY_STATUS"));
|
|
|
|
filteredDeviceWithDetails.put("connectivity-details", rs.getString("CONNECTIVITY_STATUS"));
|
|
|
|
filteredDevicesWithDetails.add(filteredDeviceWithDetails);
|
|
|
|
filteredDevicesWithDetails.add(filteredDeviceWithDetails);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|