use of com.webank.wedatasphere.qualitis.response.ApplicationResponse 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);
}
use of com.webank.wedatasphere.qualitis.response.ApplicationResponse in project Qualitis by WeBankFinTech.
the class ApplicationServiceImpl method filterProjectApplication.
@Override
public GeneralResponse<?> filterProjectApplication(FilterProjectRequest request) throws UnExpectedRequestException {
// Check arguments
FilterProjectRequest.checkRequest(request);
Long userId = HttpUtils.getUserId(httpServletRequest);
User user = userDao.findById(userId);
Integer page = request.getPage();
Integer size = request.getSize();
Long projectId = request.getProjectId();
int total = applicationDao.countByCreateUserAndProject(user.getUserName(), projectId).intValue();
List<Application> applicationList = applicationDao.findByCreateUserAndProject(user.getUserName(), projectId, page, size);
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(user.getUserName()) || application.getExecuteUser().equals(user.getUserName())) {
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("Succeed to find applications. size: {}, id of applications: {}", total, applicationIdList);
return new GeneralResponse<>("200", "{&SUCCEED_TO_GET_APPLICATIONS}", getAllResponse);
}
use of com.webank.wedatasphere.qualitis.response.ApplicationResponse in project Qualitis by WeBankFinTech.
the class ApplicationServiceImpl method filterApplicationId.
/**
* Find application by applicationId
* @param applicationId
* @return
*/
@Override
public GeneralResponse<?> filterApplicationId(String applicationId) {
Long userId = HttpUtils.getUserId(httpServletRequest);
// Find applications by user
User user = userDao.findById(userId);
List<Application> applicationList;
applicationList = applicationDao.findByCreateUserAndId(user.getUserName(), applicationId);
if (applicationList == null) {
LOGGER.info("User: {} , Not find applications with applicationId: {}", user.getUserName(), applicationId);
return new GeneralResponse<>("200", "{&SUCCEED_TO_GET_APPLICATIONS_BUT_FIND_NO_RESULTS}", null);
}
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(user.getUserName()) || application.getExecuteUser().equals(user.getUserName())) {
response.setKillOption(true);
} else {
response.setKillOption(false);
}
applicationResponses.add(response);
}
getAllResponse.setData(applicationResponses);
getAllResponse.setTotal(applicationList.size());
List<String> applicationIdList = getAllResponse.getData().stream().map(ApplicationResponse::getApplicationId).collect(Collectors.toList());
LOGGER.info("User: {}, find {} applications with like applicationId : {},Id of applications: {}", user.getUserName(), applicationList.size(), applicationId, applicationIdList);
return new GeneralResponse<>("200", "{&SUCCEED_TO_GET_APPLICATIONS}", getAllResponse);
}
use of com.webank.wedatasphere.qualitis.response.ApplicationResponse in project Qualitis by WeBankFinTech.
the class ApplicationServiceImpl method filterAdvanceApplication.
@Override
public GeneralResponse<?> filterAdvanceApplication(FilterAdvanceRequest request) {
Long userId = HttpUtils.getUserId(httpServletRequest);
// Find applications by user
User user = userDao.findById(userId);
List<Application> applicationList;
long total = 0;
// If application ID is not empty, just return application which ID like the input string.
if (StringUtils.isNotBlank(request.getApplicationId())) {
applicationList = applicationDao.findByCreateUserAndId(user.getUserName(), request.getApplicationId());
total = applicationList.size();
} else if (StringUtils.isNotBlank(request.getClusterName())) {
if (request.getStatus() != null) {
if (request.getStatus().equals(ApplicationStatusEnum.FINISHED.getCode())) {
request.setStatus(TaskStatusEnum.PASS_CHECKOUT.getCode());
} else if (request.getStatus().equals(ApplicationStatusEnum.NOT_PASS.getCode())) {
request.setStatus(TaskStatusEnum.FAIL_CHECKOUT.getCode());
} else if (request.getStatus().equals(ApplicationStatusEnum.SUCCESSFUL_CREATE_APPLICATION.getCode())) {
request.setStatus(TaskStatusEnum.INITED.getCode());
} else if (request.getStatus().equals(ApplicationStatusEnum.RUNNING.getCode())) {
request.setStatus(TaskStatusEnum.RUNNING.getCode());
} else if (request.getStatus() == 0) {
request.setStatus(null);
}
}
// If data source is not empty, it will be used as the basic filter.
applicationList = applicationDao.findApplicationByAdavnceConditionsWithDatasource(user.getUserName(), request.getClusterName(), request.getDatabaseName(), request.getTableName(), request.getProjectId(), request.getStatus(), request.getCommentType(), request.getStartTime(), request.getEndTime(), request.getPage(), request.getSize());
total = applicationDao.countApplicationByAdavnceConditionsWithDatasource(user.getUserName(), request.getClusterName(), request.getDatabaseName(), request.getTableName(), request.getProjectId(), request.getStatus(), request.getCommentType(), request.getStartTime(), request.getEndTime());
} else {
applicationList = applicationDao.findApplicationByAdavnceConditions(user.getUserName(), request.getProjectId(), request.getStatus(), request.getCommentType(), request.getStartTime(), request.getEndTime(), request.getPage(), request.getSize());
total = applicationDao.countApplicationByAdavnceConditions(user.getUserName(), request.getProjectId(), request.getStatus(), request.getCommentType(), request.getStartTime(), request.getEndTime());
}
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(user.getUserName()) || application.getExecuteUser().equals(user.getUserName())) {
response.setKillOption(true);
} else {
response.setKillOption(false);
}
applicationResponses.add(response);
}
getAllResponse.setData(applicationResponses);
getAllResponse.setTotal(total);
return new GeneralResponse<>("200", "{&SUCCEED_TO_GET_APPLICATIONS}", getAllResponse);
}
use of com.webank.wedatasphere.qualitis.response.ApplicationResponse in project Qualitis by WeBankFinTech.
the class ApplicationServiceImpl method filterDataSourceApplication.
@Override
public GeneralResponse<?> filterDataSourceApplication(FilterDataSourceRequest request) throws UnExpectedRequestException {
// Check arguments
FilterDataSourceRequest.checkRequest(request);
Integer page = request.getPage();
Integer size = request.getSize();
String clusterName = request.getClusterName();
String databaseName = StringUtils.isEmpty(request.getDatabaseName()) ? "" : request.getDatabaseName();
String tableName = StringUtils.isEmpty(request.getTableName()) ? "" : request.getTableName();
Long userId = HttpUtils.getUserId(httpServletRequest);
User user = userDao.findById(userId);
List<TaskDataSource> taskDataSources;
long total;
// Find datasource by user
taskDataSources = taskDataSourceDao.findByCreateUserAndDatasource(user.getUserName(), clusterName, databaseName, tableName, page, size);
total = taskDataSourceDao.countByCreateUserAndDatasource(user.getUserName(), clusterName, databaseName, tableName);
List<Application> applicationList = taskDataSources.stream().map(jobDataSource -> jobDataSource.getTask().getApplication()).collect(Collectors.toList());
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(user.getUserName()) || application.getExecuteUser().equals(user.getUserName())) {
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("Succeed to find applications. size: {}, id of applications: {}", total, applicationIdList);
return new GeneralResponse<>("200", "{&SUCCEED_TO_GET_APPLICATIONS}", getAllResponse);
}
Aggregations