Search in sources :

Example 76 with Component

use of org.eclipse.sw360.datahandler.thrift.components.Component 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 77 with Component

use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.

the class ComponentAttachmentCSVRecordBuilderTest method testFillComponent.

@Test
public void testFillComponent() throws Exception {
    final String componentName = "myCompo";
    final Component component = new Component();
    component.setName(componentName);
    final ComponentAttachmentCSVRecordBuilder componentAttachmentCSVRecordBuilder = new ComponentAttachmentCSVRecordBuilder();
    componentAttachmentCSVRecordBuilder.fill(component);
    final ComponentAttachmentCSVRecord filledRecord = componentAttachmentCSVRecordBuilder.build();
    assertThat(filledRecord.getComponentName(), is(componentName));
}
Also used : Component(org.eclipse.sw360.datahandler.thrift.components.Component) Test(org.junit.Test)

Example 78 with Component

use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.

the class ReleaseLinkCSVRecordBuilderTest method testFillComponent.

@Test
public void testFillComponent() throws Exception {
    final String componentName = "myCompo";
    final Component component = new Component();
    component.setName(componentName);
    final ReleaseLinkCSVRecordBuilder releaseLinkCSVRecordBuilder = new ReleaseLinkCSVRecordBuilder();
    releaseLinkCSVRecordBuilder.fill(component);
    final ReleaseLinkCSVRecord filledRecord = releaseLinkCSVRecordBuilder.build();
    assertThat(filledRecord.getComponentName(), is(componentName));
}
Also used : Component(org.eclipse.sw360.datahandler.thrift.components.Component) Test(org.junit.Test)

Example 79 with Component

use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.

the class DisplayComponentChanges method doStartTag.

public int doStartTag() throws JspException {
    JspWriter jspWriter = pageContext.getOut();
    StringBuilder display = new StringBuilder();
    String namespace = getNamespace();
    if (additions == null || deletions == null) {
        return SKIP_BODY;
    }
    try {
        for (Component._Fields field : Component._Fields.values()) {
            switch(field) {
                // ignored Fields
                case ID:
                case REVISION:
                case TYPE:
                case CREATED_BY:
                case CREATED_ON:
                case PERMISSIONS:
                case DOCUMENT_STATE:
                // Releases and aggregates:
                case RELEASES:
                case RELEASE_IDS:
                case MAIN_LICENSE_IDS:
                case LANGUAGES:
                case OPERATING_SYSTEMS:
                case VENDOR_NAMES:
                // Taken care of externally
                case ATTACHMENTS:
                    break;
                default:
                    FieldMetaData fieldMetaData = Component.metaDataMap.get(field);
                    displaySimpleFieldOrSet(display, actual, additions, deletions, field, fieldMetaData, "");
            }
        }
        String renderString = display.toString();
        if (Strings.isNullOrEmpty(renderString)) {
            renderString = "<h4> No changes in basic fields </h4>";
        } else {
            renderString = String.format("<table class=\"%s\" id=\"%schanges\" >", tableClasses, idPrefix) + "<thead><tr><th colspan=\"4\"> Changes for Basic fields</th></tr>" + String.format("<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr></thead><tbody>", FIELD_NAME, CURRENT_VAL, DELETED_VAL, SUGGESTED_VAL) + renderString + "</tbody></table>";
        }
        jspWriter.print(renderString);
    } catch (Exception e) {
        throw new JspException(e);
    }
    return SKIP_BODY;
}
Also used : JspException(javax.servlet.jsp.JspException) FieldMetaData(org.apache.thrift.meta_data.FieldMetaData) JspWriter(javax.servlet.jsp.JspWriter) Component(org.eclipse.sw360.datahandler.thrift.components.Component) JspException(javax.servlet.jsp.JspException) TException(org.apache.thrift.TException)

Example 80 with Component

use of org.eclipse.sw360.datahandler.thrift.components.Component in project sw360portal by sw360.

the class ReleaseLinkCSVRecordBuilderTest method testFillLinkedComponent.

@Test
public void testFillLinkedComponent() throws Exception {
    final String componentName = "myCompo";
    final Component component = new Component();
    component.setName(componentName);
    final ReleaseLinkCSVRecordBuilder releaseLinkCSVRecordBuilder = new ReleaseLinkCSVRecordBuilder();
    releaseLinkCSVRecordBuilder.fillLinking(component);
    final ReleaseLinkCSVRecord filledRecord = releaseLinkCSVRecordBuilder.build();
    assertThat(filledRecord.getLinkedComponentName(), is(componentName));
}
Also used : Component(org.eclipse.sw360.datahandler.thrift.components.Component) Test(org.junit.Test)

Aggregations

Component (org.eclipse.sw360.datahandler.thrift.components.Component)38 User (org.eclipse.sw360.datahandler.thrift.users.User)30 TException (org.apache.thrift.TException)23 Release (org.eclipse.sw360.datahandler.thrift.components.Release)23 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)10 TestUtils.assertTestString (org.eclipse.sw360.datahandler.TestUtils.assertTestString)8 Before (org.junit.Before)7 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)6 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)5 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)5 IOException (java.io.IOException)4 DatabaseConnector (org.eclipse.sw360.datahandler.couchdb.DatabaseConnector)4 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)4 Test (org.junit.Test)4 ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)3 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)3 FluentIterable (com.google.common.collect.FluentIterable)2 LiferayPortletURL (com.liferay.portal.kernel.portlet.LiferayPortletURL)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2