1818
1919package com .publicissapient .kpidashboard .zephyr .processor .service .impl ;
2020
21- import java .util .ArrayList ;
22- import java .util .Arrays ;
23- import java .util .HashMap ;
24- import java .util .HashSet ;
25- import java .util .List ;
26- import java .util .Map ;
27- import java .util .Set ;
28-
29- import org .apache .commons .collections4 .CollectionUtils ;
30- import org .apache .commons .lang3 .StringUtils ;
31- import org .bson .types .ObjectId ;
32- import org .joda .time .format .DateTimeFormat ;
33- import org .joda .time .format .DateTimeFormatter ;
34- import org .springframework .beans .factory .annotation .Autowired ;
35- import org .springframework .stereotype .Component ;
36-
3721import com .publicissapient .kpidashboard .common .constant .CommonConstant ;
3822import com .publicissapient .kpidashboard .common .constant .NormalizedJira ;
3923import com .publicissapient .kpidashboard .common .constant .ProcessorConstants ;
40- import com .publicissapient .kpidashboard .common .model .application .AccountHierarchy ;
41- import com .publicissapient .kpidashboard .common .model .application .KanbanAccountHierarchy ;
24+ import com .publicissapient .kpidashboard .common .model .application .OrganizationHierarchy ;
25+ import com .publicissapient .kpidashboard .common .model .application .ProjectBasicConfig ;
4226import com .publicissapient .kpidashboard .common .model .processortool .ProcessorToolConnection ;
4327import com .publicissapient .kpidashboard .common .model .zephyr .TestCaseDetails ;
4428import com .publicissapient .kpidashboard .common .model .zephyr .ZephyrTestCaseDTO ;
45- import com .publicissapient .kpidashboard .common .repository .application .AccountHierarchyRepository ;
4629import com .publicissapient .kpidashboard .common .repository .application .KanbanAccountHierarchyRepository ;
30+ import com .publicissapient .kpidashboard .common .repository .application .OrganizationHierarchyRepository ;
31+ import com .publicissapient .kpidashboard .common .repository .application .ProjectBasicConfigRepository ;
4732import com .publicissapient .kpidashboard .common .repository .zephyr .TestCaseDetailsRepository ;
4833import com .publicissapient .kpidashboard .zephyr .processor .service .ZephyrDBService ;
4934import com .publicissapient .kpidashboard .zephyr .repository .ZephyrProcessorRepository ;
50-
5135import lombok .extern .slf4j .Slf4j ;
36+ import org .apache .commons .collections4 .CollectionUtils ;
37+ import org .apache .commons .lang3 .StringUtils ;
38+ import org .bson .types .ObjectId ;
39+ import org .joda .time .format .DateTimeFormat ;
40+ import org .joda .time .format .DateTimeFormatter ;
41+ import org .springframework .beans .factory .annotation .Autowired ;
42+ import org .springframework .stereotype .Component ;
43+
44+ import java .util .ArrayList ;
45+ import java .util .Arrays ;
46+ import java .util .HashMap ;
47+ import java .util .HashSet ;
48+ import java .util .List ;
49+ import java .util .Map ;
50+ import java .util .Optional ;
51+ import java .util .Set ;
5252
5353@ Component
5454@ Slf4j
@@ -61,12 +61,10 @@ public class ZephyrDBServiceImpl implements ZephyrDBService {
6161
6262 @ Autowired
6363 private ZephyrProcessorRepository zephyrProcessorRepository ;
64-
6564 @ Autowired
66- private KanbanAccountHierarchyRepository kanbanAccountHierarchyRepo ;
67-
65+ private ProjectBasicConfigRepository projectBasicConfigRepository ;
6866 @ Autowired
69- private AccountHierarchyRepository accountHierarchyRepository ;
67+ private OrganizationHierarchyRepository organizationHierarchyRepository ;
7068
7169 @ Autowired
7270 private TestCaseDetailsRepository testCaseDetailsRepository ;
@@ -85,13 +83,10 @@ public void processTestCaseInfoToDB(final List<ZephyrTestCaseDTO> testCases,
8583 ObjectId zephyrProcessorId = zephyrProcessorRepository .findByProcessorName (ProcessorConstants .ZEPHYR ).getId ();
8684 if (null != zephyrProcessorId ) {
8785 List <TestCaseDetails > testCaseDetailsList = new ArrayList <>();
88- Map <String , AccountHierarchy > hierarchyDataMapForScrum = new HashMap <>();
89- Map <String , KanbanAccountHierarchy > hierarchyDataMapForKanban = new HashMap <>();
90-
91- if (isKanban ) {
92- prepareAccountInfoForKanban (processorToolConnection , hierarchyDataMapForKanban );
93- } else {
94- prepareAccountInfoForScrum (processorToolConnection , hierarchyDataMapForScrum );
86+ Map <String , OrganizationHierarchy > hierarchyDataMapForScrumAndKanban = new HashMap <>();
87+ Optional <ProjectBasicConfig > projectBasicConfig = projectBasicConfigRepository .findById (processorToolConnection .getBasicProjectConfigId ());
88+ if (projectBasicConfig .isPresent ()) {
89+ prepareAccountInfoForScrumAndKanban (projectBasicConfig .get ().getProjectNodeId (), hierarchyDataMapForScrumAndKanban );
9590 }
9691
9792 testCases .forEach (testCase -> {
@@ -100,11 +95,7 @@ public void processTestCaseInfoToDB(final List<ZephyrTestCaseDTO> testCases,
10095 TestCaseDetails testCaseDetails = getTestCaseDetail (testCase .getKey (), basicProjectId );
10196 testCaseDetails .setBasicProjectConfigId (basicProjectId );
10297 testCaseDetails .setProcessorId (zephyrProcessorId );
103- if (isKanban ) {
104- setAccountInfoForKanban (hierarchyDataMapForKanban , testCaseDetails );
105- } else {
106- setAccountInfoForScrum (hierarchyDataMapForScrum , testCaseDetails );
107- }
98+ setAccountInfoForScrumAndKanban (hierarchyDataMapForScrumAndKanban , testCaseDetails );
10899 setTestCaseDetails (processorToolConnection , testCase , testCaseDetails , isZephyrCloud );
109100 testCaseDetailsList .add (testCaseDetails );
110101 });
@@ -119,26 +110,13 @@ public void processTestCaseInfoToDB(final List<ZephyrTestCaseDTO> testCases,
119110 /**
120111 * prepare account related data for scrum
121112 *
122- * @param processorToolConnection
113+ * @param projectNodeID
123114 * @param hierarchyDataMap
124115 */
125- private void prepareAccountInfoForScrum (ProcessorToolConnection processorToolConnection ,
126- Map <String , AccountHierarchy > hierarchyDataMap ) {
127- AccountHierarchy projectInfo = accountHierarchyRepository .findByLabelNameAndBasicProjectConfigId (
128- CommonConstant .HIERARCHY_LEVEL_ID_PROJECT , processorToolConnection .getBasicProjectConfigId ()).get (0 );
129- hierarchyDataMap .put (CommonConstant .HIERARCHY_LEVEL_ID_PROJECT , projectInfo );
130- }
116+ private void prepareAccountInfoForScrumAndKanban (String projectNodeID ,
117+ Map <String , OrganizationHierarchy > hierarchyDataMap ) {
118+ OrganizationHierarchy projectInfo = organizationHierarchyRepository .findByNodeId (projectNodeID );
131119
132- /**
133- * prepare account related data for kanban
134- *
135- * @param processorToolConnection
136- * @param hierarchyDataMap
137- */
138- private void prepareAccountInfoForKanban (ProcessorToolConnection processorToolConnection ,
139- Map <String , KanbanAccountHierarchy > hierarchyDataMap ) {
140- KanbanAccountHierarchy projectInfo = kanbanAccountHierarchyRepo .findByLabelNameAndBasicProjectConfigId (
141- CommonConstant .HIERARCHY_LEVEL_ID_PROJECT , processorToolConnection .getBasicProjectConfigId ()).get (0 );
142120 hierarchyDataMap .put (CommonConstant .HIERARCHY_LEVEL_ID_PROJECT , projectInfo );
143121 }
144122
@@ -178,26 +156,13 @@ private void setTestCaseDetails(ProcessorToolConnection processorToolConnection,
178156 * @param hierarchyDataMapForScrum
179157 * @param testCaseDetails
180158 */
181- private void setAccountInfoForScrum (Map <String , AccountHierarchy > hierarchyDataMapForScrum ,
182- TestCaseDetails testCaseDetails ) {
159+ private void setAccountInfoForScrumAndKanban (Map <String , OrganizationHierarchy > hierarchyDataMapForScrum ,
160+ TestCaseDetails testCaseDetails ) {
183161 testCaseDetails .setProjectID (hierarchyDataMapForScrum .get (CommonConstant .HIERARCHY_LEVEL_ID_PROJECT ).getNodeId ());
184162 testCaseDetails
185163 .setProjectName (hierarchyDataMapForScrum .get (CommonConstant .HIERARCHY_LEVEL_ID_PROJECT ).getNodeName ());
186164 }
187165
188- /**
189- * set account info into test case details for scrum
190- *
191- * @param hierarchyDataMapForKanban
192- * @param testCaseDetails
193- */
194- private void setAccountInfoForKanban (Map <String , KanbanAccountHierarchy > hierarchyDataMapForKanban ,
195- TestCaseDetails testCaseDetails ) {
196- testCaseDetails .setProjectID (hierarchyDataMapForKanban .get (CommonConstant .HIERARCHY_LEVEL_ID_PROJECT ).getNodeId ());
197- testCaseDetails
198- .setProjectName (hierarchyDataMapForKanban .get (CommonConstant .HIERARCHY_LEVEL_ID_PROJECT ).getNodeName ());
199- }
200-
201166 /**
202167 * mapping of custom fields values to testing fields
203168 *
0 commit comments