Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public Optional<Job> fetchLastWorkflowJob(List<String> workflowIds) {
throw new UnsupportedOperationException();
}

@Override
public List<Long> getChildJobIds(long parentJobId) {
throw new UnsupportedOperationException();
}

@Override
public List<Job> getJobs(List<Long> ids) {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public interface JobService {

Optional<Job> fetchLastWorkflowJob(List<String> workflowIds);

List<Long> getChildJobIds(long parentJobId);

Job getJob(long id);

List<Job> getJobs(List<Long> ids);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public interface JobRepository {

List<Job> findAllByIdIn(List<Long> ids);

List<Long> findAllIdsByParentJobId(Long parentJobId);

List<Job> findAllByWorkflowId(String workflowId);

Optional<Job> findById(Long id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,10 @@ public interface JdbcJobRepository
@Query("SELECT * FROM job j WHERE j.id = (SELECT job_id FROM task_execution te WHERE te.id=:taskExecutionId)")
Optional<Job> findByTaskExecutionId(@Param("taskExecutionId") Long taskExecutionId);

@Override
@Query("SELECT j.id FROM job j WHERE j.parent_task_execution_id IN "
+ "(SELECT te.id FROM task_execution te WHERE te.job_id=:parentJobId)")
List<Long> findAllIdsByParentJobId(@Param("parentJobId") Long parentJobId);

Job save(Job job);
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@ public List<Job> findAllByWorkflowId(String workflowId) {
throw new UnsupportedOperationException();
}

@Override
public List<Long> findAllIdsByParentJobId(Long parentJobId) {
List<Long> parentTaskExecutionIds = inMemoryTaskExecutionRepository.findAllByJobIdOrderByIdDesc(parentJobId)
.stream()
.map(TaskExecution::getId)
.filter(Objects::nonNull)
.toList();

return cache.values()
.stream()
.filter(job -> {
Long parentTaskExecutionId = job.getParentTaskExecutionId();

return parentTaskExecutionId != null && parentTaskExecutionIds.contains(parentTaskExecutionId);
})
.map(Job::getId)
.filter(Objects::nonNull)
.toList();
}

@Override
public Optional<Job> findById(Long id) {
return Optional.ofNullable(cache.get(TenantCacheKeyUtils.getKey(id)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public long createJob(JobParametersDTO jobParametersDTO) {
@Override
@Transactional
public void deleteJob(long id) {
for (long childJobId : jobService.getChildJobIds(id)) {
deleteJob(childJobId);
}

taskExecutionService.deleteJobTaskExecutions(id);

jobService.deleteJob(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ public Optional<Job> fetchLastWorkflowJob(List<String> workflowIds) {
return jobRepository.findTop1ByWorkflowIdInOrderByIdDesc(workflowIds);
}

@Override
@Transactional(readOnly = true)
public List<Long> getChildJobIds(long parentJobId) {
return jobRepository.findAllIdsByParentJobId(parentJobId);
}

@Override
@Transactional(readOnly = true)
public Job getJob(long id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@

public record JobServiceWrapper(JobSyncExecutor.JobFactoryFunction jobFactoryFunction) implements JobService {

@Override
public List<Long> getChildJobIds(long parentJobId) {
throw new UnsupportedOperationException();
}

@Override
public Job getJob(long id) {
throw new UnsupportedOperationException();
Expand Down
Loading