Search in sources :

Example 41 with Release._Fields

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

the class DisplayProjectChanges 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 (Project._Fields field : Project._Fields.values()) {
            switch(field) {
                // ignored Fields
                case ID:
                case REVISION:
                case TYPE:
                case CREATED_BY:
                case CREATED_ON:
                case PERMISSIONS:
                case RELEASE_CLEARING_STATE_SUMMARY:
                case DOCUMENT_STATE:
                // Taken care of externally
                case ATTACHMENTS:
                // Done in extra tables
                case LINKED_PROJECTS:
                case RELEASE_ID_TO_USAGE:
                    break;
                default:
                    FieldMetaData fieldMetaData = Project.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 linkedProjectsDisplay = new StringBuilder();
        User user = getUserFromContext("Cannot render project changes without logged in user in request");
        renderLinkedProjects(linkedProjectsDisplay, user);
        StringBuilder releaseUsageDisplay = new StringBuilder();
        renderReleaseIdToUsage(releaseUsageDisplay, user);
        jspWriter.print(renderString + linkedProjectsDisplay.toString() + releaseUsageDisplay.toString());
    } catch (Exception e) {
        throw new JspException(e);
    }
    return SKIP_BODY;
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) 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) JspException(javax.servlet.jsp.JspException) TException(org.apache.thrift.TException)

Example 42 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields 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 43 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields 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 44 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields 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 45 with Release._Fields

use of org.eclipse.sw360.datahandler.thrift.components.Release._Fields 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)

Aggregations

Release (org.eclipse.sw360.datahandler.thrift.components.Release)93 User (org.eclipse.sw360.datahandler.thrift.users.User)42 TException (org.apache.thrift.TException)38 Test (org.junit.Test)23 Component (org.eclipse.sw360.datahandler.thrift.components.Component)20 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)20 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)17 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)13 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)13 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)12 FieldMetaData (org.apache.thrift.meta_data.FieldMetaData)11 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 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