Search in sources :

Example 1 with PageInfo

use of org.apache.dolphinscheduler.api.utils.PageInfo in project dolphinscheduler by apache.

the class ProcessDefinitionService method queryProcessDefinitionListPaging.

/**
 * query process definition list paging
 *
 * @param loginUser login user
 * @param projectName project name
 * @param searchVal search value
 * @param pageNo page number
 * @param pageSize page size
 * @param userId user id
 * @return process definition page
 */
public Map<String, Object> queryProcessDefinitionListPaging(User loginUser, String projectName, String searchVal, Integer pageNo, Integer pageSize, Integer userId) {
    Map<String, Object> result = new HashMap<>(5);
    Project project = projectMapper.queryByName(projectName);
    Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
    Status resultStatus = (Status) checkResult.get(Constants.STATUS);
    if (resultStatus != Status.SUCCESS) {
        return checkResult;
    }
    Page<ProcessDefinition> page = new Page(pageNo, pageSize);
    IPage<ProcessDefinition> processDefinitionIPage = processDefineMapper.queryDefineListPaging(page, searchVal, userId, project.getId(), isAdmin(loginUser));
    PageInfo pageInfo = new PageInfo<ProcessData>(pageNo, pageSize);
    pageInfo.setTotalCount((int) processDefinitionIPage.getTotal());
    pageInfo.setLists(processDefinitionIPage.getRecords());
    result.put(Constants.DATA_LIST, pageInfo);
    putMsg(result, Status.SUCCESS);
    return result;
}
Also used : Status(org.apache.dolphinscheduler.api.enums.Status) Project(org.apache.dolphinscheduler.dao.entity.Project) PageInfo(org.apache.dolphinscheduler.api.utils.PageInfo) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) ProcessDefinition(org.apache.dolphinscheduler.dao.entity.ProcessDefinition) IPage(com.baomidou.mybatisplus.core.metadata.IPage) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page)

Example 2 with PageInfo

use of org.apache.dolphinscheduler.api.utils.PageInfo in project dolphinscheduler by apache.

the class BaseController method returnDataListPaging.

/**
 * return data list with paging
 * @param result result code
 * @return result code
 */
public Result returnDataListPaging(Map<String, Object> result) {
    Status status = (Status) result.get(Constants.STATUS);
    if (status == Status.SUCCESS) {
        result.put(Constants.MSG, Status.SUCCESS.getMsg());
        PageInfo<Resource> pageInfo = (PageInfo<Resource>) result.get(Constants.DATA_LIST);
        return success(pageInfo.getLists(), pageInfo.getCurrentPage(), pageInfo.getTotalCount(), pageInfo.getTotalPage());
    } else {
        Integer code = status.getCode();
        String msg = (String) result.get(Constants.MSG);
        return error(code, msg);
    }
}
Also used : Status(org.apache.dolphinscheduler.api.enums.Status) PageInfo(org.apache.dolphinscheduler.api.utils.PageInfo) Resource(org.apache.dolphinscheduler.dao.entity.Resource)

Example 3 with PageInfo

use of org.apache.dolphinscheduler.api.utils.PageInfo in project dolphinscheduler by apache.

the class ProjectService method queryProjectListPaging.

/**
 * admin can view all projects
 *
 * @param loginUser login user
 * @param searchVal search value
 * @param pageSize page size
 * @param pageNo page number
 * @return project list which the login user have permission to see
 */
public Map<String, Object> queryProjectListPaging(User loginUser, Integer pageSize, Integer pageNo, String searchVal) {
    Map<String, Object> result = new HashMap<>();
    PageInfo pageInfo = new PageInfo<Project>(pageNo, pageSize);
    Page<Project> page = new Page(pageNo, pageSize);
    int userId = loginUser.getUserType() == UserType.ADMIN_USER ? 0 : loginUser.getId();
    IPage<Project> projectIPage = projectMapper.queryProjectListPaging(page, userId, searchVal);
    List<Project> projectList = projectIPage.getRecords();
    if (userId != 0) {
        for (Project project : projectList) {
            project.setPerm(org.apache.dolphinscheduler.common.Constants.DEFAULT_ADMIN_PERMISSION);
        }
    }
    pageInfo.setTotalCount((int) projectIPage.getTotal());
    pageInfo.setLists(projectList);
    result.put(Constants.COUNT, (int) projectIPage.getTotal());
    result.put(Constants.DATA_LIST, pageInfo);
    putMsg(result, Status.SUCCESS);
    return result;
}
Also used : Project(org.apache.dolphinscheduler.dao.entity.Project) PageInfo(org.apache.dolphinscheduler.api.utils.PageInfo) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Example 4 with PageInfo

use of org.apache.dolphinscheduler.api.utils.PageInfo in project dolphinscheduler by apache.

the class ResourcesService method queryResourceListPaging.

/**
 * query resources list paging
 *
 * @param loginUser login user
 * @param type resource type
 * @param searchVal search value
 * @param pageNo page number
 * @param pageSize page size
 * @return resource list page
 */
public Map<String, Object> queryResourceListPaging(User loginUser, int direcotryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize) {
    HashMap<String, Object> result = new HashMap<>(5);
    Page<Resource> page = new Page(pageNo, pageSize);
    int userId = loginUser.getId();
    if (isAdmin(loginUser)) {
        userId = 0;
    }
    if (direcotryId != -1) {
        Resource directory = resourcesMapper.selectById(direcotryId);
        if (directory == null) {
            putMsg(result, Status.RESOURCE_NOT_EXIST);
            return result;
        }
    }
    IPage<Resource> resourceIPage = resourcesMapper.queryResourcePaging(page, userId, direcotryId, type.ordinal(), searchVal);
    PageInfo pageInfo = new PageInfo<Resource>(pageNo, pageSize);
    pageInfo.setTotalCount((int) resourceIPage.getTotal());
    pageInfo.setLists(resourceIPage.getRecords());
    result.put(Constants.DATA_LIST, pageInfo);
    putMsg(result, Status.SUCCESS);
    return result;
}
Also used : PageInfo(org.apache.dolphinscheduler.api.utils.PageInfo) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Example 5 with PageInfo

use of org.apache.dolphinscheduler.api.utils.PageInfo 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)

Aggregations

PageInfo (org.apache.dolphinscheduler.api.utils.PageInfo)18 IPage (com.baomidou.mybatisplus.core.metadata.IPage)13 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)13 User (org.apache.dolphinscheduler.dao.entity.User)7 Test (org.junit.Test)7 Project (org.apache.dolphinscheduler.dao.entity.Project)5 Status (org.apache.dolphinscheduler.api.enums.Status)4 HashMap (java.util.HashMap)3 JSONObject (com.alibaba.fastjson.JSONObject)2 ExecutionStatus (org.apache.dolphinscheduler.common.enums.ExecutionStatus)2 ProcessDefinition (org.apache.dolphinscheduler.dao.entity.ProcessDefinition)2 Resource (org.apache.dolphinscheduler.dao.entity.Resource)2 UdfFunc (org.apache.dolphinscheduler.dao.entity.UdfFunc)2 WorkerGroup (org.apache.dolphinscheduler.dao.entity.WorkerGroup)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 PropertyUtils.getString (org.apache.dolphinscheduler.common.utils.PropertyUtils.getString)1 AccessToken (org.apache.dolphinscheduler.dao.entity.AccessToken)1