use of org.eclipse.sw360.datahandler.thrift.projects.ProjectWithReleaseRelationTuple in project sw360portal by sw360.
the class ProjectDatabaseHandlerTest method testReleaseIdToProjects.
@Test
public void testReleaseIdToProjects() throws Exception {
Project p1 = handler.getProjectById("P1", user1);
p1.setLinkedProjects(ImmutableMap.<String, ProjectRelationship>builder().put("P2", ProjectRelationship.CONTAINED).build());
handler.updateProject(p1, user1);
Project p2 = handler.getProjectById("P2", user2);
SetMultimap<String, ProjectWithReleaseRelationTuple> releaseIdToProjects = handler.releaseIdToProjects(p1, user1);
Set<String> releaseIds = releaseIdToProjects.keySet();
assertThat(releaseIds, containsInAnyOrder("r1", "r2", "r3", "r4", "r5", "r6"));
assertThat(releaseIdToProjects.get("r1"), containsInAnyOrder(createTuple(p1), createTuple(p2)));
assertThat(releaseIdToProjects.get("r2"), containsInAnyOrder(createTuple(p1), createTuple(p2)));
assertThat(releaseIdToProjects.get("r3"), containsInAnyOrder(createTuple(p1), createTuple(p2)));
assertThat(releaseIdToProjects.get("r4"), containsInAnyOrder(createTuple(p1)));
assertThat(releaseIdToProjects.get("r5"), containsInAnyOrder(createTuple(p1)));
assertThat(releaseIdToProjects.get("r6"), containsInAnyOrder(createTuple(p1)));
}
use of org.eclipse.sw360.datahandler.thrift.projects.ProjectWithReleaseRelationTuple in project sw360portal by sw360.
the class ProjectDatabaseHandler method releaseIdToProjects.
private void releaseIdToProjects(Project project, User user, Set<String> visitedProjectIds, Multimap<String, ProjectWithReleaseRelationTuple> releaseIdToProjects) throws SW360Exception {
if (nothingTodo(project, visitedProjectIds))
return;
nullToEmptyMap(project.getReleaseIdToUsage()).forEach((releaseId, relation) -> {
releaseIdToProjects.put(releaseId, new ProjectWithReleaseRelationTuple(project, relation));
});
Map<String, ProjectRelationship> linkedProjects = project.getLinkedProjects();
if (linkedProjects != null) {
for (String projectId : linkedProjects.keySet()) {
if (visitedProjectIds.contains(projectId))
continue;
Project linkedProject = getProjectById(projectId, user);
releaseIdToProjects(linkedProject, user, visitedProjectIds, releaseIdToProjects);
}
}
}
use of org.eclipse.sw360.datahandler.thrift.projects.ProjectWithReleaseRelationTuple in project sw360portal by sw360.
the class ProjectDatabaseHandler method getReleaseClearingStatuses.
public List<ReleaseClearingStatusData> getReleaseClearingStatuses(String projectId, User user) throws SW360Exception {
Project project = getProjectById(projectId, user);
SetMultimap<String, ProjectWithReleaseRelationTuple> releaseIdsToProject = releaseIdToProjects(project, user);
List<Release> releasesById = componentDatabaseHandler.getFullReleases(releaseIdsToProject.keySet());
Map<String, Component> componentsById = ThriftUtils.getIdMap(componentDatabaseHandler.getComponentsShort(releasesById.stream().map(Release::getComponentId).collect(Collectors.toSet())));
List<ReleaseClearingStatusData> releaseClearingStatuses = new ArrayList<>();
for (Release release : releasesById) {
List<String> projectNames = new ArrayList<>();
List<String> mainlineStates = new ArrayList<>();
for (ProjectWithReleaseRelationTuple projectWithReleaseRelation : releaseIdsToProject.get(release.getId())) {
projectNames.add(printName(projectWithReleaseRelation.getProject()));
mainlineStates.add(ThriftEnumUtils.enumToString(projectWithReleaseRelation.getRelation().getMainlineState()));
if (projectNames.size() > 3) {
projectNames.add("...");
mainlineStates.add("...");
break;
}
}
releaseClearingStatuses.add(new ReleaseClearingStatusData(release).setProjectNames(joinStrings(projectNames)).setMainlineStates(joinStrings(mainlineStates)).setComponentType(componentsById.get(release.getComponentId()).getComponentType()));
}
return releaseClearingStatuses;
}
Aggregations