remotes/1731000850486189418/master
tcdlpds 6 months ago
commit 0548dbdc3a

@ -118,6 +118,11 @@ public class Filter {
*/ */
private boolean isNotRetired; private boolean isNotRetired;
/**
* To check whether web applications should be returned
*/
private boolean withWebApps;
public int getLimit() { public int getLimit() {
return limit; return limit;
} }
@ -221,4 +226,12 @@ public class Filter {
public void setNotRetired(boolean notRetired) { public void setNotRetired(boolean notRetired) {
isNotRetired = notRetired; isNotRetired = notRetired;
} }
public boolean isWithWebApps() {
return withWebApps;
}
public void setWithWebApps(boolean withWebApps) {
this.withWebApps = withWebApps;
}
} }

@ -174,7 +174,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
sql += "AND AP_APP_RELEASE.CURRENT_STATE = ? "; sql += "AND AP_APP_RELEASE.CURRENT_STATE = ? ";
} }
if (deviceTypeId != -1) { if (deviceTypeId != -1) {
sql += "AND AP_APP.DEVICE_TYPE_ID = ? "; sql += "AND (AP_APP.DEVICE_TYPE_ID = ? ";
if (filter.isWithWebApps()) {
sql += "OR AP_APP.DEVICE_TYPE_ID = 0 ";
}
sql += ") ";
} }
if (filter.isNotRetired()) { if (filter.isNotRetired()) {
sql += "AND AP_APP.STATUS != 'RETIRED' "; sql += "AND AP_APP.STATUS != 'RETIRED' ";
@ -305,7 +309,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
sql += " AND AP_APP_RELEASE.CURRENT_STATE = ?"; sql += " AND AP_APP_RELEASE.CURRENT_STATE = ?";
} }
if (deviceTypeId != -1) { if (deviceTypeId != -1) {
sql += " AND AP_APP.DEVICE_TYPE_ID = ?"; sql += "AND (AP_APP.DEVICE_TYPE_ID = ? ";
if (filter.isWithWebApps()) {
sql += "OR AP_APP.DEVICE_TYPE_ID = 0 ";
}
sql += ") ";
} }
if (filter.isNotRetired()) { if (filter.isNotRetired()) {
sql += " AND AP_APP.STATUS != 'RETIRED'"; sql += " AND AP_APP.STATUS != 'RETIRED'";

@ -279,7 +279,7 @@ public class GroupManagementServiceImpl implements GroupManagementService {
); );
return Response.status(Response.Status.OK).build(); return Response.status(Response.Status.OK).build();
} catch (GroupManagementException e) { } catch (GroupManagementException e) {
String msg = "Error occurred while adding new group."; String msg = "Error occurred while updating group. ";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (GroupNotExistException e) { } catch (GroupNotExistException e) {

@ -176,7 +176,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
+ "d.DESCRIPTION, " + "d.DESCRIPTION, "
+ "d.NAME, " + "d.NAME, "
+ "d.LAST_UPDATED_TIMESTAMP " + "d.LAST_UPDATED_TIMESTAMP "
+ "FROM DM_DEVICE d" + "FROM DM_DEVICE d WHERE "
+ "d.DEVICE_IDENTIFICATION = ? AND " + "d.DEVICE_IDENTIFICATION = ? AND "
+ "d.TENANT_ID = ?"; + "d.TENANT_ID = ?";
@ -197,7 +197,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
int paramIndx = 1; int paramIndx = 1;
stmt.setString(paramIndx++, deviceData.getDeviceIdentifier().getType());
stmt.setString(paramIndx++, deviceData.getDeviceIdentifier().getId()); stmt.setString(paramIndx++, deviceData.getDeviceIdentifier().getId());
stmt.setInt(paramIndx++, tenantId); stmt.setInt(paramIndx++, tenantId);
if (deviceData.getLastModifiedDate() != null) { if (deviceData.getLastModifiedDate() != null) {
@ -964,12 +963,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
+ "d.NAME AS DEVICE_NAME, " + "d.NAME AS DEVICE_NAME, "
+ "d.DEVICE_IDENTIFICATION, " + "d.DEVICE_IDENTIFICATION, "
+ "d.LAST_UPDATED_TIMESTAMP, " + "d.LAST_UPDATED_TIMESTAMP, "
+ "e.DEVICE_TYPE " + "e1.DEVICE_TYPE "
+ "FROM " + "FROM "
+ "DM_DEVICE d, " + "DM_DEVICE d, "
+ "(SELECT " + "(SELECT "
+ "e.OWNER, " + "e.OWNER, "
+ "e.DEVICE_TYPE " + "e.DEVICE_TYPE, "
+ "e.OWNERSHIP, " + "e.OWNERSHIP, "
+ "e.ID AS ENROLMENT_ID, " + "e.ID AS ENROLMENT_ID, "
+ "e.DEVICE_ID, " + "e.DEVICE_ID, "
@ -1037,12 +1036,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
"(SELECT gd.DEVICE_ID, " + "(SELECT gd.DEVICE_ID, " +
"gd.DESCRIPTION, " + "gd.DESCRIPTION, " +
"gd.NAME, " + "gd.NAME, " +
"gd.DEVICE_IDENTIFICATION, " + "gd.DEVICE_IDENTIFICATION " +
"FROM " + "FROM " +
"(SELECT d.ID AS DEVICE_ID, " + "(SELECT d.ID AS DEVICE_ID, " +
"d.DESCRIPTION, " + "d.DESCRIPTION, " +
"d.NAME, " + "d.NAME, " +
"d.DEVICE_IDENTIFICATION, " + "d.DEVICE_IDENTIFICATION " +
"FROM DM_DEVICE d, " + "FROM DM_DEVICE d, " +
"(SELECT dgm.DEVICE_ID " + "(SELECT dgm.DEVICE_ID " +
"FROM DM_DEVICE_GROUP_MAP dgm " + "FROM DM_DEVICE_GROUP_MAP dgm " +
@ -2366,7 +2365,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
"e.device_id," + "e.device_id," +
"e.status, " + "e.status, " +
"e.date_of_last_update, " + "e.date_of_last_update, " +
"e.date_of_enrolment " + "e.date_of_enrolment, " +
"e.DEVICE_TYPE " + "e.DEVICE_TYPE " +
"FROM dm_enrolment e " + "FROM dm_enrolment e " +
"INNER JOIN " + "INNER JOIN " +
@ -2376,7 +2375,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
"KEY_FIELD = 'encryptionEnabled' " + "KEY_FIELD = 'encryptionEnabled' " +
"AND VALUE_FIELD = ?) AS di " + "AND VALUE_FIELD = ?) AS di " +
"ON di.DEVICE_ID = e.DEVICE_ID " + "ON di.DEVICE_ID = e.DEVICE_ID " +
"WHERE e.tenant_id = ?) e1, " + "WHERE e.tenant_id = ?) e1 " +
"WHERE d.id = e1.device_id " + "WHERE d.id = e1.device_id " +
"ORDER BY e1.date_of_last_update DESC " + "ORDER BY e1.date_of_last_update DESC " +
"LIMIT ? OFFSET ?"; "LIMIT ? OFFSET ?";
@ -2410,7 +2409,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
try { try {
Connection conn = getConnection(); Connection conn = getConnection();
String sql = String sql =
"SELECT COUNT(DEVICE_ID) " + "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT " +
"FROM DM_DEVICE_INFO " + "FROM DM_DEVICE_INFO " +
"WHERE KEY_FIELD = 'encryptionEnabled' " + "WHERE KEY_FIELD = 'encryptionEnabled' " +
"AND VALUE_FIELD = ?"; "AND VALUE_FIELD = ?";
@ -2418,7 +2417,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
try (PreparedStatement ps = conn.prepareStatement(sql)) { try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setBoolean(1, isEncrypted); ps.setBoolean(1, isEncrypted);
ps.setInt(2, tenantId);
try (ResultSet rs = ps.executeQuery()) { try (ResultSet rs = ps.executeQuery()) {
return rs.next() ? rs.getInt("DEVICE_COUNT") : 0; return rs.next() ? rs.getInt("DEVICE_COUNT") : 0;

@ -1282,8 +1282,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
StringJoiner joiner = new StringJoiner(",","SELECT " StringJoiner joiner = new StringJoiner(",","SELECT "
+ "d1.DEVICE_ID, " + "d1.DEVICE_ID, "
+ "d1.DESCRIPTION, " + "d1.DESCRIPTION, "
+ "e.DEVICE_NAME, " + "d1.NAME AS DEVICE_NAME, "
+ "d1.DEVICE_TYPE, " + "e.DEVICE_TYPE, "
+ "d1.DEVICE_IDENTIFICATION, " + "d1.DEVICE_IDENTIFICATION, "
+ "d1.LAST_UPDATED_TIMESTAMP, " + "d1.LAST_UPDATED_TIMESTAMP, "
+ "e.OWNER, " + "e.OWNER, "
@ -1343,8 +1343,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
String sql = "SELECT " String sql = "SELECT "
+ "d1.DEVICE_ID, " + "d1.DEVICE_ID, "
+ "d1.DESCRIPTION, " + "d1.DESCRIPTION, "
+ "e.DEVICE_NAME, " + "d1.NAME AS DEVICE_NAME, "
+ "d1.DEVICE_TYPE, " + "e.DEVICE_TYPE, "
+ "d1.DEVICE_IDENTIFICATION, " + "d1.DEVICE_IDENTIFICATION, "
+ "d1.LAST_UPDATED_TIMESTAMP, " + "d1.LAST_UPDATED_TIMESTAMP, "
+ "e.OWNER, " + "e.OWNER, "

@ -646,8 +646,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
} }
@Override @Override
public List<Device> searchDevicesInGroup(PaginationRequest request, int tenantId) public List<Device> searchDevicesInGroup(PaginationRequest request, int tenantId) throws DeviceManagementDAOException {
throws DeviceManagementDAOException {
List<Device> devices = null; List<Device> devices = null;
int groupId = request.getGroupId(); int groupId = request.getGroupId();
String deviceType = request.getDeviceType(); String deviceType = request.getDeviceType();
@ -687,6 +686,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
"gd.DESCRIPTION, " + "gd.DESCRIPTION, " +
"gd.NAME, " + "gd.NAME, " +
"gd.DEVICE_IDENTIFICATION, " + "gd.DEVICE_IDENTIFICATION, " +
"gd.LAST_UPDATED_TIMESTAMP " +
"FROM " + "FROM " +
"(SELECT d.ID AS DEVICE_ID, " + "(SELECT d.ID AS DEVICE_ID, " +
"d.DESCRIPTION, " + "d.DESCRIPTION, " +
@ -708,10 +708,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
sql = sql + " WHERE 1 = 1"; sql = sql + " WHERE 1 = 1";
//Add query for last updated timestamp //Add query for last updated timestamp
if (since != null) { if (since != null) {
sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?"; sql = sql + " AND gd.LAST_UPDATED_TIMESTAMP > ?";
isSinceProvided = true; isSinceProvided = true;
} }
sql = sql + " ) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? "; sql = sql + " ) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND e.TENANT_ID = ? ";
//Add the query for device-type //Add the query for device-type
if (deviceType != null && !deviceType.isEmpty()) { if (deviceType != null && !deviceType.isEmpty()) {
sql = sql + " AND e.DEVICE_TYPE = ?"; sql = sql + " AND e.DEVICE_TYPE = ?";

Loading…
Cancel
Save