Search in sources :

Example 36 with Release

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

the class DisplayProjectChanges method renderReleaseIdToUsage.

private void renderReleaseIdToUsage(StringBuilder display, User user) {
    if (ensureSomethingTodoAndNoNullReleaseIdUsage()) {
        Set<String> changedReleaseIds = Sets.intersection(additions.getReleaseIdToUsage().keySet(), deletions.getReleaseIdToUsage().keySet());
        changedReleaseIds = Sets.intersection(changedReleaseIds, // remove projects already deleted in database
        actual.getReleaseIdToUsage().keySet());
        Set<String> removedReleaseIds = Sets.difference(deletions.getReleaseIdToUsage().keySet(), changedReleaseIds);
        removedReleaseIds = Sets.intersection(removedReleaseIds, actual.getReleaseIdToUsage().keySet());
        Set<String> addedReleaseIds = Sets.difference(additions.getReleaseIdToUsage().keySet(), changedReleaseIds);
        LinkedReleaseRenderer renderer = new LinkedReleaseRenderer(display, tableClasses, idPrefix, user);
        renderer.renderReleaseLinkList(display, deletions.getReleaseIdToUsage(), removedReleaseIds, "Removed Release Links");
        renderer.renderReleaseLinkList(display, additions.getReleaseIdToUsage(), addedReleaseIds, "Added Release Links");
        renderer.renderReleaseLinkListCompare(display, actual.getReleaseIdToUsage(), deletions.getReleaseIdToUsage(), additions.getReleaseIdToUsage(), changedReleaseIds);
    }
}
Also used : LinkedReleaseRenderer(org.eclipse.sw360.portal.tags.urlutils.LinkedReleaseRenderer)

Example 37 with Release

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

the class DisplayReleaseChanges 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 (Release._Fields field : Release._Fields.values()) {
            switch(field) {
                // ignored Fields
                case ID:
                case REVISION:
                case TYPE:
                case CREATED_BY:
                case CREATED_ON:
                case PERMISSIONS:
                case DOCUMENT_STATE:
                case COMPONENT_ID:
                case VENDOR_ID:
                case CLEARING_TEAM_TO_FOSSOLOGY_STATUS:
                // Taken care of externally or in extra tables
                case ATTACHMENTS:
                case RELEASE_ID_TO_RELATIONSHIP:
                case CLEARING_INFORMATION:
                case COTS_DETAILS:
                case ECC_INFORMATION:
                    break;
                default:
                    FieldMetaData fieldMetaData = Release.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>";
        }
        StringBuilder releaseRelationshipDisplay = new StringBuilder();
        User user = getUserFromContext("Cannot render release changes without logged in user in request");
        renderReleaseIdToRelationship(releaseRelationshipDisplay, user);
        String clearingInformationDisplay = renderClearingInformation();
        String eccInformationDisplay = renderEccInformation();
        String cotsDetailDisplay = renderCOTSDetails();
        jspWriter.print(renderString + releaseRelationshipDisplay.toString() + clearingInformationDisplay + eccInformationDisplay + cotsDetailDisplay);
    } catch (Exception e) {
        throw new JspException(e);
    }
    return SKIP_BODY;
}
Also used : JspException(javax.servlet.jsp.JspException) FieldMetaData(org.apache.thrift.meta_data.FieldMetaData) User(org.eclipse.sw360.datahandler.thrift.users.User) JspWriter(javax.servlet.jsp.JspWriter) Release(org.eclipse.sw360.datahandler.thrift.components.Release) JspException(javax.servlet.jsp.JspException)

Example 38 with Release

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

the class DisplayReleaseChanges method renderCOTSDetails.

private String renderCOTSDetails() {
    if (!ensureSomethingTodoAndNoNull(Release._Fields.COTS_DETAILS)) {
        return "";
    }
    StringBuilder display = new StringBuilder();
    if (!actual.isSet(Release._Fields.COTS_DETAILS)) {
        actual.cotsDetails = new COTSDetails();
    }
    for (COTSDetails._Fields field : COTSDetails._Fields.values()) {
        FieldMetaData fieldMetaData = COTSDetails.metaDataMap.get(field);
        displaySimpleFieldOrSet(display, actual.getCotsDetails(), additions.getCotsDetails(), deletions.getCotsDetails(), field, fieldMetaData, "");
    }
    return "<h3> Changes in COTS Details </h3>" + String.format("<table class=\"%s\" id=\"%schanges\" >", tableClasses, idPrefix) + String.format("<thead><tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr></thead><tbody>", FIELD_NAME, CURRENT_VAL, DELETED_VAL, SUGGESTED_VAL) + display.toString() + "</tbody></table>";
}
Also used : FieldMetaData(org.apache.thrift.meta_data.FieldMetaData) COTSDetails(org.eclipse.sw360.datahandler.thrift.components.COTSDetails)

Example 39 with Release

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

the class DisplayReleaseChanges method renderClearingInformation.

private String renderClearingInformation() {
    if (!ensureSomethingTodoAndNoNull(Release._Fields.CLEARING_INFORMATION)) {
        return "";
    }
    StringBuilder display = new StringBuilder();
    if (!actual.isSet(Release._Fields.CLEARING_INFORMATION)) {
        actual.clearingInformation = new ClearingInformation();
    }
    for (ClearingInformation._Fields field : ClearingInformation._Fields.values()) {
        FieldMetaData fieldMetaData = ClearingInformation.metaDataMap.get(field);
        displaySimpleFieldOrSet(display, actual.getClearingInformation(), additions.getClearingInformation(), deletions.getClearingInformation(), field, fieldMetaData, "");
    }
    return "<h3> Changes in Clearing Information </h3>" + String.format("<table class=\"%s\" id=\"%schanges\" >", tableClasses, idPrefix) + String.format("<thead><tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr></thead><tbody>", FIELD_NAME, CURRENT_VAL, DELETED_VAL, SUGGESTED_VAL) + display.toString() + "</tbody></table>";
}
Also used : FieldMetaData(org.apache.thrift.meta_data.FieldMetaData) ClearingInformation(org.eclipse.sw360.datahandler.thrift.components.ClearingInformation)

Example 40 with Release

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

the class LinkedReleaseRenderer method renderReleaseLinkList.

public <T> void renderReleaseLinkList(StringBuilder display, Map<String, T> releaseRelationshipMap, Set<String> releaseIds, String msg) {
    if (releaseIds.isEmpty())
        return;
    StringBuilder candidate = new StringBuilder();
    try {
        ComponentService.Iface componentClient = new ThriftClients().makeComponentClient();
        for (Release release : componentClient.getReleasesById(releaseIds, user)) {
            candidate.append(String.format("<tr><td>%s</td><td>%s</td></tr>", release.getName(), releaseRelationshipMap.get(release.getId())));
        }
    } 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>Release name</th><th>Release relationship</th></tr></thead><tbody>", msg));
        display.append(tableContent);
        display.append("</tbody></table>");
    }
}
Also used : TException(org.apache.thrift.TException) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) Release(org.eclipse.sw360.datahandler.thrift.components.Release) ThriftClients(org.eclipse.sw360.datahandler.thrift.ThriftClients)

Aggregations

Release (org.eclipse.sw360.datahandler.thrift.components.Release)93 User (org.eclipse.sw360.datahandler.thrift.users.User)39 TException (org.apache.thrift.TException)34 Test (org.junit.Test)22 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)20 Component (org.eclipse.sw360.datahandler.thrift.components.Component)18 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)15 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)13 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)13 FossologyStatus (org.eclipse.sw360.datahandler.thrift.components.FossologyStatus)11 TestUtils.assertTestString (org.eclipse.sw360.datahandler.TestUtils.assertTestString)10 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)9 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)9 HalResource (org.eclipse.sw360.rest.resourceserver.core.HalResource)7 Before (org.junit.Before)7 Collectors (java.util.stream.Collectors)6 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)6 FilledAttachment (org.eclipse.sw360.datahandler.thrift.attachments.FilledAttachment)6 IOException (java.io.IOException)5 java.util (java.util)5