Skip to content

Commit

Permalink
Merge pull request #2648 from siemens/fix/build/reports
Browse files Browse the repository at this point in the history
fix(build): add the missing excludeReleaseVersion

reviewed-by: smruti.sahoo@siemens.com
tested-by: smruti.sahoo@siemens.com
  • Loading branch information
smrutis1 authored Oct 18, 2024
2 parents 500514b + 3f10b68 commit 4fec69e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public void getProjectReport(
@RequestParam(value = "projectId", required = false) String projectId,
@Parameter(description = "Module name.", schema = @Schema(allowableValues = {PROJECTS, COMPONENTS}))
@RequestParam(value = "module", required = true) String module,
@Parameter(description = "Exclude release version from the license info file")
@RequestParam(value = "excludeReleaseVersion", required = false, defaultValue = "false") boolean excludeReleaseVersion,
HttpServletRequest request,
HttpServletResponse response
) throws TException {
Expand All @@ -99,17 +101,17 @@ public void getProjectReport(
switch (module) {
case PROJECTS:
getProjectReports(withLinkedReleases, SW360Constants.MAIL_REQUEST_FOR_PROJECT_REPORT, response,
request, sw360User, module, projectId);
request, sw360User, module, projectId, excludeReleaseVersion);
break;
case COMPONENTS:
getComponentsReports(withLinkedReleases, SW360Constants.MAIL_REQUEST_FOR_COMPONENT_REPORT, response,
request, sw360User, module);
request, sw360User, module, excludeReleaseVersion);
break;
case LICENSES:
getLicensesReports(request, response, sw360User, module);
getLicensesReports(request, response, sw360User, module, excludeReleaseVersion);
break;
case LICENSE_INFO:
getLicensesInfoReports(request, response, sw360User, module, projectId);
getLicensesInfoReports(request, response, sw360User, module, projectId, excludeReleaseVersion);
break;
default:
break;
Expand All @@ -123,54 +125,58 @@ public void getProjectReport(
}

private void getProjectReports(boolean withLinkedReleases, boolean mailRequest, HttpServletResponse response,
HttpServletRequest request, User sw360User, String module, String projectId) throws TException {
HttpServletRequest request, User sw360User, String module, String projectId, boolean excludeReleaseVersion) throws TException {
try {
if (mailRequest) {
sw360ReportService.getUploadedProjectPath(sw360User, withLinkedReleases,getBaseUrl(request), projectId);
JsonObject responseJson = new JsonObject();
responseJson.addProperty("response", "The downloaded report link will be send to the end user.");
response.getWriter().write(responseJson.toString());
} else {
downloadExcelReport(withLinkedReleases, request, response, sw360User, module, projectId);
downloadExcelReport(withLinkedReleases, request, response, sw360User, module, projectId, excludeReleaseVersion);
}
} catch (Exception e) {
throw new TException(e.getMessage());
}
}

private void getComponentsReports(boolean withLinkedReleases, boolean mailRequest, HttpServletResponse response,
HttpServletRequest request, User sw360User, String module) throws TException {
HttpServletRequest request, User sw360User, String module, boolean excludeReleaseVersion) throws TException {
try {
if (mailRequest) {
sw360ReportService.getUploadedComponentPath(sw360User, withLinkedReleases, getBaseUrl(request));
JsonObject responseJson = new JsonObject();
responseJson.addProperty("response", "Component report download link will get send to the end user.");
response.getWriter().write(responseJson.toString());
} else {
downloadExcelReport(withLinkedReleases, request, response, sw360User, module, null);
downloadExcelReport(withLinkedReleases, request, response, sw360User, module, null, excludeReleaseVersion);
}
} catch (Exception e) {
throw new TException(e.getMessage());
}
}

private void getLicensesReports(HttpServletRequest request, HttpServletResponse response, User sw360User, String module) throws TException {
private void getLicensesReports(HttpServletRequest request, HttpServletResponse response,
User sw360User, String module, boolean excludeReleaseVersion) throws TException {
try {
downloadExcelReport(false, request, response, sw360User, module, null);
downloadExcelReport(false, request, response, sw360User, module, null, excludeReleaseVersion);
} catch (Exception e) {
throw new TException(e.getMessage());
}
}

private void getLicensesInfoReports(HttpServletRequest request, HttpServletResponse response, User sw360User, String module, String projectId) throws TException {
private void getLicensesInfoReports(HttpServletRequest request, HttpServletResponse response, User sw360User,
String module, String projectId, boolean excludeReleaseVersion) throws TException {
try {
downloadExcelReport(false, request, response, sw360User, module, projectId);
downloadExcelReport(false, request, response, sw360User, module, projectId, excludeReleaseVersion);
}catch (Exception e) {
throw new TException(e.getMessage());
}
}

private void downloadExcelReport(boolean withLinkedReleases, HttpServletRequest request , HttpServletResponse response, User user, String module, String projectId)
private void downloadExcelReport(boolean withLinkedReleases, HttpServletRequest request,
HttpServletResponse response, User user, String module,
String projectId, boolean excludeReleaseVersion)
throws TException {
try {
ByteBuffer buffer = null;
Expand All @@ -189,7 +195,7 @@ private void downloadExcelReport(boolean withLinkedReleases, HttpServletRequest
final String variant = request.getParameter("variant");
final String template = request.getParameter("template");
final String externalIds = request.getParameter("externalIds");
buffer = sw360ReportService.getLicenseInfoBuffer(user, projectId, generatorClassName, variant, template, externalIds);
buffer = sw360ReportService.getLicenseInfoBuffer(user, projectId, generatorClassName, variant, template, externalIds, excludeReleaseVersion);
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ public void sendComponentExportSpreadsheetSuccessMail(String emailURL, String em
componentclient.sendExportSpreadsheetSuccessMail(emailURL, email);
}

public ByteBuffer getLicenseInfoBuffer(User sw360User, String id, String generatorClassName, String variant, String template, String externalIds) throws TException {
public ByteBuffer getLicenseInfoBuffer(User sw360User, String id, String generatorClassName,
String variant, String template, String externalIds,
boolean excludeReleaseVersion) throws TException {
final Project sw360Project = projectService.getProjectForUserById(id, sw360User);

List<ProjectLink> mappedProjectLinks = projectService.createLinkedProjects(sw360Project,
Expand Down Expand Up @@ -217,7 +219,7 @@ public ByteBuffer getLicenseInfoBuffer(User sw360User, String id, String generat
}
final LicenseInfoFile licenseInfoFile = licenseInfoService.getLicenseInfoFile(sw360Project, sw360User,
outputGeneratorClassNameWithVariant, selectedReleaseAndAttachmentIds, excludedLicensesPerAttachments,
externalIds, fileName);
externalIds, fileName, excludeReleaseVersion);
return licenseInfoFile.bufferForGeneratedOutput();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1333,13 +1333,16 @@ public void should_document_get_component_report() throws Exception{
.queryParam("withlinkedreleases", "true")
.queryParam("mimetype", "xlsx")
.queryParam("module", "components")
.queryParam("excludeReleaseVersion", "false")
.accept(MediaTypes.HAL_JSON))
.andExpect(status().isOk())
.andDo(this.documentationHandler.document(
queryParameters(
parameterWithName("withlinkedreleases").description("Projects with linked releases. Possible values are `<true|false>`"),
parameterWithName("mimetype").description("Projects download format. Possible values are `<xls|xlsx>`"),
parameterWithName("module").description("module represent the project or component. Possible values are `<components|projects>`")
parameterWithName("module").description("module represent the project or component. Possible values are `<components|projects>`"),
parameterWithName("excludeReleaseVersion").description("Exclude version of the components from the generated license info file. "
+ "Possible values are `<true|false>`")
)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2357,13 +2357,17 @@ public void should_document_get_project_report() throws Exception {
.queryParam("withlinkedreleases", "true")
.queryParam("mimetype", "xlsx")
.queryParam("module", "projects")
.queryParam("excludeReleaseVersion", "false")
.accept(MediaTypes.HAL_JSON))
.andExpect(status().isOk())
.andDo(this.documentationHandler.document(
queryParameters(
parameterWithName("withlinkedreleases").description("Projects with linked releases. Possible values are `<true|false>`"),
parameterWithName("mimetype").description("Projects download format. Possible values are `<xls|xlsx>`"),
parameterWithName("module").description("module represent the project or component. Possible values are `<components|projects>`"))
parameterWithName("module").description("module represent the project or component. Possible values are `<components|projects>`"),
parameterWithName("excludeReleaseVersion").description("Exclude version of the components from the generated license info file. "
+ "Possible values are `<true|false>`")
)
));
}

Expand All @@ -2375,15 +2379,18 @@ public void should_document_get_project_licenseclearing_spreadsheet() throws Exc
.queryParam("mimetype", "xlsx")
.queryParam("module", "projects")
.queryParam("projectId", project.getId())
.queryParam("excludeReleaseVersion", "false")
.accept(MediaTypes.HAL_JSON))
.andExpect(status().isOk())
.andDo(this.documentationHandler.document(
queryParameters(
parameterWithName("withlinkedreleases").description("Projects with linked releases. Possible values are `<true|false>`"),
parameterWithName("mimetype").description("Projects download format. Possible values are `<xls|xlsx>`"),
parameterWithName("module").description("module represent the project or component. Possible values are `<components|projects>`"),
parameterWithName("projectId").description("Id of a project"))
));
parameterWithName("projectId").description("Id of a project"),
parameterWithName("excludeReleaseVersion").description("Exclude version of the components from the generated license info file. "
+ "Possible values are `<true|false>`")
)));
}

@Test
Expand Down

0 comments on commit 4fec69e

Please sign in to comment.