refactor(测试跟踪): 缺陷xpack相关改造
This commit is contained in:
parent
89e3fa61aa
commit
e4fede9b8e
|
@ -119,6 +119,10 @@ public class DateUtils {
|
|||
return dateSum(now, countDays).getTime() / 1000 * 1000;
|
||||
}
|
||||
|
||||
public static Long getTimestamp(String dateString) throws Exception {
|
||||
return getDate(dateString).getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当天的起始时间Date
|
||||
*
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package io.metersphere.xpack.track.controller;
|
||||
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.xpack.track.service.XpackIssueService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/xpack/issue")
|
||||
public class XpackIssueController {
|
||||
|
||||
@GetMapping("/sync/{projectId}")
|
||||
public boolean getPlatformIssue(@PathVariable String projectId) {
|
||||
XpackIssueService xpackIssueService = CommonBeanFactory.getBean(XpackIssueService.class);
|
||||
return xpackIssueService.syncThirdPartyIssues(projectId);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.constants;
|
||||
package io.metersphere.xpack.track.dto;
|
||||
|
||||
/**
|
||||
* @author songcc
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.service.issue.domain.azure;
|
||||
package io.metersphere.xpack.track.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -16,7 +16,7 @@ public class AzureDevopsWorkItemsBatchResponse {
|
|||
|
||||
@Getter
|
||||
@Setter
|
||||
public class Value {
|
||||
public static class Value {
|
||||
private int id;
|
||||
private int rev;
|
||||
private Map fields;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.dto;
|
||||
package io.metersphere.xpack.track.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.request.testcase;
|
||||
package io.metersphere.xpack.track.dto;
|
||||
import io.metersphere.base.domain.FileMetadata;
|
||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||
import io.metersphere.dto.CustomFieldResourceDTO;
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.dto;
|
||||
package io.metersphere.xpack.track.dto;
|
||||
|
||||
import io.metersphere.base.domain.IssueTemplate;
|
||||
import io.metersphere.dto.CustomFieldDao;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
|
@ -1,6 +1,8 @@
|
|||
package io.metersphere.dto;
|
||||
package io.metersphere.xpack.track.dto;
|
||||
|
||||
import io.metersphere.base.domain.IssuesWithBLOBs;
|
||||
import io.metersphere.dto.CustomFieldDao;
|
||||
import io.metersphere.dto.CustomFieldItemDTO;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.service.issue.domain.jira;
|
||||
package io.metersphere.xpack.track.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.service.issue.domain.jira;
|
||||
package io.metersphere.xpack.track.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.dto;
|
||||
package io.metersphere.xpack.track.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.service.issue.domain;
|
||||
package io.metersphere.xpack.track.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package io.metersphere.xpack.track.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class TapdBaseResponse {
|
||||
private int status;
|
||||
private String info;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.service.issue.domain.tapd;
|
||||
package io.metersphere.xpack.track.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -8,9 +8,6 @@ import java.util.Map;
|
|||
|
||||
@Getter
|
||||
@Setter
|
||||
public class TapdGetIssueResponse {
|
||||
|
||||
private int status;
|
||||
public class TapdGetIssueResponse extends TapdBaseResponse {
|
||||
private List<Map> data;
|
||||
private String info;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package io.metersphere.request.testcase;
|
||||
package io.metersphere.xpack.track.dto.request;
|
||||
|
||||
import io.metersphere.request.BaseQueryRequest;
|
||||
import lombok.Getter;
|
|
@ -1,11 +1,11 @@
|
|||
package io.metersphere.request.testcase;
|
||||
package io.metersphere.xpack.track.dto.request;
|
||||
|
||||
import io.metersphere.base.domain.FileMetadata;
|
||||
import io.metersphere.base.domain.IssuesWithBLOBs;
|
||||
import io.metersphere.dto.CustomFieldItemDTO;
|
||||
import io.metersphere.dto.CustomFieldResourceDTO;
|
||||
|
||||
import io.metersphere.dto.PlatformStatusDTO;
|
||||
import io.metersphere.xpack.track.dto.PlatformStatusDTO;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
|
@ -1,16 +1,11 @@
|
|||
package io.metersphere.service.issue;
|
||||
package io.metersphere.xpack.track.issue;
|
||||
|
||||
import io.metersphere.base.domain.IssuesWithBLOBs;
|
||||
import io.metersphere.base.domain.Project;
|
||||
import io.metersphere.constants.AttachmentSyncType;
|
||||
import io.metersphere.dto.IssueTemplateDao;
|
||||
import io.metersphere.dto.IssuesDao;
|
||||
import io.metersphere.dto.UserDTO;
|
||||
import io.metersphere.dto.DemandDTO;
|
||||
import io.metersphere.service.issue.domain.PlatformUser;
|
||||
import io.metersphere.request.testcase.EditTestCaseRequest;
|
||||
import io.metersphere.request.testcase.IssuesRequest;
|
||||
import io.metersphere.request.testcase.IssuesUpdateRequest;
|
||||
import io.metersphere.xpack.track.dto.*;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -123,4 +118,12 @@ public interface IssuesPlatform {
|
|||
* @param syncType 同步操作类型: UPLOAD, DELETE
|
||||
*/
|
||||
void syncIssuesAttachment(IssuesUpdateRequest issuesRequest, File file, AttachmentSyncType syncType);
|
||||
|
||||
|
||||
/**
|
||||
* 获取第三方平台的状态集合
|
||||
* @param issueKey
|
||||
* @return
|
||||
*/
|
||||
List<PlatformStatusDTO> getTransitions(String issueKey);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package io.metersphere.xpack.track.service;
|
||||
|
||||
public interface XpackIssueService {
|
||||
|
||||
boolean syncThirdPartyIssues(String projectId);
|
||||
}
|
|
@ -33,7 +33,7 @@
|
|||
from custom_field_template cft
|
||||
inner join custom_field cf
|
||||
on cft.field_id = cf.id
|
||||
<if test="request.templateId != null">
|
||||
<if test="templateId != null">
|
||||
where cft.template_id = #{templateId}
|
||||
</if>
|
||||
</select>
|
||||
|
|
|
@ -5,7 +5,8 @@ import io.metersphere.dto.*;
|
|||
|
||||
import io.metersphere.plan.dto.PlanReportIssueDTO;
|
||||
import io.metersphere.request.testcase.IssuesCountRequest;
|
||||
import io.metersphere.request.testcase.IssuesRequest;
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesRequest;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
and (resource_id = #{resourceId} or ref_id = #{resourceId})
|
||||
</delete>
|
||||
|
||||
<select id="getIssuesByCaseId" resultType="io.metersphere.dto.IssuesDao">
|
||||
<select id="getIssuesByCaseId" resultType="io.metersphere.xpack.track.dto.IssuesDao">
|
||||
select issues.*
|
||||
from issues
|
||||
inner join test_case_issues
|
||||
|
@ -17,7 +17,7 @@
|
|||
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
|
||||
</select>
|
||||
|
||||
<select id="getIssueForMinder" resultType="io.metersphere.dto.IssuesDao">
|
||||
<select id="getIssueForMinder" resultType="io.metersphere.xpack.track.dto.IssuesDao">
|
||||
select issues.id, issues.title , issues.num , test_case_issues.resource_id, test_case_issues.ref_id, test_case_issues.ref_type
|
||||
from issues
|
||||
inner join test_case_issues
|
||||
|
@ -49,7 +49,7 @@
|
|||
issues.lastmodify
|
||||
</sql>
|
||||
|
||||
<select id="getIssues" resultType="io.metersphere.dto.IssuesDao">
|
||||
<select id="getIssues" resultType="io.metersphere.xpack.track.dto.IssuesDao">
|
||||
select
|
||||
<include refid="Issue_List_Column"/>
|
||||
<if test="request.projectId != null||request.workspaceId != null">
|
||||
|
@ -67,7 +67,7 @@
|
|||
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
|
||||
</select>
|
||||
|
||||
<select id="getPlanIssues" resultType="io.metersphere.dto.IssuesDao">
|
||||
<select id="getPlanIssues" resultType="io.metersphere.xpack.track.dto.IssuesDao">
|
||||
select
|
||||
<include refid="Issue_List_Column"/>
|
||||
from issues
|
||||
|
@ -100,7 +100,7 @@
|
|||
where i.creator = #{request.creator}
|
||||
group by statusValue;
|
||||
</select>
|
||||
<select id="getRelateIssues" resultType="io.metersphere.dto.IssuesDao">
|
||||
<select id="getRelateIssues" resultType="io.metersphere.xpack.track.dto.IssuesDao">
|
||||
select issues.id, issues.num, issues.title, issues.project_id, issues.create_time, issues.update_time,
|
||||
issues.description, issues.status, issues.platform, issues.custom_fields,test_case_issues.resource_id,issues.platform_status,
|
||||
issues.lastmodify
|
||||
|
@ -111,7 +111,7 @@
|
|||
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
|
||||
group by issues.id
|
||||
</select>
|
||||
<select id="getIssueForSync" resultType="io.metersphere.dto.IssuesDao">
|
||||
<select id="getIssueForSync" resultType="io.metersphere.xpack.track.dto.IssuesDao">
|
||||
select id,platform, platform_id
|
||||
from issues
|
||||
where project_id = #{projectId} and platform = #{platform} and (platform_status != 'delete' or platform_status is null);
|
||||
|
@ -132,7 +132,7 @@
|
|||
where project_id = #{projectId}
|
||||
limit #{offset},#{pageSize}
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultType="io.metersphere.dto.IssuesDao">
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultType="io.metersphere.xpack.track.dto.IssuesDao">
|
||||
select
|
||||
<include refid="Issue_List_Column" />
|
||||
from issues
|
||||
|
@ -150,13 +150,13 @@
|
|||
join custom_field cf on cf.id = cfi.field_id
|
||||
where cfi.resource_id = #{issueId}
|
||||
</select>
|
||||
<select id="getPlatformIssueByIds" resultType="io.metersphere.dto.IssuesDao">
|
||||
<select id="getPlatformIssueByIds" resultType="io.metersphere.xpack.track.dto.IssuesDao">
|
||||
select * from issues where project_id = #{projectId} and platform_id in
|
||||
<foreach collection="ids" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getIssueCustomFields" resultType="io.metersphere.dto.IssuesDao">
|
||||
<select id="getIssueCustomFields" resultType="io.metersphere.xpack.track.dto.IssuesDao">
|
||||
select cfi.field_id as fieldId,
|
||||
cf.type fieldType,
|
||||
cft.custom_data,
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.github.pagehelper.Page;
|
|||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.base.domain.Issues;
|
||||
import io.metersphere.base.domain.IssuesWithBLOBs;
|
||||
import io.metersphere.base.domain.Project;
|
||||
import io.metersphere.commons.constants.NoticeConstants;
|
||||
import io.metersphere.commons.constants.OperLogConstants;
|
||||
import io.metersphere.commons.constants.OperLogModule;
|
||||
|
@ -14,7 +13,7 @@ import io.metersphere.commons.utils.Pager;
|
|||
import io.metersphere.dto.*;
|
||||
import io.metersphere.log.annotation.MsAuditLog;
|
||||
import io.metersphere.notice.annotation.SendNotice;
|
||||
import io.metersphere.service.issue.domain.PlatformUser;
|
||||
import io.metersphere.xpack.track.dto.*;
|
||||
import io.metersphere.service.issue.domain.jira.JiraIssueType;
|
||||
import io.metersphere.service.issue.domain.zentao.ZentaoBuild;
|
||||
|
||||
|
@ -22,8 +21,8 @@ import io.metersphere.request.issues.JiraIssueTypeRequest;
|
|||
import io.metersphere.request.issues.PlatformIssueTypeRequest;
|
||||
import io.metersphere.request.testcase.AuthUserIssueRequest;
|
||||
import io.metersphere.request.testcase.IssuesCountRequest;
|
||||
import io.metersphere.request.testcase.IssuesRequest;
|
||||
import io.metersphere.request.testcase.IssuesUpdateRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest;
|
||||
import io.metersphere.service.IssuesService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -185,9 +184,4 @@ public class IssuesController {
|
|||
public List<PlatformStatusDTO> getPlatformTransitions(@RequestBody PlatformIssueTypeRequest request) {
|
||||
return issuesService.getPlatformTransitions(request);
|
||||
}
|
||||
|
||||
@PostMapping("/check/third/project")
|
||||
public void checkThirdProjectExist(@RequestBody Project project) {
|
||||
issuesService.checkThirdProjectExist(project);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package io.metersphere.controller;
|
||||
|
||||
import io.metersphere.dto.IssuesDao;
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import io.metersphere.dto.TestPlanCaseDTO;
|
||||
import io.metersphere.plan.dto.TestPlanSimpleReportDTO;
|
||||
import io.metersphere.plan.service.TestPlanReportService;
|
||||
|
|
|
@ -24,6 +24,7 @@ import io.metersphere.service.BaseCheckPermissionService;
|
|||
import io.metersphere.service.FileService;
|
||||
import io.metersphere.service.TestCaseService;
|
||||
import io.metersphere.service.wapper.CheckPermissionService;
|
||||
import io.metersphere.xpack.track.dto.EditTestCaseRequest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.dto;
|
||||
|
||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.dto;
|
||||
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.dto;
|
||||
|
||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package io.metersphere.plan.dto;
|
|||
|
||||
import io.metersphere.base.domain.TestPlanReportContent;
|
||||
import io.metersphere.dto.*;
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import io.metersphere.plan.utils.TestPlanRequestUtil;
|
|||
import io.metersphere.plan.utils.TestPlanStatusCalculator;
|
||||
import io.metersphere.request.report.QueryTestPlanReportRequest;
|
||||
import io.metersphere.service.ServiceUtils;
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
|
@ -41,6 +41,7 @@ import io.metersphere.plan.utils.TestPlanRequestUtil;
|
|||
import io.metersphere.request.ScheduleRequest;
|
||||
import io.metersphere.service.*;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
|
@ -42,6 +42,7 @@ import io.metersphere.service.ServiceUtils;
|
|||
import io.metersphere.dto.*;
|
||||
import io.metersphere.request.testcase.TrackCount;
|
||||
import io.metersphere.request.testreview.SaveCommentRequest;
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
|
@ -8,14 +8,14 @@ import io.metersphere.commons.exception.MSException;
|
|||
import io.metersphere.commons.utils.BeanUtils;
|
||||
import io.metersphere.commons.utils.FileUtils;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.constants.AttachmentSyncType;
|
||||
import io.metersphere.xpack.track.dto.AttachmentSyncType;
|
||||
import io.metersphere.constants.AttachmentType;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.metadata.service.FileMetadataService;
|
||||
import io.metersphere.metadata.utils.MetadataUtils;
|
||||
import io.metersphere.request.attachment.AttachmentRequest;
|
||||
import io.metersphere.request.testcase.IssuesRequest;
|
||||
import io.metersphere.request.testcase.IssuesUpdateRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest;
|
||||
import io.metersphere.service.issue.platform.IssueFactory;
|
||||
import io.metersphere.xmind.utils.FileUtil;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
|
|
@ -43,10 +43,6 @@ public class CustomFieldIssuesService extends CustomFieldResourceService {
|
|||
super.batchEditFields(TABLE_NAME, resourceId, fields);
|
||||
}
|
||||
|
||||
// public void batchEditFields(HashMap<String, List<CustomFieldResourceDTO>> customFieldMap) {
|
||||
// super.batchEditFields(TABLE_NAME, customFieldMap);
|
||||
// }
|
||||
|
||||
public int updateByPrimaryKeySelective(CustomFieldResourceDTO field) {
|
||||
return super.updateByPrimaryKeySelective(TABLE_NAME, field);
|
||||
}
|
||||
|
@ -71,7 +67,7 @@ public class CustomFieldIssuesService extends CustomFieldResourceService {
|
|||
return super.getByResourceId(TABLE_NAME, resourceId);
|
||||
}
|
||||
|
||||
public void batchEditFields(HashMap<String, List<CustomFieldResourceDTO>> customFieldMap) {
|
||||
public void batchEditFields(Map<String, List<CustomFieldResourceDTO>> customFieldMap) {
|
||||
if (customFieldMap == null || customFieldMap.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package io.metersphere.service;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.*;
|
||||
import io.metersphere.base.mapper.ext.ExtIssuesMapper;
|
||||
|
@ -9,11 +11,12 @@ import io.metersphere.commons.constants.IssuesManagePlatform;
|
|||
import io.metersphere.commons.constants.IssuesStatus;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.*;
|
||||
import io.metersphere.constants.AttachmentSyncType;
|
||||
import io.metersphere.plan.service.TestPlanTestCaseService;
|
||||
import io.metersphere.xpack.track.dto.AttachmentSyncType;
|
||||
import io.metersphere.constants.AttachmentType;
|
||||
import io.metersphere.constants.SystemCustomField;
|
||||
import io.metersphere.dto.CustomFieldDao;
|
||||
import io.metersphere.dto.IssueTemplateDao;
|
||||
import io.metersphere.xpack.track.dto.IssueTemplateDao;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.log.utils.ReflexObjectUtil;
|
||||
import io.metersphere.log.vo.DetailColumn;
|
||||
|
@ -30,19 +33,21 @@ import io.metersphere.request.issues.JiraIssueTypeRequest;
|
|||
import io.metersphere.request.issues.PlatformIssueTypeRequest;
|
||||
import io.metersphere.request.testcase.AuthUserIssueRequest;
|
||||
import io.metersphere.request.testcase.IssuesCountRequest;
|
||||
import io.metersphere.service.issue.domain.PlatformUser;
|
||||
import io.metersphere.xpack.track.dto.PlatformUser;
|
||||
import io.metersphere.service.issue.domain.jira.JiraIssueType;
|
||||
import io.metersphere.service.issue.domain.zentao.ZentaoBuild;
|
||||
import io.metersphere.request.attachment.AttachmentRequest;
|
||||
import io.metersphere.request.testcase.IssuesRequest;
|
||||
import io.metersphere.request.testcase.IssuesUpdateRequest;
|
||||
import io.metersphere.xpack.track.dto.DemandDTO;
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest;
|
||||
import io.metersphere.service.issue.platform.*;
|
||||
import io.metersphere.service.remote.project.TrackCustomFieldTemplateService;
|
||||
import io.metersphere.service.remote.project.TrackIssueTemplateService;
|
||||
import io.metersphere.service.remote.setting.IntegrationService;
|
||||
import io.metersphere.service.wapper.TrackProjectService;
|
||||
import io.metersphere.xpack.track.dto.PlatformStatusDTO;
|
||||
import io.metersphere.xpack.track.issue.IssuesPlatform;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
|
@ -66,7 +71,7 @@ import java.util.stream.Collectors;
|
|||
public class IssuesService {
|
||||
|
||||
@Resource
|
||||
private IntegrationService integrationService;
|
||||
private BaseIntegrationService baseIntegrationService;
|
||||
@Resource
|
||||
private TrackProjectService trackProjectService;
|
||||
@Resource
|
||||
|
@ -90,12 +95,13 @@ public class IssuesService {
|
|||
private TrackIssueTemplateService trackIssueTemplateService;
|
||||
@Resource
|
||||
private TestCaseIssueService testCaseIssueService;
|
||||
// @Resource
|
||||
// private TestPlanTestCaseService testPlanTestCaseService;
|
||||
@Lazy
|
||||
@Resource
|
||||
private TestPlanTestCaseService testPlanTestCaseService;
|
||||
@Resource
|
||||
private IssueFollowMapper issueFollowMapper;
|
||||
// @Resource
|
||||
// private TestPlanTestCaseMapper testPlanTestCaseMapper;
|
||||
@Resource
|
||||
private TestPlanTestCaseMapper testPlanTestCaseMapper;
|
||||
@Resource
|
||||
private CustomFieldIssuesService customFieldIssuesService;
|
||||
@Resource
|
||||
|
@ -118,15 +124,15 @@ public class IssuesService {
|
|||
public void testAuth(String workspaceId, String platform) {
|
||||
IssuesRequest issuesRequest = new IssuesRequest();
|
||||
issuesRequest.setWorkspaceId(workspaceId);
|
||||
AbstractIssuePlatform abstractPlatform = IssueFactory.createPlatform(platform, issuesRequest);
|
||||
IssuesPlatform abstractPlatform = IssueFactory.createPlatform(platform, issuesRequest);
|
||||
abstractPlatform.testAuth();
|
||||
}
|
||||
|
||||
|
||||
public IssuesWithBLOBs addIssues(IssuesUpdateRequest issuesRequest, List<MultipartFile> files) {
|
||||
List<AbstractIssuePlatform> platformList = getAddPlatforms(issuesRequest);
|
||||
List<IssuesPlatform> platformList = getAddPlatforms(issuesRequest);
|
||||
IssuesWithBLOBs issues = null;
|
||||
for (AbstractIssuePlatform platform : platformList) {
|
||||
for (IssuesPlatform platform : platformList) {
|
||||
issues = platform.addIssue(issuesRequest);
|
||||
}
|
||||
if (issuesRequest.getIsPlanEdit()) {
|
||||
|
@ -203,7 +209,7 @@ public class IssuesService {
|
|||
}
|
||||
|
||||
public IssuesWithBLOBs updateIssues(IssuesUpdateRequest issuesRequest) {
|
||||
List<AbstractIssuePlatform> platformList = getUpdatePlatforms(issuesRequest);
|
||||
List<IssuesPlatform> platformList = getUpdatePlatforms(issuesRequest);
|
||||
platformList.forEach(platform -> {
|
||||
platform.updateIssue(issuesRequest);
|
||||
});
|
||||
|
@ -227,7 +233,7 @@ public class IssuesService {
|
|||
}
|
||||
}
|
||||
|
||||
public List<AbstractIssuePlatform> getAddPlatforms(IssuesUpdateRequest updateRequest) {
|
||||
public List<IssuesPlatform> getAddPlatforms(IssuesUpdateRequest updateRequest) {
|
||||
List<String> platforms = new ArrayList<>();
|
||||
// 缺陷管理关联
|
||||
platforms.add(getPlatform(updateRequest.getProjectId()));
|
||||
|
@ -240,7 +246,7 @@ public class IssuesService {
|
|||
return IssueFactory.createPlatforms(platforms, issuesRequest);
|
||||
}
|
||||
|
||||
public List<AbstractIssuePlatform> getUpdatePlatforms(IssuesUpdateRequest updateRequest) {
|
||||
public List<IssuesPlatform> getUpdatePlatforms(IssuesUpdateRequest updateRequest) {
|
||||
String id = updateRequest.getId();
|
||||
IssuesWithBLOBs issuesWithBLOBs = issuesMapper.selectByPrimaryKey(id);
|
||||
String platform = issuesWithBLOBs.getPlatform();
|
||||
|
@ -338,7 +344,7 @@ public class IssuesService {
|
|||
IntegrationRequest request = new IntegrationRequest();
|
||||
request.setPlatform(platform);
|
||||
request.setWorkspaceId(workspaceId);
|
||||
ServiceIntegration integration = integrationService.get(request);
|
||||
ServiceIntegration integration = baseIntegrationService.get(request);
|
||||
return StringUtils.isNotBlank(integration.getId());
|
||||
}
|
||||
|
||||
|
@ -350,12 +356,12 @@ public class IssuesService {
|
|||
}
|
||||
|
||||
public List<PlatformUser> getTapdProjectUsers(IssuesRequest request) {
|
||||
AbstractIssuePlatform platform = IssueFactory.createPlatform(IssuesManagePlatform.Tapd.name(), request);
|
||||
IssuesPlatform platform = IssueFactory.createPlatform(IssuesManagePlatform.Tapd.name(), request);
|
||||
return platform.getPlatformUser();
|
||||
}
|
||||
|
||||
public List<PlatformUser> getZentaoUsers(IssuesRequest request) {
|
||||
AbstractIssuePlatform platform = IssueFactory.createPlatform(IssuesManagePlatform.Zentao.name(), request);
|
||||
IssuesPlatform platform = IssueFactory.createPlatform(IssuesManagePlatform.Zentao.name(), request);
|
||||
return platform.getPlatformUser();
|
||||
}
|
||||
|
||||
|
@ -387,7 +393,7 @@ public class IssuesService {
|
|||
updateRequest.setResourceId(request.getCaseResourceId());
|
||||
updateRequest.setProjectId(request.getProjectId());
|
||||
updateRequest.setWorkspaceId(request.getWorkspaceId());
|
||||
List<AbstractIssuePlatform> platformList = getUpdatePlatforms(updateRequest);
|
||||
List<IssuesPlatform> platformList = getUpdatePlatforms(updateRequest);
|
||||
platformList.forEach(platform -> {
|
||||
platform.removeIssueParentLink(updateRequest);
|
||||
});
|
||||
|
@ -395,10 +401,10 @@ public class IssuesService {
|
|||
extIssuesMapper.deleteIssues(id, caseResourceId);
|
||||
TestPlanTestCaseExample testPlanTestCaseExample = new TestPlanTestCaseExample();
|
||||
testPlanTestCaseExample.createCriteria().andCaseIdEqualTo(caseResourceId);
|
||||
// List<TestPlanTestCase> list = testPlanTestCaseMapper.selectByExample(testPlanTestCaseExample);
|
||||
// list.forEach(item -> {
|
||||
// testCaseIssueService.updateIssuesCount(item.getId());
|
||||
// });
|
||||
List<TestPlanTestCase> list = testPlanTestCaseMapper.selectByExample(testPlanTestCaseExample);
|
||||
list.forEach(item -> {
|
||||
testCaseIssueService.updateIssuesCount(item.getId());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,7 +416,7 @@ public class IssuesService {
|
|||
Project project = baseProjectService.getProjectById(projectId);
|
||||
IssuesRequest issuesRequest = new IssuesRequest();
|
||||
issuesRequest.setWorkspaceId(project.getWorkspaceId());
|
||||
AbstractIssuePlatform platform = IssueFactory.createPlatform(issuesWithBLOBs.getPlatform(), issuesRequest);
|
||||
IssuesPlatform platform = IssueFactory.createPlatform(issuesWithBLOBs.getPlatform(), issuesRequest);
|
||||
platform.deleteIssue(id);
|
||||
// 删除缺陷对应的附件
|
||||
AttachmentRequest request = new AttachmentRequest();
|
||||
|
@ -570,7 +576,7 @@ public class IssuesService {
|
|||
return issueMap;
|
||||
}
|
||||
|
||||
public Map<String, AbstractIssuePlatform> getPlatformMap(IssuesRequest request) {
|
||||
public Map<String, IssuesPlatform> getPlatformMap(IssuesRequest request) {
|
||||
Project project = baseProjectService.getProjectById(request.getProjectId());
|
||||
List<String> platforms = getPlatforms(project);
|
||||
platforms.add(IssuesManagePlatform.Local.toString());
|
||||
|
@ -589,18 +595,18 @@ public class IssuesService {
|
|||
}
|
||||
|
||||
public void issuesCount() {
|
||||
// LogUtil.info("测试计划-测试用例同步缺陷信息开始");
|
||||
// int pageSize = 100;
|
||||
// int pages = 1;
|
||||
// for (int i = 0; i < pages; i++) {
|
||||
// Page<List<TestPlanTestCase>> page = PageHelper.startPage(i, pageSize, true);
|
||||
// List<TestPlanTestCaseWithBLOBs> list = testPlanTestCaseService.listAll();
|
||||
// pages = page.getPages();// 替换成真实的值
|
||||
// list.forEach(l -> {
|
||||
// testCaseIssueService.updateIssuesCount(l.getCaseId());
|
||||
// });
|
||||
// }
|
||||
// LogUtil.info("测试计划-测试用例同步缺陷信息结束");
|
||||
LogUtil.info("测试计划-测试用例同步缺陷信息开始");
|
||||
int pageSize = 100;
|
||||
int pages = 1;
|
||||
for (int i = 0; i < pages; i++) {
|
||||
Page<List<TestPlanTestCase>> page = PageHelper.startPage(i, pageSize, true);
|
||||
List<TestPlanTestCaseWithBLOBs> list = testPlanTestCaseService.listAll();
|
||||
pages = page.getPages();// 替换成真实的值
|
||||
list.forEach(l -> {
|
||||
testCaseIssueService.updateIssuesCount(l.getCaseId());
|
||||
});
|
||||
}
|
||||
LogUtil.info("测试计划-测试用例同步缺陷信息结束");
|
||||
}
|
||||
|
||||
public boolean checkSync(String projectId) {
|
||||
|
@ -649,7 +655,7 @@ public class IssuesService {
|
|||
String defaultCustomFields = getDefaultCustomFields(projectId);
|
||||
issuesRequest.setDefaultCustomFields(defaultCustomFields);
|
||||
}
|
||||
AbstractIssuePlatform platform = IssueFactory.createPlatform(project.getPlatform(), issuesRequest);
|
||||
IssuesPlatform platform = IssueFactory.createPlatform(project.getPlatform(), issuesRequest);
|
||||
syncThirdPartyIssues(platform::syncIssues, project, issues);
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
|
@ -706,7 +712,7 @@ public class IssuesService {
|
|||
request.setWorkspaceId(orgId);
|
||||
request.setPlatform(platform);
|
||||
|
||||
ServiceIntegration integration = integrationService.get(request);
|
||||
ServiceIntegration integration = baseIntegrationService.get(request);
|
||||
return integration.getConfiguration();
|
||||
}
|
||||
|
||||
|
@ -737,7 +743,7 @@ public class IssuesService {
|
|||
public void userAuth(AuthUserIssueRequest authUserIssueRequest) {
|
||||
IssuesRequest issuesRequest = new IssuesRequest();
|
||||
issuesRequest.setWorkspaceId(authUserIssueRequest.getWorkspaceId());
|
||||
AbstractIssuePlatform abstractPlatform = IssueFactory.createPlatform(authUserIssueRequest.getPlatform(), issuesRequest);
|
||||
IssuesPlatform abstractPlatform = IssueFactory.createPlatform(authUserIssueRequest.getPlatform(), issuesRequest);
|
||||
abstractPlatform.userAuth(authUserIssueRequest);
|
||||
}
|
||||
|
||||
|
@ -877,6 +883,7 @@ public class IssuesService {
|
|||
}
|
||||
|
||||
public List<IssuesWithBLOBs> getIssuesByPlatformIds(List<String> platformIds, String projectId) {
|
||||
|
||||
if (CollectionUtils.isEmpty(platformIds)) return new ArrayList<>();
|
||||
IssuesExample example = new IssuesExample();
|
||||
example.createCriteria()
|
||||
|
@ -885,6 +892,30 @@ public class IssuesService {
|
|||
return issuesMapper.selectByExampleWithBLOBs(example);
|
||||
}
|
||||
|
||||
public List<IssuesDao> getPlatformIssueByIds(List<String> platformIds, String projectId) {
|
||||
// todo 是否保留
|
||||
List<IssuesDao> issues = extIssuesMapper.getPlatformIssueByIds(platformIds, projectId);
|
||||
if (CollectionUtils.isEmpty(issues)) {
|
||||
return issues;
|
||||
}
|
||||
List<String> issueIds = issues.stream().map(IssuesDao::getId).collect(Collectors.toList());
|
||||
List<IssuesDao> issuesList = extIssuesMapper.getIssueCustomFields(issueIds);
|
||||
Map<String, List<CustomFieldItemDTO>> map = new HashMap<>();
|
||||
issuesList.forEach(f -> {
|
||||
CustomFieldItemDTO dto = new CustomFieldItemDTO();
|
||||
dto.setId(f.getFieldId());
|
||||
dto.setName(f.getFieldName());
|
||||
dto.setType(f.getFieldType());
|
||||
dto.setValue(f.getFieldValue());
|
||||
dto.setCustomData(f.getCustomData());
|
||||
List<CustomFieldItemDTO> list = Optional.ofNullable(map.get(f.getId())).orElse(new ArrayList<>());
|
||||
map.put(f.getId(), list);
|
||||
list.add(dto);
|
||||
});
|
||||
issues.forEach(i -> i.setCustomFieldList(map.getOrDefault(i.getId(), new ArrayList<>())));
|
||||
return issues;
|
||||
}
|
||||
|
||||
|
||||
public IssueTemplateDao getThirdPartTemplate(String projectId) {
|
||||
if (StringUtils.isNotBlank(projectId)) {
|
||||
|
@ -918,7 +949,7 @@ public class IssuesService {
|
|||
IssuesRequest issueRequest = new IssuesRequest();
|
||||
issueRequest.setWorkspaceId(workspaceId);
|
||||
issueRequest.setProjectId(projectId);
|
||||
AbstractIssuePlatform platform = IssueFactory.createPlatform(project.getPlatform(), issueRequest);
|
||||
IssuesPlatform platform = IssueFactory.createPlatform(project.getPlatform(), issueRequest);
|
||||
return platform.getDemandList(projectId);
|
||||
}
|
||||
|
||||
|
@ -938,12 +969,12 @@ public class IssuesService {
|
|||
}
|
||||
|
||||
IssuesRequest issuesRequest = getDefaultIssueRequest(request.getProjectId(), request.getWorkspaceId());
|
||||
Map<String, AbstractIssuePlatform> platformMap = IssueFactory.createPlatformsForMap(platforms, issuesRequest);
|
||||
Map<String, IssuesPlatform> platformMap = IssueFactory.createPlatformsForMap(platforms, issuesRequest);
|
||||
try {
|
||||
if (platformMap.size() > 1) {
|
||||
MSException.throwException(Translator.get("project_reference_multiple_plateform"));
|
||||
}
|
||||
Optional<AbstractIssuePlatform> platformOptional = platformMap.values().stream().findFirst();
|
||||
Optional<IssuesPlatform> platformOptional = platformMap.values().stream().findFirst();
|
||||
if (platformOptional.isPresent()) {
|
||||
platformStatusDTOS = platformOptional.get().getTransitions(request.getPlatformKey());
|
||||
}
|
||||
|
@ -968,32 +999,7 @@ public class IssuesService {
|
|||
issueFileMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public void checkThirdProjectExist(Project project) {
|
||||
IssuesRequest issuesRequest = new IssuesRequest();
|
||||
if (StringUtils.isBlank(project.getId())) {
|
||||
MSException.throwException("project ID cannot be empty");
|
||||
}
|
||||
issuesRequest.setProjectId(project.getId());
|
||||
issuesRequest.setWorkspaceId(project.getWorkspaceId());
|
||||
if (StringUtils.equalsIgnoreCase(project.getPlatform(), IssuesManagePlatform.Tapd.name())) {
|
||||
TapdPlatform tapd = new TapdPlatform(issuesRequest);
|
||||
this.doCheckThirdProjectExist(tapd, project.getTapdId());
|
||||
} else if (StringUtils.equalsIgnoreCase(project.getPlatform(), IssuesManagePlatform.Jira.name())) {
|
||||
JiraPlatform jira = new JiraPlatform(issuesRequest);
|
||||
this.doCheckThirdProjectExist(jira, project.getJiraKey());
|
||||
} else if (StringUtils.equalsIgnoreCase(project.getPlatform(), IssuesManagePlatform.Zentao.name())) {
|
||||
ZentaoPlatform zentao = new ZentaoPlatform(issuesRequest);
|
||||
this.doCheckThirdProjectExist(zentao, project.getZentaoId());
|
||||
}
|
||||
}
|
||||
|
||||
private void doCheckThirdProjectExist(AbstractIssuePlatform platform, String relateId) {
|
||||
if (StringUtils.isBlank(relateId)) {
|
||||
MSException.throwException(Translator.get("issue_project_not_exist"));
|
||||
}
|
||||
Boolean exist = platform.checkProjectExist(relateId);
|
||||
if (BooleanUtils.isFalse(exist)) {
|
||||
MSException.throwException(Translator.get("issue_project_not_exist"));
|
||||
}
|
||||
public boolean isThirdPartTemplate(Project project) {
|
||||
return project.getThirdPartTemplate() != null && project.getThirdPartTemplate() && project.getPlatform().equals(IssuesManagePlatform.Jira.name());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@ import io.metersphere.request.ResetOrderRequest;
|
|||
import io.metersphere.request.attachment.AttachmentRequest;
|
||||
import io.metersphere.request.member.QueryMemberRequest;
|
||||
import io.metersphere.request.testcase.*;
|
||||
import io.metersphere.service.issue.XpackIssueService;
|
||||
import io.metersphere.service.issue.platform.AbstractIssuePlatform;
|
||||
import io.metersphere.service.issue.platform.IssueFactory;
|
||||
import io.metersphere.service.remote.api.RelevanceApiCaseService;
|
||||
import io.metersphere.service.remote.performance.RelevanceLoadCaseService;
|
||||
|
@ -46,6 +44,10 @@ import io.metersphere.service.wapper.TrackProjectService;
|
|||
import io.metersphere.xmind.XmindCaseParser;
|
||||
import io.metersphere.xmind.pojo.TestCaseXmindData;
|
||||
import io.metersphere.xmind.utils.XmindExportUtil;
|
||||
import io.metersphere.xpack.track.dto.EditTestCaseRequest;
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesRequest;
|
||||
import io.metersphere.xpack.track.issue.IssuesPlatform;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
|
@ -56,7 +58,6 @@ import org.apache.ibatis.session.SqlSession;
|
|||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.mybatis.spring.SqlSessionUtils;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -259,7 +260,7 @@ public class TestCaseService {
|
|||
Project project = baseProjectService.getProjectById(request.getProjectId());
|
||||
if (StringUtils.equals(project.getPlatform(), IssuesManagePlatform.AzureDevops.name())) {
|
||||
updateRequest.setWorkspaceId(project.getWorkspaceId());
|
||||
List<AbstractIssuePlatform> platformList = getAddPlatforms(updateRequest);
|
||||
List<IssuesPlatform> platformList = getAddPlatforms(updateRequest);
|
||||
platformList.forEach(platform -> {
|
||||
platform.updateDemandHyperLink(request, project, type);
|
||||
});
|
||||
|
@ -293,7 +294,7 @@ public class TestCaseService {
|
|||
}
|
||||
}
|
||||
|
||||
private List<AbstractIssuePlatform> getAddPlatforms(IssuesRequest request) {
|
||||
private List<IssuesPlatform> getAddPlatforms(IssuesRequest request) {
|
||||
List<String> platforms = new ArrayList<>();
|
||||
// 缺陷管理关联
|
||||
platforms.add(issuesService.getPlatform(request.getProjectId()));
|
||||
|
@ -417,10 +418,19 @@ public class TestCaseService {
|
|||
* @param testCase
|
||||
*/
|
||||
public void updateThirdPartyIssuesLink(EditTestCaseRequest testCase) {
|
||||
XpackIssueService issueService = CommonBeanFactory.getBean(XpackIssueService.class);
|
||||
if (issueService != null) {
|
||||
issueService.updateThirdPartyIssuesLink(testCase);
|
||||
if (StringUtils.isBlank(testCase.getProjectId())) {
|
||||
return;
|
||||
}
|
||||
Project project = baseProjectService.getProjectById(testCase.getProjectId());
|
||||
IssuesRequest issuesRequest = new IssuesRequest();
|
||||
if (!issuesService.isThirdPartTemplate(project)) {
|
||||
issuesRequest.setDefaultCustomFields(issuesService.getDefaultCustomFields(testCase.getProjectId()));
|
||||
}
|
||||
issuesRequest.setProjectId(testCase.getProjectId());
|
||||
issuesRequest.setWorkspaceId(project.getWorkspaceId());
|
||||
IssueFactory.createPlatform(issuesService.getPlatform(testCase.getProjectId()), issuesRequest)
|
||||
.updateDemandIssueLink(testCase, project);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package io.metersphere.service.issue;
|
||||
|
||||
import io.metersphere.request.testcase.EditTestCaseRequest;
|
||||
|
||||
public interface XpackIssueService {
|
||||
|
||||
void updateThirdPartyIssuesLink(EditTestCaseRequest testCase);
|
||||
}
|
|
@ -5,6 +5,8 @@ import io.metersphere.commons.utils.JSON;
|
|||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.service.issue.domain.jira.*;
|
||||
import io.metersphere.xpack.track.dto.JiraIssue;
|
||||
import io.metersphere.xpack.track.dto.JiraIssueListResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.*;
|
||||
|
@ -242,11 +244,11 @@ public abstract class JiraAbstractClient extends BaseClient {
|
|||
PASSWD = config.getPassword();
|
||||
}
|
||||
|
||||
public JiraIssueListResponse getProjectIssues(int startAt, int maxResults, String projectKey, String issueType) {
|
||||
public JiraIssueListResponse getProjectIssues(Integer startAt, Integer maxResults, String projectKey, String issueType) {
|
||||
return getProjectIssues(startAt, maxResults, projectKey, issueType, null);
|
||||
}
|
||||
|
||||
public JiraIssueListResponse getProjectIssues(int startAt, int maxResults, String projectKey, String issueType, String fields) {
|
||||
public JiraIssueListResponse getProjectIssues(Integer startAt, Integer maxResults, String projectKey, String issueType, String fields) {
|
||||
ResponseEntity<String> responseEntity;
|
||||
String url = getBaseUrl() + "/search?startAt={1}&maxResults={2}&jql=project={3}+AND+issuetype={4}";
|
||||
if (StringUtils.isNotBlank(fields)) {
|
||||
|
@ -264,7 +266,7 @@ public abstract class JiraAbstractClient extends BaseClient {
|
|||
return responseEntity.getBody();
|
||||
}
|
||||
|
||||
public JiraIssueListResponse getProjectIssuesAttachment(int startAt, int maxResults, String projectKey, String issueType) {
|
||||
public JiraIssueListResponse getProjectIssuesAttachment(Integer startAt, Integer maxResults, String projectKey, String issueType) {
|
||||
return getProjectIssues(startAt, maxResults, projectKey, issueType, "attachment");
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@ import io.metersphere.commons.utils.LogUtil;
|
|||
import io.metersphere.service.issue.domain.tapd.AddTapdIssueResponse;
|
||||
import io.metersphere.service.issue.domain.tapd.TapdBug;
|
||||
import io.metersphere.service.issue.domain.tapd.TapdConfig;
|
||||
import io.metersphere.service.issue.domain.tapd.TapdGetIssueResponse;
|
||||
import io.metersphere.xpack.track.dto.TapdBaseResponse;
|
||||
import io.metersphere.xpack.track.dto.TapdGetIssueResponse;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
@ -29,7 +30,7 @@ public class TapdClient extends BaseClient {
|
|||
protected String PASSWD;
|
||||
|
||||
|
||||
public TapdGetIssueResponse getIssueForPage(String projectId, int pageNum, int limit) {
|
||||
public TapdGetIssueResponse getIssueForPage(String projectId, Integer pageNum, Integer limit) {
|
||||
return getIssueForPageByIds(projectId, pageNum, limit, null);
|
||||
}
|
||||
|
||||
|
@ -42,10 +43,8 @@ public class TapdClient extends BaseClient {
|
|||
MSException.throwException("请检查配置信息是否填写正确!");
|
||||
LogUtil.error(e);
|
||||
}
|
||||
String resultForObject = (String) getResultForObject(String.class, response);
|
||||
Map<String, Object> jsonObject = JSON.parseMap(resultForObject);
|
||||
String data = jsonObject.get("data").toString();
|
||||
return JSON.parseObject(data, Map.class);
|
||||
Map resultForObject = (Map) getResultForObject(Map.class, response);
|
||||
return (Map<String, String>) resultForObject.get("data");
|
||||
}
|
||||
|
||||
public List getPlatformUser(String projectId) {
|
||||
|
@ -126,7 +125,7 @@ public class TapdClient extends BaseClient {
|
|||
public boolean checkProjectExist(String relateId) {
|
||||
String url = getBaseUrl() + "/roles?workspace_id={1}";
|
||||
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, getAuthHttpEntity(), String.class, relateId);
|
||||
TapdGetIssueResponse res = (TapdGetIssueResponse) getResultForObject(TapdGetIssueResponse.class, response);
|
||||
TapdBaseResponse res = (TapdBaseResponse) getResultForObject(TapdBaseResponse.class, response);
|
||||
return res == null || res.getStatus() != 404;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,12 +152,12 @@ public abstract class ZentaoClient extends BaseClient {
|
|||
return (Map<String, Object>) JSON.parseMap(response.getBody()).get("data");
|
||||
}
|
||||
|
||||
public Map getBugsByProjectId(String projectId, int pageNum, int pageSize) {
|
||||
public Map getBugsByProjectId(String projectId, Integer pageNum, Integer pageSize) {
|
||||
String sessionId = login();
|
||||
ResponseEntity<String> response = restTemplate.exchange(requestUrl.getBugList(),
|
||||
HttpMethod.GET, null, String.class, projectId, 9999999, pageSize, pageNum, sessionId);
|
||||
try {
|
||||
return (Map) JSON.parseMap(response.getBody()).get("data");
|
||||
return JSON.parseMap(JSON.parseMap(response.getBody()).get("data").toString());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
MSException.throwException("请检查配置信息是否填写正确!");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.service.issue.domain.tapd;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
@ -14,6 +15,7 @@ public class AddTapdIssueResponse {
|
|||
@Getter
|
||||
@Setter
|
||||
public static class Data {
|
||||
@JsonAlias("Bug")
|
||||
private TapdBug bug;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,21 +11,19 @@ import io.metersphere.commons.constants.IssuesStatus;
|
|||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.*;
|
||||
import io.metersphere.dto.CustomFieldItemDTO;
|
||||
import io.metersphere.dto.IssueTemplateDao;
|
||||
import io.metersphere.dto.PlatformStatusDTO;
|
||||
import io.metersphere.xpack.track.dto.IssueTemplateDao;
|
||||
import io.metersphere.xpack.track.dto.PlatformStatusDTO;
|
||||
import io.metersphere.dto.UserDTO;
|
||||
import io.metersphere.request.IntegrationRequest;
|
||||
import io.metersphere.request.testcase.EditTestCaseRequest;
|
||||
import io.metersphere.request.testcase.IssuesRequest;
|
||||
import io.metersphere.request.testcase.IssuesUpdateRequest;
|
||||
import io.metersphere.xpack.track.dto.EditTestCaseRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest;
|
||||
import io.metersphere.service.*;
|
||||
import io.metersphere.service.issue.IssuesPlatform;
|
||||
import io.metersphere.xpack.track.issue.IssuesPlatform;
|
||||
import io.metersphere.service.issue.domain.ProjectIssueConfig;
|
||||
import io.metersphere.service.remote.setting.IntegrationService;
|
||||
import io.metersphere.service.wapper.TrackProjectService;
|
||||
import io.metersphere.service.wapper.UserService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.safety.Safelist;
|
||||
|
@ -44,7 +42,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
public abstract class AbstractIssuePlatform implements IssuesPlatform {
|
||||
|
||||
protected IntegrationService integrationService;
|
||||
protected BaseIntegrationService baseIntegrationService;
|
||||
protected TestCaseIssueService testCaseIssueService;
|
||||
protected TestCaseIssuesMapper testCaseIssuesMapper;
|
||||
protected TrackProjectService trackProjectService;
|
||||
|
@ -82,7 +80,7 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
|
|||
}
|
||||
|
||||
public AbstractIssuePlatform() {
|
||||
this.integrationService = CommonBeanFactory.getBean(IntegrationService.class);
|
||||
this.baseIntegrationService = CommonBeanFactory.getBean(BaseIntegrationService.class);
|
||||
this.testCaseIssuesMapper = CommonBeanFactory.getBean(TestCaseIssuesMapper.class);
|
||||
this.trackProjectService = CommonBeanFactory.getBean(TrackProjectService.class);
|
||||
this.testCaseService = CommonBeanFactory.getBean(TestCaseService.class);
|
||||
|
@ -100,6 +98,11 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
|
|||
this.baseProjectService = CommonBeanFactory.getBean(BaseProjectService.class);
|
||||
}
|
||||
|
||||
// xpack 反射调用
|
||||
public String getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
protected String getPlatformConfig(String platform) {
|
||||
IntegrationRequest request = new IntegrationRequest();
|
||||
if (StringUtils.isBlank(workspaceId)) {
|
||||
|
@ -108,7 +111,7 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
|
|||
request.setWorkspaceId(workspaceId);
|
||||
request.setPlatform(platform);
|
||||
|
||||
ServiceIntegration integration = integrationService.get(request);
|
||||
ServiceIntegration integration = baseIntegrationService.get(request);
|
||||
return integration.getConfiguration();
|
||||
}
|
||||
|
||||
|
@ -395,26 +398,27 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
|
|||
|
||||
protected Object getSyncJsonParamValue(Object value) {
|
||||
Map valObj = ((Map) value);
|
||||
String accountId = valObj.get("accountId").toString();
|
||||
String accountId = Optional.ofNullable(valObj.get("accountId")).orElse("").toString();
|
||||
Map child = (Map) valObj.get("child");
|
||||
if (child != null) {// 级联框
|
||||
List<Object> values = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(valObj.get("id").toString())) {
|
||||
values.add(valObj.get("id").toString());
|
||||
String id = Optional.ofNullable(valObj.get("id")).orElse("").toString();
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
values.add(valObj.get("id"));
|
||||
}
|
||||
if (StringUtils.isNotBlank(child.get("id").toString())) {
|
||||
values.add(child.get("id").toString());
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
values.add(child.get("id"));
|
||||
}
|
||||
return values;
|
||||
} else if (StringUtils.isNotBlank(accountId) && isThirdPartTemplate) {
|
||||
// 用户选择框
|
||||
return accountId;
|
||||
} else {
|
||||
String id = valObj.get("id").toString();
|
||||
String id = Optional.ofNullable(valObj.get("id")).orElse("").toString();
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
return valObj.get("id").toString();
|
||||
return valObj.get("id");
|
||||
} else {
|
||||
return valObj.get("key").toString();
|
||||
return valObj.get("key");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -434,7 +438,7 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
|
|||
if (value instanceof Map) {
|
||||
item.setValue(getSyncJsonParamValue(value));
|
||||
if (StringUtils.equals(fieldName, "assignee")) {
|
||||
item.setValue(((JSONObject) value).get("displayName"));
|
||||
item.setValue(((Map) value).get("displayName"));
|
||||
} else {
|
||||
item.setValue(getSyncJsonParamValue(value));
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@ package io.metersphere.service.issue.platform;
|
|||
|
||||
import io.metersphere.commons.constants.IssuesManagePlatform;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.request.testcase.IssuesRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesRequest;
|
||||
import io.metersphere.xpack.track.issue.IssuesPlatform;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
@ -12,7 +13,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
public class IssueFactory {
|
||||
public static AbstractIssuePlatform createPlatform(String platform, IssuesRequest addIssueRequest) {
|
||||
public static IssuesPlatform createPlatform(String platform, IssuesRequest addIssueRequest) {
|
||||
if (StringUtils.equals(IssuesManagePlatform.Tapd.toString(), platform)) {
|
||||
return new TapdPlatform(addIssueRequest);
|
||||
} else if (StringUtils.equals(IssuesManagePlatform.Jira.toString(), platform)) {
|
||||
|
@ -22,9 +23,9 @@ public class IssueFactory {
|
|||
} else if (StringUtils.equals(IssuesManagePlatform.AzureDevops.toString(), platform)) {
|
||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
try {
|
||||
Class clazz = loader.loadClass("io.metersphere.xpack.issue.azuredevops.AzureDevopsPlatform");
|
||||
Class clazz = loader.loadClass("io.metersphere.xpack.track.issue.platform.AzureDevopsPlatform");
|
||||
Constructor cons = clazz.getDeclaredConstructor(new Class[] { IssuesRequest.class });
|
||||
AbstractIssuePlatform azureDevopsPlatform = (AbstractIssuePlatform) cons.newInstance(addIssueRequest);
|
||||
IssuesPlatform azureDevopsPlatform = (IssuesPlatform) cons.newInstance(addIssueRequest);
|
||||
return azureDevopsPlatform;
|
||||
} catch (Throwable e) {
|
||||
LogUtil.error(e);
|
||||
|
@ -35,10 +36,10 @@ public class IssueFactory {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static List<AbstractIssuePlatform> createPlatforms(List<String> types, IssuesRequest addIssueRequest) {
|
||||
List<AbstractIssuePlatform> platforms = new ArrayList<>();
|
||||
public static List<IssuesPlatform> createPlatforms(List<String> types, IssuesRequest addIssueRequest) {
|
||||
List<IssuesPlatform> platforms = new ArrayList<>();
|
||||
types.forEach(type -> {
|
||||
AbstractIssuePlatform abstractIssuePlatform = createPlatform(type, addIssueRequest);
|
||||
IssuesPlatform abstractIssuePlatform = createPlatform(type, addIssueRequest);
|
||||
if (abstractIssuePlatform != null) {
|
||||
platforms.add(abstractIssuePlatform);
|
||||
}
|
||||
|
@ -46,10 +47,10 @@ public class IssueFactory {
|
|||
return platforms;
|
||||
}
|
||||
|
||||
public static Map<String, AbstractIssuePlatform> createPlatformsForMap(List<String> types, IssuesRequest addIssueRequest) {
|
||||
Map<String, AbstractIssuePlatform> platformMap = new HashMap<>();
|
||||
public static Map<String, IssuesPlatform> createPlatformsForMap(List<String> types, IssuesRequest addIssueRequest) {
|
||||
Map<String, IssuesPlatform> platformMap = new HashMap<>();
|
||||
types.forEach(type -> {
|
||||
AbstractIssuePlatform abstractIssuePlatform = createPlatform(type, addIssueRequest);
|
||||
IssuesPlatform abstractIssuePlatform = createPlatform(type, addIssueRequest);
|
||||
if (abstractIssuePlatform != null) {
|
||||
platformMap.put(type, abstractIssuePlatform);
|
||||
}
|
||||
|
|
|
@ -6,20 +6,20 @@ import io.metersphere.commons.constants.IssuesManagePlatform;
|
|||
import io.metersphere.commons.constants.IssuesStatus;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.DateUtils;
|
||||
import io.metersphere.commons.utils.JSON;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.constants.AttachmentSyncType;
|
||||
import io.metersphere.xpack.track.dto.AttachmentSyncType;
|
||||
import io.metersphere.constants.AttachmentType;
|
||||
import io.metersphere.dto.*;
|
||||
import io.metersphere.request.attachment.AttachmentRequest;
|
||||
import io.metersphere.request.testcase.IssuesRequest;
|
||||
import io.metersphere.request.testcase.IssuesUpdateRequest;
|
||||
import io.metersphere.xpack.track.dto.*;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest;
|
||||
import io.metersphere.service.issue.client.JiraClientV2;
|
||||
import io.metersphere.service.issue.domain.PlatformUser;
|
||||
import io.metersphere.service.IssuesService;
|
||||
import io.metersphere.service.issue.domain.ProjectIssueConfig;
|
||||
import io.metersphere.service.issue.domain.jira.*;
|
||||
import net.minidev.json.JSONObject;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
@ -50,6 +50,11 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
setConfig();
|
||||
}
|
||||
|
||||
// xpack 反射调用
|
||||
public JiraClientV2 getJiraClientV2() {
|
||||
return jiraClientV2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IssuesDao> getIssue(IssuesRequest issuesRequest) {
|
||||
issuesRequest.setPlatform(key);
|
||||
|
@ -62,7 +67,12 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
return issues;
|
||||
}
|
||||
|
||||
public IssuesWithBLOBs getUpdateIssue(JiraIssue jiraIssue) {
|
||||
return getUpdateIssue(null, jiraIssue);
|
||||
}
|
||||
|
||||
public IssuesWithBLOBs getUpdateIssue(IssuesWithBLOBs issue, JiraIssue jiraIssue) {
|
||||
try {
|
||||
if (issue == null) {
|
||||
issue = new IssuesWithBLOBs();
|
||||
issue.setCustomFields(defaultCustomFields);
|
||||
|
@ -76,7 +86,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
Map<String, String> fileContentMap = getContextMap((List) fields.get("attachment"));
|
||||
|
||||
// 先转换下desc的图片
|
||||
String description = dealWithDescription(fields.get("description").toString(), fileContentMap);
|
||||
String description = dealWithDescription(Optional.ofNullable(fields.get("description")).orElse("").toString(), fileContentMap);
|
||||
fields.put("description", description);
|
||||
CustomFieldItemDTO descItem = null;
|
||||
List<CustomFieldItemDTO> customFieldItems = syncIssueCustomFieldList(issue.getCustomFields(), jiraIssue.getFields());
|
||||
|
@ -93,16 +103,25 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
}
|
||||
|
||||
JSONObject assignee = (JSONObject) fields.get("assignee");
|
||||
Map assignee = (Map) fields.get("assignee");
|
||||
issue.setTitle(fields.get("summary").toString());
|
||||
issue.setCreateTime((Long) fields.get("created"));
|
||||
issue.setUpdateTime((Long) fields.get("updated"));
|
||||
issue.setLastmodify(assignee == null ? "" : assignee.get("displayName").toString());
|
||||
issue.setDescription(description);
|
||||
issue.setPlatformStatus(status);
|
||||
issue.setPlatform(key);
|
||||
issue.setCustomFields(JSON.toJSONString(customFieldItems));
|
||||
try {
|
||||
issue.setCreateTime(DateUtils.getTimestamp((String) fields.get("created")));
|
||||
issue.setUpdateTime(DateUtils.getTimestamp((String) fields.get("updated")));
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
return issue;
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
MSException.throwException(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String dealWithDescription(String description, Map<String, String> fileContentMap) {
|
||||
|
@ -207,11 +226,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
|
||||
public List<JiraIssueType> getIssueTypes(String jiraKey) {
|
||||
try {
|
||||
return jiraClientV2.getIssueType(jiraKey);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -220,8 +235,8 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
setUserConfig();
|
||||
Project project = getProject();
|
||||
|
||||
JSONObject addJiraIssueParam = buildUpdateParam(issuesRequest, getIssueType(project.getIssueConfig()), project.getJiraKey());
|
||||
JiraAddIssueResponse result = jiraClientV2.addIssue(JSONObject.toJSONString(addJiraIssueParam));
|
||||
Map addJiraIssueParam = buildUpdateParam(issuesRequest, getIssueType(project.getIssueConfig()), project.getJiraKey());
|
||||
JiraAddIssueResponse result = jiraClientV2.addIssue(JSON.toJSONString(addJiraIssueParam));
|
||||
JiraIssue issues = jiraClientV2.getIssues(result.getId());
|
||||
|
||||
// 上传富文本中的图片作为附件
|
||||
|
@ -284,7 +299,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
* 参数比较特殊,需要特别处理
|
||||
* @param fields
|
||||
*/
|
||||
private void setSpecialParam(JSONObject fields) {
|
||||
private void setSpecialParam(Map fields) {
|
||||
Project project = getProject();
|
||||
try {
|
||||
Map<String, JiraCreateMetadataResponse.Field> createMetadata = jiraClientV2.getCreateMetadata(project.getJiraKey(), getIssueType(project.getIssueConfig()));
|
||||
|
@ -312,7 +327,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
if (schema.getType() != null && schema.getType().endsWith("user")) {
|
||||
Map field = (Map) fields.get(key);
|
||||
// 如果不是用户ID,则是用户的key,参数调整为key
|
||||
JSONObject newField = new JSONObject();
|
||||
Map newField = new LinkedHashMap<>();
|
||||
newField.put("name", field.get("id").toString());
|
||||
fields.put(key, newField);
|
||||
}
|
||||
|
@ -329,10 +344,10 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
}
|
||||
|
||||
private JSONObject buildUpdateParam(IssuesUpdateRequest issuesRequest, String issuetypeStr, String jiraKey) {
|
||||
private Map<String, Object> buildUpdateParam(IssuesUpdateRequest issuesRequest, String issuetypeStr, String jiraKey) {
|
||||
issuesRequest.setPlatform(key);
|
||||
JSONObject fields = new JSONObject();
|
||||
JSONObject project = new JSONObject();
|
||||
Map fields = new LinkedHashMap<>();
|
||||
Map project = new LinkedHashMap<>();
|
||||
|
||||
String desc = "";
|
||||
// 附件描述信息处理
|
||||
|
@ -344,11 +359,11 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
fields.put("project", project);
|
||||
project.put("key", jiraKey);
|
||||
|
||||
JSONObject issuetype = new JSONObject();
|
||||
Map issuetype = new LinkedHashMap<>();
|
||||
issuetype.put("id", issuetypeStr);
|
||||
fields.put("issuetype", issuetype);
|
||||
|
||||
JSONObject addJiraIssueParam = new JSONObject();
|
||||
Map addJiraIssueParam = new LinkedHashMap();
|
||||
addJiraIssueParam.put("fields", fields);
|
||||
|
||||
if (issuesRequest.isThirdPartPlatform()) {
|
||||
|
@ -411,7 +426,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
return result;
|
||||
}
|
||||
|
||||
private void parseCustomFiled(IssuesUpdateRequest issuesRequest, JSONObject fields) {
|
||||
private void parseCustomFiled(IssuesUpdateRequest issuesRequest, Map fields) {
|
||||
List<CustomFieldItemDTO> customFields = issuesRequest.getRequestFields();
|
||||
|
||||
customFields.forEach(item -> {
|
||||
|
@ -424,7 +439,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
if (StringUtils.equalsAnyIgnoreCase(name, "PML", "PMLinkTest", "PMLink")) {
|
||||
fields.put(fieldName, item.getValue());
|
||||
} else {
|
||||
JSONObject param = new JSONObject();
|
||||
Map param = new LinkedHashMap<>();
|
||||
if (fieldName.equals("assignee") || fieldName.equals("reporter")) {
|
||||
if (issuesRequest.isThirdPartPlatform()) {
|
||||
param.put("id", item.getValue());
|
||||
|
@ -441,7 +456,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
if (item.getValue() != null) {
|
||||
List values = JSON.parseArray((String) item.getValue());
|
||||
values.forEach(v -> {
|
||||
JSONObject param = new JSONObject();
|
||||
Map param = new LinkedHashMap<>();
|
||||
param.put("id", v);
|
||||
attrs.add(param);
|
||||
});
|
||||
|
@ -449,7 +464,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
fields.put(fieldName, attrs);
|
||||
} else if (StringUtils.equalsAny(item.getType(), "cascadingSelect")) {
|
||||
if (item.getValue() != null) {
|
||||
JSONObject attr = new JSONObject();
|
||||
Map attr = new LinkedHashMap<>();
|
||||
if (item.getValue() instanceof List) {
|
||||
List values = JSON.parseArray((String) item.getValue());
|
||||
if (CollectionUtils.isNotEmpty(values)) {
|
||||
|
@ -457,7 +472,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
attr.put("id", values.get(0));
|
||||
}
|
||||
if (values.size() > 1) {
|
||||
JSONObject param = new JSONObject();
|
||||
Map param = new LinkedHashMap<>();
|
||||
param.put("id", values.get(1));
|
||||
attr.put("child", param);
|
||||
}
|
||||
|
@ -486,8 +501,8 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
public void updateIssue(IssuesUpdateRequest request) {
|
||||
setUserConfig();
|
||||
Project project = getProject();
|
||||
JSONObject param = buildUpdateParam(request, getIssueType(project.getIssueConfig()), project.getJiraKey());
|
||||
jiraClientV2.updateIssue(request.getPlatformId(), JSONObject.toJSONString(param));
|
||||
Map param = buildUpdateParam(request, getIssueType(project.getIssueConfig()), project.getJiraKey());
|
||||
jiraClientV2.updateIssue(request.getPlatformId(), JSON.toJSONString(param));
|
||||
|
||||
// 同步Jira富文本有关的附件
|
||||
syncJiraRichTextAttachment(request);
|
||||
|
@ -535,10 +550,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
super.isThirdPartTemplate = isThirdPartTemplate();
|
||||
HashMap<String, List<CustomFieldResourceDTO>> customFieldMap = new HashMap<>();
|
||||
|
||||
IssuesService issuesService = CommonBeanFactory.getBean(IssuesService.class);
|
||||
if (project.getThirdPartTemplate()) {
|
||||
super.defaultCustomFields = issuesService.getCustomFieldsValuesString(getThirdPartTemplate().getCustomFields());
|
||||
}
|
||||
prepareSync(project);
|
||||
|
||||
issues.forEach(item -> {
|
||||
try {
|
||||
|
@ -564,6 +576,13 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
customFieldIssuesService.batchEditFields(customFieldMap);
|
||||
}
|
||||
|
||||
public void prepareSync(Project project) {
|
||||
IssuesService issuesService = CommonBeanFactory.getBean(IssuesService.class);
|
||||
if (project.getThirdPartTemplate()) {
|
||||
super.defaultCustomFields = issuesService.getCustomFieldsValuesString(getThirdPartTemplate().getCustomFields());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectId(String projectId) {
|
||||
return getProjectId(projectId, Project::getJiraKey);
|
||||
|
@ -761,13 +780,13 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
Object defaultValue = item.getDefaultValue();
|
||||
if (defaultValue != null) {
|
||||
Object msDefaultValue;
|
||||
if (defaultValue instanceof JSONObject) {
|
||||
msDefaultValue = ((JSONObject) defaultValue).get("id");
|
||||
if (defaultValue instanceof Map) {
|
||||
msDefaultValue = ((Map) defaultValue).get("id");
|
||||
} else if (defaultValue instanceof List) {
|
||||
List defaultList = new ArrayList();
|
||||
((List) defaultValue).forEach(i -> {
|
||||
if (i instanceof JSONObject) {
|
||||
JSONObject obj = (JSONObject) i;
|
||||
if (i instanceof Map) {
|
||||
Map obj = (Map) i;
|
||||
defaultList.add(obj.get("id"));
|
||||
} else {
|
||||
defaultList.add(i);
|
||||
|
@ -801,7 +820,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
if (allowedValues != null) {
|
||||
List options = new ArrayList<>();
|
||||
allowedValues.forEach(val -> {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
Map jsonObject = new LinkedHashMap();
|
||||
jsonObject.put("value", val.getId());
|
||||
if (StringUtils.isNotBlank(val.getName())) {
|
||||
jsonObject.put("text", val.getName());
|
||||
|
@ -823,7 +842,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
List<JiraUser> userOptions = jiraClientV2.getAssignableUser(projectKey);
|
||||
List options = new ArrayList();
|
||||
userOptions.forEach(val -> {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
Map jsonObject = new LinkedHashMap<>();
|
||||
if (StringUtils.isNotBlank(val.getAccountId())) {
|
||||
jsonObject.put("value", val.getAccountId());
|
||||
} else {
|
||||
|
@ -877,6 +896,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
|
||||
public void syncJiraIssueAttachments(IssuesWithBLOBs issue, JiraIssue jiraIssue) {
|
||||
try {
|
||||
List<String> jiraAttachmentsName = new ArrayList<String>();
|
||||
AttachmentRequest request = new AttachmentRequest();
|
||||
request.setBelongType(AttachmentType.ISSUE.type());
|
||||
|
@ -922,6 +942,10 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
attachmentModuleRelationMapper.deleteByExample(example);
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
MSException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void syncJiraRichTextAttachment(IssuesUpdateRequest request) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package io.metersphere.service.issue.platform;
|
||||
|
||||
import io.metersphere.base.domain.Project;
|
||||
import io.metersphere.dto.IssuesDao;
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import io.metersphere.dto.UserDTO;
|
||||
import io.metersphere.request.testcase.IssuesRequest;
|
||||
import io.metersphere.service.issue.domain.PlatformUser;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesRequest;
|
||||
import io.metersphere.xpack.track.dto.PlatformUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@ import io.metersphere.commons.user.SessionUser;
|
|||
import io.metersphere.commons.utils.BeanUtils;
|
||||
import io.metersphere.commons.utils.JSON;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.constants.AttachmentSyncType;
|
||||
import io.metersphere.xpack.track.dto.AttachmentSyncType;
|
||||
import io.metersphere.dto.CustomFieldItemDTO;
|
||||
import io.metersphere.dto.DemandDTO;
|
||||
import io.metersphere.dto.IssuesDao;
|
||||
import io.metersphere.request.testcase.IssuesRequest;
|
||||
import io.metersphere.request.testcase.IssuesUpdateRequest;
|
||||
import io.metersphere.xpack.track.dto.DemandDTO;
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest;
|
||||
import io.metersphere.request.testcase.TestCaseBatchRequest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
|
|
@ -5,21 +5,16 @@ import io.metersphere.base.domain.Project;
|
|||
import io.metersphere.commons.constants.IssuesManagePlatform;
|
||||
import io.metersphere.commons.constants.IssuesStatus;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.BeanUtils;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.JSON;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.constants.AttachmentSyncType;
|
||||
import io.metersphere.commons.utils.*;
|
||||
import io.metersphere.xpack.track.dto.*;
|
||||
import io.metersphere.dto.*;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.request.testcase.IssuesRequest;
|
||||
import io.metersphere.request.testcase.IssuesUpdateRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest;
|
||||
import io.metersphere.service.SystemParameterService;
|
||||
import io.metersphere.service.issue.client.TapdClient;
|
||||
import io.metersphere.service.issue.domain.PlatformUser;
|
||||
import io.metersphere.service.issue.domain.tapd.TapdBug;
|
||||
import io.metersphere.service.issue.domain.tapd.TapdConfig;
|
||||
import io.metersphere.service.issue.domain.tapd.TapdGetIssueResponse;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
|
@ -40,6 +35,11 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
|||
setConfig();
|
||||
}
|
||||
|
||||
// xpack 反射调用
|
||||
public TapdClient getTapdClient() {
|
||||
return tapdClient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IssuesDao> getIssue(IssuesRequest issuesRequest) {
|
||||
issuesRequest.setPlatform(key);
|
||||
|
@ -211,7 +211,7 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
|||
Map bug = (Map) issue.get("Bug");
|
||||
String platformId = bug.get("id").toString();
|
||||
String id = idMap.get(platformId);
|
||||
IssuesWithBLOBs updateIssue = getUpdateIssue(issuesMapper.selectByPrimaryKey(id), bug, statusMap);
|
||||
IssuesWithBLOBs updateIssue = getUpdateIssue(issuesMapper.selectByPrimaryKey(id), bug);
|
||||
updateIssue.setId(id);
|
||||
updateIssue.setCustomFields(syncIssueCustomField(updateIssue.getCustomFields(), bug));
|
||||
customFieldMap.put(id, baseCustomFieldService.getCustomFieldResourceDTO(updateIssue.getCustomFields()));
|
||||
|
@ -232,7 +232,7 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
|||
customFieldIssuesService.batchEditFields(customFieldMap);
|
||||
}
|
||||
|
||||
protected IssuesWithBLOBs getUpdateIssue(IssuesWithBLOBs issue, Map bug, Map<String, String> statusMap) {
|
||||
public IssuesWithBLOBs getUpdateIssue(IssuesWithBLOBs issue, Map bug) {
|
||||
if (issue == null) {
|
||||
issue = new IssuesWithBLOBs();
|
||||
issue.setCustomFields(defaultCustomFields);
|
||||
|
@ -244,6 +244,10 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
|||
return issue;
|
||||
}
|
||||
|
||||
public IssuesWithBLOBs getUpdateIssue(Map bug) {
|
||||
return getUpdateIssue(null, bug);
|
||||
}
|
||||
|
||||
private void parseIssue(IssuesWithBLOBs issue, Map bug) {
|
||||
TapdBug bugObj = JSON.parseObject(JSON.toJSONString(bug), TapdBug.class);
|
||||
BeanUtils.copyBean(issue, bugObj);
|
||||
|
@ -251,11 +255,15 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
|||
issue.setDescription(htmlDesc2MsDesc(issue.getDescription()));
|
||||
issue.setCustomFields(syncIssueCustomField(issue.getCustomFields(), bug));
|
||||
issue.setPlatform(key);
|
||||
issue.setCreateTime((Long) bug.get("created"));
|
||||
issue.setUpdateTime((Long) bug.get("modified"));
|
||||
try {
|
||||
issue.setCreateTime(DateUtils.getTimestamp((String) bug.get("created")));
|
||||
issue.setUpdateTime(DateUtils.getTimestamp((String) bug.get("modified")));
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected IssuesWithBLOBs getUpdateIssue(IssuesWithBLOBs issue, Map bug, List<CustomFieldItemDTO> customField) {
|
||||
public IssuesWithBLOBs getUpdateIssue(IssuesWithBLOBs issue, Map bug, List<CustomFieldItemDTO> customField) {
|
||||
if (issue == null) {
|
||||
issue = new IssuesWithBLOBs();
|
||||
issue.setCustomFields(defaultCustomFields);
|
||||
|
|
|
@ -7,20 +7,23 @@ import io.metersphere.commons.constants.ZentaoIssuePlatformStatus;
|
|||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.JSON;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.constants.AttachmentSyncType;
|
||||
import io.metersphere.xpack.track.dto.AttachmentSyncType;
|
||||
import io.metersphere.constants.AttachmentType;
|
||||
import io.metersphere.dto.*;
|
||||
import io.metersphere.request.attachment.AttachmentRequest;
|
||||
import io.metersphere.request.testcase.IssuesRequest;
|
||||
import io.metersphere.request.testcase.IssuesUpdateRequest;
|
||||
import io.metersphere.xpack.track.dto.DemandDTO;
|
||||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesUpdateRequest;
|
||||
import io.metersphere.service.issue.client.ZentaoClient;
|
||||
import io.metersphere.service.issue.client.ZentaoGetClient;
|
||||
import io.metersphere.service.issue.domain.PlatformUser;
|
||||
import io.metersphere.xpack.track.dto.PlatformUser;
|
||||
|
||||
import io.metersphere.service.issue.domain.zentao.AddIssueResponse;
|
||||
import io.metersphere.service.issue.domain.zentao.GetIssueResponse;
|
||||
import io.metersphere.service.issue.domain.zentao.ZentaoBuild;
|
||||
import io.metersphere.service.issue.domain.zentao.ZentaoConfig;
|
||||
import io.metersphere.xpack.track.dto.PlatformStatusDTO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
|
@ -50,6 +53,10 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
"bmp", "jpg", "png", "tif", "gif", "jpeg"
|
||||
};
|
||||
|
||||
// xpack 反射调用
|
||||
public ZentaoClient getZentaoClient() {
|
||||
return zentaoClient;
|
||||
}
|
||||
|
||||
public ZentaoPlatform(IssuesRequest issuesRequest) {
|
||||
super(issuesRequest);
|
||||
|
@ -146,13 +153,19 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
return list;
|
||||
}
|
||||
|
||||
public IssuesWithBLOBs getUpdateIssues(Map bug) {
|
||||
return getUpdateIssues(null, bug);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新缺陷数据
|
||||
*
|
||||
* @param issue 待更新缺陷数据
|
||||
* @param bug 平台缺陷数据
|
||||
* @return
|
||||
*/
|
||||
public IssuesWithBLOBs getUpdateIssues(IssuesWithBLOBs issue, Map bug) {
|
||||
|
||||
GetIssueResponse.Issue bugObj = JSON.parseObject(JSON.toJSONString(bug), GetIssueResponse.Issue.class);
|
||||
String description = bugObj.getSteps();
|
||||
String steps = description;
|
||||
|
@ -362,7 +375,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
|
||||
@Override
|
||||
public List<PlatformUser> getPlatformUser() {
|
||||
String session = zentaoClient.login();;
|
||||
String session = zentaoClient.login();
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(httpHeaders);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
@ -374,7 +387,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
|
||||
LogUtil.info("zentao user " + obj);
|
||||
|
||||
List data = (List) obj.get("data");
|
||||
List data = JSON.parseArray(obj.get("data").toString());
|
||||
|
||||
List<PlatformUser> users = new ArrayList<>();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
|
|
|
@ -11,6 +11,6 @@ public class TrackCustomFieldTemplateService extends TrackProjectSettingService
|
|||
private static final String BASE_UEL = "/custom/field/template";
|
||||
|
||||
public List<CustomFieldDao> getCustomFieldByTemplateId(String templateId) {
|
||||
return microService.getForDataArray(serviceName, BASE_UEL + templateId, CustomFieldDao.class);
|
||||
return microService.getForDataArray(serviceName, BASE_UEL + "/list/" + templateId, CustomFieldDao.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package io.metersphere.service.remote.project;
|
||||
|
||||
import io.metersphere.dto.IssueTemplateDao;
|
||||
import io.metersphere.xpack.track.dto.IssueTemplateDao;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package io.metersphere.service.remote.setting;
|
||||
|
||||
import io.metersphere.base.domain.ServiceIntegration;
|
||||
import io.metersphere.request.IntegrationRequest;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class IntegrationService extends SettingService {
|
||||
|
||||
public ServiceIntegration get(IntegrationRequest request) {
|
||||
return microService.postForData(serviceName, "/service/integration/type", request,
|
||||
ServiceIntegration.class);
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ package io.metersphere.service.wapper;
|
|||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.request.testcase.IssuesRequest;
|
||||
import io.metersphere.xpack.track.dto.request.IssuesRequest;
|
||||
import io.metersphere.service.issue.platform.IssueFactory;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
|
Loading…
Reference in New Issue