use of org.eclipse.sw360.datahandler.thrift.projects.ProjectLink in project sw360portal by sw360.
the class ProjectHandler method getLinkedProjectsById.
@Override
public List<ProjectLink> getLinkedProjectsById(String id, boolean deep, User user) throws TException {
assertId(id);
Project project = getProjectById(id, user);
return getLinkedProjectsOfProject(project, deep, user);
}
use of org.eclipse.sw360.datahandler.thrift.projects.ProjectLink in project sw360portal by sw360.
the class ProjectDatabaseHandlerTest method testGetLinkedProjects.
@Test
public void testGetLinkedProjects() throws Exception {
// we wrap the potentially infinite loop in an executor
final ExecutorService service = Executors.newSingleThreadExecutor();
Project project = handler.getProjectById("P1", user);
final Future<List<ProjectLink>> completionFuture = service.submit(() -> handler.getLinkedProjects(project, true, user));
service.shutdown();
service.awaitTermination(10, TimeUnit.SECONDS);
final List<ProjectLink> linkedProjects = completionFuture.get();
ReleaseLink releaseLinkR1A = new ReleaseLink("R1A", "vendor", "component1", "releaseA", "vendor component1 releaseA", false).setReleaseRelationship(ReleaseRelationship.REFERRED).setMainlineState(MainlineState.MAINLINE).setNodeId("R1A").setComponentType(ComponentType.OSS);
ReleaseLink releaseLinkR1B = new ReleaseLink("R1B", "vendor", "component1", "releaseB", "vendor component1 releaseB", false).setReleaseRelationship(ReleaseRelationship.REFERRED).setMainlineState(MainlineState.MAINLINE).setNodeId("R1B").setComponentType(ComponentType.OSS);
ReleaseLink releaseLinkR2A = new ReleaseLink("R2A", "vendor", "component2", "releaseA", "vendor component2 releaseA", false).setReleaseRelationship(ReleaseRelationship.REFERRED).setMainlineState(MainlineState.MAINLINE).setNodeId("R2A").setComponentType(ComponentType.COTS);
ReleaseLink releaseLinkR2B = new ReleaseLink("R2B", "vendor", "component2", "releaseB", "vendor component2 releaseB", false).setReleaseRelationship(ReleaseRelationship.REFERRED).setMainlineState(MainlineState.MAINLINE).setNodeId("R2B").setComponentType(ComponentType.COTS);
ProjectLink link3 = new ProjectLink("P3", "project3").setRelation(ProjectRelationship.REFERRED).setNodeId("P3").setParentNodeId("P2").setProjectType(ProjectType.CUSTOMER).setState(ProjectState.ACTIVE).setTreeLevel(2).setLinkedReleases(Arrays.asList(releaseLinkR2A, releaseLinkR2B)).setSubprojects(Collections.emptyList());
ProjectLink link4 = new ProjectLink("P4", "project4").setRelation(ProjectRelationship.CONTAINED).setNodeId("P4").setParentNodeId("P2").setProjectType(ProjectType.CUSTOMER).setState(ProjectState.ACTIVE).setTreeLevel(2).setSubprojects(Collections.emptyList());
ProjectLink link2 = new ProjectLink("P2", "project2").setRelation(ProjectRelationship.CONTAINED).setNodeId("P2").setParentNodeId("P1").setProjectType(ProjectType.CUSTOMER).setState(ProjectState.ACTIVE).setTreeLevel(1).setLinkedReleases(Arrays.asList(releaseLinkR1A, releaseLinkR1B)).setSubprojects(Arrays.asList(link3, link4));
ProjectLink link1 = new ProjectLink("P1", "project1").setRelation(ProjectRelationship.UNKNOWN).setNodeId("P1").setProjectType(ProjectType.CUSTOMER).setState(ProjectState.ACTIVE).setTreeLevel(0).setSubprojects(Arrays.asList(link2));
stripRandomPartsOfNodeIds(linkedProjects);
assertThat(linkedProjects, contains(link1));
}
use of org.eclipse.sw360.datahandler.thrift.projects.ProjectLink in project sw360portal by sw360.
the class ProjectPortlet method prepareSourceCodeBundle.
private void prepareSourceCodeBundle(RenderRequest request, RenderResponse response) throws IOException, PortletException {
User user = UserCacheHolder.getUserFromRequest(request);
String id = request.getParameter(PROJECT_ID);
request.setAttribute(PortalConstants.SW360_USER, user);
request.setAttribute(DOCUMENT_TYPE, SW360Constants.TYPE_PROJECT);
request.setAttribute(PROJECT_LINK_TABLE_MODE, PROJECT_LINK_TABLE_MODE_SOURCE_BUNDLE);
if (id != null) {
try {
ProjectService.Iface client = thriftClients.makeProjectClient();
Project project = client.getProjectById(id, user);
request.setAttribute(PROJECT, project);
request.setAttribute(DOCUMENT_ID, id);
List<ProjectLink> mappedProjectLinks = createLinkedProjects(project, filterAndSortAttachments(SW360Constants.SOURCE_CODE_ATTACHMENT_TYPES), true, user);
request.setAttribute(PROJECT_LIST, mappedProjectLinks);
addProjectBreadcrumb(request, response, project);
} catch (TException e) {
log.error("Error fetching project from backend!", e);
setSW360SessionError(request, ErrorMessages.ERROR_GETTING_PROJECT);
}
}
}
use of org.eclipse.sw360.datahandler.thrift.projects.ProjectLink in project sw360portal by sw360.
the class ProjectPortlet method serveNewTableRowLinkedProjects.
private void serveNewTableRowLinkedProjects(ResourceRequest request, ResourceResponse response, String[] linkedIds) throws IOException, PortletException {
final User user = UserCacheHolder.getUserFromRequest(request);
List<ProjectLink> linkedProjects = new ArrayList<>();
try {
ProjectService.Iface client = thriftClients.makeProjectClient();
for (String linkedId : linkedIds) {
Project project = client.getProjectById(linkedId, user);
ProjectLink linkedProject = new ProjectLink(linkedId, project.getName());
linkedProject.setRelation(ProjectRelationship.CONTAINED);
linkedProject.setVersion(project.getVersion());
linkedProjects.add(linkedProject);
}
} catch (TException e) {
log.error("Error getting projects!", e);
throw new PortletException("cannot get projects " + Arrays.toString(linkedIds), e);
}
request.setAttribute(PROJECT_LIST, linkedProjects);
include("/html/projects/ajax/linkedProjectsAjax.jsp", request, response, PortletRequest.RESOURCE_PHASE);
}
Aggregations