Skip to content

Commit 2530cba

Browse files
authored
Merge pull request #34 from PublicisSapient/feature/DTS-45109-Rally-Implementation-v1-GP
DTS-45109: sonar issue fix and code refracting
2 parents 00c1eea + 8ef5c58 commit 2530cba

24 files changed

+2313
-670
lines changed

rally/src/main/java/com/publicissapient/kpidashboard/rally/constant/RallyConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public final class RallyConstants {
4949
public static final String NAME = "name";
5050
public static final String ERROR_NOTIFICATION_SUBJECT_KEY = "errorInJiraProcessor";
5151
public static final String ERROR_MAIL_TEMPLATE_KEY = "Error_In_Jira_Processor";
52+
public static final String HIERARCHY_REVISION_HISTORY = "HierarchyRevisionHistory";
5253

5354
static {
5455
ISSUE_FIELD_SET.add("*all,-attachment,-worklog,-comment,-votes,-watches");
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*******************************************************************************
2+
* Copyright 2014 CapitalOne, LLC.
3+
* Further development Copyright 2022 Sapient Corporation.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
******************************************************************************/
18+
package com.publicissapient.kpidashboard.rally.controller;
19+
20+
import org.springframework.beans.factory.annotation.Autowired;
21+
import org.springframework.http.ResponseEntity;
22+
import org.springframework.web.bind.annotation.GetMapping;
23+
import org.springframework.web.bind.annotation.RequestMapping;
24+
import org.springframework.web.bind.annotation.RequestParam;
25+
import org.springframework.web.bind.annotation.RestController;
26+
27+
import com.publicissapient.kpidashboard.rally.model.ReleaseDataResponse;
28+
import com.publicissapient.kpidashboard.rally.service.ReleaseDataService;
29+
30+
import lombok.extern.slf4j.Slf4j;
31+
32+
/**
33+
* REST API controller for fetching Rally Release data for frequency calculation
34+
*/
35+
@RestController
36+
@RequestMapping("/rally/release")
37+
@Slf4j
38+
public class ReleaseFrequencyController {
39+
40+
private final ReleaseDataService releaseDataService;
41+
42+
/**
43+
* Constructor for dependency injection
44+
*
45+
* @param releaseDataService Service for handling release data operations
46+
*/
47+
@Autowired
48+
public ReleaseFrequencyController(ReleaseDataService releaseDataService) {
49+
this.releaseDataService = releaseDataService;
50+
}
51+
52+
/**
53+
* Fetch release data from Rally for a project
54+
* This endpoint fetches release data from Rally and stores it in the project_release collection
55+
*
56+
* @param projectId Project ID
57+
* @return Response containing success message or error details
58+
*/
59+
@GetMapping("/fetch-data")
60+
public ResponseEntity<ReleaseDataResponse> fetchReleaseData(@RequestParam String projectId) {
61+
log.info("Received request to fetch release data for project ID: {}", projectId);
62+
return releaseDataService.fetchAndProcessReleaseData(projectId);
63+
}
64+
}

rally/src/main/java/com/publicissapient/kpidashboard/rally/jobs/RallyProcessorJob.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public class RallyProcessorJob {
6464
@Autowired
6565
SprintReportTasklet sprintReportTasklet;
6666

67+
@Autowired
68+
SprintReportDataTasklet sprintReportDataTasklet;
69+
6770
@Autowired
6871
ScrumReleaseDataTasklet scrumReleaseDataTasklet;
6972

@@ -110,7 +113,7 @@ private Step scrumReleaseDataStep() {
110113
@Bean
111114
public Job fetchIssueScrumRqlJob(@Qualifier("fetchIssueSprintJob") Job fetchIssueScrumRqlJob) {
112115
return builderFactory.getJobBuilder("FetchIssueScrum RQL Job", jobRepository).incrementer(new RunIdIncrementer())
113-
.start(metaDataStep()).next(processProjectStatusStep()).next(fetchIssueScrumRqlChunkStep())
116+
.start(metaDataStep()).next(processProjectStatusStep()).next(fetchIssueScrumRqlChunkStep()).next(fetchSprintDataStep())
114117
.next(scrumReleaseDataStep()).listener(jobListenerScrum).build();
115118
}
116119

@@ -120,6 +123,10 @@ private Step fetchIssueScrumRqlChunkStep() {
120123
.<ReadData, CompositeResult>chunk(getChunkSize(), this.transactionManager).reader(issueRqlReader)
121124
.processor(issueScrumProcessor).writer(issueScrumWriter).listener(jiraIssueJqlWriterListener).build();
122125
}
126+
private Step fetchSprintDataStep() {
127+
return builderFactory.getStepBuilder("Fetch Sprint Data", jobRepository)
128+
.tasklet(sprintReportDataTasklet, transactionManager).listener(jobStepProgressListener).build();
129+
}
123130

124131
/**
125132
* This method is setup job for fetching sprint details based on sprint id

rally/src/main/java/com/publicissapient/kpidashboard/rally/model/HierarchicalRequirement.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919
package com.publicissapient.kpidashboard.rally.model;
2020

2121
import com.fasterxml.jackson.annotation.JsonProperty;
22+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
2223
import lombok.Data;
2324

2425
import java.util.ArrayList;
26+
import java.util.HashMap;
2527
import java.util.List;
28+
import java.util.Map;
29+
2630
/**
2731
* @author girpatha
2832
*/
@@ -58,5 +62,10 @@ public class HierarchicalRequirement {
5862
private String objectID;
5963
private String currentIteration;
6064
private List<String> pastIterations; // Track spillover
65+
@JsonProperty("RevisionHistory")
66+
private Map<String, String> revisionHistory;
67+
@JsonProperty("Description")
68+
private String description;
69+
private Map<String, Object> additionalProperties = new HashMap<>();
6170
// Add a field to store linked defects
6271
}

rally/src/main/java/com/publicissapient/kpidashboard/rally/model/RallyReleaseResponse.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
package com.publicissapient.kpidashboard.rally.model;
22

3-
import org.joda.time.DateTime;
43
import java.util.List;
4+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
55
import com.fasterxml.jackson.annotation.JsonProperty;
66
import lombok.Data;
77
/**
88
* @author girpatha
99
*/
1010
@Data
11+
@JsonIgnoreProperties(ignoreUnknown = true)
1112
public class RallyReleaseResponse {
1213
@JsonProperty("QueryResult")
1314
private QueryResult queryResult;
1415

1516
@Data
17+
@JsonIgnoreProperties(ignoreUnknown = true)
1618
public static class QueryResult {
1719
@JsonProperty("_rallyAPIMajor")
1820
private String rallyAPIMajor;
@@ -33,6 +35,7 @@ public static class QueryResult {
3335
}
3436

3537
@Data
38+
@JsonIgnoreProperties(ignoreUnknown = true)
3639
public static class Release {
3740
@JsonProperty("_rallyAPIMajor")
3841
private String rallyAPIMajor;
@@ -53,9 +56,9 @@ public static class Release {
5356
@JsonProperty("Description")
5457
private String description;
5558
@JsonProperty("ReleaseStartDate")
56-
private DateTime releaseStartDate;
59+
private String releaseStartDate;
5760
@JsonProperty("ReleaseDate")
58-
private DateTime releaseDate;
61+
private String releaseDate;
5962
@JsonProperty("State")
6063
private String state;
6164
@JsonProperty("Project")
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*******************************************************************************
2+
* Copyright 2014 CapitalOne, LLC.
3+
* Further development Copyright 2022 Sapient Corporation.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
******************************************************************************/
18+
package com.publicissapient.kpidashboard.rally.model;
19+
20+
import lombok.AllArgsConstructor;
21+
import lombok.Builder;
22+
import lombok.Data;
23+
import lombok.NoArgsConstructor;
24+
25+
/**
26+
* Response model for release data operations
27+
*/
28+
@Data
29+
@Builder
30+
@NoArgsConstructor
31+
@AllArgsConstructor
32+
public class ReleaseDataResponse {
33+
34+
private String message;
35+
private String error;
36+
private boolean success;
37+
38+
/**
39+
* Create a success response
40+
*
41+
* @param message Success message
42+
* @return ReleaseDataResponse with success flag set to true
43+
*/
44+
public static ReleaseDataResponse success(String message) {
45+
return ReleaseDataResponse.builder()
46+
.message(message)
47+
.success(true)
48+
.build();
49+
}
50+
51+
/**
52+
* Create an error response
53+
*
54+
* @param errorMessage Error message
55+
* @return ReleaseDataResponse with success flag set to false
56+
*/
57+
public static ReleaseDataResponse error(String errorMessage) {
58+
return ReleaseDataResponse.builder()
59+
.error(errorMessage)
60+
.success(false)
61+
.build();
62+
}
63+
}

rally/src/main/java/com/publicissapient/kpidashboard/rally/processor/IssueScrumProcessor.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
package com.publicissapient.kpidashboard.rally.processor;
1919

2020
import java.io.IOException;
21+
import java.util.ArrayList;
22+
import java.util.List;
2123
import java.util.Set;
2224

2325
import com.publicissapient.kpidashboard.rally.model.CompositeResult;
26+
import com.publicissapient.kpidashboard.rally.model.HierarchicalRequirement;
2427
import com.publicissapient.kpidashboard.rally.model.ReadData;
2528
import org.apache.commons.collections4.CollectionUtils;
2629
import org.apache.commons.lang3.StringUtils;
@@ -59,14 +62,17 @@ public class IssueScrumProcessor implements ItemProcessor<ReadData, CompositeRes
5962
@Autowired
6063
private SprintDataProcessor sprintDataProcessor;
6164

65+
List<HierarchicalRequirement> hierarchicalRequirements = new ArrayList<>();
66+
6267
/*
6368
* (non-Javadoc)
6469
*
6570
* @see org.springframework.batch.item.ItemProcessor#process(java.lang.Object)
6671
*/
6772
@Override
6873
public CompositeResult process(ReadData readData) throws Exception {
69-
log.debug("Scrum processing started for the project : {}", readData.getProjectConfFieldMapping().getProjectName());
74+
log.debug("Scrum processing started for the project : {}",
75+
readData.getProjectConfFieldMapping().getProjectName());
7076
CompositeResult compositeResult = null;
7177
JiraIssue jiraIssue = convertIssueToJiraIssue(readData);
7278
if (null != jiraIssue) {

0 commit comments

Comments
 (0)