You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2021/11/26 03:34:10 UTC
[GitHub] [dolphinscheduler] edward-yang commented on a change in pull request #6984: [Improvement][API][num-1 & 2] Implement createEmptyProcessDefinition & updateProcessDefinitionBasicInfo
edward-yang commented on a change in pull request #6984:
URL: https://github.com/apache/dolphinscheduler/pull/6984#discussion_r757209674
##########
File path: dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
##########
@@ -1547,7 +1548,95 @@ public Result queryProcessDefinitionVersions(User loginUser, long projectCode, i
String tenantCode,
String scheduleJson,
ProcessExecutionTypeEnum executionType) {
- return null;
+ Project project = projectMapper.queryByCode(projectCode);
+ //check user access for project
+ Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
+ if (result.get(Constants.STATUS) != Status.SUCCESS) {
+ return result;
+ }
+
+ // check whether the new process define name exist
+ ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name);
+ if (definition != null) {
+ putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name);
+ return result;
+ }
+
+ int tenantId = -1;
+ if (!Constants.DEFAULT.equals(tenantCode)) {
+ Tenant tenant = tenantMapper.queryByTenantCode(tenantCode);
+ if (tenant == null) {
+ putMsg(result, Status.TENANT_NOT_EXIST);
+ return result;
+ }
+ tenantId = tenant.getId();
+ }
+ long processDefinitionCode;
+ try {
+ processDefinitionCode = CodeGenerateUtils.getInstance().genCode();
+ } catch (CodeGenerateException e) {
+ putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS);
+ return result;
+ }
+ ProcessDefinition processDefinition = new ProcessDefinition(projectCode, name, processDefinitionCode, description,
+ globalParams, "", timeout, loginUser.getId(), tenantId);
+ processDefinition.setExecutionType(executionType);
+ result = createEmptyDagDefine(loginUser, processDefinition);
+ if (result.get(Constants.STATUS) != Status.SUCCESS) {
+ return result;
+ }
+
+ if (scheduleJson==null||scheduleJson.trim().isEmpty()){
+ return result;
+ }
+ // save dag schedule
+ Map<String, Object> scheduleResult = createDagSchedule(loginUser, projectCode, processDefinitionCode, scheduleJson);
+ if (scheduleResult.get(Constants.STATUS) != Status.SUCCESS) {
+ return scheduleResult;
+ }
+ return result;
+ }
+
+ private Map<String, Object> createEmptyDagDefine(User loginUser, ProcessDefinition processDefinition) {
+ Map<String, Object> result = new HashMap<>();
+ int insertVersion = processService.saveProcessDefine(loginUser, processDefinition, true);
+ if (insertVersion == 0) {
+ putMsg(result, Status.CREATE_PROCESS_DEFINITION_ERROR);
+ throw new ServiceException(Status.CREATE_PROCESS_DEFINITION_ERROR);
+ }
+ putMsg(result, Status.SUCCESS);
+ result.put(Constants.DATA_LIST, processDefinition);
+ return result;
+ }
+
+ private Map<String, Object> createDagSchedule(User loginUser,
+ long projectCode,
+ long processDefinitionCode,
+ String scheduleJson) {
+ Map<String, Object> result = new HashMap<>();
+ ScheduleDto scheduleDto = JSONUtils.parseObject(scheduleJson, ScheduleDto.class);
+ ScheduleParam schedule = scheduleDto.getSchedule();
+ FailureStrategy failureStrategy = scheduleDto.getFailureStrategy() == null ? FailureStrategy.CONTINUE : scheduleDto.getFailureStrategy(); // 默认:CONTINUE
Review comment:
I had replace class ScheduleDto with Schedule and remove it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org