Search in sources :

Example 6 with GetAllResponse

use of com.webank.wedatasphere.qualitis.response.GetAllResponse in project Qualitis by WeBankFinTech.

the class ProxyUserServiceImpl method getAllProxyUser.

@Override
public GeneralResponse<?> getAllProxyUser(PageRequest request) throws UnExpectedRequestException {
    // Check Arguments
    PageRequest.checkRequest(request);
    // Query by page and size
    int page = request.getPage();
    int size = request.getSize();
    Sort sort = new Sort(Sort.Direction.ASC, "id");
    Pageable pageable = org.springframework.data.domain.PageRequest.of(page, size, sort);
    List<ProxyUser> proxyUsers = proxyUserRepository.findAll(pageable).getContent();
    long total = proxyUserRepository.count();
    List<AddProxyUserResponse> proxyUserResponses = new ArrayList<>();
    for (ProxyUser proxyUser : proxyUsers) {
        AddProxyUserResponse tmp = new AddProxyUserResponse(proxyUser);
        proxyUserResponses.add(tmp);
    }
    GetAllResponse<AddProxyUserResponse> response = new GetAllResponse<>();
    response.setTotal(total);
    response.setData(proxyUserResponses);
    LOGGER.info("Succeed to find all proxyUsers, response: {}", response);
    return new GeneralResponse<>("200", "{&SUCCEED_TO_FIND_ALL_PROXYUSERS}", response);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) Pageable(org.springframework.data.domain.Pageable) ArrayList(java.util.ArrayList) Sort(org.springframework.data.domain.Sort) AddProxyUserResponse(com.webank.wedatasphere.qualitis.response.AddProxyUserResponse) ProxyUser(com.webank.wedatasphere.qualitis.entity.ProxyUser) GetAllResponse(com.webank.wedatasphere.qualitis.response.GetAllResponse)

Example 7 with GetAllResponse

use of com.webank.wedatasphere.qualitis.response.GetAllResponse in project Qualitis by WeBankFinTech.

the class RolePermissionServiceImpl method findAllRolePermission.

@Override
public GeneralResponse<GetAllResponse<RolePermissionResponse>> findAllRolePermission(PageRequest request) throws UnExpectedRequestException {
    // Check Arguments
    PageRequest.checkRequest(request);
    int page = request.getPage();
    int size = request.getSize();
    List<RolePermission> rolePermissions = rolePermissionDao.findAllRolePermission(page, size);
    long total = rolePermissionDao.countAll();
    List<RolePermissionResponse> rolePermissionResponses = new ArrayList<>();
    for (RolePermission rolePermission : rolePermissions) {
        RolePermissionResponse tmp = new RolePermissionResponse(rolePermission);
        rolePermissionResponses.add(tmp);
    }
    GetAllResponse<RolePermissionResponse> responses = new GetAllResponse<>();
    responses.setData(rolePermissionResponses);
    responses.setTotal(total);
    LOGGER.info("Succeed to find all role_permission, response: {}, current_user: {}", responses, HttpUtils.getUserName(httpServletRequest));
    return new GeneralResponse<>("200", "{&FIND_ALL_ROLE_PERMISSION_SUCCESSFULLY}", responses);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) RolePermissionResponse(com.webank.wedatasphere.qualitis.response.RolePermissionResponse) ArrayList(java.util.ArrayList) RolePermission(com.webank.wedatasphere.qualitis.entity.RolePermission) GetAllResponse(com.webank.wedatasphere.qualitis.response.GetAllResponse)

Example 8 with GetAllResponse

use of com.webank.wedatasphere.qualitis.response.GetAllResponse in project Qualitis by WeBankFinTech.

the class UserServiceImpl method findAllUser.

@Override
public GeneralResponse<GetAllResponse<UserResponse>> findAllUser(PageRequest request) throws UnExpectedRequestException {
    // Check Arguments
    PageRequest.checkRequest(request);
    int page = request.getPage();
    int size = request.getSize();
    List<User> users = userDao.findAllUser(page, size);
    long total = userDao.countAll();
    List<UserResponse> userResponses = new ArrayList<>();
    for (User user : users) {
        UserResponse tmp = new UserResponse(user);
        userResponses.add(tmp);
    }
    GetAllResponse<UserResponse> response = new GetAllResponse<>();
    response.setTotal(total);
    response.setData(userResponses);
    LOGGER.info("Succeed to find all users, response: {}, current_user: {}", response, HttpUtils.getUserName(httpServletRequest));
    return new GeneralResponse<>("200", "{&FIND_ALL_USERS_SUCCESSFULLY}", response);
}
Also used : UserResponse(com.webank.wedatasphere.qualitis.response.user.UserResponse) AddUserResponse(com.webank.wedatasphere.qualitis.response.user.AddUserResponse) GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) User(com.webank.wedatasphere.qualitis.entity.User) ArrayList(java.util.ArrayList) GetAllResponse(com.webank.wedatasphere.qualitis.response.GetAllResponse)

Example 9 with GetAllResponse

use of com.webank.wedatasphere.qualitis.response.GetAllResponse in project Qualitis by WeBankFinTech.

the class DepartmentServiceImpl method findAllDepartment.

@Override
public GeneralResponse<GetAllResponse<DepartmentResponse>> findAllDepartment(PageRequest request) throws UnExpectedRequestException {
    PageRequest.checkRequest(request);
    int page = request.getPage();
    int size = request.getSize();
    long total = departmentDao.countDepartment();
    List<Department> departmentList = departmentDao.findAllDepartment(page, size);
    List<DepartmentResponse> departmentResponses = new ArrayList<>(departmentList.size());
    for (Department department : departmentList) {
        departmentResponses.add(new DepartmentResponse(department));
    }
    GetAllResponse<DepartmentResponse> responses = new GetAllResponse<>();
    responses.setData(departmentResponses);
    responses.setTotal(total);
    LOGGER.info("Succeed to find all departments, page: {}, size: {}, departments: {}", page, size, responses);
    return new GeneralResponse("200", "{&GET_DEPARTMENT_SUCCESSFULLY}", responses);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) Department(com.webank.wedatasphere.qualitis.entity.Department) ArrayList(java.util.ArrayList) GetAllResponse(com.webank.wedatasphere.qualitis.response.GetAllResponse) DepartmentResponse(com.webank.wedatasphere.qualitis.response.DepartmentResponse)

Example 10 with GetAllResponse

use of com.webank.wedatasphere.qualitis.response.GetAllResponse in project Qualitis by WeBankFinTech.

the class ApplicationServiceImpl method filterStatusApplication.

@Override
public GeneralResponse<?> filterStatusApplication(FilterStatusRequest request) throws UnExpectedRequestException {
    // Check arguments
    FilterStatusRequest.checkRequest(request);
    String userName = HttpUtils.getUserName(httpServletRequest);
    if (request.getStatus() != null) {
        LOGGER.info("User: {} wants to find applications with status: {}", userName, request.getStatus());
    } else {
        LOGGER.info("User: {} wants to find all applications", userName);
    }
    List<Application> applicationList;
    Long total;
    Integer page = request.getPage();
    Integer size = request.getSize();
    if (request.getStatus() == null || request.getStatus().intValue() == 0) {
        // Paging find applications by user
        long currentTimeUser = System.currentTimeMillis();
        applicationList = applicationDao.findByCreateUser(userName, page, size);
        LOGGER.info("timechecker find page application :" + (System.currentTimeMillis() - currentTimeUser));
        long currentTimeCountUser = System.currentTimeMillis();
        total = applicationDao.countByCreateUser(userName);
        LOGGER.info("timechecker count application :" + (System.currentTimeMillis() - currentTimeCountUser));
    } else {
        // Paging find applications by user and status
        applicationList = applicationDao.findByCreateUserAndStatus(userName, request.getStatus(), request.getCommentType(), page, size);
        total = applicationDao.countByCreateUserAndStatus(userName, request.getStatus(), request.getCommentType());
    }
    long currentTimeResponse = System.currentTimeMillis();
    GetAllResponse<ApplicationResponse> getAllResponse = new GetAllResponse<>();
    List<ApplicationResponse> applicationResponses = new ArrayList<>();
    for (Application application : applicationList) {
        List<Task> tasks = taskDao.findByApplication(application);
        ApplicationResponse response = new ApplicationResponse(application, tasks, httpServletRequest.getHeader("Content-Language"));
        if (application.getCreateUser().equals(userName) || application.getExecuteUser().equals(userName)) {
            response.setKillOption(true);
        } else {
            response.setKillOption(false);
        }
        applicationResponses.add(response);
    }
    getAllResponse.setData(applicationResponses);
    getAllResponse.setTotal(total);
    List<String> applicationIdList = getAllResponse.getData().stream().map(ApplicationResponse::getApplicationId).collect(Collectors.toList());
    LOGGER.info("timechecker response :" + (System.currentTimeMillis() - currentTimeResponse));
    LOGGER.info("Succeed to find applications. size: {}, id of applications: {}", total, applicationIdList);
    return new GeneralResponse<>("200", "{&SUCCEED_TO_GET_APPLICATIONS}", getAllResponse);
}
Also used : Task(com.webank.wedatasphere.qualitis.entity.Task) ApplicationResponse(com.webank.wedatasphere.qualitis.response.ApplicationResponse) ArrayList(java.util.ArrayList) GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) GetAllResponse(com.webank.wedatasphere.qualitis.response.GetAllResponse) Application(com.webank.wedatasphere.qualitis.entity.Application)

Aggregations

GetAllResponse (com.webank.wedatasphere.qualitis.response.GetAllResponse)28 GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)26 ArrayList (java.util.ArrayList)21 User (com.webank.wedatasphere.qualitis.entity.User)9 List (java.util.List)8 Application (com.webank.wedatasphere.qualitis.entity.Application)5 Department (com.webank.wedatasphere.qualitis.entity.Department)5 Task (com.webank.wedatasphere.qualitis.entity.Task)5 UserRole (com.webank.wedatasphere.qualitis.entity.UserRole)5 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)5 ApplicationResponse (com.webank.wedatasphere.qualitis.response.ApplicationResponse)5 Map (java.util.Map)4 RuleMetric (com.webank.wedatasphere.qualitis.entity.RuleMetric)3 Project (com.webank.wedatasphere.qualitis.project.entity.Project)3 Template (com.webank.wedatasphere.qualitis.rule.entity.Template)3 RuleTemplateResponse (com.webank.wedatasphere.qualitis.rule.response.RuleTemplateResponse)3 ClusterInfoDao (com.webank.wedatasphere.qualitis.dao.ClusterInfoDao)2 ClusterInfo (com.webank.wedatasphere.qualitis.entity.ClusterInfo)2 ProxyUser (com.webank.wedatasphere.qualitis.entity.ProxyUser)2 RolePermission (com.webank.wedatasphere.qualitis.entity.RolePermission)2