Search in sources :

Example 21 with ThriftClients

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

the class DisplayVendorEdit method doStartTag.

public int doStartTag() throws JspException {
    JspWriter jspWriter = pageContext.getOut();
    namespace = getNamespace();
    StringBuilder display = new StringBuilder();
    try {
        if (vendor == null && !Strings.isNullOrEmpty(vendorId)) {
            VendorService.Iface client;
            try {
                client = new ThriftClients().makeVendorClient();
                vendor = client.getByID(vendorId);
            } catch (TException ignored) {
            }
        }
        if (vendor != null) {
            printFullVendor(display, vendor);
        } else {
            printEmptyVendor(display);
        }
        jspWriter.print(display.toString());
    } catch (Exception e) {
        throw new JspException(e);
    }
    return SKIP_BODY;
}
Also used : VendorService(org.eclipse.sw360.datahandler.thrift.vendors.VendorService) TException(org.apache.thrift.TException) JspException(javax.servlet.jsp.JspException) JspWriter(javax.servlet.jsp.JspWriter) JspException(javax.servlet.jsp.JspException) TException(org.apache.thrift.TException) ThriftClients(org.eclipse.sw360.datahandler.thrift.ThriftClients)

Example 22 with ThriftClients

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

the class LinkedReleaseRenderer method renderReleaseLinkListCompare.

public <T> void renderReleaseLinkListCompare(StringBuilder display, Map<String, T> oldReleaseRelationshipMap, Map<String, T> deleteReleaseRelationshipMap, Map<String, T> updateReleaseRelationshipMap, Set<String> releaseIds) {
    if (releaseIds.isEmpty())
        return;
    StringBuilder candidate = new StringBuilder();
    try {
        ComponentService.Iface componentClient = new ThriftClients().makeComponentClient();
        final HashSet<String> changedIds = new HashSet<>();
        for (String releaseId : releaseIds) {
            T oldReleaseRelationship = oldReleaseRelationshipMap.get(releaseId);
            T updateReleaseRelationship = updateReleaseRelationshipMap.get(releaseId);
            if (!oldReleaseRelationship.equals(updateReleaseRelationship)) {
                changedIds.add(releaseId);
            }
        }
        for (Release release : componentClient.getReleasesById(changedIds, user)) {
            String releaseId = release.getId();
            T oldReleaseRelationship = oldReleaseRelationshipMap.get(releaseId);
            T deleteReleaseRelationship = deleteReleaseRelationshipMap.get(releaseId);
            T updateReleaseRelationship = updateReleaseRelationshipMap.get(releaseId);
            candidate.append(String.format("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>", release.getName(), oldReleaseRelationship, deleteReleaseRelationship, updateReleaseRelationship));
        }
    } catch (TException ignored) {
    }
    String tableContent = candidate.toString();
    if (!tableContent.isEmpty()) {
        display.append(String.format("<table class=\"%s\" id=\"%sUpdated\" >", tableClasses, idPrefix));
        display.append("<thead><tr><th colspan=\"4\">Updated Release Links</th></tr><tr><th>Release name</th><th>Current Release relationship</th><th>Deleted Release relationship</th><th>Suggested release relationship</th></tr></thead><tbody>");
        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) HashSet(java.util.HashSet)

Aggregations

TException (org.apache.thrift.TException)17 User (org.eclipse.sw360.datahandler.thrift.users.User)12 ThriftClients (org.eclipse.sw360.datahandler.thrift.ThriftClients)10 JspException (javax.servlet.jsp.JspException)3 UsedAsLiferayAction (org.eclipse.sw360.portal.common.UsedAsLiferayAction)3 HashMap (java.util.HashMap)2 JspWriter (javax.servlet.jsp.JspWriter)2 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)2 Release (org.eclipse.sw360.datahandler.thrift.components.Release)2 ProjectLink (org.eclipse.sw360.datahandler.thrift.projects.ProjectLink)2 ProjectRelationship (org.eclipse.sw360.datahandler.thrift.projects.ProjectRelationship)2 ProjectService (org.eclipse.sw360.datahandler.thrift.projects.ProjectService)2 UserService (org.eclipse.sw360.datahandler.thrift.users.UserService)2 VendorService (org.eclipse.sw360.datahandler.thrift.vendors.VendorService)2 Before (org.junit.Before)2 Joiner (com.google.common.base.Joiner)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 AttachmentHandler (org.eclipse.sw360.attachments.AttachmentHandler)1 ComponentHandler (org.eclipse.sw360.components.ComponentHandler)1