Merge branch 'master' of ssh://repository.entgra.net:222/community/device-mgt-core into secure-folder-policy

windows-login-issue
Oshani Silva 2 months ago
commit 21290dfba6

@ -22,7 +22,7 @@ package io.entgra.device.mgt.core.application.mgt.common;
public class ReleaseVersionInfo {
private String version;
private String releaseType;
private String rating;
private double rating;
private String state;
private String uuid;
@ -38,11 +38,11 @@ public class ReleaseVersionInfo {
return releaseType;
}
public String getRating() {
public double getRating() {
return rating;
}
public void setRating(String rating) {
public void setRating(double rating) {
this.rating = rating;
}

@ -187,11 +187,14 @@ public interface SubscriptionManager {
* @param subType subscription type of the application.
* @param offsetValue offset value for get paginated request.
* @param limitValue limit value for get paginated request.
* @param uninstalled a Boolean flag indicating the filter criteria for retrieve subscription data
* @param searchName an optional search term to filter the results by name. If null or empty, no filtering by name is applied.
* @return {@link PaginationResult} pagination result of the category details.
* @throws {@link ApplicationManagementException} Exception of the application management
*/
PaginationResult getAppInstalledSubscribers(int offsetValue, int limitValue, String appUUID,
String subType) throws ApplicationManagementException;
String subType, Boolean uninstalled, String searchName)
throws ApplicationManagementException;
/**
* This method is responsible to provide application subscription data for given application release UUID.

@ -198,14 +198,33 @@ public interface SubscriptionDAO {
* @param offsetValue offset value for get paginated result
* @param limitValue limit value for get paginated result
* @param appReleaseId id of the application release.
* @param uninstalled a Boolean flag indicating the filter criteria for getting users:
* - `true` to get only unsubscribed users,
* - `false` to get only subscribed users,
* - `null` to get all users regardless of their unsubscription status.
* @param searchName an optional search term to filter the results by username.
* @return subscribedUsers - list of app subscribed users.
* @throws {@link ApplicationManagementDAOException} if connections establishment fails.
*/
List<String> getAppSubscribedUsers(int offsetValue, int limitValue, int appReleaseId,
int tenantId)
int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException;
int getSubscribedUserCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException;
/**
* This method is used to get the count of users who are subscribed or unsubscribed to a specific application release.
*
* @param appReleaseId the ID of the application release for which the user count is to be retrieved.
* @param tenantId the ID of the current tenant.
* @param uninstalled a Boolean flag indicating the filter criteria for counting users:
* - `true` to count only unsubscribed users,
* - `false` to count only subscribed users,
* - `null` to count all users regardless of their unsubscription status.
* @param searchName an optional search term to filter the results by username.
* @return the count of users based on the specified criteria.
* @throws ApplicationManagementDAOException if an error occurs while establishing a database connection or executing the query.
*/
int getSubscribedUserCount(int appReleaseId, int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException;
/**
* This method is used to get the details of roles
@ -214,14 +233,34 @@ public interface SubscriptionDAO {
* @param offsetValue offset value for get paginated request.
* @param limitValue limit value for get paginated request.
* @param appReleaseId id of the application release.
* @param uninstalled a Boolean flag indicating the filter criteria for getting roles:
* - `true` to get only unsubscribed roles,
* - `false` to get only subscribed roles,
* - `null` to get all roles regardless of their unsubscription status.
* @param searchName an optional search term to filter the results by role name.
* @return subscribedRoles - list of app subscribed roles.
* @throws {@link ApplicationManagementDAOException} if connections establishment fails.
*/
List<String> getAppSubscribedRoles(int offsetValue, int limitValue, int appReleaseId,
int tenantId)
int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException;
int getSubscribedRoleCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException;
/**
* This method retrieves the count of roles subscribed to a given application release.
* The count can be filtered based on the unsubscription status.
*
* @param appReleaseId the ID of the application release for which the subscribed roles are counted.
* @param tenantId the ID of the current tenant.
* @param uninstalled a Boolean flag indicating the filter criteria for counting roles:
* - `true` to count only unsubscribed roles,
* - `false` to count only subscribed roles,
* - `null` to count all roles regardless of their unsubscription status.
* @param searchName an optional search term to filter the results by role name.
* @return the count of roles that match the specified criteria.
* @throws ApplicationManagementDAOException if there is an error while accessing the database or processing the request.
*/
int getSubscribedRoleCount(int appReleaseId, int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException;
/**
* This method is used to get the details of subscribed groups
@ -230,13 +269,33 @@ public interface SubscriptionDAO {
* @param offsetValue offset value for get paginated request.
* @param limitValue limit value for get paginated request.
* @param appReleaseId id of the application release.
* @param uninstalled a Boolean flag indicating the filter criteria for getting groups:
* - `true` to get only unsubscribed groups,
* - `false` to get only subscribed groups,
* - `null` to get all groups regardless of their unsubscription status.
* @param searchName an optional search term to filter the results by group name.
* @return subscribedGroups - list of app subscribed groups.
* @throws {@link ApplicationManagementDAOException} if connections establishment fails.
*/
List<String> getAppSubscribedGroups(int offsetValue, int limitValue, int appReleaseId, int tenantId)
List<String> getAppSubscribedGroups(int offsetValue, int limitValue, int appReleaseId, int tenantId,
Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException;
int getSubscribedGroupCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException;
/**
* This method is used to get the count of subscribed groups
*
* @param tenantId id of the current tenant
* @param appReleaseId id of the application release.
* @param uninstalled a Boolean flag indicating the filter criteria for counting groups:
* - `true` to count only unsubscribed groups,
* - `false` to count only subscribed groups,
* - `null` to count all groups regardless of their unsubscription status.
* @param searchName an optional search term to filter the results by group name.
* @return subscribedGroups - list of app subscribed groups.
* @throws {@link ApplicationManagementDAOException} if connections establishment fails.
*/
int getSubscribedGroupCount(int appReleaseId, int tenantId,Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException;
/**
* This method is used to get the details of subscribed groups

@ -2075,7 +2075,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
releaseVersionInfo = new ReleaseVersionInfo();
releaseVersionInfo.setVersion(resultSet.getString("VERSION"));
releaseVersionInfo.setReleaseType(resultSet.getString("RELEASE_TYPE"));
releaseVersionInfo.setRating(resultSet.getString("RATING"));
releaseVersionInfo.setRating(resultSet.getDouble("RATING"));
releaseVersionInfo.setState(resultSet.getString("CURRENT_STATE"));
releaseVersionInfo.setUuid(resultSet.getString("UUID"));
releaseVersionInfos.add(releaseVersionInfo);

@ -967,25 +967,37 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
@Override
public List<String> getAppSubscribedUsers(int offsetValue, int limitValue, int appReleaseId,
int tenantId)
int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get already subscribed users for " +
"given app release id.");
log.debug("Request received in DAO Layer to get subscribed/unsubscribed users for the given app release ID.");
}
try {
Connection conn = this.getDBConnection();
List<String> subscribedUsers = new ArrayList<>();
String sql = "SELECT "
+ "US.USER_NAME AS USER_NAME "
+ "FROM AP_USER_SUBSCRIPTION US "
+ "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?";
String sql = "SELECT US.USER_NAME AS USER_NAME " +
"FROM AP_USER_SUBSCRIPTION US " +
"WHERE AP_APP_RELEASE_ID = ? " +
"AND TENANT_ID = ? ";
if (uninstalled != null) {
sql += "AND UNSUBSCRIBED = ? ";
}
if (searchName != null && !searchName.trim().isEmpty()) {
sql += "AND US.USER_NAME LIKE ? ";
}
sql += "LIMIT ? OFFSET ?";
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, appReleaseId);
stmt.setInt(2, tenantId);
stmt.setInt(3, limitValue);
stmt.setInt(4, offsetValue);
int index = 1;
stmt.setInt(index++, appReleaseId);
stmt.setInt(index++, tenantId);
if (uninstalled != null) {
stmt.setBoolean(index++, uninstalled);
}
if (searchName != null && !searchName.trim().isEmpty()) {
stmt.setString(index++, "%" + searchName + "%");
}
stmt.setInt(index++, limitValue);
stmt.setInt(index, offsetValue);
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
subscribedUsers.add(rs.getString("USER_NAME"));
@ -994,50 +1006,62 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
return subscribedUsers;
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get already " +
"subscribed users for given app release id.";
String msg = "Error occurred while obtaining the DB connection to get subscribed/unsubscribed users for the " +
"given app release ID.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while getting subscribed users for given app release id.";
String msg = "SQL Error occurred while getting subscribed/unsubscribed users for the given app release ID.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public int getSubscribedUserCount(int appReleaseId, int tenantId)
public int getSubscribedUserCount(int appReleaseId, int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get already subscribed users for " +
log.debug("Request received in DAO Layer to get already subscribed/unsubscribed users for " +
"given app release id.");
}
try {
Connection conn = this.getDBConnection();
String sql = "SELECT "
+ "COUNT(US.USER_NAME) AS USER_NAME "
+ "FROM AP_USER_SUBSCRIPTION US "
+ "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ?";
String sql = "SELECT COUNT(US.USER_NAME) AS USER_COUNT " +
"FROM AP_USER_SUBSCRIPTION US " +
"WHERE AP_APP_RELEASE_ID = ? " +
"AND TENANT_ID = ?";
if (uninstalled != null) {
sql += " AND UNSUBSCRIBED = ?";
}
if (searchName != null && !searchName.trim().isEmpty()) {
sql += " AND US.USER_NAME LIKE ?";
}
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, appReleaseId);
stmt.setInt(2, tenantId);
int index = 1;
stmt.setInt(index++, appReleaseId);
stmt.setInt(index++, tenantId);
if (uninstalled != null) {
stmt.setBoolean(index++, uninstalled);
}
if (searchName != null && !searchName.trim().isEmpty()) {
stmt.setString(index++, "%" + searchName + "%");
}
try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
return rs.getInt("USER_NAME");
return rs.getInt("USER_COUNT");
}
}
return 0;
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get already " +
"subscribed users count for given app release id.";
"subscribed/unsubscribed users count for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while getting subscribed users for given app release id.";
String msg = "SQL Error occurred while getting subscribed/unsubscribed users count for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}
@ -1151,25 +1175,40 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
@Override
public List<String> getAppSubscribedRoles(int offsetValue, int limitValue, int appReleaseId,
int tenantId)
int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get already subscribed roles for " +
log.debug("Request received in DAO Layer to get already subscribed/unsubscribed roles for " +
"given app release id.");
}
try {
Connection conn = this.getDBConnection();
List<String> subscribedRoles = new ArrayList<>();
String sql = "SELECT "
+ "RS.ROLE_NAME AS ROLE "
+ "FROM AP_ROLE_SUBSCRIPTION RS "
+ "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?";
+ "RS.ROLE_NAME AS ROLE "
+ "FROM AP_ROLE_SUBSCRIPTION RS "
+ "WHERE AP_APP_RELEASE_ID = ? "
+ "AND TENANT_ID = ?";
if (uninstalled != null) {
sql += " AND UNSUBSCRIBED = ?";
}
if (searchName != null && !searchName.trim().isEmpty()) {
sql += " AND RS.ROLE_NAME LIKE ?";
}
sql += " LIMIT ? OFFSET ?";
try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, appReleaseId);
ps.setInt(2, tenantId);
ps.setInt(3, limitValue);
ps.setInt(4, offsetValue);
int paramIndex = 1;
ps.setInt(paramIndex++, appReleaseId);
ps.setInt(paramIndex++, tenantId);
if (uninstalled != null) {
ps.setBoolean(paramIndex++, uninstalled);
}
if (searchName != null && !searchName.trim().isEmpty()) {
ps.setString(paramIndex++, "%" + searchName + "%");
}
ps.setInt(paramIndex++, limitValue);
ps.setInt(paramIndex, offsetValue);
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
subscribedRoles.add(rs.getString("ROLE"));
@ -1179,49 +1218,61 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get already " +
"subscribed roles for given app release id.";
"subscribed/unsubscribed roles for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while getting subscribed roles for given app release id.";
String msg = "SQL Error occurred while getting subscribed/unsubscribed roles for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public int getSubscribedRoleCount(int appReleaseId, int tenantId)
public int getSubscribedRoleCount(int appReleaseId, int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get already subscribed roles for " +
log.debug("Request received in DAO Layer to get already subscribed/unsubscribed roles for " +
"given app release id.");
}
try {
Connection conn = this.getDBConnection();
String sql = "SELECT "
+ "COUNT(RS.ROLE_NAME) AS ROLE_NAME "
+ "FROM AP_ROLE_SUBSCRIPTION RS "
+ "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ?";
+ "COUNT(RS.ROLE_NAME) AS ROLE_COUNT "
+ "FROM AP_ROLE_SUBSCRIPTION RS "
+ "WHERE AP_APP_RELEASE_ID = ? "
+ "AND TENANT_ID = ?";
if (uninstalled != null) {
sql += " AND UNSUBSCRIBED = ?";
}
if (searchName != null && !searchName.trim().isEmpty()) {
sql += " AND RS.ROLE_NAME LIKE ?";
}
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, appReleaseId);
stmt.setInt(2, tenantId);
int paramIndex = 1;
stmt.setInt(paramIndex++, appReleaseId);
stmt.setInt(paramIndex++, tenantId);
if (uninstalled != null) {
stmt.setBoolean(paramIndex++, uninstalled);
}
if (searchName != null && !searchName.trim().isEmpty()) {
stmt.setString(paramIndex++, "%" + searchName + "%");
}
try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
return rs.getInt("ROLE_NAME");
return rs.getInt("ROLE_COUNT");
}
return 0;
}
return 0;
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get already " +
"subscribed roles count for given app release id.";
"subscribed/unsubscribed roles count for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while getting subscribed roles for given app release id.";
String msg = "SQL Error occurred while getting subscribed/unsubscribed roles count for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}
@ -1269,25 +1320,37 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
@Override
public List<String> getAppSubscribedGroups(int offsetValue, int limitValue, int appReleaseId,
int tenantId)
int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get already subscribed groups for " +
log.debug("Request received in DAO Layer to get already subscribed/unsubscribed groups for " +
"given app release id.");
}
try {
Connection conn = this.getDBConnection();
List<String> subscribedGroups = new ArrayList<>();
String sql = "SELECT "
+ "GS.GROUP_NAME AS APP_GROUPS "
+ "FROM AP_GROUP_SUBSCRIPTION GS "
+ "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?";
String sql = "SELECT GS.GROUP_NAME AS APP_GROUPS " +
"FROM AP_GROUP_SUBSCRIPTION GS " +
"WHERE AP_APP_RELEASE_ID = ? AND TENANT_ID = ?";
if (uninstalled != null) {
sql += " AND UNSUBSCRIBED = ?";
}
if (searchName != null && !searchName.trim().isEmpty()) {
sql += " AND GS.GROUP_NAME LIKE ?";
}
sql += " LIMIT ? OFFSET ?";
try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, appReleaseId);
ps.setInt(2, tenantId);
ps.setInt(3, limitValue);
ps.setInt(4, offsetValue);
int paramIndex = 1;
ps.setInt(paramIndex++, appReleaseId);
ps.setInt(paramIndex++, tenantId);
if (uninstalled != null) {
ps.setBoolean(paramIndex++, uninstalled);
}
if (searchName != null && !searchName.trim().isEmpty()) {
ps.setString(paramIndex++, "%" + searchName + "%");
}
ps.setInt(paramIndex++, limitValue);
ps.setInt(paramIndex, offsetValue);
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
subscribedGroups.add(rs.getString("APP_GROUPS"));
@ -1297,11 +1360,11 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get already " +
"subscribed groups for given app release id.";
"subscribed/unsubscribed groups for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while getting subscribed groups for given " +
String msg = "SQL Error occurred while getting subscribed/unsubscribed groups for given " +
"app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
@ -1309,24 +1372,34 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
}
@Override
public int getSubscribedGroupCount(int appReleaseId, int tenantId)
public int getSubscribedGroupCount(int appReleaseId, int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get already subscribed groups for " +
"given app release id.");
log.debug("Request received in DAO Layer to get the count of subscribed/unsubscribed groups for " +
"given app release id.");
}
try {
Connection conn = this.getDBConnection();
String sql = "SELECT "
+ "COUNT(GS.GROUP_NAME) AS APP_GROUPS_COUNT "
+ "FROM AP_GROUP_SUBSCRIPTION GS "
+ "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ?";
String sql = "SELECT COUNT(GS.GROUP_NAME) AS APP_GROUPS_COUNT " +
"FROM AP_GROUP_SUBSCRIPTION GS " +
"WHERE AP_APP_RELEASE_ID = ? AND TENANT_ID = ?";
if (uninstalled != null) {
sql += " AND UNSUBSCRIBED = ?";
}
if (searchName != null && !searchName.trim().isEmpty()) {
sql += " AND GS.GROUP_NAME LIKE ?";
}
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, appReleaseId);
stmt.setInt(2, tenantId);
int paramIndex = 1;
stmt.setInt(paramIndex++, appReleaseId);
stmt.setInt(paramIndex++, tenantId);
if (uninstalled != null) {
stmt.setBoolean(paramIndex++, uninstalled);
}
if (searchName != null && !searchName.trim().isEmpty()) {
stmt.setString(paramIndex++, "%" + searchName + "%");
}
try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
return rs.getInt("APP_GROUPS_COUNT");
@ -1335,12 +1408,13 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
return 0;
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get already " +
"subscribed groups count for given app release id.";
String msg = "Error occurred while obtaining the DB connection to get the count of " +
"subscribed/unsubscribed groups for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while getting subscribed groups for given app release id.";
String msg = "SQL Error occurred while getting the count of subscribed/unsubscribed groups for given " +
"app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}

@ -43,10 +43,10 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
@Override
public List<String> getAppSubscribedUsers(int offsetValue, int limitValue, int appReleaseId,
int tenantId)
int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get already subscribed users for " +
log.debug("Request received in DAO Layer to get already subscribed/unsubscribed users for " +
"given app release id.");
}
try {
@ -55,13 +55,28 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
String sql = "SELECT "
+ "US.USER_NAME AS USER "
+ "FROM AP_USER_SUBSCRIPTION US "
+ "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY US.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
+ "WHERE AP_APP_RELEASE_ID = ? "
+ "AND TENANT_ID = ? ";
if (uninstalled != null) {
sql += "AND UNSUBSCRIBED = ? ";
}
if (searchName != null && !searchName.trim().isEmpty()) {
sql += "AND US.USER_NAME LIKE ? ";
}
sql += "ORDER BY US.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, appReleaseId);
stmt.setInt(2, tenantId);
stmt.setInt(3, offsetValue);
stmt.setInt(4, limitValue);
int index = 1;
stmt.setInt(index++, appReleaseId);
stmt.setInt(index++, tenantId);
if (uninstalled != null) {
stmt.setBoolean(index++, uninstalled);
}
if (searchName != null && !searchName.trim().isEmpty()) {
stmt.setString(index++, "%" + searchName + "%");
}
stmt.setInt(index++, offsetValue);
stmt.setInt(index, limitValue);
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
subscribedUsers.add(rs.getString("USER"));
@ -71,11 +86,11 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get already " +
"subscribed users for given app release id.";
"subscribed/unsubscribed users for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while getting subscribed users for given app release id.";
String msg = "SQL Error occurred while getting subscribed/unsubscribed users for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}
@ -83,10 +98,10 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
@Override
public List<String> getAppSubscribedRoles(int offsetValue, int limitValue, int appReleaseId,
int tenantId)
int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get already subscribed roles for " +
log.debug("Request received in DAO Layer to get already subscribed/unsubscribed roles for " +
"given app release id.");
}
try {
@ -95,13 +110,27 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
String sql = "SELECT "
+ "RS.ROLE_NAME AS ROLE "
+ "FROM AP_ROLE_SUBSCRIPTION RS "
+ "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY RS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
+ "WHERE AP_APP_RELEASE_ID = ? "
+ "AND TENANT_ID = ? ";
if (uninstalled != null) {
sql += "AND UNSUBSCRIBED = ? ";
}
if (searchName != null && !searchName.trim().isEmpty()) {
sql += "AND RS.ROLE_NAME LIKE ? ";
}
sql += "ORDER BY RS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, appReleaseId);
ps.setInt(2, tenantId);
ps.setInt(3, offsetValue);
ps.setInt(4, limitValue);
int paramIndex = 1;
ps.setInt(paramIndex++, appReleaseId);
ps.setInt(paramIndex++, tenantId);
if (uninstalled != null) {
ps.setBoolean(paramIndex++, uninstalled);
}
if (searchName != null && !searchName.trim().isEmpty()) {
ps.setString(paramIndex++, "%" + searchName + "%");
}
ps.setInt(paramIndex++, offsetValue);
ps.setInt(paramIndex, limitValue);
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
subscribedRoles.add(rs.getString("ROLE"));
@ -111,11 +140,11 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get already " +
"subscribed roles for given app release id.";
"subscribed/unsubscribed roles for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while getting subscribed roles for given app release id.";
String msg = "SQL Error occurred while getting subscribed/unsubscribed roles for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}
@ -123,11 +152,10 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
@Override
public List<String> getAppSubscribedGroups(int offsetValue, int limitValue, int appReleaseId,
int tenantId)
int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get already subscribed groups for " +
"given app release id.");
log.debug("Request received in DAO Layer to get subscribed/unsubscribed groups for the given app release ID.");
}
try {
Connection conn = this.getDBConnection();
@ -135,13 +163,26 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
String sql = "SELECT "
+ "GS.GROUP_NAME AS GROUPS "
+ "FROM AP_GROUP_SUBSCRIPTION GS "
+ "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY GS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
+ "WHERE AP_APP_RELEASE_ID = ? AND TENANT_ID = ?";
if (uninstalled != null) {
sql += " AND UNSUBSCRIBED = ?";
}
if (searchName != null && !searchName.trim().isEmpty()) {
sql += " AND GS.GROUP_NAME LIKE ?";
}
sql += " ORDER BY GS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, appReleaseId);
ps.setInt(2, tenantId);
ps.setInt(3, offsetValue);
ps.setInt(4, limitValue);
int paramIndex = 1;
ps.setInt(paramIndex++, appReleaseId);
ps.setInt(paramIndex++, tenantId);
if (uninstalled != null) {
ps.setBoolean(paramIndex++, uninstalled);
}
if (searchName != null && !searchName.trim().isEmpty()) {
ps.setString(paramIndex++, "%" + searchName + "%");
}
ps.setInt(paramIndex++, offsetValue);
ps.setInt(paramIndex, limitValue);
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
subscribedGroups.add(rs.getString("GROUPS"));
@ -150,13 +191,12 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
return subscribedGroups;
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get already " +
"subscribed groups for given app release id.";
String msg = "Error occurred while obtaining the DB connection to get subscribed/unsubscribed groups" +
" for the given app release ID.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while getting subscribed groups for given " +
"app release id.";
String msg = "SQL Error occurred while getting subscribed/unsubscribed groups for the given app release ID.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}

@ -39,10 +39,10 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
@Override
public List<String> getAppSubscribedUsers(int offsetValue, int limitValue, int appReleaseId,
int tenantId)
int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get already subscribed users for " +
log.debug("Request received in DAO Layer to get already subscribed/unsubscribed users for " +
"given app release id.");
}
try {
@ -51,13 +51,28 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
String sql = "SELECT "
+ "US.USER_NAME AS USER_NAME "
+ "FROM AP_USER_SUBSCRIPTION US "
+ "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY US.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
+ "WHERE AP_APP_RELEASE_ID = ? "
+ "AND TENANT_ID = ? ";
if (uninstalled != null) {
sql += "AND UNSUBSCRIBED = ? ";
}
if (searchName != null && !searchName.trim().isEmpty()) {
sql += "AND US.USER_NAME LIKE ? ";
}
sql += "ORDER BY US.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, appReleaseId);
stmt.setInt(2, tenantId);
stmt.setInt(3, offsetValue);
stmt.setInt(4, limitValue);
int index = 1;
stmt.setInt(index++, appReleaseId);
stmt.setInt(index++, tenantId);
if (uninstalled != null) {
stmt.setBoolean(index++, uninstalled);
}
if (searchName != null && !searchName.trim().isEmpty()) {
stmt.setString(index++, "%" + searchName + "%");
}
stmt.setInt(index++, offsetValue);
stmt.setInt(index, limitValue);
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
subscribedUsers.add(rs.getString("USER_NAME"));
@ -67,11 +82,11 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get already " +
"subscribed users for given app release id.";
"subscribed/unsubscribed users for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while getting subscribed users for given app release id.";
String msg = "SQL Error occurred while getting subscribed/unsubscribed users for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}
@ -79,10 +94,10 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
@Override
public List<String> getAppSubscribedRoles(int offsetValue, int limitValue, int appReleaseId,
int tenantId)
int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get already subscribed roles for " +
log.debug("Request received in DAO Layer to get already subscribed/unsubscribed roles for " +
"given app release id.");
}
try {
@ -91,13 +106,29 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
String sql = "SELECT "
+ "RS.ROLE_NAME AS ROLE "
+ "FROM AP_ROLE_SUBSCRIPTION RS "
+ "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY RS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
+ "WHERE AP_APP_RELEASE_ID = ? "
+ "AND TENANT_ID = ? ";
if (uninstalled != null) {
sql += "AND UNSUBSCRIBED = ? ";
}
if (searchName != null && !searchName.trim().isEmpty()) {
sql += "AND RS.ROLE_NAME LIKE ? ";
}
sql += "ORDER BY RS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, appReleaseId);
ps.setInt(2, tenantId);
ps.setInt(3, offsetValue);
ps.setInt(4, limitValue);
int paramIndex = 1;
ps.setInt(paramIndex++, appReleaseId);
ps.setInt(paramIndex++, tenantId);
if (uninstalled != null) {
ps.setBoolean(paramIndex++, uninstalled);
}
if (searchName != null && !searchName.trim().isEmpty()) {
ps.setString(paramIndex++, "%" + searchName + "%");
}
ps.setInt(paramIndex++, offsetValue);
ps.setInt(paramIndex, limitValue);
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
subscribedRoles.add(rs.getString("ROLE"));
@ -107,11 +138,11 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get already " +
"subscribed roles for given app release id.";
"subscribed/unsubscribed roles for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while getting subscribed roles for given app release id.";
String msg = "SQL Error occurred while getting subscribed/unsubscribed roles for given app release id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}
@ -119,11 +150,10 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
@Override
public List<String> getAppSubscribedGroups(int offsetValue, int limitValue, int appReleaseId,
int tenantId)
int tenantId, Boolean uninstalled, String searchName)
throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get already subscribed groups for " +
"given app release id.");
log.debug("Request received in DAO Layer to get subscribed/unsubscribed groups for the given app release ID.");
}
try {
Connection conn = this.getDBConnection();
@ -131,13 +161,26 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
String sql = "SELECT "
+ "GS.GROUP_NAME AS GROUPS "
+ "FROM AP_GROUP_SUBSCRIPTION GS "
+ "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY GS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
+ "WHERE AP_APP_RELEASE_ID = ? AND TENANT_ID = ?";
if (uninstalled != null) {
sql += " AND UNSUBSCRIBED = ?";
}
if (searchName != null && !searchName.trim().isEmpty()) {
sql += " AND GS.GROUP_NAME LIKE ?";
}
sql += " ORDER BY GS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, appReleaseId);
ps.setInt(2, tenantId);
ps.setInt(3, offsetValue);
ps.setInt(4, limitValue);
int paramIndex = 1;
ps.setInt(paramIndex++, appReleaseId);
ps.setInt(paramIndex++, tenantId);
if (uninstalled != null) {
ps.setBoolean(paramIndex++, uninstalled);
}
if (searchName != null && !searchName.trim().isEmpty()) {
ps.setString(paramIndex++, "%" + searchName + "%");
}
ps.setInt(paramIndex++, offsetValue);
ps.setInt(paramIndex, limitValue);
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
subscribedGroups.add(rs.getString("GROUPS"));
@ -146,13 +189,11 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
return subscribedGroups;
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get already " +
"subscribed groups for given app release id.";
String msg = "Error occurred while obtaining the DB connection to get subscribed/unsubscribed groups for the given app release ID.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while getting subscribed groups for given " +
"app release id.";
String msg = "SQL Error occurred while getting subscribed/unsubscribed groups for the given app release ID.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}

@ -1498,7 +1498,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
}
@Override
public PaginationResult getAppInstalledSubscribers(int offsetValue, int limitValue, String appUUID, String subType)
public PaginationResult getAppInstalledSubscribers(int offsetValue, int limitValue, String appUUID, String subType,
Boolean uninstalled, String searchName)
throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
@ -1513,20 +1514,16 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
if (SubscriptionType.USER.toString().equalsIgnoreCase(subType)) {
subscriptionList = subscriptionDAO
.getAppSubscribedUsers(offsetValue, limitValue, applicationReleaseId, tenantId);
count = subscriptionDAO.getSubscribedUserCount(applicationReleaseId, tenantId);
} else {
if (SubscriptionType.ROLE.toString().equalsIgnoreCase(subType)) {
subscriptionList = subscriptionDAO
.getAppSubscribedRoles(offsetValue, limitValue, applicationReleaseId, tenantId);
count = subscriptionDAO.getSubscribedRoleCount(applicationReleaseId, tenantId);
} else {
if (SubscriptionType.GROUP.toString().equalsIgnoreCase(subType)) {
subscriptionList = subscriptionDAO
.getAppSubscribedGroups(offsetValue, limitValue, applicationReleaseId, tenantId);
count = subscriptionDAO.getSubscribedGroupCount(applicationReleaseId, tenantId);
}
}
.getAppSubscribedUsers(offsetValue, limitValue, applicationReleaseId, tenantId, uninstalled, searchName);
count = subscriptionDAO.getSubscribedUserCount(applicationReleaseId, tenantId, uninstalled, searchName);
} else if (SubscriptionType.ROLE.toString().equalsIgnoreCase(subType)) {
subscriptionList = subscriptionDAO
.getAppSubscribedRoles(offsetValue, limitValue, applicationReleaseId, tenantId, uninstalled, searchName);
count = subscriptionDAO.getSubscribedRoleCount(applicationReleaseId, tenantId, uninstalled, searchName);
} else if (SubscriptionType.GROUP.toString().equalsIgnoreCase(subType)) {
subscriptionList = subscriptionDAO
.getAppSubscribedGroups(offsetValue, limitValue, applicationReleaseId, tenantId, uninstalled, searchName);
count = subscriptionDAO.getSubscribedGroupCount(applicationReleaseId, tenantId, uninstalled, searchName);
}
paginationResult.setData(subscriptionList);

@ -1365,7 +1365,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
query += " AND i.VALUE_FIELD LIKE ?" ;
}
if (user != null && !user.isEmpty()) {
query += " AND e.OWNER = ?";
query += " AND e.OWNER LIKE ?";
isOwnerProvided = true;
}
if (status != null && !status.isEmpty()) {
@ -1395,7 +1395,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString());
ps.setString(index++, EnrolmentInfo.Status.DELETED.toString());
if (isDeviceNameProvided) {
ps.setString(index++, name + "%");
ps.setString(index++, "%" + name + "%");
}
if (isOwnershipProvided) {
ps.setString(index++, ownership);
@ -1404,7 +1404,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
ps.setString(index++, "%" + serial + "%");
}
if (isOwnerProvided) {
ps.setString(index++, user);
ps.setString(index++, "%" + user + "%");
}
if (isStatusProvided) {
for (String deviceStatus : status) {

@ -1105,7 +1105,7 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl {
isOwnershipProvided = true;
}
if (user != null && !user.isEmpty()) {
query += " AND e.OWNER = ?";
query += " AND e.OWNER LIKE ?";
isOwnerProvided = true;
}
if (status != null && !status.isEmpty()) {
@ -1136,13 +1136,13 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl {
ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString());
ps.setString(index++, EnrolmentInfo.Status.DELETED.toString());
if (isDeviceNameProvided) {
ps.setString(index++, name + "%");
ps.setString(index++, "%" + name + "%");
}
if (isOwnershipProvided) {
ps.setString(index++, ownership);
}
if (isOwnerProvided) {
ps.setString(index++, user);
ps.setString(index++, "%" + user + "%");
}
if (isStatusProvided) {
for (String deviceStatus : status) {

@ -977,7 +977,7 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl {
isOwnershipProvided = true;
}
if (user != null && !user.isEmpty()) {
query += " AND e.OWNER = ?";
query += " AND e.OWNER LIKE ?";
isOwnerProvided = true;
}
if (status != null && !status.isEmpty()) {
@ -1008,13 +1008,13 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl {
ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString());
ps.setString(index++, EnrolmentInfo.Status.DELETED.toString());
if (isDeviceNameProvided) {
ps.setString(index++, name + "%");
ps.setString(index++, "%" + name + "%");
}
if (isOwnershipProvided) {
ps.setString(index++, ownership);
}
if (isOwnerProvided) {
ps.setString(index++, user);
ps.setString(index++, "%" + user + "%");
}
if (isStatusProvided) {
for (String deviceStatus : status) {

@ -672,7 +672,7 @@ CREATE TABLE IF NOT EXISTS DM_METADATA (
-- DM_TAG TABLE --
CREATE TABLE IF NOT EXISTS DM_TAG (
ID BIGINT AUTO_INCREMENT,
ID INTEGER AUTO_INCREMENT,
NAME VARCHAR(255) NOT NULL,
DESCRIPTION VARCHAR(255) NULL,
TENANT_ID INTEGER NOT NULL,
@ -683,8 +683,8 @@ CREATE TABLE IF NOT EXISTS DM_TAG (
-- DM_DEVICE_TAG_MAPPING TABLE --
CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING (
ENROLMENT_ID BIGINT NOT NULL,
TAG_ID BIGINT NOT NULL,
ENROLMENT_ID INTEGER NOT NULL,
TAG_ID INTEGER NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID),
FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID),

@ -878,7 +878,7 @@ CREATE TABLE IF NOT EXISTS DM_CEA_POLICIES (
-- DM_TAG TABLE --
CREATE TABLE IF NOT EXISTS DM_TAG (
ID BIGINT AUTO_INCREMENT,
ID INTEGER AUTO_INCREMENT,
NAME VARCHAR(255) NOT NULL,
DESCRIPTION VARCHAR(255) NULL,
TENANT_ID INTEGER NOT NULL,
@ -889,8 +889,8 @@ CREATE TABLE IF NOT EXISTS DM_TAG (
-- DM_DEVICE_TAG_MAPPING TABLE --
CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING (
ENROLMENT_ID BIGINT NOT NULL,
TAG_ID BIGINT NOT NULL,
ENROLMENT_ID INTEGER NOT NULL,
TAG_ID INTEGER NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID),
FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID),

@ -954,19 +954,19 @@ END;
-- DM_TAG TABLE --
CREATE TABLE IF NOT EXISTS DM_TAG (
ID BIGINT IDENTITY(1,1) PRIMARY KEY,
ID INTEGER IDENTITY(1,1) PRIMARY KEY,
NAME NVARCHAR(255) NOT NULL,
DESCRIPTION NVARCHAR(255) NULL,
TENANT_ID INT NOT NULL,
TENANT_ID INTEGER NOT NULL,
CONSTRAINT DM_TAG_NAME_TENANT_UNIQUE UNIQUE (NAME, TENANT_ID)
);
-- END OF DM_TAG TABLE --
-- DM_DEVICE_TAG_MAPPING TABLE --
CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING (
ENROLMENT_ID BIGINT NOT NULL,
TAG_ID BIGINT NOT NULL,
TENANT_ID INT NOT NULL,
ENROLMENT_ID INTEGER NOT NULL,
TAG_ID INTEGER NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID),
FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID),
FOREIGN KEY (TAG_ID) REFERENCES DM_TAG(ID) ON DELETE CASCADE

@ -953,19 +953,19 @@ CREATE TABLE IF NOT EXISTS DM_CEA_POLICIES (
-- DM_TAG TABLE --
CREATE TABLE IF NOT EXISTS DM_TAG (
ID BIGINT AUTO_INCREMENT PRIMARY KEY,
ID INTEGER AUTO_INCREMENT PRIMARY KEY,
NAME VARCHAR(255) NOT NULL,
DESCRIPTION VARCHAR(255) NULL,
TENANT_ID INT NOT NULL,
TENANT_ID INTEGER NOT NULL,
CONSTRAINT DM_TAG_NAME_TENANT_UNIQUE UNIQUE (NAME, TENANT_ID)
);
-- END OF DM_TAG TABLE --
-- DM_DEVICE_TAG_MAPPING TABLE --
CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING (
ENROLMENT_ID BIGINT NOT NULL,
TAG_ID BIGINT NOT NULL,
TENANT_ID INT NOT NULL,
ENROLMENT_ID INTEGER NOT NULL,
TAG_ID INTEGER NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID),
FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID),
FOREIGN KEY (TAG_ID) REFERENCES DM_TAG(ID) ON DELETE CASCADE

@ -1258,7 +1258,7 @@ END;
-- DM_TAG TABLE --
CREATE TABLE DM_TAG (
ID NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY PRIMARY KEY,
ID NUMBER(10) GENERATED BY DEFAULT ON NULL AS IDENTITY PRIMARY KEY,
NAME VARCHAR2(255) NOT NULL,
DESCRIPTION VARCHAR2(255) NULL,
TENANT_ID NUMBER(10) NOT NULL,
@ -1268,8 +1268,8 @@ CREATE TABLE DM_TAG (
-- DM_DEVICE_TAG_MAPPING TABLE --
CREATE TABLE DM_DEVICE_TAG_MAPPING (
ENROLMENT_ID NUMBER(19) NOT NULL,
TAG_ID NUMBER(19) NOT NULL,
ENROLMENT_ID NUMBER(10) NOT NULL,
TAG_ID NUMBER(10) NOT NULL,
TENANT_ID NUMBER(10) NOT NULL,
PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID),
FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID),

@ -884,7 +884,7 @@ CREATE TABLE IF NOT EXISTS DM_CEA_POLICIES (
-- DM_TAG TABLE --
CREATE TABLE IF NOT EXISTS DM_TAG (
ID BIGSERIAL PRIMARY KEY,
ID INTEGER PRIMARY KEY,
NAME VARCHAR(255) NOT NULL,
DESCRIPTION VARCHAR(255) NULL,
TENANT_ID INTEGER NOT NULL,
@ -894,8 +894,8 @@ CREATE TABLE IF NOT EXISTS DM_TAG (
-- DM_DEVICE_TAG_MAPPING TABLE --
CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING (
ENROLMENT_ID BIGINT NOT NULL,
TAG_ID BIGINT NOT NULL,
ENROLMENT_ID INTEGER NOT NULL,
TAG_ID INTEGER NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID),
FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID),

Loading…
Cancel
Save