Search in sources :

Example 1 with ReleaseRelationship

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);
                }
            }
        }
    }
}
Also used : ReleaseRelationship(org.eclipse.sw360.datahandler.thrift.ReleaseRelationship) Component(org.eclipse.sw360.datahandler.thrift.components.Component) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Example 2 with ReleaseRelationship

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);
}
Also used : ReleaseRelationship(org.eclipse.sw360.datahandler.thrift.ReleaseRelationship) Component(org.eclipse.sw360.datahandler.thrift.components.Component) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Example 3 with ReleaseRelationship

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));
}
Also used : ReleaseRelationship(org.eclipse.sw360.datahandler.thrift.ReleaseRelationship) Test(org.junit.Test)

Aggregations

ReleaseRelationship (org.eclipse.sw360.datahandler.thrift.ReleaseRelationship)3 Component (org.eclipse.sw360.datahandler.thrift.components.Component)2 Release (org.eclipse.sw360.datahandler.thrift.components.Release)2 Test (org.junit.Test)1