Search in sources :

Example 16 with GetAllResponse

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

the class UserRoleServiceImpl method findAllUserRole.

@Override
public GeneralResponse<GetAllResponse<UserRoleResponse>> findAllUserRole(PageRequest request) throws UnExpectedRequestException {
    // Check Arguments
    PageRequest.checkRequest(request);
    int page = request.getPage();
    int size = request.getSize();
    List<UserRole> userRoles = userRoleDao.findAllUserRole(page, size);
    long total = userRoleDao.countAll();
    List<UserRoleResponse> userRoleResponses = new ArrayList<>();
    for (UserRole userRole : userRoles) {
        UserRoleResponse response = new UserRoleResponse(userRole);
        userRoleResponses.add(response);
    }
    GetAllResponse<UserRoleResponse> responses = new GetAllResponse<>();
    responses.setTotal(total);
    responses.setData(userRoleResponses);
    LOGGER.info("Succeed to find all user_roles, response: {}, current_user: {}", responses, HttpUtils.getUserName(httpServletRequest));
    return new GeneralResponse<>("200", "{&FIND_ALL_USER_ROLES_SUCCESSFULLY}", responses);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) UserRoleResponse(com.webank.wedatasphere.qualitis.response.UserRoleResponse) UserRole(com.webank.wedatasphere.qualitis.entity.UserRole) ArrayList(java.util.ArrayList) GetAllResponse(com.webank.wedatasphere.qualitis.response.GetAllResponse)

Example 17 with GetAllResponse

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

the class UserSpecPermissionServiceImpl method findAllUserSpecPermission.

@Override
public GeneralResponse<GetAllResponse<UserSpecPermissionResponse>> findAllUserSpecPermission(PageRequest request) throws UnExpectedRequestException {
    // Check Arguments
    PageRequest.checkRequest(request);
    int page = request.getPage();
    int size = request.getSize();
    List<UserSpecPermission> userSpecPermissions = userSpecPermissionDao.findAllUserSpecPermission(page, size);
    long total = userSpecPermissionDao.countAll();
    List<UserSpecPermissionResponse> userSpecPermissionResponses = new ArrayList<>();
    for (UserSpecPermission userSpecPermission : userSpecPermissions) {
        UserSpecPermissionResponse tmp = new UserSpecPermissionResponse(userSpecPermission);
        userSpecPermissionResponses.add(tmp);
    }
    GetAllResponse<UserSpecPermissionResponse> responses = new GetAllResponse<>();
    responses.setTotal(total);
    responses.setData(userSpecPermissionResponses);
    LOGGER.info("Succeed to find user_permission. page: {}, size: {}, response: {}, current_user: {}", page, size, responses, HttpUtils.getUserName(httpServletRequest));
    return new GeneralResponse<>("200", "{&FIND_USER_SPEC_PERMISSION_SUCCESSFULLY}", responses);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) UserSpecPermissionResponse(com.webank.wedatasphere.qualitis.response.UserSpecPermissionResponse) ArrayList(java.util.ArrayList) GetAllResponse(com.webank.wedatasphere.qualitis.response.GetAllResponse) UserSpecPermission(com.webank.wedatasphere.qualitis.entity.UserSpecPermission)

Example 18 with GetAllResponse

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

the class PermissionServiceImpl method getAllPermission.

@Override
public GeneralResponse<GetAllResponse<PermissionResponse>> getAllPermission(PageRequest request) throws UnExpectedRequestException {
    // Check Arguments
    PageRequest.checkRequest(request);
    int page = request.getPage();
    int size = request.getSize();
    List<Permission> permissions = permissionDao.findAllPermission(page, size);
    long total = permissionDao.countAll();
    GetAllResponse<PermissionResponse> getAllPermissionResponse = new GetAllResponse<>();
    getAllPermissionResponse.setTotal(total);
    getAllPermissionResponse.setData(permissions.stream().map(p -> new PermissionResponse(p)).collect(Collectors.toList()));
    LOGGER.info("Succeed to get all permission, page: {}, size: {}, permissions: {}, current_user: {}", page, size, getAllPermissionResponse, HttpUtils.getUserName(httpServletRequest));
    return new GeneralResponse<>("200", "{&FIND_ALL_PERMISSIONS_SUCCESSFULLY}", getAllPermissionResponse);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) UserSpecPermission(com.webank.wedatasphere.qualitis.entity.UserSpecPermission) Permission(com.webank.wedatasphere.qualitis.entity.Permission) RolePermission(com.webank.wedatasphere.qualitis.entity.RolePermission) PermissionResponse(com.webank.wedatasphere.qualitis.response.PermissionResponse) GetAllResponse(com.webank.wedatasphere.qualitis.response.GetAllResponse)

Example 19 with GetAllResponse

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

the class RoleServiceImpl method getAllRole.

@Override
public GeneralResponse<GetAllResponse<RoleResponse>> getAllRole(PageRequest request) throws UnExpectedRequestException {
    // Check Arguments
    PageRequest.checkRequest(request);
    int page = request.getPage();
    int size = request.getSize();
    List<Role> roles = roleDao.findAllRole(page, size);
    long total = roleDao.countAll();
    List<RoleResponse> roleResponses = new ArrayList<>();
    for (Role role : roles) {
        RoleResponse tmp = new RoleResponse(role);
        roleResponses.add(tmp);
    }
    GetAllResponse<RoleResponse> responses = new GetAllResponse<>();
    responses.setData(roleResponses);
    responses.setTotal(total);
    LOGGER.info("Succeed to find all roles, page: {}, size: {}, role: {}, current_user: {}", page, size, responses, HttpUtils.getUserName(httpServletRequest));
    return new GeneralResponse<>("200", "{&FIND_ALL_ROLES_SUCCESSFULLY}", responses);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) ArrayList(java.util.ArrayList) RoleResponse(com.webank.wedatasphere.qualitis.response.RoleResponse) UserAndRoleResponse(com.webank.wedatasphere.qualitis.response.UserAndRoleResponse) GetAllResponse(com.webank.wedatasphere.qualitis.response.GetAllResponse)

Example 20 with GetAllResponse

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

the class ProjectServiceImpl method getProjectEvents.

@Override
public GeneralResponse<GetAllResponse<ProjectEventResponse>> getProjectEvents(Long projectId, Integer typeId, PageRequest pageRequest) throws UnExpectedRequestException, PermissionDeniedRequestException {
    PageRequest.checkRequest(pageRequest);
    String loginUser = HttpUtils.getUserName(httpServletRequest);
    // Check project existence.
    Project projectInDb = checkProjectExistence(projectId, loginUser);
    List<Integer> permissions = new ArrayList<>();
    permissions.add(ProjectUserPermissionEnum.BUSSMAN.getCode());
    checkProjectPermission(projectInDb, loginUser, permissions);
    List<ProjectEvent> projectEvents = projectEventDao.find(pageRequest.getPage(), pageRequest.getSize(), projectInDb, typeId);
    long total = projectEventDao.count(projectInDb, typeId);
    List<ProjectEventResponse> projectEventResponses = new ArrayList<>(projectEvents.size());
    for (ProjectEvent projectEvent : projectEvents) {
        ProjectEventResponse projectEventResponse = new ProjectEventResponse(projectEvent);
        projectEventResponses.add(projectEventResponse);
    }
    GetAllResponse<ProjectEventResponse> response = new GetAllResponse<>(total, projectEventResponses);
    return new GeneralResponse<>("200", "{&SUCCESS_TO_GET_PROJECT_EVENT}", response);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) Project(com.webank.wedatasphere.qualitis.project.entity.Project) GetAllResponse(com.webank.wedatasphere.qualitis.response.GetAllResponse) ProjectEventResponse(com.webank.wedatasphere.qualitis.project.response.ProjectEventResponse) ProjectEvent(com.webank.wedatasphere.qualitis.project.entity.ProjectEvent)

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