Fix favourite flag being always false when getting application by uuid

feature/traccar-sync
Mohamed Rashd 3 years ago
parent 817dc57862
commit 3b3c89849e

@ -961,9 +961,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
//Set application categories, tags and unrestricted roles to the application DTO. //Set application categories, tags and unrestricted roles to the application DTO.
applicationDTO applicationDTO
.setUnrestrictedRoles(visibilityDAO.getUnrestrictedRoles(applicationDTO.getId(), tenantId)); .setUnrestrictedRoles(visibilityDAO.getUnrestrictedRoles(applicationDTO.getId(), tenantId));
applicationDTO.setAppCategories(applicationDAO.getAppCategories(applicationDTO.getId(), tenantId)); setApplicationProperties(applicationDTO);
applicationDTO.setTags(applicationDAO.getAppTags(applicationDTO.getId(), tenantId));
applicationDTO.setFavourite(applicationDAO.isFavouriteApp(applicationDTO.getId(), userName, tenantId));
if (isFilteringApp(applicationDTO, filter)) { if (isFilteringApp(applicationDTO, filter)) {
boolean isHideableApp = isHideableApp(applicationDTO.getApplicationReleaseDTOs()); boolean isHideableApp = isHideableApp(applicationDTO.getApplicationReleaseDTOs());
@ -1586,11 +1584,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
return null; return null;
} }
applicationDTO.setApplicationReleaseDTOs(filteredApplicationReleaseDTOs); applicationDTO.setApplicationReleaseDTOs(filteredApplicationReleaseDTOs);
setApplicationProperties(applicationDTO);
List<String> tags = this.applicationDAO.getAppTags(applicationDTO.getId(), tenantId);
List<String> categories = this.applicationDAO.getAppCategories(applicationDTO.getId(), tenantId);
applicationDTO.setTags(tags);
applicationDTO.setAppCategories(categories);
List<String> unrestrictedRoles = this.visibilityDAO.getUnrestrictedRoles(applicationDTO.getId(), tenantId); List<String> unrestrictedRoles = this.visibilityDAO.getUnrestrictedRoles(applicationDTO.getId(), tenantId);
if (!unrestrictedRoles.isEmpty()) { if (!unrestrictedRoles.isEmpty()) {
@ -1630,6 +1624,17 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
} }
/**
* This is useful to set application properties that are mapped in other database tables (I.E: tags and categories)
*/
private void setApplicationProperties(ApplicationDTO applicationDTO) throws ApplicationManagementDAOException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
applicationDTO.setTags(applicationDAO.getAppTags(applicationDTO.getId(), tenantId));
applicationDTO.setAppCategories(applicationDAO.getAppCategories(applicationDTO.getId(), tenantId));
applicationDTO.setFavourite(applicationDAO.isFavouriteApp(applicationDTO.getId(), userName, tenantId));
}
/** /**
* Check whether at least one role is assigned to the given user. * Check whether at least one role is assigned to the given user.
* *

Loading…
Cancel
Save