Package com.epam.ta.reportportal.dao
Interface TestItemRepository
-
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<TestItem,java.lang.Long>,FilterableRepository<TestItem>,org.springframework.data.jpa.repository.JpaRepository<TestItem,java.lang.Long>,org.springframework.data.repository.PagingAndSortingRepository<TestItem,java.lang.Long>,org.springframework.data.repository.query.QueryByExampleExecutor<TestItem>,ReportPortalRepository<TestItem,java.lang.Long>,org.springframework.data.repository.Repository<TestItem,java.lang.Long>,TestItemRepositoryCustom
public interface TestItemRepository extends ReportPortalRepository<TestItem,java.lang.Long>, TestItemRepositoryCustom
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddeleteAllByItemIdIn(java.util.Collection<java.lang.Long> ids)voiddeleteTestItem(java.lang.Long itemId)java.util.Optional<TestItem>findByNameAndLaunchUnderPath(java.lang.String name, java.lang.Long launchId, java.lang.String path)java.util.Optional<TestItem>findByNameAndLaunchWithoutParents(java.lang.String name, java.lang.Long launchId)java.util.Optional<TestItem>findByUuid(java.lang.String uuid)java.util.Optional<TestItem>findByUuidForUpdate(java.lang.String uuid)FindsTestItembyTestItem.getUuid()and sets a lock on the found 'item' row in the database.java.util.Optional<TestItem>findParentByChildId(java.lang.Long childId)java.util.List<TestItem>findTestItemsByLaunchId(java.lang.Long launchId)java.util.List<TestItem>findTestItemsByLaunchIdOrderByStartTimeAsc(java.lang.Long launchId)Finds allTestItemby specified launch idjava.util.List<TestItem>findTestItemsByUniqueId(java.lang.String uniqueId)voidhandleRetries(java.lang.Long itemId)Execute sql-function that changes a structure of retries according to the MAXTestItem.startTime.booleanhasChildren(java.lang.Long itemId, java.lang.String itemPath)Checks does test item have children.booleanhasDescendantsNotInStatus(java.lang.Long parentId, java.lang.String... statuses)Check for existence of descendants with statuses NOT EQUAL to provided statusbooleanhasDescendantsNotInStatusExcludingById(java.lang.Long parentId, java.lang.Long stepId, java.lang.String... statuses)Checks if all children of test item with id =parentId, except item with id =stepId, has status not in providedstatusesbooleanhasItemsInStatusByParent(java.lang.Long parentId, java.lang.String parentPath, java.lang.String... statuses)True if the parent item has any child items with provided status.booleanhasParentWithStatus(java.lang.Long itemId, java.lang.String itemPath, StatusEnum status)Checks does test item have parent with provided status.voidinterruptInProgressItems(java.lang.Long launchId)Interrupts allStatusEnum.IN_PROGRESSchildren items of the launch with provided launchId.java.util.List<java.lang.Long>selectAllDescendantsIds(java.lang.String path)Finds all descendants ids ofTestItemwithpathinclude its own idjava.util.stream.Stream<java.math.BigInteger>streamIdsByHasChildrenAndLaunchIdAndStatusOrderedByPathLevel(java.lang.Long launchId, StatusEnum status)Retrieve theListof theTestItem.itemIdby launch ID,Enum.name()andTestItem.hasChildren== true ordered (DESCENDING) by 'nlevel' of theTestItem.pathjava.util.stream.Stream<java.math.BigInteger>streamIdsByHasChildrenAndParentPathAndStatusOrderedByPathLevel(java.lang.String parentPath, StatusEnum status)Retrieve theStreamof theTestItem.itemIdunder parentTestItem.path,Enum.name()andTestItem.hasChildren== true ordered (DESCENDING) by 'nlevel' of theTestItem.pathjava.util.stream.Stream<java.math.BigInteger>streamIdsByNotHasChildrenAndLaunchIdAndStatus(java.lang.Long launchId, StatusEnum status)Retrieve theListof theTestItem.itemIdby launch ID,Enum.name()andTestItem.hasChildren== falsejava.util.stream.Stream<java.math.BigInteger>streamIdsByNotHasChildrenAndParentPathAndStatus(java.lang.String parentPath, StatusEnum status)Retrieve theStreamof theTestItem.itemIdunder parentTestItem.path,Enum.name()andTestItem.hasChildren== falsejava.util.stream.Stream<java.lang.Long>streamTestItemIdsByLaunchId(java.lang.Long launchId)-
Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteById, existsById, findById, save
-
Methods inherited from interface com.epam.ta.reportportal.dao.FilterableRepository
findByFilter, findByFilter
-
Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAllById, flush, getOne, saveAll, saveAndFlush
-
Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAll
-
Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findOne
-
Methods inherited from interface com.epam.ta.reportportal.dao.ReportPortalRepository
exists, refresh
-
Methods inherited from interface com.epam.ta.reportportal.dao.TestItemRepositoryCustom
findAllInIssueGroupByLaunch, findAllNestedStepsByIds, findAllNotInIssueByLaunch, findAllNotInIssueGroupByLaunch, findByFilter, getTypeByItemId, hasItemsInStatusAddedLately, hasItemsInStatusByLaunch, hasLogs, loadItemsHistoryPage, loadItemsHistoryPage, loadItemsHistoryPage, loadItemsHistoryPage, loadItemsHistoryPage, selectAllDescendants, selectAllDescendantsWithChildren, selectIdsByAnalyzedWithLevelGte, selectIdsByRegexPatternMatchedLogMessage, selectIdsByStringPatternMatchedLogMessage, selectIdsNotInIssueByLaunch, selectIdsNotInIssueGroupByLaunch, selectIdsWithIssueByLaunch, selectIssueLocatorsByProject, selectIssueTypeByLocator, selectItemsInIssueByLaunch, selectItemsInStatusByLaunch, selectItemsInStatusByParent, selectPathNames, selectPathNames, selectRetries, updateStatusAndEndTimeById
-
-
-
-
Method Detail
-
streamTestItemIdsByLaunchId
@QueryHints() @Query("SELECT ti.id FROM TestItem ti WHERE ti.launchId = :launchId") java.util.stream.Stream<java.lang.Long> streamTestItemIdsByLaunchId(@Param("launchId") java.lang.Long launchId)
-
findParentByChildId
@Query("SELECT parent FROM TestItem child JOIN child.parent parent WHERE child.itemId = :childId") java.util.Optional<TestItem> findParentByChildId(@Param("childId") java.lang.Long childId)
-
streamIdsByNotHasChildrenAndLaunchIdAndStatus
@QueryHints() @Query(value="SELECT test_item.item_id FROM test_item JOIN test_item_results result ON test_item.item_id = result.result_id WHERE test_item.launch_id = :launchId AND NOT test_item.has_children AND result.status = cast(:#{#status.name()} AS STATUS_ENUM)", nativeQuery=true) java.util.stream.Stream<java.math.BigInteger> streamIdsByNotHasChildrenAndLaunchIdAndStatus(@Param("launchId") java.lang.Long launchId, @Param("status") StatusEnum status)Retrieve theListof theTestItem.itemIdby launch ID,Enum.name()andTestItem.hasChildren== false- Parameters:
launchId-Launch.idstatus-Enum.name()- Returns:
- the
Listof theTestItem.itemId
-
streamIdsByHasChildrenAndLaunchIdAndStatusOrderedByPathLevel
@QueryHints() @Query(value="SELECT test_item.item_id FROM test_item JOIN test_item_results result ON test_item.item_id = result.result_id WHERE test_item.launch_id = :launchId AND test_item.has_children AND result.status = cast(:#{#status.name()} AS STATUS_ENUM) ORDER BY nlevel(test_item.path) DESC", nativeQuery=true) java.util.stream.Stream<java.math.BigInteger> streamIdsByHasChildrenAndLaunchIdAndStatusOrderedByPathLevel(@Param("launchId") java.lang.Long launchId, @Param("status") StatusEnum status)Retrieve theListof theTestItem.itemIdby launch ID,Enum.name()andTestItem.hasChildren== true ordered (DESCENDING) by 'nlevel' of theTestItem.path- Parameters:
launchId-Launch.idstatus-Enum.name()- Returns:
- the
Listof theTestItem.itemId - See Also:
- https://www.postgresql.org/docs/current/ltree.html
-
streamIdsByNotHasChildrenAndParentPathAndStatus
@QueryHints() @Query(value="SELECT test_item.item_id FROM test_item JOIN test_item_results result ON test_item.item_id = result.result_id WHERE cast(:parentPath AS LTREE) @> test_item.path AND cast(:parentPath AS LTREE) != test_item.path AND NOT test_item.has_children AND result.status = cast(:#{#status.name()} AS STATUS_ENUM)", nativeQuery=true) java.util.stream.Stream<java.math.BigInteger> streamIdsByNotHasChildrenAndParentPathAndStatus(@Param("parentPath") java.lang.String parentPath, @Param("status") StatusEnum status)Retrieve theStreamof theTestItem.itemIdunder parentTestItem.path,Enum.name()andTestItem.hasChildren== false- Parameters:
parentPath-TestItem.pathof the parent itemstatus-Enum.name()- Returns:
- the
Listof theTestItem.itemId
-
streamIdsByHasChildrenAndParentPathAndStatusOrderedByPathLevel
@QueryHints() @Query(value="SELECT test_item.item_id FROM test_item JOIN test_item_results result ON test_item.item_id = result.result_id WHERE cast(:parentPath AS LTREE) @> test_item.path AND cast(:parentPath AS LTREE) != test_item.path AND test_item.has_children AND result.status = cast(:#{#status.name()} AS STATUS_ENUM) ORDER BY nlevel(test_item.path) DESC", nativeQuery=true) java.util.stream.Stream<java.math.BigInteger> streamIdsByHasChildrenAndParentPathAndStatusOrderedByPathLevel(@Param("parentPath") java.lang.String parentPath, @Param("status") StatusEnum status)Retrieve theStreamof theTestItem.itemIdunder parentTestItem.path,Enum.name()andTestItem.hasChildren== true ordered (DESCENDING) by 'nlevel' of theTestItem.path- Parameters:
parentPath-TestItem.pathof the parent itemstatus-Enum.name()- Returns:
- the
Listof theTestItem.itemId - See Also:
- https://www.postgresql.org/docs/current/ltree.html
-
findTestItemsByUniqueId
java.util.List<TestItem> findTestItemsByUniqueId(java.lang.String uniqueId)
-
findTestItemsByLaunchId
java.util.List<TestItem> findTestItemsByLaunchId(java.lang.Long launchId)
-
findByUuid
java.util.Optional<TestItem> findByUuid(java.lang.String uuid)
-
findByUuidForUpdate
@Query("SELECT ti FROM TestItem ti WHERE ti.uuid = :uuid") @Lock(PESSIMISTIC_WRITE) java.util.Optional<TestItem> findByUuidForUpdate(@Param("uuid") java.lang.String uuid)FindsTestItembyTestItem.getUuid()and sets a lock on the found 'item' row in the database. Required for fetching 'item' from the concurrent environment to provide synchronization between dependant entities- Parameters:
uuid-TestItem.getUuid()- Returns:
OptionalwithTestItemobject
-
findTestItemsByLaunchIdOrderByStartTimeAsc
java.util.List<TestItem> findTestItemsByLaunchIdOrderByStartTimeAsc(java.lang.Long launchId)
Finds allTestItemby specified launch id- Parameters:
launchId-Launch.id- Returns:
ListofTestItemordered byTestItem.startTimeascending
-
handleRetries
@Query(value="SELECT handle_retries(:itemId)", nativeQuery=true) void handleRetries(@Param("itemId") java.lang.Long itemId)Execute sql-function that changes a structure of retries according to the MAXTestItem.startTime. If the new-insertedTestItemwith specifiedTestItem.itemIdis a retry and it hasTestItem.startTimegreater than MAXTestItem.startTimeof the otherTestItemwith the sameTestItem.uniqueIdthen all those test items become retries of the new-inserted one: theirsTestItem.hasRetriesflag is set to 'false' andTestItem.retryOfgets the new-insertedTestItem.itemIdvalue. The same operation applies to the new-insertedTestItemif itsTestItem.startTimeis less than MAXTestItem.startTimeof the otherTestItemwith the sameTestItem.uniqueId- Parameters:
itemId- The new-insertedTestItem.itemId
-
deleteTestItem
@Query(value="DELETE FROM test_item WHERE test_item.item_id = :itemId", nativeQuery=true) void deleteTestItem(@Param("itemId") java.lang.Long itemId)
-
hasChildren
@Query(value="SELECT exists(SELECT 1 FROM test_item t WHERE t.path <@ cast(:itemPath AS LTREE) AND t.item_id != :itemId LIMIT 1)", nativeQuery=true) boolean hasChildren(@Param("itemId") java.lang.Long itemId, @Param("itemPath") java.lang.String itemPath)Checks does test item have children.- Parameters:
itemPath- Current item path in a tree- Returns:
- True if has
-
hasParentWithStatus
@Query(value="SELECT exists(SELECT 1 FROM test_item ti JOIN test_item_results tir ON ti.item_id = tir.result_id WHERE ti.path @> cast(:itemPath AS LTREE) AND ti.has_stats = TRUE AND ti.item_id != :itemId AND tir.status = cast(:#{#status.name()} AS STATUS_ENUM) LIMIT 1)", nativeQuery=true) boolean hasParentWithStatus(@Param("itemId") java.lang.Long itemId, @Param("itemPath") java.lang.String itemPath, @Param("status") StatusEnum status)Checks does test item have parent with provided status.- Parameters:
itemId- Cuttent item iditemPath- Current item path in a treestatus-StatusEnum- Returns:
- 'True' if has, otherwise 'false'
-
hasDescendantsNotInStatus
@Query(value="SELECT exists(SELECT 1 FROM test_item ti JOIN test_item_results tir ON ti.item_id = tir.result_id WHERE ti.parent_id = :parentId AND ti.retry_of IS NULL AND CAST(tir.status AS VARCHAR) NOT IN (:statuses))", nativeQuery=true) boolean hasDescendantsNotInStatus(@Param("parentId") java.lang.Long parentId, @Param("statuses") java.lang.String... statuses)Check for existence of descendants with statuses NOT EQUAL to provided status- Parameters:
parentId-TestItem.getParent()IDstatuses-Enum.name()Array- Returns:
- 'true' if items with statuses NOT EQUAL to provided status exist, otherwise 'false'
-
hasItemsInStatusByParent
@Query(value="SELECT exists(SELECT 1 FROM test_item ti JOIN test_item_results tir ON ti.item_id = tir.result_id WHERE ti.path <@ cast(:parentPath AS LTREE) AND ti.item_id != :parentId AND cast(tir.status AS VARCHAR) IN (:statuses))", nativeQuery=true) boolean hasItemsInStatusByParent(@Param("parentId") java.lang.Long parentId, @Param("parentPath") java.lang.String parentPath, @Param("statuses") java.lang.String... statuses)True if the parent item has any child items with provided status.- Parameters:
parentId- parent itemTestItem.getItemId()parentPath- parent itemTestItem.getPath()statuses- child itemTestItemResults.getStatus()- Returns:
- True if contains, false if not
-
interruptInProgressItems
@Modifying @Query(value="UPDATE test_item_results SET status = \'INTERRUPTED\', end_time = current_timestamp, duration = EXTRACT(EPOCH FROM current_timestamp - i.start_time)FROM test_item i WHERE i.item_id = result_id AND i.launch_id = :launchId AND status = \'IN_PROGRESS\'", nativeQuery=true) void interruptInProgressItems(@Param("launchId") java.lang.Long launchId)Interrupts allStatusEnum.IN_PROGRESSchildren items of the launch with provided launchId. Sets themStatusEnum.INTERRUPTEDstatus- Parameters:
launchId- Launch id
-
hasDescendantsNotInStatusExcludingById
@Query(value="SELECT exists(SELECT 1 FROM test_item JOIN test_item_results result ON test_item.item_id = result.result_id WHERE test_item.parent_id = :parentId AND test_item.item_id != :stepId AND test_item.retry_of IS NULL AND CAST(result.status AS VARCHAR) NOT IN (:statuses))", nativeQuery=true) boolean hasDescendantsNotInStatusExcludingById(@Param("parentId") java.lang.Long parentId, @Param("stepId") java.lang.Long stepId, @Param("statuses") java.lang.String... statuses)Checks if all children of test item with id =parentId, except item with id =stepId, has status not in providedstatuses- Parameters:
parentId- Id of parent test itemstepId- Id of test item that should be ignored during the checkingstatuses-Enum.name()Array- Returns:
- True if has
-
findByNameAndLaunchWithoutParents
@Query("SELECT t FROM TestItem t WHERE t.name=:name AND t.parent IS NULL AND t.launchId=:launchId") java.util.Optional<TestItem> findByNameAndLaunchWithoutParents(@Param("name") java.lang.String name, @Param("launchId") java.lang.Long launchId)
-
findByNameAndLaunchUnderPath
@Query(value="SELECT * FROM test_item t WHERE t.name=:name AND t.launch_id=:launchId AND t.path <@ cast(:path AS LTREE)", nativeQuery=true) java.util.Optional<TestItem> findByNameAndLaunchUnderPath(@Param("name") java.lang.String name, @Param("launchId") java.lang.Long launchId, @Param("path") java.lang.String path)
-
selectAllDescendantsIds
@Query(value="SELECT item_id FROM test_item WHERE path <@ cast(:path AS LTREE)", nativeQuery=true) java.util.List<java.lang.Long> selectAllDescendantsIds(@Param("path") java.lang.String path)Finds all descendants ids ofTestItemwithpathinclude its own id- Parameters:
path- Path ofTestItem- Returns:
Listof test item ids
-
deleteAllByItemIdIn
void deleteAllByItemIdIn(java.util.Collection<java.lang.Long> ids)
-
-