Search in sources :

Example 1 with TaskBean

use of com.linkedin.thirdeye.datalayer.pojo.TaskBean in project pinot by linkedin.

the class TaskManagerImpl method findByStatusOrderByCreateTime.

@Override
public List<TaskDTO> findByStatusOrderByCreateTime(TaskStatus status, int fetchSize, boolean asc) {
    Map<String, Object> parameterMap = new HashMap<>();
    parameterMap.put("status", status.toString());
    List<TaskBean> list;
    String queryClause = (asc) ? FIND_BY_STATUS_ORDER_BY_CREATE_TIME_ASC : FIND_BY_STATUS_ORDER_BY_CREATE_TIME_DESC;
    list = genericPojoDao.executeParameterizedSQL(queryClause, parameterMap, TaskBean.class);
    List<TaskDTO> result = new ArrayList<>();
    for (TaskBean bean : list) {
        result.add((TaskDTO) MODEL_MAPPER.map(bean, TaskDTO.class));
    }
    return result;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TaskBean(com.linkedin.thirdeye.datalayer.pojo.TaskBean) TaskDTO(com.linkedin.thirdeye.datalayer.dto.TaskDTO)

Example 2 with TaskBean

use of com.linkedin.thirdeye.datalayer.pojo.TaskBean in project pinot by linkedin.

the class TaskManagerImpl method deleteRecordsOlderThanDaysWithStatus.

@Override
@Transactional
public int deleteRecordsOlderThanDaysWithStatus(int days, TaskStatus status) {
    DateTime expireDate = new DateTime().minusDays(days);
    Timestamp expireTimestamp = new Timestamp(expireDate.getMillis());
    Predicate timestampPredicate = Predicate.LT("createTime", expireTimestamp);
    Predicate statusPredicate = Predicate.EQ("status", status.toString());
    List<TaskBean> list = genericPojoDao.get(Predicate.AND(statusPredicate, timestampPredicate), TaskBean.class);
    for (TaskBean bean : list) {
        deleteById(bean.getId());
    }
    return list.size();
}
Also used : TaskBean(com.linkedin.thirdeye.datalayer.pojo.TaskBean) Timestamp(java.sql.Timestamp) DateTime(org.joda.time.DateTime) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate) Transactional(com.google.inject.persist.Transactional)

Example 3 with TaskBean

use of com.linkedin.thirdeye.datalayer.pojo.TaskBean 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;
}
Also used : ArrayList(java.util.ArrayList) TaskBean(com.linkedin.thirdeye.datalayer.pojo.TaskBean) TaskDTO(com.linkedin.thirdeye.datalayer.dto.TaskDTO) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate)

Example 4 with TaskBean

use of com.linkedin.thirdeye.datalayer.pojo.TaskBean in project pinot by linkedin.

the class TaskManagerImpl method save.

public Long save(TaskDTO entity) {
    if (entity.getId() != null) {
        //TODO: throw exception and force the caller to call update instead
        update(entity);
        return entity.getId();
    }
    TaskBean bean = (TaskBean) convertDTO2Bean(entity, TaskBean.class);
    Long id = genericPojoDao.put(bean);
    entity.setId(id);
    return id;
}
Also used : TaskBean(com.linkedin.thirdeye.datalayer.pojo.TaskBean)

Example 5 with TaskBean

use of com.linkedin.thirdeye.datalayer.pojo.TaskBean 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;
}
Also used : ArrayList(java.util.ArrayList) TaskBean(com.linkedin.thirdeye.datalayer.pojo.TaskBean) TaskDTO(com.linkedin.thirdeye.datalayer.dto.TaskDTO) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate) Transactional(com.google.inject.persist.Transactional)

Aggregations

TaskBean (com.linkedin.thirdeye.datalayer.pojo.TaskBean)5 TaskDTO (com.linkedin.thirdeye.datalayer.dto.TaskDTO)3 Predicate (com.linkedin.thirdeye.datalayer.util.Predicate)3 ArrayList (java.util.ArrayList)3 Transactional (com.google.inject.persist.Transactional)2 Timestamp (java.sql.Timestamp)1 HashMap (java.util.HashMap)1 DateTime (org.joda.time.DateTime)1