Search in sources :

Example 1 with TaskRecord

use of org.apache.dolphinscheduler.dao.entity.TaskRecord in project dolphinscheduler by apache.

the class TaskRecordDao method getQueryResult.

/**
 * query task list by select sql
 *
 * @param selectSql select sql
 * @return task record list
 */
private static List<TaskRecord> getQueryResult(String selectSql) {
    List<TaskRecord> recordList = new ArrayList<>();
    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        conn = getConn();
        if (conn == null) {
            return recordList;
        }
        pstmt = conn.prepareStatement(selectSql);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            TaskRecord taskRecord = convertToTaskRecord(rs);
            recordList.add(taskRecord);
        }
    } catch (SQLException e) {
        logger.error("Exception ", e);
    } finally {
        ConnectionUtils.releaseResource(rs, pstmt, conn);
    }
    return recordList;
}
Also used : TaskRecord(org.apache.dolphinscheduler.dao.entity.TaskRecord) ArrayList(java.util.ArrayList)

Example 2 with TaskRecord

use of org.apache.dolphinscheduler.dao.entity.TaskRecord in project dolphinscheduler by apache.

the class TaskRecordService method queryTaskRecordListPaging.

/**
 * query task record list paging
 *
 * @param taskName task name
 * @param state state
 * @param sourceTable source table
 * @param destTable destination table
 * @param taskDate task date
 * @param startDate start time
 * @param endDate end time
 * @param pageNo page numbere
 * @param pageSize page size
 * @param isHistory is history
 * @return task record list
 */
public Map<String, Object> queryTaskRecordListPaging(boolean isHistory, String taskName, String startDate, String taskDate, String sourceTable, String destTable, String endDate, String state, Integer pageNo, Integer pageSize) {
    Map<String, Object> result = new HashMap<>(10);
    PageInfo pageInfo = new PageInfo<TaskRecord>(pageNo, pageSize);
    Map<String, String> map = new HashMap<>(10);
    map.put("taskName", taskName);
    map.put("taskDate", taskDate);
    map.put("state", state);
    map.put("sourceTable", sourceTable);
    map.put("targetTable", destTable);
    map.put("startTime", startDate);
    map.put("endTime", endDate);
    map.put("offset", pageInfo.getStart().toString());
    map.put("pageSize", pageInfo.getPageSize().toString());
    String table = isHistory ? TASK_RECORD_TABLE_HISTORY_HIVE_LOG : TASK_RECORD_TABLE_HIVE_LOG;
    int count = TaskRecordDao.countTaskRecord(map, table);
    List<TaskRecord> recordList = TaskRecordDao.queryAllTaskRecord(map, table);
    pageInfo.setTotalCount(count);
    pageInfo.setLists(recordList);
    result.put(Constants.DATA_LIST, pageInfo);
    putMsg(result, Status.SUCCESS);
    return result;
}
Also used : PageInfo(org.apache.dolphinscheduler.api.utils.PageInfo) TaskRecord(org.apache.dolphinscheduler.dao.entity.TaskRecord) HashMap(java.util.HashMap)

Example 3 with TaskRecord

use of org.apache.dolphinscheduler.dao.entity.TaskRecord in project dolphinscheduler by apache.

the class TaskRecordDao method convertToTaskRecord.

/**
 * convert result set to task record
 *
 * @param resultSet resultSet
 * @return task record
 * @throws SQLException if error throws SQLException
 */
private static TaskRecord convertToTaskRecord(ResultSet resultSet) throws SQLException {
    TaskRecord taskRecord = new TaskRecord();
    taskRecord.setId(resultSet.getInt("ID"));
    taskRecord.setProcId(resultSet.getInt("PROC_ID"));
    taskRecord.setProcName(resultSet.getString("PROC_NAME"));
    taskRecord.setProcDate(resultSet.getString("PROC_DATE"));
    taskRecord.setStartTime(DateUtils.stringToDate(resultSet.getString("STARTDATE")));
    taskRecord.setEndTime(DateUtils.stringToDate(resultSet.getString("ENDDATE")));
    taskRecord.setResult(resultSet.getString("RESULT"));
    taskRecord.setDuration(resultSet.getInt("DURATION"));
    taskRecord.setNote(resultSet.getString("NOTE"));
    taskRecord.setSchema(resultSet.getString("SCHEMA"));
    taskRecord.setJobId(resultSet.getString("JOB_ID"));
    taskRecord.setSourceTab(resultSet.getString("SOURCE_TAB"));
    taskRecord.setSourceRowCount(resultSet.getLong("SOURCE_ROW_COUNT"));
    taskRecord.setTargetTab(resultSet.getString("TARGET_TAB"));
    taskRecord.setTargetRowCount(resultSet.getLong("TARGET_ROW_COUNT"));
    taskRecord.setErrorCode(resultSet.getString("ERROR_CODE"));
    return taskRecord;
}
Also used : TaskRecord(org.apache.dolphinscheduler.dao.entity.TaskRecord)

Aggregations

TaskRecord (org.apache.dolphinscheduler.dao.entity.TaskRecord)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 PageInfo (org.apache.dolphinscheduler.api.utils.PageInfo)1