Browse Source
* [Feature][api] Workflow version control * Update messages.properties * Update messages_en_US.properties * Update messages_zh_CN.propertiesdata_quality_design
Yichao Yang
4 years ago
committed by
GitHub
35 changed files with 2723 additions and 522 deletions
@ -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.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; |
||||
|
||||
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,181 @@
|
||||
/* |
||||
* 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.BaseService; |
||||
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; |
||||
|
||||
@Service |
||||
public class ProcessDefinitionVersionServiceImpl extends BaseService implements |
||||
ProcessDefinitionVersionService { |
||||
|
||||
@Autowired |
||||
private ProcessDefinitionVersionMapper processDefinitionVersionMapper; |
||||
|
||||
@Autowired |
||||
private ProjectService projectService; |
||||
|
||||
@Autowired |
||||
private ProjectMapper projectMapper; |
||||
|
||||
/** |
||||
* 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 |
||||
*/ |
||||
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()) |
||||
.receivers(processDefinition.getReceivers()) |
||||
.receiversCc(processDefinition.getReceiversCc()) |
||||
.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 |
||||
*/ |
||||
public Map<String, Object> queryProcessDefinitionVersions(User loginUser, String projectName, int pageNo, int pageSize, int processDefinitionId) { |
||||
|
||||
Map<String, Object> result = new HashMap<>(); |
||||
|
||||
// check the if pageNo or pageSize less than 1
|
||||
if (pageNo <= 0 || pageSize <= 0) { |
||||
putMsg(result |
||||
, Status.QUERY_PROCESS_DEFINITION_VERSIONS_PAGE_NO_OR_PAGE_SIZE_LESS_THAN_1_ERROR |
||||
, pageNo |
||||
, pageSize); |
||||
return result; |
||||
} |
||||
|
||||
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 |
||||
*/ |
||||
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 |
||||
*/ |
||||
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; |
||||
} |
||||
processDefinitionVersionMapper.deleteByProcessDefinitionIdAndVersion(processDefinitionId, version); |
||||
putMsg(result, Status.SUCCESS); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,274 @@
|
||||
/* |
||||
* 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; |
||||
|
||||
@RunWith(MockitoJUnitRunner.class) |
||||
public class ProcessDefinitionVersionServiceTest { |
||||
|
||||
@InjectMocks |
||||
private ProcessDefinitionVersionServiceImpl processDefinitionVersionService; |
||||
|
||||
@Mock |
||||
private ProcessDefinitionVersionMapper processDefinitionVersionMapper; |
||||
|
||||
@Mock |
||||
private ProjectMapper projectMapper; |
||||
|
||||
@Mock |
||||
private ProjectServiceImpl projectService; |
||||
|
||||
@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> resultMap1 = processDefinitionVersionService.queryProcessDefinitionVersions( |
||||
loginUser |
||||
, projectName |
||||
, pageNo |
||||
, pageSize |
||||
, processDefinitionId); |
||||
Assert.assertEquals(Status.QUERY_PROCESS_DEFINITION_VERSIONS_PAGE_NO_OR_PAGE_SIZE_LESS_THAN_1_ERROR |
||||
, resultMap1.get(Constants.STATUS)); |
||||
|
||||
// pageSize <= 0
|
||||
pageNo = 1; |
||||
pageSize = -1; |
||||
Map<String, Object> resultMap2 = processDefinitionVersionService.queryProcessDefinitionVersions( |
||||
loginUser |
||||
, projectName |
||||
, pageNo |
||||
, pageSize |
||||
, processDefinitionId); |
||||
Assert.assertEquals(Status.QUERY_PROCESS_DEFINITION_VERSIONS_PAGE_NO_OR_PAGE_SIZE_LESS_THAN_1_ERROR |
||||
, resultMap2.get(Constants.STATUS)); |
||||
|
||||
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); |
||||
|
||||
Map<String, Object> resultMap2 = processDefinitionVersionService.deleteByProcessDefinitionIdAndVersion( |
||||
loginUser |
||||
, projectName |
||||
, processDefinitionId |
||||
, version); |
||||
|
||||
Assert.assertEquals(Status.SUCCESS, resultMap2.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()) |
||||
.receivers(processDefinition.getReceivers()) |
||||
.receiversCc(processDefinition.getReceiversCc()) |
||||
.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,329 @@
|
||||
/* |
||||
* 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.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; |
||||
|
||||
/** |
||||
* receivers |
||||
*/ |
||||
private String receivers; |
||||
|
||||
/** |
||||
* receivers cc |
||||
*/ |
||||
private String receiversCc; |
||||
|
||||
/** |
||||
* 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; |
||||
|
||||
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 String getReceivers() { |
||||
return receivers; |
||||
} |
||||
|
||||
public void setReceivers(String receivers) { |
||||
this.receivers = receivers; |
||||
} |
||||
|
||||
public String getReceiversCc() { |
||||
return receiversCc; |
||||
} |
||||
|
||||
public void setReceiversCc(String receiversCc) { |
||||
this.receiversCc = receiversCc; |
||||
} |
||||
|
||||
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; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "ProcessDefinitionVersion{" |
||||
+ "id=" + id |
||||
+ ", processDefinitionId=" + processDefinitionId |
||||
+ ", version=" + version |
||||
+ ", processDefinitionJson='" + processDefinitionJson + '\'' |
||||
+ ", description='" + description + '\'' |
||||
+ ", globalParams='" + globalParams + '\'' |
||||
+ ", createTime=" + createTime |
||||
+ ", locations='" + locations + '\'' |
||||
+ ", connects='" + connects + '\'' |
||||
+ ", receivers='" + receivers + '\'' |
||||
+ ", receiversCc='" + receiversCc + '\'' |
||||
+ ", timeout=" + timeout |
||||
+ ", 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 String receivers; |
||||
private String receiversCc; |
||||
private int timeout; |
||||
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 receivers(String receivers) { |
||||
this.receivers = receivers; |
||||
return this; |
||||
} |
||||
|
||||
public Builder receiversCc(String receiversCc) { |
||||
this.receiversCc = receiversCc; |
||||
return this; |
||||
} |
||||
|
||||
public Builder timeout(int timeout) { |
||||
this.timeout = timeout; |
||||
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.setReceivers(receivers); |
||||
processDefinitionVersion.setReceiversCc(receiversCc); |
||||
processDefinitionVersion.setTimeout(timeout); |
||||
processDefinitionVersion.setResourceIds(resourceIds); |
||||
return processDefinitionVersion; |
||||
} |
||||
} |
||||
} |
@ -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.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 @@
|
||||
<?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.ProcessDefinitionVersionMapper"> |
||||
<select id="queryMaxVersionByProcessDefinitionId" resultType="java.lang.Long"> |
||||
select max(version) |
||||
from t_ds_process_definition_version |
||||
where process_definition_id = #{processDefinitionId} |
||||
</select> |
||||
|
||||
<select id="queryProcessDefinitionVersionsPaging" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinitionVersion"> |
||||
select * |
||||
from t_ds_process_definition_version |
||||
where process_definition_id = #{processDefinitionId} |
||||
order by version desc |
||||
</select> |
||||
|
||||
<select id="queryByProcessDefinitionIdAndVersion" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinitionVersion"> |
||||
select * |
||||
from t_ds_process_definition_version |
||||
where process_definition_id = #{processDefinitionId} |
||||
and version = #{version} |
||||
</select> |
||||
|
||||
<delete id="deleteByProcessDefinitionIdAndVersion"> |
||||
delete |
||||
from t_ds_process_definition_version |
||||
where process_definition_id = #{processDefinitionId} |
||||
and version = #{version} |
||||
</delete> |
||||
</mapper> |
@ -0,0 +1,172 @@
|
||||
/* |
||||
* 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.common.utils.StringUtils; |
||||
import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionVersion; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.test.annotation.Rollback; |
||||
import org.springframework.test.context.junit4.SpringRunner; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
||||
@RunWith(SpringRunner.class) |
||||
@SpringBootTest |
||||
@Transactional |
||||
@Rollback(true) |
||||
public class ProcessDefinitionVersionMapperTest { |
||||
|
||||
|
||||
@Autowired |
||||
ProcessDefinitionMapper processDefinitionMapper; |
||||
|
||||
@Autowired |
||||
ProcessDefinitionVersionMapper processDefinitionVersionMapper; |
||||
|
||||
@Autowired |
||||
UserMapper userMapper; |
||||
|
||||
@Autowired |
||||
QueueMapper queueMapper; |
||||
|
||||
@Autowired |
||||
TenantMapper tenantMapper; |
||||
|
||||
@Autowired |
||||
ProjectMapper projectMapper; |
||||
|
||||
/** |
||||
* insert |
||||
* |
||||
* @return ProcessDefinition |
||||
*/ |
||||
private ProcessDefinitionVersion insertOne() { |
||||
// insertOne
|
||||
ProcessDefinitionVersion processDefinitionVersion |
||||
= new ProcessDefinitionVersion(); |
||||
processDefinitionVersion.setProcessDefinitionId(66); |
||||
processDefinitionVersion.setVersion(10); |
||||
processDefinitionVersion.setProcessDefinitionJson(StringUtils.EMPTY); |
||||
processDefinitionVersion.setDescription(StringUtils.EMPTY); |
||||
processDefinitionVersion.setGlobalParams(StringUtils.EMPTY); |
||||
processDefinitionVersion.setCreateTime(new Date()); |
||||
processDefinitionVersion.setLocations(StringUtils.EMPTY); |
||||
processDefinitionVersion.setConnects(StringUtils.EMPTY); |
||||
processDefinitionVersion.setReceivers(StringUtils.EMPTY); |
||||
processDefinitionVersion.setReceiversCc(StringUtils.EMPTY); |
||||
processDefinitionVersion.setTimeout(10); |
||||
processDefinitionVersion.setResourceIds("1,2"); |
||||
processDefinitionVersionMapper.insert(processDefinitionVersion); |
||||
return processDefinitionVersion; |
||||
} |
||||
|
||||
/** |
||||
* insert |
||||
* |
||||
* @return ProcessDefinitionVersion |
||||
*/ |
||||
private ProcessDefinitionVersion insertTwo() { |
||||
// insertTwo
|
||||
ProcessDefinitionVersion processDefinitionVersion |
||||
= new ProcessDefinitionVersion(); |
||||
processDefinitionVersion.setProcessDefinitionId(67); |
||||
processDefinitionVersion.setVersion(11); |
||||
processDefinitionVersion.setProcessDefinitionJson(StringUtils.EMPTY); |
||||
processDefinitionVersion.setDescription(StringUtils.EMPTY); |
||||
processDefinitionVersion.setGlobalParams(StringUtils.EMPTY); |
||||
processDefinitionVersion.setCreateTime(new Date()); |
||||
processDefinitionVersion.setLocations(StringUtils.EMPTY); |
||||
processDefinitionVersion.setConnects(StringUtils.EMPTY); |
||||
processDefinitionVersion.setReceivers(StringUtils.EMPTY); |
||||
processDefinitionVersion.setReceiversCc(StringUtils.EMPTY); |
||||
processDefinitionVersion.setTimeout(10); |
||||
processDefinitionVersion.setResourceIds("1,2"); |
||||
processDefinitionVersionMapper.insert(processDefinitionVersion); |
||||
return processDefinitionVersion; |
||||
} |
||||
|
||||
/** |
||||
* test insert |
||||
*/ |
||||
@Test |
||||
public void testInsert() { |
||||
ProcessDefinitionVersion processDefinitionVersion = insertOne(); |
||||
Assert.assertTrue(processDefinitionVersion.getId() > 0); |
||||
} |
||||
|
||||
/** |
||||
* test query |
||||
*/ |
||||
@Test |
||||
public void testQueryMaxVersionByProcessDefinitionId() { |
||||
ProcessDefinitionVersion processDefinitionVersion = insertOne(); |
||||
|
||||
Long version = processDefinitionVersionMapper.queryMaxVersionByProcessDefinitionId( |
||||
processDefinitionVersion.getProcessDefinitionId()); |
||||
// query
|
||||
Assert.assertEquals(10, (long) version); |
||||
} |
||||
|
||||
@Test |
||||
public void testQueryProcessDefinitionVersionsPaging() { |
||||
insertOne(); |
||||
insertTwo(); |
||||
|
||||
Page<ProcessDefinitionVersion> page = new Page<>(1, 3); |
||||
|
||||
IPage<ProcessDefinitionVersion> processDefinitionVersionIPage = |
||||
processDefinitionVersionMapper.queryProcessDefinitionVersionsPaging(page, 10); |
||||
|
||||
Assert.assertTrue(processDefinitionVersionIPage.getSize() >= 2); |
||||
} |
||||
|
||||
@Test |
||||
public void testDeleteByProcessDefinitionIdAndVersion() { |
||||
ProcessDefinitionVersion processDefinitionVersion = insertOne(); |
||||
int i = processDefinitionVersionMapper.deleteByProcessDefinitionIdAndVersion( |
||||
processDefinitionVersion.getProcessDefinitionId(), processDefinitionVersion.getVersion()); |
||||
Assert.assertEquals(1, i); |
||||
} |
||||
|
||||
@Test |
||||
public void testQueryByProcessDefinitionIdAndVersion() { |
||||
ProcessDefinitionVersion processDefinitionVersion1 = insertOne(); |
||||
ProcessDefinitionVersion processDefinitionVersion3 = processDefinitionVersionMapper.queryByProcessDefinitionIdAndVersion( |
||||
processDefinitionVersion1.getProcessDefinitionId(), 10); |
||||
|
||||
ProcessDefinitionVersion processDefinitionVersion2 = insertTwo(); |
||||
ProcessDefinitionVersion processDefinitionVersion4 = processDefinitionVersionMapper.queryByProcessDefinitionIdAndVersion( |
||||
processDefinitionVersion2.getProcessDefinitionId(), 11); |
||||
|
||||
Assert.assertEquals(processDefinitionVersion1.getProcessDefinitionId(), |
||||
processDefinitionVersion3.getProcessDefinitionId()); |
||||
Assert.assertEquals(processDefinitionVersion2.getProcessDefinitionId(), |
||||
processDefinitionVersion4.getProcessDefinitionId()); |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,255 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
<template> |
||||
<div class="container"> |
||||
|
||||
<div class="title-box"> |
||||
<span class="name">{{$t('Version Info')}}</span> |
||||
</div> |
||||
|
||||
<div class="table-box" v-if="processDefinitionVersions.length > 0"> |
||||
<table class="fixed"> |
||||
<caption><!-- placeHolder --></caption> |
||||
<tr> |
||||
<th scope="col"> |
||||
<span>#</span> |
||||
</th> |
||||
<th scope="col" style="min-width: 40px"> |
||||
<span>Version</span> |
||||
</th> |
||||
<th scope="col" style="min-width: 200px;max-width: 300px;"> |
||||
<span>{{$t('Description')}}</span> |
||||
</th> |
||||
<th scope="col" style="min-width: 50px"> |
||||
<span>{{$t('Create Time')}}</span> |
||||
</th> |
||||
<th scope="col" style="min-width: 300px"> |
||||
<span>{{$t('Operation')}}</span> |
||||
</th> |
||||
</tr> |
||||
<tr v-for="(item, $index) in processDefinitionVersions" :key="item.id"> |
||||
<td> |
||||
<span>-</span> |
||||
</td> |
||||
<td> |
||||
<span v-if="item.version"> |
||||
<span v-if="item.version === processDefinition.version" style="color: green"><strong>{{item.version}} {{$t('Current Version')}}</strong></span> |
||||
<span v-else>{{item.version}}</span> |
||||
</span> |
||||
<span v-else>-</span> |
||||
</td> |
||||
<td> |
||||
<span v-if="item.description">{{item.description}}</span> |
||||
<span v-else>-</span> |
||||
</td> |
||||
<td> |
||||
<span v-if="item.createTime">{{item.createTime}}</span> |
||||
<span v-else>-</span> |
||||
</td> |
||||
<td> |
||||
<x-poptip |
||||
:ref="'poptip-switch-version-' + $index" |
||||
placement="top-end" |
||||
width="90"> |
||||
<p>{{$t('Confirm Switch To This Version?')}}</p> |
||||
<div style="text-align: right; margin: 0;padding-top: 4px;"> |
||||
<x-button type="text" size="xsmall" shape="circle" @click="_closeSwitchVersion($index)">{{$t('Cancel')}}</x-button> |
||||
<x-button type="primary" size="xsmall" shape="circle" @click="_mVersionSwitchProcessDefinitionVersion(item)">{{$t('Confirm')}}</x-button> |
||||
</div> |
||||
<template slot="reference"> |
||||
<x-button |
||||
icon="ans-icon-dependence" |
||||
type="primary" |
||||
shape="circle" |
||||
size="xsmall" |
||||
:disabled="item.version === processDefinition.version" |
||||
data-toggle="tooltip" |
||||
:title="$t('Switch To This Version')"> |
||||
</x-button> |
||||
</template> |
||||
</x-poptip> |
||||
<x-poptip |
||||
:ref="'poptip-delete-' + $index" |
||||
placement="top-end" |
||||
width="90"> |
||||
<p>{{$t('Delete?')}}</p> |
||||
<div style="text-align: right; margin: 0;padding-top: 4px;"> |
||||
<x-button type="text" size="xsmall" shape="circle" @click="_closeDelete($index)">{{$t('Cancel')}}</x-button> |
||||
<x-button type="primary" size="xsmall" shape="circle" @click="_mVersionDeleteProcessDefinitionVersion(item,$index)">{{$t('Confirm')}}</x-button> |
||||
</div> |
||||
<template slot="reference"> |
||||
<x-button |
||||
icon="ans-icon-trash" |
||||
type="error" |
||||
shape="circle" |
||||
size="xsmall" |
||||
:disabled="item.version === processDefinition.version" |
||||
data-toggle="tooltip" |
||||
:title="$t('delete')"> |
||||
</x-button> |
||||
</template> |
||||
</x-poptip> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</div> |
||||
|
||||
<div v-if="processDefinitionVersions.length === 0"> |
||||
<m-no-data><!----></m-no-data> |
||||
</div> |
||||
|
||||
<div v-if="processDefinitionVersions.length > 0"> |
||||
<div class="bottom-box"> |
||||
<x-button type="text" @click="_close()"> {{$t('Cancel')}} </x-button> |
||||
<x-page :current="pageNo" :total="total" @on-change="_mVersionGetProcessDefinitionVersionsPage" small><!----></x-page> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import mNoData from '@/module/components/noData/noData' |
||||
|
||||
export default { |
||||
name: 'versions', |
||||
data () { |
||||
return { |
||||
tableHeaders: [ |
||||
{ |
||||
label: 'version', |
||||
prop: 'version' |
||||
}, |
||||
{ |
||||
label: 'createTime', |
||||
prop: 'createTime' |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
props: { |
||||
processDefinition: Object, |
||||
processDefinitionVersions: Array, |
||||
total: Number, |
||||
pageNo: Number, |
||||
pageSize: Number |
||||
}, |
||||
methods: { |
||||
/** |
||||
* switch version in process definition version list |
||||
*/ |
||||
_mVersionSwitchProcessDefinitionVersion (item) { |
||||
this.$emit('mVersionSwitchProcessDefinitionVersion', { |
||||
version: item.version, |
||||
processDefinitionId: this.processDefinition.id, |
||||
fromThis: this |
||||
}) |
||||
}, |
||||
|
||||
/** |
||||
* delete one version of process definition |
||||
*/ |
||||
_mVersionDeleteProcessDefinitionVersion (item) { |
||||
this.$emit('mVersionDeleteProcessDefinitionVersion', { |
||||
version: item.version, |
||||
processDefinitionId: this.processDefinition.id, |
||||
fromThis: this |
||||
}) |
||||
}, |
||||
|
||||
/** |
||||
* Paging event of process definition versions |
||||
*/ |
||||
_mVersionGetProcessDefinitionVersionsPage (val) { |
||||
this.$emit('mVersionGetProcessDefinitionVersionsPage', { |
||||
pageNo: val, |
||||
pageSize: this.pageSize, |
||||
processDefinitionId: this.processDefinition.id, |
||||
fromThis: this |
||||
}) |
||||
}, |
||||
|
||||
/** |
||||
* Close the switch version layer |
||||
*/ |
||||
_closeSwitchVersion (i) { |
||||
if (i > 0) { |
||||
this.$refs[`poptip-switch-version-${i}`][0].doClose() |
||||
} |
||||
}, |
||||
|
||||
/** |
||||
* Close the delete layer |
||||
*/ |
||||
_closeDelete (i) { |
||||
if (i > 0) { |
||||
this.$refs[`poptip-delete-${i}`][0].doClose() |
||||
} |
||||
}, |
||||
|
||||
/** |
||||
* Close and destroy component and component internal events |
||||
*/ |
||||
_close () { |
||||
// flag Whether to delete a node this.$destroy() |
||||
this.$emit('close', { |
||||
fromThis: this |
||||
}) |
||||
} |
||||
}, |
||||
created () {}, |
||||
mounted () {}, |
||||
components: { mNoData } |
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss" rel="stylesheet/scss"> |
||||
.container { |
||||
width: 500px; |
||||
position: relative; |
||||
.title-box { |
||||
height: 61px; |
||||
border-bottom: 1px solid #DCDEDC; |
||||
position: relative; |
||||
.name { |
||||
position: absolute; |
||||
left: 24px; |
||||
top: 18px; |
||||
font-size: 16px; |
||||
} |
||||
} |
||||
.bottom-box { |
||||
position: absolute; |
||||
bottom: 0; |
||||
left: 0; |
||||
width: 100%; |
||||
text-align: right; |
||||
height: 60px; |
||||
line-height: 60px; |
||||
border-top: 1px solid #DCDEDC; |
||||
background: #fff; |
||||
.ans-page { |
||||
display: inline-block; |
||||
} |
||||
} |
||||
.table-box { |
||||
overflow-y: scroll; |
||||
height: calc(100vh - 61px); |
||||
padding-bottom: 60px; |
||||
} |
||||
} |
||||
</style> |
Loading…
Reference in new issue