Merge pull request #8005 from metersphere/pr@dev@refactor_同步缺陷项目ID未填提示
refactor: 同步缺陷项目ID未填提示
This commit is contained in:
commit
6e5e805de8
|
@ -37,6 +37,7 @@ import javax.net.ssl.SSLContext;
|
|||
import java.io.File;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -135,6 +136,19 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
|
|||
*/
|
||||
public abstract String getProjectId(String projectId);
|
||||
|
||||
public String getProjectId(String projectId, Function<Project, String> getProjectKeyFuc) {
|
||||
Project project;
|
||||
if (StringUtils.isNotBlank(projectId)) {
|
||||
project = projectService.getProjectById(projectId);
|
||||
} else {
|
||||
TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId);
|
||||
project = projectService.getProjectById(testCase.getProjectId());
|
||||
}
|
||||
String projectKey = getProjectKeyFuc.apply(project);
|
||||
if (StringUtils.isBlank(projectKey)) MSException.throwException("请在项目设置配置 " + key + "项目ID");
|
||||
return projectKey;
|
||||
}
|
||||
|
||||
protected boolean isIntegratedPlatform(String workspaceId, String platform) {
|
||||
IntegrationRequest request = new IntegrationRequest();
|
||||
request.setPlatform(platform);
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import io.metersphere.base.domain.IssuesDao;
|
||||
import io.metersphere.base.domain.IssuesWithBLOBs;
|
||||
import io.metersphere.base.domain.Project;
|
||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||
import io.metersphere.commons.constants.IssuesManagePlatform;
|
||||
import io.metersphere.commons.constants.IssuesStatus;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
|
@ -34,19 +33,18 @@ import java.util.UUID;
|
|||
|
||||
public class JiraPlatform extends AbstractIssuePlatform {
|
||||
|
||||
protected String key = IssuesManagePlatform.Jira.toString();
|
||||
|
||||
protected JiraClientV2 jiraClientV2;
|
||||
|
||||
public JiraPlatform(IssuesRequest issuesRequest) {
|
||||
super(issuesRequest);
|
||||
jiraClientV2 = new JiraClientV2();
|
||||
setConfig();
|
||||
this.key = IssuesManagePlatform.Jira.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IssuesDao> getIssue(IssuesRequest issuesRequest) {
|
||||
issuesRequest.setPlatform(IssuesManagePlatform.Jira.toString());
|
||||
issuesRequest.setPlatform(key);
|
||||
List<IssuesDao> issues;
|
||||
if (StringUtils.isNotBlank(issuesRequest.getProjectId())) {
|
||||
issues = extIssuesMapper.getIssues(issuesRequest);
|
||||
|
@ -81,7 +79,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
issue.setLastmodify(assignee == null ? "" : assignee.getString("displayName"));
|
||||
issue.setDescription(description);
|
||||
issue.setPlatformStatus(status);
|
||||
issue.setPlatform(IssuesManagePlatform.Jira.toString());
|
||||
issue.setPlatform(key);
|
||||
issue.setCustomFields(syncIssueCustomField(issue.getCustomFields(), jiraIssue.getFields()));
|
||||
return issue;
|
||||
}
|
||||
|
@ -112,7 +110,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
DemandDTO demandDTO = new DemandDTO();
|
||||
demandDTO.setName(summary);
|
||||
demandDTO.setId(issueKey);
|
||||
demandDTO.setPlatform(IssuesManagePlatform.Jira.name());
|
||||
demandDTO.setPlatform(key);
|
||||
list.add(demandDTO);
|
||||
}
|
||||
startAt += maxResults;
|
||||
|
@ -170,7 +168,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
|
||||
private JSONObject buildUpdateParam(IssuesUpdateRequest issuesRequest, String issuetypeStr) {
|
||||
|
||||
issuesRequest.setPlatform(IssuesManagePlatform.Jira.toString());
|
||||
issuesRequest.setPlatform(key);
|
||||
|
||||
String jiraKey = validateJiraKey(issuesRequest.getProjectId());
|
||||
|
||||
|
@ -288,16 +286,11 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
|
||||
@Override
|
||||
public String getProjectId(String projectId) {
|
||||
if (StringUtils.isNotBlank(projectId)) {
|
||||
return projectService.getProjectById(projectId).getJiraKey();
|
||||
}
|
||||
TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId);
|
||||
Project project = projectService.getProjectById(testCase.getProjectId());
|
||||
return project.getJiraKey();
|
||||
return getProjectId(projectId, Project::getJiraKey);
|
||||
}
|
||||
|
||||
public JiraConfig getConfig() {
|
||||
return getConfig(IssuesManagePlatform.Jira.toString(), JiraConfig.class);
|
||||
return getConfig(key, JiraConfig.class);
|
||||
}
|
||||
|
||||
public JiraConfig setConfig() {
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import io.metersphere.base.domain.IssuesDao;
|
||||
import io.metersphere.base.domain.IssuesWithBLOBs;
|
||||
import io.metersphere.base.domain.Project;
|
||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||
import io.metersphere.commons.constants.IssuesManagePlatform;
|
||||
import io.metersphere.commons.constants.IssuesStatus;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
|
@ -35,19 +34,18 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class TapdPlatform extends AbstractIssuePlatform {
|
||||
|
||||
protected String key = IssuesManagePlatform.Tapd.toString();
|
||||
|
||||
protected TapdClient tapdClient;
|
||||
|
||||
public TapdPlatform(IssuesRequest issueRequest) {
|
||||
super(issueRequest);
|
||||
tapdClient = new TapdClient();
|
||||
setConfig();
|
||||
this.key = IssuesManagePlatform.Tapd.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IssuesDao> getIssue(IssuesRequest issuesRequest) {
|
||||
issuesRequest.setPlatform(IssuesManagePlatform.Tapd.toString());
|
||||
issuesRequest.setPlatform(key);
|
||||
List<IssuesDao> issues;
|
||||
if (StringUtils.isNotBlank(issuesRequest.getProjectId())) {
|
||||
issues = extIssuesMapper.getIssues(issuesRequest);
|
||||
|
@ -64,7 +62,7 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
|||
for (int i = 0; i < demands.size(); i++) {
|
||||
JSONObject o = demands.getJSONObject(i);
|
||||
DemandDTO demand = o.getObject("Story", DemandDTO.class);
|
||||
demand.setPlatform(IssuesManagePlatform.Tapd.name());
|
||||
demand.setPlatform(key);
|
||||
demandList.add(demand);
|
||||
}
|
||||
return demandList;
|
||||
|
@ -99,7 +97,7 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
|
||||
private MultiValueMap<String, Object> buildUpdateParam(IssuesUpdateRequest issuesRequest) {
|
||||
issuesRequest.setPlatform(IssuesManagePlatform.Tapd.toString());
|
||||
issuesRequest.setPlatform(key);
|
||||
|
||||
String tapdId = getProjectId(issuesRequest.getProjectId());
|
||||
|
||||
|
@ -228,16 +226,11 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
|||
|
||||
@Override
|
||||
public String getProjectId(String projectId) {
|
||||
if (StringUtils.isNotBlank(projectId)) {
|
||||
return projectService.getProjectById(projectId).getTapdId();
|
||||
}
|
||||
TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId);
|
||||
Project project = projectService.getProjectById(testCase.getProjectId());
|
||||
return project.getTapdId();
|
||||
return getProjectId(projectId, Project::getTapdId);
|
||||
}
|
||||
|
||||
public TapdConfig getConfig() {
|
||||
return getConfig(IssuesManagePlatform.Tapd.toString(), TapdConfig.class);
|
||||
return getConfig(key, TapdConfig.class);
|
||||
}
|
||||
|
||||
public TapdConfig setConfig() {
|
||||
|
|
|
@ -37,29 +37,23 @@ import java.util.regex.Pattern;
|
|||
public class ZentaoPlatform extends AbstractIssuePlatform {
|
||||
protected final ZentaoClient zentaoClient;
|
||||
|
||||
protected String key = IssuesManagePlatform.Zentao.toString();
|
||||
|
||||
public ZentaoPlatform(IssuesRequest issuesRequest) {
|
||||
super(issuesRequest);
|
||||
ZentaoConfig zentaoConfig = getConfig();
|
||||
this.workspaceId = issuesRequest.getWorkspaceId();
|
||||
this.zentaoClient = ZentaoFactory.getInstance(zentaoConfig.getUrl(), zentaoConfig.getRequest());
|
||||
this.zentaoClient.setConfig(zentaoConfig);
|
||||
this.key = IssuesManagePlatform.Zentao.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectId(String projectId) {
|
||||
if (StringUtils.isNotBlank(projectId)) {
|
||||
return projectService.getProjectById(projectId).getZentaoId();
|
||||
}
|
||||
TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId);
|
||||
Project project = projectService.getProjectById(testCase.getProjectId());
|
||||
return project.getZentaoId();
|
||||
return getProjectId(projectId, Project::getZentaoId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IssuesDao> getIssue(IssuesRequest issuesRequest) {
|
||||
issuesRequest.setPlatform(IssuesManagePlatform.Zentao.toString());
|
||||
issuesRequest.setPlatform(key);
|
||||
List<IssuesDao> issues;
|
||||
if (StringUtils.isNotBlank(issuesRequest.getProjectId())) {
|
||||
issues = extIssuesMapper.getIssues(issuesRequest);
|
||||
|
@ -99,7 +93,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
DemandDTO demandDTO = new DemandDTO();
|
||||
demandDTO.setId(o.getString("id"));
|
||||
demandDTO.setName(o.getString("title"));
|
||||
demandDTO.setPlatform(IssuesManagePlatform.Zentao.name());
|
||||
demandDTO.setPlatform(key);
|
||||
list.add(demandDTO);
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +108,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
DemandDTO demandDTO = new DemandDTO();
|
||||
demandDTO.setId(jsonObject.getString("id"));
|
||||
demandDTO.setName(jsonObject.getString("title"));
|
||||
demandDTO.setPlatform(IssuesManagePlatform.Zentao.name());
|
||||
demandDTO.setPlatform(key);
|
||||
list.add(demandDTO);
|
||||
});
|
||||
}
|
||||
|
@ -170,7 +164,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
|
||||
IssuesExample issuesExample = new IssuesExample();
|
||||
issuesExample.createCriteria().andIdEqualTo(id)
|
||||
.andPlatformEqualTo(IssuesManagePlatform.Zentao.toString());
|
||||
.andPlatformEqualTo(key);
|
||||
if (issuesMapper.selectByExample(issuesExample).size() <= 0) {
|
||||
// 插入缺陷表
|
||||
issues = insertIssues(issuesRequest);
|
||||
|
@ -191,7 +185,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
|
||||
private MultiValueMap<String, Object> buildUpdateParam(IssuesUpdateRequest issuesRequest) {
|
||||
issuesRequest.setPlatform(IssuesManagePlatform.Zentao.toString());
|
||||
issuesRequest.setPlatform(key);
|
||||
String projectId = getProjectId(issuesRequest.getProjectId());
|
||||
if (StringUtils.isBlank(projectId)) {
|
||||
MSException.throwException("未关联禅道项目ID.");
|
||||
|
@ -246,7 +240,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
|
||||
public ZentaoConfig getConfig() {
|
||||
return getConfig(IssuesManagePlatform.Zentao.toString(), ZentaoConfig.class);
|
||||
return getConfig(key, ZentaoConfig.class);
|
||||
}
|
||||
|
||||
public ZentaoConfig setConfig() {
|
||||
|
|
|
@ -34,13 +34,6 @@
|
|||
ref="table"
|
||||
>
|
||||
<span v-for="(item) in fields" :key="item.key">
|
||||
<!-- <ms-table-column
|
||||
:label="$t('test_track.issue.id')"
|
||||
prop="id"
|
||||
:field="item"
|
||||
:fields-width="fieldsWidth"
|
||||
v-if="false">
|
||||
</ms-table-column>-->
|
||||
<ms-table-column width="1">
|
||||
</ms-table-column>
|
||||
<ms-table-column
|
||||
|
@ -179,7 +172,7 @@ import {getIssues, syncIssues} from "@/network/Issue";
|
|||
import {
|
||||
getCustomFieldValue,
|
||||
getCustomTableWidth,
|
||||
getPageInfo, getTableHeaderWithCustomFields,saveLastTableSortField,getLastTableSortField
|
||||
getPageInfo, getTableHeaderWithCustomFields, getLastTableSortField
|
||||
} from "@/common/js/tableUtils";
|
||||
import MsContainer from "@/business/components/common/components/MsContainer";
|
||||
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
|
||||
|
@ -253,7 +246,7 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
this.$refs.table.reloadTable();
|
||||
if (this.$refs.table) this.$refs.table.reloadTable();
|
||||
});
|
||||
this.getIssues();
|
||||
},
|
||||
|
@ -278,7 +271,7 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
tableDoLayout() {
|
||||
this.$refs.table.doLayout();
|
||||
if (this.$refs.table) this.$refs.table.doLayout();
|
||||
},
|
||||
getCustomFieldValue(row, field) {
|
||||
return getCustomFieldValue(row, field, this.members);
|
||||
|
|
Loading…
Reference in New Issue