use of com.webank.wedatasphere.qualitis.request.GroupExecutionRequest in project Qualitis by WeBankFinTech.
the class OuterExecutionServiceImpl method generalExecution.
@Override
@Transactional(rollbackFor = { RuntimeException.class, UnExpectedRequestException.class })
public GeneralResponse<?> generalExecution(GeneralExecutionRequest request) throws UnExpectedRequestException, PermissionDeniedRequestException {
// Generator application information
GeneralExecutionRequest.checkRequest(request);
if (request.getDyNamicPartitionPrefix() == null) {
request.setDyNamicPartitionPrefix("");
}
if (request.getProjectId() != null) {
ProjectExecutionRequest projectExecutionRequest = new ProjectExecutionRequest();
BeanUtils.copyProperties(request, projectExecutionRequest);
return projectExecution(projectExecutionRequest, InvokeTypeEnum.BDP_CLIENT_API_INVOKE.getCode());
} else if (CollectionUtils.isNotEmpty(request.getRuleList())) {
RuleListExecutionRequest ruleListExecutionRequest = new RuleListExecutionRequest();
BeanUtils.copyProperties(request, ruleListExecutionRequest);
return ruleListExecution(ruleListExecutionRequest, InvokeTypeEnum.BDP_CLIENT_API_INVOKE.getCode());
} else if (request.getGroupId() != null) {
GroupExecutionRequest groupExecutionRequest = new GroupExecutionRequest();
BeanUtils.copyProperties(request, groupExecutionRequest);
return groupExecution(groupExecutionRequest, InvokeTypeEnum.FLOW_API_INVOKE.getCode());
} else if (StringUtils.isNotBlank(request.getProjectName())) {
Project projectInDb = projectDao.findByNameAndCreateUser(request.getProjectName(), request.getCreateUser());
if (projectInDb == null) {
List<Integer> permissions = new ArrayList<>();
permissions.add(ProjectUserPermissionEnum.CREATOR.getCode());
permissions.add(ProjectUserPermissionEnum.DEVELOPER.getCode());
List<Project> projects = projectUserDao.findByUsernameAndPermission(request.getExecutionUser(), permissions);
if (CollectionUtils.isEmpty(projects)) {
throw new UnExpectedRequestException("Pick project has no permissions.");
}
List<Project> execProject = projects.stream().filter(project -> project.getName().equals(request.getProjectName())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(execProject)) {
throw new UnExpectedRequestException("Pick project has no permissions.");
} else if (execProject.size() > 1) {
throw new UnExpectedRequestException("Pick project has dubplicate names.");
}
projectInDb = execProject.iterator().next();
}
if (CollectionUtils.isNotEmpty(request.getRuleNameList())) {
List<Long> ruleIds = new ArrayList<>(request.getRuleNameList().size());
for (String ruleName : request.getRuleNameList()) {
Rule rule = ruleDao.findByProjectAndRuleName(projectInDb, ruleName);
ruleIds.add(rule.getId());
}
request.setRuleList(ruleIds);
RuleListExecutionRequest ruleListExecutionRequest = new RuleListExecutionRequest();
BeanUtils.copyProperties(request, ruleListExecutionRequest);
return ruleListExecution(ruleListExecutionRequest, InvokeTypeEnum.BDP_CLIENT_API_INVOKE.getCode());
} else {
request.setProjectId(projectInDb.getId());
ProjectExecutionRequest projectExecutionRequest = new ProjectExecutionRequest();
BeanUtils.copyProperties(request, projectExecutionRequest);
return projectExecution(projectExecutionRequest, InvokeTypeEnum.BDP_CLIENT_API_INVOKE.getCode());
}
} else if (StringUtils.isNotBlank(request.getCluster())) {
DataSourceExecutionRequest dataSourceExecutionRequest = new DataSourceExecutionRequest();
BeanUtils.copyProperties(request, dataSourceExecutionRequest);
return dataSourceExecution(dataSourceExecutionRequest);
} else {
LOGGER.error("Can not resolve the request: " + request);
throw new UnExpectedRequestException("{&CAN_NOT_RESOLVE_THE_REQUEST}");
}
}
Aggregations