use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class ComponentTest method before.
@Before
public void before() throws TException {
List<Component> componentList = new ArrayList<>();
Component component = new Component();
component.setName("Component name");
component.setDescription("Component description");
componentList.add(component);
given(this.componentServiceMock.getComponentsForUser(anyObject())).willReturn(componentList);
User user = new User();
user.setId("admin@sw360.org");
user.setEmail("admin@sw360.org");
user.setFullname("John Doe");
given(this.userServiceMock.getUserByEmail("admin@sw360.org")).willReturn(user);
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class RestControllerHelper method convertToEmbeddedComponent.
public Component convertToEmbeddedComponent(Component component) {
Component embeddedComponent = new Component();
embeddedComponent.setId(component.getId());
embeddedComponent.setName(component.getName());
embeddedComponent.setComponentType(component.getComponentType());
embeddedComponent.setType(null);
return embeddedComponent;
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class RestControllerHelper method createHalReleaseResource.
public HalResource<Release> createHalReleaseResource(Release release, boolean verbose) {
HalResource<Release> halRelease = new HalResource<>(release);
Link componentLink = linkTo(ReleaseController.class).slash("api" + ComponentController.COMPONENTS_URL + "/" + release.getComponentId()).withRel("component");
halRelease.add(componentLink);
release.setComponentId(null);
if (verbose) {
if (release.getModerators() != null) {
Set<String> moderators = release.getModerators();
this.addEmbeddedModerators(halRelease, moderators);
release.setModerators(null);
}
if (release.getAttachments() != null) {
Set<Attachment> attachments = release.getAttachments();
this.addEmbeddedAttachments(halRelease, attachments);
release.setAttachments(null);
}
if (release.getVendor() != null) {
Vendor vendor = release.getVendor();
HalResource<Vendor> vendorHalResource = this.addEmbeddedVendor(vendor.getFullname());
halRelease.addEmbeddedResource("sw360:vendors", vendorHalResource);
release.setVendor(null);
}
if (release.getMainLicenseIds() != null) {
this.addEmbeddedLicenses(halRelease, release.getMainLicenseIds());
release.setMainLicenseIds(null);
}
}
return halRelease;
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class ComponentSpecTest method before.
@Before
public void before() throws TException {
List<Component> componentList = new ArrayList<>();
List<Component> componentListByName = new ArrayList<>();
angularComponent = new Component();
angularComponent.setId("17653524");
angularComponent.setName("Angular");
angularComponent.setComponentOwner("John");
angularComponent.setDescription("Angular is a development platform for building mobile and desktop web applications.");
angularComponent.setCreatedOn("2016-12-15");
angularComponent.setCreatedBy("admin@sw360.org");
angularComponent.setComponentType(ComponentType.OSS);
angularComponent.setVendorNames(new HashSet<>(Collections.singletonList("Google")));
angularComponent.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "john@sw360.org")));
angularComponent.setOwnerAccountingUnit("4822");
angularComponent.setOwnerCountry("DE");
angularComponent.setOwnerGroup("AA BB 123 GHV2-DE");
angularComponent.setCategories(ImmutableSet.of("java", "javascript", "sql"));
angularComponent.setLanguages(ImmutableSet.of("EN", "DE"));
angularComponent.setOperatingSystems(ImmutableSet.of("Windows", "Linux"));
componentList.add(angularComponent);
componentListByName.add(angularComponent);
Component springComponent = new Component();
springComponent.setId("678dstzd8");
springComponent.setName("Spring Framework");
springComponent.setComponentOwner("Jane");
springComponent.setDescription("The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications.");
springComponent.setCreatedOn("2016-12-18");
springComponent.setCreatedBy("jane@sw360.org");
springComponent.setComponentType(ComponentType.OSS);
springComponent.setVendorNames(new HashSet<>(Collections.singletonList("Pivotal")));
springComponent.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
springComponent.setOwnerAccountingUnit("5661");
springComponent.setOwnerCountry("FR");
springComponent.setOwnerGroup("SIM-KA12");
springComponent.setCategories(ImmutableSet.of("jdbc", "java"));
springComponent.setLanguages(ImmutableSet.of("EN", "DE"));
springComponent.setOperatingSystems(ImmutableSet.of("Windows", "Linux"));
componentList.add(springComponent);
when(this.componentServiceMock.createComponent(anyObject(), anyObject())).then(invocation -> {
springComponent.setType("component");
springComponent.setCreatedOn("2016-12-20");
springComponent.setModerators(null);
springComponent.setVendorNames(null);
return springComponent;
});
given(this.componentServiceMock.getComponentsForUser(anyObject())).willReturn(componentList);
given(this.componentServiceMock.getComponentForUserById(eq("17653524"), anyObject())).willReturn(angularComponent);
given(this.componentServiceMock.searchComponentByName(eq(angularComponent.getName()))).willReturn(componentListByName);
User user = new User();
user.setId("admin@sw360.org");
user.setEmail("admin@sw360.org");
user.setFullname("John Doe");
user.setDepartment("sw360");
given(this.userServiceMock.getUserByEmail("admin@sw360.org")).willReturn(user);
List<Release> releaseList = new ArrayList<>();
Release release = new Release();
release.setId("3765276512");
release.setName("Angular 2.3.0");
release.setCpeid("cpe:/a:Google:Angular:2.3.0:");
release.setReleaseDate("2016-12-07");
release.setVersion("2.3.0");
release.setCreatedOn("2016-12-18");
release.setCreatedBy("admin@sw360.org");
release.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
release.setComponentId(springComponent.getId());
releaseList.add(release);
Release release2 = new Release();
release2.setId("3765276512");
release2.setName("Angular 2.3.1");
release2.setCpeid("cpe:/a:Google:Angular:2.3.1:");
release2.setReleaseDate("2016-12-15");
release2.setVersion("2.3.1");
release2.setCreatedOn("2016-12-18");
release2.setCreatedBy("admin@sw360.org");
release2.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
release2.setComponentId(springComponent.getId());
releaseList.add(release2);
angularComponent.setReleases(releaseList);
}
use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.
the class ModerationPortlet method renderEditViewForId.
private void renderEditViewForId(RenderRequest request, RenderResponse response, String id) throws IOException, PortletException, TException {
if (id != null) {
ModerationRequest moderationRequest = null;
User user = UserCacheHolder.getUserFromRequest(request);
try {
ModerationService.Iface client = thriftClients.makeModerationClient();
moderationRequest = client.getModerationRequestById(id);
boolean actionsAllowed = moderationRequest.getModerators().contains(user.getEmail()) && ModerationPortletUtils.isOpenModerationRequest(moderationRequest);
request.setAttribute(PortalConstants.MODERATION_ACTIONS_ALLOWED, actionsAllowed);
if (actionsAllowed) {
SessionMessages.add(request, "request_processed", "You have assigned yourself to this moderation request.");
client.setInProgress(id, user);
}
request.setAttribute(PortalConstants.MODERATION_REQUEST, moderationRequest);
addModerationBreadcrumb(request, response, moderationRequest);
} catch (TException e) {
log.error("Error fetching moderation details from backend", e);
}
if (moderationRequest != null) {
switch(moderationRequest.getDocumentType()) {
case COMPONENT:
renderComponentModeration(request, response, moderationRequest, user);
break;
case RELEASE:
VendorService.Iface vendorClient = thriftClients.makeVendorClient();
Release additions = moderationRequest.getReleaseAdditions();
if (additions.isSetVendorId()) {
additions.setVendor(vendorClient.getByID(additions.getVendorId()));
}
Release deletions = moderationRequest.getReleaseDeletions();
if (deletions.isSetVendorId()) {
deletions.setVendor(vendorClient.getByID(deletions.getVendorId()));
}
renderReleaseModeration(request, response, moderationRequest, user);
break;
case PROJECT:
renderProjectModeration(request, response, moderationRequest, user);
break;
case LICENSE:
renderLicenseModeration(request, response, moderationRequest, user);
break;
case USER:
renderUserModeration(request, response, moderationRequest, user);
break;
}
}
}
}
Aggregations