mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'master' into 'master'
Fix incorrect app release loading issue in app store Closes product-iots#524 See merge request entgra/carbon-device-mgt!554
This commit is contained in:
commit
ebbe7c5edf
@ -138,16 +138,16 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
||||
+ "INNER JOIN AP_APP_RELEASE ON "
|
||||
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "
|
||||
+ "INNER JOIN (SELECT AP_APP.ID FROM AP_APP ";
|
||||
if (!StringUtils.isEmpty(filter.getVersion()) || !StringUtils.isEmpty(filter.getAppReleaseState())
|
||||
|| !StringUtils.isEmpty(filter.getAppReleaseType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getVersion()) || StringUtils.isNotEmpty(filter.getAppReleaseState())
|
||||
|| StringUtils.isNotEmpty(filter.getAppReleaseType())) {
|
||||
sql += "INNER JOIN AP_APP_RELEASE ON AP_APP.ID = AP_APP_RELEASE.AP_APP_ID ";
|
||||
}
|
||||
sql += "WHERE AP_APP.TENANT_ID = ? ";
|
||||
|
||||
if (!StringUtils.isEmpty(filter.getAppType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppType())) {
|
||||
sql += "AND AP_APP.TYPE = ? ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppName())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppName())) {
|
||||
sql += "AND LOWER (AP_APP.NAME) ";
|
||||
if (filter.isFullMatch()) {
|
||||
sql += "= ? ";
|
||||
@ -155,26 +155,26 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
||||
sql += "LIKE ? ";
|
||||
}
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getSubscriptionType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getSubscriptionType())) {
|
||||
sql += "AND AP_APP.SUB_TYPE = ? ";
|
||||
}
|
||||
if (filter.getMinimumRating() > 0) {
|
||||
sql += "AND AP_APP.RATING >= ? ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getVersion())) {
|
||||
if (StringUtils.isNotEmpty(filter.getVersion())) {
|
||||
sql += "AND AP_APP_RELEASE.VERSION = ? ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppReleaseType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppReleaseType())) {
|
||||
sql += "AND AP_APP_RELEASE.RELEASE_TYPE = ? ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppReleaseState())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppReleaseState())) {
|
||||
sql += "AND AP_APP_RELEASE.CURRENT_STATE = ? ";
|
||||
}
|
||||
if (deviceTypeId != -1) {
|
||||
sql += "AND AP_APP.DEVICE_TYPE_ID = ? ";
|
||||
}
|
||||
sql += "GROUP BY AP_APP.ID ";
|
||||
if (!StringUtils.isEmpty(filter.getSortBy())) {
|
||||
if (StringUtils.isNotEmpty(filter.getSortBy())) {
|
||||
sql += "ORDER BY ID " + filter.getSortBy() +" ";
|
||||
}
|
||||
if (filter.getLimit() != -1) {
|
||||
@ -186,29 +186,29 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
int paramIndex = 1;
|
||||
stmt.setInt(paramIndex++, tenantId);
|
||||
if (!StringUtils.isEmpty(filter.getAppType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppType())) {
|
||||
stmt.setString(paramIndex++, filter.getAppType());
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppName())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppName())) {
|
||||
if (filter.isFullMatch()) {
|
||||
stmt.setString(paramIndex++, filter.getAppName().toLowerCase());
|
||||
} else {
|
||||
stmt.setString(paramIndex++, "%" + filter.getAppName().toLowerCase() + "%");
|
||||
}
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getSubscriptionType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getSubscriptionType())) {
|
||||
stmt.setString(paramIndex++, filter.getSubscriptionType());
|
||||
}
|
||||
if (filter.getMinimumRating() > 0) {
|
||||
stmt.setInt(paramIndex++, filter.getMinimumRating());
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getVersion())) {
|
||||
if (StringUtils.isNotEmpty(filter.getVersion())) {
|
||||
stmt.setString(paramIndex++, filter.getVersion());
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppReleaseType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppReleaseType())) {
|
||||
stmt.setString(paramIndex++, filter.getAppReleaseType());
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppReleaseState())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppReleaseState())) {
|
||||
stmt.setString(paramIndex++, filter.getAppReleaseState());
|
||||
}
|
||||
if (deviceTypeId > 0) {
|
||||
|
||||
@ -85,14 +85,14 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl {
|
||||
+ "INNER JOIN AP_APP_RELEASE ON "
|
||||
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "
|
||||
+ "INNER JOIN (SELECT AP_APP.ID FROM AP_APP ORDER BY ID ";
|
||||
if (!StringUtils.isEmpty(filter.getVersion()) || !StringUtils.isEmpty(filter.getAppReleaseState())
|
||||
|| !StringUtils.isEmpty(filter.getAppReleaseType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getVersion()) || StringUtils.isNotEmpty(filter.getAppReleaseState())
|
||||
|| StringUtils.isNotEmpty(filter.getAppReleaseType())) {
|
||||
sql += "INNER JOIN AP_APP_RELEASE ON AP_APP.ID = AP_APP_RELEASE.AP_APP_ID ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppType())) {
|
||||
sql += "AND AP_APP.TYPE = ? ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppName())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppName())) {
|
||||
sql += " AND LOWER (AP_APP.NAME) ";
|
||||
if (filter.isFullMatch()) {
|
||||
sql += "= ? ";
|
||||
@ -100,26 +100,26 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl {
|
||||
sql += "LIKE ? ";
|
||||
}
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getSubscriptionType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getSubscriptionType())) {
|
||||
sql += "AND AP_APP.SUB_TYPE = ? ";
|
||||
}
|
||||
if (filter.getMinimumRating() > 0) {
|
||||
sql += "AND AP_APP.RATING >= ? ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getVersion())) {
|
||||
if (StringUtils.isNotEmpty(filter.getVersion())) {
|
||||
sql += "AND AP_APP_RELEASE.VERSION = ? ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppReleaseType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppReleaseType())) {
|
||||
sql += "AND AP_APP_RELEASE.RELEASE_TYPE = ? ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppReleaseState())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppReleaseState())) {
|
||||
sql += "AND AP_APP_RELEASE.CURRENT_STATE = ? ";
|
||||
}
|
||||
if (deviceTypeId != -1) {
|
||||
sql += "AND AP_APP.DEVICE_TYPE_ID = ? ";
|
||||
}
|
||||
sql += "GROUP BY AP_APP.ID ";
|
||||
if (!StringUtils.isEmpty(filter.getSortBy())) {
|
||||
if (StringUtils.isNotEmpty(filter.getSortBy())) {
|
||||
sql += "ORDER BY ID " + filter.getSortBy() + " ";
|
||||
}
|
||||
if (filter.getLimit() != -1) {
|
||||
@ -131,29 +131,29 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl {
|
||||
Connection conn = this.getDBConnection();
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
int paramIndex = 1;
|
||||
if (!StringUtils.isEmpty(filter.getAppType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppType())) {
|
||||
stmt.setString(paramIndex++, filter.getAppType());
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppName())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppName())) {
|
||||
if (filter.isFullMatch()) {
|
||||
stmt.setString(paramIndex++, filter.getAppName().toLowerCase());
|
||||
} else {
|
||||
stmt.setString(paramIndex++, "%" + filter.getAppName().toLowerCase() + "%");
|
||||
}
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getSubscriptionType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getSubscriptionType())) {
|
||||
stmt.setString(paramIndex++, filter.getSubscriptionType());
|
||||
}
|
||||
if (filter.getMinimumRating() > 0) {
|
||||
stmt.setInt(paramIndex++, filter.getMinimumRating());
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getVersion())) {
|
||||
if (StringUtils.isNotEmpty(filter.getVersion())) {
|
||||
stmt.setString(paramIndex++, filter.getVersion());
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppReleaseType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppReleaseType())) {
|
||||
stmt.setString(paramIndex++, filter.getAppReleaseType());
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppReleaseState())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppReleaseState())) {
|
||||
stmt.setString(paramIndex++, filter.getAppReleaseState());
|
||||
}
|
||||
if (deviceTypeId > 0) {
|
||||
|
||||
@ -84,14 +84,14 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl {
|
||||
+ "INNER JOIN AP_APP_RELEASE ON "
|
||||
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "
|
||||
+ "INNER JOIN (SELECT AP_APP.ID FROM AP_APP ";
|
||||
if (!StringUtils.isEmpty(filter.getVersion()) || !StringUtils.isEmpty(filter.getAppReleaseState())
|
||||
|| !StringUtils.isEmpty(filter.getAppReleaseType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getVersion()) || StringUtils.isNotEmpty(filter.getAppReleaseState())
|
||||
|| StringUtils.isNotEmpty(filter.getAppReleaseType())) {
|
||||
sql += "INNER JOIN AP_APP_RELEASE ON AP_APP.ID = AP_APP_RELEASE.AP_APP_ID ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppType())) {
|
||||
sql += "AND AP_APP.TYPE = ? ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppName())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppName())) {
|
||||
sql += " AND LOWER (AP_APP.NAME) ";
|
||||
if (filter.isFullMatch()) {
|
||||
sql += "= ? ";
|
||||
@ -99,26 +99,26 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl {
|
||||
sql += "LIKE ? ";
|
||||
}
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getSubscriptionType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getSubscriptionType())) {
|
||||
sql += "AND AP_APP.SUB_TYPE = ? ";
|
||||
}
|
||||
if (filter.getMinimumRating() > 0) {
|
||||
sql += "AND AP_APP.RATING >= ? ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getVersion())) {
|
||||
if (StringUtils.isNotEmpty(filter.getVersion())) {
|
||||
sql += "AND AP_APP_RELEASE.VERSION = ? ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppReleaseType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppReleaseType())) {
|
||||
sql += "AND AP_APP_RELEASE.RELEASE_TYPE = ? ";
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppReleaseState())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppReleaseState())) {
|
||||
sql += "AND AP_APP_RELEASE.CURRENT_STATE = ? ";
|
||||
}
|
||||
if (deviceTypeId != -1) {
|
||||
sql += "AND AP_APP.DEVICE_TYPE_ID = ? ";
|
||||
}
|
||||
sql += "GROUP BY AP_APP.ID ";
|
||||
if (!StringUtils.isEmpty(filter.getSortBy())) {
|
||||
if (StringUtils.isNotEmpty(filter.getSortBy())) {
|
||||
sql += "ORDER BY ID " + filter.getSortBy() + " ";
|
||||
}
|
||||
if (filter.getLimit() != -1) {
|
||||
@ -130,29 +130,29 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl {
|
||||
Connection conn = this.getDBConnection();
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
int paramIndex = 1;
|
||||
if (!StringUtils.isEmpty(filter.getAppType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppType())) {
|
||||
stmt.setString(paramIndex++, filter.getAppType());
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppName())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppName())) {
|
||||
if (filter.isFullMatch()) {
|
||||
stmt.setString(paramIndex++, filter.getAppName().toLowerCase());
|
||||
} else {
|
||||
stmt.setString(paramIndex++, "%" + filter.getAppName().toLowerCase() + "%");
|
||||
}
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getSubscriptionType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getSubscriptionType())) {
|
||||
stmt.setString(paramIndex++, filter.getSubscriptionType());
|
||||
}
|
||||
if (filter.getMinimumRating() > 0) {
|
||||
stmt.setInt(paramIndex++, filter.getMinimumRating());
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getVersion())) {
|
||||
if (StringUtils.isNotEmpty(filter.getVersion())) {
|
||||
stmt.setString(paramIndex++, filter.getVersion());
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppReleaseType())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppReleaseType())) {
|
||||
stmt.setString(paramIndex++, filter.getAppReleaseType());
|
||||
}
|
||||
if (!StringUtils.isEmpty(filter.getAppReleaseState())) {
|
||||
if (StringUtils.isNotEmpty(filter.getAppReleaseState())) {
|
||||
stmt.setString(paramIndex++, filter.getAppReleaseState());
|
||||
}
|
||||
if (deviceTypeId > 0) {
|
||||
|
||||
@ -618,41 +618,36 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
||||
}
|
||||
|
||||
//Set application categories, tags and unrestricted roles to the application DTO.
|
||||
applicationDTO.setUnrestrictedRoles(visibilityDAO
|
||||
.getUnrestrictedRoles(applicationDTO.getId(), tenantId));
|
||||
applicationDTO
|
||||
.setUnrestrictedRoles(visibilityDAO.getUnrestrictedRoles(applicationDTO.getId(), tenantId));
|
||||
applicationDTO.setAppCategories(applicationDAO.getAppCategories(applicationDTO.getId(), tenantId));
|
||||
applicationDTO.setTags(applicationDAO.getAppTags(applicationDTO.getId(), tenantId));
|
||||
|
||||
if (isFilteringApp(applicationDTO, filter)) {
|
||||
boolean isHideableApp = isHideableApp(applicationDTO.getApplicationReleaseDTOs());
|
||||
boolean isDeletableApp = isDeletableApp(applicationDTO.getApplicationReleaseDTOs());
|
||||
|
||||
List<ApplicationReleaseDTO> filteredApplicationReleaseDTOs = new ArrayList<>();
|
||||
AtomicBoolean isDeletableApp = new AtomicBoolean(true);
|
||||
for (ApplicationReleaseDTO applicationReleaseDTO : applicationDTO.getApplicationReleaseDTOs()) {
|
||||
String appReleaseCurrentState = applicationReleaseDTO.getCurrentState();
|
||||
if (!lifecycleStateManager.getEndState().equals(appReleaseCurrentState)) {
|
||||
if (isDeletableApp.get() && !lifecycleStateManager.isDeletableState(appReleaseCurrentState)) {
|
||||
isDeletableApp.set(false);
|
||||
if (StringUtils.isNotEmpty(filter.getVersion()) && !filter.getVersion()
|
||||
.equals(applicationReleaseDTO.getVersion())) {
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(filter.getAppReleaseState()) && !filter.getAppReleaseState()
|
||||
.equals(applicationReleaseDTO.getCurrentState())) {
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(filter.getAppReleaseType()) && !filter.getAppReleaseType()
|
||||
.equals(applicationReleaseDTO.getReleaseType())) {
|
||||
continue;
|
||||
}
|
||||
filteredApplicationReleaseDTOs.add(applicationReleaseDTO);
|
||||
}
|
||||
}
|
||||
|
||||
applicationDTO.setApplicationReleaseDTOs(filteredApplicationReleaseDTOs);
|
||||
Application application = APIUtil.appDtoToAppResponse(applicationDTO);
|
||||
|
||||
/*
|
||||
* Load the entire application again if the searched application is either deletable or all the app
|
||||
* releases are in the end state of the app lifecycle. App has to be reloaded because when searching
|
||||
* applications it may not contains all the application releases of an application.
|
||||
*/
|
||||
if (isDeletableApp.get() || filteredApplicationReleaseDTOs.isEmpty()){
|
||||
ApplicationDTO entireApp = applicationDAO.getApplication(applicationDTO.getId(), tenantId);
|
||||
if (filteredApplicationReleaseDTOs.isEmpty()){
|
||||
application.setHideableApp(isHideableApp(entireApp.getApplicationReleaseDTOs()));
|
||||
}
|
||||
if (isDeletableApp.get()) {
|
||||
application.setDeletableApp(isDeletableApp(entireApp.getApplicationReleaseDTOs()));
|
||||
}
|
||||
}
|
||||
application.setDeletableApp(isDeletableApp);
|
||||
application.setHideableApp(isHideableApp);
|
||||
applications.add(application);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user