Search in sources :

Example 1 with ProjectEvent

use of com.webank.wedatasphere.qualitis.project.entity.ProjectEvent in project Qualitis by WeBankFinTech.

the class ProjectEventServiceImpl method record.

@Override
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = { RuntimeException.class, UnExpectedRequestException.class })
public void record(Long projectId, String userName, String operation, String content, Integer typeId) {
    Project projectInDb = projectDao.findById(projectId);
    ProjectEvent projectEvent = new ProjectEvent(projectInDb, userName, operation + " " + content, ExecutionManagerImpl.PRINT_TIME_FORMAT.format(new Date()), typeId);
    try {
        projectEventDao.save(projectEvent);
    } catch (Exception e) {
        LOGGER.error("Failed to record project event.");
        LOGGER.error(e.getMessage(), e);
    }
}
Also used : Project(com.webank.wedatasphere.qualitis.project.entity.Project) Date(java.util.Date) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) ProjectEvent(com.webank.wedatasphere.qualitis.project.entity.ProjectEvent) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ProjectEvent

use of com.webank.wedatasphere.qualitis.project.entity.ProjectEvent 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

Project (com.webank.wedatasphere.qualitis.project.entity.Project)2 ProjectEvent (com.webank.wedatasphere.qualitis.project.entity.ProjectEvent)2 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)1 ProjectEventResponse (com.webank.wedatasphere.qualitis.project.response.ProjectEventResponse)1 GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)1 GetAllResponse (com.webank.wedatasphere.qualitis.response.GetAllResponse)1 Date (java.util.Date)1 Transactional (org.springframework.transaction.annotation.Transactional)1