Improve get applications method

feature/appm-store/pbac
lasanthaDLPDS 6 years ago
parent 6dafe59eab
commit b991ed22ee

@ -643,49 +643,45 @@ public class ApplicationManagerImpl implements ApplicationManager {
validateFilter(filter); validateFilter(filter);
appDTOs = applicationDAO.getApplications(filter, deviceType.getId(), tenantId); appDTOs = applicationDAO.getApplications(filter, deviceType.getId(), tenantId);
//todo as a performance improvement get these data from DB. Consider where in clause. //todo as a performance improvement get these data from DB. Consider where in clause.
for (ApplicationDTO app : appDTOs) { for (ApplicationDTO applicationDTO : appDTOs) {
boolean isSearchingApp = true; boolean isSearchingApp = true;
List<String> filteringTags = filter.getTags(); List<String> filteringTags = filter.getTags();
List<String> filteringCategories = filter.getAppCategories(); List<String> filteringCategories = filter.getAppCategories();
List<String> filteringUnrestrictedRoles = filter.getUnrestrictedRoles(); List<String> filteringUnrestrictedRoles = filter.getUnrestrictedRoles();
if (!lifecycleStateManager.getEndState().equals(app.getStatus())) { if (!lifecycleStateManager.getEndState().equals(applicationDTO.getStatus())) {
List<String> appUnrestrictedRoles = visibilityDAO.getUnrestrictedRoles(app.getId(), tenantId); List<String> appUnrestrictedRoles = visibilityDAO.getUnrestrictedRoles(applicationDTO.getId(), tenantId);
if ((appUnrestrictedRoles.isEmpty() || hasUserRole(appUnrestrictedRoles, userName)) && ( if ((appUnrestrictedRoles.isEmpty() || hasUserRole(appUnrestrictedRoles, userName)) && (
filteringUnrestrictedRoles == null || filteringUnrestrictedRoles.isEmpty() filteringUnrestrictedRoles == null || filteringUnrestrictedRoles.isEmpty()
|| hasAppUnrestrictedRole(appUnrestrictedRoles, filteringUnrestrictedRoles, || hasAppUnrestrictedRole(appUnrestrictedRoles, filteringUnrestrictedRoles,
userName))) { userName))) {
if (filteringCategories != null && !filteringCategories.isEmpty()) { if (filteringCategories != null && !filteringCategories.isEmpty()) {
List<String> appTagList = applicationDAO.getAppCategories(app.getId(), tenantId); List<String> appTagList = applicationDAO.getAppCategories(applicationDTO.getId(), tenantId);
boolean isAppCategory = false; boolean isAppCategory = filteringCategories.stream().anyMatch(appTagList::contains);
for (String category : filteringCategories) {
if (appTagList.contains(category)) {
isAppCategory = true;
break;
}
}
if (!isAppCategory) { if (!isAppCategory) {
isSearchingApp = false; isSearchingApp = false;
} }
} }
if (filteringTags != null && !filteringTags.isEmpty()) { if (filteringTags != null && !filteringTags.isEmpty()) {
List<String> appTagList = applicationDAO.getAppTags(app.getId(), tenantId); List<String> appTagList = applicationDAO.getAppTags(applicationDTO.getId(), tenantId);
boolean isAppTag = false; boolean isAppTag = filteringTags.stream().anyMatch(appTagList::contains);
for (String tag : filteringTags) {
if (appTagList.contains(tag)) {
isAppTag = true;
break;
}
}
if (!isAppTag) { if (!isAppTag) {
isSearchingApp = false; isSearchingApp = false;
} }
} }
if (isSearchingApp) { if (isSearchingApp) {
filteredApplications.add(app); filteredApplications.add(applicationDTO);
} }
} }
} }
List<ApplicationReleaseDTO> filteredApplicationReleaseDTOs = new ArrayList<>();
for (ApplicationReleaseDTO applicationReleaseDTO : applicationDTO.getApplicationReleaseDTOs()) {
if (!applicationReleaseDTO.getCurrentState().equals(lifecycleStateManager.getEndState())) {
filteredApplicationReleaseDTOs.add(applicationReleaseDTO);
}
}
applicationDTO.setApplicationReleaseDTOs(filteredApplicationReleaseDTOs);
} }
for(ApplicationDTO appDTO : filteredApplications){ for(ApplicationDTO appDTO : filteredApplications){

Loading…
Cancel
Save