use of org.eclipse.sw360.datahandler.thrift.projects.ProjectRelationship in project sw360portal by sw360.
the class DisplayProjectChanges method renderProjectLinkList.
private void renderProjectLinkList(StringBuilder display, Map<String, ProjectRelationship> projectRelationshipMap, Set<String> projectIds, String msg, User user) {
if (projectIds.isEmpty())
return;
Map<String, ProjectRelationship> filteredMap = new HashMap<>();
for (String id : projectIds) {
filteredMap.put(id, projectRelationshipMap.get(id));
}
StringBuilder candidate = new StringBuilder();
try {
ProjectService.Iface client = new ThriftClients().makeProjectClient();
for (ProjectLink projectLink : client.getLinkedProjects(filteredMap, user)) {
candidate.append(String.format("<tr><td>%s</td><td>%s</td></tr>", projectLink.getName(), projectLink.getRelation()));
}
} catch (TException ignored) {
}
String tableContent = candidate.toString();
if (!tableContent.isEmpty()) {
display.append(String.format("<table class=\"%s\" id=\"%s%s\" >", tableClasses, idPrefix, msg));
display.append(String.format("<thead><tr><th colspan=\"2\">%s</th></tr>" + "<tr><th>Project Name</th><th>Project Relationship</th></tr></thead><tbody>", msg));
display.append(tableContent);
display.append("</tbody></table>");
}
}
use of org.eclipse.sw360.datahandler.thrift.projects.ProjectRelationship in project sw360portal by sw360.
the class ProjectDatabaseHandlerTest method setUp.
@Before
public void setUp() throws Exception {
assertTestString(dbName);
assertTestString(attachmentsDbName);
List<Project> projects = new ArrayList<>();
Project p1 = new Project().setId("P1").setName("Project1").setBusinessUnit("AB CD EF").setCreatedBy("user1").setReleaseIdToUsage(ImmutableMap.<String, ProjectReleaseRelationship>builder().put("r1", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r2", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r3", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r4", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r5", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r6", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).build());
projects.add(p1);
Project p2 = new Project().setId("P2").setName("Project2").setBusinessUnit("AB CD FE").setCreatedBy("user2").setReleaseIdToUsage(ImmutableMap.<String, ProjectReleaseRelationship>builder().put("r1", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r2", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r3", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).build());
projects.add(p2);
projects.get(1).addToContributors("user1");
projects.add(new Project().setId("P3").setName("Project3").setBusinessUnit("AB CD EF").setCreatedBy("user3"));
Project p4 = new Project().setId("P4").setName("Project4").setBusinessUnit("AB CD EF").setCreatedBy("user1").setVisbility(Visibility.PRIVATE).setReleaseIdToUsage(ImmutableMap.<String, ProjectReleaseRelationship>builder().put("r1", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r2", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).build()).setLinkedProjects(ImmutableMap.<String, ProjectRelationship>builder().put("P5", ProjectRelationship.CONTAINED).build());
projects.add(p4);
projects.add(new Project().setId("P5").setName("Project5").setBusinessUnit("AB CD EF").setCreatedBy("user1"));
List<Release> releases = new ArrayList<>();
releases.add(new Release().setId("r1").setComponentId("c1"));
releases.add(new Release().setId("r2").setComponentId("c1"));
releases.add(new Release().setId("r3").setComponentId("c1"));
releases.add(new Release().setId("r4").setComponentId("c1"));
releases.add(new Release().setId("r5").setComponentId("c1"));
releases.add(new Release().setId("r6").setComponentId("c1"));
// Create the database
TestUtils.createDatabase(DatabaseSettings.getConfiguredHttpClient(), dbName);
// Prepare the database
DatabaseConnector databaseConnector = new DatabaseConnector(DatabaseSettings.getConfiguredHttpClient(), dbName);
for (Project project : projects) {
databaseConnector.add(project);
}
for (Release r : releases) {
databaseConnector.add(r);
}
databaseConnector.add(new Component("comp1").setId("c1"));
componentHandler = new ComponentDatabaseHandler(DatabaseSettings.getConfiguredHttpClient(), dbName, attachmentsDbName);
handler = new ProjectDatabaseHandler(DatabaseSettings.getConfiguredHttpClient(), dbName, attachmentDbName, moderator, componentHandler);
}
use of org.eclipse.sw360.datahandler.thrift.projects.ProjectRelationship in project sw360portal by sw360.
the class ProjectSpecTest method before.
@Before
public void before() throws TException {
Map<String, ProjectReleaseRelationship> linkedReleases = new HashMap<>();
Map<String, ProjectRelationship> linkedProjects = new HashMap<>();
ProjectReleaseRelationship projectReleaseRelationship = new ProjectReleaseRelationship(CONTAINED, MAINLINE);
List<Project> projectList = new ArrayList<>();
List<Project> projectListByName = new ArrayList<>();
project = new Project();
project.setId("376576");
project.setName("Emerald Web");
project.setProjectType(ProjectType.PRODUCT);
project.setVersion("1.0.2");
project.setDescription("Emerald Web provides a suite of components for Critical Infrastructures.");
project.setCreatedOn("2016-12-15");
project.setCreatedBy("admin@sw360.org");
project.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
project.setBusinessUnit("sw360 AR");
project.setExternalIds(Collections.singletonMap("mainline-id-project", "515432"));
project.setOwnerAccountingUnit("4822");
project.setOwnerCountry("DE");
project.setOwnerGroup("AA BB 123 GHV2-DE");
project.setTag("project test tag 1");
project.setPreevaluationDeadline("2018-07-17");
project.setSystemTestStart("2017-01-01");
project.setSystemTestEnd("2018-03-01");
linkedReleases.put("3765276512", projectReleaseRelationship);
project.setReleaseIdToUsage(linkedReleases);
linkedProjects.put("376576", ProjectRelationship.CONTAINED);
project.setLinkedProjects(linkedProjects);
projectList.add(project);
projectListByName.add(project);
Project project2 = new Project();
project2.setId("376570");
project2.setName("Orange Web");
project2.setVersion("2.0.1");
project2.setProjectType(ProjectType.PRODUCT);
project2.setDescription("Orange Web provides a suite of components for documentation.");
project2.setCreatedOn("2016-12-17");
project2.setCreatedBy("john@sw360.org");
project2.setBusinessUnit("sw360 EX DF");
project2.setOwnerAccountingUnit("5661");
project2.setOwnerCountry("FR");
project2.setOwnerGroup("SIM-KA12");
project2.setTag("project test tag 2");
project2.setPreevaluationDeadline("2018-07-17");
project2.setSystemTestStart("2017-01-01");
project2.setSystemTestEnd("2018-03-01");
project2.setExternalIds(Collections.singletonMap("mainline-id-project", "7657"));
linkedReleases = new HashMap<>();
linkedReleases.put("5578999", projectReleaseRelationship);
project2.setReleaseIdToUsage(linkedReleases);
projectList.add(project2);
Set<String> releaseIds = new HashSet<>(Arrays.asList("3765276512"));
Set<String> releaseIdsTransitive = new HashSet<>(Arrays.asList("3765276512", "5578999"));
given(this.projectServiceMock.getProjectsForUser(anyObject())).willReturn(projectList);
given(this.projectServiceMock.getProjectForUserById(eq(project.getId()), anyObject())).willReturn(project);
given(this.projectServiceMock.searchProjectByName(eq(project.getName()), anyObject())).willReturn(projectListByName);
given(this.projectServiceMock.getReleaseIds(eq(project.getId()), anyObject(), eq("false"))).willReturn(releaseIds);
given(this.projectServiceMock.getReleaseIds(eq(project.getId()), anyObject(), eq("true"))).willReturn(releaseIdsTransitive);
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");
EccInformation eccInformation = new EccInformation();
eccInformation.setEccStatus(ECCStatus.APPROVED);
release.setEccInformation(eccInformation);
release.setCreatedBy("admin@sw360.org");
release.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
release.setComponentId("12356115");
release.setClearingState(ClearingState.APPROVED);
release.setExternalIds(Collections.singletonMap("mainline-id-component", "1432"));
Release release2 = new Release();
release2.setId("5578999");
release2.setName("Spring 1.4.0");
release2.setCpeid("cpe:/a:Spring:1.4.0:");
release2.setReleaseDate("2017-05-06");
release2.setVersion("1.4.0");
release2.setCreatedOn("2017-11-19");
eccInformation.setEccStatus(ECCStatus.APPROVED);
release2.setEccInformation(eccInformation);
release2.setCreatedBy("admin@sw360.org");
release2.setModerators(new HashSet<>(Arrays.asList("admin@sw360.org", "jane@sw360.org")));
release2.setComponentId("12356115");
release2.setClearingState(ClearingState.APPROVED);
release2.setExternalIds(Collections.singletonMap("mainline-id-component", "1771"));
given(this.releaseServiceMock.getReleaseForUserById(eq(release.getId()), anyObject())).willReturn(release);
given(this.releaseServiceMock.getReleaseForUserById(eq(release2.getId()), anyObject())).willReturn(release2);
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);
}
Aggregations