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);
}
}
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);
}
Aggregations