Kirs
4 years ago
committed by
GitHub
175 changed files with 8344 additions and 4694 deletions
@ -1,73 +0,0 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.api.service; |
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
||||
import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionVersion; |
||||
import org.apache.dolphinscheduler.dao.entity.User; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* process definition version service |
||||
*/ |
||||
public interface ProcessDefinitionVersionService { |
||||
|
||||
/** |
||||
* add the newest version of one process definition |
||||
* |
||||
* @param processDefinition the process definition that need to record version |
||||
* @return the newest version number of this process definition |
||||
*/ |
||||
long addProcessDefinitionVersion(ProcessDefinition processDefinition); |
||||
|
||||
/** |
||||
* query the pagination versions info by one certain process definition id |
||||
* |
||||
* @param loginUser login user info to check auth |
||||
* @param projectName process definition project name |
||||
* @param pageNo page number |
||||
* @param pageSize page size |
||||
* @param processDefinitionId process definition id |
||||
* @return the pagination process definition versions info of the certain process definition |
||||
*/ |
||||
Map<String, Object> queryProcessDefinitionVersions(User loginUser, String projectName, |
||||
int pageNo, int pageSize, int processDefinitionId); |
||||
|
||||
/** |
||||
* query one certain process definition version by version number and process definition id |
||||
* |
||||
* @param processDefinitionId process definition id |
||||
* @param version version number |
||||
* @return the process definition version info |
||||
*/ |
||||
ProcessDefinitionVersion queryByProcessDefinitionIdAndVersion(int processDefinitionId, |
||||
long version); |
||||
|
||||
/** |
||||
* delete one certain process definition by version number and process definition id |
||||
* |
||||
* @param loginUser login user info to check auth |
||||
* @param projectName process definition project name |
||||
* @param processDefinitionId process definition id |
||||
* @param version version number |
||||
* @return delele result code |
||||
*/ |
||||
Map<String, Object> deleteByProcessDefinitionIdAndVersion(User loginUser, String projectName, |
||||
int processDefinitionId, long version); |
||||
} |
@ -0,0 +1,40 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.api.service; |
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.User; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* process task relation service |
||||
*/ |
||||
public interface ProcessTaskRelationService { |
||||
|
||||
/** |
||||
* query process task relation |
||||
* |
||||
* @param loginUser login user |
||||
* @param projectName project name |
||||
* @param processDefinitionCode process definition code |
||||
*/ |
||||
Map<String, Object> queryProcessTaskRelation(User loginUser, |
||||
String projectName, |
||||
Long processDefinitionCode); |
||||
} |
||||
|
@ -0,0 +1,88 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.api.service; |
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.User; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* task definition service |
||||
*/ |
||||
public interface TaskDefinitionService { |
||||
|
||||
/** |
||||
* create task definition |
||||
* |
||||
* @param loginUser login user |
||||
* @param projectName project name |
||||
* @param taskDefinitionJson task definition json |
||||
*/ |
||||
Map<String, Object> createTaskDefinition(User loginUser, |
||||
String projectName, |
||||
String taskDefinitionJson); |
||||
|
||||
/** |
||||
* query task definition |
||||
* |
||||
* @param loginUser login user |
||||
* @param projectName project name |
||||
* @param taskName task name |
||||
*/ |
||||
Map<String, Object> queryTaskDefinitionByName(User loginUser, |
||||
String projectName, |
||||
String taskName); |
||||
|
||||
/** |
||||
* delete task definition |
||||
* |
||||
* @param loginUser login user |
||||
* @param projectName project name |
||||
* @param taskCode task code |
||||
*/ |
||||
Map<String, Object> deleteTaskDefinitionByCode(User loginUser, |
||||
String projectName, |
||||
Long taskCode); |
||||
|
||||
/** |
||||
* update task definition |
||||
* |
||||
* @param loginUser login user |
||||
* @param projectName project name |
||||
* @param taskCode task code |
||||
* @param taskDefinitionJson task definition json |
||||
*/ |
||||
Map<String, Object> updateTaskDefinition(User loginUser, |
||||
String projectName, |
||||
Long taskCode, |
||||
String taskDefinitionJson); |
||||
|
||||
/** |
||||
* update task definition |
||||
* |
||||
* @param loginUser login user |
||||
* @param projectName project name |
||||
* @param taskCode task code |
||||
* @param version the version user want to switch |
||||
*/ |
||||
Map<String, Object> switchVersion(User loginUser, |
||||
String projectName, |
||||
Long taskCode, |
||||
int version); |
||||
} |
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,189 +0,0 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.api.service.impl; |
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status; |
||||
import org.apache.dolphinscheduler.api.service.ProcessDefinitionService; |
||||
import org.apache.dolphinscheduler.api.service.ProcessDefinitionVersionService; |
||||
import org.apache.dolphinscheduler.api.service.ProjectService; |
||||
import org.apache.dolphinscheduler.api.utils.PageInfo; |
||||
import org.apache.dolphinscheduler.common.Constants; |
||||
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
||||
import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionVersion; |
||||
import org.apache.dolphinscheduler.dao.entity.Project; |
||||
import org.apache.dolphinscheduler.dao.entity.User; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionVersionMapper; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Objects; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.google.common.collect.ImmutableMap; |
||||
|
||||
/** |
||||
* process definition version service impl |
||||
*/ |
||||
@Service |
||||
public class ProcessDefinitionVersionServiceImpl extends BaseServiceImpl implements ProcessDefinitionVersionService { |
||||
|
||||
@Autowired |
||||
private ProcessDefinitionVersionMapper processDefinitionVersionMapper; |
||||
|
||||
@Autowired |
||||
private ProjectService projectService; |
||||
|
||||
@Autowired |
||||
private ProjectMapper projectMapper; |
||||
|
||||
@Autowired |
||||
private ProcessDefinitionService processDefinitionService; |
||||
|
||||
/** |
||||
* add the newest version of one process definition |
||||
* |
||||
* @param processDefinition the process definition that need to record version |
||||
* @return the newest version number of this process definition |
||||
*/ |
||||
@Override |
||||
public long addProcessDefinitionVersion(ProcessDefinition processDefinition) { |
||||
|
||||
long version = this.queryMaxVersionByProcessDefinitionId(processDefinition.getId()) + 1; |
||||
|
||||
ProcessDefinitionVersion processDefinitionVersion = ProcessDefinitionVersion |
||||
.newBuilder() |
||||
.processDefinitionId(processDefinition.getId()) |
||||
.version(version) |
||||
.processDefinitionJson(processDefinition.getProcessDefinitionJson()) |
||||
.description(processDefinition.getDescription()) |
||||
.locations(processDefinition.getLocations()) |
||||
.connects(processDefinition.getConnects()) |
||||
.timeout(processDefinition.getTimeout()) |
||||
.globalParams(processDefinition.getGlobalParams()) |
||||
.createTime(processDefinition.getUpdateTime()) |
||||
.warningGroupId(processDefinition.getWarningGroupId()) |
||||
.resourceIds(processDefinition.getResourceIds()) |
||||
.build(); |
||||
|
||||
processDefinitionVersionMapper.insert(processDefinitionVersion); |
||||
|
||||
return version; |
||||
} |
||||
|
||||
/** |
||||
* query the max version number by the process definition id |
||||
* |
||||
* @param processDefinitionId process definition id |
||||
* @return the max version number of this id |
||||
*/ |
||||
private long queryMaxVersionByProcessDefinitionId(int processDefinitionId) { |
||||
Long maxVersion = processDefinitionVersionMapper.queryMaxVersionByProcessDefinitionId(processDefinitionId); |
||||
if (Objects.isNull(maxVersion)) { |
||||
return 0L; |
||||
} else { |
||||
return maxVersion; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* query the pagination versions info by one certain process definition id |
||||
* |
||||
* @param loginUser login user info to check auth |
||||
* @param projectName process definition project name |
||||
* @param pageNo page number |
||||
* @param pageSize page size |
||||
* @param processDefinitionId process definition id |
||||
* @return the pagination process definition versions info of the certain process definition |
||||
*/ |
||||
@Override |
||||
public Map<String, Object> queryProcessDefinitionVersions(User loginUser, String projectName, int pageNo, int pageSize, int processDefinitionId) { |
||||
|
||||
Project project = projectMapper.queryByName(projectName); |
||||
|
||||
// check project auth
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName); |
||||
Status resultStatus = (Status) checkResult.get(Constants.STATUS); |
||||
if (resultStatus != Status.SUCCESS) { |
||||
return checkResult; |
||||
} |
||||
|
||||
PageInfo<ProcessDefinitionVersion> pageInfo = new PageInfo<>(pageNo, pageSize); |
||||
Page<ProcessDefinitionVersion> page = new Page<>(pageNo, pageSize); |
||||
IPage<ProcessDefinitionVersion> processDefinitionVersionsPaging = processDefinitionVersionMapper.queryProcessDefinitionVersionsPaging(page, processDefinitionId); |
||||
List<ProcessDefinitionVersion> processDefinitionVersions = processDefinitionVersionsPaging.getRecords(); |
||||
pageInfo.setLists(processDefinitionVersions); |
||||
pageInfo.setTotalCount((int) processDefinitionVersionsPaging.getTotal()); |
||||
return ImmutableMap.of( |
||||
Constants.MSG, Status.SUCCESS.getMsg() |
||||
, Constants.STATUS, Status.SUCCESS |
||||
, Constants.DATA_LIST, pageInfo); |
||||
} |
||||
|
||||
/** |
||||
* query one certain process definition version by version number and process definition id |
||||
* |
||||
* @param processDefinitionId process definition id |
||||
* @param version version number |
||||
* @return the process definition version info |
||||
*/ |
||||
@Override |
||||
public ProcessDefinitionVersion queryByProcessDefinitionIdAndVersion(int processDefinitionId, long version) { |
||||
return processDefinitionVersionMapper.queryByProcessDefinitionIdAndVersion(processDefinitionId, version); |
||||
} |
||||
|
||||
/** |
||||
* delete one certain process definition by version number and process definition id |
||||
* |
||||
* @param loginUser login user info to check auth |
||||
* @param projectName process definition project name |
||||
* @param processDefinitionId process definition id |
||||
* @param version version number |
||||
* @return delele result code |
||||
*/ |
||||
@Override |
||||
public Map<String, Object> deleteByProcessDefinitionIdAndVersion(User loginUser, String projectName, int processDefinitionId, long version) { |
||||
Map<String, Object> result = new HashMap<>(); |
||||
Project project = projectMapper.queryByName(projectName); |
||||
// check project auth
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName); |
||||
Status resultStatus = (Status) checkResult.get(Constants.STATUS); |
||||
if (resultStatus != Status.SUCCESS) { |
||||
return checkResult; |
||||
} |
||||
|
||||
// check has associated process definition
|
||||
boolean hasAssociatedProcessDefinition = processDefinitionService.checkHasAssociatedProcessDefinition(processDefinitionId, version); |
||||
if (hasAssociatedProcessDefinition) { |
||||
putMsg(result, Status.PROCESS_DEFINITION_VERSION_IS_USED); |
||||
return result; |
||||
} |
||||
|
||||
processDefinitionVersionMapper.deleteByProcessDefinitionIdAndVersion(processDefinitionId, version); |
||||
putMsg(result, Status.SUCCESS); |
||||
return result; |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,78 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.api.service.impl; |
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status; |
||||
import org.apache.dolphinscheduler.api.service.ProcessTaskRelationService; |
||||
import org.apache.dolphinscheduler.api.service.ProjectService; |
||||
import org.apache.dolphinscheduler.common.Constants; |
||||
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; |
||||
import org.apache.dolphinscheduler.dao.entity.Project; |
||||
import org.apache.dolphinscheduler.dao.entity.User; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* task definition service impl |
||||
*/ |
||||
@Service |
||||
public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements |
||||
ProcessTaskRelationService { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProcessTaskRelationServiceImpl.class); |
||||
|
||||
@Autowired |
||||
private ProjectMapper projectMapper; |
||||
|
||||
@Autowired |
||||
private ProjectService projectService; |
||||
|
||||
@Autowired |
||||
private ProcessTaskRelationMapper processTaskRelationMapper; |
||||
|
||||
/** |
||||
* query process task relation |
||||
* |
||||
* @param loginUser login user |
||||
* @param projectName project name |
||||
* @param processDefinitionCode process definition code |
||||
*/ |
||||
@Override |
||||
public Map<String, Object> queryProcessTaskRelation(User loginUser, String projectName, Long processDefinitionCode) { |
||||
Map<String, Object> result = new HashMap<>(); |
||||
Project project = projectMapper.queryByName(projectName); |
||||
// check project auth
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName); |
||||
if (checkResult.get(Constants.STATUS) != Status.SUCCESS) { |
||||
return checkResult; |
||||
} |
||||
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByProcessCode(project.getCode(), processDefinitionCode); |
||||
result.put(Constants.DATA_LIST, processTaskRelationList); |
||||
putMsg(result, Status.SUCCESS); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,281 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.api.service.impl; |
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.DATA_IS_NOT_VALID; |
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status; |
||||
import org.apache.dolphinscheduler.api.service.ProjectService; |
||||
import org.apache.dolphinscheduler.api.service.TaskDefinitionService; |
||||
import org.apache.dolphinscheduler.api.utils.CheckUtils; |
||||
import org.apache.dolphinscheduler.common.Constants; |
||||
import org.apache.dolphinscheduler.common.model.TaskNode; |
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.apache.dolphinscheduler.common.utils.SnowFlakeUtils; |
||||
import org.apache.dolphinscheduler.common.utils.SnowFlakeUtils.SnowFlakeException; |
||||
import org.apache.dolphinscheduler.common.utils.StringUtils; |
||||
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; |
||||
import org.apache.dolphinscheduler.dao.entity.Project; |
||||
import org.apache.dolphinscheduler.dao.entity.TaskDefinition; |
||||
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; |
||||
import org.apache.dolphinscheduler.dao.entity.User; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
||||
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; |
||||
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; |
||||
import org.apache.dolphinscheduler.service.process.ProcessService; |
||||
|
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
import java.util.stream.Collectors; |
||||
|
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
/** |
||||
* task definition service impl |
||||
*/ |
||||
@Service |
||||
public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDefinitionService { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TaskDefinitionServiceImpl.class); |
||||
|
||||
@Autowired |
||||
private ProjectMapper projectMapper; |
||||
|
||||
@Autowired |
||||
private ProjectService projectService; |
||||
|
||||
@Autowired |
||||
private TaskDefinitionMapper taskDefinitionMapper; |
||||
|
||||
@Autowired |
||||
private TaskDefinitionLogMapper taskDefinitionLogMapper; |
||||
|
||||
@Autowired |
||||
private ProcessTaskRelationMapper processTaskRelationMapper; |
||||
|
||||
@Autowired |
||||
private ProcessService processService; |
||||
|
||||
/** |
||||
* create task definition |
||||
* |
||||
* @param loginUser login user |
||||
* @param projectName project name |
||||
* @param taskDefinitionJson task definition json |
||||
*/ |
||||
@Transactional(rollbackFor = RuntimeException.class) |
||||
@Override |
||||
public Map<String, Object> createTaskDefinition(User loginUser, |
||||
String projectName, |
||||
String taskDefinitionJson) { |
||||
|
||||
Map<String, Object> result = new HashMap<>(); |
||||
Project project = projectMapper.queryByName(projectName); |
||||
// check project auth
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName); |
||||
Status resultStatus = (Status) checkResult.get(Constants.STATUS); |
||||
if (resultStatus != Status.SUCCESS) { |
||||
return checkResult; |
||||
} |
||||
|
||||
TaskNode taskNode = JSONUtils.parseObject(taskDefinitionJson, TaskNode.class); |
||||
checkTaskNode(result, taskNode, taskDefinitionJson); |
||||
if (result.get(Constants.STATUS) == DATA_IS_NOT_VALID |
||||
|| result.get(Constants.STATUS) == Status.PROCESS_NODE_S_PARAMETER_INVALID) { |
||||
return result; |
||||
} |
||||
TaskDefinition taskDefinition = new TaskDefinition(); |
||||
long code = 0L; |
||||
try { |
||||
code = SnowFlakeUtils.getInstance().nextId(); |
||||
taskDefinition.setCode(code); |
||||
} catch (SnowFlakeException e) { |
||||
logger.error("Task code get error, ", e); |
||||
} |
||||
if (code == 0L) { |
||||
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, "Error generating task definition code"); |
||||
return result; |
||||
} |
||||
int insert = processService.saveTaskDefinition(loginUser, project.getCode(), taskNode, taskDefinition); |
||||
// return taskDefinition object with code
|
||||
result.put(Constants.DATA_LIST, code); |
||||
putMsg(result, Status.SUCCESS, insert); |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* query task definition |
||||
* |
||||
* @param loginUser login user |
||||
* @param projectName project name |
||||
* @param taskName task name |
||||
*/ |
||||
@Override |
||||
public Map<String, Object> queryTaskDefinitionByName(User loginUser, String projectName, String taskName) { |
||||
Map<String, Object> result = new HashMap<>(); |
||||
Project project = projectMapper.queryByName(projectName); |
||||
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName); |
||||
Status resultStatus = (Status) checkResult.get(Constants.STATUS); |
||||
if (resultStatus != Status.SUCCESS) { |
||||
return checkResult; |
||||
} |
||||
|
||||
TaskDefinition taskDefinition = taskDefinitionMapper.queryByDefinitionName(project.getCode(), taskName); |
||||
if (taskDefinition == null) { |
||||
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskName); |
||||
} else { |
||||
result.put(Constants.DATA_LIST, taskDefinition); |
||||
putMsg(result, Status.SUCCESS); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* delete task definition |
||||
* |
||||
* @param loginUser login user |
||||
* @param projectName project name |
||||
* @param taskCode task code |
||||
*/ |
||||
@Transactional(rollbackFor = RuntimeException.class) |
||||
@Override |
||||
public Map<String, Object> deleteTaskDefinitionByCode(User loginUser, String projectName, Long taskCode) { |
||||
Map<String, Object> result = new HashMap<>(5); |
||||
Project project = projectMapper.queryByName(projectName); |
||||
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName); |
||||
Status resultEnum = (Status) checkResult.get(Constants.STATUS); |
||||
if (resultEnum != Status.SUCCESS) { |
||||
return checkResult; |
||||
} |
||||
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByTaskCode(taskCode); |
||||
if (!processTaskRelationList.isEmpty()) { |
||||
Set<Long> processDefinitionCodes = processTaskRelationList |
||||
.stream() |
||||
.map(ProcessTaskRelation::getProcessDefinitionCode) |
||||
.collect(Collectors.toSet()); |
||||
putMsg(result, Status.PROCESS_TASK_RELATION_EXIST, StringUtils.join(processDefinitionCodes, ",")); |
||||
return result; |
||||
} |
||||
int delete = taskDefinitionMapper.deleteByCode(taskCode); |
||||
if (delete > 0) { |
||||
putMsg(result, Status.SUCCESS); |
||||
} else { |
||||
putMsg(result, Status.DELETE_TASK_DEFINE_BY_CODE_ERROR); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* update task definition |
||||
* |
||||
* @param loginUser login user |
||||
* @param projectName project name |
||||
* @param taskCode task code |
||||
* @param taskDefinitionJson task definition json |
||||
*/ |
||||
@Transactional(rollbackFor = RuntimeException.class) |
||||
@Override |
||||
public Map<String, Object> updateTaskDefinition(User loginUser, String projectName, Long taskCode, String taskDefinitionJson) { |
||||
Map<String, Object> result = new HashMap<>(5); |
||||
Project project = projectMapper.queryByName(projectName); |
||||
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName); |
||||
Status resultEnum = (Status) checkResult.get(Constants.STATUS); |
||||
if (resultEnum != Status.SUCCESS) { |
||||
return checkResult; |
||||
} |
||||
if (processService.isTaskOnline(taskCode)) { |
||||
putMsg(result, Status.PROCESS_DEFINE_STATE_ONLINE); |
||||
return result; |
||||
} |
||||
TaskDefinition taskDefinition = taskDefinitionMapper.queryByDefinitionCode(taskCode); |
||||
if (taskDefinition == null) { |
||||
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode); |
||||
return result; |
||||
} |
||||
TaskNode taskNode = JSONUtils.parseObject(taskDefinitionJson, TaskNode.class); |
||||
checkTaskNode(result, taskNode, taskDefinitionJson); |
||||
if (result.get(Constants.STATUS) == DATA_IS_NOT_VALID |
||||
|| result.get(Constants.STATUS) == Status.PROCESS_NODE_S_PARAMETER_INVALID) { |
||||
return result; |
||||
} |
||||
int update = processService.updateTaskDefinition(loginUser, project.getCode(), taskNode, taskDefinition); |
||||
result.put(Constants.DATA_LIST, taskCode); |
||||
putMsg(result, Status.SUCCESS, update); |
||||
return result; |
||||
} |
||||
|
||||
public void checkTaskNode(Map<String, Object> result, TaskNode taskNode, String taskDefinitionJson) { |
||||
if (taskNode == null) { |
||||
logger.error("taskDefinitionJson is not valid json"); |
||||
putMsg(result, Status.DATA_IS_NOT_VALID, taskDefinitionJson); |
||||
return; |
||||
} |
||||
if (!CheckUtils.checkTaskNodeParameters(taskNode)) { |
||||
logger.error("task node {} parameter invalid", taskNode.getName()); |
||||
putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskNode.getName()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* update task definition |
||||
* |
||||
* @param loginUser login user |
||||
* @param projectName project name |
||||
* @param taskCode task code |
||||
* @param version the version user want to switch |
||||
*/ |
||||
@Override |
||||
public Map<String, Object> switchVersion(User loginUser, String projectName, Long taskCode, int version) { |
||||
Map<String, Object> result = new HashMap<>(5); |
||||
Project project = projectMapper.queryByName(projectName); |
||||
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName); |
||||
Status resultEnum = (Status) checkResult.get(Constants.STATUS); |
||||
if (resultEnum != Status.SUCCESS) { |
||||
return checkResult; |
||||
} |
||||
if (processService.isTaskOnline(taskCode)) { |
||||
putMsg(result, Status.PROCESS_DEFINE_STATE_ONLINE); |
||||
return result; |
||||
} |
||||
TaskDefinition taskDefinition = taskDefinitionMapper.queryByDefinitionCode(taskCode); |
||||
if (taskDefinition == null) { |
||||
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode); |
||||
return result; |
||||
} |
||||
TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(taskCode, version); |
||||
taskDefinitionLog.setUserId(loginUser.getId()); |
||||
taskDefinitionLog.setUpdateTime(new Date()); |
||||
taskDefinitionMapper.updateById(taskDefinitionLog); |
||||
result.put(Constants.DATA_LIST, taskCode); |
||||
putMsg(result, Status.SUCCESS); |
||||
return result; |
||||
} |
||||
} |
||||
|
@ -1,269 +0,0 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.api.service; |
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status; |
||||
import org.apache.dolphinscheduler.api.service.impl.ProcessDefinitionVersionServiceImpl; |
||||
import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl; |
||||
import org.apache.dolphinscheduler.api.utils.PageInfo; |
||||
import org.apache.dolphinscheduler.common.Constants; |
||||
import org.apache.dolphinscheduler.common.enums.UserType; |
||||
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
||||
import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionVersion; |
||||
import org.apache.dolphinscheduler.dao.entity.Project; |
||||
import org.apache.dolphinscheduler.dao.entity.User; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionVersionMapper; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
||||
|
||||
import java.text.MessageFormat; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.mockito.InjectMocks; |
||||
import org.mockito.Mock; |
||||
import org.mockito.Mockito; |
||||
import org.mockito.junit.MockitoJUnitRunner; |
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.google.common.collect.Lists; |
||||
|
||||
/** |
||||
* process definition version service test |
||||
*/ |
||||
@RunWith(MockitoJUnitRunner.class) |
||||
public class ProcessDefinitionVersionServiceTest { |
||||
|
||||
@InjectMocks |
||||
private ProcessDefinitionVersionServiceImpl processDefinitionVersionService; |
||||
|
||||
@Mock |
||||
private ProcessDefinitionVersionMapper processDefinitionVersionMapper; |
||||
|
||||
@Mock |
||||
private ProjectMapper projectMapper; |
||||
|
||||
@Mock |
||||
private ProjectServiceImpl projectService; |
||||
|
||||
@Mock |
||||
private ProcessDefinitionService processDefinitionService; |
||||
|
||||
@Test |
||||
public void testAddProcessDefinitionVersion() { |
||||
long expectedVersion = 5L; |
||||
ProcessDefinition processDefinition = getProcessDefinition(); |
||||
Mockito.when(processDefinitionVersionMapper |
||||
.queryMaxVersionByProcessDefinitionId(processDefinition.getId())) |
||||
.thenReturn(expectedVersion); |
||||
|
||||
long version = processDefinitionVersionService.addProcessDefinitionVersion(processDefinition); |
||||
|
||||
Assert.assertEquals(expectedVersion + 1, version); |
||||
} |
||||
|
||||
@Test |
||||
@SuppressWarnings("unchecked") |
||||
public void testQueryProcessDefinitionVersions() { |
||||
// pageNo <= 0
|
||||
int pageNo = -1; |
||||
int pageSize = 10; |
||||
int processDefinitionId = 66; |
||||
|
||||
String projectName = "project_test1"; |
||||
User loginUser = new User(); |
||||
loginUser.setId(-1); |
||||
loginUser.setUserType(UserType.GENERAL_USER); |
||||
|
||||
Map<String, Object> res = new HashMap<>(); |
||||
putMsg(res, Status.PROJECT_NOT_FOUNT); |
||||
Project project = getProject(projectName); |
||||
Mockito.when(projectMapper.queryByName(projectName)) |
||||
.thenReturn(project); |
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)) |
||||
.thenReturn(res); |
||||
|
||||
// project auth fail
|
||||
pageNo = 1; |
||||
pageSize = 10; |
||||
Map<String, Object> resultMap3 = processDefinitionVersionService.queryProcessDefinitionVersions( |
||||
loginUser |
||||
, projectName |
||||
, pageNo |
||||
, pageSize |
||||
, processDefinitionId); |
||||
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, resultMap3.get(Constants.STATUS)); |
||||
|
||||
putMsg(res, Status.SUCCESS); |
||||
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)) |
||||
.thenReturn(res); |
||||
|
||||
ProcessDefinitionVersion processDefinitionVersion = getProcessDefinitionVersion(getProcessDefinition()); |
||||
|
||||
Mockito.when(processDefinitionVersionMapper |
||||
.queryProcessDefinitionVersionsPaging(Mockito.any(Page.class), Mockito.eq(processDefinitionId))) |
||||
.thenReturn(new Page<ProcessDefinitionVersion>() |
||||
.setRecords(Lists.newArrayList(processDefinitionVersion))); |
||||
|
||||
Map<String, Object> resultMap4 = processDefinitionVersionService.queryProcessDefinitionVersions( |
||||
loginUser |
||||
, projectName |
||||
, pageNo |
||||
, pageSize |
||||
, processDefinitionId); |
||||
Assert.assertEquals(Status.SUCCESS, resultMap4.get(Constants.STATUS)); |
||||
Assert.assertEquals(processDefinitionVersion |
||||
, ((PageInfo<ProcessDefinitionVersion>) resultMap4.get(Constants.DATA_LIST)) |
||||
.getLists().get(0)); |
||||
} |
||||
|
||||
@Test |
||||
public void testQueryByProcessDefinitionIdAndVersion() { |
||||
|
||||
ProcessDefinitionVersion expectedProcessDefinitionVersion = |
||||
getProcessDefinitionVersion(getProcessDefinition()); |
||||
|
||||
int processDefinitionId = 66; |
||||
long version = 10; |
||||
Mockito.when(processDefinitionVersionMapper.queryByProcessDefinitionIdAndVersion(processDefinitionId, version)) |
||||
.thenReturn(expectedProcessDefinitionVersion); |
||||
|
||||
ProcessDefinitionVersion processDefinitionVersion = processDefinitionVersionService |
||||
.queryByProcessDefinitionIdAndVersion(processDefinitionId, version); |
||||
|
||||
Assert.assertEquals(expectedProcessDefinitionVersion, processDefinitionVersion); |
||||
} |
||||
|
||||
@Test |
||||
public void testDeleteByProcessDefinitionIdAndVersion() { |
||||
String projectName = "project_test1"; |
||||
int processDefinitionId = 66; |
||||
long version = 10; |
||||
Project project = getProject(projectName); |
||||
Mockito.when(projectMapper.queryByName(projectName)) |
||||
.thenReturn(project); |
||||
|
||||
User loginUser = new User(); |
||||
loginUser.setId(-1); |
||||
loginUser.setUserType(UserType.GENERAL_USER); |
||||
|
||||
// project auth fail
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)) |
||||
.thenReturn(new HashMap<>()); |
||||
|
||||
Map<String, Object> resultMap1 = processDefinitionVersionService.deleteByProcessDefinitionIdAndVersion( |
||||
loginUser |
||||
, projectName |
||||
, processDefinitionId |
||||
, version); |
||||
|
||||
Assert.assertEquals(0, resultMap1.size()); |
||||
|
||||
Map<String, Object> res = new HashMap<>(); |
||||
putMsg(res, Status.SUCCESS); |
||||
|
||||
Mockito.when(processDefinitionVersionMapper.deleteByProcessDefinitionIdAndVersion(processDefinitionId, version)) |
||||
.thenReturn(1); |
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)) |
||||
.thenReturn(res); |
||||
Mockito.when(processDefinitionService.checkHasAssociatedProcessDefinition(processDefinitionId, version)) |
||||
.thenReturn(false); |
||||
|
||||
Map<String, Object> resultMap2 = processDefinitionVersionService.deleteByProcessDefinitionIdAndVersion( |
||||
loginUser |
||||
, projectName |
||||
, processDefinitionId |
||||
, version); |
||||
|
||||
Assert.assertEquals(Status.SUCCESS, resultMap2.get(Constants.STATUS)); |
||||
|
||||
Mockito.when(processDefinitionService.checkHasAssociatedProcessDefinition(processDefinitionId, version)) |
||||
.thenReturn(true); |
||||
Map<String, Object> resultMap3 = processDefinitionVersionService.deleteByProcessDefinitionIdAndVersion( |
||||
loginUser |
||||
, projectName |
||||
, processDefinitionId |
||||
, version); |
||||
Assert.assertEquals(Status.PROCESS_DEFINITION_VERSION_IS_USED, resultMap3.get(Constants.STATUS)); |
||||
} |
||||
|
||||
/** |
||||
* get mock processDefinitionVersion by processDefinition |
||||
* |
||||
* @return processDefinitionVersion |
||||
*/ |
||||
private ProcessDefinitionVersion getProcessDefinitionVersion(ProcessDefinition processDefinition) { |
||||
return ProcessDefinitionVersion |
||||
.newBuilder() |
||||
.processDefinitionId(processDefinition.getId()) |
||||
.version(1) |
||||
.processDefinitionJson(processDefinition.getProcessDefinitionJson()) |
||||
.description(processDefinition.getDescription()) |
||||
.locations(processDefinition.getLocations()) |
||||
.connects(processDefinition.getConnects()) |
||||
.timeout(processDefinition.getTimeout()) |
||||
.globalParams(processDefinition.getGlobalParams()) |
||||
.createTime(processDefinition.getUpdateTime()) |
||||
.warningGroupId(processDefinition.getWarningGroupId()) |
||||
.resourceIds(processDefinition.getResourceIds()) |
||||
.build(); |
||||
} |
||||
|
||||
/** |
||||
* get mock processDefinition |
||||
* |
||||
* @return ProcessDefinition |
||||
*/ |
||||
private ProcessDefinition getProcessDefinition() { |
||||
|
||||
ProcessDefinition processDefinition = new ProcessDefinition(); |
||||
processDefinition.setId(66); |
||||
processDefinition.setName("test_pdf"); |
||||
processDefinition.setProjectId(2); |
||||
processDefinition.setTenantId(1); |
||||
processDefinition.setDescription(""); |
||||
|
||||
return processDefinition; |
||||
} |
||||
|
||||
/** |
||||
* get mock Project |
||||
* |
||||
* @param projectName projectName |
||||
* @return Project |
||||
*/ |
||||
private Project getProject(String projectName) { |
||||
Project project = new Project(); |
||||
project.setId(1); |
||||
project.setName(projectName); |
||||
project.setUserId(1); |
||||
return project; |
||||
} |
||||
|
||||
private void putMsg(Map<String, Object> result, Status status, Object... statusParams) { |
||||
result.put(Constants.STATUS, status); |
||||
if (statusParams != null && statusParams.length > 0) { |
||||
result.put(Constants.MSG, MessageFormat.format(status.getMsg(), statusParams)); |
||||
} else { |
||||
result.put(Constants.MSG, status.getMsg()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,107 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.api.service; |
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status; |
||||
import org.apache.dolphinscheduler.api.service.impl.ProcessTaskRelationServiceImpl; |
||||
import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl; |
||||
import org.apache.dolphinscheduler.common.Constants; |
||||
import org.apache.dolphinscheduler.common.enums.UserType; |
||||
import org.apache.dolphinscheduler.dao.entity.Project; |
||||
import org.apache.dolphinscheduler.dao.entity.User; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
||||
|
||||
import java.text.MessageFormat; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.mockito.InjectMocks; |
||||
import org.mockito.Mock; |
||||
import org.mockito.Mockito; |
||||
import org.mockito.junit.MockitoJUnitRunner; |
||||
|
||||
@RunWith(MockitoJUnitRunner.class) |
||||
public class ProcessTaskRelationServiceImplTest { |
||||
@InjectMocks |
||||
private ProcessTaskRelationServiceImpl processTaskRelationService; |
||||
|
||||
@Mock |
||||
private ProcessDefinitionMapper processDefineMapper; |
||||
|
||||
@Mock |
||||
private ProcessTaskRelationMapper processTaskRelationMapper; |
||||
|
||||
@Mock |
||||
private ProjectMapper projectMapper; |
||||
|
||||
@Mock |
||||
private ProjectServiceImpl projectService; |
||||
|
||||
@Test |
||||
public void queryProcessTaskRelationTest() { |
||||
String projectName = "project_test1"; |
||||
|
||||
Project project = getProject(projectName); |
||||
Mockito.when(projectMapper.queryByName(projectName)).thenReturn(project); |
||||
|
||||
User loginUser = new User(); |
||||
loginUser.setId(-1); |
||||
loginUser.setUserType(UserType.GENERAL_USER); |
||||
|
||||
Map<String, Object> result = new HashMap<>(); |
||||
putMsg(result, Status.SUCCESS, projectName); |
||||
|
||||
//project check auth fail
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result); |
||||
|
||||
Map<String, Object> relation = processTaskRelationService |
||||
.queryProcessTaskRelation(loginUser, projectName, 11L); |
||||
|
||||
Assert.assertEquals(Status.SUCCESS, relation.get(Constants.STATUS)); |
||||
} |
||||
|
||||
private void putMsg(Map<String, Object> result, Status status, Object... statusParams) { |
||||
result.put(Constants.STATUS, status); |
||||
if (statusParams != null && statusParams.length > 0) { |
||||
result.put(Constants.MSG, MessageFormat.format(status.getMsg(), statusParams)); |
||||
} else { |
||||
result.put(Constants.MSG, status.getMsg()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* get mock Project |
||||
* |
||||
* @param projectName projectName |
||||
* @return Project |
||||
*/ |
||||
private Project getProject(String projectName) { |
||||
Project project = new Project(); |
||||
project.setCode(11L); |
||||
project.setId(1); |
||||
project.setName(projectName); |
||||
project.setUserId(1); |
||||
return project; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,298 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.api.service; |
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status; |
||||
import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl; |
||||
import org.apache.dolphinscheduler.api.service.impl.TaskDefinitionServiceImpl; |
||||
import org.apache.dolphinscheduler.common.Constants; |
||||
import org.apache.dolphinscheduler.common.enums.UserType; |
||||
import org.apache.dolphinscheduler.common.model.TaskNode; |
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.apache.dolphinscheduler.dao.entity.Project; |
||||
import org.apache.dolphinscheduler.dao.entity.TaskDefinition; |
||||
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; |
||||
import org.apache.dolphinscheduler.dao.entity.User; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
||||
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; |
||||
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; |
||||
import org.apache.dolphinscheduler.service.process.ProcessService; |
||||
|
||||
import java.text.MessageFormat; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.mockito.InjectMocks; |
||||
import org.mockito.Mock; |
||||
import org.mockito.Mockito; |
||||
import org.mockito.junit.MockitoJUnitRunner; |
||||
|
||||
@RunWith(MockitoJUnitRunner.class) |
||||
public class TaskDefinitionServiceImplTest { |
||||
|
||||
String taskDefinitionJson = "{\n" |
||||
+ " \"type\": \"SQL\",\n" |
||||
+ " \"id\": \"tasks-27297\",\n" |
||||
+ " \"name\": \"SQL\",\n" |
||||
+ " \"params\": {\n" |
||||
+ " \"type\": \"MYSQL\",\n" |
||||
+ " \"datasource\": 1,\n" |
||||
+ " \"sql\": \"select * from test\",\n" |
||||
+ " \"udfs\": \"\",\n" |
||||
+ " \"sqlType\": \"1\",\n" |
||||
+ " \"title\": \"\",\n" |
||||
+ " \"receivers\": \"\",\n" |
||||
+ " \"receiversCc\": \"\",\n" |
||||
+ " \"showType\": \"TABLE\",\n" |
||||
+ " \"localParams\": [\n" |
||||
+ " \n" |
||||
+ " ],\n" |
||||
+ " \"connParams\": \"\",\n" |
||||
+ " \"preStatements\": [\n" |
||||
+ " \n" |
||||
+ " ],\n" |
||||
+ " \"postStatements\": [\n" |
||||
+ " \n" |
||||
+ " ]\n" |
||||
+ " },\n" |
||||
+ " \"description\": \"\",\n" |
||||
+ " \"runFlag\": \"NORMAL\",\n" |
||||
+ " \"dependence\": {\n" |
||||
+ " \n" |
||||
+ " },\n" |
||||
+ " \"maxRetryTimes\": \"0\",\n" |
||||
+ " \"retryInterval\": \"1\",\n" |
||||
+ " \"timeout\": {\n" |
||||
+ " \"strategy\": \"\",\n" |
||||
+ " \"enable\": false\n" |
||||
+ " },\n" |
||||
+ " \"taskInstancePriority\": \"MEDIUM\",\n" |
||||
+ " \"workerGroupId\": -1,\n" |
||||
+ " \"preTasks\": [\n" |
||||
+ " \"dependent\"\n" |
||||
+ " ]\n" |
||||
+ "}\n"; |
||||
|
||||
@InjectMocks |
||||
private TaskDefinitionServiceImpl taskDefinitionService; |
||||
|
||||
@Mock |
||||
private TaskDefinitionMapper taskDefinitionMapper; |
||||
|
||||
@Mock |
||||
private TaskDefinitionLogMapper taskDefinitionLogMapper; |
||||
|
||||
@Mock |
||||
private ProcessDefinitionMapper processDefineMapper; |
||||
|
||||
@Mock |
||||
private ProcessTaskRelationMapper processTaskRelationMapper; |
||||
|
||||
@Mock |
||||
private ProjectMapper projectMapper; |
||||
|
||||
@Mock |
||||
private ProjectServiceImpl projectService; |
||||
|
||||
@Mock |
||||
private ProcessService processService; |
||||
|
||||
@Test |
||||
public void createTaskDefinition() { |
||||
String projectName = "project_test1"; |
||||
|
||||
Project project = getProject(projectName); |
||||
Mockito.when(projectMapper.queryByName(projectName)).thenReturn(project); |
||||
|
||||
User loginUser = new User(); |
||||
loginUser.setId(-1); |
||||
loginUser.setUserType(UserType.GENERAL_USER); |
||||
|
||||
Map<String, Object> result = new HashMap<>(); |
||||
putMsg(result, Status.SUCCESS, projectName); |
||||
|
||||
//project check auth fail
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result); |
||||
|
||||
TaskNode taskNode = JSONUtils.parseObject(taskDefinitionJson, TaskNode.class); |
||||
|
||||
Mockito.when(processService.saveTaskDefinition(Mockito.eq(loginUser) |
||||
, Mockito.eq(project.getCode()) |
||||
, Mockito.eq(taskNode) |
||||
, Mockito.any(TaskDefinition.class))) |
||||
.thenReturn(1); |
||||
|
||||
Map<String, Object> relation = taskDefinitionService |
||||
.createTaskDefinition(loginUser, projectName, taskDefinitionJson); |
||||
|
||||
Assert.assertEquals(Status.SUCCESS, relation.get(Constants.STATUS)); |
||||
|
||||
} |
||||
|
||||
@Test |
||||
public void queryTaskDefinitionByName() { |
||||
String projectName = "project_test1"; |
||||
String taskName = "task"; |
||||
Project project = getProject(projectName); |
||||
Mockito.when(projectMapper.queryByName(projectName)).thenReturn(project); |
||||
|
||||
User loginUser = new User(); |
||||
loginUser.setId(-1); |
||||
loginUser.setUserType(UserType.GENERAL_USER); |
||||
|
||||
Map<String, Object> result = new HashMap<>(); |
||||
putMsg(result, Status.SUCCESS, projectName); |
||||
|
||||
//project check auth fail
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result); |
||||
|
||||
TaskNode taskNode = JSONUtils.parseObject(taskDefinitionJson, TaskNode.class); |
||||
|
||||
Mockito.when(taskDefinitionMapper.queryByDefinitionName(project.getCode(), taskName)) |
||||
.thenReturn(new TaskDefinition()); |
||||
|
||||
Map<String, Object> relation = taskDefinitionService |
||||
.queryTaskDefinitionByName(loginUser, projectName, taskName); |
||||
|
||||
Assert.assertEquals(Status.SUCCESS, relation.get(Constants.STATUS)); |
||||
} |
||||
|
||||
@Test |
||||
public void deleteTaskDefinitionByCode() { |
||||
String projectName = "project_test1"; |
||||
|
||||
Project project = getProject(projectName); |
||||
Mockito.when(projectMapper.queryByName(projectName)).thenReturn(project); |
||||
|
||||
User loginUser = new User(); |
||||
loginUser.setId(-1); |
||||
loginUser.setUserType(UserType.GENERAL_USER); |
||||
|
||||
Map<String, Object> result = new HashMap<>(); |
||||
putMsg(result, Status.SUCCESS, projectName); |
||||
|
||||
//project check auth fail
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result); |
||||
|
||||
TaskNode taskNode = JSONUtils.parseObject(taskDefinitionJson, TaskNode.class); |
||||
|
||||
Mockito.when(taskDefinitionMapper.deleteByCode(Mockito.anyLong())) |
||||
.thenReturn(1); |
||||
|
||||
Map<String, Object> relation = taskDefinitionService |
||||
.deleteTaskDefinitionByCode(loginUser, projectName, 11L); |
||||
|
||||
Assert.assertEquals(Status.SUCCESS, relation.get(Constants.STATUS)); |
||||
|
||||
} |
||||
|
||||
@Test |
||||
public void updateTaskDefinition() { |
||||
String projectName = "project_test1"; |
||||
|
||||
Project project = getProject(projectName); |
||||
Mockito.when(projectMapper.queryByName(projectName)).thenReturn(project); |
||||
|
||||
User loginUser = new User(); |
||||
loginUser.setId(-1); |
||||
loginUser.setUserType(UserType.GENERAL_USER); |
||||
|
||||
Map<String, Object> result = new HashMap<>(); |
||||
putMsg(result, Status.SUCCESS, projectName); |
||||
|
||||
//project check auth fail
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result); |
||||
|
||||
TaskNode taskNode = JSONUtils.parseObject(taskDefinitionJson, TaskNode.class); |
||||
|
||||
Mockito.when(processService.updateTaskDefinition(Mockito.eq(loginUser) |
||||
, Mockito.eq(project.getCode()) |
||||
, Mockito.eq(taskNode) |
||||
, Mockito.any(TaskDefinition.class))) |
||||
.thenReturn(1); |
||||
|
||||
Mockito.when(taskDefinitionMapper.queryByDefinitionCode(11L)) |
||||
.thenReturn(new TaskDefinition()); |
||||
|
||||
Map<String, Object> relation = taskDefinitionService |
||||
.updateTaskDefinition(loginUser, projectName, 11L, taskDefinitionJson); |
||||
|
||||
Assert.assertEquals(Status.SUCCESS, relation.get(Constants.STATUS)); |
||||
} |
||||
|
||||
@Test |
||||
public void switchVersion() { |
||||
String projectName = "project_test1"; |
||||
int version = 1; |
||||
Long taskCode = 11L; |
||||
Project project = getProject(projectName); |
||||
Mockito.when(projectMapper.queryByName(projectName)).thenReturn(project); |
||||
|
||||
User loginUser = new User(); |
||||
loginUser.setId(-1); |
||||
loginUser.setUserType(UserType.GENERAL_USER); |
||||
|
||||
Map<String, Object> result = new HashMap<>(); |
||||
putMsg(result, Status.SUCCESS, projectName); |
||||
|
||||
//project check auth fail
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result); |
||||
|
||||
TaskNode taskNode = JSONUtils.parseObject(taskDefinitionJson, TaskNode.class); |
||||
|
||||
Mockito.when(taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(taskCode, version)) |
||||
.thenReturn(new TaskDefinitionLog()); |
||||
|
||||
Mockito.when(taskDefinitionMapper.queryByDefinitionCode(taskCode)) |
||||
.thenReturn(new TaskDefinition()); |
||||
|
||||
Map<String, Object> relation = taskDefinitionService |
||||
.switchVersion(loginUser, projectName, taskCode, version); |
||||
|
||||
Assert.assertEquals(Status.SUCCESS, relation.get(Constants.STATUS)); |
||||
} |
||||
|
||||
private void putMsg(Map<String, Object> result, Status status, Object... statusParams) { |
||||
result.put(Constants.STATUS, status); |
||||
if (statusParams != null && statusParams.length > 0) { |
||||
result.put(Constants.MSG, MessageFormat.format(status.getMsg(), statusParams)); |
||||
} else { |
||||
result.put(Constants.MSG, status.getMsg()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* get mock Project |
||||
* |
||||
* @param projectName projectName |
||||
* @return Project |
||||
*/ |
||||
private Project getProject(String projectName) { |
||||
Project project = new Project(); |
||||
project.setId(1); |
||||
project.setName(projectName); |
||||
project.setUserId(1); |
||||
return project; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,69 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.common.enums; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue; |
||||
|
||||
/** |
||||
* condition type |
||||
*/ |
||||
public enum ConditionType { |
||||
/** |
||||
* 0 none |
||||
* 1 judge |
||||
* 2 delay |
||||
*/ |
||||
NONE(0, "none"), |
||||
JUDGE(1, "judge"), |
||||
DELAY(2, "delay"); |
||||
|
||||
ConditionType(int code, String desc) { |
||||
this.code = code; |
||||
this.desc = desc; |
||||
} |
||||
|
||||
@EnumValue |
||||
private final int code; |
||||
private final String desc; |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public String getDesc() { |
||||
return desc; |
||||
} |
||||
|
||||
private static final Map<String, ConditionType> CONDITION_TYPE_MAP = new HashMap<>(); |
||||
|
||||
static { |
||||
for (ConditionType conditionType : ConditionType.values()) { |
||||
CONDITION_TYPE_MAP.put(conditionType.desc, conditionType); |
||||
} |
||||
} |
||||
|
||||
public static ConditionType of(String desc) { |
||||
if (CONDITION_TYPE_MAP.containsKey(desc)) { |
||||
return CONDITION_TYPE_MAP.get(desc); |
||||
} |
||||
throw new IllegalArgumentException("invalid type : " + desc); |
||||
} |
||||
} |
@ -0,0 +1,49 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.common.enums; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue; |
||||
|
||||
/** |
||||
* timeout flag |
||||
*/ |
||||
public enum TimeoutFlag { |
||||
/** |
||||
* 0 close |
||||
* 1 open |
||||
*/ |
||||
CLOSE(0, "close"), |
||||
OPEN(1, "open"); |
||||
|
||||
TimeoutFlag(int code, String desc) { |
||||
this.code = code; |
||||
this.desc = desc; |
||||
} |
||||
|
||||
@EnumValue |
||||
private final int code; |
||||
private final String desc; |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public String getDesc() { |
||||
return desc; |
||||
} |
||||
} |
@ -0,0 +1,70 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.common.model; |
||||
|
||||
public class PreviousTaskNode { |
||||
|
||||
/** |
||||
* code |
||||
*/ |
||||
private long code; |
||||
|
||||
/** |
||||
* name |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* version |
||||
*/ |
||||
private int version; |
||||
|
||||
public PreviousTaskNode() { |
||||
|
||||
} |
||||
|
||||
public PreviousTaskNode(long code, String name, int version) { |
||||
this.code = code; |
||||
this.name = name; |
||||
this.version = version; |
||||
} |
||||
|
||||
public long getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public void setCode(long code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public int getVersion() { |
||||
return version; |
||||
} |
||||
|
||||
public void setVersion(int version) { |
||||
this.version = version; |
||||
} |
||||
} |
@ -0,0 +1,91 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.common.utils; |
||||
|
||||
import java.net.InetAddress; |
||||
import java.net.UnknownHostException; |
||||
import java.util.Objects; |
||||
|
||||
public class SnowFlakeUtils { |
||||
// start timestamp
|
||||
private static final long START_TIMESTAMP = 1609430400L; //2021-01-01
|
||||
// Number of digits
|
||||
private static final long SEQUENCE_BIT = 13; |
||||
private static final long MACHINE_BIT = 2; |
||||
private static final long MAX_SEQUENCE = ~(-1L << SEQUENCE_BIT); |
||||
// The displacement to the left
|
||||
private static final long MACHINE_LEFT = SEQUENCE_BIT; |
||||
private static final long TIMESTAMP_LEFT = SEQUENCE_BIT + MACHINE_BIT; |
||||
private final int machineId; |
||||
private long sequence = 0L; |
||||
private long lastTimestamp = -1L; |
||||
|
||||
private SnowFlakeUtils() throws SnowFlakeException { |
||||
try { |
||||
this.machineId = Math.abs(Objects.hash(InetAddress.getLocalHost().getHostName())) % 32; |
||||
} catch (UnknownHostException e) { |
||||
throw new SnowFlakeException(e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
private static SnowFlakeUtils instance = null; |
||||
|
||||
public static synchronized SnowFlakeUtils getInstance() throws SnowFlakeException { |
||||
if (instance == null) { |
||||
instance = new SnowFlakeUtils(); |
||||
} |
||||
return instance; |
||||
} |
||||
|
||||
public synchronized long nextId() throws SnowFlakeException { |
||||
long currStmp = nowTimestamp(); |
||||
if (currStmp < lastTimestamp) { |
||||
throw new SnowFlakeException("Clock moved backwards. Refusing to generate id"); |
||||
} |
||||
if (currStmp == lastTimestamp) { |
||||
sequence = (sequence + 1) & MAX_SEQUENCE; |
||||
if (sequence == 0L) { |
||||
currStmp = getNextMill(); |
||||
} |
||||
} else { |
||||
sequence = 0L; |
||||
} |
||||
lastTimestamp = currStmp; |
||||
return (currStmp - START_TIMESTAMP) << TIMESTAMP_LEFT |
||||
| machineId << MACHINE_LEFT |
||||
| sequence; |
||||
} |
||||
|
||||
private long getNextMill() { |
||||
long mill = nowTimestamp(); |
||||
while (mill <= lastTimestamp) { |
||||
mill = nowTimestamp(); |
||||
} |
||||
return mill; |
||||
} |
||||
|
||||
private long nowTimestamp() { |
||||
return System.currentTimeMillis() / 1000; |
||||
} |
||||
|
||||
public static class SnowFlakeException extends Exception { |
||||
public SnowFlakeException(String message) { |
||||
super(message); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,33 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.common.utils; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
public class SnowFlakeUtilsTest { |
||||
@Test |
||||
public void testNextId() { |
||||
try { |
||||
for (int i = 0; i < 5; i++) { |
||||
System.out.println(SnowFlakeUtils.getInstance().nextId()); |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,89 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.entity; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
||||
/** |
||||
* process definition log |
||||
*/ |
||||
@TableName("t_ds_process_definition_log") |
||||
public class ProcessDefinitionLog extends ProcessDefinition { |
||||
|
||||
/** |
||||
* operator |
||||
*/ |
||||
private int operator; |
||||
|
||||
/** |
||||
* operateTime |
||||
*/ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
private Date operateTime; |
||||
|
||||
public ProcessDefinitionLog() { |
||||
super(); |
||||
} |
||||
|
||||
public ProcessDefinitionLog(ProcessDefinition processDefinition) { |
||||
this.setId(processDefinition.getId()); |
||||
this.setCode(processDefinition.getCode()); |
||||
this.setName(processDefinition.getName()); |
||||
this.setVersion(processDefinition.getVersion()); |
||||
this.setReleaseState(processDefinition.getReleaseState()); |
||||
this.setProjectCode(processDefinition.getProjectCode()); |
||||
this.setDescription(processDefinition.getDescription()); |
||||
this.setGlobalParams(processDefinition.getGlobalParams()); |
||||
this.setGlobalParamList(processDefinition.getGlobalParamList()); |
||||
this.setGlobalParamMap(processDefinition.getGlobalParamMap()); |
||||
this.setCreateTime(processDefinition.getCreateTime()); |
||||
this.setUpdateTime(processDefinition.getUpdateTime()); |
||||
this.setFlag(processDefinition.getFlag()); |
||||
this.setUserId(processDefinition.getUserId()); |
||||
this.setUserName(processDefinition.getUserName()); |
||||
this.setProjectName(processDefinition.getProjectName()); |
||||
this.setLocations(processDefinition.getLocations()); |
||||
this.setConnects(processDefinition.getConnects()); |
||||
this.setScheduleReleaseState(processDefinition.getScheduleReleaseState()); |
||||
this.setTimeout(processDefinition.getTimeout()); |
||||
this.setTenantId(processDefinition.getTenantId()); |
||||
this.setModifyBy(processDefinition.getModifyBy()); |
||||
this.setResourceIds(processDefinition.getResourceIds()); |
||||
this.setWarningGroupId(processDefinition.getWarningGroupId()); |
||||
} |
||||
|
||||
public int getOperator() { |
||||
return operator; |
||||
} |
||||
|
||||
public void setOperator(int operator) { |
||||
this.operator = operator; |
||||
} |
||||
|
||||
public Date getOperateTime() { |
||||
return operateTime; |
||||
} |
||||
|
||||
public void setOperateTime(Date operateTime) { |
||||
this.operateTime = operateTime; |
||||
} |
||||
|
||||
} |
@ -1,311 +0,0 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.entity; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
||||
|
||||
/** |
||||
* process definition version |
||||
*/ |
||||
@TableName("t_ds_process_definition_version") |
||||
public class ProcessDefinitionVersion { |
||||
|
||||
/** |
||||
* id |
||||
*/ |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private int id; |
||||
|
||||
/** |
||||
* process definition id |
||||
*/ |
||||
private int processDefinitionId; |
||||
|
||||
/** |
||||
* version |
||||
*/ |
||||
private long version; |
||||
|
||||
/** |
||||
* definition json string |
||||
*/ |
||||
private String processDefinitionJson; |
||||
|
||||
/** |
||||
* description |
||||
*/ |
||||
private String description; |
||||
|
||||
/** |
||||
* process warning time out. unit: minute |
||||
*/ |
||||
private int timeout; |
||||
|
||||
/** |
||||
* resource ids |
||||
*/ |
||||
private String resourceIds; |
||||
|
||||
/** |
||||
* create time |
||||
*/ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* user defined parameters |
||||
*/ |
||||
private String globalParams; |
||||
|
||||
/** |
||||
* locations array for web |
||||
*/ |
||||
private String locations; |
||||
|
||||
/** |
||||
* connects array for web |
||||
*/ |
||||
private String connects; |
||||
|
||||
|
||||
/** |
||||
* warningGroupId |
||||
*/ |
||||
@TableField(exist = false) |
||||
private int warningGroupId; |
||||
|
||||
public String getGlobalParams() { |
||||
return globalParams; |
||||
} |
||||
|
||||
public void setGlobalParams(String globalParams) { |
||||
this.globalParams = globalParams; |
||||
} |
||||
|
||||
public int getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(int id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public int getProcessDefinitionId() { |
||||
return processDefinitionId; |
||||
} |
||||
|
||||
public void setProcessDefinitionId(int processDefinitionId) { |
||||
this.processDefinitionId = processDefinitionId; |
||||
} |
||||
|
||||
public long getVersion() { |
||||
return version; |
||||
} |
||||
|
||||
public void setVersion(long version) { |
||||
this.version = version; |
||||
} |
||||
|
||||
public String getProcessDefinitionJson() { |
||||
return processDefinitionJson; |
||||
} |
||||
|
||||
public void setProcessDefinitionJson(String processDefinitionJson) { |
||||
this.processDefinitionJson = processDefinitionJson; |
||||
} |
||||
|
||||
public String getDescription() { |
||||
return description; |
||||
} |
||||
|
||||
public void setDescription(String description) { |
||||
this.description = description; |
||||
} |
||||
|
||||
public Date getCreateTime() { |
||||
return createTime; |
||||
} |
||||
|
||||
public void setCreateTime(Date createTime) { |
||||
this.createTime = createTime; |
||||
} |
||||
|
||||
public String getLocations() { |
||||
return locations; |
||||
} |
||||
|
||||
public void setLocations(String locations) { |
||||
this.locations = locations; |
||||
} |
||||
|
||||
public String getConnects() { |
||||
return connects; |
||||
} |
||||
|
||||
public void setConnects(String connects) { |
||||
this.connects = connects; |
||||
} |
||||
|
||||
public int getTimeout() { |
||||
return timeout; |
||||
} |
||||
|
||||
public void setTimeout(int timeout) { |
||||
this.timeout = timeout; |
||||
} |
||||
|
||||
public String getResourceIds() { |
||||
return resourceIds; |
||||
} |
||||
|
||||
public void setResourceIds(String resourceIds) { |
||||
this.resourceIds = resourceIds; |
||||
} |
||||
|
||||
public int getWarningGroupId() { |
||||
return warningGroupId; |
||||
} |
||||
|
||||
public void setWarningGroupId(int warningGroupId) { |
||||
this.warningGroupId = warningGroupId; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "ProcessDefinitionVersion{" |
||||
+ "id=" + id |
||||
+ ", processDefinitionId=" + processDefinitionId |
||||
+ ", version=" + version |
||||
+ ", processDefinitionJson='" + processDefinitionJson + '\'' |
||||
+ ", description='" + description + '\'' |
||||
+ ", globalParams='" + globalParams + '\'' |
||||
+ ", createTime=" + createTime |
||||
+ ", locations='" + locations + '\'' |
||||
+ ", connects='" + connects + '\'' |
||||
+ ", timeout=" + timeout |
||||
+ ", warningGroupId=" + warningGroupId |
||||
+ ", resourceIds='" + resourceIds + '\'' |
||||
+ '}'; |
||||
} |
||||
|
||||
public static Builder newBuilder() { |
||||
return new Builder(); |
||||
} |
||||
|
||||
public static final class Builder { |
||||
private int id; |
||||
private int processDefinitionId; |
||||
private long version; |
||||
private String processDefinitionJson; |
||||
private String description; |
||||
private String globalParams; |
||||
private Date createTime; |
||||
private String locations; |
||||
private String connects; |
||||
private int timeout; |
||||
private int warningGroupId; |
||||
private String resourceIds; |
||||
|
||||
private Builder() { |
||||
} |
||||
|
||||
public Builder id(int id) { |
||||
this.id = id; |
||||
return this; |
||||
} |
||||
|
||||
public Builder processDefinitionId(int processDefinitionId) { |
||||
this.processDefinitionId = processDefinitionId; |
||||
return this; |
||||
} |
||||
|
||||
public Builder version(long version) { |
||||
this.version = version; |
||||
return this; |
||||
} |
||||
|
||||
public Builder processDefinitionJson(String processDefinitionJson) { |
||||
this.processDefinitionJson = processDefinitionJson; |
||||
return this; |
||||
} |
||||
|
||||
public Builder description(String description) { |
||||
this.description = description; |
||||
return this; |
||||
} |
||||
|
||||
public Builder globalParams(String globalParams) { |
||||
this.globalParams = globalParams; |
||||
return this; |
||||
} |
||||
|
||||
public Builder createTime(Date createTime) { |
||||
this.createTime = createTime; |
||||
return this; |
||||
} |
||||
|
||||
public Builder locations(String locations) { |
||||
this.locations = locations; |
||||
return this; |
||||
} |
||||
|
||||
public Builder connects(String connects) { |
||||
this.connects = connects; |
||||
return this; |
||||
} |
||||
|
||||
public Builder timeout(int timeout) { |
||||
this.timeout = timeout; |
||||
return this; |
||||
} |
||||
|
||||
public Builder warningGroupId(int warningGroupId) { |
||||
this.warningGroupId = warningGroupId; |
||||
return this; |
||||
} |
||||
|
||||
public Builder resourceIds(String resourceIds) { |
||||
this.resourceIds = resourceIds; |
||||
return this; |
||||
} |
||||
|
||||
public ProcessDefinitionVersion build() { |
||||
ProcessDefinitionVersion processDefinitionVersion = new ProcessDefinitionVersion(); |
||||
processDefinitionVersion.setId(id); |
||||
processDefinitionVersion.setProcessDefinitionId(processDefinitionId); |
||||
processDefinitionVersion.setVersion(version); |
||||
processDefinitionVersion.setProcessDefinitionJson(processDefinitionJson); |
||||
processDefinitionVersion.setDescription(description); |
||||
processDefinitionVersion.setGlobalParams(globalParams); |
||||
processDefinitionVersion.setCreateTime(createTime); |
||||
processDefinitionVersion.setLocations(locations); |
||||
processDefinitionVersion.setConnects(connects); |
||||
processDefinitionVersion.setTimeout(timeout); |
||||
processDefinitionVersion.setWarningGroupId(warningGroupId); |
||||
processDefinitionVersion.setResourceIds(resourceIds); |
||||
return processDefinitionVersion; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,120 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.entity; |
||||
|
||||
/** |
||||
* Process lineage |
||||
*/ |
||||
public class ProcessLineage { |
||||
|
||||
/** |
||||
* project code |
||||
*/ |
||||
private Long projectCode; |
||||
|
||||
/** |
||||
* post task code |
||||
*/ |
||||
private Long postTaskCode; |
||||
|
||||
/** |
||||
* post task version |
||||
*/ |
||||
private int postTaskVersion; |
||||
|
||||
/** |
||||
* pre task code |
||||
*/ |
||||
private Long preTaskCode; |
||||
|
||||
/** |
||||
* pre task version |
||||
*/ |
||||
private int preTaskVersion; |
||||
|
||||
/** |
||||
* process definition code |
||||
*/ |
||||
private Long processDefinitionCode; |
||||
|
||||
/** |
||||
* process definition version |
||||
*/ |
||||
private int processDefinitionVersion; |
||||
|
||||
public Long getProjectCode() { |
||||
return projectCode; |
||||
} |
||||
|
||||
public void setProjectCode(Long projectCode) { |
||||
this.projectCode = projectCode; |
||||
} |
||||
|
||||
public Long getProcessDefinitionCode() { |
||||
return processDefinitionCode; |
||||
} |
||||
|
||||
public void setProcessDefinitionCode(Long processDefinitionCode) { |
||||
this.processDefinitionCode = processDefinitionCode; |
||||
} |
||||
|
||||
public int getProcessDefinitionVersion() { |
||||
return processDefinitionVersion; |
||||
} |
||||
|
||||
public void setProcessDefinitionVersion(int processDefinitionVersion) { |
||||
this.processDefinitionVersion = processDefinitionVersion; |
||||
} |
||||
|
||||
public void setPostTaskCode(Long postTaskCode) { |
||||
this.postTaskCode = postTaskCode; |
||||
} |
||||
|
||||
public Long getPreTaskCode() { |
||||
return preTaskCode; |
||||
} |
||||
|
||||
public void setPreTaskCode(Long preTaskCode) { |
||||
this.preTaskCode = preTaskCode; |
||||
} |
||||
|
||||
public int getPreTaskVersion() { |
||||
return preTaskVersion; |
||||
} |
||||
|
||||
public void setPreTaskVersion(int preTaskVersion) { |
||||
this.preTaskVersion = preTaskVersion; |
||||
} |
||||
|
||||
public int getPostTaskVersion() { |
||||
return postTaskVersion; |
||||
} |
||||
|
||||
public void setPostTaskVersion(int postTaskVersion) { |
||||
this.postTaskVersion = postTaskVersion; |
||||
} |
||||
|
||||
public long getPostTaskCode() { |
||||
return postTaskCode; |
||||
} |
||||
|
||||
public void setPostTaskCode(long postTaskCode) { |
||||
this.postTaskCode = postTaskCode; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,254 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.entity; |
||||
|
||||
import org.apache.dolphinscheduler.common.enums.ConditionType; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
||||
/** |
||||
* process task relation |
||||
*/ |
||||
@TableName("t_ds_process_task_relation") |
||||
public class ProcessTaskRelation { |
||||
|
||||
/** |
||||
* id |
||||
*/ |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private int id; |
||||
|
||||
/** |
||||
* name |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* process version |
||||
*/ |
||||
private int processDefinitionVersion; |
||||
|
||||
/** |
||||
* project code |
||||
*/ |
||||
private long projectCode; |
||||
|
||||
/** |
||||
* process code |
||||
*/ |
||||
private long processDefinitionCode; |
||||
|
||||
/** |
||||
* pre task code |
||||
*/ |
||||
private long preTaskCode; |
||||
|
||||
/** |
||||
* pre node version |
||||
*/ |
||||
private int preTaskVersion; |
||||
|
||||
/** |
||||
* post task code |
||||
*/ |
||||
private long postTaskCode; |
||||
|
||||
/** |
||||
* post node version |
||||
*/ |
||||
private int postTaskVersion; |
||||
|
||||
/** |
||||
* condition type |
||||
*/ |
||||
private ConditionType conditionType; |
||||
|
||||
/** |
||||
* condition parameters |
||||
*/ |
||||
private String conditionParams; |
||||
|
||||
/** |
||||
* create time |
||||
*/ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* update time |
||||
*/ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
private Date updateTime; |
||||
|
||||
public ProcessTaskRelation() { |
||||
} |
||||
|
||||
public ProcessTaskRelation(String name, |
||||
int processDefinitionVersion, |
||||
long projectCode, |
||||
long processDefinitionCode, |
||||
long preTaskCode, |
||||
int preTaskVersion, |
||||
long postTaskCode, |
||||
int postTaskVersion, |
||||
ConditionType conditionType, |
||||
String conditionParams, |
||||
Date createTime, |
||||
Date updateTime) { |
||||
this.name = name; |
||||
this.processDefinitionVersion = processDefinitionVersion; |
||||
this.projectCode = projectCode; |
||||
this.processDefinitionCode = processDefinitionCode; |
||||
this.preTaskCode = preTaskCode; |
||||
this.preTaskVersion = preTaskVersion; |
||||
this.postTaskCode = postTaskCode; |
||||
this.postTaskVersion = postTaskVersion; |
||||
this.conditionType = conditionType; |
||||
this.conditionParams = conditionParams; |
||||
this.createTime = createTime; |
||||
this.updateTime = updateTime; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public int getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(int id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public Date getCreateTime() { |
||||
return createTime; |
||||
} |
||||
|
||||
public void setCreateTime(Date createTime) { |
||||
this.createTime = createTime; |
||||
} |
||||
|
||||
public Date getUpdateTime() { |
||||
return updateTime; |
||||
} |
||||
|
||||
public void setUpdateTime(Date updateTime) { |
||||
this.updateTime = updateTime; |
||||
} |
||||
|
||||
public String getConditionParams() { |
||||
return conditionParams; |
||||
} |
||||
|
||||
public void setConditionParams(String conditionParams) { |
||||
this.conditionParams = conditionParams; |
||||
} |
||||
|
||||
public int getProcessDefinitionVersion() { |
||||
return processDefinitionVersion; |
||||
} |
||||
|
||||
public void setProcessDefinitionVersion(int processDefinitionVersion) { |
||||
this.processDefinitionVersion = processDefinitionVersion; |
||||
} |
||||
|
||||
public long getProjectCode() { |
||||
return projectCode; |
||||
} |
||||
|
||||
public void setProjectCode(long projectCode) { |
||||
this.projectCode = projectCode; |
||||
} |
||||
|
||||
public long getProcessDefinitionCode() { |
||||
return processDefinitionCode; |
||||
} |
||||
|
||||
public void setProcessDefinitionCode(long processDefinitionCode) { |
||||
this.processDefinitionCode = processDefinitionCode; |
||||
} |
||||
|
||||
public long getPreTaskCode() { |
||||
return preTaskCode; |
||||
} |
||||
|
||||
public void setPreTaskCode(long preTaskCode) { |
||||
this.preTaskCode = preTaskCode; |
||||
} |
||||
|
||||
public long getPostTaskCode() { |
||||
return postTaskCode; |
||||
} |
||||
|
||||
public void setPostTaskCode(long postTaskCode) { |
||||
this.postTaskCode = postTaskCode; |
||||
} |
||||
|
||||
public ConditionType getConditionType() { |
||||
return conditionType; |
||||
} |
||||
|
||||
public void setConditionType(ConditionType conditionType) { |
||||
this.conditionType = conditionType; |
||||
} |
||||
|
||||
public int getPreTaskVersion() { |
||||
return preTaskVersion; |
||||
} |
||||
|
||||
public void setPreTaskVersion(int preTaskVersion) { |
||||
this.preTaskVersion = preTaskVersion; |
||||
} |
||||
|
||||
public int getPostTaskVersion() { |
||||
return postTaskVersion; |
||||
} |
||||
|
||||
public void setPostTaskVersion(int postTaskVersion) { |
||||
this.postTaskVersion = postTaskVersion; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "ProcessTaskRelation{" |
||||
+ "id=" + id |
||||
+ ", name='" + name + '\'' |
||||
+ ", processDefinitionVersion=" + processDefinitionVersion |
||||
+ ", projectCode=" + projectCode |
||||
+ ", processDefinitionCode=" + processDefinitionCode |
||||
+ ", preTaskCode=" + preTaskCode |
||||
+ ", preTaskVersion=" + preTaskVersion |
||||
+ ", postTaskCode=" + postTaskCode |
||||
+ ", postTaskVersion=" + postTaskVersion |
||||
+ ", conditionType=" + conditionType |
||||
+ ", conditionParams='" + conditionParams + '\'' |
||||
+ ", createTime=" + createTime |
||||
+ ", updateTime=" + updateTime |
||||
+ '}'; |
||||
} |
||||
} |
@ -0,0 +1,83 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.entity; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
||||
/** |
||||
* process task relation log |
||||
*/ |
||||
@TableName("t_ds_process_task_relation_log") |
||||
public class ProcessTaskRelationLog extends ProcessTaskRelation { |
||||
|
||||
/** |
||||
* operator user id |
||||
*/ |
||||
private int operator; |
||||
|
||||
/** |
||||
* operate time |
||||
*/ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
private Date operateTime; |
||||
|
||||
public ProcessTaskRelationLog() { |
||||
super(); |
||||
} |
||||
|
||||
public ProcessTaskRelationLog(ProcessTaskRelation processTaskRelation) { |
||||
super(); |
||||
this.setId(processTaskRelation.getId()); |
||||
this.setName(processTaskRelation.getName()); |
||||
this.setProcessDefinitionCode(processTaskRelation.getProcessDefinitionCode()); |
||||
this.setProcessDefinitionVersion(processTaskRelation.getProcessDefinitionVersion()); |
||||
this.setProjectCode(processTaskRelation.getProjectCode()); |
||||
this.setPreTaskCode(processTaskRelation.getPreTaskCode()); |
||||
this.setPreTaskVersion(processTaskRelation.getPreTaskVersion()); |
||||
this.setPostTaskCode(processTaskRelation.getPostTaskCode()); |
||||
this.setPostTaskVersion(processTaskRelation.getPostTaskVersion()); |
||||
this.setConditionType(processTaskRelation.getConditionType()); |
||||
this.setConditionParams(processTaskRelation.getConditionParams()); |
||||
this.setCreateTime(processTaskRelation.getCreateTime()); |
||||
this.setUpdateTime(processTaskRelation.getUpdateTime()); |
||||
} |
||||
|
||||
public int getOperator() { |
||||
return operator; |
||||
} |
||||
|
||||
public void setOperator(int operator) { |
||||
this.operator = operator; |
||||
} |
||||
|
||||
public Date getOperateTime() { |
||||
return operateTime; |
||||
} |
||||
|
||||
public void setOperateTime(Date operateTime) { |
||||
this.operateTime = operateTime; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return super.toString(); |
||||
} |
||||
} |
@ -0,0 +1,428 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.entity; |
||||
|
||||
import org.apache.dolphinscheduler.common.enums.Flag; |
||||
import org.apache.dolphinscheduler.common.enums.Priority; |
||||
import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; |
||||
import org.apache.dolphinscheduler.common.enums.TimeoutFlag; |
||||
import org.apache.dolphinscheduler.common.process.Property; |
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.stream.Collectors; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import com.fasterxml.jackson.databind.JsonNode; |
||||
|
||||
/** |
||||
* task definition |
||||
*/ |
||||
@TableName("t_ds_task_definition") |
||||
public class TaskDefinition { |
||||
|
||||
/** |
||||
* id |
||||
*/ |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private int id; |
||||
|
||||
/** |
||||
* code |
||||
*/ |
||||
private long code; |
||||
|
||||
/** |
||||
* name |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* version |
||||
*/ |
||||
private int version; |
||||
|
||||
/** |
||||
* description |
||||
*/ |
||||
private String description; |
||||
|
||||
/** |
||||
* project code |
||||
*/ |
||||
private long projectCode; |
||||
|
||||
/** |
||||
* task user id |
||||
*/ |
||||
private int userId; |
||||
|
||||
/** |
||||
* task type |
||||
*/ |
||||
private String taskType; |
||||
|
||||
/** |
||||
* user defined parameters |
||||
*/ |
||||
private String taskParams; |
||||
|
||||
/** |
||||
* user defined parameter list |
||||
*/ |
||||
@TableField(exist = false) |
||||
private List<Property> taskParamList; |
||||
|
||||
/** |
||||
* user define parameter map |
||||
*/ |
||||
@TableField(exist = false) |
||||
private Map<String, String> taskParamMap; |
||||
|
||||
/** |
||||
* task is valid: yes/no |
||||
*/ |
||||
private Flag flag; |
||||
|
||||
/** |
||||
* task priority |
||||
*/ |
||||
private Priority taskPriority; |
||||
|
||||
/** |
||||
* user name |
||||
*/ |
||||
@TableField(exist = false) |
||||
private String userName; |
||||
|
||||
/** |
||||
* project name |
||||
*/ |
||||
@TableField(exist = false) |
||||
private String projectName; |
||||
|
||||
/** |
||||
* worker group |
||||
*/ |
||||
private String workerGroup; |
||||
|
||||
/** |
||||
* fail retry times |
||||
*/ |
||||
private int failRetryTimes; |
||||
|
||||
/** |
||||
* fail retry interval |
||||
*/ |
||||
private int failRetryInterval; |
||||
|
||||
/** |
||||
* timeout flag |
||||
*/ |
||||
private TimeoutFlag timeoutFlag; |
||||
|
||||
/** |
||||
* timeout notify strategy |
||||
*/ |
||||
private TaskTimeoutStrategy timeoutNotifyStrategy; |
||||
|
||||
/** |
||||
* task warning time out. unit: minute |
||||
*/ |
||||
private int timeout; |
||||
|
||||
/** |
||||
* delay execution time. |
||||
*/ |
||||
private int delayTime; |
||||
|
||||
/** |
||||
* resource ids |
||||
*/ |
||||
private String resourceIds; |
||||
|
||||
/** |
||||
* create time |
||||
*/ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* update time |
||||
*/ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
private Date updateTime; |
||||
|
||||
public TaskDefinition() { |
||||
} |
||||
|
||||
public TaskDefinition(long code, int version) { |
||||
this.code = code; |
||||
this.version = version; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public int getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(int id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public Date getCreateTime() { |
||||
return createTime; |
||||
} |
||||
|
||||
public void setCreateTime(Date createTime) { |
||||
this.createTime = createTime; |
||||
} |
||||
|
||||
public Date getUpdateTime() { |
||||
return updateTime; |
||||
} |
||||
|
||||
public void setUpdateTime(Date updateTime) { |
||||
this.updateTime = updateTime; |
||||
} |
||||
|
||||
public Flag getFlag() { |
||||
return flag; |
||||
} |
||||
|
||||
public void setFlag(Flag flag) { |
||||
this.flag = flag; |
||||
} |
||||
|
||||
public int getUserId() { |
||||
return userId; |
||||
} |
||||
|
||||
public void setUserId(int userId) { |
||||
this.userId = userId; |
||||
} |
||||
|
||||
public String getUserName() { |
||||
return userName; |
||||
} |
||||
|
||||
public void setUserName(String userName) { |
||||
this.userName = userName; |
||||
} |
||||
|
||||
public String getProjectName() { |
||||
return projectName; |
||||
} |
||||
|
||||
public void setProjectName(String projectName) { |
||||
this.projectName = projectName; |
||||
} |
||||
|
||||
public String getTaskParams() { |
||||
return taskParams; |
||||
} |
||||
|
||||
public void setTaskParams(String taskParams) { |
||||
this.taskParams = taskParams; |
||||
} |
||||
|
||||
public List<Property> getTaskParamList() { |
||||
JsonNode localParams = JSONUtils.parseObject(taskParams).findValue("localParams"); |
||||
if (localParams != null) { |
||||
taskParamList = JSONUtils.toList(localParams.toString(), Property.class); |
||||
} |
||||
|
||||
return taskParamList; |
||||
} |
||||
|
||||
public void setTaskParamList(List<Property> taskParamList) { |
||||
this.taskParamList = taskParamList; |
||||
} |
||||
|
||||
public void setTaskParamMap(Map<String, String> taskParamMap) { |
||||
this.taskParamMap = taskParamMap; |
||||
} |
||||
|
||||
public Map<String, String> getTaskParamMap() { |
||||
if (taskParamMap == null && StringUtils.isNotEmpty(taskParams)) { |
||||
JsonNode localParams = JSONUtils.parseObject(taskParams).findValue("localParams"); |
||||
if (localParams != null) { |
||||
List<Property> propList = JSONUtils.toList(localParams.toString(), Property.class); |
||||
taskParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue)); |
||||
} |
||||
} |
||||
return taskParamMap; |
||||
} |
||||
|
||||
public int getTimeout() { |
||||
return timeout; |
||||
} |
||||
|
||||
public void setTimeout(int timeout) { |
||||
this.timeout = timeout; |
||||
} |
||||
|
||||
public String getDescription() { |
||||
return description; |
||||
} |
||||
|
||||
public void setDescription(String description) { |
||||
this.description = description; |
||||
} |
||||
|
||||
public long getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public void setCode(long code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public int getVersion() { |
||||
return version; |
||||
} |
||||
|
||||
public void setVersion(int version) { |
||||
this.version = version; |
||||
} |
||||
|
||||
public long getProjectCode() { |
||||
return projectCode; |
||||
} |
||||
|
||||
public void setProjectCode(long projectCode) { |
||||
this.projectCode = projectCode; |
||||
} |
||||
|
||||
public String getTaskType() { |
||||
return taskType; |
||||
} |
||||
|
||||
public void setTaskType(String taskType) { |
||||
this.taskType = taskType; |
||||
} |
||||
|
||||
public Priority getTaskPriority() { |
||||
return taskPriority; |
||||
} |
||||
|
||||
public void setTaskPriority(Priority taskPriority) { |
||||
this.taskPriority = taskPriority; |
||||
} |
||||
|
||||
public String getWorkerGroup() { |
||||
return workerGroup; |
||||
} |
||||
|
||||
public void setWorkerGroup(String workerGroup) { |
||||
this.workerGroup = workerGroup; |
||||
} |
||||
|
||||
public int getFailRetryTimes() { |
||||
return failRetryTimes; |
||||
} |
||||
|
||||
public void setFailRetryTimes(int failRetryTimes) { |
||||
this.failRetryTimes = failRetryTimes; |
||||
} |
||||
|
||||
public int getFailRetryInterval() { |
||||
return failRetryInterval; |
||||
} |
||||
|
||||
public void setFailRetryInterval(int failRetryInterval) { |
||||
this.failRetryInterval = failRetryInterval; |
||||
} |
||||
|
||||
public TaskTimeoutStrategy getTimeoutNotifyStrategy() { |
||||
return timeoutNotifyStrategy; |
||||
} |
||||
|
||||
public void setTimeoutNotifyStrategy(TaskTimeoutStrategy timeoutNotifyStrategy) { |
||||
this.timeoutNotifyStrategy = timeoutNotifyStrategy; |
||||
} |
||||
|
||||
public TimeoutFlag getTimeoutFlag() { |
||||
return timeoutFlag; |
||||
} |
||||
|
||||
public void setTimeoutFlag(TimeoutFlag timeoutFlag) { |
||||
this.timeoutFlag = timeoutFlag; |
||||
} |
||||
|
||||
public String getResourceIds() { |
||||
return resourceIds; |
||||
} |
||||
|
||||
public void setResourceIds(String resourceIds) { |
||||
this.resourceIds = resourceIds; |
||||
} |
||||
|
||||
public int getDelayTime() { |
||||
return delayTime; |
||||
} |
||||
|
||||
public void setDelayTime(int delayTime) { |
||||
this.delayTime = delayTime; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "TaskDefinition{" |
||||
+ "id=" + id |
||||
+ ", code=" + code |
||||
+ ", name='" + name + '\'' |
||||
+ ", version=" + version |
||||
+ ", description='" + description + '\'' |
||||
+ ", projectCode=" + projectCode |
||||
+ ", userId=" + userId |
||||
+ ", taskType=" + taskType |
||||
+ ", taskParams='" + taskParams + '\'' |
||||
+ ", taskParamList=" + taskParamList |
||||
+ ", taskParamMap=" + taskParamMap |
||||
+ ", flag=" + flag |
||||
+ ", taskPriority=" + taskPriority |
||||
+ ", userName='" + userName + '\'' |
||||
+ ", projectName='" + projectName + '\'' |
||||
+ ", workerGroup='" + workerGroup + '\'' |
||||
+ ", failRetryTimes=" + failRetryTimes |
||||
+ ", failRetryInterval=" + failRetryInterval |
||||
+ ", timeoutFlag=" + timeoutFlag |
||||
+ ", timeoutNotifyStrategy=" + timeoutNotifyStrategy |
||||
+ ", timeout=" + timeout |
||||
+ ", delayTime=" + delayTime |
||||
+ ", resourceIds='" + resourceIds + '\'' |
||||
+ ", createTime=" + createTime |
||||
+ ", updateTime=" + updateTime |
||||
+ '}'; |
||||
} |
||||
} |
@ -0,0 +1,95 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.entity; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
||||
/** |
||||
* task definition log |
||||
*/ |
||||
@TableName("t_ds_task_definition_log") |
||||
public class TaskDefinitionLog extends TaskDefinition { |
||||
|
||||
/** |
||||
* operator user id |
||||
*/ |
||||
private int operator; |
||||
|
||||
/** |
||||
* operate time |
||||
*/ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
private Date operateTime; |
||||
|
||||
public TaskDefinitionLog() { |
||||
super(); |
||||
} |
||||
|
||||
public TaskDefinitionLog(TaskDefinition taskDefinition) { |
||||
super(); |
||||
this.setId(taskDefinition.getId()); |
||||
this.setCode(taskDefinition.getCode()); |
||||
this.setVersion(taskDefinition.getVersion()); |
||||
this.setName(taskDefinition.getName()); |
||||
this.setDescription(taskDefinition.getDescription()); |
||||
this.setUserId(taskDefinition.getUserId()); |
||||
this.setUserName(taskDefinition.getUserName()); |
||||
this.setWorkerGroup(taskDefinition.getWorkerGroup()); |
||||
this.setProjectCode(taskDefinition.getProjectCode()); |
||||
this.setProjectName(taskDefinition.getProjectName()); |
||||
this.setResourceIds(taskDefinition.getResourceIds()); |
||||
this.setTaskParams(taskDefinition.getTaskParams()); |
||||
this.setTaskParamList(taskDefinition.getTaskParamList()); |
||||
this.setTaskParamMap(taskDefinition.getTaskParamMap()); |
||||
this.setTaskPriority(taskDefinition.getTaskPriority()); |
||||
this.setTimeoutNotifyStrategy(taskDefinition.getTimeoutNotifyStrategy()); |
||||
this.setTaskType(taskDefinition.getTaskType()); |
||||
this.setTimeout(taskDefinition.getTimeout()); |
||||
this.setDelayTime(taskDefinition.getDelayTime()); |
||||
this.setTimeoutFlag(taskDefinition.getTimeoutFlag()); |
||||
this.setUpdateTime(taskDefinition.getUpdateTime()); |
||||
this.setCreateTime(taskDefinition.getCreateTime()); |
||||
this.setFailRetryInterval(taskDefinition.getFailRetryInterval()); |
||||
this.setFailRetryTimes(taskDefinition.getFailRetryTimes()); |
||||
this.setFlag(taskDefinition.getFlag()); |
||||
} |
||||
|
||||
public int getOperator() { |
||||
return operator; |
||||
} |
||||
|
||||
public void setOperator(int operator) { |
||||
this.operator = operator; |
||||
} |
||||
|
||||
public Date getOperateTime() { |
||||
return operateTime; |
||||
} |
||||
|
||||
public void setOperateTime(Date operateTime) { |
||||
this.operateTime = operateTime; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return super.toString(); |
||||
} |
||||
} |
@ -0,0 +1,91 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.mapper; |
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
||||
/** |
||||
* process definition log mapper interface
|
||||
*/ |
||||
public interface ProcessDefinitionLogMapper extends BaseMapper<ProcessDefinitionLog> { |
||||
|
||||
/** |
||||
* query process definition log by name |
||||
* |
||||
* @param projectCode projectCode |
||||
* @param name process name |
||||
* @return process definition log list |
||||
*/ |
||||
List<ProcessDefinitionLog> queryByDefinitionName(@Param("projectCode") Long projectCode, |
||||
@Param("processDefinitionName") String name); |
||||
|
||||
/** |
||||
* query process definition log list |
||||
* |
||||
* @param processDefinitionCode processDefinitionCode |
||||
* @return process definition log list |
||||
*/ |
||||
List<ProcessDefinitionLog> queryByDefinitionCode(@Param("processDefinitionCode") long processDefinitionCode); |
||||
|
||||
/** |
||||
* query max version for definition |
||||
*/ |
||||
Integer queryMaxVersionForDefinition(@Param("processDefinitionCode") long processDefinitionCode); |
||||
|
||||
/** |
||||
* query max version definition log |
||||
*/ |
||||
ProcessDefinitionLog queryMaxVersionDefinitionLog(@Param("processDefinitionCode") long processDefinitionCode); |
||||
|
||||
/** |
||||
* query the certain process definition version info by process definition code and version number |
||||
* |
||||
* @param processDefinitionCode process definition code |
||||
* @param version version number |
||||
* @return the process definition version info |
||||
*/ |
||||
ProcessDefinitionLog queryByDefinitionCodeAndVersion(@Param("processDefinitionCode") Long processDefinitionCode, |
||||
@Param("version") long version); |
||||
|
||||
/** |
||||
* query the paging process definition version list by pagination info |
||||
* |
||||
* @param page pagination info |
||||
* @param processDefinitionCode process definition code |
||||
* @return the paging process definition version list |
||||
*/ |
||||
IPage<ProcessDefinitionLog> queryProcessDefinitionVersionsPaging(Page<ProcessDefinitionLog> page, |
||||
@Param("processDefinitionCode") Long processDefinitionCode); |
||||
|
||||
/** |
||||
* delete the certain process definition version by process definition id and version number |
||||
* |
||||
* @param processDefinitionCode process definition code |
||||
* @param version version number |
||||
* @return delete result |
||||
*/ |
||||
int deleteByProcessDefinitionCodeAndVersion(@Param("processDefinitionCode") Long processDefinitionCode, @Param("version") long version); |
||||
} |
@ -1,69 +0,0 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.mapper; |
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionVersion; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
||||
/** |
||||
* process definition mapper interface
|
||||
*/ |
||||
public interface ProcessDefinitionVersionMapper extends BaseMapper<ProcessDefinitionVersion> { |
||||
|
||||
/** |
||||
* query max version by process definition id |
||||
* |
||||
* @param processDefinitionId process definition id |
||||
* @return the max version of this process definition id |
||||
*/ |
||||
Long queryMaxVersionByProcessDefinitionId(@Param("processDefinitionId") int processDefinitionId); |
||||
|
||||
/** |
||||
* query the paging process definition version list by pagination info |
||||
* |
||||
* @param page pagination info |
||||
* @param processDefinitionId process definition id |
||||
* @return the paging process definition version list |
||||
*/ |
||||
IPage<ProcessDefinitionVersion> queryProcessDefinitionVersionsPaging(Page<ProcessDefinitionVersion> page, |
||||
@Param("processDefinitionId") int processDefinitionId); |
||||
|
||||
/** |
||||
* query the certain process definition version info by process definition id and version number |
||||
* |
||||
* @param processDefinitionId process definition id |
||||
* @param version version number |
||||
* @return the process definition version info |
||||
*/ |
||||
ProcessDefinitionVersion queryByProcessDefinitionIdAndVersion(@Param("processDefinitionId") int processDefinitionId, @Param("version") long version); |
||||
|
||||
/** |
||||
* delete the certain process definition version by process definition id and version number |
||||
* |
||||
* @param processDefinitionId process definition id |
||||
* @param version version number |
||||
* @return delete result |
||||
*/ |
||||
int deleteByProcessDefinitionIdAndVersion(@Param("processDefinitionId") int processDefinitionId, @Param("version") long version); |
||||
|
||||
} |
@ -0,0 +1,47 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.mapper; |
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
/** |
||||
* process task relation log mapper interface
|
||||
*/ |
||||
public interface ProcessTaskRelationLogMapper extends BaseMapper<ProcessTaskRelationLog> { |
||||
|
||||
/** |
||||
* query process task relation log |
||||
* |
||||
* @param processCode process definition code |
||||
* @param processVersion process version |
||||
* @return process task relation log |
||||
*/ |
||||
List<ProcessTaskRelationLog> queryByProcessCodeAndVersion(@Param("processCode") long processCode, |
||||
@Param("processVersion") int processVersion); |
||||
|
||||
List<ProcessTaskRelationLog> queryByTaskRelationList(@Param("processCode") long processCode, |
||||
@Param("processVersion") int processVersion, |
||||
@Param("taskCode") long taskCode, |
||||
@Param("taskVersion") long taskVersion); |
||||
} |
@ -0,0 +1,68 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.mapper; |
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
/** |
||||
* process task relation mapper interface
|
||||
*/ |
||||
public interface ProcessTaskRelationMapper extends BaseMapper<ProcessTaskRelation> { |
||||
|
||||
/** |
||||
* process task relation by projectCode and processCode |
||||
* |
||||
* @param projectCode projectCode |
||||
* @param processCode processCode |
||||
* @return ProcessTaskRelation list |
||||
*/ |
||||
List<ProcessTaskRelation> queryByProcessCode(@Param("projectCode") Long projectCode, |
||||
@Param("processCode") Long processCode); |
||||
|
||||
/** |
||||
* process task relation by taskCode |
||||
* |
||||
* @param taskCodes taskCode list |
||||
* @return ProcessTaskRelation |
||||
*/ |
||||
List<ProcessTaskRelation> queryByTaskCodes(@Param("taskCodes") Long[] taskCodes); |
||||
|
||||
/** |
||||
* process task relation by taskCode |
||||
* |
||||
* @param taskCode taskCode |
||||
* @return ProcessTaskRelation |
||||
*/ |
||||
List<ProcessTaskRelation> queryByTaskCode(@Param("taskCode") Long taskCode); |
||||
|
||||
/** |
||||
* delete process task relation by processCode |
||||
* |
||||
* @param projectCode projectCode |
||||
* @param processCode processCode |
||||
* @return int |
||||
*/ |
||||
int deleteByCode(@Param("projectCode") Long projectCode, |
||||
@Param("processCode") Long processCode); |
||||
} |
@ -0,0 +1,70 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.mapper; |
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.TaskDefinition; |
||||
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.Collection; |
||||
import java.util.List; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
/** |
||||
* task definition log mapper interface
|
||||
*/ |
||||
public interface TaskDefinitionLogMapper extends BaseMapper<TaskDefinitionLog> { |
||||
|
||||
/** |
||||
* query task definition log by name |
||||
* |
||||
* @param projectCode projectCode |
||||
* @param name name |
||||
* @return task definition log list |
||||
*/ |
||||
List<TaskDefinitionLog> queryByDefinitionName(@Param("projectCode") Long projectCode, |
||||
@Param("taskDefinitionName") String name); |
||||
|
||||
/** |
||||
* query max version for definition |
||||
* |
||||
* @param taskDefinitionCode taskDefinitionCode |
||||
*/ |
||||
Integer queryMaxVersionForDefinition(@Param("taskDefinitionCode") long taskDefinitionCode); |
||||
|
||||
/** |
||||
* query task definition log |
||||
* |
||||
* @param taskDefinitionCode taskDefinitionCode |
||||
* @param version version |
||||
* @return task definition log |
||||
*/ |
||||
TaskDefinitionLog queryByDefinitionCodeAndVersion(@Param("taskDefinitionCode") long taskDefinitionCode, |
||||
@Param("version") int version); |
||||
|
||||
|
||||
/** |
||||
* |
||||
* @param taskDefinitions |
||||
* @return |
||||
*/ |
||||
List<TaskDefinitionLog> queryByTaskDefinitions(@Param("taskDefinitions") Collection<TaskDefinition> taskDefinitions); |
||||
|
||||
} |
@ -0,0 +1,109 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.dao.mapper; |
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.DefinitionGroupByUser; |
||||
import org.apache.dolphinscheduler.dao.entity.TaskDefinition; |
||||
|
||||
import org.apache.ibatis.annotations.MapKey; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
/** |
||||
* task definition mapper interface
|
||||
*/ |
||||
public interface TaskDefinitionMapper extends BaseMapper<TaskDefinition> { |
||||
|
||||
/** |
||||
* query task definition by name |
||||
* |
||||
* @param projectCode projectCode |
||||
* @param name name |
||||
* @return task definition |
||||
*/ |
||||
TaskDefinition queryByDefinitionName(@Param("projectCode") Long projectCode, |
||||
@Param("taskDefinitionName") String name); |
||||
|
||||
/** |
||||
* query task definition by id |
||||
* |
||||
* @param taskDefinitionId taskDefinitionId |
||||
* @return task definition |
||||
*/ |
||||
TaskDefinition queryByDefinitionId(@Param("taskDefinitionId") int taskDefinitionId); |
||||
|
||||
/** |
||||
* query task definition by code |
||||
* |
||||
* @param taskDefinitionCode taskDefinitionCode |
||||
* @return task definition |
||||
*/ |
||||
TaskDefinition queryByDefinitionCode(@Param("taskDefinitionCode") Long taskDefinitionCode); |
||||
|
||||
/** |
||||
* query all task definition list |
||||
* |
||||
* @param projectCode projectCode |
||||
* @return task definition list |
||||
*/ |
||||
List<TaskDefinition> queryAllDefinitionList(@Param("projectCode") Long projectCode); |
||||
|
||||
/** |
||||
* query task definition by ids |
||||
* |
||||
* @param ids ids |
||||
* @return task definition list |
||||
*/ |
||||
List<TaskDefinition> queryDefinitionListByIdList(@Param("ids") Integer[] ids); |
||||
|
||||
/** |
||||
* count task definition group by user |
||||
* |
||||
* @param projectCodes projectCodes |
||||
* @return task definition list |
||||
*/ |
||||
List<DefinitionGroupByUser> countDefinitionGroupByUser(@Param("projectCodes") Long[] projectCodes); |
||||
|
||||
/** |
||||
* list all resource ids |
||||
* |
||||
* @return task ids list |
||||
*/ |
||||
@MapKey("id") |
||||
List<Map<String, Object>> listResources(); |
||||
|
||||
/** |
||||
* list all resource ids by user id |
||||
* |
||||
* @return resource ids list |
||||
*/ |
||||
@MapKey("id") |
||||
List<Map<String, Object>> listResourcesByUser(@Param("userId") Integer userId); |
||||
|
||||
/** |
||||
* delete task definition by code |
||||
* |
||||
* @param code code |
||||
* @return int |
||||
*/ |
||||
int deleteByCode(@Param("code") Long code); |
||||
} |
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!-- |
||||
~ Licensed to the Apache Software Foundation (ASF) under one or more |
||||
~ contributor license agreements. See the NOTICE file distributed with |
||||
~ this work for additional information regarding copyright ownership. |
||||
~ The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
~ (the "License"); you may not use this file except in compliance with |
||||
~ the License. You may obtain a copy of the License at |
||||
~ |
||||
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||
~ |
||||
~ Unless required by applicable law or agreed to in writing, software |
||||
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
~ See the License for the specific language governing permissions and |
||||
~ limitations under the License. |
||||
--> |
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
||||
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionLogMapper"> |
||||
|
||||
<sql id="baseSql"> |
||||
id, code, name, version, description, project_code, |
||||
release_state, user_id,global_params, flag, locations, connects, |
||||
warning_group_id, timeout, tenant_id,operator, operate_time, create_time, |
||||
update_time |
||||
</sql> |
||||
<select id="queryByDefinitionName" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog"> |
||||
select pd.id, pd.code, pd.name, pd.version, pd.description, pd.project_code, |
||||
pd.release_state, pd.user_id,pd.global_params, pd.flag, pd.locations, pd.connects, |
||||
pd.warning_group_id, pd.timeout, pd.tenant_id,pd.operator, pd.operate_time, pd.create_time, |
||||
pd.update_time, u.user_name,p.name as project_name |
||||
from t_ds_process_definition_log pd |
||||
JOIN t_ds_user u ON pd.user_id = u.id |
||||
JOIN t_ds_project p ON pd.project_code = p.code |
||||
WHERE p.code = #{projectCode} |
||||
and pd.name = #{processDefinitionName} |
||||
</select> |
||||
<select id="queryByDefinitionCode" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog"> |
||||
select |
||||
<include refid="baseSql"/> |
||||
from t_ds_process_definition_log |
||||
WHERE code = #{processDefinitionCode} |
||||
</select> |
||||
<select id="queryByDefinitionCodeAndVersion" |
||||
resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog"> |
||||
select |
||||
<include refid="baseSql"/> |
||||
from t_ds_process_definition_log |
||||
where code = #{processDefinitionCode} |
||||
and version = #{version} |
||||
</select> |
||||
<select id="queryMaxVersionForDefinition" resultType="java.lang.Integer"> |
||||
select max(version) |
||||
from t_ds_process_definition_log |
||||
where code = #{processDefinitionCode} |
||||
</select> |
||||
|
||||
<select id="queryMaxVersionDefinitionLog" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog"> |
||||
|
||||
select |
||||
<include refid="baseSql"/> |
||||
from t_ds_process_definition_log |
||||
where code = #{processDefinitionCode} order by version desc limit 1 |
||||
</select> |
||||
|
||||
<select id="queryProcessDefinitionVersionsPaging" |
||||
resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog"> |
||||
select |
||||
<include refid="baseSql"/> |
||||
from t_ds_process_definition_log |
||||
where code = #{processDefinitionCode} |
||||
order by version desc |
||||
</select> |
||||
|
||||
<delete id="deleteByProcessDefinitionCodeAndVersion"> |
||||
delete |
||||
from t_ds_process_definition_log |
||||
where code = #{processDefinitionCode} |
||||
and version = #{version} |
||||
</delete> |
||||
</mapper> |
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!-- |
||||
~ Licensed to the Apache Software Foundation (ASF) under one or more |
||||
~ contributor license agreements. See the NOTICE file distributed with |
||||
~ this work for additional information regarding copyright ownership. |
||||
~ The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
~ (the "License"); you may not use this file except in compliance with |
||||
~ the License. You may obtain a copy of the License at |
||||
~ |
||||
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||
~ |
||||
~ Unless required by applicable law or agreed to in writing, software |
||||
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
~ See the License for the specific language governing permissions and |
||||
~ limitations under the License. |
||||
--> |
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
||||
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper"> |
||||
<sql id="baseSql"> |
||||
id, `name`, process_definition_version, project_code, process_definition_code, pre_task_code, pre_task_version, |
||||
post_task_code, post_task_version, condition_type, condition_params, create_time, update_time |
||||
</sql> |
||||
<select id="queryByProcessCode" resultType="org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation"> |
||||
select |
||||
<include refid="baseSql"/> |
||||
from t_ds_process_task_relation |
||||
WHERE project_code = #{projectCode} |
||||
and process_definition_code = #{processCode} |
||||
</select> |
||||
<select id="queryByTaskCode" resultType="org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation"> |
||||
select |
||||
<include refid="baseSql"/> |
||||
from t_ds_process_task_relation |
||||
WHERE pre_task_code = #{taskCode} |
||||
<if test="taskCode != 0"> |
||||
or post_task_code = #{taskCode} |
||||
</if> |
||||
</select> |
||||
<select id="queryByTaskCodes" resultType="org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation"> |
||||
select |
||||
<include refid="baseSql"/> |
||||
from t_ds_process_task_relation |
||||
WHERE 1 = 1 |
||||
<if test="taskCodes != null and taskCodes.length != 0"> |
||||
and pre_task_code in |
||||
<foreach collection="taskCodes" index="index" item="i" open="(" separator="," close=")"> |
||||
#{i} |
||||
</foreach> |
||||
or post_task_code in |
||||
<foreach collection="taskCodes" index="index" item="i" open="(" separator="," close=")"> |
||||
#{i} |
||||
</foreach> |
||||
</if> |
||||
</select> |
||||
<delete id="deleteByCode"> |
||||
delete from t_ds_process_task_relation |
||||
WHERE project_code = #{projectCode} |
||||
and process_definition_code = #{processCode} |
||||
</delete> |
||||
</mapper> |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue