use of com.linkedin.thirdeye.datalayer.util.Predicate in project pinot by linkedin.
the class TaskManagerImpl method updateStatusAndWorkerId.
@Override
public boolean updateStatusAndWorkerId(Long workerId, Long id, Set<TaskStatus> permittedOldStatus, TaskStatus newStatus, int expectedVersion) {
TaskDTO task = findById(id);
if (permittedOldStatus.contains(task.getStatus())) {
task.setStatus(newStatus);
task.setWorkerId(workerId);
//increment the version
task.setVersion(expectedVersion + 1);
Predicate predicate = Predicate.AND(Predicate.EQ("id", id), Predicate.EQ("version", expectedVersion));
int update = update(task, predicate);
return update == 1;
} else {
return false;
}
}
use of com.linkedin.thirdeye.datalayer.util.Predicate in project pinot by linkedin.
the class TaskManagerImpl method findByJobIdStatusNotIn.
@Override
public List<TaskDTO> findByJobIdStatusNotIn(Long jobId, TaskStatus status) {
Predicate jobIdPredicate = Predicate.EQ("jobId", jobId);
Predicate statusPredicate = Predicate.NEQ("status", status.toString());
List<TaskBean> list = genericPojoDao.get(Predicate.AND(statusPredicate, jobIdPredicate), TaskBean.class);
List<TaskDTO> result = new ArrayList<>();
for (TaskBean bean : list) {
result.add((TaskDTO) MODEL_MAPPER.map(bean, TaskDTO.class));
}
return result;
}
use of com.linkedin.thirdeye.datalayer.util.Predicate in project pinot by linkedin.
the class TaskManagerImpl method findByStatusNotIn.
@Override
@Transactional
public List<TaskDTO> findByStatusNotIn(TaskStatus status) {
Predicate statusPredicate = Predicate.NEQ("status", status.toString());
List<TaskBean> list = genericPojoDao.get(statusPredicate, TaskBean.class);
List<TaskDTO> result = new ArrayList<>();
for (TaskBean bean : list) {
result.add((TaskDTO) MODEL_MAPPER.map(bean, TaskDTO.class));
}
return result;
}
Aggregations