|
|
@ -48,24 +48,27 @@ public class GenericPolicyDAOImpl extends AbstractPolicyDAOImpl {
|
|
|
|
String name = request.getName();
|
|
|
|
String name = request.getName();
|
|
|
|
String type = request.getType();
|
|
|
|
String type = request.getType();
|
|
|
|
String status = request.getStatus();
|
|
|
|
String status = request.getStatus();
|
|
|
|
|
|
|
|
String deviceType = request.getDeviceType();
|
|
|
|
int statusValue = 0;
|
|
|
|
int statusValue = 0;
|
|
|
|
boolean isPolicyNameProvided = false;
|
|
|
|
boolean isPolicyNameProvided = false;
|
|
|
|
boolean isPolicyTypeProvided = false;
|
|
|
|
boolean isPolicyTypeProvided = false;
|
|
|
|
boolean isPolicyStatusProvided = false;
|
|
|
|
boolean isPolicyStatusProvided = false;
|
|
|
|
|
|
|
|
boolean isDeviceTypeProvided = false;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String query = "SELECT * " +
|
|
|
|
String query = "SELECT * " +
|
|
|
|
"FROM DM_POLICY " +
|
|
|
|
"FROM DM_POLICY P " +
|
|
|
|
"WHERE TENANT_ID = ? ";
|
|
|
|
"LEFT JOIN DM_PROFILE PR ON P.PROFILE_ID = PR.ID " +
|
|
|
|
|
|
|
|
"WHERE P.TENANT_ID = ? ";
|
|
|
|
|
|
|
|
|
|
|
|
if (name != null && !name.isEmpty()) {
|
|
|
|
if (name != null && !name.isEmpty()) {
|
|
|
|
query += "AND NAME LIKE ? " ;
|
|
|
|
query += "AND P.NAME LIKE ? " ;
|
|
|
|
isPolicyNameProvided = true;
|
|
|
|
isPolicyNameProvided = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (type != null && !type.isEmpty()) {
|
|
|
|
if (type != null && !type.isEmpty()) {
|
|
|
|
query += "AND POLICY_TYPE = ? " ;
|
|
|
|
query += "AND P.POLICY_TYPE = ? " ;
|
|
|
|
isPolicyTypeProvided = true;
|
|
|
|
isPolicyTypeProvided = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -73,11 +76,16 @@ public class GenericPolicyDAOImpl extends AbstractPolicyDAOImpl {
|
|
|
|
if (status.equals("ACTIVE")) {
|
|
|
|
if (status.equals("ACTIVE")) {
|
|
|
|
statusValue = 1;
|
|
|
|
statusValue = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
query += "AND ACTIVE = ? " ;
|
|
|
|
query += "AND P.ACTIVE = ? " ;
|
|
|
|
isPolicyStatusProvided = true;
|
|
|
|
isPolicyStatusProvided = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
query += "ORDER BY ID LIMIT ?,?";
|
|
|
|
if (deviceType != null && !deviceType.isEmpty()) {
|
|
|
|
|
|
|
|
query += "AND PR.DEVICE_TYPE = ? ";
|
|
|
|
|
|
|
|
isDeviceTypeProvided = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query += "ORDER BY P.ID LIMIT ?,?";
|
|
|
|
|
|
|
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(query)) {
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(query)) {
|
|
|
|
int paramIdx = 1;
|
|
|
|
int paramIdx = 1;
|
|
|
@ -91,10 +99,13 @@ public class GenericPolicyDAOImpl extends AbstractPolicyDAOImpl {
|
|
|
|
if (isPolicyStatusProvided) {
|
|
|
|
if (isPolicyStatusProvided) {
|
|
|
|
stmt.setInt(paramIdx++, statusValue);
|
|
|
|
stmt.setInt(paramIdx++, statusValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isDeviceTypeProvided) {
|
|
|
|
|
|
|
|
stmt.setString(paramIdx++, deviceType);
|
|
|
|
|
|
|
|
}
|
|
|
|
stmt.setInt(paramIdx++, request.getStartIndex());
|
|
|
|
stmt.setInt(paramIdx++, request.getStartIndex());
|
|
|
|
stmt.setInt(paramIdx++, request.getRowCount());
|
|
|
|
stmt.setInt(paramIdx++, request.getRowCount());
|
|
|
|
try (ResultSet resultSet = stmt.executeQuery()) {
|
|
|
|
try (ResultSet resultSet = stmt.executeQuery()) {
|
|
|
|
return this.extractPolicyListFromDbResult(resultSet, tenantId);
|
|
|
|
return this.extractPolicyListWithProfileFromDbResult(resultSet, tenantId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|