Skip to content

Commit 5eb295e

Browse files
Farooq-Fateh-AftabGMishx
authored andcommitted
feat(rest): Get license clearing counts based on clearing status
1 parent 9073eaa commit 5eb295e

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/project/ProjectController.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2927,6 +2927,39 @@ public void getlicenseClearingCount(
29272927
}
29282928
}
29292929

2930+
@Operation(
2931+
description = "Get license clearing details counts for `Clearing Detail` field " +
2932+
"at Administration tab of project detail page.",
2933+
tags = {"Projects"}
2934+
)
2935+
@RequestMapping(value = PROJECTS_URL + "/{id}/clearingDetailsCount", method = RequestMethod.GET)
2936+
public void getlicenseClearingDetailsCount(
2937+
HttpServletResponse response ,
2938+
@Parameter(description = "Project ID", example = "376521")
2939+
@PathVariable("id") String id
2940+
) throws TException {
2941+
User sw360User = restControllerHelper.getSw360UserFromAuthentication();
2942+
restControllerHelper.throwIfSecurityUser(sw360User);
2943+
Project sw360Project = projectService.getProjectForUserById(id, sw360User);
2944+
2945+
Project proj = projectService.getClearingInfo(sw360Project, sw360User);
2946+
ReleaseClearingStateSummary clearingInfo = proj.getReleaseClearingStateSummary();
2947+
int releaseCount = clearingInfo.newRelease + clearingInfo.sentToClearingTool + clearingInfo.underClearing + clearingInfo.reportAvailable + clearingInfo.approved;
2948+
2949+
try {
2950+
JsonObject row = new JsonObject();
2951+
row.addProperty("newClearing",clearingInfo.newRelease);
2952+
row.addProperty("underClearing",clearingInfo.underClearing);
2953+
row.addProperty("sentToClearingTool",clearingInfo.sentToClearingTool);
2954+
row.addProperty("reportAvailable",clearingInfo.reportAvailable);
2955+
row.addProperty("approved",clearingInfo.approved);
2956+
row.addProperty("totalReleases", releaseCount);
2957+
response.getWriter().write(row.toString());
2958+
} catch (IOException e) {
2959+
throw new SW360Exception(e.getMessage());
2960+
}
2961+
}
2962+
29302963
@Operation(
29312964
description = "Get license obligations data from license database.",
29322965
tags = {"Projects"}

rest/resource-server/src/test/java/org/eclipse/sw360/rest/resourceserver/restdocs/ProjectSpecTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2477,6 +2477,24 @@ public void should_document_get_license_clearing_information() throws Exception
24772477
)));
24782478
}
24792479

2480+
@Test
2481+
public void should_document_get_license_clearing_details_count() throws Exception {
2482+
this.mockMvc.perform(get("/api/projects/" + project.getId()+ "/clearingDetailsCount")
2483+
.header("Authorization", TestHelper.generateAuthHeader(testUserId, testUserPassword))
2484+
.accept(MediaTypes.HAL_JSON)
2485+
.contentType(MediaTypes.HAL_JSON))
2486+
.andExpect(status().isOk())
2487+
.andDo(this.documentationHandler.document(
2488+
responseFields(
2489+
fieldWithPath("newClearing").description("Number of new releases for clearing"),
2490+
fieldWithPath("underClearing").description("Number of releases under clearing"),
2491+
fieldWithPath("sentToClearingTool").description("Number of releases sent to clearing tool"),
2492+
fieldWithPath("reportAvailable").description("Number of releases with report available"),
2493+
fieldWithPath("approved").description("Number of approved license clearing state"),
2494+
fieldWithPath("totalReleases").description("Total count of releases of a project including sub-projects releases")
2495+
)));
2496+
}
2497+
24802498
@Test
24812499
public void should_document_create_summary_administration() throws Exception {
24822500
mockMvc.perform(get("/api/projects/" + project.getId()+ "/summaryAdministration")

0 commit comments

Comments
 (0)