|
|
@ -66,12 +66,12 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
stmt = conn.prepareStatement("INSERT INTO AP_APP (NAME, TYPE, APP_CATEGORY, "
|
|
|
|
stmt = conn.prepareStatement("INSERT INTO AP_APP (NAME, TYPE, APP_CATEGORY, "
|
|
|
|
+ "IS_FREE, PAYMENT_CURRENCY, RESTRICTED, TENANT_ID) VALUES "
|
|
|
|
+ "SUB_TYPE, PAYMENT_CURRENCY, RESTRICTED, TENANT_ID) VALUES "
|
|
|
|
+ "(?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
|
|
|
|
+ "(?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
|
|
|
|
stmt.setString(1, application.getName());
|
|
|
|
stmt.setString(1, application.getName());
|
|
|
|
stmt.setString(2, application.getType());
|
|
|
|
stmt.setString(2, application.getType());
|
|
|
|
stmt.setString(3, application.getAppCategory());
|
|
|
|
stmt.setString(3, application.getAppCategory());
|
|
|
|
stmt.setInt(4, application.getIsFree());
|
|
|
|
stmt.setString(4, application.getSubType());
|
|
|
|
stmt.setString(5, application.getPaymentCurrency());
|
|
|
|
stmt.setString(5, application.getPaymentCurrency());
|
|
|
|
stmt.setInt(6, application.getIsRestricted());
|
|
|
|
stmt.setInt(6, application.getIsRestricted());
|
|
|
|
stmt.setInt(7, application.getUser().getTenantId());
|
|
|
|
stmt.setInt(7, application.getUser().getTenantId());
|
|
|
@ -133,7 +133,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
log.debug("Getting application data from the database");
|
|
|
|
log.debug("Getting application data from the database");
|
|
|
|
log.debug(String.format("Filter: limit=%s, offset=%s", filter.getLimit(), filter.getOffset()));
|
|
|
|
log.debug(String.format("Filter: limit=%s, offset=%s", filter.getLimit(), filter.getOffset()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int paramIndex = 1;
|
|
|
|
Connection conn;
|
|
|
|
Connection conn;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
ResultSet rs = null;
|
|
|
@ -141,8 +141,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
Pagination pagination = new Pagination();
|
|
|
|
Pagination pagination = new Pagination();
|
|
|
|
String sql = "SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY"
|
|
|
|
String sql = "SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY"
|
|
|
|
+
|
|
|
|
+
|
|
|
|
" AS APP_CATEGORY, AP_APP.IS_FREE, AP_APP.RESTRICTED, AP_APP_TAG.TAG AS APP_TAG, " +
|
|
|
|
" AS APP_CATEGORY, AP_APP.SUB_TYPE AS SUB_TYPE, AP_APP.CURRENCY AS CURRENCY, "
|
|
|
|
"AP_UNRESTRICTED_ROLES.ROLE "
|
|
|
|
+ "AP_APP.RESTRICTED, AP_APP_TAG.TAG AS APP_TAG, AP_UNRESTRICTED_ROLES.ROLE "
|
|
|
|
+ "AS APP_UNRESTRICTED_ROLES FROM ((AP_APP LEFT JOIN AP_APP_TAG ON AP_APP.ID = AP_APP_TAG.AP_APP_ID) "
|
|
|
|
+ "AS APP_UNRESTRICTED_ROLES FROM ((AP_APP LEFT JOIN AP_APP_TAG ON AP_APP.ID = AP_APP_TAG.AP_APP_ID) "
|
|
|
|
+ "LEFT JOIN AP_UNRESTRICTED_ROLES ON AP_APP.ID = AP_UNRESTRICTED_ROLES.AP_APP_ID) "
|
|
|
|
+ "LEFT JOIN AP_UNRESTRICTED_ROLES ON AP_APP.ID = AP_UNRESTRICTED_ROLES.AP_APP_ID) "
|
|
|
|
+ "WHERE AP_APP.TENANT_ID = ? AND AP_APP.STATUS != ?";
|
|
|
|
+ "WHERE AP_APP.TENANT_ID = ? AND AP_APP.STATUS != ?";
|
|
|
@ -165,7 +165,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sql += " LIMIT ? OFFSET ? ORDER BY " + filter.getSortBy() + " APP_ID";
|
|
|
|
sql += " LIMIT ? OFFSET ? ORDER BY " + filter.getSortBy() + " APP_ID;";
|
|
|
|
|
|
|
|
|
|
|
|
pagination.setLimit(filter.getLimit());
|
|
|
|
pagination.setLimit(filter.getLimit());
|
|
|
|
pagination.setOffset(filter.getOffset());
|
|
|
|
pagination.setOffset(filter.getOffset());
|
|
|
@ -173,22 +173,22 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
stmt.setInt(paramIndex, tenantId);
|
|
|
|
stmt.setString(2, AppLifecycleState.REMOVED.toString());
|
|
|
|
stmt.setString(paramIndex++, AppLifecycleState.REMOVED.toString());
|
|
|
|
|
|
|
|
|
|
|
|
if (filter.getAppType() != null) {
|
|
|
|
if (filter.getAppType() != null) {
|
|
|
|
stmt.setString(3, filter.getAppType());
|
|
|
|
stmt.setString(paramIndex++, filter.getAppType());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filter.getAppName() != null) {
|
|
|
|
if (filter.getAppName() != null) {
|
|
|
|
if (filter.isFullMatch()) {
|
|
|
|
if (filter.isFullMatch()) {
|
|
|
|
stmt.setString(4, filter.getAppName().toLowerCase());
|
|
|
|
stmt.setString(paramIndex++, filter.getAppName().toLowerCase());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
stmt.setString(4, "%" + filter.getAppName().toLowerCase() + "%");
|
|
|
|
stmt.setString(paramIndex++, "%" + filter.getAppName().toLowerCase() + "%");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stmt.setInt(5, filter.getLimit());
|
|
|
|
stmt.setInt(paramIndex++, filter.getLimit());
|
|
|
|
stmt.setInt(6, filter.getOffset());
|
|
|
|
stmt.setInt(paramIndex, filter.getOffset());
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
applicationList.setApplications(Util.loadApplications(rs));
|
|
|
|
applicationList.setApplications(Util.loadApplications(rs));
|
|
|
|
applicationList.setPagination(pagination);
|
|
|
|
applicationList.setPagination(pagination);
|
|
|
@ -251,7 +251,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
log.debug("Getting application count from the database");
|
|
|
|
log.debug("Getting application count from the database");
|
|
|
|
log.debug(String.format("Filter: limit=%s, offset=%s", filter.getLimit(), filter.getOffset()));
|
|
|
|
log.debug(String.format("Filter: limit=%s, offset=%s", filter.getLimit(), filter.getOffset()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int paramIndex = 1;
|
|
|
|
Connection conn;
|
|
|
|
Connection conn;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
ResultSet rs = null;
|
|
|
@ -272,9 +272,9 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
sql += ";";
|
|
|
|
sql += ";";
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setInt(1, tenantId);
|
|
|
|
stmt.setInt(paramIndex++, tenantId);
|
|
|
|
if (filter.getAppName() != null) {
|
|
|
|
if (filter.getAppName() != null) {
|
|
|
|
stmt.setString(2, "%" + filter.getAppName().toLowerCase() + "%");
|
|
|
|
stmt.setString(paramIndex, "%" + filter.getAppName().toLowerCase() + "%");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
if (rs.next()) {
|
|
|
|
if (rs.next()) {
|
|
|
@ -304,9 +304,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
String sql =
|
|
|
|
String sql =
|
|
|
|
"SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY "
|
|
|
|
"SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY "
|
|
|
|
+ "AS APP_CATEGORY, AP_APP.IS_FREE AS IS_FREE, AP_APP.RESTRICTED AS RESTRICTED, " +
|
|
|
|
+ "AS APP_CATEGORY, AP_APP.SUB_TYPE AS SUB_TYPE ,AP_APP.CURRENCY AS CURRENCY,"
|
|
|
|
"AP_APP_TAG.TAG AS APP_TAG, AP_UNRESTRICTED_ROLES.ROLE AS ROLE FROM AP_APP, AP_APP_TAG, " +
|
|
|
|
+ " AP_APP.RESTRICTED AS RESTRICTED, AP_APP_TAG.TAG AS APP_TAG, AP_UNRESTRICTED_ROLES.ROLE "
|
|
|
|
"AP_UNRESTRICTED_ROLES WHERE AP_APP.NAME=? AND AP_APP.TYPE= ? AND AP_APP.TENANT_ID=?;";
|
|
|
|
+ "AS ROLE FROM AP_APP, AP_APP_TAG, AP_UNRESTRICTED_ROLES WHERE AP_APP.NAME=? AND "
|
|
|
|
|
|
|
|
+ "AP_APP.TYPE= ? AND AP_APP.TENANT_ID=?;";
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setString(1, appName);
|
|
|
|
stmt.setString(1, appName);
|
|
|
@ -347,9 +348,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
String sql =
|
|
|
|
String sql =
|
|
|
|
"SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY "
|
|
|
|
"SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY "
|
|
|
|
+ "AS APP_CATEGORY, AP_APP.IS_FREE AS IS_FREE, AP_APP.RESTRICTED AS RESTRICTED, AP_APP_TAG"
|
|
|
|
+ "AS APP_CATEGORY, AP_APP.SUB_TYPE AS SUB_TYPE ,AP_APP.CURRENCY AS CURRENCY, "
|
|
|
|
+ ".TAG AS APP_TAG, AP_UNRESTRICTED_ROLES.ROLE AS ROLE FROM AP_APP, AP_APP_TAG, " +
|
|
|
|
+ "AP_APP.RESTRICTED AS RESTRICTED, AP_APP_TAG.TAG AS APP_TAG, AP_UNRESTRICTED_ROLES.ROLE "
|
|
|
|
"AP_UNRESTRICTED_ROLES WHERE AP_APP.ID=? AND AP_APP.TENANT_ID=?;";
|
|
|
|
+ "AS ROLE FROM AP_APP, AP_APP_TAG, AP_UNRESTRICTED_ROLES WHERE AP_APP.ID=? AND "
|
|
|
|
|
|
|
|
+ "AP_APP.TENANT_ID=?;";
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setInt(1, applicationId);
|
|
|
|
stmt.setInt(1, applicationId);
|
|
|
@ -389,8 +391,9 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
String sql =
|
|
|
|
String sql =
|
|
|
|
"SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY "
|
|
|
|
"SELECT AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, AP_APP.APP_CATEGORY "
|
|
|
|
+ "AS APP_CATEGORY, AP_APP.IS_FREE, AP_APP_TAG.TAG, AP_UNRESTRICTED_ROLES.ROLE AS RELESE_ID"
|
|
|
|
+ "AS APP_CATEGORY, AP_APP.SUB_TYPE AS SUB_TYPE, AP_APP_TAG.TAG AS TAG, "
|
|
|
|
+ " FROM AP_APP, AP_APP_TAG, AP_UNRESTRICTED_ROLES WHERE AP_APP.ID = ?;";
|
|
|
|
+ "AP_UNRESTRICTED_ROLES.ROLE AS ROLE FROM AP_APP, AP_APP_TAG, AP_UNRESTRICTED_ROLES "
|
|
|
|
|
|
|
|
+ "WHERE AP_APP.ID = ?;";
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setInt(1, appId);
|
|
|
|
stmt.setInt(1, appId);
|
|
|
@ -419,6 +422,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Application editApplication(Application application, int tenantId) throws ApplicationManagementException {
|
|
|
|
public Application editApplication(Application application, int tenantId) throws ApplicationManagementException {
|
|
|
|
|
|
|
|
int paramIndex = 1;
|
|
|
|
Connection conn;
|
|
|
|
Connection conn;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
Application existingApplication = this.getApplication(application.getName(), application.getType(), tenantId);
|
|
|
|
Application existingApplication = this.getApplication(application.getName(), application.getType(), tenantId);
|
|
|
@ -443,31 +447,30 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
if (application.getIsRestricted() != existingApplication.getIsRestricted()) {
|
|
|
|
if (application.getIsRestricted() != existingApplication.getIsRestricted()) {
|
|
|
|
sql += "RESTRICTED = ? ";
|
|
|
|
sql += "RESTRICTED = ? ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (application.getIsFree() != existingApplication.getIsFree()) {
|
|
|
|
if (!application.getSubType().equals(existingApplication.getSubType())) {
|
|
|
|
sql += "IS_FREE = ? ";
|
|
|
|
sql += "SUB_TYPE = ? ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sql += "WHERE ID = ?";
|
|
|
|
sql += "WHERE ID = ?";
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
if (application.getName() != null && !application.getName().equals(existingApplication.getName())) {
|
|
|
|
if (application.getName() != null && !application.getName().equals(existingApplication.getName())) {
|
|
|
|
stmt.setString(1, application.getName());
|
|
|
|
stmt.setString(paramIndex++, application.getName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (application.getType() != null && !application.getType().equals(existingApplication.getType())) {
|
|
|
|
if (application.getType() != null && !application.getType().equals(existingApplication.getType())) {
|
|
|
|
stmt.setString(2, application.getType());
|
|
|
|
stmt.setString(paramIndex++, application.getType());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (application.getAppCategory() != null && !application.getAppCategory().equals(
|
|
|
|
if (application.getAppCategory() != null && !application.getAppCategory().equals(
|
|
|
|
existingApplication.getAppCategory())) {
|
|
|
|
existingApplication.getAppCategory())) {
|
|
|
|
stmt.setString(3, application.getAppCategory());
|
|
|
|
stmt.setString(paramIndex++, application.getAppCategory());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (application.getIsRestricted() != existingApplication.getIsRestricted()) {
|
|
|
|
if (application.getIsRestricted() != existingApplication.getIsRestricted()) {
|
|
|
|
stmt.setInt(4, application.getIsRestricted());
|
|
|
|
stmt.setInt(paramIndex++, application.getIsRestricted());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (application.getIsFree() != existingApplication.getIsFree()) {
|
|
|
|
if (!application.getSubType().equals(existingApplication.getSubType())) {
|
|
|
|
stmt.setInt(5, application.getIsFree());
|
|
|
|
stmt.setString(paramIndex++, application.getSubType());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stmt.setInt(paramIndex, application.getId());
|
|
|
|
stmt.setInt(6, application.getId());
|
|
|
|
|
|
|
|
stmt.executeUpdate();
|
|
|
|
stmt.executeUpdate();
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
@ -580,8 +583,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
+ "AP_APP_RELEASE.CREATED_AT, AP_APP_RELEASE.PUBLISHED_BY, AP_APP_RELEASE.PUBLISHED_AT, "
|
|
|
|
+ "AP_APP_RELEASE.CREATED_AT, AP_APP_RELEASE.PUBLISHED_BY, AP_APP_RELEASE.PUBLISHED_AT, "
|
|
|
|
+ "AP_APP_RELEASE.STARS,"
|
|
|
|
+ "AP_APP_RELEASE.STARS,"
|
|
|
|
+ "AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, "
|
|
|
|
+ "AP_APP.ID AS APP_ID, AP_APP.NAME AS APP_NAME, AP_APP.TYPE AS APP_TYPE, "
|
|
|
|
+ "AP_APP.APP_CATEGORY AS APP_CATEGORY, AP_APP.IS_FREE, AP_UNRESTRICTED_ROLES.ROLE AS ROLE "
|
|
|
|
+ "AP_APP.APP_CATEGORY AS APP_CATEGORY, AP_APP.SUB_TYPE AS SUB_TYPE, AP_APP.CURRENCY AS CURRENCY, "
|
|
|
|
+ "FROM AP_APP, AP_UNRESTRICTED_ROLES, AP_APP_RELEASE "
|
|
|
|
+ "AP_UNRESTRICTED_ROLES.ROLE AS ROLE FROM AP_APP, AP_UNRESTRICTED_ROLES, AP_APP_RELEASE "
|
|
|
|
+ "WHERE AP_APP_RELEASE.UUID=? AND AP_APP.TENANT_ID=?;";
|
|
|
|
+ "WHERE AP_APP_RELEASE.UUID=? AND AP_APP.TENANT_ID=?;";
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
@ -602,7 +605,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
application.setName(rs.getString("APP_NAME"));
|
|
|
|
application.setName(rs.getString("APP_NAME"));
|
|
|
|
application.setType(rs.getString("APP_TYPE"));
|
|
|
|
application.setType(rs.getString("APP_TYPE"));
|
|
|
|
application.setAppCategory(rs.getString("APP_CATEGORY"));
|
|
|
|
application.setAppCategory(rs.getString("APP_CATEGORY"));
|
|
|
|
application.setIsFree(rs.getInt("IS_FREE"));
|
|
|
|
application.setSubType(rs.getString("SUB_TYPE"));
|
|
|
|
|
|
|
|
application.setPaymentCurrency(rs.getString("CURRENCY"));
|
|
|
|
application.setIsRestricted(rs.getInt("RESTRICTED"));
|
|
|
|
application.setIsRestricted(rs.getInt("RESTRICTED"));
|
|
|
|
|
|
|
|
|
|
|
|
UnrestrictedRole unrestrictedRole = new UnrestrictedRole();
|
|
|
|
UnrestrictedRole unrestrictedRole = new UnrestrictedRole();
|
|
|
|