added findByKey method to service
This commit is contained in:
parent
44a4d9d690
commit
5f9afd14d3
@ -37,4 +37,6 @@ public interface JobService extends EntityDaoService {
|
||||
|
||||
PageData<Job> findJobsByTenantId(TenantId tenantId, PageLink pageLink);
|
||||
|
||||
Job findJobByKey(TenantId tenantId, String key);
|
||||
|
||||
}
|
||||
|
||||
@ -29,8 +29,8 @@ import org.thingsboard.server.common.data.job.JobResult;
|
||||
import org.thingsboard.server.common.data.job.JobStats;
|
||||
import org.thingsboard.server.common.data.job.JobStatus;
|
||||
import org.thingsboard.server.common.data.job.JobType;
|
||||
import org.thingsboard.server.common.data.job.TaskResult;
|
||||
import org.thingsboard.server.common.data.job.TaskFailure;
|
||||
import org.thingsboard.server.common.data.job.TaskResult;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
import org.thingsboard.server.common.data.page.PageLink;
|
||||
import org.thingsboard.server.dao.entity.AbstractEntityService;
|
||||
@ -187,6 +187,11 @@ public class DefaultJobService extends AbstractEntityService implements JobServi
|
||||
return jobDao.findByTenantId(tenantId, pageLink);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Job findJobByKey(TenantId tenantId, String key) {
|
||||
return jobDao.findByKey(tenantId, key);
|
||||
}
|
||||
|
||||
private Job findForUpdate(TenantId tenantId, JobId jobId) {
|
||||
return jobDao.findByIdForUpdate(tenantId, jobId);
|
||||
}
|
||||
|
||||
@ -30,6 +30,8 @@ public interface JobDao extends Dao<Job> {
|
||||
|
||||
Job findByIdForUpdate(TenantId tenantId, JobId jobId);
|
||||
|
||||
Job findByKey(TenantId tenantId, String key);
|
||||
|
||||
boolean existsByKeyAndStatusOneOf(String key, JobStatus... statuses);
|
||||
|
||||
boolean existsByTenantIdAndTypeAndStatusOneOf(TenantId tenantId, JobType type, JobStatus... statuses);
|
||||
|
||||
@ -45,6 +45,8 @@ public interface JobRepository extends JpaRepository<JobEntity, UUID> {
|
||||
@Query("SELECT j FROM JobEntity j WHERE j.id = :id")
|
||||
JobEntity findByIdForUpdate(UUID id);
|
||||
|
||||
JobEntity findByTenantIdAndKey(@Param("tenantId") UUID tenantId, @Param("key") String key);
|
||||
|
||||
boolean existsByKeyAndStatusIn(String key, List<JobStatus> statuses);
|
||||
|
||||
boolean existsByTenantIdAndTypeAndStatusIn(UUID tenantId, JobType type, List<JobStatus> statuses);
|
||||
|
||||
@ -29,9 +29,9 @@ import org.thingsboard.server.common.data.job.JobType;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
import org.thingsboard.server.common.data.page.PageLink;
|
||||
import org.thingsboard.server.dao.DaoUtil;
|
||||
import org.thingsboard.server.dao.job.JobDao;
|
||||
import org.thingsboard.server.dao.model.sql.JobEntity;
|
||||
import org.thingsboard.server.dao.sql.JpaAbstractDao;
|
||||
import org.thingsboard.server.dao.job.JobDao;
|
||||
import org.thingsboard.server.dao.util.SqlDao;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -54,6 +54,11 @@ public class JpaJobDao extends JpaAbstractDao<JobEntity, Job> implements JobDao
|
||||
return DaoUtil.getData(jobRepository.findByIdForUpdate(jobId.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Job findByKey(TenantId tenantId, String key) {
|
||||
return DaoUtil.getData(jobRepository.findByTenantIdAndKey(tenantId.getId(), key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existsByKeyAndStatusOneOf(String key, JobStatus... statuses) {
|
||||
return jobRepository.existsByKeyAndStatusIn(key, Arrays.stream(statuses).toList());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user