Skip to content

Commit e8ca230

Browse files
authored
EPMRPP-111882 || Find locked dashboards (#1196)
1 parent e7407f2 commit e8ca230

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

src/main/java/com/epam/ta/reportportal/dao/UserFilterRepository.java

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import java.util.Collection;
2121
import java.util.List;
2222
import java.util.Optional;
23+
import org.springframework.data.jpa.repository.Query;
24+
import org.springframework.data.repository.query.Param;
2325

2426
/**
2527
* @author Pavel Bortnik
@@ -31,23 +33,20 @@ public interface UserFilterRepository extends ReportPortalRepository<UserFilter,
3133
* Finds filter by 'id' and 'project id'
3234
*
3335
* @param id {@link UserFilter#id}
34-
* @param projectId Id of the {@link com.epam.ta.reportportal.entity.project.Project} whose filter
35-
* will be extracted
36+
* @param projectId Id of the {@link com.epam.ta.reportportal.entity.project.Project} whose filter will be extracted
3637
* @return {@link UserFilter} wrapped in the {@link Optional}
3738
*/
3839
Optional<UserFilter> findByIdAndProjectId(Long id, Long projectId);
3940

4041
/**
4142
* @param ids {@link Iterable} of the filter Ids
42-
* @param projectId Id of the {@link com.epam.ta.reportportal.entity.project.Project} whose
43-
* filters will be extracted
43+
* @param projectId Id of the {@link com.epam.ta.reportportal.entity.project.Project} whose filters will be extracted
4444
* @return The {@link List} of the {@link UserFilter}
4545
*/
4646
List<UserFilter> findAllByIdInAndProjectId(Collection<Long> ids, Long projectId);
4747

4848
/**
49-
* @param projectId Id of the {@link com.epam.ta.reportportal.entity.project.Project} whose
50-
* filters will be extracted
49+
* @param projectId Id of the {@link com.epam.ta.reportportal.entity.project.Project} whose filters will be extracted
5150
* @return The {@link List} of the {@link UserFilter}
5251
*/
5352
List<UserFilter> findAllByProjectId(Long projectId);
@@ -57,8 +56,8 @@ public interface UserFilterRepository extends ReportPortalRepository<UserFilter,
5756
*
5857
* @param name {@link UserFilter#name}
5958
* @param owner {@link UserFilter#owner}
60-
* @param projectId Id of the {@link com.epam.ta.reportportal.entity.project.Project} on which
61-
* filter existence will be checked
59+
* @param projectId Id of the {@link com.epam.ta.reportportal.entity.project.Project} on which filter existence will
60+
* be checked
6261
* @return if exists 'true' else 'false'
6362
*/
6463
boolean existsByNameAndOwnerAndProjectId(String name, String owner, Long projectId);
@@ -67,10 +66,31 @@ public interface UserFilterRepository extends ReportPortalRepository<UserFilter,
6766
* Checks the existence of the {@link UserFilter} with specified name on a project
6867
*
6968
* @param name {@link UserFilter#name}
70-
* @param projectId Id of the {@link com.epam.ta.reportportal.entity.project.Project} on which
71-
* filter existence will be checked
69+
* @param projectId Id of the {@link com.epam.ta.reportportal.entity.project.Project} on which filter existence will
70+
* be checked
7271
* @return if exists 'true' else 'false'
7372
*/
7473
boolean existsByNameAndProjectId(String name, Long projectId);
7574

75+
/**
76+
* Finds locked dashboards that use the specified filter. Returns dashboard names.
77+
*
78+
* @param filterId The filter ID
79+
* @param projectId The project ID to filter dashboards
80+
* @return List of dashboard names
81+
*/
82+
@Query(value = """
83+
SELECT d.name
84+
FROM dashboard d
85+
INNER JOIN owned_entity oe ON d.id = oe.id
86+
WHERE oe.locked = true
87+
AND oe.project_id = :projectId
88+
AND d.id IN (
89+
SELECT dw.dashboard_id
90+
FROM dashboard_widget dw
91+
INNER JOIN widget_filter wf ON dw.widget_id = wf.widget_id
92+
WHERE wf.filter_id = :filterId
93+
)
94+
""", nativeQuery = true)
95+
List<String> findLockedDashboardsByFilterId(@Param("filterId") Long filterId, @Param("projectId") Long projectId);
7696
}

0 commit comments

Comments
 (0)