|
|
@ -18,6 +18,7 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
package org.wso2.carbon.device.application.mgt.core.dao.impl.application;
|
|
|
|
package org.wso2.carbon.device.application.mgt.core.dao.impl.application;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.json.JSONException;
|
|
|
|
import org.json.JSONException;
|
|
|
@ -124,119 +125,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public ApplicationList getApplications(Filter filter, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
// if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
// log.debug("Getting application data from the database");
|
|
|
|
|
|
|
|
// log.debug(String.format("Filter: limit=%s, offset=%s", filter.getLimit(), filter.getOffset()));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// int paramIndex = 1;
|
|
|
|
|
|
|
|
// Connection conn;
|
|
|
|
|
|
|
|
// PreparedStatement stmt = null;
|
|
|
|
|
|
|
|
// ResultSet rs = null;
|
|
|
|
|
|
|
|
// ApplicationList applicationList = new ApplicationList();
|
|
|
|
|
|
|
|
// 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 AS APP_CATEGORY,"
|
|
|
|
|
|
|
|
// + " AP_APP.SUB_TYPE AS SUB_TYPE,"
|
|
|
|
|
|
|
|
// + " AP_APP.CURRENCY AS CURRENCY, "
|
|
|
|
|
|
|
|
// + "AP_APP.RESTRICTED AS RESTRICTED,"
|
|
|
|
|
|
|
|
// + " AP_APP_TAG.TAG AS APP_TAG,"
|
|
|
|
|
|
|
|
// + " AP_UNRESTRICTED_ROLE.ROLE AS ROLE "
|
|
|
|
|
|
|
|
// + "FROM ((AP_APP LEFT JOIN AP_APP_TAG ON AP_APP.ID = AP_APP_TAG.AP_APP_ID) "
|
|
|
|
|
|
|
|
// + "LEFT JOIN AP_UNRESTRICTED_ROLE ON AP_APP.ID = AP_UNRESTRICTED_ROLE.AP_APP_ID) "
|
|
|
|
|
|
|
|
// + "WHERE AP_APP.TENANT_ID = ?";
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (filter == null) {
|
|
|
|
|
|
|
|
// throw new ApplicationManagementDAOException("Filter need to be instantiated");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (filter.getAppType() != null && !filter.getAppType().isEmpty()) {
|
|
|
|
|
|
|
|
// sql += " AND AP_APP.TYPE ";
|
|
|
|
|
|
|
|
// sql += "= ?";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (filter.getAppCategory() != null && !filter.getAppCategory().isEmpty()) {
|
|
|
|
|
|
|
|
// sql += " AND AP_APP.APP_CATEGORY ";
|
|
|
|
|
|
|
|
// sql += "= ?";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (filter.getAppName() != null && !filter.getAppName().isEmpty()) {
|
|
|
|
|
|
|
|
// sql += " AND LOWER (AP_APP.NAME) ";
|
|
|
|
|
|
|
|
// if (filter.isFullMatch()) {
|
|
|
|
|
|
|
|
// sql += "= ?";
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// sql += "LIKE ?";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (filter.getDeviceTypeName() != null ) {
|
|
|
|
|
|
|
|
// sql += " AND AP_APP.DEVICE_TYPE_ID ";
|
|
|
|
|
|
|
|
// sql += "= ?";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// String defaultSortOrder = "ASC";
|
|
|
|
|
|
|
|
// if (filter.getSortBy() != null && !filter.getSortBy().isEmpty()) {
|
|
|
|
|
|
|
|
// defaultSortOrder = filter.getSortBy();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// sql += " ORDER BY APP_ID " + defaultSortOrder +" LIMIT ? OFFSET ? ";
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// pagination.setLimit(filter.getLimit());
|
|
|
|
|
|
|
|
// pagination.setOffset(filter.getOffset());
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// conn = this.getDBConnection();
|
|
|
|
|
|
|
|
// stmt = conn.prepareStatement(sql);
|
|
|
|
|
|
|
|
// stmt.setInt(paramIndex++, tenantId);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (filter.getAppType() != null && !filter.getAppType().isEmpty()) {
|
|
|
|
|
|
|
|
// stmt.setString(paramIndex++, filter.getAppType());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (filter.getAppCategory() != null && !filter.getAppCategory().isEmpty()) {
|
|
|
|
|
|
|
|
// stmt.setString(paramIndex++, filter.getAppCategory());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (filter.getAppName() != null && !filter.getAppName().isEmpty()) {
|
|
|
|
|
|
|
|
// if (filter.isFullMatch()) {
|
|
|
|
|
|
|
|
// stmt.setString(paramIndex++, filter.getAppName().toLowerCase());
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// stmt.setString(paramIndex++, "%" + filter.getAppName().toLowerCase() + "%");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (filter.getDeviceTypeName() != null ) {
|
|
|
|
|
|
|
|
// stmt.setInt(paramIndex++, filter.getDeviceTypeName().getId());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (filter.getLimit() == 0) {
|
|
|
|
|
|
|
|
// stmt.setInt(paramIndex++, 100);
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// stmt.setInt(paramIndex++, filter.getLimit());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// stmt.setInt(paramIndex, filter.getOffset());
|
|
|
|
|
|
|
|
// rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
// applicationList.setApplications(Util.loadApplications(rs));
|
|
|
|
|
|
|
|
// applicationList.setPagination(pagination);
|
|
|
|
|
|
|
|
// applicationList.getPagination().setSize(filter.getOffset());
|
|
|
|
|
|
|
|
// applicationList.getPagination().setCount(applicationList.getApplications().size());
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// } catch (SQLException e) {
|
|
|
|
|
|
|
|
// throw new ApplicationManagementDAOException("Error occurred while getting application list for the tenant"
|
|
|
|
|
|
|
|
// + " " + tenantId + ". While executing " + sql, e);
|
|
|
|
|
|
|
|
// } catch (DBConnectionException e) {
|
|
|
|
|
|
|
|
// throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection while "
|
|
|
|
|
|
|
|
// + "getting application list for the tenant " + tenantId,
|
|
|
|
|
|
|
|
// e);
|
|
|
|
|
|
|
|
// } catch (JSONException e) {
|
|
|
|
|
|
|
|
// throw new ApplicationManagementDAOException("Error occurred while parsing JSON ", e);
|
|
|
|
|
|
|
|
// } finally {
|
|
|
|
|
|
|
|
// Util.cleanupResources(stmt, rs);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return applicationList;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ApplicationList getApplications(Filter filter, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
public List<ApplicationDTO> getApplications(Filter filter,int deviceTypeId, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
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()));
|
|
|
@ -245,8 +135,6 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
Connection conn;
|
|
|
|
Connection conn;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
ApplicationList applicationList = new ApplicationList();
|
|
|
|
|
|
|
|
Pagination pagination = new Pagination();
|
|
|
|
|
|
|
|
String sql = "SELECT "
|
|
|
|
String sql = "SELECT "
|
|
|
|
+ "AP_APP.ID AS APP_ID, "
|
|
|
|
+ "AP_APP.ID AS APP_ID, "
|
|
|
|
+ "AP_APP.NAME AS APP_NAME, "
|
|
|
|
+ "AP_APP.NAME AS APP_NAME, "
|
|
|
@ -281,15 +169,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
if (filter == null) {
|
|
|
|
if (filter == null) {
|
|
|
|
throw new ApplicationManagementDAOException("Filter need to be instantiated");
|
|
|
|
throw new ApplicationManagementDAOException("Filter need to be instantiated");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filter.getAppType() != null && !filter.getAppType().isEmpty()) {
|
|
|
|
|
|
|
|
sql += " AND AP_APP.TYPE ";
|
|
|
|
if (!StringUtils.isEmpty(filter.getAppType())) {
|
|
|
|
sql += "= ?";
|
|
|
|
sql += " AND AP_APP.TYPE = ?";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filter.getAppCategory() != null && !filter.getAppCategory().isEmpty()) {
|
|
|
|
|
|
|
|
sql += " AND AP_APP.APP_CATEGORY ";
|
|
|
|
|
|
|
|
sql += "= ?";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filter.getAppName() != null && !filter.getAppName().isEmpty()) {
|
|
|
|
if (!StringUtils.isEmpty(filter.getAppName())) {
|
|
|
|
sql += " AND LOWER (AP_APP.NAME) ";
|
|
|
|
sql += " AND LOWER (AP_APP.NAME) ";
|
|
|
|
if (filter.isFullMatch()) {
|
|
|
|
if (filter.isFullMatch()) {
|
|
|
|
sql += "= ?";
|
|
|
|
sql += "= ?";
|
|
|
@ -297,19 +181,30 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
sql += "LIKE ?";
|
|
|
|
sql += "LIKE ?";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filter.getDeviceTypeId() > 0 ) {
|
|
|
|
if (!StringUtils.isEmpty(filter.getSubscriptionType())) {
|
|
|
|
sql += " AND AP_APP.DEVICE_TYPE_ID ";
|
|
|
|
sql += " AND AP_APP.SUB_TYPE = ?";
|
|
|
|
sql += "= ?";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filter.getMinimumRating() > 0) {
|
|
|
|
String defaultSortOrder = "ASC";
|
|
|
|
sql += " AND AP_APP.RATING >= ?";
|
|
|
|
if (filter.getSortBy() != null && !filter.getSortBy().isEmpty()) {
|
|
|
|
}
|
|
|
|
defaultSortOrder = filter.getSortBy();
|
|
|
|
if (!StringUtils.isEmpty(filter.getVersion())) {
|
|
|
|
|
|
|
|
sql += " AND AP_APP_RELEASE.VERSION = ?";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(filter.getAppReleaseType())) {
|
|
|
|
|
|
|
|
sql += " AND AP_APP_RELEASE.RELEASE_TYPE = ?";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(filter.getAppReleaseState())) {
|
|
|
|
|
|
|
|
sql += " AND AP_APP_RELEASE.CURRENT_STATE = ?";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (deviceTypeId > 0) {
|
|
|
|
|
|
|
|
sql += " AND AP_APP.DEVICE_TYPE_ID = ?";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sql += " ORDER BY APP_ID " + defaultSortOrder +" LIMIT ? OFFSET ? ";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pagination.setLimit(filter.getLimit());
|
|
|
|
String sortingOrder = "ASC";
|
|
|
|
pagination.setOffset(filter.getOffset());
|
|
|
|
if (!StringUtils.isEmpty(filter.getSortBy() )) {
|
|
|
|
|
|
|
|
sortingOrder = filter.getSortBy();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sql += " ORDER BY APP_ID " + sortingOrder +" LIMIT ? OFFSET ? ";
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
conn = this.getDBConnection();
|
|
|
@ -319,9 +214,6 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
if (filter.getAppType() != null && !filter.getAppType().isEmpty()) {
|
|
|
|
if (filter.getAppType() != null && !filter.getAppType().isEmpty()) {
|
|
|
|
stmt.setString(paramIndex++, filter.getAppType());
|
|
|
|
stmt.setString(paramIndex++, filter.getAppType());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filter.getAppCategory() != null && !filter.getAppCategory().isEmpty()) {
|
|
|
|
|
|
|
|
stmt.setString(paramIndex++, filter.getAppCategory());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filter.getAppName() != null && !filter.getAppName().isEmpty()) {
|
|
|
|
if (filter.getAppName() != null && !filter.getAppName().isEmpty()) {
|
|
|
|
if (filter.isFullMatch()) {
|
|
|
|
if (filter.isFullMatch()) {
|
|
|
|
stmt.setString(paramIndex++, filter.getAppName().toLowerCase());
|
|
|
|
stmt.setString(paramIndex++, filter.getAppName().toLowerCase());
|
|
|
@ -329,11 +221,24 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
stmt.setString(paramIndex++, "%" + filter.getAppName().toLowerCase() + "%");
|
|
|
|
stmt.setString(paramIndex++, "%" + filter.getAppName().toLowerCase() + "%");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filter.getDeviceTypeId() > 0 ) {
|
|
|
|
if (!StringUtils.isEmpty(filter.getSubscriptionType())) {
|
|
|
|
stmt.setInt(paramIndex++, filter.getDeviceTypeId());
|
|
|
|
stmt.setString(paramIndex++, filter.getSubscriptionType());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filter.getMinimumRating() > 0) {
|
|
|
|
|
|
|
|
stmt.setInt(paramIndex++, filter.getMinimumRating());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(filter.getVersion())) {
|
|
|
|
|
|
|
|
stmt.setString(paramIndex++, filter.getVersion());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(filter.getAppReleaseType())) {
|
|
|
|
|
|
|
|
stmt.setString(paramIndex++, filter.getAppReleaseType());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(filter.getAppReleaseState())) {
|
|
|
|
|
|
|
|
stmt.setString(paramIndex++, filter.getAppReleaseState());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (deviceTypeId > 0 ) {
|
|
|
|
|
|
|
|
stmt.setInt(paramIndex++, deviceTypeId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (filter.getLimit() == 0) {
|
|
|
|
if (filter.getLimit() == 0) {
|
|
|
|
stmt.setInt(paramIndex++, 100);
|
|
|
|
stmt.setInt(paramIndex++, 100);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -341,11 +246,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmt.setInt(paramIndex, filter.getOffset());
|
|
|
|
stmt.setInt(paramIndex, filter.getOffset());
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
applicationList.setApplications(Util.loadApplications(rs));
|
|
|
|
return Util.loadApplications(rs);
|
|
|
|
applicationList.setPagination(pagination);
|
|
|
|
|
|
|
|
applicationList.getPagination().setSize(filter.getOffset());
|
|
|
|
|
|
|
|
applicationList.getPagination().setCount(applicationList.getApplications().size());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while getting application list for the tenant"
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while getting application list for the tenant"
|
|
|
|
+ " " + tenantId + ". While executing " + sql, e);
|
|
|
|
+ " " + tenantId + ". While executing " + sql, e);
|
|
|
@ -358,7 +259,6 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Util.cleanupResources(stmt, rs);
|
|
|
|
Util.cleanupResources(stmt, rs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return applicationList;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -972,6 +872,70 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public List<String> getAppTags(int appId, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug("Request received in DAO Layer to get tags for given application.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Connection conn;
|
|
|
|
|
|
|
|
List<String> tags = new ArrayList<>();
|
|
|
|
|
|
|
|
String sql = "SELECT tag.TAG AS TAG "
|
|
|
|
|
|
|
|
+ "FROM "
|
|
|
|
|
|
|
|
+ "AP_APP_TAG tag INNER JOIN AP_APP_TAG_MAPPING tag_map ON tag.ID = tag_map.AP_APP_TAG_ID "
|
|
|
|
|
|
|
|
+ "INNER JOIN AP_APP app ON tag_map.AP_APP_ID = app.ID "
|
|
|
|
|
|
|
|
+ "WHERE app.ID = ? and app.TENANT_ID = ?";
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)){
|
|
|
|
|
|
|
|
stmt.setInt(1, appId);
|
|
|
|
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
|
|
|
tags.add(rs.getString("TAG"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return tags;
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
|
|
|
"Error occurred while obtaining the DB connection when adding tags", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while adding tags", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public List<String> getAppCategories(int appId, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug("Request received in DAO Layer to get categories for given application.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Connection conn;
|
|
|
|
|
|
|
|
List<String> categories = new ArrayList<>();
|
|
|
|
|
|
|
|
String sql = "SELECT CATEGORY "
|
|
|
|
|
|
|
|
+ "FROM "
|
|
|
|
|
|
|
|
+ "AP_APP_CATEGORY cat INNER JOIN AP_APP_CATEGORY_MAPPING cat_map ON cat.ID = cat_map.AP_APP_CATEGORY_ID "
|
|
|
|
|
|
|
|
+ "INNER JOIN AP_APP app ON cat_map.AP_APP_ID = app.ID "
|
|
|
|
|
|
|
|
+ "WHERE app.ID = ? and app.TENANT_ID = ?";
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
|
|
|
|
try (PreparedStatement stmt = conn.prepareStatement(sql)){
|
|
|
|
|
|
|
|
stmt.setInt(1, appId);
|
|
|
|
|
|
|
|
stmt.setInt(2, tenantId);
|
|
|
|
|
|
|
|
try (ResultSet rs = stmt.executeQuery()) {
|
|
|
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
|
|
|
categories.add(rs.getString("CATEGORY"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return categories;
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException(
|
|
|
|
|
|
|
|
"Error occurred while obtaining the DB connection when adding tags", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new ApplicationManagementDAOException("Error occurred while adding tags", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void deleteTags(List<String> tags, int applicationId, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|
public void deleteTags(List<String> tags, int applicationId, int tenantId) throws ApplicationManagementDAOException {
|
|
|
|