mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Handle execution of queries contain IN clause with empty array
This commit is contained in:
parent
40a59ba86c
commit
0f39b2f253
@ -24,6 +24,7 @@ import org.wso2.carbon.device.application.mgt.common.AppLifecycleState;
|
|||||||
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
|
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
|
||||||
import org.wso2.carbon.device.application.mgt.common.dto.CategoryDTO;
|
import org.wso2.carbon.device.application.mgt.common.dto.CategoryDTO;
|
||||||
import org.wso2.carbon.device.application.mgt.common.Filter;
|
import org.wso2.carbon.device.application.mgt.common.Filter;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.dto.ReviewDTO;
|
||||||
import org.wso2.carbon.device.application.mgt.common.dto.TagDTO;
|
import org.wso2.carbon.device.application.mgt.common.dto.TagDTO;
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO;
|
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO;
|
||||||
@ -491,6 +492,9 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|||||||
+ " from the database");
|
+ " from the database");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (packageNames.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
@ -826,9 +830,12 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|||||||
log.debug("Request received in DAO Layer to get category ids for given category names");
|
log.debug("Request received in DAO Layer to get category ids for given category names");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
List<Integer> tagIds = new ArrayList<>();
|
||||||
|
if (categoryNames.isEmpty()) {
|
||||||
|
return tagIds;
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
List<Integer> tagIds = new ArrayList<>();
|
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT AP_APP_CATEGORY.ID AS ID FROM AP_APP_CATEGORY WHERE AP_APP_CATEGORY.CATEGORY IN (",
|
"SELECT AP_APP_CATEGORY.ID AS ID FROM AP_APP_CATEGORY WHERE AP_APP_CATEGORY.CATEGORY IN (",
|
||||||
") AND TENANT_ID = ?");
|
") AND TENANT_ID = ?");
|
||||||
@ -1117,9 +1124,12 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|||||||
log.debug("Request received in DAO Layer to get tag ids for given tag names");
|
log.debug("Request received in DAO Layer to get tag ids for given tag names");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
List<Integer> tagIds = new ArrayList<>();
|
||||||
|
if (tagNames.isEmpty()) {
|
||||||
|
return tagIds;
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
List<Integer> tagIds = new ArrayList<>();
|
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT AP_APP_TAG.ID AS ID FROM AP_APP_TAG WHERE AP_APP_TAG.TAG IN (",
|
"SELECT AP_APP_TAG.ID AS ID FROM AP_APP_TAG WHERE AP_APP_TAG.TAG IN (",
|
||||||
") AND TENANT_ID = ?");
|
") AND TENANT_ID = ?");
|
||||||
|
|||||||
@ -564,6 +564,11 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|||||||
public List<ApplicationReleaseDTO> getReleaseByPackages(List<String> packages, int tenantId) throws
|
public List<ApplicationReleaseDTO> getReleaseByPackages(List<String> packages, int tenantId) throws
|
||||||
ApplicationManagementDAOException {
|
ApplicationManagementDAOException {
|
||||||
|
|
||||||
|
List<ApplicationReleaseDTO> releaseDTOs = new ArrayList<>();
|
||||||
|
if (packages.isEmpty()) {
|
||||||
|
return releaseDTOs;
|
||||||
|
}
|
||||||
|
|
||||||
String sql = "SELECT "
|
String sql = "SELECT "
|
||||||
+ "AR.ID AS RELEASE_ID, "
|
+ "AR.ID AS RELEASE_ID, "
|
||||||
+ "AR.DESCRIPTION AS RELEASE_DESCRIPTION, "
|
+ "AR.DESCRIPTION AS RELEASE_DESCRIPTION, "
|
||||||
@ -600,7 +605,6 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
|
|||||||
}
|
}
|
||||||
statement.setInt(index, tenantId);
|
statement.setInt(index, tenantId);
|
||||||
try (ResultSet resultSet = statement.executeQuery()) {
|
try (ResultSet resultSet = statement.executeQuery()) {
|
||||||
List<ApplicationReleaseDTO> releaseDTOs = new ArrayList<>();
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
releaseDTOs.add(DAOUtil.constructAppReleaseDTO(resultSet));
|
releaseDTOs.add(DAOUtil.constructAppReleaseDTO(resultSet));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,6 +110,9 @@ public class GenericReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
|
|||||||
+ "application. Commenting user: " + username + " and tenant-id: " + tenantId);
|
+ "application. Commenting user: " + username + " and tenant-id: " + tenantId);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (appReleaseIds.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT rv.ID FROM AP_APP_REVIEW rv WHERE rv.AP_APP_RELEASE_ID IN (",
|
"SELECT rv.ID FROM AP_APP_REVIEW rv WHERE rv.AP_APP_RELEASE_ID IN (",
|
||||||
@ -283,6 +286,9 @@ public class GenericReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
|
|||||||
log.debug("DAO request is received to Get all active application reviews.");
|
log.debug("DAO request is received to Get all active application reviews.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (releaseIds.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT " + "AP_APP_REVIEW.ID AS ID, "
|
"SELECT " + "AP_APP_REVIEW.ID AS ID, "
|
||||||
@ -336,6 +342,9 @@ public class GenericReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
|
|||||||
log.debug("DAO request is received to Get all active application reviews of user " + username);
|
log.debug("DAO request is received to Get all active application reviews of user " + username);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (releaseIds.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT "
|
"SELECT "
|
||||||
@ -473,6 +482,10 @@ public class GenericReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
|
|||||||
log.debug("DAO request is received to Get all application rating values of an application.");
|
log.debug("DAO request is received to Get all application rating values of an application.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
List<Integer> reviews = new ArrayList<>();
|
||||||
|
if (uuids.isEmpty()) {
|
||||||
|
return reviews;
|
||||||
|
}
|
||||||
int index = 1;
|
int index = 1;
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
@ -487,7 +500,6 @@ public class GenericReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
|
|||||||
}
|
}
|
||||||
ps.setInt(index, tenantId);
|
ps.setInt(index, tenantId);
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
List<Integer> reviews = new ArrayList<>();
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
reviews.add(rs.getInt("RATING"));
|
reviews.add(rs.getInt("RATING"));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,6 +97,9 @@ public class OracleReviewDAOImpl extends GenericReviewDAOImpl {
|
|||||||
log.debug("DAO request is received to Get all active application reviews.");
|
log.debug("DAO request is received to Get all active application reviews.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (releaseIds.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT " + "AP_APP_REVIEW.ID AS ID, "
|
"SELECT " + "AP_APP_REVIEW.ID AS ID, "
|
||||||
@ -150,6 +153,9 @@ public class OracleReviewDAOImpl extends GenericReviewDAOImpl {
|
|||||||
log.debug("DAO request is received to Get all active application reviews of user " + username);
|
log.debug("DAO request is received to Get all active application reviews of user " + username);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (releaseIds.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT "
|
"SELECT "
|
||||||
@ -203,6 +209,10 @@ public class OracleReviewDAOImpl extends GenericReviewDAOImpl {
|
|||||||
log.debug("DAO request is received to Get all application rating values of an application.");
|
log.debug("DAO request is received to Get all application rating values of an application.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
List<Integer> reviews = new ArrayList<>();
|
||||||
|
if (uuids.isEmpty()) {
|
||||||
|
return reviews;
|
||||||
|
}
|
||||||
int index = 1;
|
int index = 1;
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
@ -217,7 +227,6 @@ public class OracleReviewDAOImpl extends GenericReviewDAOImpl {
|
|||||||
}
|
}
|
||||||
ps.setInt(index, tenantId);
|
ps.setInt(index, tenantId);
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
List<Integer> reviews = new ArrayList<>();
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
reviews.add(rs.getInt("RATING"));
|
reviews.add(rs.getInt("RATING"));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,6 +97,9 @@ public class SQLServerReviewDAOImpl extends GenericReviewDAOImpl {
|
|||||||
log.debug("DAO request is received to Get all active application reviews.");
|
log.debug("DAO request is received to Get all active application reviews.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (releaseIds.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT " + "AP_APP_REVIEW.ID AS ID, "
|
"SELECT " + "AP_APP_REVIEW.ID AS ID, "
|
||||||
@ -150,6 +153,9 @@ public class SQLServerReviewDAOImpl extends GenericReviewDAOImpl {
|
|||||||
log.debug("DAO request is received to Get all active application reviews of user " + username);
|
log.debug("DAO request is received to Get all active application reviews of user " + username);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (releaseIds.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT "
|
"SELECT "
|
||||||
@ -203,6 +209,10 @@ public class SQLServerReviewDAOImpl extends GenericReviewDAOImpl {
|
|||||||
log.debug("DAO request is received to Get all application rating values of an application.");
|
log.debug("DAO request is received to Get all application rating values of an application.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
List<Integer> reviews = new ArrayList<>();
|
||||||
|
if (uuids.isEmpty()) {
|
||||||
|
return reviews;
|
||||||
|
}
|
||||||
int index = 1;
|
int index = 1;
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
@ -217,7 +227,6 @@ public class SQLServerReviewDAOImpl extends GenericReviewDAOImpl {
|
|||||||
}
|
}
|
||||||
ps.setInt(index, tenantId);
|
ps.setInt(index, tenantId);
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
List<Integer> reviews = new ArrayList<>();
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
reviews.add(rs.getInt("RATING"));
|
reviews.add(rs.getInt("RATING"));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -383,9 +383,12 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|||||||
log.debug("Request received in DAO Layer to get device subscriptions for given device ids.");
|
log.debug("Request received in DAO Layer to get device subscriptions for given device ids.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
Map<Integer, DeviceSubscriptionDTO> deviceSubscriptionDTOHashMap = new HashMap<>();
|
||||||
|
if (deviceIds.isEmpty()) {
|
||||||
|
return deviceSubscriptionDTOHashMap;
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
Map<Integer, DeviceSubscriptionDTO> deviceSubscriptionDTOHashMap = new HashMap<>();
|
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT "
|
"SELECT "
|
||||||
+ "DS.ID AS ID, "
|
+ "DS.ID AS ID, "
|
||||||
@ -439,9 +442,12 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|||||||
log.debug("Request received in DAO Layer to get already subscribed users for given list of user names.");
|
log.debug("Request received in DAO Layer to get already subscribed users for given list of user names.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
List<String> subscribedUsers = new ArrayList<>();
|
||||||
|
if (users.isEmpty()) {
|
||||||
|
return subscribedUsers;
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
List<String> subscribedUsers = new ArrayList<>();
|
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT US.USER_NAME AS USER_NAME "
|
"SELECT US.USER_NAME AS USER_NAME "
|
||||||
+ "FROM AP_USER_SUBSCRIPTION US "
|
+ "FROM AP_USER_SUBSCRIPTION US "
|
||||||
@ -479,9 +485,12 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|||||||
log.debug("Request received in DAO Layer to get already subscribed role names for given list of roles.");
|
log.debug("Request received in DAO Layer to get already subscribed role names for given list of roles.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
List<String> subscribedRoles = new ArrayList<>();
|
||||||
|
if (roles.isEmpty()) {
|
||||||
|
return subscribedRoles;
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
List<String> subscribedUsers = new ArrayList<>();
|
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT RS.ROLE_NAME AS ROLE "
|
"SELECT RS.ROLE_NAME AS ROLE "
|
||||||
+ "FROM AP_ROLE_SUBSCRIPTION RS "
|
+ "FROM AP_ROLE_SUBSCRIPTION RS "
|
||||||
@ -496,11 +505,11 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|||||||
ps.setInt(index, tenantId);
|
ps.setInt(index, tenantId);
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
subscribedUsers.add(rs.getString("ROLE"));
|
subscribedRoles.add(rs.getString("ROLE"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return subscribedUsers;
|
return subscribedRoles;
|
||||||
} catch (DBConnectionException e) {
|
} catch (DBConnectionException e) {
|
||||||
String msg = "Error occurred while obtaining the DB connection to getg subscribed roles for given role "
|
String msg = "Error occurred while obtaining the DB connection to getg subscribed roles for given role "
|
||||||
+ "names.";
|
+ "names.";
|
||||||
@ -520,9 +529,12 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|||||||
log.debug("Request received in DAO Layer to get already subscribed groups for given list of groups.");
|
log.debug("Request received in DAO Layer to get already subscribed groups for given list of groups.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
List<String> subscribedGroups = new ArrayList<>();
|
||||||
|
if (groups.isEmpty()) {
|
||||||
|
return subscribedGroups;
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
List<String> subscribedUsers = new ArrayList<>();
|
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT GS.GROUP_NAME AS GROUP_NAME "
|
"SELECT GS.GROUP_NAME AS GROUP_NAME "
|
||||||
+ "FROM AP_GROUP_SUBSCRIPTION GS "
|
+ "FROM AP_GROUP_SUBSCRIPTION GS "
|
||||||
@ -537,11 +549,11 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|||||||
ps.setInt(index, tenantId);
|
ps.setInt(index, tenantId);
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
subscribedUsers.add(rs.getString("GROUP_NAME"));
|
subscribedGroups.add(rs.getString("GROUP_NAME"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return subscribedUsers;
|
return subscribedGroups;
|
||||||
} catch (DBConnectionException e) {
|
} catch (DBConnectionException e) {
|
||||||
String msg = "Error occurred while obtaining the DB connection to get already subscribed groups for given "
|
String msg = "Error occurred while obtaining the DB connection to get already subscribed groups for given "
|
||||||
+ "group names.";
|
+ "group names.";
|
||||||
@ -562,9 +574,12 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|||||||
log.debug("Request received to DAO Layer to get already subscribed dvice Ids for given list of device Ids.");
|
log.debug("Request received to DAO Layer to get already subscribed dvice Ids for given list of device Ids.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
List<Integer> subscribedDevices = new ArrayList<>();
|
||||||
|
if (deviceIds.isEmpty()) {
|
||||||
|
return subscribedDevices;
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
List<Integer> subscribedDevices = new ArrayList<>();
|
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT DS.ID AS DEVICE_SUBSCRIPTION_ID "
|
"SELECT DS.ID AS DEVICE_SUBSCRIPTION_ID "
|
||||||
+ "FROM AP_DEVICE_SUBSCRIPTION DS "
|
+ "FROM AP_DEVICE_SUBSCRIPTION DS "
|
||||||
@ -695,6 +710,9 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|||||||
public boolean updateDeviceSubStatus(int deviceId, List<Integer> deviceSubIds, String status, int tenantId)
|
public boolean updateDeviceSubStatus(int deviceId, List<Integer> deviceSubIds, String status, int tenantId)
|
||||||
throws ApplicationManagementDAOException {
|
throws ApplicationManagementDAOException {
|
||||||
try {
|
try {
|
||||||
|
if (deviceSubIds.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
|
|||||||
@ -380,6 +380,9 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
List<Device> devices = new ArrayList<>();
|
List<Device> devices = new ArrayList<>();
|
||||||
|
if (deviceProps.isEmpty()) {
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
List<List<String>> outputLists = new ArrayList<>();
|
List<List<String>> outputLists = new ArrayList<>();
|
||||||
List<String> deviceList = null;
|
List<String> deviceList = null;
|
||||||
@ -935,6 +938,9 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
throws DeviceManagementDAOException {
|
throws DeviceManagementDAOException {
|
||||||
List<Device> devices = new ArrayList<>();
|
List<Device> devices = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
|
if (deviceStatuses.isEmpty()) {
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
StringJoiner joiner = new StringJoiner(",","SELECT "
|
StringJoiner joiner = new StringJoiner(",","SELECT "
|
||||||
+ "e1.OWNER, "
|
+ "e1.OWNER, "
|
||||||
@ -1222,6 +1228,9 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
|
if (devices.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
StringBuilder sql = new StringBuilder("UPDATE DM_ENROLMENT SET STATUS = ? WHERE DEVICE_ID IN " +
|
StringBuilder sql = new StringBuilder("UPDATE DM_ENROLMENT SET STATUS = ? WHERE DEVICE_ID IN " +
|
||||||
"(SELECT d.ID FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.DEVICE_IDENTIFICATION IN (");
|
"(SELECT d.ID FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.DEVICE_IDENTIFICATION IN (");
|
||||||
@ -1913,6 +1922,10 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
int counter = 0;
|
int counter = 0;
|
||||||
List<Device> devices = new ArrayList<>();
|
List<Device> devices = new ArrayList<>();
|
||||||
|
|
||||||
|
if (deviceIdentifiers.isEmpty()) {
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
"SELECT "
|
"SELECT "
|
||||||
+ "d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, "
|
+ "d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, "
|
||||||
@ -1961,6 +1974,10 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
int counter = 0;
|
int counter = 0;
|
||||||
List<Device> devices = new ArrayList<>();
|
List<Device> devices = new ArrayList<>();
|
||||||
|
|
||||||
|
if (deviceIdentifiers.isEmpty() || statuses.isEmpty()) {
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
StringJoiner statusJoiner = new StringJoiner(",", "e.STATUS IN (", ") ");
|
StringJoiner statusJoiner = new StringJoiner(",", "e.STATUS IN (", ") ");
|
||||||
while (counter < statuses.size()) {
|
while (counter < statuses.size()) {
|
||||||
statusJoiner.add("?");
|
statusJoiner.add("?");
|
||||||
|
|||||||
@ -68,6 +68,9 @@ public abstract class AbstractEventConfigDAO implements EventConfigDAO {
|
|||||||
public List<EventConfig> getEventsOfGroups(List<Integer> groupIds, int tenantId) throws EventManagementDAOException {
|
public List<EventConfig> getEventsOfGroups(List<Integer> groupIds, int tenantId) throws EventManagementDAOException {
|
||||||
try {
|
try {
|
||||||
List<EventConfig> eventList = new ArrayList<>();
|
List<EventConfig> eventList = new ArrayList<>();
|
||||||
|
if (groupIds.isEmpty()) {
|
||||||
|
return eventList;
|
||||||
|
}
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
String sql = "SELECT " +
|
String sql = "SELECT " +
|
||||||
"E.ID AS EVENT_ID, " +
|
"E.ID AS EVENT_ID, " +
|
||||||
@ -145,6 +148,9 @@ public abstract class AbstractEventConfigDAO implements EventConfigDAO {
|
|||||||
@Override
|
@Override
|
||||||
public void deleteEventGroupMappingRecordsByEventIds(List<Integer> eventsIdsToDelete) throws EventManagementDAOException {
|
public void deleteEventGroupMappingRecordsByEventIds(List<Integer> eventsIdsToDelete) throws EventManagementDAOException {
|
||||||
try {
|
try {
|
||||||
|
if (eventsIdsToDelete.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
String sql = "DELETE FROM DM_DEVICE_EVENT_GROUP_MAPPING WHERE EVENT_ID IN (%s)";
|
String sql = "DELETE FROM DM_DEVICE_EVENT_GROUP_MAPPING WHERE EVENT_ID IN (%s)";
|
||||||
String inClause = String.join(", ", Collections.nCopies(eventsIdsToDelete.size(), "?"));
|
String inClause = String.join(", ", Collections.nCopies(eventsIdsToDelete.size(), "?"));
|
||||||
@ -166,6 +172,9 @@ public abstract class AbstractEventConfigDAO implements EventConfigDAO {
|
|||||||
@Override
|
@Override
|
||||||
public void deleteEventGroupMappingRecordsByGroupIds(List<Integer> groupIdsToDelete) throws EventManagementDAOException {
|
public void deleteEventGroupMappingRecordsByGroupIds(List<Integer> groupIdsToDelete) throws EventManagementDAOException {
|
||||||
try {
|
try {
|
||||||
|
if (groupIdsToDelete.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
String sql = "DELETE FROM DM_DEVICE_EVENT_GROUP_MAPPING WHERE GROUP_ID IN (%s)";
|
String sql = "DELETE FROM DM_DEVICE_EVENT_GROUP_MAPPING WHERE GROUP_ID IN (%s)";
|
||||||
String inClause = String.join(", ", Collections.nCopies(groupIdsToDelete.size(), "?"));
|
String inClause = String.join(", ", Collections.nCopies(groupIdsToDelete.size(), "?"));
|
||||||
@ -230,6 +239,9 @@ public abstract class AbstractEventConfigDAO implements EventConfigDAO {
|
|||||||
public List<EventConfig> getEventsById(List<Integer> eventIdList) throws EventManagementDAOException {
|
public List<EventConfig> getEventsById(List<Integer> eventIdList) throws EventManagementDAOException {
|
||||||
try {
|
try {
|
||||||
List<EventConfig> eventList = new ArrayList<>();
|
List<EventConfig> eventList = new ArrayList<>();
|
||||||
|
if (eventIdList.isEmpty()) {
|
||||||
|
return eventList;
|
||||||
|
}
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
String sql = "SELECT " +
|
String sql = "SELECT " +
|
||||||
"ID AS EVENT_ID, " +
|
"ID AS EVENT_ID, " +
|
||||||
@ -269,6 +281,9 @@ public abstract class AbstractEventConfigDAO implements EventConfigDAO {
|
|||||||
public List<Integer> getGroupsOfEvents(List<Integer> eventIdList) throws EventManagementDAOException {
|
public List<Integer> getGroupsOfEvents(List<Integer> eventIdList) throws EventManagementDAOException {
|
||||||
try {
|
try {
|
||||||
List<Integer> groupIdList = new ArrayList<>();
|
List<Integer> groupIdList = new ArrayList<>();
|
||||||
|
if (eventIdList.isEmpty()) {
|
||||||
|
return groupIdList;
|
||||||
|
}
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
String sql = "SELECT " +
|
String sql = "SELECT " +
|
||||||
"GROUP_ID " +
|
"GROUP_ID " +
|
||||||
|
|||||||
@ -772,6 +772,9 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
|
|||||||
throws GroupManagementDAOException {
|
throws GroupManagementDAOException {
|
||||||
List<Device> devices = new ArrayList<>();
|
List<Device> devices = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
|
if (deviceStatuses.isEmpty()) {
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
Connection conn = GroupManagementDAOFactory.getConnection();
|
Connection conn = GroupManagementDAOFactory.getConnection();
|
||||||
StringJoiner joiner = new StringJoiner(",","SELECT "
|
StringJoiner joiner = new StringJoiner(",","SELECT "
|
||||||
+ "d1.DEVICE_ID, "
|
+ "d1.DEVICE_ID, "
|
||||||
|
|||||||
@ -421,6 +421,9 @@ public class GeofenceDAOImpl implements GeofenceDAO {
|
|||||||
public Map<Integer, List<EventConfig>> getEventsOfGeoFences(List<Integer> geofenceIds) throws DeviceManagementDAOException {
|
public Map<Integer, List<EventConfig>> getEventsOfGeoFences(List<Integer> geofenceIds) throws DeviceManagementDAOException {
|
||||||
try {
|
try {
|
||||||
Map<Integer, List<EventConfig>> geoFenceEventMap = new HashMap<>();
|
Map<Integer, List<EventConfig>> geoFenceEventMap = new HashMap<>();
|
||||||
|
if (geofenceIds.isEmpty()) {
|
||||||
|
return geoFenceEventMap;
|
||||||
|
}
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
String sql = "SELECT " +
|
String sql = "SELECT " +
|
||||||
"E.ID AS EVENT_ID, " +
|
"E.ID AS EVENT_ID, " +
|
||||||
@ -490,6 +493,9 @@ public class GeofenceDAOImpl implements GeofenceDAO {
|
|||||||
public Set<GeoFenceGroupMap> getGroupIdsOfGeoFences(List<Integer> fenceIds) throws DeviceManagementDAOException {
|
public Set<GeoFenceGroupMap> getGroupIdsOfGeoFences(List<Integer> fenceIds) throws DeviceManagementDAOException {
|
||||||
try {
|
try {
|
||||||
Set<GeoFenceGroupMap> geoFenceGroupSet = new HashSet<>();
|
Set<GeoFenceGroupMap> geoFenceGroupSet = new HashSet<>();
|
||||||
|
if (fenceIds.isEmpty()) {
|
||||||
|
return geoFenceGroupSet;
|
||||||
|
}
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
String sql = "SELECT " +
|
String sql = "SELECT " +
|
||||||
"FENCE_ID, " +
|
"FENCE_ID, " +
|
||||||
|
|||||||
@ -883,6 +883,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
Connection conn;
|
Connection conn;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
List<Device> devices = new ArrayList<>();
|
||||||
|
if (deviceIds.isEmpty()) {
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
|
|
||||||
@ -937,7 +941,6 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
ps.setInt(index, limitValue);
|
ps.setInt(index, limitValue);
|
||||||
|
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
List<Device> devices = new ArrayList<>();
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
devices.add(DeviceManagementDAOUtil.loadDevice(rs));
|
devices.add(DeviceManagementDAOUtil.loadDevice(rs));
|
||||||
}
|
}
|
||||||
@ -956,6 +959,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, List<String> status)
|
public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, List<String> status)
|
||||||
throws DeviceManagementDAOException {
|
throws DeviceManagementDAOException {
|
||||||
try {
|
try {
|
||||||
|
if (deviceIds.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
|
|||||||
@ -853,6 +853,10 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
Connection conn;
|
Connection conn;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
List<Device> devices = new ArrayList<>();
|
||||||
|
if (deviceIds.isEmpty()) {
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
|
|
||||||
@ -907,7 +911,6 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
ps.setInt(index, limitValue);
|
ps.setInt(index, limitValue);
|
||||||
|
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
List<Device> devices = new ArrayList<>();
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
devices.add(DeviceManagementDAOUtil.loadDevice(rs));
|
devices.add(DeviceManagementDAOUtil.loadDevice(rs));
|
||||||
}
|
}
|
||||||
@ -926,6 +929,9 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, List<String> status)
|
public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, List<String> status)
|
||||||
throws DeviceManagementDAOException {
|
throws DeviceManagementDAOException {
|
||||||
try {
|
try {
|
||||||
|
if (deviceIds.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
|
|||||||
@ -833,6 +833,10 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
Connection conn;
|
Connection conn;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
List<Device> devices = new ArrayList<>();
|
||||||
|
if (deviceIds.isEmpty()) {
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
|
|
||||||
@ -887,7 +891,6 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
ps.setInt(index, limitValue);
|
ps.setInt(index, limitValue);
|
||||||
|
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
List<Device> devices = new ArrayList<>();
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
devices.add(DeviceManagementDAOUtil.loadDevice(rs));
|
devices.add(DeviceManagementDAOUtil.loadDevice(rs));
|
||||||
}
|
}
|
||||||
@ -906,6 +909,9 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, List<String> status)
|
public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, List<String> status)
|
||||||
throws DeviceManagementDAOException {
|
throws DeviceManagementDAOException {
|
||||||
try {
|
try {
|
||||||
|
if (deviceIds.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
|
|||||||
@ -699,6 +699,10 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
Connection conn;
|
Connection conn;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
List<Device> devices = new ArrayList<>();
|
||||||
|
if (deviceIds.isEmpty()) {
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
|
|
||||||
@ -753,7 +757,6 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
ps.setInt(index, limitValue);
|
ps.setInt(index, limitValue);
|
||||||
|
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
List<Device> devices = new ArrayList<>();
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
devices.add(DeviceManagementDAOUtil.loadDevice(rs));
|
devices.add(DeviceManagementDAOUtil.loadDevice(rs));
|
||||||
}
|
}
|
||||||
@ -1039,6 +1042,9 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, List<String> status)
|
public int getSubscribedDeviceCount(List<Integer> deviceIds, int tenantId, List<String> status)
|
||||||
throws DeviceManagementDAOException {
|
throws DeviceManagementDAOException {
|
||||||
try {
|
try {
|
||||||
|
if (deviceIds.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
StringJoiner joiner = new StringJoiner(",",
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user