use of org.eclipse.sw360.datahandler.thrift.ReleaseRelationship in project sw360portal by sw360.
the class ComponentUploadPortlet method dealWithReleaseLinksContainedInRelease.
private void dealWithReleaseLinksContainedInRelease(Map<String, Component> componentsById, Map<String, Release> releasesById, Component component, Release release, List<Iterable<String>> csvRows) throws IOException {
final Map<String, ReleaseRelationship> releaseIdToRelationship = release.getReleaseIdToRelationship();
if (releaseIdToRelationship != null) {
for (Map.Entry<String, ReleaseRelationship> idReleaseRelationshipEntry : releaseIdToRelationship.entrySet()) {
final Release linkedRelease = releasesById.get(idReleaseRelationshipEntry.getKey());
if (linkedRelease != null) {
final ReleaseRelationship relationship = idReleaseRelationshipEntry.getValue();
final Component linkedComponent = componentsById.get(linkedRelease.getComponentId());
if (linkedComponent != null) {
printReleaseLinkEntry(component, release, linkedRelease, relationship, linkedComponent, csvRows);
}
}
}
}
}
use of org.eclipse.sw360.datahandler.thrift.ReleaseRelationship in project sw360portal by sw360.
the class ComponentImportUtils method writeReleaseLinksToDatabase.
public static RequestSummary writeReleaseLinksToDatabase(FluentIterable<ReleaseLinkCSVRecord> csvRecords, ComponentService.Iface componentClient, User user) throws TException {
final List<Component> componentDetailedSummaryForExport = componentClient.getComponentDetailedSummaryForExport();
final Map<String, Release> releasesByIdentifier = getReleasesByIdentifier(componentDetailedSummaryForExport);
final Set<String> releasesIdentifiersToBeUpdated = new HashSet<>();
for (ReleaseLinkCSVRecord csvRecord : csvRecords) {
final String releaseIdentifier = csvRecord.getReleaseIdentifier();
final String linkedReleaseIdentifier = csvRecord.getLinkedReleaseIdentifier();
final ReleaseRelationship relationship = csvRecord.getRelationship();
if (releaseIdentifier != null && linkedReleaseIdentifier != null && relationship != null) {
final Release release = releasesByIdentifier.get(releaseIdentifier);
final Release linkedRelease = releasesByIdentifier.get(linkedReleaseIdentifier);
if (release != null && linkedRelease != null) {
final Map<String, ReleaseRelationship> releaseIdToRelationship = getRelationshipMap(release);
releaseIdToRelationship.put(linkedRelease.getId(), relationship);
release.setReleaseIdToRelationship(releaseIdToRelationship);
releasesIdentifiersToBeUpdated.add(releaseIdentifier);
}
}
}
final HashSet<Release> updatedReleases = getUpdatedReleases(releasesByIdentifier, releasesIdentifiersToBeUpdated);
return componentClient.updateReleases(updatedReleases, user);
}
use of org.eclipse.sw360.datahandler.thrift.ReleaseRelationship in project sw360portal by sw360.
the class ReleaseLinkCSVRecordBuilderTest method testReleaseReleationship.
@Test
public void testReleaseReleationship() throws Exception {
final ReleaseRelationship releaseRelationship = ReleaseRelationship.CONTAINED;
final ReleaseLinkCSVRecordBuilder releaseLinkCSVRecordBuilder = new ReleaseLinkCSVRecordBuilder();
releaseLinkCSVRecordBuilder.setRelationship(releaseRelationship);
final ReleaseLinkCSVRecord filledRecord = releaseLinkCSVRecordBuilder.build();
assertThat(filledRecord.getRelationship(), is(releaseRelationship));
}
Aggregations