Skip to content

Commit

Permalink
Merge pull request #2077 from toshiba/release/feat_cots-details-infor…
Browse files Browse the repository at this point in the history
…mation-in-release-response

Fix(REST): Add COTS details information when fetch a single release that has component type COTS

Reviewed by: [email protected]
Tested by: [email protected]
  • Loading branch information
ag4ums authored Aug 8, 2023
2 parents b9ae7f6 + 790c7ae commit ee2b517
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import org.eclipse.sw360.datahandler.thrift.components.Component;
import org.eclipse.sw360.datahandler.thrift.components.ComponentDTO;
import org.eclipse.sw360.datahandler.thrift.components.ComponentService;
import org.eclipse.sw360.datahandler.thrift.components.ComponentType;
import org.eclipse.sw360.datahandler.thrift.components.COTSDetails;
import org.eclipse.sw360.datahandler.thrift.packages.Package;
import org.eclipse.sw360.datahandler.thrift.components.Release;
import org.eclipse.sw360.datahandler.thrift.components.ReleaseLink;
Expand Down Expand Up @@ -318,6 +320,7 @@ public void addEmbeddedDataToHalResourceRelease(HalResource halResource, Release
addEmbeddedCreatedByToHalResourceRelease(halResource, sw360Release.getCreatedBy());
addEmbeddedModifiedByToHalResourceRelease(halResource, sw360Release.getModifiedBy());
addEmbeddedSubcribeToHalResourceRelease(halResource, sw360Release);
addEmbeddedCotsDetails(halResource, sw360Release);
}

public void addEmbeddedContributorsToHalResourceRelease(HalResource halResource, Release sw360Release) {
Expand Down Expand Up @@ -1295,4 +1298,17 @@ public ProjectDTO convertToEmbeddedProjectDTO(Project project) {
embeddedProject.setType(null);
return embeddedProject;
}

public void addEmbeddedCotsDetails(HalResource halResource, Release release) {
if (null != release.getCotsDetails() && release.getComponentType().equals(ComponentType.COTS)) {
HalResource<COTSDetails> cotsDetailsHalResource = new HalResource<>(release.getCotsDetails());
if (CommonUtils.isNotNullEmptyOrWhitespace(release.getCotsDetails().getCotsResponsible())) {
User sw360User = userService.getUserByEmail(release.getCotsDetails().getCotsResponsible());
if (null != sw360User) {
addEmbeddedUser(cotsDetailsHalResource, sw360User, "sw360:cotsResponsible");
}
}
addEmbeddedFields("sw360:cotsDetails", cotsDetailsHalResource, halResource);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void before() throws TException, IOException {
component.setDescription("Angular is a development platform for building mobile and desktop web applications.");
component.setCreatedOn("2016-12-15");
component.setCreatedBy("[email protected]");
component.setComponentType(ComponentType.OSS);
component.setComponentType(ComponentType.COTS);
component.setVendorNames(new HashSet<>(Collections.singletonList("Google")));
component.setModerators(new HashSet<>(Arrays.asList("[email protected]", "[email protected]")));
usedByComponent.add(component);
Expand Down Expand Up @@ -221,6 +221,10 @@ public void before() throws TException, IOException {
clearingInformation.setComponentClearingReportIsSet(false);
clearingInformation.setExternalUrl("https://external.url");

COTSDetails cotsDetails1 = new COTSDetails().setClearingDeadline("2016-12-18").setContainsOSS(true)
.setCotsResponsible("[email protected]").setLicenseClearingReportURL("http://licenseclearingreporturl.com")
.setOssInformationURL("http://ossinformationurl.com").setUsedLicense("MIT");

release.setId(releaseId);
owner.setReleaseId(release.getId());
release.setName("Spring Core 4.3.4");
Expand Down Expand Up @@ -250,6 +254,8 @@ public void before() throws TException, IOException {
release.setSoftwarePlatforms(new HashSet<>(Arrays.asList("Java SE", ".NET")));
release.setEccInformation(eccInformation);
release.setClearingInformation(clearingInformation);
release.setCotsDetails(cotsDetails1);
release.setComponentType(ComponentType.COTS);

Set<String> licenseIds = new HashSet<>();
licenseIds.add("MIT");
Expand Down Expand Up @@ -695,6 +701,7 @@ public void should_document_get_release() throws Exception {
subsectionWithPath("_embedded.sw360:modifiedBy").description("A release modifiedBy with email and link to their <<resources-user-get,User resource>>"),
subsectionWithPath("_embedded.sw360:createdBy").description("A release createdBy with email and link to their <<resources-user-get,User resource>>"),
subsectionWithPath("_embedded.sw360:attachments").description("An array of all release attachments and link to their <<resources-attachment-get,Attachment resource>>"),
subsectionWithPath("_embedded.sw360:cotsDetails").description("Cots details information of release has component type = COTS "),
subsectionWithPath("_links").description("<<resources-index-links,Links>> to other resources")
)));
}
Expand Down

0 comments on commit ee2b517

Please sign in to comment.